Category: CSV
-
Replace Blank CELLs with NULL Value
SELECT ‘UPDATE table SET [‘ + name + ‘] = NULL WHERE [‘ + name + ‘] = ””;’ FROM syscolumns WHERE id = object_id(‘table’) AND isnullable = 1;
-
Import CSV using “Microsoft Access Database Engine 2010” to SQL Server
[SQL] sp_configure ‘Ad Hoc Distributed Queries’, 1 reconfigure with override SET NOCOUNT ON EXEC master..xp_cmdshell ‘del C:\Temp\Schema.ini’ EXEC master..xp_cmdshell ‘echo [Test.txt] > C:\Temp\Schema.ini’ EXEC master..xp_cmdshell ‘echo ColNameHeader=True >> C:\Temp\Schema.ini’ EXEC master..xp_cmdshell ‘echo Format=Delimited(^|) >> C:\Temp\Schema.ini’ EXEC master..xp_cmdshell ‘echo MaxScanRows=50 >> C:\Temp\Schema.ini’ EXEC master..xp_cmdshell ‘echo CharacterSet=OEM >> C:\Temp\Schema.ini’ EXEC master..xp_cmdshell ‘echo Col1=ID TEXT >> C:\Temp\Schema.ini’ EXEC…