sql server里的查询结果要保存到一个变量里,怎么弄?

2024-12-28 17:41:07
推荐回答(5个)
回答1:

举个例子给你:

declare @a int
declare @b int

select @a=count(*) from sysobjects where name like '%sys%'

select @b=count(*) from sysobjects where name like '%set%'

select @a-@b

回答2:

赞同

检举 | 2011-10-21 10:18 lchy0987 | 十一级
举个例子给你:

declare @a int
declare @b int

select @a=count(*) from sysobjects where name like '%sys%'

select @b=count(*) from sysobjects where name like '%set%'

select @a-@b

回答3:

从数据库读取出来,然后将读取的内容赋值给变量

回答4:

select (select Count(*) from users) usercount,(select Count(*) from ProgramModuleCodes) pcount ,((select Count(*) from ProgramModuleCodes)-(select Count(*) from users)) chabie
我也简单的给些了一个SQL语句 ,,,

回答5:

count返回的就是整型,直接int