Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

store proceudre or funcion table type:

Posted on 2011-03-01
10
Medium Priority
?
343 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 900 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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 452 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 448 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 900 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

618 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