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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-03-22 : 07:53:44
|
| Klaus writes "I have searched, with no luck, however the answer is proberly straight forward.I have a table with working dates adjusting for holidays. For a given date and a number of days, #days, I need to get the date #days from the input date. This date is used in alot of different queries, so I need it to return as value I can assign to a parameter. I tryed the below (also as a stored procedure with an out variable with no succes), but I am having trouble getting the value out for further calculations."This is working but how do I get the value into a parameter"declare @dato as smalldatetime, @ndays as intset @dato = '03-18-2005'set @ndays = 3declare @vSQL varchar(1000)set @vSQL = 'select top ' + convert(varchar, @ndays) + ' DKK from inv_holidays where dkk>cast('''+convert(varchar,@dato)+''' as smalldatetime) Order by DKK'set @vSQL ='select top 1 DKK from inv_holidays where dkk in ('+@vSQL+') order by dkk desc'Execute (@vSQL)" |
|
|
dev45
Yak Posting Veteran
54 Posts |
Posted - 2005-03-22 : 08:16:55
|
| it may not be the best solution, but it's an ideau can have a table (or create a temporary table) let's say : theTable then alter @vsql to insert the data in theTable then u can retrieve the values from theTable with a select statement(take a look at the sp_executeSql stored proc) |
 |
|
|
|
|
|