现在有4个整数变量:@A=1;@B=2;@C=3;@D=4.
想得到的结果是1234.
有两种方法:1.@A*1000+@B*100+@C*10+@D
2.先将整形变量转化为字符串,然后 @A+@B+@C+@D或者直接定义变量的类型为 varchar操作的数据库是 SQL 。版本是SQL 2008
想得到的结果是1234.
有两种方法:1.@A*1000+@B*100+@C*10+@D
2.先将整形变量转化为字符串,然后 @A+@B+@C+@D或者直接定义变量的类型为 varchar操作的数据库是 SQL 。版本是SQL 2008
set statistics io on
set statistics time on
go
declare @A int,@B int,@C int,@D int
select @A=1,@B=2,@C=3,@D=4
select @A*1000+@B*100+@C*10+@D
go
set statistics profile off
set statistics io off
set statistics time off
go
set statistics profile on
set statistics io on
set statistics time on
go
declare @A int,@B int,@C int,@D int
select @A=1,@B=2,@C=3,@D=4
select cast(@A as varchar(1))+cast(@B as varchar(1))+cast(@C as varchar(1))+cast(@D as varchar(1))
go
set statistics profile off
set statistics io off
set statistics time off
go
set statistics profile on
set statistics io on
set statistics time on
go
declare @A int,@B int,@C int,@D int
select @A=1,@B=2,@C=3,@D=4
select ltrim(@A)+ltrim(@B)+ltrim(@C)+ltrim(@D)
go
set statistics profile off
set statistics io off
set statistics time off
go
/*
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。(1 row(s) affected)SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。(1 row(s) affected)SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。(1 row(s) affected)SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。*/
上面我贴出来的是以文本形式显示结果,而下面的是以网络形式显示结果。SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 1 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。(1 row(s) affected)SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 1 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。(1 row(s) affected)SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。(1 row(s) affected)SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。