T-SQL - Search all tables for field name

A while back, I went over a method that could be used, via query, to find all SQL stored procedures containing a specific string. When working with large databases with thousands of objects (including stored procedures), that has come in handy. Another situation that comes up from time to time is the need to find all tables which contain a specific field name. If you've been consistent with your naming conventions, and have numerous links (possibly foreign keys) between tables, this can be accomplished fairly easy. Just execute the following query (verified to be working in MSSQL 2008, MSSQL 2005, and MSSQL 2000).

SELECT *
FROM information_schema.columns
WHERE column_name = '[FIELD NAME]'
ORDER BY TABLE_NAME

Where [FIELD NAME] is the name of the field that you're actually looking for. This will provide you a list of tables in your database which have the field that you're looking for. Easy enough.



AndAlso and OrElse - Difference in use and performance vs And/Or

In .NET languages (VB.NET, C#) we have a couple of short circuit operators available for use called AndAlso & OrElse. Not surprisingly, AndAlso is a short circuit variation of "And" and OrElse is a short circuit variation of "Or". That's great and all, but one might wonder why they would use these operators, and what benefits do they have over using the traditional "And" and "Or". Here's a couple of reasons. Read more



How to Display Single and Double Quotes in WordPress

I feel like I've been focusing a lot on SQL and database related programming in general, so It's time to switch it up and look at a nagging WordPress problem. I love WordPress (hense this being a WP blog). There are countless things to love about using it. Of course, there are also a few things to hate, loathe, despise, etc. One of these things is how WordPress, by default, renders single and double quotes. I wanted this to be a site where other developers could copy and paste code examples that I have into their own application. As developers, we've come to know the versatility and importance of single and double quotes. So - when I write a SQL query, I'm looking for it to include single quotes - not `s. I have no use for `s. Nobody does. Here is how, with a couple of very simple function calls, to force WordPress to render single quotes and double quotes as you intend them to be rendered. Read more