go
if exists(select * from sysobjects where name = 'Students')
drop table Students
go
create table Students
(
StudentId int identity(10000,1) primary key,--自動標識列,系統自動生成,10000是起始值,1是遞增值
StudentName varchar(20) not null,
Gender char(2) not null,
Birthday datetime not null,
StudentIdNo numeric(18, 0) not null,
Age int not null,
PhoneNumber varchar(50),
StudentAddress varchar(500),
ClassId int not null
)
go
簡單說明:go是批處理的標誌,表示SQLserver將這些SQL語句編譯成一個執行單元,提高執行效率。go是SQLServer的批處理命令,只有代碼編輯器才能識別並處理,編輯其他應用程序就不能使用該命令。由於每個批處理之間是獨立的,因此,在一個批處理出現錯誤時,並不影響其他批處理中SQL代碼的執行。