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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Numeric

Author  Topic 

sardinka
Posting Yak Master

142 Posts

Posted - 2004-11-18 : 12:05:24
How do I pass a numeric value to sp?
in my sp I have
declare ID numeric....
exec sp ???

X002548
Not Just a Number

15586 Posts

Posted - 2004-11-18 : 12:14:04
[code]
USE Northwind
GO

CREATE PROC mySproc99 @inputParameter int, @outputParameter int OUTPUT
AS
SELECT @outputParameter = @inputParameter / 2.00
GO

DECLARE @x int
EXEC mySproc99 15, @x OUTPUT
SELECT @x
GO

DROP PROC mySproc99
GO

[/code]


Brett

8-)
Go to Top of Page

sardinka
Posting Yak Master

142 Posts

Posted - 2004-11-18 : 12:24:38
what Am I doing incorrect?
CREATE procedure dbo.test
@ID varchar(10)=Null,
@SID varchar(10)=Null,
@TId int=0,
@LName varchar(20)=Null,
@FName varchar(17)=Null ....
select....

exec test '724535','',,'s',''
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ','.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-11-18 : 12:37:53
[code]
USE Northwind
GO

CREATE PROC test
@ID varchar(10)=Null,
@SID varchar(10)=Null,
@TId int=0,
@LName varchar(20)=Null,
@FName varchar(17)=Null
AS
SELECT 'HI'
GO

DECLARE @ID varchar(10),
@SID varchar(10),
@TId int,
@LName varchar(20),
@FName varchar(17)

SELECT @ID = '724535',
@SID = '',
@LName = 's',
@FName = ''

EXEC test @ID, @SID, @TId, @LName, @FName

EXEC test '724535', '', 0, 's', ''

-- Fails
-- EXEC test '724535', '', , 's', ''
GO

DROP PROC test
GO

[/code]


Brett

8-)
Go to Top of Page

sardinka
Posting Yak Master

142 Posts

Posted - 2004-11-18 : 14:27:15
SO I can't pass an empty integer?
EXEC test '724535', '', , 's', '' ???

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-11-18 : 14:30:49
You would pass NULL for the "empty integer". Or exclude it from your input list. If you do this, you have to explicitly state where the values are going:

EXEC test @ID = '4', @SID = '9', @FName = 'Tara'

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-11-18 : 15:17:05
You would do it like

EXEC test '724535', '', null , 's', ''
GO




Brett

8-)
Go to Top of Page
   

- Advertisement -