Solved

how to implement function on  my database

Posted on 2013-05-25
1
309 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 500 total points
Comment Utility
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

In this article I will describe the Copy Database Wizard 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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

762 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

12 Experts available now in Live!

Get 1:1 Help Now