Wednesday, January 29, 2014

Insert Update Delete

Use Automart
--insert update delete

Insert into Person(LastName, FirstName)
Values('Watson', 'John')

Insert into Person(LastName, FirstName)
Values('Marley', 'Bob'),
('Carrol', 'Lewis'),
('Baggins', 'Bilbo')

Create table PersonTemp
(
   PersonKey int,
   Lastname nvarchar(255),
   FirstName nvarchar(255)
)

Insert into PersonTemp(PersonKey, lastName, Firstname)
Select PersonKey, Lastname, FirstName from Person

Insert into Person(LastName, FirstName)
Values(N'στεφενοσ', N'κονγεροσ')

Insert into Person(Lastname)
values('Dedealos')

Insert into Person(firstname)
values('Dedealos')

Insert into Person(LastName,firstname)
values('Madonna', null)

Select * from Person


Select * from PersonTemp
Order by Lastname

begin tran
Update Person
Set LastName='Anders',
firstname='Jason'
Where Personkey=1



rollback tran

Commit tran

Begin tran
Delete from Employee.VehicleServiceDetail
Select * from Employee.VehicleServiceDetail
Rollback tran
Commit tran

Drop Table PersonTemp
--Drop Database Automart

No comments:

Post a Comment