• Hi Kingston

    '

    even though thi seeems to run, it is geberating an error

    Thanks

    Jim

    1> IF OBJECT_ID('tempdb..#tmp_Indexes') IS NOT NULL

    2> DROP TABLE #tmp_Indexes

    3>

    4> DECLARE @strSQL VARCHAR(2000)

    5> DECLARE @IndexName VARCHAR(1000)

    6>

    7> CREATE TABLE #tmp_Indexes

    8> (

    9> DatabaseName VARCHAR(100),

    10> IndexName VARCHAR(1000)

    11> )

    12>

    13> SET @IndexName = 'AllDocs_PK' -- You can enter the name of the index here

    14>

    15> SET @strSQL = ' SELECT ''?'', name FROM ?..sysindexes WHERE name LIKE ''%' + @IndexName + '%'' '

    16>

    17> INSERT #tmp_Indexes( DatabaseName, IndexName )

    18> EXECUTE sp_MSforeachdb @strSQL

    19>

    20> SELECT * FROM #tmp_Indexes

    21>

    22> IF OBJECT_ID('tempdb..#tmp_Indexes') IS NOT NULL

    23> DROP TABLE #tmp_Indexes

    24> go

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.

    Msg 102, Level 15, State 1, Server NSAB-SS80-SQL-N, Line 1

    Incorrect syntax near '-'.