1

Database1

  • --X_Table

  • --Y_Table

  • --Z_Table

Database2

  • --A_Table

  • --B_Table

  • --Z_Table

I have a table which is include product details and I use them for 2 seperated databases .Can i make Z_Table as a shared table?

Because when i want to update Z_Table i have to do that for both DB's.

**i know that i can deal with it with serverside coding (queries).But if i can do that on Sql server that would be nice.

1 Answer 1

7

You can't actually have a shared table. But you can use synonyms. That means you could have Z_Table in Database1 and a synonym in Database2 which points to that table in Database1.

In Database2 you could create it like this.

CREATE SYNONYM Z_Table FOR Database1.Z_Table

Then in queries from Database2 you just reference it by the name. You can treat it just like any other table.

You can read more about synonyms here. https://learn.microsoft.com/en-us/sql/relational-databases/synonyms/synonyms-database-engine

Sign up to request clarification or add additional context in comments.

1 Comment

Why is this not marked as correct answers?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.