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 2005 Forums
 Transact-SQL (2005)
 change variable value in executing SP statement

Author  Topic 

chih
Posting Yak Master

154 Posts

Posted - 2007-09-09 : 21:51:24
Hi Everyone,
Please see below example. I want to execute the SP. One of variable I want to change it to negative value (-@num). How can I do it? becasue I alwasy get syntax error.
Incorrect syntax near '@num'.

Thank you


Example,
In the Stored procedure,
select @num =qty from sales
exec salesClaim @id, -@num

Zoroaster
Aged Yak Warrior

702 Posts

Posted - 2007-09-09 : 21:55:05
Chih, please post the ddl for the stored procedure.



Future guru in the making.
Go to Top of Page

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2007-09-10 : 01:39:05
Hi,

Try this one

Declare @num int
select @num = -qty from sales
exec salesClaim @id, @num
Go to Top of Page

chih
Posting Yak Master

154 Posts

Posted - 2007-09-10 : 01:52:23
Hi Zoroaster,

Thank you. so there is no way we can use -@num in executing stored procedure statement.



quote:
Originally posted by PeterNeo

Hi,

Try this one

Declare @num int
select @num = -qty from sales
exec salesClaim @id, @num

Go to Top of Page

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2007-09-10 : 01:56:29
Yes(as of my knowledge), why do u want like this can u post u r stored procedure code.
Go to Top of Page

chih
Posting Yak Master

154 Posts

Posted - 2007-09-10 : 02:09:45
I don't have scripts, it is just one of my colleagues ask me.
Thanks you!


quote:
Originally posted by PeterNeo

Yes(as of my knowledge), why do u want like this can u post u r stored procedure code.

Go to Top of Page

Zoroaster
Aged Yak Warrior

702 Posts

Posted - 2007-09-10 : 09:16:47
quote:
Originally posted by chih

Hi Zoroaster,

Thank you. so there is no way we can use -@num in executing stored procedure statement.



Correct.



Future guru in the making.
Go to Top of Page
   

- Advertisement -