Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Text Qualifier During BULK INSERT

Status
Not open for further replies.

SQLBI

IS-IT--Management
Jul 25, 2003
988
GB
Hi,

I'm attempting to use BULK INSERT to import data from a .txt file to a table in my DB.

The problem i'm having is that despite working correctly, the data in the SQL table is imported together with its text qualifier, in this case ".

My code is as follows:

Code:
SET NOCOUNT ON
GO

TRUNCATE TABLE Client_Raw
GO


DECLARE @Practice int
DECLARE @File varchar(255)
DECLARE @SQL varchar(8000)

SET @Practice = 101
SET @File = 'E:\RxWorks\DataExtracts\' + CONVERT(char(3), @Practice) + '_C_Data.txt'

PRINT @File

SET @SQL = N'BULK INSERT Marketing..Client_Raw
		FROM ''' + @File + ''' 
				WITH 
				(	
				FIELDTERMINATOR = ' +  ''',''' + ', 
				ROWTERMINATOR = ' + '''\n''' + ',
				FIRSTROW = 2,
				KEEPNULLS
			        )'

PRINT @SQL

EXEC (@SQL)

GO
SET NOCOUNT OFF

One would expect that the BULK INSERT statement would have a 'TEXTQUALIFIER' property, afterall it has 'FIELDTERMINATOR' and 'ROWTERMINATOR' etc

By using the import/export wizard, i'm able to specify a text qualifier and the data is inserted correctly, is there a way to accomplish the same using BULK INSERT or am i going to have to remove the " after the import?

Any help would be appreciated.


Cheers,
Leigh

Sure, if it has a microchip in it, it must be IT... Now what seems to be the problem with your toaster...?
 
Hi Denis,

No unfortunately that didn't work.

Thanks anyway.

Cheers,
Leigh

Sure, if it has a microchip in it, it must be IT... Now what seems to be the problem with your toaster...?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top