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.Khan (amir@.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, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||thanx erland,, its fine now.
No comments:
Post a Comment