Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Dynamic sql from table

$
0
0
You cannot vote on your own post
0

Hi,

I have a Hierarchic  table  T like this :

ID     Caption      Table        Id_Dim
-----------------------------------------
1         A           [DimA]         NULL
2         B           [DimB]         id_A
3         C           [DimC]         id_B

How can generate this SQL from the table T ?

SELECT * FROM [DimA] -- Level 1
SELECT * FROM [DimB] WHERE  id_A =@id_A -- Level 2
SELECT * FROM [DimC] WHERE  id_A =@id_A AND id_B=@id_B -- Level 3

thx for help


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>