Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to write a function to create a table.

Author  Topic 

psiri3
Starting Member

5 Posts

Posted - 2011-06-22 : 22:51:41
Hello all, This is an emergency requirement of client..

I need to write a function to populate a temporary table.


My Query is this way:



select p.product,max(p.price)as price
into #temptable
from owner.products p,
(select product,max(date) from owner.products where product = 'mouse' group by product) q
where p.product = q.product and
p.date = q.date
group by p.product



This is my query..where in I am populating the data into a table named "temptable"

I need to implement this little query by using a function..
I would be passing a parameter for 'mouse' through the functiu=on as Input..
Please help me..



khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-06-22 : 23:08:11
you can't use FUNCTION to do that. You have to do it with Stored Procedure


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -