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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store Procedure convert into Function

Status
Not open for further replies.

Edimator

IS-IT--Management
Mar 13, 2001
49
VE
Hi, i need convert a stored procedure into a online function.

My tables are DAY01, DAY02 ... DAY31, and y need to put the SP in a select query.

the sp is:

ALTER PROCEDURE dbo.sp_get_calls
@day varchar(15)
AS
begin
declare @sql varchar(400)
set @sql = 'SELECT * FROM DAY' + @table + 'WHERE calltype = 1'
exec (@sql)
end


I realy apreciate any kind of help

 
Please explain what you mean. What result would the function return? Do you intend to return the same data set as the stored procedure or something else? Which SQL Server version are you running? Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
I'm using SQL2000, because i cant put a SP in a query from select, i need to convert the SP above in a inline function with one parameter.

This SP returns the same dataset for all tables that tablename begin with "DAY"

Sorry about my bad english, spanish is my natural language.
 
In SQL 2000, you can create a function that returns a table. You then can use the function in a select statment.

See SQL BOL or this link for details.

Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top