Interview Question in Microsoft Transact-SQL


 

Interview Question :: Can I do this in TSQL


I'm trying to write a T-SQL script that involves cursors.
I'm getting errors. Is this code ok?
(all variables are varchar(20))

if @PhoneID=@PrevPhoneID and @PhoneType=@PrevPhoneType
Begin
Set @Phonetype=@Phonetype & "2")
End
Answers to "Can I do this in TSQL"
RE: Can I do this in TSQL?

you dont need the ) after the "2"

you also might want to put parentheses around each part of the if like:



If (@PhoneID = @PrevphoneID) and ()
 
Vote for this answer ::  
RE: Can I do this in TSQL?

Where does the ")" come from?



Are you getting compile errors, run time errors, or logical bugs?
 
Vote for this answer ::  
Update Alert Setting