1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| USE MASTER
GO
EXEC SP_addlogin 'log1', 'pass1'
EXEC SP_addlogin 'log2', 'pass2'
EXEC SP_addlogin 'log3', 'pass3'
GO
USE mabase
GO
SP_grantdbaccess 'log1', 'user1'
SP_grantdbaccess 'log2', 'user2'
SP_grantdbaccess 'log3', 'user3'
GO
CREATE TABLE user1.t_1 (c int);
CREATE TABLE user2.t_1 (c int);
CREATE TABLE user3.t_1 (c int);
INSERT INTO user1.t_1 VALUES (11)
INSERT INTO user2.t_1 VALUES (22)
INSERT INTO user3.t_1 VALUES (33)
SELECT *, 'user1' AS SCHEMA_NAME
FROM user1.t_1
UNION
SELECT *, 'user2' AS SCHEMA_NAME
FROM user2.t_1
UNION
SELECT *, 'user2' AS SCHEMA_NAME
FROM user2.t_1 |
Partager