如何在sql server中插入Previous值和New Value? [英] How to insert Previous value and New Value in sql server?
本文介绍了如何在sql server中插入Previous值和New Value?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想插入像chennai这样的表城市名称并重新更新delhi两行在sql server中维护
? br />
谢谢提前,
Hi,
I want to insert table city name like chennai and newly update delhi both rows maintain
in sql server ?
Thanks Advance,
推荐答案
我的建议是在表格中放置一个标志,如IsActive基于标志你可以在标志值为1时进行更新,然后在表中插入新行并将旧行标志值更新为0.
Ex:
插入表格(城市,Isactive)
值('新城',1)
更新表格设置Isactive = 0其中city ='old city '和ID ='旧城ID'
My suggestion fro this is put an flag in table like IsActive Based on flag you can do the updation means when the flag value is 1 then insert new row into the Table and update the old row flag value to 0.
Ex:
Insert into table(city ,Isactive)
values('New City',1)
update table set Isactive=0 where city='old city' and ID='Old City ID'
你可以这样做
添加新列
语法:
ALTER TABLE< table_name> ;;
ADD(< newcolumnname>< data_type(>< size>)
you can do this
for Adding New Columns
Syntax:
ALTER TABLE <table_name>;
ADD (<newcolumnname><data_type(><size>)
如何写这种情况的查询或存储过程
How to write query or stored procedure for this situation
这篇关于如何在sql server中插入Previous值和New Value?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文