[dba-SQLServer] Stored Procedures - Checking If Parameter Contains A Value

Paul Hartland Paul.Hartland at orridge.co.uk
Tue Jun 7 10:06:50 CDT 2005


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

 

_______________________________________________

*  This message is confidential.
*  This email, its content and any files transmitted with it are intended solely for the addressee and may be legally privileged and/or confidential.
*  Access by any other party is unauthorised without the express written permission of the sender.
*  If you have received this email in error you may not copy or use the contents, attachments or information in any way and any review, use, dissemination, forwarding, disclosure, alteration, printing of this information is strictly prohibited. Please destroy it and notify the sender via return e-mail.
*  This email has been prepared using information believed by Paul Hartland to be reliable and accurate, but the company makes no warranty as to accuracy or completeness. In particular the author does not accept responsibility for changes made to this email after it was sent.
*  Any opinions expressed in this document are those of the author and do not necessarily reflect the opinions of the company or its affiliates.

The Orridge web site can be found at:
http://www.orridge.co.uk





More information about the dba-SQLServer mailing list