SQL 字段格式化的问题 字段: a b c 值 86 000000 a字段的值是会变的,b字段是指c字段的长度也就是六位,怎么写SQL语句使c等于000086呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 update tbset c=right(b+ltrim(a),len(b)) update tb set c=right(b+ltrim(a),6) update tb set c=right(b+ltrim(a),len(b)) if object_id('[tb]') is not null drop table [tb]gocreate table [tb]([a] int,[b] varchar(6),[c] varchar(10))insert [tb]select 86,'000000',null update tbset c=right(b+ltrim(a),len(b))select * from [tb]/**a b c ----------- ------ ---------- 86 000000 000086(所影响的行数为 1 行)**/ update tb set c=substring(a+b,len(a),len(a+b)) 呃,刚看到a是数值型的--也可以这样update tb set c=substring(b+ltrim(a),len(ltrim(a)),len(ltrim(a)+b))--不过没有right简单就是了 请问,约束与触发器冲突 问下SQLserver 如何根据参数是否未空 来添加where条件 更新问题 高分请教 SQL2000支持表内容汉字吗? 把表1 select到的行结果以列的形势插入到表2 SQL Server字段数据类型的简单问题 关于查询的问题(高手请进)100+分,在线 求助!100分 如何得知后台数据库中的table或view是否存在,即判断table或view是否存在的sql语句是什么?而不是返回出错提示! 一段日期的查询 如何快速生成一张千万级表
set c=right(b+ltrim(a),len(b))
update tb
set c=right(b+ltrim(a),len(b))
go
create table [tb]([a] int,[b] varchar(6),[c] varchar(10))
insert [tb]
select 86,'000000',null
update tb
set c=right(b+ltrim(a),len(b))
select * from [tb]
/**
a b c
----------- ------ ----------
86 000000 000086(所影响的行数为 1 行)
**/