Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 29th, 2006, 02:22 AM
Authorized User
 
Join Date: Oct 2004
Location: Hyderabad, Andhra Pradesh, India.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Find databaseName of particular object?

Hi,

I am having nearly 10 databases in database server with more than 1000 objects. Now, i got a stored procedure written in SQL Server 2000. I am having it's name as "spGetCustomerByName".

Can anybody tell how to find the exact databasename that this stored procedure in present in?

I am using SQL Server 2000. I am not creator of database objects, so i am not confirmed about its location.

A.D.Ramkumar
__________________
Ramkumar A D
Reply With Quote
  #2 (permalink)  
Old May 29th, 2006, 08:40 AM
Friend of Wrox
 
Join Date: May 2006
Location: Helsingborg, , Sweden.
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is a quick'n'dirty solution... Not pretty but it works!



---------------------------------------------------------------------
declare @proc_name nvarchar(100)
select @proc_name = 'uspPeriodsOpen'

create table #db (z smallint identity(0, 1), dbname nvarchar (100), present tinyint)

insert into #db (dbname)
EXEC sp_MSforeachdb @command1="select '?'"

declare @z smallint, @maxz smallint, @sql nvarchar (500), @db nvarchar (100)

select @z = 0,
@maxz = max(z)
from #db

while @z <= @maxz
   begin
select @db = quotename(dbname)
from #db
where z = @z

select @sql = 'update #db set present = (select count(*) from ' + @db + '..sysobjects where name = ''' + convert(nvarchar, @proc_name) + ''') where z = ' + convert(nvarchar, @z)

exec sp_executesql @sql

select @z = @z + 1
   end


select dbname from #db where present = 1

drop table #db
Reply With Quote
  #3 (permalink)  
Old May 29th, 2006, 08:54 AM
Authorized User
 
Join Date: Oct 2004
Location: Hyderabad, Andhra Pradesh, India.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kindly check this article for the reply:

http://www.sql-server-performance.co...se_objects.asp

A.D.Ramkumar
Reply With Quote
  #4 (permalink)  
Old May 29th, 2006, 09:08 AM
Friend of Wrox
 
Join Date: May 2006
Location: Helsingborg, , Sweden.
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

These are all fine scripts, but they all return the name of all databases, even of there are not match...

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box can't find Object message PaulJH Access 5 April 13th, 2007 03:27 PM
cannot resolve object, cannot find java file!!help Calverstine Apache Tomcat 3 May 22nd, 2006 03:02 PM
List tablesname from database & list databasename ittorget MySQL 3 September 10th, 2005 03:06 AM
can't find an object kliu9 Excel VBA 7 March 4th, 2005 06:21 PM



All times are GMT -4. The time now is 01:03 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.