T-SQL to create the table

1.1 Creating a database

  

IF DB_ID('TEST') IS NULL
  CREATE DATABASE  TEST
DB_ID function checks whether there is a database named TEST, does not exist, then return NULL. 

1.2 Create a table

- Use [the TEST] database
the USE [the TEST]
--OBJECT_ID function checks whether the current database exists Employees table, this table indicates that the user U, the OBJECT_ID function is received and a table name
- type as its input. If this table exists, the function returns the ID of the table, the following can be used to print out the data Print.
The OBJECT_ID the IF ( 'the Employees', 'the U-') the NOT NULL the IS
the DROP TABLE the Employees - Print the OBJECT_ID ( 'the Employees', 'the U-')

--IDENTITY主键递增
CREATE TABLE Employees
(

NAME VARCHAR(30) NULL,
ID [int] IDENTITY(1,1) NOT NULL,
-- CONSTRAINT PK_Employees
Primary Key(ID)
);

 

Guess you like

Origin www.cnblogs.com/anjingdian/p/11519478.html