Solved

Set Optional to the Parameters in Sproc

Posted on 2002-04-25
2
341 Views
Last Modified: 2008-03-03
I would like to know whether we can set the parameter in Sproc to be an optional. The values that passed from VB or Access to the sproc can be ignore when this option has been set. Like in Vb or VBA, the function that we create or declare can define the variables either optional or compulsory. Does anyone know this?????

0
Comment
Question by:jetyun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 6968005
CREATE PROC yourproc
  @mandatory varchar(10),
  @optional int = NULL
AS
  SELECT @mandatory, @optional
GO

try usage:
EXEC yourproc 'testing', 10
EXEC yourproc 'testing'
EXEC yourproc ----> error, proc expects value for parameter @mandatory

CHeers
0
 

Author Comment

by:jetyun
ID: 6968040
cool ..i got it..thankx
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question