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)
 Stored Procedure parameter information

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-09-13 : 06:28:50
Hashmi writes "Hi all.

How to allow null values for any parameter in sql server stored procedure and how not to allow null values for any parameter? And also is there any way to find out programatically whether null values are allowed for any parameter or whether any parameter is nullable?

Please help me. badly need the answer to it.

Thanks."

nr
SQLTeam MVY

12543 Posts

Posted - 2006-09-13 : 06:45:36
Parameters always allow null.
You would have to check for it in the code.

You can give a default but if someone passes null it would set it to null.

==========================================
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

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-13 : 06:47:36
If you don't want NULL parameter, there are couple of things you can do:

1. Specify default value for parameter like @a int = 0
2. Check NULLability of the parameter inside Proc and raise error if parameter is found to be null using IS NULL


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

LazyDragon
Starting Member

30 Posts

Posted - 2006-09-13 : 08:44:27
There is an undocumented system procedure sp_procedure_params_rowset, which is typically used by client libraries like ADO, to collect parameter info.

This procedure returns details like, param name, default, nullabilty, datatype etc...

LazyDragon
T-SQL Programmer
Go to Top of Page
   

- Advertisement -