June 21, 2010 at 8:11 am
Hi Experts,
I am loading a text file to a sql server database. Text file has TAB as a field terminator and LINE FEED (LF) as row terminator. Iwanted to verify is below syntax is correct?
BULK INSERT dbo.test
FROM 'F:\test.txt'
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '0x0a', -- OR ,ROWTERMINATOR = ' + CHAR(10) + '
KEEPNULLS,
firstrow =2
);
June 21, 2010 at 9:12 am
See this article: http://msdn.microsoft.com/en-us/library/ms191485.aspx
You should use backslash n to indicate a linefeed row terminator
June 21, 2010 at 9:38 am
Since both of those are the default terminator values, all you need is:
BULK INSERT dbo.test
FROM 'F:\test.txt'
WITH (
DATAFILETYPE = 'char',
KEEPNULLS,
firstrow =2
);
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply