September 18, 2007 at 1:56 am
Hi all,
Will the CTE executes a Dynamic SQl.
Please help me for the following.
For Ex:
With Cte as
(
Set @CntSQL = 'SELECT * FROM (SELECT A.Companyid,A.Category
FROM ' + @Name + '.DBO.TABLE A join ' + @@Name + '.dbo.TAble B
On A.Category = B.CategoryUsed) o PIVOT
(COUNT(Category) FOR Category IN (
Exec (@CntSQL)
)
Thanks,
Nithyapriya
R
September 18, 2007 at 2:43 am
The real question is "Why do you think you need a CTE for this?".
See http://www.sommarskog.se/dynamic_sql.html before you enter the land of denormalization.
N 56°04'39.16"
E 12°55'05.25"
September 18, 2007 at 2:52 am
BOL says that select expression in CTE has to meet same requirements as the one for view, so no dynamic SQL inside.
...and your only reply is slàinte mhath
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply