Transact-SQL Insert Data Into Table Examples

Tool : Microsoft SQL Server Management Studio (SSMS)

Transact-SQL Create Database And Create Table Examples

The Design of Table [Departments]


Insert Data Into The Table [Departments] Example

/* Insert data into the table [Departments] in the database [SampleDB] */

Use [SampleDB]
Go
Insert into Departments(ID,Name,Location)
Values
(NewID(),'IT','Taipei'),
(NewID(),'Marketing','Taichung'),
(NewID(),'Planning','Hualien'),
(NewID(),'Quality Control','Kaohsiung'),
(NewID(),'Research & Development','Taipei'),
(NewID(),'Sales','Taipei'),
(NewID(),'Finance','Kaohsiung');

Result : Data of The Table [Departments]


The Design of Table [Employees]


Insert Data Into The Table [Employees] Example

/* Insert data into the table [Employees] in the database [SampleDB] */

Use [SampleDB]
Go
Insert into Employees(ID,FirstName,LastName,Gender,Salary,DepartmentID)
Values
(NewID(),'Peter','Hsu','Male',100000,'BD700289-DA44-4797-B8B2-1AC5B2614D1F'),
(NewID(),'Big','Huang','Male',80000,'BD700289-DA44-4797-B8B2-1AC5B2614D1F'),
(NewID(),'Rocket','Tang','Male',65000,'72D5F78A-BEC1-459F-AD18-29DDF70BDF8E'),
(NewID(),'Tom','Shen','Male',35000,'72D5F78A-BEC1-459F-AD18-29DDF70BDF8E'),
(NewID(),'Jenny','Chan','Female',12000,'72D5F78A-BEC1-459F-AD18-29DDF70BDF8E'),
(NewID(),'Mary','Jiang','Female',75000,'AF04717A-62EF-4264-9A5D-3C22FC6F6D90'),
(NewID(),'Sandy','Lin','Female',65000,'AF04717A-62EF-4264-9A5D-3C22FC6F6D90'),
(NewID(),'Vivian','Ju','Female',90000,'AF04717A-62EF-4264-9A5D-3C22FC6F6D90'),
(NewID(),'Kelly','Yin','Female',45000,'443354E0-A761-4BB7-8CDE-4053ABB21B17'),
(NewID(),'John','Yang','Male',55000,'A9ED6397-E216-4C7B-8AE1-C6F8B9006B2E'),
(NewID(),'Jason','Zhu','Male',32000,'A9ED6397-E216-4C7B-8AE1-C6F8B9006B2E'),
(NewID(),'May','Xu','Female',22000,'2638A084-9B1B-452B-A256-EB362BC90150'),
(NewID(),'Emily','Cao','Female',24000,'2638A084-9B1B-452B-A256-EB362BC90150'),
(NewID(),'Amy','Jin','Female',26000,'2638A084-9B1B-452B-A256-EB362BC90150'),
(NewID(),'Ivy','Tao','Female',31000,'14392AAF-83E8-4E30-A86C-EFC9DD71F04B'),
(NewID(),'Miranda','Su','Female',35000,'14392AAF-83E8-4E30-A86C-EFC9DD71F04B'),
(NewID(),'Andrea','Zhao','Female',42000,'14392AAF-83E8-4E30-A86C-EFC9DD71F04B'),
(NewID(),'Anna','Wu','Female',48000,'14392AAF-83E8-4E30-A86C-EFC9DD71F04B'),
(NewID(),'Daisy','Yuan','Female',66000,'14392AAF-83E8-4E30-A86C-EFC9DD71F04B');

Result : Data of The Table [Employees]


張貼留言

0 留言