Solved

store proceudre or funcion table type:

Posted on 2011-03-01
10
331 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
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 8

Expert Comment

by:Som Tripathi
Comment Utility
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
Comment Utility
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
Comment Utility
I ATTACHED THE FILE
rewritingSP.jpg
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
Comment Utility
You are reading someone's opinion.
0
 
LVL 8

Assisted Solution

by:Som Tripathi
Som Tripathi earned 113 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:enrique_aeo
Comment Utility
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:ewangoya
Comment Utility

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
Comment Utility
actually it is a sp with parameters, so I can not use views
0
 
LVL 32

Assisted Solution

by:ewangoya
ewangoya earned 112 total points
Comment Utility

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
Comment Utility
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article I will describe the Detach & Attach 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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now