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 |
|
vl262610
Starting Member
6 Posts |
Posted - 2006-06-13 : 13:39:30
|
| Hello there, maybe somebody can help me solving this problem:I would like to start a scalar-procedure using a variable for the database name, but it is not working.This works:exec @JulianTime = dwhont.dbo.DateTime2Julian @ReloadTable, 'Time'Now I want to replace dwhont for a variable set earlier in the script. This does not seem to be working:set @DbVariable = 'dwhont'exec @JulianTime = @DbVariable.dbo.DateTime2Julian @ReloadTable, 'Time' |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-06-13 : 16:49:45
|
| declare @sql nvarchar(1000)select @sql = 'exec @JulianTime = ' + @DbVariable + '.dbo.DateTime2Julian ''' + @ReloadTable + ''', ''Time'''exec sp_executesql @sql, N'@JulianTime int out' @JulianTime outDatatypes might be wrong.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
vl262610
Starting Member
6 Posts |
Posted - 2006-06-14 : 03:28:13
|
| Thanks for replying. Your solution works fine.Had to refer to the sp_executesql syntax cause you missed a comma before the last part - @JulianTime out |
 |
|
|
|
|
|