社区
MS-SQL Server
帖子详情
[help]一个update sql怎么写
x0y1z2
2005-03-21 10:53:23
create table Test(
pk varchar(10) primary key,
code varchar(12),
year int,
fieldA varchar(20)
fiedlB int
);
表中有2002,2003,2004,2005的数据,每年code大多数一样的,现在要把2005的fieldA,fieldB 改为和2004的相同code对应的fieldA,fieldB
...全文
125
7
打赏
收藏
[help]一个update sql怎么写
create table Test( pk varchar(10) primary key, code varchar(12), year int, fieldA varchar(20) fiedlB int ); 表中有2002,2003,2004,2005的数据,每年code大多数一样的,现在要把2005的fieldA,fieldB 改为和2004的相同code对应的fieldA,fieldB
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
x0y1z2
2005-03-21
打赏
举报
回复
赫赫,好像是的
ps:你上面的方法可以用的
lsxaa
2005-03-21
打赏
举报
回复
and a.code='0101101010'
and a.code='01011010' 这两个不一样啊
x0y1z2
2005-03-21
打赏
举报
回复
运行
update test set fieldA =a.fieldA ,fiedlB =a.fiedlB
from test as a where code=a.code and year=2005 and a.year=2004
and a.code='01011010'
(0 row(s) affected)
但是运行
select * from test as a ,test as b
where b.code=a.code and b.year=2005 and a.year=2004
and a.code='0101101010'
却有一条记录阿,
我什么地方写错了阿?
lsxaa
2005-03-21
打赏
举报
回复
不支持别名,这样
select * into #t from 表
update test set fieldA=#t.fieldA ,fieldB=#t.fieldB
from #t where test.code=#t.code and test.year=2005 and #t.year=2004
x0y1z2
2005-03-21
打赏
举报
回复
The column prefix 'test' does not match with a table name or alias name used in the query.
但是test 表示有的阿
x0y1z2
2005-03-21
打赏
举报
回复
The column prefix 'test' does not match with a table name or alias name used in the query.
jinjazz
2005-03-21
打赏
举报
回复
update test set fieldA=a.fieldA ,fieldB=a.fieldB
from test a where test.code=a.code and test.year=2005 and a.year=2004
SQL
的
update
问题 (得到
HELP
)
如果我想将
一个
表中的某些字段的数据更新到另
一个
表,以关健字pd_ID为相关联,又怎样
写
SQL
呢?例如:A表:pd_ID name expression1 test1 abc2 test2 asdf3 test3 zxcvB表:pd_ID name expr
sp_
help
如果执行不带参数的 sp_
help
,则返回当前数据库中现有的所有类型对象的摘要信息。 列名数据类型描述Namenvarchar(128)对象名Ownernvarchar(128)对象所有者Object_typenvarchar(31)对象类型 如果 name 是
SQL
Server 数据类型或用户定义数据类型,则 sp_
help
返回此结果集。 列名数据类型描述Type_namenvarchar(128)数据类型名称。Storage_typenvarchar(128)
SQL
Server 类
通过
一个
sql
语句,如何做到把1个表的数据插入到另外1个表
前言 有时候,我们往往有这种需求:需要把1个表某个字段的数据根据条件查询出来,再插入到另外
一个
表。这就是表与表之前数据的转移。 这种场景,一般是同步历史数据需要。 假定这两个表分别是A表和B表,并且表结构不一样,只是有部分字段含义一致。 如果数据少还好说,直接在需要插入数据的表中,手工录入即可。但要是成千上万呢,那手工方式肯定是不行的。 一、数据准备 1.表结构 1) 创建帮助表 t_
help
CREATE TABLE `t_
help
`...
ABAP
Help
Document(23):11.1 OPEN
SQL
11.Processing External Data 11.1DataBase Access
SQL
Trace Tool(ST05),
SQL
跟踪分析工具。Index可以有效提高效率,但是仅正向查询where条件,例如:=,like;如果是<>,index没有优化效果。index包含字段1~4个关键字段。 示例:OR没有优化 SELECT * FROM spfli WHE...
sp_
help
MERGE INTO
从备份表中更新字段到正式表中,使用
UPDATE
批量更新大量的数据,会出现效率低下,有时候甚至卡死的情况,后面通过使用 MERGE INTO 代替
UPDATE
执行批量更新,会提升执行效率。 MERGE INTO table_name alias1 USING (table|view|sub_query) alias2 ON (join condition) WHEN MATCHED TH...
MS-SQL Server
34,876
社区成员
254,635
社区内容
发帖
与我相关
我的任务
MS-SQL Server
MS-SQL Server相关内容讨论专区
复制链接
扫一扫
分享
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章