日期:2014-05-16 浏览次数:20511 次
----------------------------------------------------------------
-- Author :fredrickhu(小F,向高手学习)
-- Date :2014-02-28 17:50:54
-- Verstion:
-- Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
-- Jul 9 2008 14:43:34
-- Copyright (c) 1988-2008 Microsoft Corporation
-- Enterprise Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
--
----------------------------------------------------------------
--> 测试数据:[U_CCC]
if object_id('[U_CCC]') is not null drop table [U_CCC]
go
create table [U_CCC]([Price] int,[OriPrice] int)
insert [U_CCC]
select 100,0
--------------开始查询--------------------------
SELECT * INTO #tb FROM U_CCC
UPDATE U_CCC SET Price=200,OriPrice=a.Price FROM #tb AS a
SELECT * FROM U_CCC
DROP TABLE #tb
----------------结果----------------------------
/* Price OriPrice
----------- -----------
200 100
(1 行受影响)
*/