Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Useful Sql Quries

By Ashis Das,

Useful Sql Server Statements

1. Search through Column Name: - Suppose you want to know how many objects have the same column name. You can use this sql statement.

For Sql Server 2000:-
Select * from sysobjects where id in (Select * from Syscolumn where name='ColumnName')
For Sql Server 2005:-
select * from sys.objects where object_id in
(select object_id from sys.columns where name='ColumnName')
2. Search through Query statement: - Suppose you have a query and you want to know if this query is used in which views or which procedure. You can use this sql statement.
Select * from syscomments where name like ('%your Sql Query%')
3. Search constraint used in whole database: -Suppose you want to view all the constraint used in your database. You can use this sql statement.

select pr.name,fr.parent_object_id,fr.name,fr.type_desc from sys.objects pr,
sys.objects Fr where pr.type<>'s'
and pr.object_id=fr.parent_object_id
order by fr.parent_object_id

Total article views: 2453 | Views in the last 30 days: 4
 
Related Articles
FORUM

select statement

select statement

FORUM

SELECT statement hangs on certain where conditions

Bizarre issue with certain conditions in where statement cause the select to hang forever

FORUM

select statements

select statements

FORUM

Problem with Select Statement

Help needed in select statement to set where condition

ARTICLE

The Unpopular SELECT Statement

SELECT statements should be the most popular query in SQL Server, so why are they unpopular? It's th...

Tags
search    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones