假設我有以下疑問我怎麼能單獨的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