假设我有以下疑问我怎么能单独的SQL查询
select userName, password, email
from tblUsersProfile
where email = '145' or userName = '112'
select userName, password, email
from tblUsersProfile
where email = '80' or userName = '70'
select userName, password, email
from tblUsersProfile
where email = '129' or userName = '169'
select userName, password, email
from tblUsersProfile
where email = '1' or userName = '2'
select
AVG(PokemonLevel) as AvgLevel, PokemonId
from
tblUsersPokemons
group by
PokemonId
order by
PokemonId asc
insert into tblOnlineUsersCounts
select
(select
COUNT(LastMoveTime)
from
tblUsersProfile
where
LastMoveTime > DATEADD(HOUR, -24, sysutcdatetime())),
(select
COUNT(LastMoveTime)
from
tblUsersProfile
where
LastMoveTime > DATEADD(DAY, -7, sysutcdatetime())),
(select
COUNT(LastMoveTime)
from
tblUsersProfile
where
LastMoveTime > DATEADD(DAY, -30, sysutcdatetime()))
select
count(Id) as TotalCount, PokemonId
from
tblUsersPokemons
group by
PokemonId
order by
PokemonId asc
现在,当我在SQL Server Management Studio中执行它们,它会尝试一切,如果一个失败,所有的失败,这意味着所有的人都被计作为一个单一的查询
而且当我在SSMS中右键单击,然后单击分析数据库引擎优化顾问查询还指望他们作为一个单一的查询,而不是每一个都是独立的查询
所以我希望他们的方式,既SSMS应该把它们格式化为他们每个人是一个单独的查询
所以,即使发生故障,SSMS应该执行其它工作的人
什么是实现这一目标的正确格式?
Ty非常多
什么是这些downvotes为?
您应该使用'TRY'和'CATCH'进行错误处理。其他人可能会建议在你的陈述之间使用“GO”。 – 2014-10-19 14:07:33
@RaduGheorghiu例如,当我捕获这个查询在分析器它被视为一个单一的批处理查询,而不是每个人都是独立的查询 – MonsterMMORPG 2014-10-19 14:09:27
@RaduGheorghiu去看起来像工作非常多:) – MonsterMMORPG 2014-10-19 14:10:16