The following is a code template for creating a SQL Server database, plus a template to create a table. The development of the time can copy the past direct changes can be used.
I hope I can help!
Copy Code code as follows:
Use [master]
Go
IF EXISTS (SELECT 1 from sysdatabases WHERE name=n ' hktemp ')
BEGIN
DROP Database Hktemp--If a database exists, delete it first
End
Go
CREATE DATABASE Hktemp
On
PRIMARY--Create master database files
(
Name= ' Hktemp ',
Filename= ' E:\Databases\HkTemp.dbf ',
SIZE=5MB,
MAXSIZE=20MB,
Filegrowth=1mb
)
Log on--Creating a journal file
(
Name= ' Hktemplog ',
Filename= ' E:\Databases\HkTemp.ldf ',
SIZE=2MB,
MAXSIZE=20MB,
Filegrowth=1mb
)
Go
--Adding tables
IF not EXISTS (SELECT * from sys.objects WHERE object_id = object_id (n ' hksj_user ') and type in (n ' U '))
BEGIN
CREATE TABLE Hksj_user
(
Id INT IDENTITY (1,1) not NULL,
Sname NVARCHAR is not NULL,
Snickname NVARCHAR (20),
Spassword NVARCHAR () not NULL,
Dcreatedate DATETIME,
Screator NVARCHAR (20),
Semail NVARCHAR (50),
Sphone NVARCHAR (50),
Sidentifyid NVARCHAR (30),
Dlasttimelogon DATETIME
PRIMARY KEY CLUSTERED
(
Id ASC
) with (Ignore_dup_key = out) on [PRIMARY]
) on [PRIMARY]
End
Go
--Add comments
EXEC sys.sp_addextendedproperty @name =n ' ms_description ', @value =n ' login name ', @level0type =n ' SCHEMA ', @level0name =n ' dbo ', @ Level1type=n ' TABLE ', @level1name =n ' Hksj_user ', @level2type =n ' COLUMN ', @level2name =n ' sname '
Go
EXEC sys.sp_addextendedproperty @name =n ' ms_description ', @value =n ' mailbox ', @level0type =n ' SCHEMA ', @level0name =n ' dbo ', @ Level1type=n ' TABLE ', @level1name =n ' Hksj_user ', @level2type =n ' COLUMN ', @level2name =n ' Semail '