Misc SQL Server UPDATE Examples

UPDATE - Single row

Update a single row of data.

BEGIN TRANSACTION
GO

UPDATE [dbo].[Students]
SET    employee_id_fk                = '3208'  ,
       gender_code                   = 'F'     ,
       marital_status_code           = 'M'  
WHERE  student_id = 11  
GO

COMMIT TRANSACTION
GO

UPDATE - Update multiple rows

Update multiple rows of data..

BEGIN TRANSACTION
GO

UPDATE [dbo].[ClassConvenings]
SET     acitve_flg                    = 2  
WHERE   class_convene_date > '2005-1-01 00:00:00.0' 
   AND  class_convene_date < '2005-12-31 00:00:00.0'
GO

COMMIT TRANSACTION
GO  
 Collapse All    Expand All
Custom Search

SQL Server Information and Resources