Importing A Txt File Into Sql Server With A Where Clause
I have a .txt file which is 6.00 GB. It is a tab-delimited file so when I try to load it into SQL Server, the column delimiter is tab. I need to load that .txt file into the datab
Solution 1:
Have you tried with BULK INSERT command? Take a look at this solution:
--Create temporary tableCREATETABLE #BulkTemporary
(
Id int,
Valuevarchar(10)
)
--BULK INSERT has no WHERE clause
BULK INSERT #BulkTemporary FROM'D:\Temp\File.txt'WITH (FIELDTERMINATOR ='\t', ROWTERMINATOR ='\n')
--Filter resultsSELECT*INTO MyTable FROM #BulkTemporary WHEREValueIN ('Row2', 'Row3')
--Drop temporary tableDROPTABLE #BulkTemporary
Hope this helps.
Post a Comment for "Importing A Txt File Into Sql Server With A Where Clause"