I created trigger to one table like this
CREATE TRIGGER REPPartition_WorkflowStatus ON [dbo].[WorkflowStatus] AFTER INSERT, UPDATE AS UPDATE [dbo].[WorkflowStatus] SET [PartitionId] = (SELECT [PartitionSettingId] FROM [dbo].[PartitionSetting] where [InstanceName] = @@SERVERNAME) WHERE [StatusID] IN(SELECT [StatusID] from inserted) BEGIN SET NOCOUNT ON END
it works fine, but I have 100 table which have the same column id "
PartitionId
and every Primary Key filed is table name plus the ID, so no problem with that naming convention
so I tried to do like this
EXEC sp_MSforeachtable ' CREATE TRIGGER REPPartition? ON [dbo].[?] AFTER INSERT, UPDATE AS UPDATE [dbo].[Workflow] SET [PartitionId] = (SELECT [PartitionSettingId] FROM [dbo].[PartitionSetting] where [InstanceName] = @@SERVERNAME) WHERE [?ID] IN(SELECT [?ID] from inserted) BEGIN SET NOCOUNT ON END '
but it doesnt work... anyone who can help me?
Binyam Welday