我想写的是触发点。 当表1中出现条目时,表2应插入同样的数值。 在表1的某些领域,必须更新表2。 我如何知道是否添加或更新价值?
我被插入,以添加价值。
请指导我。
我想写的是触发点。 当表1中出现条目时,表2应插入同样的数值。 在表1的某些领域,必须更新表2。 我如何知道是否添加或更新价值?
我被插入,以添加价值。
请指导我。
这里,你将知道在这样的触发点中是否添加或更新价值:
INSERT
, the inserted
dynamic table is populated with the new valuesUPDATE
, the inserted
dynamic table is populated with the new values of the records that were updated, and the deleted
dynamic table is poulated with the old values of the records that were updated因此,如果<代码>删除编码>表格中包含(假设你有背栏)的复制件(见<>编码>。 表格可以保证,该编码为UPD
,造成触发。 如果<代码>删除 表格是空的,反之,是<代码>。 INSERT。
use this trigger to solve your problem..
create TRIGGER [dbo].[insert_Assets_Tran]
ON [dbo].[AssetMaster]
AFTER INSERT , UPDATE
AS BEGIN
DECLARE @isnum TINYINT;
SlectT @isnum = COUNT(*)
IF (@isnum = 1)
INSERT INTO AssetTransaction
select [AssetId],[Brandname],[SrNo],[Modelno],[Processor],[Ram],[Hdd],[Display],[Os],[Office],[Purchasedt]
,[Expirydt],[Vendor],[VendorAMC],[Typename],[LocationName],[Empid],[CreatedBy],[CreatedOn],[ModifiedBy]
,[ModifiedOn],[Remark],[AssetStatus],[Category],[Oylstartdt],[Oylenddt],[Configuration]
,[AStatus],[Tassign]
FROM inserted;
ELSE
RAISERROR( some fields not supplied , 16, 1)
WITH SETERROR;
END
I have installed ASP.NET application with database on our server. ASP.NET application created database using connection string below. The problem is that I do not see database in SQL Server Management ...
What datatype is the most efficient to store a number such as 11.111. The numbers will have up 2 digits before the point and up to three after. Currently the column is a bigint , I am guessing that ...
是否需要在提瓜表之后更新表格统计数据,还是自动更新?
Ok, so I ve got a bit of a SQL and Powershell problem. There are 2 SQL scripts, one to setup 4 different global stored procedures. Another to execute them and manipulate data before returning it to PS ...
I add a column of type tinyint and being set to not allow nulls in a table and generate the change scripts. The table has data in it at this time. The script has code that creates a temp table and ...
I am currently working on a particularly complex use-case. Simplifying below :) First, a client record has a many-to-one relationship with a collection of services, that is, a single client may have ...
I have a particularly troublesome xml column to query data from. The schema is fixed by the Quebec Ministry of Revenue so "it is what it is" The important part of the query looks like this: with ...
I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...