Originally posted by: Armitage
If you have to search every column of every table, your DB design is seriously fvcked
Originally posted by: kamper
Just as an example of why you might possibly want to do this: I have worked on a system that uses GUIDs for keys on all records that must be unique. Every now and then while testing you get a guid but you're not sure what type of record it belongs to (since a GUID will never be duplicated anywhere, even in different tables except in foreign key situations) so it'd be handy to see if that key exists anywhere in the database. Of course, there was no need to do this programatically in the actual product, it was just to help me figure out what was going on.
Something like DT4K's code looks pretty handy.
Well, more than one column per table because I'd want to know about foreign key references. What it'd boil down to is isolating every column who's type is the guid (I think it's called UniqueIdentifier in sql server).Originally posted by: Armitage
It seems in this case that you'd be only searching one column from every table ... not every column from every table.
LOL. I know what you mean. I just wrote that code for fun after this thread got me wondering how I would do something like that.Originally posted by: Armitage
Something like DT4K's code looks pretty handy.
Not every slick solution answers a reasonable problem 😛