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 |
|
craigwg
Posting Yak Master
154 Posts |
Posted - 2009-07-28 : 11:52:53
|
Hi!How do I make my If statement work? I think my problem is setting the variable equal to the results of a select statement. Basically my logic is this: If the server version is 2000, then run Code X, otherwise run code Y. This was my approach to it, but I am open to other ideas. Here is what I have:DECLARE @version sql_variantselect @version=SERVERPROPERTY('productversion')if @version like '8%'--for 2000 servers Code XELSE--for 2005 serversCode YAny ideas?Craig Greenwood |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-07-28 : 12:38:13
|
| [code]declare @f sql_variantselect @f = SERVERPROPERTY('productversion')if convert(varchar(20),@f) like '8%'beginselect 1endelse beginselect 2end[\code]http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|