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
 Transact-SQL (2000)
 Calling store procedure from another one

Author  Topic 

alperozgur
Starting Member

16 Posts

Posted - 2006-07-12 : 09:28:18
Hi;
How can i call a store procedure from another store procedure with parameters?
I mean what is the correct syntax of the code below

@CIKISNO VARCHAR(30),
@SATIRNO INT,
@PRJ VARCHAR(4)
as
DECLARE @HARNO VARCHAR(30)
SET @HARNO = (SELECT HAREKETNO FROM MALHAREKET (NOLOCK) WHERE ISLEMNO=@CIKISNO AND ISLEM='Ship' AND ISLEMSATIR=@SATIRNO
EXEC MalCikis_Ship_Iptal @Proje=@PRJ, @HareketNo=@HARNO, @Yil=Year(GetDate())

nr
SQLTeam MVY

12543 Posts

Posted - 2006-07-12 : 09:33:25
You can't include a stored proc call as a column in a select statement.
You can populate a temp table and use that or make the sp into a function and call that in the select.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

alperozgur
Starting Member

16 Posts

Posted - 2006-07-12 : 09:35:09
It's not a column in select statement. It's only for execute...
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-07-12 : 10:29:50
Ok I got the brackets confused. Where is the close bracket meant to be for the select statement?
SET @HARNO =
(
SELECT HAREKETNO FROM MALHAREKET (NOLOCK) WHERE ISLEMNO=@CIKISNO AND ISLEM='Ship' AND ISLEMSATIR=@SATIRNO
EXEC MalCikis_Ship_Iptal @Proje=@PRJ, @HareketNo=@HARNO, @Yil=Year(GetDate())

try
declare @y int
select @y = Year(GetDate())
EXEC MalCikis_Ship_Iptal @Proje=@PRJ, @HareketNo=@HARNO, @Yil=@y

That might solve your problem.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -