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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 IF ELSE construction?

Author  Topic 

neutcomp
Posting Yak Master

111 Posts

Posted - 2002-11-25 : 10:05:00
Hello,

is there a way to use a if else construction in your sql code?
I use SQL server enteprise edition.

Something like:
SELECT active
FROM tbl_person
IF active = "yes" THEN
SELECT name from tbl_person
Else
SELECT error_message from tbl_error_messages

Thanxx
Bjorn


Cya
Bjorn

nr
SQLTeam MVY

12543 Posts

Posted - 2002-11-25 : 10:12:12
declare @Active int
select @Active = active from tblPerson where id = @user_id
if @Active = 1
SELECT name from tbl_person
else
SELECT error_message from tbl_error_messages

Also look at the case statement.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -