我们需要创建一个tinymce.get("textfull").getBody().innerHTML = d.Description;
script
,insert
仅新created
offices
和districts
Data table
。我们需要检查新Office
District
和tables
Records
,如果数据存在,我们需要insert
。
我们已经尝试了以下语法,
IF EXISTS (
SELECT 1
FROM [dbo].[office] o
LEFT OUTER JOIN [dbo].[Datatable] a ON (o.OfficeID = a.OfficeID)
WHERE a.OfficeID IS NULL
)
OR (
IF EXISTS (
SELECT 1
FROM [dbo].[District] o
LEFT OUTER JOIN [dbo].[Datatable] a ON (o.DistrictID = DistrictID)
WHERE a.DistrictID IS NULL
)
)
BEGIN
-- //CODE
END
但SSMS为此提供了syntax error
。如何实现上述场景?
答案 0 :(得分:6)
应该是... OR EXISTS(
而不是OR ( if EXISTS(
:
IF EXISTS
(
SELECT 1
FROM [dbo].[office] o
LEFT OUTER JOIN [dbo].[Datatable] a
ON (o.OfficeID = a.OfficeID )
WHERE a.OfficeID IS NULL
)
OR EXISTS
(
SELECT 1
FROM [dbo].[District] o
LEFT OUTER JOIN [dbo].[Datatable] a
ON (o.DistrictID = DistrictID )
WHERE a.DistrictID IS NULL
)
BEGIN
//CODE
END