[dba-SQLServer] Stored Procedures - Checking If Parameter Contains AValue

David Mcafee dmcafee at pacbell.net
Wed Jun 8 14:37:25 CDT 2005


Thats actually a great idea (if you are sure your
first ID is 1, otherwise set a variable to the min ID
such as:

DECLARE @MinID As INT

IF ISNULL(@strACNo,0) = 0 
SELECT @MinID = MIN(AccountNo) FROM tblClient


By the way are you the same Nick Van from Access-L (or
was it AccessD) several years back?

David

--- nicholas van <nick at frasiervan.com> wrote:
> Will using a default value work?
> 
> CREATE PROCEDURE [genesis_select_ClientDetails] 
>    @strACNo		[nvarchar](20) = '000001'
> 
> It should set teh @strACNo to '000001' when the
> input is Null.
> 
> ---------- Original Message
> ----------------------------------
> From: "Paul Hartland" <Paul.Hartland at orridge.co.uk>
> Reply-To: dba-sqlserver at databaseadvisors.com
> Date:  Tue, 7 Jun 2005 16:06:50 +0100
> 
> >To all,
> >
> >I have done a little work with SQL Server stored
> procedures with
> >parameters (very simple ones), i.e. I have a stored
> procedure that
> >selects a client based on the user entering an
> Account Number:
> >
> >	CREATE PROCEDURE [genesis_select_ClientDetails] 
> >		@strACNo		[nvarchar](20)
> >
> >	AS
> >
> >	SELECT		* 
> >
> >	FROM 		tblClient
> >
> >	WHERE		JobNo		=	@strACNo
> >
> >	GO
> >
> >This works well enough, but what I want to do is
> put a simple check in
> >there where if @strACNo IS NULL then I want
> @strACNo to equal the very
> >first Account number in the Client table.  I could
> do the check via my
> >Visual Basic FE, but was wondering if it is
> possible to incorporate it
> >into the stored procedure above.
> >
> >Thanks in advance for any help on this.....
> >
> >
> >PAUL HARTLAND
> >Database Designer/Programmer
> >paul.hartland at isharp.co.uk
> >Mobile - (+44)7730 523179
> >
> > 
> >
>  
>              
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
>
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
> 
> 



More information about the dba-SQLServer mailing list