The following describes how to create an sqlserver Database Code Template, and a template for creating a table. During development, you can copy it and change it directly.
Hope you can help me! Copy code The Code is as follows: use [Master]
Go
If exists (select 1 from sysdatabases where name = n' hktemp ')
Begin
Drop database hktemp -- if the database exists, delete the database first.
End
Go
Create Database hktemp
On
Primary -- create a master database file
(
Name = 'hktemp ',
Filename = 'e: \ databases \ hktemp. dbf ',
Size = 5 MB,
Maxsize = 20 mb,
Filegrowth = 1 MB
)
Log On -- create a log file
(
Name = 'hktemplog ',
Filename = 'e: \ databases \ hktemp. ldf ',
Size = 2 MB,
Maxsize = 20 mb,
Filegrowth = 1 MB
)
Go
-- Add a table
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 (20) not null,
Snickname nvarchar (20 ),
Spassword nvarchar (30) 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 = OFF) on [primary]
) On [primary]
End
Go
-- Add comments
Exec sys. sp_addextendedproperty @ name = n' MS _ description', @ value = n' ', @ 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'