Contents

1 襦蠏語
2 ろる
3 覦 蟠覿
4
5 谿瑚


1 襦蠏語 #

--襦蠏語 
USE master;

IF EXISTS (SELECT * FROM sys.server_principals WHERE name = 'yasicom')
	DROP LOGIN yasicom;

CREATE LOGIN yasicom
WITH 
	PASSWORD = 'pw1234!@#$' 
,	DEFAULT_DATABASE = tempdb
,	CHECK_EXPIRATION = OFF
,	CHECK_POLICY = OFF;
GO	

2 ろる #

--ろる 
USE tempdb;

IF EXISTS(SELECT * FROM sys.schemas WHERE name = 'TestSchema')
	DROP SCHEMA PubDiv;
GO

CREATE SCHEMA TestSchema
GO

--alter schema dbo transfer ABC.TableAAA

3 覦 蟠覿 #

-- 
IF EXISTS(select * from sys.database_principals WHERE name = 'yasicom')
	DROP USER yasicom;
GO

CREATE USER yasicom FOR LOGIN yasicom
WITH DEFAULT_SCHEMA = TestSchema;
GO

--蟠覿
GRANT SELECT ON SCHEMA::TestSchema TO yasicom;
GO

/*
DB 蟆曙
EXEC sp_addrolemember 'db_owner', '覈'
GO
*/

4 #

--ろ
CREATE TABLE TestSchema.Test(nm varchar(20));
INSERT TestSchema.Test VALUES('Hello World!');

--覲蟆:yasicom
EXECUTE AS USER = 'yasicom';
SELECT USER_NAME(); --yasicom

SELECT * FROM TestSchema.Test

--覲蟆:dbo
REVERT
SELECT USER_NAME(); --dbo

5 谿瑚 #

覓語..
ALTER AUTHORIZATION ON Database::XXXX TO sa;