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
SQLpro [MVP]
Christophe a écrit :
Quelle est la methode la plus rapide ?
** Methode 1 update matable set C1 = 1 where SEMSOR = 0 and C1 <> 1 update matable set C1 = 0 where SEMSOR <> 0 and C1 <> 0
** Methode 2 update matable set C1 > case when SEMSOR = 0 and C1 <> 1 then 1 when SEMSOR <> 0 and C1 <> 0 then 0 end
C1 = tinyint SEMSOR = INT Table matable contient ~90000 lignes et 133 champs
en principe le 2
pour comparer les temps d'exec;
SET STATISTICS TIME ON
update matable set C1 = 1 where SEMSOR = 0 and C1 <> 1 update matable set C1 = 0 where SEMSOR <> 0 and C1 <> 0
update matable set C1 case when SEMSOR = 0 and C1 <> 1 then 1 when SEMSOR <> 0 and C1 <> 0 then 0 end
SET STATISTICS TIME OFF
A +
-- Frédéric BROUARD, MVP SQL Server, expert bases de données et langage SQL Le site sur le langage SQL et les SGBDR : http://sqlpro.developpez.com Audit, conseil, expertise, formation, modélisation, tuning, optimisation ********************* http://www.datasapiens.com ***********************
Christophe a écrit :
Quelle est la methode la plus rapide ?
** Methode 1
update matable set C1 = 1 where SEMSOR = 0 and C1 <> 1
update matable set C1 = 0 where SEMSOR <> 0 and C1 <> 0
** Methode 2
update matable set C1 > case
when SEMSOR = 0 and C1 <> 1 then 1
when SEMSOR <> 0 and C1 <> 0 then 0
end
C1 = tinyint
SEMSOR = INT
Table matable contient ~90000 lignes et 133 champs
en principe le 2
pour comparer les temps d'exec;
SET STATISTICS TIME ON
update matable set C1 = 1 where SEMSOR = 0 and C1 <> 1
update matable set C1 = 0 where SEMSOR <> 0 and C1 <> 0
update matable set C1 case
when SEMSOR = 0 and C1 <> 1 then 1
when SEMSOR <> 0 and C1 <> 0 then 0
end
SET STATISTICS TIME OFF
A +
--
Frédéric BROUARD, MVP SQL Server, expert bases de données et langage SQL
Le site sur le langage SQL et les SGBDR : http://sqlpro.developpez.com
Audit, conseil, expertise, formation, modélisation, tuning, optimisation
********************* http://www.datasapiens.com ***********************
** Methode 1 update matable set C1 = 1 where SEMSOR = 0 and C1 <> 1 update matable set C1 = 0 where SEMSOR <> 0 and C1 <> 0
** Methode 2 update matable set C1 > case when SEMSOR = 0 and C1 <> 1 then 1 when SEMSOR <> 0 and C1 <> 0 then 0 end
C1 = tinyint SEMSOR = INT Table matable contient ~90000 lignes et 133 champs
en principe le 2
pour comparer les temps d'exec;
SET STATISTICS TIME ON
update matable set C1 = 1 where SEMSOR = 0 and C1 <> 1 update matable set C1 = 0 where SEMSOR <> 0 and C1 <> 0
update matable set C1 case when SEMSOR = 0 and C1 <> 1 then 1 when SEMSOR <> 0 and C1 <> 0 then 0 end
SET STATISTICS TIME OFF
A +
-- Frédéric BROUARD, MVP SQL Server, expert bases de données et langage SQL Le site sur le langage SQL et les SGBDR : http://sqlpro.developpez.com Audit, conseil, expertise, formation, modélisation, tuning, optimisation ********************* http://www.datasapiens.com ***********************