Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Create a table valued function to get dates from a table and run a query

$
0
0
Hi All,


Here is my requirement,

I need to create a table valued function which basically runs the following query for the current date

SELECT * FROM OPENQUERY([abc],
'select * from aaa.fnData(''11-18-2013'',''11-18-2013'',3)')

and insert it into a table which i can basically do like this

INSERT Test
  SELECT * FROM
(
SELECT * FROM OPENQUERY([abc],
'select * from aaa.fnData(GETDATE(),GETDATE(),3)')
) AS X     ;



Its fine until here, but here is where i am stuck at,So i have a table which has only one column named date and some dates in it which will be like lets say

11-17-2013
11-16-2013

as the values of the column , now i must get these dates from the table and run the above open query and insert the data into my test table for each of the dates in that table.


Can someone please help me with any ideas?

If i am not clear please let me know.


Thanks


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>