• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • 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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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