SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 compare a value in column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

allan8964
Posting Yak Master

196 Posts

Posted - 05/14/2012 :  14:39:12  Show Profile  Reply with Quote
Hi there,

I need compare a value to a column in a table1:

table1
Id | Code |
01 | CCD
02 | FFT


How can I check if @varName is one of the values in column Code?

Thanks.

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 05/14/2012 :  14:55:18  Show Profile  Reply with Quote
quote:
Originally posted by allan8964

Hi there,

I need compare a value to a column in a table1:

table1
Id | Code |
01 | CCD
02 | FFT


How can I check if @varName is one of the values in column Code?

Thanks.

SELECT * FROM table1 WHERE Code = @varname
If you simply want a YES or NO answer:
IF EXISTS (SELECT * FROM table1 WHERE Code = @varname) 
SELECT 'Yes'
ELSE 
SELECT 'No'
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000