我正在尝试使用.net应用程序将整个模型插入数据库中。我使用的是用户定义的表格类型。
这是我的过程和用户定义的表;我正在使用SQL Server 2012。
CREATE TYPE [dbo].[TmpAccessRequest] AS TABLE
(
[RequestId] [int] NULL,
[RequesterID] [int] NULL,
[RequestType] [int] NULL,
[NextApprover] [int] NULL,
[RequestStatus] [varchar](100) NULL,
[Delegation] [int] NULL,
[CreatedOn] [date] NULL,
[CreatedBy] [varchar](100) NULL,
[Description] [varchar](max) NULL,
[IsSepecialRequest] [bit] NULL,
[DelegationDetailID] [int] NULL,
[IsActive] [bit] NULL,
[IsDeleted] [bit] NULL,
[ModifiedOn] [date] NULL
)
GO
CREATE PROCEDURE [dbo].[proc_SaveAccessRequest]
(@TmpAR TmpAccessRequest READONLY,
@IsUAMSRequest BIT,
@RequestID INT OUTPUT)
AS
BEGIN
INSERT INTO tblRequests (RequesterID, RequestType, NextApprover, RequestStatus,
Delegation, CreatedOn, CreatedBy, Description,
IsSepecialRequest, DelegationDetailID, IsActive, IsDeleted, ModifiedOn)
SELECT
RequesterID, RequestType, NextApprover, RequestStatus,
Delegation, CreatedOn, CreatedBy, Description,
IsSepecialRequest, DelegationDetailID, IsActive, IsDeleted, ModifiedOn
FROM
@TmpAR
SET @RequestID = SCOPE_IDENTITY()
--SET @RequestID=IDENT_CURRENT('tblRequests')
SELECT @RequestID
END
我要检查是否不应同时插入重复数据。那么我该如何使用用户定义的表类型呢?
答案 0 :(得分:0)
请找到对脚本所做的更改,以避免插入重复的记录。因此,我认为两列数据应该是唯一的,以避免重复,以方便用户理解。
.DEFAULT_GOAL := myAll
include CMake.generated.Makefile
.PHONY: myAll
myAll: cmake-target-for-compilation
$(MAKE) -j $(concurrent-linkers) cmake-target-for-link