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 |
|
renu
Starting Member
47 Posts |
Posted - 2007-10-24 : 00:49:10
|
| hi all,I have a query in CTE. Once the CTE was created us itpossible to use anywhere in the SP like temp table. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-24 : 02:46:46
|
Also you can use it immediately for only one time WITH t as( select 1 as n union all select 10)select n from tselect n from t MadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-24 : 02:56:17
|
Mmmm.. Not quite right.You can only reference the CTE with one statement, but this one statement can reference the CTE one, twice or more times.SELECT * FROM cte where Col1 = 2UNION ALLSELECT * FROM cte where Col2 = 1 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-24 : 04:36:01
|
quote: Originally posted by Peso Mmmm.. Not quite right.You can only reference the CTE with one statement, but this one statement can reference the CTE one, twice or more times.SELECT * FROM cte where Col1 = 2UNION ALLSELECT * FROM cte where Col2 = 1 E 12°55'05.25"N 56°04'39.16"
Yes it is. Thats why my example MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|