Skip to content

Commit

Permalink
updated sql2016-crud-demo (#1156)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpraveenpai authored and kburtram committed Feb 13, 2019
1 parent cd75466 commit fd5c553
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions samples/sql2016-crud-demo.sql
Expand Up @@ -31,8 +31,10 @@ CREATE TABLE [dbo].[Customers]
[CustId] [int] NOT NULL,
[FirstName] [nvarchar](50) NOT NULL,
[LastName] [nvarchar](50) NOT NULL,
[DateOfBirth][date] NOT NULL,
[Email] [nvarchar](50) NOT NULL,


PRIMARY KEY CLUSTERED ([CustId] ASC) ON [PRIMARY]
);
GO
Expand All @@ -42,19 +44,19 @@ SELECT * FROM Customers;
GO

-- Insert sample data into table
INSERT INTO [dbo].[Customers]([CustId],[FirstName],[LastName],[Email])
INSERT INTO [dbo].[Customers]([CustId],[FirstName],[LastName],[DateOfBirth],[Email])
VALUES
(1, 'Amitabh', 'Bachchan', 'angry_young_man@gmail.com'),
(2, 'Abhishek', 'Bachchan', 'abhishek@abhishekbachchan.org'),
(3, 'Aishwarya', 'Rai', 'ash@gmail.com'),
(4, 'Aamir', 'Khan', 'aamir@khan.com')
(1, 'Amitabh', 'Bachchan', '1942-07-10','angry_young_man@gmail.com'),
(2, 'Abhishek', 'Bachchan','1976-05-06','abhishek@abhishekbachchan.org'),
(3, 'Aishwarya', 'Rai','1973-11-06', 'ash@gmail.com'),
(4, 'Aamir', 'Khan','1965-04-28', 'aamir@khan.com')
GO

-- Dump records (we should have 4 records now)
SELECT * FROM Customers;
GO

-- Update 2 records
-- Update 2 records(Sets email as bachans@gmailcom to all those who have lastname as Bachan)
UPDATE Customers
SET Email = 'bachchans@gmail.com'
WHERE LastName = 'Bachchan'
Expand All @@ -64,9 +66,9 @@ GO
SELECT * FROM Customers;
GO

-- Delete a record
-- Delete a record(Customer with DateOfBirth 1965-04-28 i.e, Aamir Khan, will be deleted)
DELETE FROM Customers
WHERE CustId = 4
WHERE DateOfBirth = '1965-04-28'
GO

-- Dump records (note that we only have 3 records now)
Expand Down

0 comments on commit fd5c553

Please sign in to comment.