Insert Proc. Accept Null Values?
Insert Proc. Accept Null Values?
am 07.09.2005 21:05:54 von jason
Is it possible to allow a sql stored procedure to accept NULL values from a
large processing form that INSERTS a bunch of values into the database?
How would one do this...my table is set up to accept Null values
CREATE Procedure spr_AddStatusRequest
@BoatID int,
@StatusID int,
@CompID int,
AS
INSERT INTO StatusRequest
(BoatID,StatusID,CompID)
VALUES
(@BoatID,@StatusID,@CompID)
GO
Re: Insert Proc. Accept Null Values?
am 07.09.2005 22:27:47 von unknown
You could default the values to NULL in the SP and just not pass anything in
your code. Eg.
CREATE Procedure spr_AddStatusRequest
@BoatID int = NULL,
@StatusID int = NULL,
@CompID int = NULL
AS
INSERT INTO StatusRequest
(BoatID,StatusID,CompID)
VALUES
(@BoatID,@StatusID,@CompID)
GO
'''''
sSQL = "EXEC spr_AddStatusRequest @BoatID=3, @CompID=9"
Ray at work
wrote in message
news:ujQSt89sFHA.908@tk2msftngp13.phx.gbl...
> Is it possible to allow a sql stored procedure to accept NULL values from
> a large processing form that INSERTS a bunch of values into the database?
>
> How would one do this...my table is set up to accept Null values
>
> CREATE Procedure spr_AddStatusRequest
> @BoatID int,
> @StatusID int,
> @CompID int,
>
>
> AS
>
>
> INSERT INTO StatusRequest
>
> (BoatID,StatusID,CompID)
>
> VALUES
>
> (@BoatID,@StatusID,@CompID)
> GO
>
>
Re: Insert Proc. Accept Null Values?
am 08.09.2005 22:11:54 von jason
Ahhh Thank You Thank You!!
"Ray Costanzo [MVP]" wrote in
message news:epomdq%23sFHA.3328@TK2MSFTNGP11.phx.gbl...
> You could default the values to NULL in the SP and just not pass anything
> in your code. Eg.
>
>
> CREATE Procedure spr_AddStatusRequest
> @BoatID int = NULL,
> @StatusID int = NULL,
> @CompID int = NULL
>
> AS
>
>
> INSERT INTO StatusRequest
>
> (BoatID,StatusID,CompID)
>
> VALUES
>
> (@BoatID,@StatusID,@CompID)
> GO
>
>
> '''''
> sSQL = "EXEC spr_AddStatusRequest @BoatID=3, @CompID=9"
>
> Ray at work
>
>
> wrote in message
> news:ujQSt89sFHA.908@tk2msftngp13.phx.gbl...
>> Is it possible to allow a sql stored procedure to accept NULL values from
>> a large processing form that INSERTS a bunch of values into the database?
>>
>> How would one do this...my table is set up to accept Null values
>>
>> CREATE Procedure spr_AddStatusRequest
>> @BoatID int,
>> @StatusID int,
>> @CompID int,
>>
>>
>> AS
>>
>>
>> INSERT INTO StatusRequest
>>
>> (BoatID,StatusID,CompID)
>>
>> VALUES
>>
>> (@BoatID,@StatusID,@CompID)
>> GO
>>
>>
>
>
Re: Insert Proc. Accept Null Values?
am 09.09.2005 16:00:33 von jason
ps: Does this work for Dates too....?
wrote in message
news:edHXQGLtFHA.3120@TK2MSFTNGP10.phx.gbl...
> Ahhh Thank You Thank You!!
>
> "Ray Costanzo [MVP]" wrote in
> message news:epomdq%23sFHA.3328@TK2MSFTNGP11.phx.gbl...
>> You could default the values to NULL in the SP and just not pass anything
>> in your code. Eg.
>>
>>
>> CREATE Procedure spr_AddStatusRequest
>> @BoatID int = NULL,
>> @StatusID int = NULL,
>> @CompID int = NULL
>>
>> AS
>>
>>
>> INSERT INTO StatusRequest
>>
>> (BoatID,StatusID,CompID)
>>
>> VALUES
>>
>> (@BoatID,@StatusID,@CompID)
>> GO
>>
>>
>> '''''
>> sSQL = "EXEC spr_AddStatusRequest @BoatID=3, @CompID=9"
>>
>> Ray at work
>>
>>
>> wrote in message
>> news:ujQSt89sFHA.908@tk2msftngp13.phx.gbl...
>>> Is it possible to allow a sql stored procedure to accept NULL values
>>> from a large processing form that INSERTS a bunch of values into the
>>> database?
>>>
>>> How would one do this...my table is set up to accept Null values
>>>
>>> CREATE Procedure spr_AddStatusRequest
>>> @BoatID int,
>>> @StatusID int,
>>> @CompID int,
>>>
>>>
>>> AS
>>>
>>>
>>> INSERT INTO StatusRequest
>>>
>>> (BoatID,StatusID,CompID)
>>>
>>> VALUES
>>>
>>> (@BoatID,@StatusID,@CompID)
>>> GO
>>>
>>>
>>
>>
>
>
Re: Insert Proc. Accept Null Values?
am 09.09.2005 16:06:42 von jason
Yes, it does but you have to replace empty values with a null assignment in
your code. Probably not a good idea but I'm doing it!
Tricky things these dates...
wrote in message
news:uEu4abUtFHA.908@tk2msftngp13.phx.gbl...
> ps: Does this work for Dates too....?
> wrote in message
> news:edHXQGLtFHA.3120@TK2MSFTNGP10.phx.gbl...
>> Ahhh Thank You Thank You!!
>>
>> "Ray Costanzo [MVP]" wrote in
>> message news:epomdq%23sFHA.3328@TK2MSFTNGP11.phx.gbl...
>>> You could default the values to NULL in the SP and just not pass
>>> anything in your code. Eg.
>>>
>>>
>>> CREATE Procedure spr_AddStatusRequest
>>> @BoatID int = NULL,
>>> @StatusID int = NULL,
>>> @CompID int = NULL
>>>
>>> AS
>>>
>>>
>>> INSERT INTO StatusRequest
>>>
>>> (BoatID,StatusID,CompID)
>>>
>>> VALUES
>>>
>>> (@BoatID,@StatusID,@CompID)
>>> GO
>>>
>>>
>>> '''''
>>> sSQL = "EXEC spr_AddStatusRequest @BoatID=3, @CompID=9"
>>>
>>> Ray at work
>>>
>>>
>>> wrote in message
>>> news:ujQSt89sFHA.908@tk2msftngp13.phx.gbl...
>>>> Is it possible to allow a sql stored procedure to accept NULL values
>>>> from a large processing form that INSERTS a bunch of values into the
>>>> database?
>>>>
>>>> How would one do this...my table is set up to accept Null values
>>>>
>>>> CREATE Procedure spr_AddStatusRequest
>>>> @BoatID int,
>>>> @StatusID int,
>>>> @CompID int,
>>>>
>>>>
>>>> AS
>>>>
>>>>
>>>> INSERT INTO StatusRequest
>>>>
>>>> (BoatID,StatusID,CompID)
>>>>
>>>> VALUES
>>>>
>>>> (@BoatID,@StatusID,@CompID)
>>>> GO
>>>>
>>>>
>>>
>>>
>>
>>
>
>