
use pubs
go

-- SQL Server 2000 create schema, no schema name
-- USER fred need not exist for this to succeed
CREATE SCHEMA AUTHORIZATION fred
GRANT SELECT ON v1 TO public
CREATE VIEW v1 AS SELECT au_id, au_lname FROM authors
GO

-- SQL Server 2005 create schema with name
-- USER fred needs to exist for this to succeed
CREATE SCHEMA fredstuff AUTHORIZATION fred

-- user's default schema is uschema
CREATE LOGIN u1 WITH PASSWORD = '*Y6fy)'
CREATE LOGIN u2 WITH PASSWORD = '*Y6fy)'
CREATE USER u1 FOR LOGIN u1 WITH DEFAULT_SCHEMA = uschema
go
-- user's default schema is dbo
CREATE USER u2 FOR LOGIN u2
go

