반응형
  1. /**********************************************************************************************
    -- Title : [2k] 업데이트와 함께 변수에 값 저장하기
    -- Reference : 웹검색
    -- Key word : update, set
    **********************************************************************************************/
  2. use pubs
  3. begin tran
        declare @price money
  4.     select price "원래값" from titles
        where title_id = 'bu1032'
  5.     update titles
        set @price = price = price + 1   -- 업데이트와 동시에 변수 저장
        where title_id = 'bu1032'
  6.     select @price "저장된 변수값"
  7.     select price "변경된값" from titles
        where title_id = 'bu1032'
    rollback
  8.     select @price "롤백 이후의 변수값"
  9.     select price "롤백 이후의 값" from titles
        where title_id = 'bu1032'
반응형

+ Recent posts