开发者

CROSS APPLY with encrypted column converted to XML

I am trying to put this Decompress CLR function to work with CROSS APPLY but so far I had not success. The Decompress functions works fine. The problem is开发者_Go百科 to Decompress the column and call .nodes function as shown below. Please, if anyone could help me with that would be great.

SELECT
T0.Chassis.value('Model', 'varchar(50)')
FROM ANYTABLE c 
CROSS APPLY CAST( dbo.Decompress( CAST(content AS nvarchar(max)) ) AS xml).nodes('this part is correct') AS T0(Chassis)


You need to split your cast to XML and the .nodes part.

SELECT T0.Chassis.value('Model', 'varchar(50)')
FROM ANYTABLE c 
  CROSS APPLY (select CAST( dbo.Decompress( CAST(content AS nvarchar(max)) ) AS xml)) as T(X)
  CROSS APPLY T.X.nodes('this part is correct') AS T0(Chassis)


Thanks Mikael but I´ve found the answer:

According to the microsoft documentation:

The nodes() function cannot be applied directly to the results of a user-defined function. To use the nodes() function with the result of a scalar user-defined function, you can either assign the result of the user-defined function to a variable or use a derived table to assign a column alias to the user-defined function return value and then use CROSS APPLY to select from the alias.

http://msdn.microsoft.com/en-us/library/ms188282(v=SQL.90).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜