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.
| 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 quotesselect {[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)" ) = -1But 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''MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|