Hi,
I have a variable error that stated that I have to declare @table which I already declare when I run my query below. Please advise. Thanks
DECLARE @YR varchar(4)
DECLARE @QTR varchar(3)
DECLARE @Table varchar(30)
SET @YR = Year(getdate())
If Month(getdate()) IN (1,2,3)
SET @QTR = '_Q1'
If Month(getdate()) IN (4,5,6)
SET @QTR = '_Q2'
If Month(getdate()) IN (7,8,9)
SET @QTR = '_Q3'
If Month(getdate()) IN (10,11,12)
SET @QTR = '_Q4'
SET @Table = 'dbo.AUDIT2' + @YR
select * from @Table (nolock)