Accessing tables in 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
Accessing tables in other database which are created in master database. Accessing tables in other database which are created in master database. Reviewed by kamal kumar das on February 22, 2012 Rating: 5

No comments:

ads 728x90 B
Powered by Blogger.