Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 declaring a parameter as null

Author  Topic 

marclas
Starting Member

16 Posts

Posted - 2012-05-08 : 06:23:24
HI

how can i set a null value when declaring a parameter
example
[code="sql"]
CREATE PROCEDURE dbo.GestionStatutDossier
-- Add the parameters for the stored procedure here
@StaId int NULL,
@DosID uniqueidentifier,
@staDate datetime,
@staBL nvarchar (50),
@staCRprod nvarchar (50)
AS
[/code]


Marclas

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-05-08 : 06:31:33
use =

Here you can see some default values for the parameters.


BEGIN TRANSACTION
GO

CREATE PROCEDURE dbo.GestionStatutDossier
-- Add the parameters for the stored procedure here
@StaId int = NULL,
@DosID uniqueidentifier,
@staDate datetime = '20120101',
@staBL nvarchar (50) = 'FOO',
@staCRprod nvarchar (50) = NULL
AS BEGIN
SELECT
@StaId
, @DosID
, @staDate
, @staBL
, @staCRprod
END
GO

DECLARE @dosID UNIQUEIDENTIFIER = NEWID()
EXEC dbo.GestionStatutDossier @DosID = @dosID
GO

ROLLBACK TRANSACTION


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

marclas
Starting Member

16 Posts

Posted - 2012-05-08 : 06:59:56
Merci

Marclas
Go to Top of Page
   

- Advertisement -