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 2000 Forums
 Transact-SQL (2000)
 Double quotes inside double quotes

Author  Topic 

delpiero
Yak Posting Veteran

98 Posts

Posted - 2005-08-11 : 22:18:09
Hi all,

I encountered a pretty complicated dynamic SQL as below:

set @SQL = ' select * from openquery(MyLinkedServer, "WITH MEMBER [measures].[COST] as '' -- 2 single quotes
iif( val [Customer].CurrentMember.Properties(credited) ) = -1, [measures].[net],[measures].[gross] ) '' -- 2 single quotes
select {[Customer].[Cust_name].members} on columns,
{[measures].[COST]} on rows from [MyCube]
where [Product].[Product_ID].[' + @Prod_ID + '] ") '

exec(@SQL)

The above query looks OK. Only the quotes before WITH MEMBER and the last quote before closing bracket, are double quotes.
However, the correct usage of the above query is that I need to add a pair of double quotes for the property name credited, making it [Customer].CurrentMember.Properties("credited)" ) = -1
But as I am already using double quotes for the argument in openquery, and single quotes for the dynamic SQL, I can't figure out any method to add this pair of double quotes into the dynamic SQL.
We can use 2 single quotes inside a quoted string to denote a single quote inside the string, but what about double quotes?
Can anyone help me?

Lots of thanks,
delpiero

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-12 : 01:01:39
>>but what about double quotes?

Declare @t varchar(10)
Set @t= '''test'''
select @t -- Result is 'test'
Set @t= '''''test'''''
select @t -- Result is ''test''


Madhivanan

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

- Advertisement -