Home Tags SQL Server – TSQL

Tag: SQL Server – TSQL

Comment supprimer les lignes en double d’une table SQL Server ?

Méthode 1 : with cte as ( select row_number()over (partition by ParentProductCategoryID,Name order by ParentProductCategoryID ) as classement,  ParentProductCategoryID,Name  from .  where ParentProductCategoryID is not null )delete from cte where classement >1 Méthode...

Comment obtenir des informations sur les colonnes des tables dans SQL...

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME='DWH_STOCK'

Comment obtenir toutes les tables qui n’ont pas de clé primaire...

SELECT name AS Table_Name FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0 ORDER BY Table_Name;

Comment afficher la liste des tables avec nombre d’enregistrements dans SQL...

CREATE TABLE #Tab ( Table_Name (max), Total_Records int ); EXEC sp_MSForEachTable @command1=' Insert Into #Tab(Table_Name, Total_Records) SELECT ''?'', COUNT(*) FROM ?' SELECT * FROM #Tab t ORDER BY t.Total_Records DESC; DROP...

Comment afficher les derniers scripts exécutés dans SQL Server ?

Pour avoir la liste des derniers scripts exécutés sur une base de données, voilà la requête : SELECT execquery.last_execution_time AS ,execsql.TEXT AS FROM sys.dm_exec_query_stats AS...

Comment afficher toutes les tables en utilisant d’une base SQL SERVER...

Il s'agit de requêter sur la table système : information_schema.tables SELECT * FROM information_schema.tables WHERE table_type='BASE TABLE';
- Advertisement -

MOST POPULAR

HOT NEWS