The present database server I have consists of 6 databases based on Technical & Non technical sectors.
For Technical sector, has 3 DBs namely BizTech, BizTechArchive & BizTechLog
For Non technical sector, has 3 DBs namely BizNonTech, BizNonTechArchive & BizNonTechLog.
BizTech & BizNonTech are the main databases. BizTechArchive & BizNonTechArchive arethe archive Dbs where data is archived when some updation & deletion happens in the main DBs. These archive DBs has all tables present in the main DBs. The other DBs are for logging the error if some error occurs.
For example, in every stored proc of BizTech database, in the CATCH block, error is caught & inserted into respective Log DB tables.
INSERT INTO BizTechLog.dbo.errorlog (Collumn1, Column2..)
How can I pass the database name as a parameter such that I can pass it to every stored procedure in BizNonTech CATCH block i.e. BizNonTech is passed as input param say @dbname & used as
INSERT INTO @dbname.dbo.errorlog (Collumn1, Column2..)
Please guide me on this. Thanks