No More Solutions

You can find a lot of debugging and deploying problems while developing applications in .NET and Visual Basic here. There are also some querying tips in SQL and typical source codes which might be useful shared here.

Sys on SQL

Not sharing query, but some tips that might be useful when looking for a needle in a haystack.
Am using Microsoft SQL Server 2000, but won't differ too much on later versions, I guess.

Find tables with the specified name

-----------------------------------
select name from sysobjects where name like '%table_name%' and type = 'u'



Find stored procedures with the specified name
----------------------------------------------
select name from sysobjects where name like '%sp_name%' and type = 'p'



Find the name of the tables which contain specified column
----------------------------------------------------------
select TableName = a.name, ColumnName = b.name from sysobjects a, syscolumns b
where a.id = b.id and b.name = 'column_name'



Find stored procedures which contain certain key / text
-------------------------------------------------------
select name from sysobjects where id in ( select id from syscomments where text like '%text_in_sp%')

This is also useful when you would like to search for stored procedures which uses a certain table.
e.g. If you would like to know the stored procedures which use the table named table_name,
select name from sysobjects where id in ( select id from syscomments where text like '%table_name%')
Bookmark and Share

1 comments:

  1. mUjA said...
     

    Thanks for your informations.
    good post.

Post a Comment