Accessing Tables from Other Database which are Created in Master Database

If you want to see tables created in master database to your user database, create the table with name "sp_" as prefix .

You can access the table in any user database.

First create table

USE

CREATE TABLE sp_test (id int)

 

USE master

INSERT INTO sp_test VALUES(1)

INSERT INTO sp_test VALUES(2)

INSERT INTO sp_test VALUES(3)

INSERT INTO sp_test VALUES(4)

INSERT INTO sp_test VALUES(5)

Now select from other user database

USE test

SELECT * FROM sp_test

you will get following.

id
1
2
3
4
5 master

Ebook Download
View all
Learn
View all