T-SQL Declaring Connection String as a Parameter
问题 DECLARE @DBS nvarchar(32) SET @DBS = 'Current' --'Archive' SELECT TOP 100 * FROM [@DBS].[dbo].[table] I have 2 structurally identical databases that sit on the same server. One only saves information for 30 days, for quick report processing, the other saves years worth of information. Either query executes fine if I have Current.dbo.table or Archive.dbo.table, but I'm wanting to set a parameter so we can toggle between Current and Archive, within the same report, so a user can pull from the