Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Databases Programming Interviews:BtrieveClipperData ModelingData StructuresDatabase AdministrationDatabase Administrator (DBA)Database AnalystDatabase DeveloperDB DevelopmentEDI/Data Integration ExpertFirebirdHierarchicalIBM DB2InformixJava DatabaseMariaDBMicrosoft Access DeveloperMongoDBMS SQL ServerMySQL ProgrammingNetworkNoSQLObject RelationalPostgrePostgreSQLProgressRDBMSRelationalSQLSQL AdministratorSQL and PL/SQLSQL Notification ServicesSQL server 2008SSRSStored ProcedureSybaseTeradata
Copyright © 2018. All Rights Reserved
MS SQL Server Interview Question:
How To Update Values in a Table with UPDATE Statements in MS SQL Server?
Submitted by: AdministratorIf you want to update some values in one row or multiple rows in a table, you can use the UPDATE statement. The tutorial script below shows a good example:
SELECT * FROM ggl_links WHERE id = 101
GO
id url notes counts created
101 www.globalguideline.com NULL 0 2006-04-30
UPDATE ggl_links SET counts = 999, notes = 'Good.'
WHERE id = 101;
GO
(1 row(s) affected)
SELECT * FROM ggl_links WHERE id = 101
GO
id url notes counts created
101 www.globalguideline.com Good. 999 2006-04-30
As you can see, the SET clause takes column and value pairs to provide new values, while the WHERE clause defines which row to apply the update.
Submitted by: Administrator
SELECT * FROM ggl_links WHERE id = 101
GO
id url notes counts created
101 www.globalguideline.com NULL 0 2006-04-30
UPDATE ggl_links SET counts = 999, notes = 'Good.'
WHERE id = 101;
GO
(1 row(s) affected)
SELECT * FROM ggl_links WHERE id = 101
GO
id url notes counts created
101 www.globalguideline.com Good. 999 2006-04-30
As you can see, the SET clause takes column and value pairs to provide new values, while the WHERE clause defines which row to apply the update.
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.