I have some old database things which are interconnected to some other systems, I have a new database configuration with table names that are somewhat different than the original older database - I want the older systems to still be able to update the database tables as if nothing changed so to speak.
I know in a query I can alias the table name - I am not looking for how to do that.
I want to set the alias in a more permanent fashion; is there a way to do this in SQL Server? If so how?
I had thought on adding a trigger to the original tables on insert, delete, update to accomplish this - but was hoping for something more elegant than to do this for each of the tables I have to do this with.
CodePudding user response:
If the structure of the tables are identical, you can use synonyms.
CREATE SYNONYM <new_table_name>
FOR <old_table_name>;
Otherwise you'll need (updatable) views, possibly with INSTEAD OF triggers implementing the translation.
CodePudding user response:
You can create a view, which in many ways will appear to behave like a table.
create view aliasname
as
select fields1, field2
from originalname
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-view-transact-sql?view=sql-server-ver15
