Pages

Monday, 24 February 2014

Update and Delete Top N records

Once table created enter some dummy data like as shown below

Check below methods to use Top keyword or clause with update and delete statements

Top keyword with Update Statement

Syntax to use top keyword with update statement

UPDATE TOP(N) Table1 SET Column1='somevalue'
Example

UPDATE TOP(2) UserInformation SET UserName='test2'
Once we run above query our table UserInformation will contain data like as shown below

Output

Top keyword with delete statement

Syntax to use top keyword with delete statement

DELETE TOP(N) FROM Table1
Example

DELETE TOP(2) FROm UserInformation
Once we run above query our table UserInformation will contain data like as shown below

No comments:

Post a Comment