G
Guest
In Access Project (2002) and I'm writing a stored procedure to create tables
based on whatever year the user selects. i.e. asmntyear = @year. This
executes correctly but I would also like to use the @year in my table name
(see below). My INTO table name gives me an error at the &.
Is there a way to incorporate this variable in the table name? Do you have
another suggestion?
SELECT dbo.tblPembina_Linear_Master.[Roll Number],
dbo.tblPembina_Linear_Master.LPAUID, dbo.tblPembina_Linear_Master.[Munc
Code],
dbo.tblPembina_Linear_Master.[Municipality Name],
dbo.tblPembina_Linear_Master.Licence, dbo.tblPembina_Linear_Master.[Line ],
dbo.tblPembina_Linear_Master.Description,
dbo.tblPembina_Linear_Master.[Fr Fac ], dbo.tblPembina_Linear_Master.[Fr
Lsd],
dbo.tblPembina_Linear_Master.[Fr Rge],
dbo.tblPembina_Linear_Master.[Fr Twp], dbo.tblPembina_Linear_Master.[Fr Sec],
dbo.tblPembina_Linear_Master.[Fr Mer],
dbo.tblPembina_Linear_Master.[To Fac ], dbo.tblPembina_Linear_Master.[To
Lsd],
dbo.tblPembina_Linear_Master.[To Sec],
dbo.tblPembina_Linear_Master.[To Twp], dbo.tblPembina_Linear_Master.[To Rge],
dbo.tblPembina_Linear_Master.[To Mer],
dbo.tblPembina_Linear_Master.[AUB Status],
dbo.tblPembina_Linear_Master.[Material/Substance/Size],
dbo.tblPembina_Linear_Master.Length,
dbo.tblPembina_Linear_Master.FACILITY, dbo.tblPembina_Linear_Master.COMMENTS,
dbo.tblEubdata.AsmntValue, dbo.tblEubdata.AsmntYr,
dbo.tblPembina_Linear_Master.Rate, dbo.tblPembina_Linear_Master.Depr,
dbo.tblPembina_Linear_Master.[Share %],
dbo.tblMultiplier.Multiplier,
ROUND(((dbo.tblPembina_Linear_Master.Length *
dbo.tblPembina_Linear_Master.Rate) * (dbo.tblPembina_Linear_Master.[Share %]
/ 100))
* (dbo.tblPembina_Linear_Master.Depr / 100) *
dbo.tblMultiplier.Multiplier * 0.75, - 1) AS check_value
INTO dbo.[tbl] + @year + [LinearAssessment]
FROM dbo.tblEubdata INNER JOIN
dbo.tblMultiplier ON dbo.tblEubdata.AsmntYr =
dbo.tblMultiplier.Year INNER JOIN
dbo.tblPembina_Linear_Master ON dbo.tblEubdata.LPAUID
= dbo.tblPembina_Linear_Master.LPAUID INNER JOIN
dbo.tblCreateTableMunc ON
dbo.tblPembina_Linear_Master.[Municipality Name] =
dbo.tblCreateTableMunc.[Municipality Name]
WHERE (dbo.tblEubdata.AsmntYr = @Year)
based on whatever year the user selects. i.e. asmntyear = @year. This
executes correctly but I would also like to use the @year in my table name
(see below). My INTO table name gives me an error at the &.
Is there a way to incorporate this variable in the table name? Do you have
another suggestion?
SELECT dbo.tblPembina_Linear_Master.[Roll Number],
dbo.tblPembina_Linear_Master.LPAUID, dbo.tblPembina_Linear_Master.[Munc
Code],
dbo.tblPembina_Linear_Master.[Municipality Name],
dbo.tblPembina_Linear_Master.Licence, dbo.tblPembina_Linear_Master.[Line ],
dbo.tblPembina_Linear_Master.Description,
dbo.tblPembina_Linear_Master.[Fr Fac ], dbo.tblPembina_Linear_Master.[Fr
Lsd],
dbo.tblPembina_Linear_Master.[Fr Rge],
dbo.tblPembina_Linear_Master.[Fr Twp], dbo.tblPembina_Linear_Master.[Fr Sec],
dbo.tblPembina_Linear_Master.[Fr Mer],
dbo.tblPembina_Linear_Master.[To Fac ], dbo.tblPembina_Linear_Master.[To
Lsd],
dbo.tblPembina_Linear_Master.[To Sec],
dbo.tblPembina_Linear_Master.[To Twp], dbo.tblPembina_Linear_Master.[To Rge],
dbo.tblPembina_Linear_Master.[To Mer],
dbo.tblPembina_Linear_Master.[AUB Status],
dbo.tblPembina_Linear_Master.[Material/Substance/Size],
dbo.tblPembina_Linear_Master.Length,
dbo.tblPembina_Linear_Master.FACILITY, dbo.tblPembina_Linear_Master.COMMENTS,
dbo.tblEubdata.AsmntValue, dbo.tblEubdata.AsmntYr,
dbo.tblPembina_Linear_Master.Rate, dbo.tblPembina_Linear_Master.Depr,
dbo.tblPembina_Linear_Master.[Share %],
dbo.tblMultiplier.Multiplier,
ROUND(((dbo.tblPembina_Linear_Master.Length *
dbo.tblPembina_Linear_Master.Rate) * (dbo.tblPembina_Linear_Master.[Share %]
/ 100))
* (dbo.tblPembina_Linear_Master.Depr / 100) *
dbo.tblMultiplier.Multiplier * 0.75, - 1) AS check_value
INTO dbo.[tbl] + @year + [LinearAssessment]
FROM dbo.tblEubdata INNER JOIN
dbo.tblMultiplier ON dbo.tblEubdata.AsmntYr =
dbo.tblMultiplier.Year INNER JOIN
dbo.tblPembina_Linear_Master ON dbo.tblEubdata.LPAUID
= dbo.tblPembina_Linear_Master.LPAUID INNER JOIN
dbo.tblCreateTableMunc ON
dbo.tblPembina_Linear_Master.[Municipality Name] =
dbo.tblCreateTableMunc.[Municipality Name]
WHERE (dbo.tblEubdata.AsmntYr = @Year)