Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Avoiding selection primary key in sysindexes
Message
De
04/03/2008 23:28:03
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01298781
Message ID:
01298790
Vues:
23
>Add a where clause:
>
>WHERE NOT IN (SELECT key_column_usage.COLUMN_NAME FROM information_schema.table_constraints
> INNER JOIN information_schema.key_column_usage
> ON table_constraints.constraint_name = key_column_usage.constraint_name
>WHERE
> table_constraints.constraint_type = 'PRIMARY KEY' AND table_constraints.table_name = 'table_name')

Thanks, it's looking good. I have this code presently.
SELECT name FROM sysindexes
WHERE id = OBJECT_ID(N'MyTable') AND
   indid > 0 AND indid < 255 AND
  INDEXPROPERTY(id, name, 'IsStatistics') = 0 AND
 NOT IN (SELECT key_column_usage.COLUMN_NAME FROM information_schema.table_constraints 
INNER JOIN information_schema.key_column_usage 
ON table_constraints.constraint_name = key_column_usage.constraint_name
WHERE 
table_constraints.constraint_type = 'PRIMARY KEY' AND table_constraints.table_name = 'MyTable')
ORDER BY indid DESC
There is a small syntax adjustment that is required. I get this message presently:

"Incorrect syntax near the keyboard 'IN'."
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform