我有超過3個sql表。如何在一個腳本中的多個sql表中檢查數據是否存在?
現在我想從所有表格select count(*)
,但我怎麼能做到這一點?
我想知道數據是否存在的所有表中或不
I need to check the row count from previous business day ~15% for any table and it sends an email alert
我試着像下面請大家幫我完成
PROCEDURE [dbo].[SendEmail_WSOTableDataAlert]
AS
BEGIN
declare @err int
IF NOT EXISTS (select 1 from T1) OR
NOT EXISTS (select 1 from T2)
BEGIN
set @error=1
END
//here i need to show which table is having empty data how can i do this please help
SET @tableHTML = @tableHTML + +
'</TABLE>' + @EmailFooter;
@error =1
then
發送郵件
END
但是我如何知道哪個表有0值? – Neo 2012-07-10 14:23:34
僅當所有表都爲空時,此查詢才返回零;當三個表中的任何**都爲空時,看起來OP正在尋找一個零。 – dasblinkenlight 2012-07-10 14:23:37
@dasblinkenlight你是對的,並已更新我的答案。 OP甚至編輯了這個問題。讓我們看看最終被問到的是什麼 – codingbiz 2012-07-10 14:45:30