set@Subtable='[table that uses id from source table]'
set@Roottable='[source table]'
set@idColumn='[idColumnName]'
SET@SQLStatement='SELECT * FROM '+@Subtable+' as st '+' where not exists(select * from '+@Roottable+' as rt where st.'+@idColumn+'=rt.'+@idColumn+')and '+@idColumn+' is not null'
AS BEGIN declare @ParameterOfStoredPRocedureToExecute1 varchar(255) declare cur cursor for select ColumnWithPArameterValue from TblToReadFrom -- or from dbo.MyTableFunction()
open cur fetch next from cur into @ParameterOfStoredPRocedureToExecute1 while @@fetch_status = 0 begin exec [dbo].[StoredProcedureToExecute] @ParameterOfStoredPRocedureToExecute1 fetch next from cur into @ParameterOfStoredPRocedureToExecute1
BEGIN
set @Tablename= 'tablename'
declare @tablename as nvarchar(max)
Select Distinct
o.Name 'TableName',
op.Name 'DependentObject',
op.XType 'objecttype'
From SysObjects o
INNER Join SysDepends d ON d.DepId = o.Id
INNER Join SysObjects op on op.Id = d.Id
Where o.XType = 'U' and o.Name= @Tablename
END
USE [DatabaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[updateLastEditTime]
ON [dbo].[LogonLog]
FOR UPDATE, INSERT
AS
UPDATE LogonLog SET [timestamp] = CURRENT_TIMESTAMP
FROM LogonLog Inner Join Inserted On
LogonLog.username = Inserted.username
and LogonLog.computername = Inserted.computername