Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 1st, 2005, 05:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default Stored Procedure Insert Null Value

How can I get this to insert a NULL value if nothing is passed to @StoryCount, I am getting the following error
Microsoft OLE DB Provider for SQL Server error '80040e07'
Error converting data type varchar to int.
modify_story.asp, line 35

CREATE PROCEDURE sp_InsertStoryCount
(
@StoryCount int,
@Header varchar(60), ---line 35
@NewID int OUTPUT
)
AS
BEGIN
INSERT INTO my_Database
(StoryCount, Header)
VALUES
(@StoryCount, @Header)
SELECT @NewID = @@IDENTITY
END

Peace
Mike

Peace
Mike
http://www.eclecticpixel.com
http://www.homegrownmusicjam.com
__________________
Peace
Mike
http://www.eclecticpixel.com
 
Old March 2nd, 2005, 01:39 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

You can just pass NULL. You may be putting it between quotes('NULL').
 
Old March 5th, 2005, 10:19 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

as per Madhu change the default value to NULL, one thing use SCOPE_IDENTITY() rather than @@IDENTITY (look in the books Online)

CREATE PROCEDURE sp_InsertStoryCount
(
@StoryCount int,
@Header varchar(60)= NULL,
@NewID int OUTPUT
)
AS
BEGIN
INSERT INTO my_Database
(StoryCount, Header)
VALUES
(@StoryCount, @Header)
SELECT @NewID = @@IDENTITY --SELECT @NEWID = Scope_Identity()
END





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure return value is NULL kshort ASP.NET 2.0 Basics 16 March 14th, 2017 12:45 PM
pass null to the parameter in the stored procedure kokila BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 12th, 2007 03:02 AM
Biztalk Stored Procedure problems with NULL value mtlili Biztalk 0 September 21st, 2004 05:32 AM
How do I insert stored procedure through C# nishim.attreja VB How-To 1 September 18th, 2004 01:24 AM
Using an insert stored procedure morpheus VB How-To 3 August 7th, 2003 08:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.