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 |
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-01-07 : 13:52:04
|
| Hello all. I have a question about table expression.With A As(............),B As(............)Then it pump error up when I want to select from B.If I do it like------------------With A As (.....)With B As(....)--------------------The error is "If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon."What should I do to fix it?Thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-01-07 : 14:26:01
|
| but where should I add it to? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-01-07 : 14:38:26
|
| It is terminated by error: Incorrect syntax near ';'. |
 |
|
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-01-07 : 15:44:12
|
| Finally, I only use one such CTE. But it seems it could only be select once.---------------------------------With A as(....)select .....from A(It works)select .....from A(It fail)---------------------------------anyone could tell me the reason?Thanks a lot. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-07 : 15:56:48
|
It's because of SCOPE!CTE's can only be used by following statement, due to scope limitation. However you can reference to the CTE up to 256 times in same following statement.Yes, it is documented in Books Online. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-07 : 15:57:29
|
And you are corrent in using comma to declare multiple CTE's;With A As(............),B As(............)will work. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
mavershang
Posting Yak Master
111 Posts |
Posted - 2009-01-07 : 16:12:23
|
Thanks a lot.quote: Originally posted by Peso And you are corrent in using comma to declare multiple CTE's;With A As(............),B As(............)will work. E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
|
|
|