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 Usage

Author  Topic 

bobbabuoy
Starting Member

33 Posts

Posted - 2004-06-14 : 06:28:44
Ok, I still have some uncertainty as to just exactly how this whole apostrophe thing works with databases. I understand that it is a reserved character and so when a sql query runs into one of these creatures it looks at it as something other than a normal character.

I am working primarily in vb/asp/sql server with a little bit of access. I am familiar with the instrinsic 'Replace' function and I use it but I still have occassional problems.

I would like any information I can get on just exactly why/how this thing works and how to work-around the apostrophe when writing to, reading from, and validating data from sql server/access/any databases.

Thanks!

gpl
Posting Yak Master

195 Posts

Posted - 2004-06-14 : 06:37:25
it is a string delimiter, the same as in VB
if you want to use a " in a VB string, you would do this
"""Help"" he said"
Its the same in SQL, except it is a single quote
so if you have the name O'Brian, you would use 'O''Brian'
In your stored procedures, just ensure that all your string parameters are modified to say
Set @Param = Replace(@Param, '''', '''''')

When you read stuff back, the correct number of quotes will appear in the string where necessary
Graham
Go to Top of Page
   

- Advertisement -