Home » SQL ServerRSS

Using 'UNIQUE' in CTE......

Hi,

I am using CTE instead of a TABLE in my stored proc. Before when I was using TABLE, while declaring the fields for that table, I am specifying UNIQUE for two columns....but when I try to use same in CTE, it gives an error.....

Is it possible to use UNIQUE in CTE........

 

2 Answers Found

 

Answer 1

There is no such possibility in CTE.....

Probably u can take all that rows including duplicates into  a cte, then in next step, in another cte, remove those duplicates, then use that cte in subsequent query part

 

Answer 2

alternatively, you can use DISTINCT operator in SELECT statement for CTE;
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter