Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to implement function on  my database

Posted on 2013-05-25
1
Medium Priority
?
342 Views
Last Modified: 2013-05-25
hi, i have an select statment that i want to put an a user function that returns an table:

dbo.fngetpost(iduser parameter)

this function returns an one row table with some information of that user in particular,

select top 5 t1.* from tbuser as t1
    left outer joing dbo.fngetpost(iduser parameter)

i can't do this above, i want to get the each information for the specific user that is return on the function, how do i put this 2 together?
0
Comment
Question by:rafaelrgl
1 Comment
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 2000 total points
ID: 39196454
Here is how you create an inline table valued function, although if the logic is complex you may need a regular table valued function.

http://msdn.microsoft.com/en-us/library/aa175924(v=sql.80).aspx

http://msdn.microsoft.com/en-us/library/ms191165(v=sql.105).aspx

Then your query would be:

select top 5 t1.*, p.*
from tbuser t1
left outer join (select * from dbo.fngetpost(iduser)) p
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

783 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