Solved

store proceudre or funcion table type:

Posted on 2011-03-01
10
339 Views
Last Modified: 2012-05-11
i have this procedure
   CREATE PROC Production.LongLeadProducts
AS
  SELECT      Name, ProductNumber
  FROM      Production.Product
  WHERE      DaysToManufacture >= 1
GO

I was reading.
recommend that converts sp to  the function of such a table, I wonder why?
0
Comment
Question by:enrique_aeo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 8

Expert Comment

by:Som Tripathi
ID: 35010418
Where did you read this?

Stored procedure and function have their own scope and usage. Such a conversion is never done by SQL Server.
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 225 total points
ID: 35010461
Honestly, I likely wouldn't use a procedure or a function for such a simple select. If anything, MAYBE a view.  You have no input criteria so I see no reason for it to be a procedure/function.
0
 

Author Comment

by:enrique_aeo
ID: 35010569
I ATTACHED THE FILE
rewritingSP.jpg
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 35010591
You are reading someone's opinion.
0
 
LVL 8

Assisted Solution

by:Som Tripathi
Som Tripathi earned 113 total points
ID: 35010687
Enrique,

I think you have asked this question earlier two times -

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL_Server_2008/Q_26547587.html

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL_Server_2008/Q_26689460.html

What interesting research you are doing, please let us know.. :)
0
 

Author Comment

by:enrique_aeo
ID: 35011198
so is a friend, now I want to know why a store procedure to select should be a function of the type table
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35011470

It should not be either. You are simply displaying data, there are no parameters, inserts or edits and your where clause is constant
Just use a view as suggested earlier
0
 

Author Comment

by:enrique_aeo
ID: 35020361
actually it is a sp with parameters, so I can not use views
0
 
LVL 32

Assisted Solution

by:Ephraim Wangoya
Ephraim Wangoya earned 112 total points
ID: 35020879

it would have been better if you provided a real representation of the SP

If you want to join the results to a different table then you can convert it to a table valued function
0
 
LVL 39

Assisted Solution

by:BrandonGalderisi
BrandonGalderisi earned 225 total points
ID: 35022084
You can still have "parameters" on views.  You just add a where clause to the select.  I'm not saying it's always that simple, but sometimes it is.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question