asp_databases thread: having trouble INSERTING null into datetime field
Message #1 by "Philip Sayers" <philipsayers@m...> on Wed, 19 Dec 2001 16:07:11 -0500
|
|
All,
I?m using MS SQL 2k, win2k server.
USING a stored procedure as follows.
CREATE PROCEDURE sp_AddPortOfCall
@TOURRECID int,
@DAYNUMBER tinyint,
@PORTNAME varchar(100),
@ARRIVETIME datetime = null,
@DEPARTTIME datetime = null
AS
INSERT INTO tblPortsOfCall
(fldTourRecId, fldDayNumber, fldPortOfCall, fldArriveTime,
fldDepartTime)
VALUES
(@TOURRECID, @DAYNUMBER, @PORTNAME, @ARRIVETIME, @DEPARTTIME)
Calling sp from a function within an include file. I pass in my
variables to my Fn as below
Function AddPortOfCall (intTourRecId, intDayNumber, strPortName,
dteArrive, dteDepart)
When I pass in my dteArrive and dteDepart (both date datatype) within my
function I use IsDate() to see if I really passed in a date, since I am
allowing null values in the Db. If IsDate returns false, then I set
dteArrive and dteDepart to Null. Then I call the sp shown above. BUT
iget a date of jan 1st, 1900 in the db, instead of a null.
Can someone show me the light?
Thx
Phil
Message #2 by "Breidenbach, Beth" <Beth.Breidenbach@g...> on Wed, 19 Dec 2001 16:11:29 -0500
|
|
Phil,
If you can, fire up SQL Profiler, set it to capture the SQL, and re-run the
sproc. Look in the capture log to see what was actually sent -- which is
often different than what we _think_ was sent. :-)
Beth
-----Original Message-----
From: Philip Sayers [mailto:philipsayers@m...]
Sent: Wednesday, December 19, 2001 1:07 PM
To: ASP Databases
Subject: [asp_databases] having trouble INSERTING null into datetime
field
All,
I'm using MS SQL 2k, win2k server.
USING a stored procedure as follows.
CREATE PROCEDURE sp_AddPortOfCall
@TOURRECID int,
@DAYNUMBER tinyint,
@PORTNAME varchar(100),
@ARRIVETIME datetime = null,
@DEPARTTIME datetime = null
AS
INSERT INTO tblPortsOfCall
(fldTourRecId, fldDayNumber, fldPortOfCall, fldArriveTime,
fldDepartTime)
VALUES
(@TOURRECID, @DAYNUMBER, @PORTNAME, @ARRIVETIME, @DEPARTTIME)
Calling sp from a function within an include file. I pass in my
variables to my Fn as below
Function AddPortOfCall (intTourRecId, intDayNumber, strPortName,
dteArrive, dteDepart)
When I pass in my dteArrive and dteDepart (both date datatype) within my
function I use IsDate() to see if I really passed in a date, since I am
allowing null values in the Db. If IsDate returns false, then I set
dteArrive and dteDepart to Null. Then I call the sp shown above. BUT
iget a date of jan 1st, 1900 in the db, instead of a null.
Can someone show me the light?
Thx
Phil
$subst('Email.Unsub').
|