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 2005 Forums
 Transact-SQL (2005)
 single quotes in stored procedure input parameters

Author  Topic 

safderalimd
Starting Member

32 Posts

Posted - 2008-07-02 : 13:49:14
How can I handle single quotes that are passed in as part of input parameters to SQL stored procedure.

For example if I have a stored proc to insert employee data and column value for name may or may not have single quote in it.

INput parameter value:

Sample 1) @name = 'sam'

Sample 2) @name = 'sam's'

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-02 : 13:51:46
Double the single quote

'sam''s'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-02 : 13:55:01
or use QUOTENAME function
Go to Top of Page

safderalimd
Starting Member

32 Posts

Posted - 2008-07-02 : 13:55:41
You mean, calling applicaiton program weather it might be PHP, ASP or JAVA should take care of replacing single quote with double quote before calling stored procedure?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-02 : 13:57:29
quote:
Originally posted by safderalimd

You mean, calling applicaiton program weather it might be PHP, ASP or JAVA should take care of replacing single quote with double quote before calling stored procedure?


Yes it is

Note that thats not double quote, single quote entered twice

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -