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)
 Stored procedure in Function

Author  Topic 

DENIZ3E
Yak Posting Veteran

56 Posts

Posted - 2005-06-18 : 02:15:32
hi,
I WANT TO USE STORED PROCEDURE IN QUERY


QUERY
-------
select
*,(stored procedure)=exec fudgunref 2,orf.duedate,002
FROM orderline orl
LEFT OUTER JOIN orderfiche orf ON ORf.LOGICALREF=ORl.ORDFICHEREF
-------------------------


stored procedure
------------------
create procedure FUDGUNREF @date datetime ,@ITEMREF VARCHAR(10),@FNO VARCHAR(3), @RETURN VARCHAR(3) output
AS

SET DATEFIRST 6
DECLARE @stmt nvarchar(1000),@hafta VARCHAR(3),@HAFTA1 VARCHAR(3),@HAFTA2 VARCHAR(3),@HAFTA3 VARCHAR(3),@HAFTA4 VARCHAR(3),@HAFTA5 VARCHAR(3)

SET @HAFTA=(SELECT DATEPART(WW,@DATE))


SET @stmt = N'select @p1 =' + ' W' + @HAFTA + '-1' +' from F_' + @FNO +'_STOK WHERE ITEMREF= ' + @ITEMREF
exec sp_executesql @stmt, N'@p1 varchar(70) out', @RETURN OUT
IF @RETURN IS NOT NULL

SELECT @RETURN AS 'GUN'

ELSE
SELECT @RETURN=0



madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-18 : 02:45:52
It is not possible
What do you want to do?
Post table structure with sample data and expected result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

xpherion
Starting Member

4 Posts

Posted - 2005-06-18 : 15:06:19
you can use global function and call that function from the query. Put all your stored proc in the functon.

Thanks
sqlhelp.blogspot.com
Go to Top of Page
   

- Advertisement -