询问一条undate语句

opou 2008-07-29 10:01:40

create table tb4(a int, b int, c int)
select * from tb4
--显示:
a b c
1 1 2 3
2 4 5 6
3 7 8 9
4 7 8 9

我想修改第四行中的8为10。
如何修改?
...全文
229 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChinaJiaBing 2008-07-29
  • 打赏
  • 举报
回复

if object_id('tb4') is not null
drop table tb4
if object_id('c1') is not null
drop table c1
go

create table tb4
( a int,
b int,
c int
)
insert into tb4 select 1,2,3
union all select 4,5,6
union all select 7,8,9
union all select 7,8,9
go

select * ,identity(int,1,1) d INTO c1 from tb4
update c1 set b=10 where d=4
select a,b,c from c1
寒塘鹤影 2008-07-29
  • 打赏
  • 举报
回复
5楼的做法是有用: 他的做法是在原有的表中添加了一个主键字段. 然后,通过主键来修改的.

这样也可以吗?
zdgood 2008-07-29
  • 打赏
  • 举报
回复
5楼的语句可以显示上面的结果。LZ能否把原始的TABLE贴出来看看。
opou 2008-07-29
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 yueqing 的回复:]
SQL code
Create table tb4(a int, b int, c int)
insert into tb4 select 1,2,3 Union all select 4,5,6 Union all select 7,8,9 Union all select 7,8,9
select * from tb4

alter table tb4 add sid int identity(1,1)
select * from tb4
update tb4 set b=10 where sid=4
alter table tb4 drop column sid

select * from tb4
drop table tb4
[/Quote]

列名 'sid' 无效。
yueqing 2008-07-29
  • 打赏
  • 举报
回复

Create table tb4(a int, b int, c int)
insert into tb4 select 1,2,3 Union all select 4,5,6 Union all select 7,8,9 Union all select 7,8,9
select * from tb4

alter table tb4 add sid int identity(1,1)
select * from tb4
update tb4 set b=10 where sid=4
alter table tb4 drop column sid

select * from tb4
drop table tb4

水族杰纶 2008-07-29
  • 打赏
  • 举报
回复
if object_id('tb1') is not null
drop table tb1
go
create table tb1(a int, b int, c int)
insert tb1 select
1, 2, 3 union all select
4, 5, 6 union all select
7, 8, 9 union all select
7, 8, 9
if object_id('tempdb..#temp') is not null
drop table #temp
select identity(int,1,1) ID,* into #temp from tb1
update #temp set b=10 where id=4
truncate table tb1
insert tb1(a,b,c) select a,b,c from #temp
select * from tb1
drop table #temp

(4 行受影响)

(4 行受影响)

(1 行受影响)

(4 行受影响)
a b c
----------- ----------- -----------
1 2 3
4 5 6
7 8 9
7 10 9

(4 行受影响)
opou 2008-07-29
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 WANGXUELLD 的回复:]
不知道搞什么
[/Quote]
3行和4行的数据是一模一样的,我只想修改第四行的b=10
wangxuelid 2008-07-29
  • 打赏
  • 举报
回复
不知道搞什么
opou 2008-07-29
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 wackyboy 的回复:]
SQL code
alter table tb4 add sid int identity(1,1)
update tb4 set b=10 where sid=4
alter table tb4 drop column sid
[/Quote]
还是不行啊
wackyboy 2008-07-29
  • 打赏
  • 举报
回复

alter table tb4 add sid int identity(1,1)
update tb4 set b=10 where sid=4
alter table tb4 drop column sid
opou 2008-07-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lgxyz 的回复:]
create table tb4(a int, b int, c int)
select * from tb4
--显示:
a b c
1 1 2 3
2 4 5 6
3 7 8 9
4 7 8 9


这两行有什么区别
3 跟4 两行
你表只有三个字段?
重复的话,随便改一行不行?
[/Quote]

最好能修改我想修改的那一行。
opou 2008-07-29
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wackyboy 的回复:]
SQL code
update tb4 set b=10 where b=(select top 1 b from tb4 where b not in (select top 3 b from tb4))
[/Quote]
运行结果:
(所影响的行数为 0 行)
lgxyz 2008-07-29
  • 打赏
  • 举报
回复
create table tb4(a int, b int, c int)
select * from tb4
--显示:
a b c
1 1 2 3
2 4 5 6
3 7 8 9
4 7 8 9


这两行有什么区别
3 跟4 两行
你表只有三个字段?
重复的话,随便改一行不行?
wackyboy 2008-07-29
  • 打赏
  • 举报
回复

update tb4 set b=10 where b=(selet top 1 b from tb4 where b not in (select top 3 b from tb4))
内容概要:本文系统研究了构网型变流器的正负序阻抗解耦特性及其在弱电网环境下的稳定性表现,重点依托Matlab/Simulink仿真平台,构建了详细的阻抗数学模型,设计了解耦控制策略,并采用小信号扫频法进行频域辨识与稳定性验证。研究深入探讨了构网型变流器与传统跟网型逆变器在正负序阻抗特性上的本质差异,结合虚拟同步发电机(VSG)等先进控制技术,分析其在抑制宽频带振荡、削弱锁相环动态耦合等方面的优越性。文中不仅提供了完整的仿真模型与MATLAB代码实现,还整合了光伏、风电、储能、微电网等多类新能源系统的阻抗建模与稳定性分析资源,形成了一套面向新型电力系统稳定性的综合性技术资料体系,具有较强的科研复现与工程参考价值。; 适合人群:面向具备电力电子、电力系统自动化、新能源并网等专业背景的研究生、高校教师及工程技术人员,特别适用于从事阻抗建模、小干扰稳定性分析、宽频振荡机理研究以及撰写高水平学术论文的科研工作者。; 使用场景及目标:①掌握构网型变流器正负序阻抗建模与扫频辨识的仿真方法;②深入理解VSG等构网型控制在弱电网中提升稳定性的内在机理;③复现顶刊论文中的阻抗分析流程与稳定性判据应用;④利用提供的成熟模型与代码加速科研进程,支撑课题研究与学术成果产出。; 阅读建议:建议结合文中提供的Simulink模型与MATLAB代码,按照“理论建模—仿真搭建—扫频激励—频响提取—Nyquist判据分析”的完整流程进行实践操作,重点关注扫频信号的注入方式、频率范围设置及阻抗曲线的物理意义解读,并参考博士论文复现案例深化对复杂动态耦合问题的理解。

34,875

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧