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)
 default value for OUTPUT params

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2009-06-20 : 07:50:56
Hi,

I have a SP like so, and I am having a problem with the @blocked parameter.

I thought that since I am passing it a default value of "0" that if I bring back its value in my front end code I should get a "0" as well.

The problem is I am getting a NULL value. I only set it to a different value if its not 0

Is this a wrong approach ? How can I have its default value be ZERO and not NULL

any help much appreciated !:)

Thanks very much!
mike123


create PROCEDURE [dbo].[insert_tblComment]
(
@CommentTo [int],
@CommentFromID [int],
@Comment [varchar](500),
@IP [varchar](15),
@blocked [tinyint] = 0 OUTPUT
)
AS

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-06-20 : 07:56:59
create PROCEDURE [dbo].[insert_tblComment]
(
@CommentTo [int],
@CommentFromID [int],
@Comment [varchar](500),
@IP [varchar](15),
@blocked [tinyint] OUTPUT
)
AS
begin
set @blocked = 0
select statements
-- If error occurs, return the status as failed i.e. –1, else success i.e. 0
SELECT @bolcked= -1 WHERE @@ERROR <> 0
end
try like this see

Go to Top of Page
   

- Advertisement -