• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

how to find if a variable is equal to a value in sql

Hi,
I want to find if a variable has a particular value but i dont know the syntax, heres the sql code i have:

CREATE PROCEDURE usp_GetFilteredTimesheet
@clientID uniqueidentifier,
@ProjectID uniqueidentifier,
@employee nvarchar(50),
@Task nvarchar( 50)


 AS
BEGIN
IF @employee="MyValue" AND @Task ="MyValue"   BEGIN

SELECT Project FROM tbTimesheet

WHERE ProjectID=@ProjectID AND tblProject.ClientID =@ClientID
END


So I want to find if the value of the @employee and see if its value as a string is MyValue

I have hard coded the value in my c#.net  to be the string "MyValue"

This code doesnt work, i have a syntax error on : IF @employee="MyValue"

Thanks
0
CharlieDev
Asked:
CharlieDev
2 Solutions
 
stesomCommented:
Use ' instead of " around the varchar/string. "MyValue" -> 'MyValue'.
0
 
Pratima PharandeCommented:
use single quotes like this
IF @employee='MyValue' AND @Task ='MyValue'
0
 
CharlieDevAuthor Commented:
Thanks, i'm sure i had treid that it it didnt work, but i was wrong, tried again after the suggest and its worked, cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now