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 |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-09-26 : 07:42:09
|
Julia writes "Hi. I need create a view that will check the server id.Depend on the Server id I need to have a different select statment inside this view. For example:Create View_SomeNameIF ServerID = 1 BEGIN SELECT * FROM TABLE_NAME1 ENDELSE BEGIN SELECT * FROM TABLE_NAME2 ENDWhat I am doing wrong here?? I am getting SQL syntax error.Thank you, all." |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-26 : 07:46:10
|
Try replacing your if statement...IF @@SERVERNAME = 'ServerName' |
 |
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-09-26 : 07:59:56
|
I dont think what you are trying to do can be achvied using view.. Chirag |
 |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-26 : 08:06:14
|
duh.. View...I have to read a little closer. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-26 : 09:26:11
|
Why dont you use Stored preocedure?MadhivananFailing to plan is Planning to fail |
 |
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2006-09-27 : 00:17:03
|
select * from table_1where@@servername='1'union allselect * from table_2where@@servername='2'Seems a bit of a dodgy requirement though. What's your objective here? |
 |
|
|
|
|