M
Malcolm Cook
Hi,
I have a table which has an INSERT trigger that sets a field as a side effect.
For a while, my ADP client would refresh the current records with fields from the entire row after inserting a new row, which was good, because the screen would should the side-effected column.
Now this has stopped happening and I can't figure out why. (If I refresh the record set I see the side effected update).
I just created another (albeit simpler) table with a similar trigger to set a field as a side effect, and, LO, indeed it works.
So, what's the difference?
I ran the SQL Profiler (1st time) to get a trace.
I can see with the table ItWorks the final three lines doing the insert, getting the @@IDENTITY, and then refreshing the entire row, like this:
exec sp_executesql N'INSERT INTO "SILO"."dbo"."ItWorks" ("c") VALUES (@P1)', N'@P1 nvarchar(2)', N'dd'
SELECT @@IDENTITY
exec sp_executesql N'SELECT * FROM ( SELECT * FROM "dbo"."ItWorks" ) AS DRVD_TBL WHERE "a" = @P1', N'@P1 bigint', 34
However, it the table 'ItFails' the final select is missing:
exec sp_executesql N'INSERT INTO "SILO"."dbo"."ItFails" ("req_ID") VALUES (@P1)', N'@P1 bigint', 994
SELECT @@IDENTITY
I expect that there is something different between them but I can't figure out what could cause the change.
1.. Neither of the tables has a resync command.
2.. They both have IDENTIY columns as (indexed) primary keys
3.. They both have timestamps (I've tried removing them on a lark, but, no dice).
4.. Neither have ROWGUID columns (could this make a difference anyway?)
Behind my sig are the two traces of opening each table from the database window and inserting a single row. If you can make any sense of them or otherwise suggest something else I might check or do I would be grateful. I inserted some blank lines to break the events into logical groups. The 2nd trace has an extra group of trace events for handling foreign key lookups.
Thanks!
--
Malcolm Cook - (e-mail address removed)
Database Applications Manager - Bioinformatics
Stowers Institute for Medical Research - Kansas City, MO USA
----------------This is the trace from 'ItWorks'
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'ItWorks',NULL,NULL)
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'ItWorks',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
SET ROWCOUNT 10000
SELECT * FROM "dbo"."ItWorks"
SET ROWCOUNT 0
EXEC sp_MShelpcolumns N'ItWorks', NULL, N'id', 1
SET NO_BROWSETABLE OFF
EXEC sp_MShelpcolumns N'dbo.ItWorks' , NULL, 'id', 1
SELECT IDENT_SEED('ItWorks')
SELECT IDENT_INCR('ItWorks')
SET NO_BROWSETABLE ON
exec sp_executesql N'INSERT INTO "SILO"."dbo"."ItWorks" ("c") VALUES (@P1)', N'@P1 nvarchar(2)', N'dd'
SELECT @@IDENTITY
exec sp_executesql N'SELECT * FROM ( SELECT * FROM "dbo"."ItWorks" ) AS DRVD_TBL WHERE "a" = @P1', N'@P1 bigint', 34
----------------This is the trace from 'ItFails'
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'ItFails',NULL,NULL)
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'ItFails',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
SET ROWCOUNT 10000
SELECT * FROM "dbo"."ItFails"
SET ROWCOUNT 0
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'SomeLookup',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
SELECT * FROM "dbo"."SomeLookup"
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'SomeLookup',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
EXEC sp_MShelpcolumns N'ItFails', NULL, N'id', 1
SELECT * FROM "req"
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'req',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
SET NO_BROWSETABLE OFF
EXEC sp_MShelpcolumns N'dbo.ItFails' , NULL, 'id', 1
SELECT IDENT_SEED('ItFails')
SELECT IDENT_INCR('ItFails')
SET NO_BROWSETABLE ON
exec sp_executesql N'INSERT INTO "SILO"."dbo"."ItFails" ("req_ID") VALUES (@P1)', N'@P1 bigint', 994
SELECT @@IDENTITY
I have a table which has an INSERT trigger that sets a field as a side effect.
For a while, my ADP client would refresh the current records with fields from the entire row after inserting a new row, which was good, because the screen would should the side-effected column.
Now this has stopped happening and I can't figure out why. (If I refresh the record set I see the side effected update).
I just created another (albeit simpler) table with a similar trigger to set a field as a side effect, and, LO, indeed it works.
So, what's the difference?
I ran the SQL Profiler (1st time) to get a trace.
I can see with the table ItWorks the final three lines doing the insert, getting the @@IDENTITY, and then refreshing the entire row, like this:
exec sp_executesql N'INSERT INTO "SILO"."dbo"."ItWorks" ("c") VALUES (@P1)', N'@P1 nvarchar(2)', N'dd'
SELECT @@IDENTITY
exec sp_executesql N'SELECT * FROM ( SELECT * FROM "dbo"."ItWorks" ) AS DRVD_TBL WHERE "a" = @P1', N'@P1 bigint', 34
However, it the table 'ItFails' the final select is missing:
exec sp_executesql N'INSERT INTO "SILO"."dbo"."ItFails" ("req_ID") VALUES (@P1)', N'@P1 bigint', 994
SELECT @@IDENTITY
I expect that there is something different between them but I can't figure out what could cause the change.
1.. Neither of the tables has a resync command.
2.. They both have IDENTIY columns as (indexed) primary keys
3.. They both have timestamps (I've tried removing them on a lark, but, no dice).
4.. Neither have ROWGUID columns (could this make a difference anyway?)
Behind my sig are the two traces of opening each table from the database window and inserting a single row. If you can make any sense of them or otherwise suggest something else I might check or do I would be grateful. I inserted some blank lines to break the events into logical groups. The 2nd trace has an extra group of trace events for handling foreign key lookups.
Thanks!
--
Malcolm Cook - (e-mail address removed)
Database Applications Manager - Bioinformatics
Stowers Institute for Medical Research - Kansas City, MO USA
----------------This is the trace from 'ItWorks'
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'ItWorks',NULL,NULL)
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'ItWorks',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
SET ROWCOUNT 10000
SELECT * FROM "dbo"."ItWorks"
SET ROWCOUNT 0
EXEC sp_MShelpcolumns N'ItWorks', NULL, N'id', 1
SET NO_BROWSETABLE OFF
EXEC sp_MShelpcolumns N'dbo.ItWorks' , NULL, 'id', 1
SELECT IDENT_SEED('ItWorks')
SELECT IDENT_INCR('ItWorks')
SET NO_BROWSETABLE ON
exec sp_executesql N'INSERT INTO "SILO"."dbo"."ItWorks" ("c") VALUES (@P1)', N'@P1 nvarchar(2)', N'dd'
SELECT @@IDENTITY
exec sp_executesql N'SELECT * FROM ( SELECT * FROM "dbo"."ItWorks" ) AS DRVD_TBL WHERE "a" = @P1', N'@P1 bigint', 34
----------------This is the trace from 'ItFails'
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'ItFails',NULL,NULL)
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'ItFails',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
SET ROWCOUNT 10000
SELECT * FROM "dbo"."ItFails"
SET ROWCOUNT 0
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'SomeLookup',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
SELECT * FROM "dbo"."SomeLookup"
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'SomeLookup',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
EXEC sp_MShelpcolumns N'ItFails', NULL, N'id', 1
SELECT * FROM "req"
SELECT *, sql_variant_property(value, 'basetype') AS type FROM ::fn_listextendedproperty(NULL,N'user',N'dbo',N'table',N'req',N'column',NULL) ORDER BY PATINDEX(N'MS_DisplayControl', name) DESC
SET NO_BROWSETABLE OFF
EXEC sp_MShelpcolumns N'dbo.ItFails' , NULL, 'id', 1
SELECT IDENT_SEED('ItFails')
SELECT IDENT_INCR('ItFails')
SET NO_BROWSETABLE ON
exec sp_executesql N'INSERT INTO "SILO"."dbo"."ItFails" ("req_ID") VALUES (@P1)', N'@P1 bigint', 994
SELECT @@IDENTITY