dbTalk Databases Forums  

Qouted String

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Qouted String in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Khan
 
Posts: n/a

Default Qouted String - 05-13-2006 , 09:33 AM






Hi all,
I have a string user_name and it is saved in table with single

qoutes, i mean if you view the table there are single qoutes on both
sides of user_name like 'amir', it is saved with single qoutes. The
problem is how can i write sql query with = comparison, i'm
using
select * from sasuser.Followup where user_name= ' 'amir ' ';.

I need to use single qoutes for the query, coz variable is string but
how can i use single qoutes which are with the name itself.


Thanx.


Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Qouted String - 05-13-2006 , 10:42 AM






Khan (amir (AT) programmer (DOT) net) writes:
Quote:
I have a string user_name and it is saved in table with single
qoutes, i mean if you view the table there are single qoutes on both
sides of user_name like 'amir', it is saved with single qoutes. The
problem is how can i write sql query with = comparison, i'm
using
select * from sasuser.Followup where user_name= ' 'amir ' ';.

I need to use single qoutes for the query, coz variable is string but
how can i use single qoutes which are with the name itself.
To include the string delimiter in a string literal you need to double
it:

SELECT * FROM sasuser.Followup WHERE user_name = '''amit''';

Note that when you work from client code, you should use parameterised
SQL commands, which makes this a non-issue..


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #3  
Old   
Khan
 
Posts: n/a

Default Re: Qouted String - 05-14-2006 , 12:59 AM



thanx erland,, its fine now.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.