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
 General SQL Server Forums
 New to SQL Server Programming
 condition check

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-02-17 : 01:20:42


hi team , i have a proc with ONE IN parameters and i need to
pass a value , when value not in 360, 365 then prints "value not in 360 or 365"

challenge everything

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-02-17 : 02:29:53
Show us what you have so far. This is a pretty basic stored proc, and it seems you are asking a homework question. We are willing to help, but we need to see some effort on your part.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-02-17 : 02:38:05
i do.. the same like this please correct if i am wrong


declare @id numeric(10)
begin

set @id = 365

if @id <> 360 and @id <> 365

begin

print 'p'

end
print 's'
end

challenge everything
Go to Top of Page

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-02-17 : 02:45:55
i also do it in another way where i write
if @id not in (360,365)
in place of
"if @id <> 360 and @id <> 365"

challenge everything
Go to Top of Page

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-02-17 : 02:46:17
please help which is better

challenge everything
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-02-17 : 02:49:29
I prefer to use IN here as it's shorter code.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -