[dba-SQLServer] Re: Nulls in sprocs

Robert L. Stewart rl_stewart at highstream.net
Wed Jan 12 12:36:55 CST 2005


Steve,

Try building the insert statement in SQL instead of using a stored 
procedure.  When building it, you can leave out the ones that are null.

If you want to keep doing it as a stored procedure, pass null as the actual 
value.  It does not do that automatically in .Net.

Robert

At 12:00 PM 1/12/2005 -0600, you wrote:
>Date: Wed, 12 Jan 2005 10:28:12 -0600
>From: "Steven W. Erbach" <serbach at new.rr.com>
>Subject: RE: [dba-SQLServer] Nulls in sprocs
>To: dba-sqlserver at databaseadvisors.com
>Message-ID: <20050112102812.1185074831.serbach at new.rr.com>
>Content-Type: text/plain; charset=utf-8
>
>Doris,
>
>Thanks for the reply. I'm using VB.NET and ASP.NET and ADO.NET and 
>#$!@#%**#@&!?!.NET for my front end. I tried using the sproc in an ADO.NET 
>Transaction to allow Commit/Rollback. That's what I ultimately want to do. 
>For now I'm using the VB.NET ExecuteNonQuery() method just to get the data 
>in the table updated.
>
>My actual MAIN concern is with a couple of fields I have in another 
>database that hold 1 for yes and 0 for no. These are radio button values. 
>But if the answer is not known I'd like the value in the table to remain 
>NULL. Of course, once a value IS selected, I don't have to worry about 
>NULLs anymore because you can't set a radio button group back to nothing 
>without code.
>
>I just thought of something: what if I constructed the sproc in my VB.NET 
>code and simply skipped past the NULLs so that I don't have to worry about 
>trying to update a field with a NULL value? Since the sproc begins with 
>'CREATE PROCEDURE sprocname' all I'd have to do would be to create a 
>temporary file name, perhaps, to which to save the "constructed" sproc, 
>execute the Transaction set like I want to, and then delete the temporary 
>sproc after completion. What about that?
>
>Steve Erbach
>Neenah, WI





More information about the dba-SQLServer mailing list