If you want to look where a string is in all tables in a database, how do you do that? Here's a very helpful SQL to run: Further Reading How to Get Names of All Tables in SQL Server How to Find a Column Name in SQL Server Database Search all tables, all columns for a specific value SQL Server … [Read more...]
Format SQL Using Redgate SQL Prompt
As a follow-up of the post String Literals as Column Aliases are Deprecated, this one feature from Redgate's SQL Prompt is quite handy to correct any existing SQL scripts quickly. Using the SQL from How to Find All References to an Object in a SQL Server Database as an example, here's what we originally have: Pay attention to the object name within the single quotes as a column … [Read more...]
String Literals as Column Aliases are Deprecated
Something that's still found in SQL scripts in enterprise environment, even with newly written scripts is the use of string literals as column aliases. Although this feature has been deprecated since 2012, old habits die hard. So what's the right way to write it? You can either use alias without a whitespace or use a double quote character. Either of these examples below is … [Read more...]
How to Find All References to an Object in a SQL Server Database
You can use the following scripts to find all affected objects that make any references to your search term. You can either use sql_modules or syscomments to accomplish this purpose. Generally, they should give you the same results, but from time to time, I found that they may give you slightly different results and I haven't had the chance to look closer how big the difference is. Just to keep … [Read more...]
How to Get Table Definition in SQL Server
Whenever you need to pull a quick definition of a table in SQL Server. Here's the SQL command (T-SQL) to get the table definition in a database: The result would be something similar to this: COLUMN_NAME DATA_TYPE IS_NULLABLE AccountNo int(10,0) YES AccountName varchar(50) YES Balance money(10,2) … [Read more...]
- 1
- 2
- 3
- 4
- Next Page »