--创建调试环境
if object_id('tbl_t') is null
print 'not exists'
else
drop table tbl_t
create table tbl_t
(
t_t text
)
insert into tbl_t values('123,345')
insert into tbl_t values('123,3456')
select * from tbl_t where t_t like'%123,345%'
--删除表
drop table tbl_t
--结果:
/*(所影响的行数为 1 行)
(所影响的行数为 1 行)t_t
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
123,345
123,3456(所影响的行数为 2 行)
*/
if object_id('tbl_t') is null
print 'not exists'
else
drop table tbl_t
create table tbl_t
(
t_t text
)
insert into tbl_t values('123,345')
insert into tbl_t values('123,3456')
select * from tbl_t where t_t like'%123,345%'
--删除表
drop table tbl_t
--结果:
/*(所影响的行数为 1 行)
(所影响的行数为 1 行)t_t
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
123,345
123,3456(所影响的行数为 2 行)
*/
create table t1 (a text)
insert t1
select '123456'select * from t1declare @a varchar(50)
select @a =cast(a as varchar(50)) from t1
select @a=@a+'789'
update t1
set a=@aselect * from t1
001 001,002,003.......
左边是用户ID ,右边是他拥有的物品,现在用SQL语句实现将物品编号为010的物品放到里面,如何实现.: internetcsdn说的应该可以实现,我想是否有更简单的语句实现,我想做个asp管理,谢谢大家帮忙
你想得到怎样的结果啊?是不是这样?create table t1 (b varchar(10),a text)
insert t1
select '010','123456'select * from t1update t1
set a=cast(a as varchar(10))+b
drop table t1
/*
b a
----------------
010 123456010
*/
insert t1
select '010','123456'select * from t1--update t1
--set a=cast(a as varchar(10))+bselect *,bb=(cast(a as varchar(10))+b) from t1drop table t1
select '010','123456'
union all select '020','654321'
union all ..这是对表格插入数据的一种写法啊.
id 物品 item
----------------
010 苹果 123456
020 香蕉 654321合成后得
id 物品 item
-----------------
010 苹果 123456苹果
020 香蕉 654321香蕉 如果是的话,
上面的语句可以实现的啊
如果不是,
就以上面的形式给数据吧
Select @p=textptr(item) from 表名(uplock) where id='00A’
If @p is not null
Updatetext 表名.item @p null 0 with log “,010”我所说的要求,这样可以实现,我想问问是否还有简单些的语句可以实现,如果你不明白我说的意思,上面的语句的意思应该明白?
但只能说SORRY等高手吧.
Select @p=textptr(item) from 表名(uplock) where id='00A’
If @p is not null
Updatetext 表名.item @p null 0 with log “,010”
没办法,SQL中对text字段的处理就是类似这样,没有什么简便的方法,如果你嫌那样写烦,可以封装成存储过程