Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 1st, 2005, 05:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
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
Reply With Quote
  #2 (permalink)  
Old March 2nd, 2005, 01:39 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
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').
Reply With Quote
  #3 (permalink)  
Old March 5th, 2005, 10:19 AM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:27 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.