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
 General SQL Server Forums
 New to SQL Server Programming
 Sql statement with multiple single quotations

Author  Topic 

issammansour
Yak Posting Veteran

51 Posts

Posted - 2007-04-19 : 15:24:35
>Hi,
>
>Thanks you for quick answer but we still the same problem special with names like the following exmple:

DECLARE @L_SQLCOMM VARCHAR(8000)

SET @L_SQLCOMM = 'SELECT * FROM AMASTER where ACCTNAME = (ala'a)'

EXEC(@L_SQLCOMM

"ala'a " is Arabic name in English characters.

Regards

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-19 : 15:37:58
Why are you using EXEC? You should not be using dynamically created sql statements unless it is a last resort.

Either way, the cost you've posted has lots of errors; missing parenthesis after the EXEC() and missing quotes in your string literal.

Anyway, in your case, all you need is:

SELECT * FROM AMASTER where ACCTNAME = '(ala''a)'

notice that you simple double the single quotes to indicate a single quote within a string.


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

issammansour
Yak Posting Veteran

51 Posts

Posted - 2007-04-19 : 15:40:06
i het the following:
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'a'.
Msg 105, Level 15, State 1, Line 5
Unclosed quotation mark after the character string '

EXEC(@L_SQLCOMM
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-19 : 19:43:57
[code]
DECLARE @L_SQLCOMM VARCHAR(8000)

SET @L_SQLCOMM = 'SELECT * FROM AMASTER where ACCTNAME = ''(ala''a)'''

EXEC(@L_SQLCOMM)
[/code]


KH

Go to Top of Page
   

- Advertisement -