Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AnimalMagic
Starting Member
28 Posts |
Posted - 2007-10-24 : 07:32:08
|
I am trying to insert a text document into sql which contains single quotes, therefore i cant copy and paste it into a string or anything and read it in that way. What is the best way that i can get this information in? |
|
Williem
Starting Member
3 Posts |
Posted - 2007-10-24 : 07:52:43
|
You can use :DECLARE @SQL NVARCHAR(500) DECLARE @FILE_NAME NVARCHAR(50)SET @SQL= 'BULK INSERT TABLE_NAME FROM ''c:\' + @FILE_NAME + ''' WITH (CODEPAGE = ''1250'', FIELDTERMINATOR = '','') ' EXEC(@SQL)UPDATE TABLE_NAME SET COLUMN_NAME = CONVERT(NVARCHAR(50), REPLACE(COLUMN_NAME, '"',''))TABLE_NAME IS TABLE IN SQL SERVER DATABASE -- ISN'T POSSIBLE #TABLE |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-24 : 07:54:56
|
"which contains single quotes, therefore i cant copy and paste it into a string or anything and read it in that way"You can double-up any embedded single quotes:INSERT INTO MyTable(MyColumn) VALUES('foo''bar') Kristen |
|
|
|
|
|