tags:

views:

70

answers:

3

How do you pass a value from your DAL to your sproc so that the ISNULL function will do it's job.

Particularly the DATE value coming from my .NET assembly.

In T-SQL an INSERT STMNT and in the VALUES clause, the line of interest goes like this;

ISNULL(@myparm_forcolumn9, @myparm_forcolumn9)

What value do I pass from .NET to make this line in my sproc work universally, so I don't have to write a millions INSERT SPROCS for every combination of columns??? I just want to write one stored procedure(sproc) that will handle all INSERTS in my universe.

+4  A: 

I'd use default parameters on the stored procedure to do this.

e.g.

CREATE PROCEDURE [dbo].[employee_add]
@createdate int = null,
@uid int =-1 
AS
...
Richard Harrison
A: 

I agree, a default parameter would be ideal. In your .NET code then, simply omit passing that parameter to the procedure in the event you want that to be null.

Tejs
A: 

DBNull.Value.

http://msdn.microsoft.com/en-us/library/system.dbnull.aspx

Neal