Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

RE: Expand / Collapse
Author
Message
Posted Wednesday, March 22, 2006 7:56 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 14, 2010 12:32 AM
Points: 127, Visits: 49

Hi, recently I needed to pass some null value as parameteres to a DateTime field, I was using SQL Server 2k and C# VS 2003.

I tried using DBNull and others values but none fo them worked for me. 

What I did at the end was to set a default value of null in the database field, and didn't pass the parameter when I didn't have it, of course it added a little bit of logic when building the query.

Is there anyway to pass null value in the param???

 



Kindest Regards,

@puy Inc
Post #267584
Posted Friday, November 09, 2007 7:22 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, March 28, 2014 12:56 AM
Points: 115, Visits: 317
To pass in a null to some stored procs (with older Vb6/ADO code) you can do this:

1) The VB code puts 1/1/1900 in the date and the proc converts it to null.

2) the proc code is shown below.
...
set @NullDate = convert(smalldatetime, '1/1/1900')

if @aTestTime =@NullDate set @aTestTime = null
...
Then your insert/update statement in the proc uses @aTestTime normally and this will put a null in the date field.

For our other code that generates insert and update statements just use null as you would in query analyzer.

Good luck




Doug
Post #420512
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse