Rad & Dot Net - Digital Warrior

Assorted ramblings (and vents!!) from a techie on the sunny shores of Kenya, East Africa

Thursday, February 03, 2005

Assorted Gotchas

After wasting an entire day debugging one stored procedure, let me share my newly gained wisdom

1) When declaring nvarchar variables never forget to specify the size. If you don't it defaults to one then you will wonder why


select from users where username =@username

returns nothing

2) When you have a stored procedure that calls another, the latter of which returns a value in an ouput paramer, do it like this

declare @ProductID int

exec 
[Products.Insert1,'ACME'
'A generic ACME'1, @ProductID output

select 
@ProductID


and not like this

declare @ProductID int

execute 
[Products.Insert1,'ACME'
'A generic ACME'1, @ProductID 
select 
@ProductID

The difference is the OUTPUT. If you fail to include that little word the output parameter is never populated!

0 Comments:

Post a Comment

<< Home