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
 SQL Server Development (2000)
 Bit Data type

Author  Topic 

anuradhay
Starting Member

41 Posts

Posted - 2004-11-22 : 03:01:03
Hi,

I have a procedure like this.

create proc bit_output
@var2 char(1),
@var1 bit out
as
begin
select @var1 = 0
if @var2 = '2'
select @var1 = 1

select @var1

end.
@var1 is not initialized. When i execute this procedure : exec bit_output '1',@var1 out

it is returning null in 2000 and 0 in sql 6.5 . even if i assign default value to this paramater it is returning null.. when i initialize this variable insided the procedure it is working fine. why it is behaving differently when i don't initialize the variable? any idea?

is there any other way to get the same result other than initializing the variable inside the proc.

Thanks,

nr
SQLTeam MVY

12543 Posts

Posted - 2004-11-22 : 05:36:38
In 6.5 bit datatypes didn't allow null.
This could be

if @var2 = '2'
select @var1 = 1
else
select @var1 = 0


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -