Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Set Optional to the Parameters in Sproc

Posted on 2002-04-25
2
Medium Priority
?
345 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 400 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

604 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