Groups | Blog | Home
all groups > sql server new users > may 2006 >

sql server new users : INSERT INTO Query


RC-
5/17/2006 2:12:17 PM
I have a list of values that I need to insert into a SQL table. The list of
values is stored in a .txt file. What would be the syntax of the insert into
query be and how would I reference the .txt file. Or, is there a better way
to get the values added to the table?

TIA,
RC-

Hugo Kornelis
5/17/2006 11:58:01 PM
[quoted text, click to view]

Hi RC,

Check out the BULK INSERT statement in Books Online. Way too much
options to describe in a usenet post.

Or alternatively, consider using bcp.exe (the external broother of BULK
INSERT). Or SSIS (SQL Server 2005) or its predecessor DTS (SQL Server
2000).

--
SQL
5/18/2006 6:34:18 AM
And one more option in addition to the ones that Hugo mentioned

INSERT INTO TableName
SELECT * FROM OPENROWSET('MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)};
DefaultDir=C:\;',
'select * from FileName.txt')

But BULK INSERT/bcp will be the fastest


Denis the SQL Menace
http://sqlservercode.blogspot.com/
RC-
5/18/2006 8:27:52 AM
Thank you for the replies. I didn't even know where to start!

[quoted text, click to view]

AddThis Social Bookmark Button