By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,266 Members | 1,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,266 IT Pros & Developers. It's quick & easy.

Qouted String

P: n/a
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.

May 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Khan (am**@programmer.net) writes:
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, es****@sommarskog.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
May 13 '06 #2

P: n/a
thanx erland,, its fine now.

May 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.