Get All Tables Referenced by at Least One View
The following query will produce a list of tables that are referenced by one or more Views: SELECT [table] = s.name + N’.’ + t.name FROM sys.tables AS t INNER
The following query will produce a list of tables that are referenced by one or more Views: SELECT [table] = s.name + N’.’ + t.name FROM sys.tables AS t INNER
It can become quite frustrating when you cannot remember the name of an SQL stored procedure, especially if you have quite a few of them. But, let’s say that you
It is quite easy to find out which tables in your database(s) do not have Primary Keys. You can use the following SQL script: SELECT s.name + N’.’ + t.name
Getting a user that has deleted rows with SQL is a multi-part process. First you have to search the transaction log file for information on deleted rows. SELECT [Transaction ID],
You can restrict the connection to a database by specifying Single User mode, as shown below: USE master;GOALTER DATABASE YourDatabaseNameSET SINGLE_USERWITH ROLLBACK IMMEDIATE;GOALTER DATABASE YourDatabaseNameSET READ_ONLY;GOALTER DATABASE YourDatabaseNameSET MULTI_USER;GO This
The sp_spaceused special SQL procedure displays the number of rows, disk space reserved, disk space used by a table, or indexed view in the current database. Here is a small
Did you know that you can create Folders with T-SQL? With the help of the built-in Extended Stored Procedure named xp_create_subdir you can. Here is a small example: DECLARE @DBName
You can use an undocumented Extended Stored Procedure named xp_dirtree to list folders, subfolders, and files for a given path. Xp_dirtree has three parameters that need to be supplied: directory?-
Once you get the hang of the CASE WHEN SQL Statement it can be easy to overuse it. Sometimes you do not need to even use the CASE WHEN Statement