| Author |
Topic |
|
QuietRiot
Yak Posting Veteran
67 Posts |
Posted - 2007-11-12 : 08:52:57
|
| [code]With tmp as ( Select db = 'ABC001', fieldvalue from ABC001..fundcustomfieldvalues where fieldid = '1'Union allSelect db = 'ABC002', fieldvalue from ABC002..fundcustomfieldvalues where fieldid = '1'Union allSelect db = 'ABC003', fieldvalue from ABC003..fundcustomfieldvalues where fieldid = '1'Union all ) Select fieldvalue, dbname From tmp Where fieldvalue in ( Select fieldvalue from tmp Group by fieldvalue Having count(*) > 1 ) Order by fieldvalue, dbname[/code]Server: Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'With'.Server: Msg 170, Level 15, State 1, Line 9Line 9: Incorrect syntax near ')'.its the whole with temp ( ... ) part |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-11-12 : 08:55:00
|
quote: Originally posted by QuietRiot
With tmp as ( Select db = 'ABC001', fieldvalue from ABC001..fundcustomfieldvalues where fieldid = '1'Union allSelect db = 'ABC002', fieldvalue from ABC002..fundcustomfieldvalues where fieldid = '1'Union allSelect db = 'ABC003', fieldvalue from ABC003..fundcustomfieldvalues where fieldid = '1'Union all ) Select fieldvalue, dbname From tmp Where fieldvalue in ( Select fieldvalue from tmp Group by fieldvalue Having count(*) > 1 ) Order by fieldvalue, dbname Server: Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'With'.Server: Msg 170, Level 15, State 1, Line 9Line 9: Incorrect syntax near ')'.its the whole with temp ( ... ) part
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-11-12 : 08:59:49
|
| and add a ; before with just in case.;With ..._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
QuietRiot
Yak Posting Veteran
67 Posts |
Posted - 2007-11-12 : 08:59:53
|
| ok,i solved one but I still get this one error Server: Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'With'. |
 |
|
|
QuietRiot
Yak Posting Veteran
67 Posts |
Posted - 2007-11-12 : 09:01:21
|
| Line 1: Incorrect syntax near ';'. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-11-12 : 09:03:34
|
well post your "fixed" query _______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-11-12 : 09:05:30
|
| well you are doing too many wrong things. There is no column with name dbname. Secondly are you quite sure, you are running this query in SQL 2005?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
QuietRiot
Yak Posting Veteran
67 Posts |
Posted - 2007-11-12 : 09:10:34
|
| no its 2000.. just checked |
 |
|
|
QuietRiot
Yak Posting Veteran
67 Posts |
Posted - 2007-11-12 : 09:14:49
|
| also these are my 2 original if someone can help tweak the aboveuse ABC003 select co# =(003), fieldvalue from fundcustomfieldvalues where fieldid = '1'use ABC004 select co# =(004), fieldvalue from fundcustomfieldvalues where fieldid = '1' |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-11-12 : 09:20:35
|
| you can't use WITH in sql server 2000_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
QuietRiot
Yak Posting Veteran
67 Posts |
Posted - 2007-11-12 : 09:36:15
|
| Ok, thanks guys I just created a new thread in the 2000 sectionsorry |
 |
|
|
|