遇到1个问题: 将字段中现在的字符串,替换成原字符串+YYY 例如: A字段 DDD VVV CCC 替换成: A字段 DDDYYY VVVYYY CCCYYY--- update tb set a = a + 'YYY'
update 表名 set A=A+'YYY'
declare @t table (myyear int,mymonth int,myday int) insert into @t values(2005,1,1) insert into @t values(2003,2,5) insert into @t values(2006,5,5) insert into @t values(2006,1,2) update @t set myyear=Convert (varchar(10),myyear)+Convert(varchar(10),mymonth)+convert(varchar(10),myday ) select * from @t
update 表名 set A字段=A字段+'YYY'
update 表名 set A=A+'YYY'
update 表名 set A=A+'YYY'提示数据类型 text 和 varchar 在 add 运算符中不兼容。因为 A字段 是text类型。 这样的话怎么做???
update 表名 set A=convert(nvarchar,A)+'YYY'
UPDATE 表名 SET A=CAST(A AS VARCHAR(MAX))+'YYY'
CAST and CONVERT Explicitly convertsan expression of one data type to another. CAST and CONVERT provide similar functionality.Syntax Using CAST:CAST ( expression AS data_type ) Using CONVERT:CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
set a=a+'YYY'
select [a]=a+'YYY' from T
将字段中现在的字符串,替换成原字符串+YYY
例如:
A字段
DDD
VVV
CCC 替换成:
A字段
DDDYYY
VVVYYY
CCCYYY---
update tb set a = a + 'YYY'
insert into @t values(2005,1,1)
insert into @t values(2003,2,5)
insert into @t values(2006,5,5)
insert into @t values(2006,1,2)
update @t set myyear=Convert (varchar(10),myyear)+Convert(varchar(10),mymonth)+convert(varchar(10),myday )
select * from @t
set A字段=A字段+'YYY'
这样的话怎么做???
SET A=CAST(A AS VARCHAR(MAX))+'YYY'
Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.Syntax
Using CAST:CAST ( expression AS data_type ) Using CONVERT:CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
set A字段=A字段+'YYY'