|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, April 19, 2011 5:10 PM
Points: 275,
Visits: 168
|
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Saturday, February 19, 2011 7:19 PM
Points: 31,
Visits: 101
|
|
The "i.id = t.id" in the WHERE clause is not needed because it's already in the join condition.
Since we are looking for primary keys and text fields cannot be part of primary key, the "AND i.indid BETWEEN 1 And 254" is not needed as well.
Otherwise, nice code!
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, August 19, 2009 12:36 PM
Points: 1,
Visits: 32
|
|
Here is an alternative using the INFORMATION_SCHEMA view.
select column_name from information_schema.table_constraints join information_schema.key_column_usage on (information_schema.table_constraints.constraint_name = information_schema.key_column_usage.constraint_name) where information_schema.table_constraints.table_name = @table_name and constraint_type = 'PRIMARY KEY'
|
|
|
|