select ps, '('ltrim(online)+')|('+ltrim(totle)+')' as exp from tb
select ps , exp = '(' + cast(online as varchar) + ')|(' + cast(total as varchar) + ')' from tb
select ps,exp='('+cast(online as varchar(10))+')|('+cast(totle as varchar(10))+')' from 表
--> 测试数据:@tb declare @tb table([ps] varchar(1),[online] int,[totle] int) insert @tb select 'a',0,10 union all select 'b',1,11 union all select 'c',5,8 select ps,exp='('+ltrim(online)+')'+'('+ltrim([totle])+')' from @tb/* ps exp ---- ---------------------------- a (0)(10) b (1)(11) c (5)(8)(3 行受影响) */
select ps, '('+ltrim(online)+')|('+ltrim(totle)+')' as [exp] from tb 修改一楼
create table tb(ps varchar(10), online int, totle int) insert into tb values('a' , 0 , 10 ) insert into tb values('b' , 1 , 11 ) insert into tb values('c' , 5 , 8 ) goselect ps , exp = '(' + cast(online as varchar) + ')|(' + cast(totle as varchar) + ')' from tbdrop table tb/* ps exp ---------- ----------------------------------------------------------------- a (0)|(10) b (1)|(11) c (5)|(8)(所影响的行数为 3 行) */
select ps,exp='('+ltrim(online)+')|'+'('+ltrim([totle])+')' from @tb
if object_id('[tb]') is not null drop table [tb] go create table [tb]([ps] varchar(1),[online] int,[totle] int) insert [tb] select 'a',0,10 union all select 'b',1,11 union all select 'c',5,8select ps, '('+ltrim([online])+')|('+ltrim([totle])+')' as exp from tb --测试结果: /* ps exp ---- ----------------------------- a (0)|(10) b (1)|(11) c (5)|(8)(3 行受影响)*/
select ps,'('+ltrim(online)+')|('+ltrim(totle)+')' as exp from tb
declare @tb table([ps] varchar(1),[online] int,[totle] int) insert @tb select 'a',0,10 union all select 'b',1,11 union all select 'c',5,8 select ps, reg = '(' + ltrim(online) +')|' + '(' + ltrim(totle) + ')' from @tb
ps,
'('ltrim(online)+')|('+ltrim(totle)+')' as exp
from
tb
--> 测试数据:@tb
declare @tb table([ps] varchar(1),[online] int,[totle] int)
insert @tb
select 'a',0,10 union all
select 'b',1,11 union all
select 'c',5,8
select ps,exp='('+ltrim(online)+')'+'('+ltrim([totle])+')' from @tb/*
ps exp
---- ----------------------------
a (0)(10)
b (1)(11)
c (5)(8)(3 行受影响)
*/
ps,
'('+ltrim(online)+')|('+ltrim(totle)+')' as [exp]
from
tb
修改一楼
insert into tb values('a' , 0 , 10 )
insert into tb values('b' , 1 , 11 )
insert into tb values('c' , 5 , 8 )
goselect ps , exp = '(' + cast(online as varchar) + ')|(' + cast(totle as varchar) + ')' from tbdrop table tb/*
ps exp
---------- -----------------------------------------------------------------
a (0)|(10)
b (1)|(11)
c (5)|(8)(所影响的行数为 3 行)
*/
go
create table [tb]([ps] varchar(1),[online] int,[totle] int)
insert [tb]
select 'a',0,10 union all
select 'b',1,11 union all
select 'c',5,8select
ps,
'('+ltrim([online])+')|('+ltrim([totle])+')' as exp
from
tb
--测试结果:
/*
ps exp
---- -----------------------------
a (0)|(10)
b (1)|(11)
c (5)|(8)(3 行受影响)*/
declare @tb table([ps] varchar(1),[online] int,[totle] int)
insert @tb
select 'a',0,10 union all
select 'b',1,11 union all
select 'c',5,8
select ps,
reg = '(' + ltrim(online) +')|' + '(' + ltrim(totle) + ')'
from @tb