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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 if statement

Author  Topic 

mary_itohan
Posting Yak Master

191 Posts

Posted - 2008-10-01 : 06:43:33
Hello,
when using an if statement, must i use begin and end ?

And if not, what is evaluated after the if statement ?

ie i have a SP with multiple lines of code.

if @@rowcount = 1
set @true = 1

...code continues here.

Am wondering if is correct or i must use


if @@rowcount = 1
begin
set @true = 1
end




_____________________


Yes O !

ganeshkumar08
Posting Yak Master

187 Posts

Posted - 2008-10-01 : 06:48:26
If you have more that one statement you must place the statements between BEGIN and END, if you have single statement there is no need BEGIN and END.

If @@rowcount = 1
set @true = 1
is enough..


Solutions are easy. Understanding the problem, now, that's the hard part
Go to Top of Page
   

- Advertisement -