· 8 years ago · Feb 23, 2018, 08:29 AM
1-- 0. Drop example table if exists
2if object_id('test') is not null drop table test
3
4-- 1. Query tables (nothing returned)
5select * from sysobjects where name = 'test'
6
7-- 3. Query indexes (index returned for the new table)
8select IndexName = x.name, TableName = o.name
9from sysobjects o join sysindexes x on x.id = o.id
10where o.name = 'test'
11
12-- 2. Create table with index
13create table test (id int primary key)