Existe-t-il un moyen de connaitre les champs d'une table qui ont été
modifiés par un UPDATE ?
Le but étant de "tracer" les modifications sur certaines colonnes d'une
table
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Med Bouchenafa
Dans un trigger, la caluse IF COLUMNS_UPDATED() permet de savoir les colonnes modifiées Voir Aide En ligne pour plus de détails
-- Bien cordialement Med Bouchenafa
"patrick" wrote in message news:uhgOTd%
Bonjour,
Existe-t-il un moyen de connaitre les champs d'une table qui ont été modifiés par un UPDATE ? Le but étant de "tracer" les modifications sur certaines colonnes d'une table
Merci
Dans un trigger, la caluse IF COLUMNS_UPDATED() permet de savoir les
colonnes modifiées
Voir Aide En ligne pour plus de détails
--
Bien cordialement
Med Bouchenafa
"patrick" <patrick@patrick.com> wrote in message
news:uhgOTd%231GHA.1132@TK2MSFTNGP02.phx.gbl...
Bonjour,
Existe-t-il un moyen de connaitre les champs d'une table qui ont été
modifiés par un UPDATE ?
Le but étant de "tracer" les modifications sur certaines colonnes d'une
table
Dans un trigger, la caluse IF COLUMNS_UPDATED() permet de savoir les colonnes modifiées Voir Aide En ligne pour plus de détails
-- Bien cordialement Med Bouchenafa
"patrick" wrote in message news:uhgOTd%
Bonjour,
Existe-t-il un moyen de connaitre les champs d'une table qui ont été modifiés par un UPDATE ? Le but étant de "tracer" les modifications sur certaines colonnes d'une table
Merci
Rudi Bruchez
patrick a écrit:
Existe-t-il un moyen de connaitre les champs d'une table qui ont été modifiés par un UPDATE ? Le but étant de "tracer" les modifications sur certaines colonnes d'une table
Bonjour,
A posteriori non. Tu peux faire un trigger pour tracer ces changements quand ils se produisent.
-- Rudi Bruchez Consultant indépendant modélisation, administration, optimisation, Solutions MS SQL Server et informatique libre. MCDBA, SCJP2 http://www.babaluga.com/
patrick a écrit:
Existe-t-il un moyen de connaitre les champs d'une table qui ont été
modifiés par un UPDATE ?
Le but étant de "tracer" les modifications sur certaines colonnes d'une
table
Bonjour,
A posteriori non. Tu peux faire un trigger pour tracer ces changements
quand ils se produisent.
--
Rudi Bruchez
Consultant indépendant
modélisation, administration, optimisation,
Solutions MS SQL Server et informatique libre.
MCDBA, SCJP2
http://www.babaluga.com/
Existe-t-il un moyen de connaitre les champs d'une table qui ont été modifiés par un UPDATE ? Le but étant de "tracer" les modifications sur certaines colonnes d'une table
Bonjour,
A posteriori non. Tu peux faire un trigger pour tracer ces changements quand ils se produisent.
-- Rudi Bruchez Consultant indépendant modélisation, administration, optimisation, Solutions MS SQL Server et informatique libre. MCDBA, SCJP2 http://www.babaluga.com/
zoltix
patrick wrote:
Bonjour,
Existe-t-il un moyen de connaitre les champs d'une table qui ont été modifiés par un UPDATE ? Le but étant de "tracer" les modifications sur certaines colonnes d'une table
Merci
dant ton trigger update , ca va te ramener toutes les rows qui ont été modifié.
Va voir chez MS tu vas comprendres pourquoi.
Doc de msql server 2005 ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/765fde44-1f95-4015-80a4-45388f18a42c.htm
if ((select count(*)from deleted)>0 and (select count(*)from inserted)>0) begin --print 'update' declare @i int declare @b binary set @position = 0 set @strChange ='' set @i = 1
--print columns_updated() set @bit = columns_updated() --print @bit
while(@i<=@iBinary) begin
set @b = substring(@bit,@i,1) --print 'binary' --print @b
--print 'position' --print @position
--print @position if (@b & 1 ) =1 begin --print 1+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 1+@position end if (@b & 2 ) =2 begin --print 2+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 2+@position end if (@b & 4 ) =4 begin --print 3+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 3+@position end if (@b & 8 ) =8 begin --print 4+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 4+@position end if (@b & 16 ) begin --print 5+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 5+@position end if (@b & 32 ) 2 begin --print 6+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 6+@position end if (@b & 64 ) d begin --print 7+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 7+@position end if (@b & 128 ) 8 begin --print 8+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 8+@position end
set @position = @position+ 8 set @i = @i+1
end
patrick wrote:
Bonjour,
Existe-t-il un moyen de connaitre les champs d'une table qui ont été
modifiés par un UPDATE ?
Le but étant de "tracer" les modifications sur certaines colonnes d'une
table
Merci
dant ton trigger update ,
ca va te ramener toutes les rows qui ont été modifié.
Va voir chez MS tu vas comprendres pourquoi.
Doc de msql server 2005
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/765fde44-1f95-4015-80a4-45388f18a42c.htm
if ((select count(*)from deleted)>0 and (select count(*)from inserted)>0)
begin
--print 'update'
declare @i int
declare @b binary
set @position = 0
set @strChange =''
set @i = 1
--print columns_updated()
set @bit = columns_updated()
--print @bit
while(@i<=@iBinary)
begin
set @b = substring(@bit,@i,1)
--print 'binary'
--print @b
--print 'position'
--print @position
--print @position
if (@b & 1 ) =1 begin
--print 1+@position
select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM
INFORMATION_SCHEMA.COLUMNS where table_name =@table and
ordinal_position = 1+@position
end
if (@b & 2 ) =2 begin
--print 2+@position
select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM
INFORMATION_SCHEMA.COLUMNS where table_name =@table and
ordinal_position = 2+@position
end
if (@b & 4 ) =4 begin
--print 3+@position
select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM
INFORMATION_SCHEMA.COLUMNS where table_name =@table and
ordinal_position = 3+@position
end
if (@b & 8 ) =8 begin
--print 4+@position
select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM
INFORMATION_SCHEMA.COLUMNS where table_name =@table and
ordinal_position = 4+@position
end
if (@b & 16 ) begin
--print 5+@position
select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM
INFORMATION_SCHEMA.COLUMNS where table_name =@table and
ordinal_position = 5+@position
end
if (@b & 32 ) 2 begin
--print 6+@position
select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM
INFORMATION_SCHEMA.COLUMNS where table_name =@table and
ordinal_position = 6+@position
end
if (@b & 64 ) d begin
--print 7+@position
select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM
INFORMATION_SCHEMA.COLUMNS where table_name =@table and
ordinal_position = 7+@position
end
if (@b & 128 ) 8 begin
--print 8+@position
select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM
INFORMATION_SCHEMA.COLUMNS where table_name =@table and
ordinal_position = 8+@position
end
Existe-t-il un moyen de connaitre les champs d'une table qui ont été modifiés par un UPDATE ? Le but étant de "tracer" les modifications sur certaines colonnes d'une table
Merci
dant ton trigger update , ca va te ramener toutes les rows qui ont été modifié.
Va voir chez MS tu vas comprendres pourquoi.
Doc de msql server 2005 ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/765fde44-1f95-4015-80a4-45388f18a42c.htm
if ((select count(*)from deleted)>0 and (select count(*)from inserted)>0) begin --print 'update' declare @i int declare @b binary set @position = 0 set @strChange ='' set @i = 1
--print columns_updated() set @bit = columns_updated() --print @bit
while(@i<=@iBinary) begin
set @b = substring(@bit,@i,1) --print 'binary' --print @b
--print 'position' --print @position
--print @position if (@b & 1 ) =1 begin --print 1+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 1+@position end if (@b & 2 ) =2 begin --print 2+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 2+@position end if (@b & 4 ) =4 begin --print 3+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 3+@position end if (@b & 8 ) =8 begin --print 4+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 4+@position end if (@b & 16 ) begin --print 5+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 5+@position end if (@b & 32 ) 2 begin --print 6+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 6+@position end if (@b & 64 ) d begin --print 7+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 7+@position end if (@b & 128 ) 8 begin --print 8+@position select @strChange= @strChange +','+ltrim(rtrim(column_name)) FROM INFORMATION_SCHEMA.COLUMNS where table_name =@table and ordinal_position = 8+@position end
set @position = @position+ 8 set @i = @i+1
end
john
Merci à tous
"Med Bouchenafa" wrote in message news:%
Dans un trigger, la caluse IF COLUMNS_UPDATED() permet de savoir les colonnes modifiées Voir Aide En ligne pour plus de détails
-- Bien cordialement Med Bouchenafa
"patrick" wrote in message news:uhgOTd% > Bonjour, > > Existe-t-il un moyen de connaitre les champs d'une table qui ont été > modifiés par un UPDATE ? > Le but étant de "tracer" les modifications sur certaines colonnes d'une > table > > Merci > >
Merci à tous
"Med Bouchenafa" <com.hotmail@bouchenafa> wrote in message
news:%23iE4SyA2GHA.328@TK2MSFTNGP06.phx.gbl...
Dans un trigger, la caluse IF COLUMNS_UPDATED() permet de savoir les
colonnes modifiées
Voir Aide En ligne pour plus de détails
--
Bien cordialement
Med Bouchenafa
"patrick" <patrick@patrick.com> wrote in message
news:uhgOTd%231GHA.1132@TK2MSFTNGP02.phx.gbl...
> Bonjour,
>
> Existe-t-il un moyen de connaitre les champs d'une table qui ont été
> modifiés par un UPDATE ?
> Le but étant de "tracer" les modifications sur certaines colonnes d'une
> table
>
> Merci
>
>
Dans un trigger, la caluse IF COLUMNS_UPDATED() permet de savoir les colonnes modifiées Voir Aide En ligne pour plus de détails
-- Bien cordialement Med Bouchenafa
"patrick" wrote in message news:uhgOTd% > Bonjour, > > Existe-t-il un moyen de connaitre les champs d'une table qui ont été > modifiés par un UPDATE ? > Le but étant de "tracer" les modifications sur certaines colonnes d'une > table > > Merci > >