Solved

how to implement function on  my database

Posted on 2013-05-25
1
326 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
[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
1 Comment
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 500 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

622 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