ODBC guide

Bulk create sheet rows using SQL Server data


Bulk creates rows in a sheet by reading data from an external SQL Server database using the SOURCE clause. Column names must match the target sheet's column names.

INSERT INTO [My Sheet]
SOURCE(   'MSSQL'--OR 'ODBC'--OR 'OLEDB'
        , 'Data Source=localhost;Initial Catalog=tempdb;Integrated Security=true'
		--OR for ODBC
		--,'DSN=MyOdbcDsn'
		--OR (DSN less connection)
		--,'Driver={Some ODBC Driver};uid=xxx;pwd=xxx;prop1=xxx;prop2=xxx....'
        , 'SELECT ''2012-12-31'' [Some Date Column],''true'' [Some CheckBox Column],''Good example'' [Some Text Column]
           UNION 
		   SELECT ''2012-13-31'' [Some Date Column],''false'' [Some CheckBox Column],''Bad date example'' [Some Text Column]
           UNION 
		   SELECT ''2012-10-01'' [Some Date Column],''true'' [Some CheckBox Column],''Good example'' [Some Text Column]
        ')
--WITH(AllowPartialSuccess='true',output=1)