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)
 Apostrophe Problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-05 : 09:52:16
Sai writes "Hi,
I'll get straight to the Problem. I have an Apostrophe in the Variable. I use a Execute() in the stored procedure to Build my query. This fails Even after I do something like
fStory = replace ( fStory ,"'","''") in ASP.
I even tried fStory = replace ( fStory ,"'","''''"), hoping that the execute will need another apostrophe, but i guess that the string building is failing due to the apostrophes, maybe it is expecting a '+' in between for concatenation.
How do I resolve this problem ?
Thanks.

I am pasting the Query below.
execute ('
INSERT INTO tblRegisteredUser
( ' + @SVC + '
, EmailAddress
, FirstName
, LastName
, OrganizationName
, Title
, City
, State
, WorkNumber
, RegistrationDate
, CostCenter
, UserId)
VALUES (' + '''' + '1' + '''' + ', ' +
'''' + @EMailAddress + '''' + ', ' +
'''' + @FirstName + '''' + ', ' +
'''' + @LastName + '''' + ', ' +
'''' + @Dept + '''' + ', ' +
'''' + @Title + '''' + ', ' +
'''' + @City + '''' + ', ' +
'''' + @State + '''' + ', ' +
'''' + @WorkNumber + '''' + ', ' +
'convert(varchar,GETDATE())' + ', ' +
'''' + 'iPortal' + '''' + ', ' +
'''' + @uid + '''' + ')'
)

The '@EmailAddress' has the Apostrophe. In between, this code is written by someone i don't know, and i am the support person trying to debug this undocummented code."
   

- Advertisement -