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
 General SQL Server Forums
 New to SQL Server Programming
 numeric variable value

Author  Topic 

paritosh
Starting Member

42 Posts

Posted - 2012-02-20 : 00:52:06
1:-
declare @id numeric(10)
begin
print @id /* is this print any value what is the value of this */
end

2:-
declare @id numeric(10)
begin
select @id= id from table where name='aaaa' /* and table have not any name with name 'aaaa'*/
print @id /*what will give this print and how to handle this with null handling*/
end


thanks in advance...

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2012-02-20 : 03:42:25
You can't print the Null value.

You can use Select cluase

declare @id numeric(10)
begin
select @id= id from table where name='aaaa' /* and table have not any name with name 'aaaa'*/
Select @id /*what will give this print and how to handle this with null handling*/
end

or else you can try something like this

if(@id is null)
print 'null'
else
print @id
end


Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008
Go to Top of Page
   

- Advertisement -