Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling stored procedure in an insert statement

Status
Not open for further replies.

sandra64

Programmer
Jun 26, 2002
28
GB
I am trying to call a procedure in an insert statement. The procedure takes in two dates and outputs how many working days are between those dates. I then want to use the output in my insert. Sounds simple enough but I'm going round in cirles with it.


here is my code

declare @numbofdays int
INSERT INTO sac_rfp(closing_date, rfp_sent_date, rfp_sent)
SELECT a.closing_date, a.rfp_sent_date,exec usp_GetWorkingDays closing_date, rfp_sent_date, @numbofdays OUTPUT
FROM advert a

It is complaining about the exec and the from which leads me to believe that the start of the exec needs to be separated from the rest of the statement. I've tried single quotes, double quotes but to no avail, hope someone can help.

cheers Sandra
 
Use a function rather than stored procedure
Very similar but these can be used in select statements

Damian.
 
Thanks for that but I've never written a funtion before so I went into the help and it says that SQL 7.0 doesn't support user-defined functions.

how do I create one?
 
Like you say SQL 7 doesn't have user functions. Only SQL 2000.

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top