本文介绍了sqlserver表中的更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张五排的桌子。我想用第一个记录的值更新最后四行。第一行包含主记录。我怎样才能做到这一点。 PLZ帮帮我
提前致谢
kunjammu
Hi,
I have a table with five rows. i want to update the last four rows with the values of first record. First row contain the master record. How can i do that. plz help me
Thanks in advance
kunjammu
推荐答案
UPDATE TABLE_NAME SET
COL_NAME=(SELECT COL_NAME FROM TABLE_NAME WHERE RECNO= 1)
UPDATE myTable
SET
column1 = firstrow.column1,
column1 = firstrow.column1,
column1 = firstrow.column1
FROM
(
SELECT
column1,column2,column3
FROM MyTable
WHERE
RECNO=1
) firstrow
where RECNO<> 1
应该达到目的
希望有所帮助
Milind
That should serve the purpose
Hope that helps
Milind
这篇关于sqlserver表中的更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!