Thursday, February 9, 2012

Attach text files into sql server table

Is there a way i can attach multiple text files into a single sql server table. Or what are the options for attaching multiple text files into sql server?

Please advise.

Thanks

You can use

BULK INSERT

bcp

Import Export Wizard

See SQL Server 2005 Books Online topics:

BULK INSERT (Transact-SQL)

http://msdn2.microsoft.com/en-us/library/ms188365.aspx

bcp Utility

http://msdn2.microsoft.com/en-us/library/ms162802.aspx

SQL Server Import and Export Wizard F1 Help

http://msdn2.microsoft.com/en-us/library/ms188032.aspx

|||

There is no way to 'attach' a text file to SQL Server. You can, however, import the data from a text file into a SQL Server table -recognizing that any modifications will NOT be available to that text file, they are only in the server table. You can also export data from a SQL Server table to a text file.

But these are not inconsequential activities.

|||I know how to import single text file data into sql server table, but i have multiple text files. So how can i import all those at once?|||

In 2005 you can use SSIS...It has a loop task inside of which you could put an import task.

You could write a script, vbscript, that looped through a directory and used the sqlcmd utility to import each file.

No comments:

Post a Comment