October 28, 2003 at 1:33 pm
Is there a way to search for a row in a database? Im looking for a docpage object/row and don't know what database it is in.
October 28, 2003 at 3:42 pm
I don't understand. Do you mean search for a row in all tables in a database? All databases on a server?
My initial response to "Is there a way to search for a row in a database?" is "Yes, a query!"
"I met Larry Niven at ConClave 27...AND I fixed his computer. How cool is that?"
(Memoirs of a geek)
"I met Larry Niven at ConClave 27...AND I fixed his computer. How cool is that?"
(Memoirs of a geek)
October 29, 2003 at 6:02 am
yeah i want to do both search for a row and search for a row in all tables in database.
October 29, 2003 at 6:19 am
trying to hack an unkown source? 😉
could do it like that: cursor for "select name from sysdatabases"
dynamic cursor for: "select name from <db>.dbo.sysobjects where xtype = 'U'"
dynamic select for your search criteria for every field of every table ... ok, this is a major effort, but it works 😉
easier solution could be: write SQL code that *generates* your sql statements at least down to the table portion ...
best regards,
chris.
Edited by - cneuhold on 10/29/2003 06:19:54 AM
October 29, 2003 at 7:04 am
i need to find a row and i have a lot of databases. not trying to hack. could you do a select statement in a certain table?
October 29, 2003 at 7:38 am
do you have a fixed search condition ? or even a fixed field name to be searching for ?
can you give the contents of row that you are looking for ?
October 29, 2003 at 8:04 am
binid is the row name and there are 2 digit number for contents.
October 29, 2003 at 8:53 am
Matt1: Its hard to know what you want because you are not using the correct terms. I assume when you say "binid is the row name" you mean "binid is the column name" Rows don't have names in tables. You identify a row by the primary key. The primary key is comprised of one or more columns that are named. So if what you are looking for is the name of a table in some database that contains a certain column you could try:
EXEC sp_MSForEachDB "USE ? IF db_name() NOT IN ('tempdb', 'model', 'msdb' )
select db_name(), so.name as 'Table Name', sc.name as 'Column Name'
from syscolumns sc
join sysobjects so on so.id = sc.id
where sc.name = 'xxxx' "
where xxxx is the name of the column you are looking for. This could be modified to only select columns that are primary keys etc. It depends what you are looking for.
Francis
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply