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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 quoted_identifier

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-18 : 08:30:31
Scott Scriver writes "SQL7.0, NT4.0
I cannot seem to find way around this. Here is my code:

I have a text file that is comma delimited with quotes around the strings. The Text file looks like this:

1,2,3,"FirstName","LastName","NickName"
2,3,4,"FirstName","LastName","NickName"
EOF

I then have a statement that loops through the file, grabs the entire line and puts it in the database:

strData = oTS.ReadLine
If LCase(Mid(strData, 1, 3)) <> "eof" Then
SQL = "set quoted_identifier off " + _
"INSERT INTO TABLE (Value1, Value2, Value3, String1, String2, String3) VALUES (" & strData & ")"
RunSQL gsConnect, SQL
End If

All works great until this:

1,2,3,"FirstName","LastName",""Nick" Name"
2,3,4,"FirstName","LastName","NickName"

Notice Line 1 has quotes around Nick. I get the following error:

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'Nick'.

The code handles single quotes just fine, but double quotes, it chokes!

Any suggestions? I am trying to avoid having to physically parse the entire line.

"
   

- Advertisement -