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 |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2007-02-14 : 06:40:30
|
| Hello,I have the following code:DECLARE @LevelId UNIQUEIDENTIFIERSELECT @LevelId = LevelId FROM dbo.Levels WHERE LevelName = @LevelNameLater in my code I need to check if a record was found or not.How can I do this?I know I could do:EXISTS(SELECT @LevelId = LevelId FROM dbo.Levels WHERE LevelName = @LevelName)But I don't want to do this. I want to check the @LevelId variable.Thanks,Miguel |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-14 : 06:44:14
|
Assuming LevelID does not contain NULLS, you can do this,If @LevelId IS Not NULL -- record found do somethingElse -- record not found, do something Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|