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
Solved

Set Optional to the Parameters in Sproc

Posted on 2002-04-25
2
338 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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

809 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