我有一个从TBL_DOMAIN
INSERT INTO TBL_STAGING
的SP,但首先我要检查表TBL_STAGING
以确保在截断表TBL_DOMAIN
之前表不为空,如果表TBL_STAGING
有多个记录,则继续截断表TBL_DOMAIN
然后运行INSERT,ELSE消息,表示表TBL_STAGING
为EMPTY并退出SP。我的目标是确保表TBL_DOMAIN
仍然有数据甚至是旧的。我是非常新的SQL请帮忙。
CREATE PROCEDURE [dbo].[SP_INSERT_ALL_DOMAIN]
WITH EXECUTE AS CALLER
AS
BEGIN
BEGIN TRANSACTION NT_ALL_DOMAIN
INSERT INTO TBL_DOMAIN
(DOMAIN_NAME,
DISTINGUISHED_NAME,
EMAIL_ADDR_I)
SELECT DOMAIN_NAME,
DISTINGUISHED_NAME,
EMAIL_ADDR_I
FROM TBL_STAGING
答案 0 :(得分:1)
首先,您需要检查TBL_STAGING是否有数据:
=Sum(iif(
Fields!Sub.Value = "Ins",
0,
IIF(Fields!Sub.Value = "Ins - Int", 0, Fields!A.Value)
))