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 2000 Forums
 Transact-SQL (2000)
 question about if statement

Author  Topic 

zaidqis
Yak Posting Veteran

63 Posts

Posted - 2006-05-29 : 13:10:56
hi all
i have a question about if
i have this code
declare @x NUMBER
set @x=value
IF @x>1 somecondition
SELECT some data
ELSE
SELECT some data
DECLARE @TimeSheetDate DATETIME
SET @TimeSheetDate = GETDATE()

i want
DECLARE @TimeSheetDate DATETIME
SET @TimeSheetDate = GETDATE()

be executed with no considering if @x>1 or not
note : i am new with t-sql
thank you

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-05-29 : 14:06:31
zaidqis,

U may need to learn a lot of things
1. there is no data type as Number (check for the available data types)
2. "IF @x>1 somecondition" doesn't make any sense as "@x>1" is a condition itself
3. ur concern is about doing something independent of if-else
that will be done in the way u wrote it (but its not a good practice)
4. Any block of code that u want to execute if a condition is satisfied, has to be put inside a begin-End block.
eg.
   if <Condition>
begin
<Code>
<Code>
<Code>
....
end
else
begin
<Code>
<Code>
<Code>
....
end


Srinika
Go to Top of Page

zaidqis
Yak Posting Veteran

63 Posts

Posted - 2006-05-29 : 15:17:41
thank you very much for answe me
i am stil beginner with t-sql
and i will work hard to be professional with t-sql oneday
thank you again for anser me
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-05-29 : 16:37:07
Advice: press the F1 Key to see help files (books online)
Go to Top of Page
   

- Advertisement -