# SQL Authority with Pinal Dave > SQL Server Performance Tuning Expert ## Posts - [SQL SERVER - Script to Find SQL Server on Network](https://blog.sqlauthority.com/2007/04/13/sql-server-script-to-find-sql-server-on-network/): I manage lots of SQL Servers. Many times I forget how many server I have and what are their names. New servers are added frequently and old servers are replaced with powerful servers. I run following script to check if server is properly set up and announcing itself. This script requires execute permissions on XP_CMDShell. CREATE TABLE #servers(sname VARCHAR(255)) INSERT #servers (sname) EXEC master..xp_CMDShell 'ISQL -L' DELETE FROM #servers WHERE sname='Servers:' OR sname IS NULL SELECT LTRIM(sname) FROM #servers DROP TABLE #servers Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Disable Triggers - Drop Triggers](https://blog.sqlauthority.com/2007/04/13/sql-server-2005-disable-triggers-drop-triggers/): There are two ways to prevent trigger from firing. 1) Drop Trigger Example: DROP TRIGGER TriggerName GO 2) Disable Trigger DML trigger can be disabled two ways. Using ALETER TABLE statement or use DISABLE TRIGGER. I prefer DISABLE TRIGGER statement. Syntax: DISABLE TRIGGER { [ schema . ] trigger_name [ ,...n ] | ALL } ON { OBJECT_NAME | DATABASE | ALL SERVER } [ ; ] Example: DISABLE TRIGGER TriggerName ON TableName Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-1702-create-table-failed-because-column-in-table-exceeds-the-maximum-of-columns/): Error Received: Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns SQL Server 2000 supports table with maximum 1024 columns. This errors happens when we try to create table with 1024 columns or try to add columns to table which exceeds more than 1024. Fix/Solution/WorkAround: Reduce the number of columns in the table to 1,024 or less. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error: 3902, Severity: 16; State: 1 : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-3902-severity-16-state-1-the-commit-transaction-request-has-no-corresponding-begin-transaction/): SQL Server Integration Services Error : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. (Microsoft OLE DB Provider for SQL Server) Fix/Workaround/Solution: Option 1: To work around this problem, do not call the stored procedure by using ODBC Call syntax. You can call the stored procedure in may ways by using ADO. One of the methods is to call a stored procedure by using a command object. (View Example) Option 2: If the sql statements are like BEGIN TRAN SQL Statements END TRAN SET “RetainSameConnection” property on the connection manager to true. This will fix the problem. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Running 64 bit SQL SERVER 2005 on 32 bit Operating System](https://blog.sqlauthority.com/2007/04/12/sql-server-running-64-bit-sql-server-2005-on-32-bit-operating-system/): Few days ago, I have received email from users asking question :How to run 64 bit SQL SERVER 2005 on 32 bit operating system? - [SQL SERVER - UDF - User Defined Function to Extract Only Numbers From String](https://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/): Following SQL User Defined Function will extract/parse numbers from the string. CREATE FUNCTION ExtractInteger(@String VARCHAR(2000)) RETURNS VARCHAR(1000) AS BEGIN DECLARE @Count INT DECLARE @IntNumbers VARCHAR(1000) SET @Count = 0 SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1) END SET @Count = @Count + 1 END RETURN @IntNumbers END GO Run following script in query analyzer. SELECT dbo.ExtractInteger('My 3rd Phone Number is 323-111-CALL') GO It will return following values. 3323111 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Explanation of TRY...CATCH and ERROR Handling](https://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/): SQL Server 2005 offers a more robust set of tools for handling errors than in previous versions of SQL Server. Deadlocks, which are virtually impossible to handle at the database level in SQL Server 2000, can now be handled with ease. By taking advantage of these new features, you can focus more on IT business strategy development and less on what needs to happen when errors occur. In SQL Server 2005, @@ERROR variable is no longer needed after every statement executed, as was the case in SQL Server 2000. SQL Server 2005 provides the TRY…CATCH construct, which is already present in... - [SQL SERVER - 2005 - Silent Installation - Unattended Installation](https://blog.sqlauthority.com/2007/04/10/sql-server-2005-silent-installation-unattended-installation/): Silent SQL Server 2005 Installation is possible in two steps. 1) Creating an .ini file The SQL Server CD contains a template file called template.ini . Based on that create another required .ini file which includes a single [Options] section containing multiple parameters, each relating to a different feature or configuration setting. 2) Run Setup on command prompt On command prompt type following script setup.exe /settings <path TO .ini FILE> If location of sqlinstall.ini file is at C:\SQLSetup folder. The command to initiate silent installation is: setup.exe /settings C:SQLSetup sqlinstall.ini Specify the /qn switch to perform a silent installation (with no... - [SQL SERVER - SP Performance Improvement without changing T-SQL](https://blog.sqlauthority.com/2007/04/10/sql-server-sp-performance-improvement-without-changing-t-sql/): There are two ways, which can be used to improve the performance of Stored Procedure (SP) without making T-SQL changes in SP. Do not prefix your Stored Procedure with sp_. In SQL Server, all system SPs are prefixed with sp_. When any SP is called which begins sp_ it is looked into masters database first before it is looked into the database it is called in. Call your Stored Procedure prefixed with dbo.SPName – fully qualified name. When SP are called prefixed with dbo. or database.dbo. it will prevent SQL Server from placing a COMPILE lock on the procedure. While SP... - [SQL SERVER - 2005 Reserved Keywords](https://blog.sqlauthority.com/2007/04/09/sql-server-2005-reserved-keywords/): Microsoft SQL Server 2005 uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language that is used by SQL Server to parse and understand Transact-SQL statements and batches. It is not legal to include the reserved keywords in a Transact-SQL statement in any location except that defined by SQL Server. No objects in the database should be given a name that matches a reserved keyword. Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using... - [SQL SERVER - Search Text Field - CHARINDEX vs PATINDEX](https://blog.sqlauthority.com/2007/04/08/sql-server-search-text-field-charindex-vs-patindex/): We can use either CHARINDEX or PATINDEX to search in TEXT field in SQL SERVER. The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. Both functions take two arguments. With PATINDEX, you must include percent signs before and after the pattern, unless you are looking for the pattern as the first (omit the first %) or last (omit the last %) characters in a column. For CHARINDEX, the pattern cannot include wildcard characters. The second argument is a character expression, usually a column name, in which Adaptive Server searches for the specified pattern. Example of CHARINDEX:... - [SQL SERVER - DBCC Commands Introduced in SQL Server 2005](https://blog.sqlauthority.com/2007/04/07/sql-server-dbcc-commands-introduced-in-sql-server-2005/): SQL Server 2005 has introduced following two documented and five undocumented DBCC Commands. I was able to find documentation for only first one online. If you find any documentation of any other DBCC Commands please add comments. It will be helpful to all of us. Documented: freesessioncache () — no parameters Flushes the distributed query connection cache used by distributed queries against an instance of Microsoft SQL Server. View Details requeststats ({clear} | {setfastdecayrate, rate} | {setslowdecayrate, rate}) UnDocumented: mapallocunit (I8AllocUnitId | {I4part, I2part}) metadata ({‘print’ [, printopt = {0 |1}] | ‘drop’ | ‘clone’ [, ” | ….]}, {‘object’ [,... - [SQL SERVER - Fix: Server: Msg 7391, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/06/sql-server-fix-server-msg-7391-level-16-state-1-line-1/): I have received this error many times on different servers in my careers. There is no single fix for this Error. Server: Msg 7391, Level 16, State 1, Line 1 can happen due to many reasons. I have used various of this reasons with few of my servers. Please refer them and try them one by one. One of them should be applicable to your problem. You may receive a 7391 error message in SQLOLEDB when you run a distributed transaction against a linked server after you install Windows XP Service Pack 2 or Windows XP Tablet PC Edition 200. View... - [SQL SERVER - Performance Optimization of SQL Query and FileGroups](https://blog.sqlauthority.com/2007/04/05/sql-server-performance-optimization-of-sql-query-and-filegroups/): It is suggested to place transaction logs on separate physical hard drives. In this manner, data can be recovered up to the second in the event of a media failure. In SQL 2005 When database is created without specifying a transaction log size, the transaction log will be re-sized to 25 percent of the size of data files. Tables and their non-clustered indexes separated into separate file groups can improve performance, because modifications to the table can be written to both the table and the index at the same time. If tables and their corresponding indexes in a different file group,... - [SQL SERVER - Fix: HResult 0x274D, SQLCMD Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired](https://blog.sqlauthority.com/2007/04/04/sql-server-fix-hresult-0x274d-level-16-state-1-error-microsoft-sql-native-client-login-timeout-expired/): While Working with SQLCMD in SQL Server 2005 I encountered following error. Let us learn in this blog post how we can solve Fix: HResult 0x274D, Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired. - [SQL SERVER - T-SQL Paging Query Technique Comparison - SQL 2000 vs SQL 2005](https://blog.sqlauthority.com/2007/04/03/sql-server-t-sql-paging-query-technique-comparison-sql-2000-vs-sql-2005/): I was doing paging in SQL Server 2000 using Temp Table or Derived Tables. I decided to checkout new function ROW_NUMBER() in SQL Server 2005. ROW_NUMBER() returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. I have compared both the following query on SQL Server 2005. SQL 2005 Paging Method USE AdventureWorks GO DECLARE @StartRow INT DECLARE @EndRow INT SET @StartRow = 120 SET @EndRow = 140 SELECT FirstName, LastName, EmailAddress FROM ( SELECT PC.FirstName, PC.LastName, PC.EmailAddress, ROW_NUMBER() OVER( ORDER BY PC.FirstName, PC.LastName,PC.ContactID) AS RowNumber FROM... - [SQL SERVER - 2005 - Performance Dashboard Reports](https://blog.sqlauthority.com/2007/04/02/sql-server-2005-performance-dashboard-reports/): The Microsoft SQL Server 2005 Performance Dashboard Reports are used to monitor and resolve performance problems on your SQL Server 2005 database server. The SQL Server instance being monitored and the Management Studio client used to run the reports must both be running SP2 or later. Common performance problems that the dashboard reports may help to resolve include: – CPU bottlenecks (and what queries are consuming the most CPU) – IO bottlenecks (and what queries are performing the most IO). – Index recommendations generated by the query optimizer (missing indexes) – Blocking – Latch contention The SQL Server 2005 Performance Dashboard... - [SQL SERVER - TempDB is Full. Move TempDB from one drive to another drive.](https://blog.sqlauthority.com/2007/04/01/sql-server-tempdb-is-full-move-tempdb-from-one-drive-to-another-drive/): If you ever find your TEmpDB to be full and if you want to move TempDB, you will find this blog post very helpful. Here is the error message which may come across. Event ID: 17052 Description: The LOG FILE FOR DATABASE 'tempdb' IS FULL. Back up the TRANSACTION LOG FOR the DATABASE TO free Up SOME LOG SPACE - [SQL SERVER - 2005 Best Practices Analyzer (February 2007 CTP)](https://blog.sqlauthority.com/2007/03/31/sql-server-2005-best-practices-analyzer-february-2007-ctp/): Microsoft has released a tool called the Microsoft SQL Server Best Practices Analyzer. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. Download SQL Server 2005 Best Practices Analyzer (February 2007 Community Technology Preview) Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Index Seek Vs. Index Scan (Table Scan)](https://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/): Index Scan retrieves all the rows from the table. Index Seek retrieves selective rows from the table. - [SQL SERVER - Difference between DISTINCT and GROUP BY - Distinct vs Group By](https://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/): This question is asked many times to me. What is difference between DISTINCT and GROUP BY? A DISTINCT and GROUP BY usually generate the same query plan, so performance should be the same across both query constructs. GROUP BY should be used to apply aggregate operators to each group. If all you need is to remove duplicates then use DISTINCT. If you are using sub-queries execution plan for that query varies so in that case you need to check the execution plan before making decision of which is faster. Example of DISTINCT: SELECT DISTINCT Employee, Rank FROM Employees Example of GROUP... - [SQL SERVER - Fix : Error 8101 An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON](https://blog.sqlauthority.com/2007/03/28/sql-server-fix-error-8101-an-explicit-value-for-the-identity-column-in-table-can-only-be-specified-when-a-column-list-is-used-and-identity_insert-is-on/): This error occurs when the user has attempted to insert a row containing a specific identity value into a table that contains an identity column. Run following commands according to your SQL Statement. Let us learn about the IDENTITY_INSERT. - [SQL SERVER - Fix : Error 701 There is insufficient system memory to run this query](https://blog.sqlauthority.com/2007/03/27/sql-server-fix-error-701-there-is-insufficient-system-memory-to-run-this-query/): Generic Solution: Check the settings for both min server memory (MB) and max server memory (MB). If max server memory (MB) is a value close to the value of min server memory (MB), then increase the max server memory (MB) value. Check the size of the virtual memory paging file. If possible, increase the size of the file. For SQL Server 2005: Install following HotFix and Restart Server. Additionally following DBCC Commands can be ran to free memory: DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT - Retrieve Last Inserted Identity of Record](https://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/): SELECT @@IDENTITY It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value. @@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it. SELECT SCOPE_IDENTITY()... - [SQL SERVER - Stored Procedure - Clean Cache and Clean Buffer](https://blog.sqlauthority.com/2007/03/23/sql-server-stored-procedure-clean-cache-and-clean-buffer/): DBCC FREEPROCCACHE will invalidate all stored procedure plans that the optimizer has cached in memory. Let us learn how to clean cache.  - [SQL SERVER - Fix: Error Msg 128 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.](https://blog.sqlauthority.com/2007/03/22/sql-server-fix-error-msg-128-the-name-is-not-permitted-in-this-context-only-constants-expressions-or-variables-allowed-here-column-names-are-not-permitted/): Error Message: Server: Msg 128, Level 15, State 1, Line 3 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Causes: This error occurs when using a column as the DEFAULT value of another column when a table is created. CREATE TABLE [dbo].[Items] ( [OrderCount] INT, [ProductAmount] INT, [TotalAmount] DEFAULT ([OrderCount] + [ProductAmount]) ) Executing this CREATE TABLE statement will generate the following error message: Server: Msg 128, Level 15, State 1, Line 5 The name ‘TotalAmount’ is not permitted in this context. Only constants, expressions, or variables allowed here.... - [SQL SERVER - 2005 Security Best Practices - Operational and Administrative Tasks](https://blog.sqlauthority.com/2007/03/21/sql-server-2005-security-best-practices-operational-and-administrative-tasks/): This white paper covers some of the operational and administrative tasks associated with SQL Server 2005 security and enumerates best practices and operational and administrative tasks that will result in a more secure SQL Server system. - [SQL SERVER - SQL Commandments - Suggestions, Tips, Tricks](https://blog.sqlauthority.com/2007/03/20/sql-server-sql-commandments-suggestions-tips-tricks/): Few days ago, while searching for something on web site, I came across a very good article of 25 SQL Commandments. I really enjoyed reading it. It was for Oracle, I re-wrote it for SQL Server. First 18 points are taken from original article and last 2 I added to complete total of 20 Commandments. Many more rules and suggestions can be added to this list, this list is just a beginning. 1. Know your data and business application well. Familiarize yourself with these sources; you must be aware of the data volume and distribution in your database. 2. Test your... - [SQL SERVER - Fix: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17](https://blog.sqlauthority.com/2007/03/16/sql-server-fix-sqllib-error-oledb-error-encountered-calling-idbinitializeinitialize-hr-0x80004005-sqlstate-08001-native-error-17/): Error received: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17 Error state: 1, Severity: 16 Source: Microsoft OLE DB Provider for SQL Server Error message: [DBNETLIB]SQL Server does not exist or access denied The simple fix: Microsoft SQL Server 2005 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server 2005 Network Configuration >> Enable TCP-IP. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC command to RESEED Table Identity Value - Reset Table Identity](https://blog.sqlauthority.com/2007/03/15/sql-server-dbcc-reseed-table-identity-value-reset-table-identity/): DBCC CHECKIDENT can reseed (reset) the identity value of the table. For example, YourTable has 25 rows with 25 as last identity. If we want next record to have identity as 35 we need to run following T SQL script in Query Analyzer. DBCC CHECKIDENT (yourtable, reseed, 34) If table has to start with an identity of 1 with the next insert then the table should be reseeded with the identity to 0. If identity seed is set below values that currently are in table, it will violate the uniqueness constraint as soon as the values start to duplicate and will... - [SQL SERVER - Union vs. Union All - Which is better for performance?](https://blog.sqlauthority.com/2007/03/10/sql-server-union-vs-union-all-which-is-better-for-performance/): This article is completely re-written with better example SQL SERVER – Difference Between Union vs. Union All – Optimal Performance Comparison. I suggest all of my readers to go here for update article. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values. The difference between Union and Union all... - [SQL SERVER - Download 2005 SP2a](https://blog.sqlauthority.com/2007/03/07/sql-server-2005-sp2a/): Microsoft released an updated SQL Server 2005 SP2 on March 5th, 2007. The build number is 9.00.3042.01. The previous build number was 9.00.3042.00.Microsoft released a SP2a patch for the second service pack for SQL Server 2005 to fix the issues with the maintenance plans.If you have upgraded to SP2, use the download from here to patch the system. KB 933508 has more information on this patch. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Script to Determine Which Version of SQL Server 2000-2005 is Running](https://blog.sqlauthority.com/2007/03/07/sql-server-script-to-determine-which-version-of-sql-server-2000-2005-is-running/): To determine which version of SQL Server 2000/2005 is running, connect to SQL Server 2000/2005 by using Query Analyzer, and then run the following code: SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') The results are: The product version (for example, 8.00.534). The product level (for example, “RTM” or “SP2”). The edition (for example, “Standard Edition”). For example, the result looks similar to: 8.00.534 RTM Standard Edition Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation](https://blog.sqlauthority.com/2007/03/05/sql-server-quoted_identifier-onoff-and-ansi_null-onoff-explanation/): When create or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF? SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO--SQL PROCEDURE, SQL FUNCTIONS, SQL OBJECTGO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO ANSI NULL ON/OFF: This option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares a value with a null returns a 0. When off, any query that compares a value with a null returns a null value. QUOTED IDENTIFIER ON/OFF:... - [SQL SERVER - Delete Duplicate Records - Rows](https://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/): Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3. DELETE FROM MyTable WHERE ID NOT IN ( SELECT MAX(ID) FROM MyTable GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3) Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to find the CD key from Registry](https://blog.sqlauthority.com/2007/02/28/sql-server-t-sql-script-to-find-the-cd-key-from-registry/): Here is the way to find SQL Server CD key, which was used to install it on machine. If user do not have permission on the SP, please login using SA username. Expended stored procedure xp_regread can read any registry values. I have used this XP to read CD_KEY. This is undocumented Stroed Procedure and may not be supported in Future Version of SQL Server. USE master GO EXEC xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Microsoft SQL Server\80\Registration','CD_KEY' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - What is New in SQL Server Agent for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/02/26/sql-server-whats-new-in-sql-server-agent-for-microsoft-sql-server-2005/): I came across this interesting and detailed article ‘What’s New in SQL Server Agent for Microsoft SQL Server 2005’ on Microsoft TechNet. This article describes Security Improvements, New Roles in the msdb Database, Multiple Proxy Accounts, Performance Improvements, Performance Counters, New SQL Server Agent Subsystems, Shared Schedules, WMI Event Alerts, SQL Server Agent Sessions, Database Mail Support, Stored Procedure Changes in depth. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Restore Database Backup using SQL Script (T-SQL)](https://blog.sqlauthority.com/2007/02/25/sql-server-restore-database-backup-using-sql-script-t-sql/): In this blog post we are going to learn how to restore database backup using T-SQL script. We have already database which we will use to take a backup first and right after that we will use it to restore to the server. Taking backup is an easy thing, but I have seen many times when a user tries to restore the database, it throws an error. - [SQL SERVER - Download SQL Server 2005 Books Online (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-download-sql-server-2005-books-online-february-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The February 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - SQL Server 2005 Samples and Sample Databases (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-sql-server-2005-samples-and-sample-databases-february-2007/): The samples download provides over 100 samples for SQL Server 2005, demonstrating the following components: Database Engine, including administration, data access, Full-Text Search, Common Language Runtime (CLR) integration, Server Management Objects (SMO), Service Broker, and XML Analysis Services Integration Services Notification Services Reporting Services Replication The samples databases downloads include the AdventureWorks sample online transaction processing (OLTP) database, the AdventureWorksDW sample data warehouse, and the AdventureWorksAS sample projects which you can use to build the AdventureWorksAS BI database. These databases are used in the samples and in the code examples in the SQL Server 2005 Books Online. There is also a... - [SQL SERVER - Creating Comma Separate List From Table](https://blog.sqlauthority.com/2007/02/20/deprecate-dec-2007-creating-comma-separate-list-from-table/): Update : (5/5/2007) I have updated the script to support SQL SERVER 2005. Visit :SQL SERVER – Creating Comma Separate Values List from Table – UDF – SP Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 15023: User already exists in current database.](https://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/): Error 15023: User already exists in current database. 1) This is the best Solution. First of all run following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan. USE YourDB GO EXEC sp_change_users_login 'Report' GO Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist. In following example ‘ColdFusion’ is UserName, ‘cf’ is Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in... - [SQL SERVER - Function to Convert List to Table](https://blog.sqlauthority.com/2007/02/10/sql-server-function-to-convert-list-to-table/): Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005. Visit :SQL SERVER – UDF – Function to Convert List to Table Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Constraints and Unique Key Constraints](https://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/): Primary Key: Primary Key enforces uniqueness of the column on which they are defined. Primary Key creates a clustered index on the column. Primary Key does not allow Nulls. Create table with Primary Key: CREATE TABLE Authors ( AuthorID INT NOT NULL PRIMARY KEY, Name VARCHAR(100) NOT NULL ) GO Alter table with Primary Key: ALTER TABLE Authors ADD CONSTRAINT pk_authors PRIMARY KEY (AuthorID) GO Unique Key: Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value. Alter table to add unique constraint... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case](https://blog.sqlauthority.com/2007/02/01/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case/): Following function will convert any string to Title Case. I have this function for long time. I do not remember that if I wrote it myself or I modified from original source. Run Following T-SQL statement in query analyzer: SELECT dbo.udf_TitleCase('This function will convert this string to title case!') The output will be displayed in Results pan as follows: This Function Will Convert This String To Title Case! T-SQL code of the function is: CREATE FUNCTION udf_TitleCase (@InputString VARCHAR(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(1) DECLARE @OutputString VARCHAR(255) SET @OutputString = LOWER(@InputString) SET @Index = 2... - [SQL SERVER - ReIndexing Database Tables and Update Statistics on Tables](https://blog.sqlauthority.com/2007/01/31/sql-server-reindexing-database-tables-and-update-statistics-on-tables/): SQL SERVER 2005 uses ALTER INDEX syntax to reindex database. SQL SERVER 2005 supports DBREINDEX but it will be deprecated in future versions. Let us learn how to do ReIndexing Database Tables and Update Statistics on Tables. - [SQL SERVER - Query Analyzer Short Cut to display the text of Stored Procedure](https://blog.sqlauthority.com/2007/01/30/query-analyzer-short-cut-to-display-the-text-of-stored-procedure/): This is quick but interesting trick to display the text of Stored Procedure in the result window. Open SQL Query Analyzer >> Tools >> Customize >> Custom Tab type sp_helptext against Ctrl+3 (or shortcut key of your choice) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2007/01/26/sql-server-sql-joke-sql-humor-sql-laugh/): I have heard this joke from my friend. I always wanted to write it but I was not able to find the source of the joke. This joke I have located on DavidM’s Blog on SQLTeam. It is March 1st and the first day of DBMS school The teacher starts off with a role call.. Teacher: Oracle? “Present sir” Teacher: DB2? “Present sir” Teacher: SQL Server? “Present sir” Teacher: MySQL? [Silence] Teacher: MySQL? [Silence] Teacher: Where the hell is MySQL [In rushes MySQL, unshaven, hair a mess] Teacher: Where have you been MySQL “Sorry sir I thought it was February 31st”... - [SQL SERVER - Query Analyzer Shortcuts](https://blog.sqlauthority.com/2007/01/20/sql-server-query-analyzer-shortcuts/): Download Query Analyzer Shortcuts (PDF) Shortcut Function Shortcut Function ALT+BREAK Cancel a query CTRL+SHIFT+F2 Clear all bookmarks ALT+F1 Database object information CTRL+SHIFT+INSERT Insert a template ALT+F4 Exit CTRL+SHIFT+L Make selection lowercase CTRL+A Select all CTRL+SHIFT+M Replace template parameters CTRL+B Move the splitter CTRL+SHIFT+P Open CTRL+C Copy CTRL+SHIFT+R Remove comment CTRL+D Display results in grid format CTRL+SHIFT+S Show client statistics CTRL+Delete Delete through the end of the line CTRL+SHIFT+T Show server trace CTRL+E Execute query CTRL+SHIFT+U Make selection uppercase CTRL+F Find CTRL+T Display results in text format CTRL+F2 Insert/remove bookmark CTRL+U Change database CTRL+F4 Disconnect CTRL+V Paste CTRL+F5 Parse query and check... - [SQL SERVER - Query to find number Rows, Columns, ByteSize for each table in the current database - Find Biggest Table in Database](https://blog.sqlauthority.com/2007/01/10/sql-server-query-to-find-number-rows-columns-bytesize-for-each-table-in-the-current-database-find-biggest-table-in-database/): USE DatabaseName GO CREATE TABLE #temp ( table_name sysname , row_count INT, reserved_size VARCHAR(50), data_size VARCHAR(50), index_size VARCHAR(50), unused_size VARCHAR(50)) SET NOCOUNT ON INSERT #temp EXEC sp_msforeachtable 'sp_spaceused ''?''' SELECT a.table_name, a.row_count, COUNT(*) AS col_count, a.data_size FROM #temp a INNER JOIN information_schema.columns b ON a.table_name collate database_default = b.table_name collate database_default GROUP BY a.table_name, a.row_count, a.data_size ORDER BY CAST(REPLACE(a.data_size, ' KB', '') AS integer) DESC DROP TABLE #temp Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Simple Example of Cursor](https://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/): UPDATE: For working example using AdventureWorks visit : SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2 This is the simplest example of the SQL Server Cursor. I have used this all the time for any use of Cursor in my T-SQL. DECLARE @AccountID INT DECLARE @getAccountID CURSOR SET @getAccountID = CURSOR FOR SELECT Account_ID FROM Accounts OPEN @getAccountID FETCH NEXT FROM @getAccountID INTO @AccountID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @AccountID FETCH NEXT FROM @getAccountID INTO @AccountID END CLOSE @getAccountID DEALLOCATE @getAccountID Reference: Pinal Dave (http://www.SQLAuthority.com), BOL - [SQL SERVER - Shrinking Truncate Log File - Log Full](https://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/): UPDATE: Please follow link for SQL SERVER – SHRINKFILE and TRUNCATE Log File in SQL Server 2008. Sometime, it looks impossible to shrink the Truncated Log file. Following code always shrinks the Truncated Log File to minimum size possible. USE DatabaseName GO DBCC SHRINKFILE(<TransactionLogName>, 1) BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY DBCC SHRINKFILE(<TransactionLogName>, 1) GO [Update: Please note, there are much more to this subject, read my more recent blogs. This breaks the chain of the logs and in future you will not be able to restore point in time. If you have followed this advise, you are recommended to take full... - [SQL SERVER - Fix : Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved.](https://blog.sqlauthority.com/2006/12/20/sql-server-fix-error-14274-cannot-add-update-or-delete-a-job-or-its-steps-or-schedules-that-originated-from-an-msx-server-the-job-was-not-saved/): To fix the error which occurs after the Windows server name been changed, when trying to update or delete the jobs previously created in a SQL Server 2000 instance, or attaching msdb database. Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved. Reason: SQL Server 2000 supports multi-instances, the originating_server field contains the instance name in the format ‘server\instance’. Even for the default instance of the server, the actual server name is used instead of ‘(local)’. Therefore, after the Windows server is renamed, these jobs... - [SQL SERVER - Find Stored Procedure Related to Table in Database - Search in All Stored Procedure](https://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/): Following code will help to find all the Stored Procedures (SP) which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results. ----Option 1 SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so ON sc.id=so.id WHERE sc.TEXT LIKE '%tablename%' ----Option 2 SELECT DISTINCT o.name, o.xtype FROM syscomments c INNER JOIN sysobjects o ON c.id=o.id WHERE c.TEXT LIKE '%tablename%' Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Cursor to Kill All Process in Database](https://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/): When you run the script please make sure that you run it in different database then the one you want all the processes to be killed. CREATE TABLE #TmpWho (spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150), hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150)) INSERT INTO #TmpWho EXEC sp_who DECLARE @spid INT DECLARE @tString VARCHAR(15) DECLARE @getspid CURSOR SET @getspid =   CURSOR FOR SELECT spid FROM #TmpWho WHERE dbname = 'mydb'OPEN @getspid FETCH NEXT FROM @getspid INTO @spid WHILE @@FETCH_STATUS = 0 BEGIN SET @tString = 'KILL ' + CAST(@spid AS VARCHAR(5)) EXEC(@tString) FETCH NEXT FROM @getspid INTO @spid END CLOSE @getspid DEALLOCATE @getspid DROP TABLE #TmpWho... - [SQL SERVER - Simple Cursor to Select Tables in Database with Static Prefix and Date Created](https://blog.sqlauthority.com/2006/11/30/sql-server-cursor-to-process-tables-in-database-with-static-prefix-and-date-created/): Following cursor query runs through the database and find all the table with certain prefixed ('b_','delete_'). It also checks if the Table is more than certain days old or created before certain days, it will delete it. We can have any other operation on that table like to delete, print or index. - [SQL SERVER - Auto Generate Script to Delete Deprecated Fields in Current Database](https://blog.sqlauthority.com/2006/11/20/sql-server-auto-generate-script-to-delete-deprecated-fields-in-current-database/): I always mark fields to be deprecated with “dep_” as prefix. In this way, after few days, when I am sure that I do not need the field any more I run the query to auto generate the deprecation script. The script also checks for any constraint in the system and auto generate the script to drop it also. SELECT 'ALTER TABLE ['+po.name+'] DROP CONSTRAINT [' + so.name + ']' FROM sysobjects so INNER JOIN sysconstraints sc ON so.id = sc.constid INNER JOIN syscolumns col ON sc.colid = col.colid AND so.parent_obj = col.id AND col.name LIKE 'dep[_]%' INNER JOIN sysobjects po ON so.parent_obj = po.id WHERE so.xtype = 'D' ORDER BY po.name, col.name SELECT... - [SQL SERVER - Query to Find ByteSize of All the Tables in Database](https://blog.sqlauthority.com/2006/11/10/sql-server-query-to-find-byte-size/): SELECT CASE WHEN (GROUPING(sob.name)=1) THEN 'All_Tables'    ELSE ISNULL(sob.name, 'unknown') END AS Table_name,    SUM(sys.length) AS Byte_Length FROM sysobjects sob, syscolumns sys WHERE sob.xtype='u' AND sys.id=sob.id GROUP BY sob.name WITH CUBE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database](https://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/): UPDATE : SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database This is very long query. Optionally, we can limit the query to return results for one or more than one table. SELECT K_Table = FK.TABLE_NAME, FK_Column = CU.COLUMN_NAME, PK_Table = PK.TABLE_NAME, PK_Column = PT.COLUMN_NAME, Constraint_Name = C.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME INNER JOIN ( SELECT i1.TABLE_NAME, i2.COLUMN_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1 INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME WHERE i1.CONSTRAINT_TYPE = 'PRIMARY KEY' ) PT ON PT.TABLE_NAME = PK.TABLE_NAME ---- optional: ORDER BY 1,2,3,4 WHERE PK.TABLE_NAME='something'WHERE FK.TABLE_NAME='something'... - [SQL SERVER - User Defined Functions (UDF) Limitations](https://blog.sqlauthority.com/2007/05/29/sql-server-user-defined-functions-udf-limitations/): UDF have its own advantage and usage but in this article we will see the limitation of UDF. Things UDF can not do and why Stored Procedure are considered as more flexible then UDFs. Stored Procedure are more flexibility then User Defined Functions(UDF). UDF has No Access to Structural and Permanent Tables. UDF can call Extended Stored Procedure, which can have access to structural and permanent tables. (No Access to Stored Procedure) UDF Accepts Lesser Numbers of Input Parameters. UDF can have upto 1023 input parameters, Stored Procedure can have upto 21000 input parameters. UDF Prohibit Usage of Non-Deterministic Built-in Functions... - [SQLAuthority News - Author Visit - Meeting with Readers - Top Three Features of SQL SERVER 2005](https://blog.sqlauthority.com/2007/05/28/sqlauthority-news-author-visit-meeting-with-readers-top-three-features-of-sql-server-2005/): Lots of travelers are visiting to Las Vegas due to long weekend of Memorial Day. I was invited to dinner meeting by two of my readers. It was wonderful discussion with them. We primarily discussed about scalability and upgrading issues about SQL Server. I received feedback about SQLAuthority.com site. There were two primarily request for them. I have been working on both of them already as I have received quite a few request for them from other readers as well. Beta testing has been completed, I will announce them on 1st June. While enjoying dinner I was asked interesting question and... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - SP](https://blog.sqlauthority.com/2007/05/28/sql-server-sql-joke-sql-humor-sql-laugh-sp/): One of my Friend send me(in email) following stored procedure. I laughed when I read it. Please enjoy it. It is here for amusement purpose only. Never use on development or production server. This is already dangerous you have been warned. CREATE PROCEDURE MyMarriage @ BrideGroom CHAR(NotBad), @ Bride CHAR(Good) AS BEGIN SELECT Bride FROM india_ Brides WHERE FatherInLaw = 'Millionaire' AND CarCount > 2 AND HouseStatus ='TwoStoreyed' AND BrideEduStatus='PG or Above' AND HavingBrothers='NO' AND HavingSisters ='No' AND AllowRelocate ='YES' SELECT Gold ,Cash,Car,BankBalance FROM FatherInLaw UPDATE MyBankAccout SET MyBal = MyBal + FatherinLawBal UPDATE MyLocker SET MyLockerContents = MyLockerContents + FatherinLawGold... - [SQL SERVER - Download Feature Pack for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/05/27/sql-server-download-feature-pack-for-microsoft-sql-server-2005/): Feature Pack for Microsoft SQL Server 2005 – February 2007 Download the February 2007 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. I have listed all the stand alone packages here. Even though title says February 2007, publication day of this package is 5/25/2007. All DBA should go through following list and see if their organization is using any of the application/feature and update is required for them. Microsoft ADOMD.NET Microsoft Core XML Services (MSXML) 6.0 Microsoft OLEDB Provider for DB2 Microsoft SQL Server Management Pack for MOM... - [SQL SERVER - 2005 Limiting Result Sets by Using TABLESAMPLE - Examples](https://blog.sqlauthority.com/2007/05/27/sql-server-2005-limiting-result-sets-by-using-tablesample-examples/): Introduced in SQL Server 2005, TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set. Example 1: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (10 PERCENT) Example 2: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (1000 ROWS) If you run above script many times you will notice that different numbers of... - [SQL SERVER - 2005 Replace TEXT with VARCHAR(MAX) - Stop using TEXT, NTEXT, IMAGE Data Types](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-replace-text-with-varcharmax-stop-using-text-ntext-image-data-types/): Yesterday, in Friday Afternoon team meeting. I was asked question by one of application developer “I am asked in new coding standards to use VARHCAR(MAX) instead of TEXT. Is VARCHAR(MAX) big enough to store TEXT field?” Well, I realize that I was not clear enough in my coding standard. It is extremely important for coding standards to be clear and have a enough explanation that developer have no doubt about them. I updated coding standards after the meeting. The answer is “Yes, VARCHAR(MAX) is big enough to accommodate TEXT field. TEXT, NTEXT and IMAGE data types of SQL Server 2000 will... - [SQL SERVER - 2005 Find Table without Clustered Index - Find Table with no Primary Key](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-find-table-without-clustered-index-find-table-with-no-primary-key/): One of the basic Database Rule I have is that all the table must Clustered Index. Clustered Index speeds up performance of the query ran on that table. Clustered Index are usually Primary Key but not necessarily. I frequently run following query to verify that all the Jr. DBAs are creating all the tables with no Clustered Index. USE AdventureWorks ----Replace AdventureWorks with your DBName GO SELECT DISTINCT [TABLE] = OBJECT_NAME(OBJECT_ID) FROM SYS.INDEXES WHERE INDEX_ID = 0 AND OBJECTPROPERTY(OBJECT_ID,'IsUserTable') = 1 ORDER BY [TABLE] GO Result set for AdventureWorks: TABLE ——————————————————- DatabaseLog ProductProductPhoto (2 row(s) affected) Related Post: SQL SERVER –... - [SQL SERVER - Change Default Fill Factor For Index](https://blog.sqlauthority.com/2007/05/25/sql-server-change-default-fill-factor-for-index/): SQL Server has default value for fill factor is Zero (0). The fill factor is implemented only when the index is created; it is not maintained after the index is created as data is added, deleted, or updated in the table. When creating an index, you can specify a fill factor to leave extra gaps and reserve a percentage of free space on each leaf level page of the index to accommodate future expansion in the storage of the table's data and reduce the potential for page splits. Let us learn about how to change default fill factor of index. - [SQL SERVER - Stored Procedure to display code (text) of Stored Procedure, Trigger, View or Object](https://blog.sqlauthority.com/2007/05/25/sql-server-stored-procedure-to-display-code-text-of-stored-procedure-trigger-view-or-object/): This is another popular question I receive. How to see text/content/code of Stored Procedure. System stored procedure that prints the text of a rule, a default, or an unencrypted stored procedure, user-defined function, trigger, or view. Syntax sp_helptext @objname = 'name' sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name Displaying the definition of a trigger or stored procedure sp_helptext 'dbo.nameofsp' Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Disadvantages (Problems) of Triggers](https://blog.sqlauthority.com/2007/05/24/sql-server-disadvantages-problems-of-triggers/): One of my team member asked me should I use triggers or stored procedure. Both of them has its usage and needs. I just basically told him few issues with triggers. This is small note about our discussion. Disadvantages(Problems) of Triggers It is easy to view table relationships , constraints, indexes, stored procedure in database but triggers are difficult to view. Triggers execute invisible to client-application application. They are not visible or can be traced in debugging code. It is hard to follow their logic as it they can be fired before or after the database insert/update happens. It is easy... - [SQL SERVER - 2005 Retrieve Configuration of Server](https://blog.sqlauthority.com/2007/05/24/sql-server-2005-retrieve-configuration-of-server/): Few days ago I was asked what is our SQL Server’s configuration. I provided way more information then they requested. Run following script and it will provide all the information about SQL Server . SQL Server provides in detailed information if Advanced Options are turned on. It is very clear from this that maximum number of object SQL Server can have is 2,147,483,647. It is considerably very big number. I am not worried yet about my database reaching its limit. EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure GO EXEC sp_configure 'show advanced options', 0 GO To change... - [SQL SERVER - NorthWind Database or AdventureWorks Database - Samples Databases](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases/): SQL Server 2005 does not install sample databases by default due to security reasons.I have received many questions regarding where is sample database in SQL Server 2005. One can install it afterward. AdventureWorks and AdvetureWorksDS are the new sample databases for SQL Server 2005, they can be download from here. Let us learn how to install NorthWind Database - samples databases.  - [SQL SERVER - 2005 Explanation Left Semi Join Showplan Operator and Other Operator](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-explanation-left-semi-join-showplan-operator-and-other-operator/): I come across very interesting documentation about Joins, while I was researching about article about EXCEPT yesterday. There are few interesting kind of join operations exists when execution plan is displayed in text format. Left Semi Join Showplan Operator The Left Semi Join operator returns each row from the first (top) input when there is a matching row in the second (bottom) input. If no join predicate exists in the Argument column, each row is a matching row. Left Anti Semi Join Showplan Operator The Left Anti Semi Join operator returns each row from the first (top) input when there is... - [SQLAuthority News - Funny One Liners - Humor](https://blog.sqlauthority.com/2007/05/23/sqlauthority-news-funny-one-liners-humor/): Once in a while we should laugh and relax. Here are few of my favorite funny one liners which I often use in my presentations. Let us start- Just read that 4,153,237 people got married last year, not to cause any trouble, but shouldn't that be an even number? - [SQLAuthority News - T-Shirts in Action](https://blog.sqlauthority.com/2007/05/22/sqlauthority-news-t-shirts-in-action/): Thank you All for great response to SQLAuthority T-Shirts. I have ran out of all of them. Please put your request here. I will go over all of them soon and see what I can do. They are made from high quality fiber and very comfortable. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Comparison EXCEPT operator vs. NOT IN](https://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/): The EXCEPT operator returns all of the distinct rows from the query to the left of the EXCEPT operator when there are no matching rows in the right query. The EXCEPT operator is equivalent of the Left Anti Semi Join. EXCEPT operator works the same way NOT IN. EXCEPTS returns any distinct values from the query to the left of the EXCEPT operand that do not also return from the right query. - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - T-Shirt](https://blog.sqlauthority.com/2007/05/21/sql-server-sql-joke-sql-humor-sql-laugh-t-shirt/): My friend sent me this in an email two days ago as he wanted me to have SQLAuthority T-Shirt with this image. I found it funny, I am not sure if I will have this on SQLAuthority T-Shirts. Please pay attention to the options available to select. I spend more than 3 hours to find the original source as my friend did not remember the source. Let's see some SQL Humor here: - [SQL SERVER - Top 15 free SQL Injection Scanners - Link to Security Hacks](https://blog.sqlauthority.com/2007/05/21/sql-server-top-15-free-sql-injection-scanners-link-to-security-hacks/): SQL injection is a technique for exploiting web applications that use client-supplied data in SQL queries, but without first stripping potentially harmful characters. Checking for SQL Injection vulnerabilities involves auditing your web applications and the best way to do it is by using automated SQL Injection Scanners. Security-Hacks.com compiled a list of free SQL Injection Scanners. I really enjoy reading the article. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Build List Link](https://blog.sqlauthority.com/2007/05/21/sql-server-2005-build-list-link/): What is Build List? All SQL Server has build list, this is incremental list of numbers which indicates which version SQL Server is running and what are its compatibility, patches etc. Regular Columnist Steve Jones of SQL Server Central has created build list. It is updated and informative. Microsoft Hot fixes are always cumulative. You can find your build number with: SELECT@@Version Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Code Formatting Tools](https://blog.sqlauthority.com/2007/05/20/sql-server-sql-code-formatter-tools/): SQL Code Formatting is very important. Every SQL Server DBA has its own preference about formatting. I like to format all keywords to uppercase. Following are two online tools, which formats SQL Code very good. I tested following script with those tools and I found two of the tools worth mentioning here. - [SQL SERVER - Script/Function to Find Last Day of Month](https://blog.sqlauthority.com/2007/05/20/sql-server-scriptfunction-to-find-last-day-of-month/): Following query will find the last day of the month. Query also take care of Leap Year. Script: DECLARE @date DATETIME SET @date='2008-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO DECLARE @date DATETIME SET @date='2007-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO ResultSet: LastDayOfMonth ----------------------- 2008-02-29 00:00:00.000 (1 row(s) affected) LastDayOfMonth ----------------------- 2007-02-28 00:00:00.000 (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ASCII to Decimal and Decimal to ASCII Conversion](https://blog.sqlauthority.com/2007/05/19/sql-server-ascii-to-decimal-and-decimal-to-ascii/): In this blog post we will see how we can convert ASCII to Decimal and Decimal to ASCII. In simple words, we will see the decimal and ASCII conversion. - [SQL SERVER - Math Functions Available in SQL Server](https://blog.sqlauthority.com/2007/05/19/sql-server-math-functions-for-2005/): The large majority of math functions is specific to applications using trigonometry, calculus, and geometry. This is very important and it is very difficult to have all of them together at place. - [SQL SERVER - 2005 Understanding Trigger Recursion and Nesting with examples](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-understanding-trigger-recursion-and-nesting-with-examples/): Trigger events can be fired within another trigger action. One Trigger execution can trigger even on another table or same table. This trigger is called NESTED TRIGGER or RECURSIVE TRIGGER. Nested triggers SQL Server supports the nesting of triggers up to a maximum of 32 levels. Nesting means that when a trigger is fired, it will also cause another trigger to be fired. If a trigger creates an infinitive loop, the nesting level of 32 will be exceeded and the trigger will cancel with an error message. Recursive triggers When a trigger fires and performs a statement that will cause the... - [SQL SERVER - 2005 - SSMS Change T-SQL Batch Separator](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-ssms-change-t-sql-batch-separator/): I recently received one big file with many T-SQL batches. It was a very big file and I was asked that this file was tested many times and it can run one transaction. I noticed the separator of the batches is not GO but it was EndBatch. I have followed two options to run the whole batch in one transaction. Let us learn how to change T-SQL Batch Separator. - [SQLAuthority News - Limited Edition T-Shirts Arrived](https://blog.sqlauthority.com/2007/05/17/sqlauthority-news-limited-edition-t-shirts-arrived/): I have received quite a few request for SQLAuthority.com T-shirts. Every day I receive lots of emails and suggestions. Many readers have great suggestions and have helped to improve content. First of all I express my gratitude to all of you. Few of my loyal and enthusiastic readers will receive the T-shirt by tomorrow. T-shirts are very limited. I have kept only two for me and have shipped all other. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Disable Index - Enable Index - ALTER Index](https://blog.sqlauthority.com/2007/05/17/sql-server-disable-index-enable-index-alter-index/): There are few requirements in real world when Index on table needs to be disabled and re-enabled afterwards. e.g. DTS, BCP, BULK INSERT etc. Index can be dropped and recreated. I prefer to disable the Index if I am going to re-enable it again. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO ----Enable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact REBUILD GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-1205-transaction-process-id-was-deadlocked-on-resources-with-another-process-and-has-been-chosen-as-the-deadlock-victim-rerun-the-transaction/): Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction. - [SQL SERVER - Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-130-cannot-perform-an-aggregate-function-on-an-expression-containing-an-aggregate-or-a-subquery/): Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery Following statement will give the following error: “Cannot perform an aggregate function on an expression containing an aggregate or a subquery.” MS SQL Server doesn’t support it. USE PUBS GO SELECT AVG(COUNT(royalty)) RoyaltyAvg FROM dbo.roysched GO You can get around this problem by breaking out the computation of the average in derived tables. USE PUBS GO SELECT AVG(t.RoyaltyCounts) FROM ( SELECT COUNT(royalty) AS RoyaltyCounts FROM dbo.roysched ) T GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL. - [SQL SERVER - Binary Sequence Generator - Truth Table Generator](https://blog.sqlauthority.com/2007/05/15/sql-server-binary-sequence-generator-truth-table-generator/): Run following script in query editor to generate truth table with its decimal value and binary sequence. The truth table is 512 rows long. This can be extended or reduced by adding or removing cross joins respectively. Script: USE AdventureWorks; DECLARE @Binary TABLE ( Digit bit) INSERT @Binary VALUES (0) INSERT @Binary VALUES (1) SELECT ((a.Digit*256) + (b.Digit*128) + (c.Digit*64) + (d.Digit*32) + (e.Digit*16) + (f.Digit*8) + (g.Digit*4) + (h.Digit*2) + (i.Digit*1)) DecimalValue, a.Digit '256', b.Digit '128' , c.Digit '64', d.Digit '32', e.Digit '16', f.Digit '8', g.Digit '4', h.Digit '2', i.Digit '1' FROM @Binary a CROSS JOIN @Binary b CROSS JOIN... - [SQL SERVER - DBCC commands List - documented and undocumented](https://blog.sqlauthority.com/2007/05/15/sql-server-dbcc-commands-list-documented-and-undocumented/): Database Consistency Checker (DBCC) commands can gives valuable insight into what’s going on inside SQL Server system. DBCC commands have powerful documented functions and many undocumented capabilities. Current DBCC commands are most useful for performance and troubleshooting exercises. To learn about all the DBCC commands run following script in query analyzer. DBCC TRACEON(2520) DBCC HELP (‘?’) GO To learn about syntax of an individual DBCC command run following script in query analyzer. DBCC HELP(<command>) GO Following is the list of all the DBCC commands and their syntax. List contains all documented and undocumented DBCC commands. DBCC activecursors [(spid)] DBCC addextendedproc (function_name,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Photo](https://blog.sqlauthority.com/2007/05/14/sql-server-sql-joke-sql-humor-sql-laugh-photo/): Pay attention to the last line of the ingredients. I found this entry at Worse Than Failure. I found it humorous. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - MS TechNet : Storage Top 10 Best Practices](https://blog.sqlauthority.com/2007/05/14/sql-server-ms-technet-storage-top-10-best-practices/): This one of the very interesting article I read regarding SQL Server 2005 Storage. Please refer original article at MS TechNet here. Understand the IO characteristics of SQL Server and the specific IO requirements / characteristics of your application. More / faster spindles are better for performance. Try not to “over” optimize the design of the storage; simpler designs generally offer good performance and more flexibility. Validate configurations prior to deployment. Always place log files on RAID 1+0 (or RAID 1) disks. Isolate log from data at the physical disk level. Consider configuration of TEMPDB database. Lining up the number of... - [SQL SERVER - Query to Find First and Last Day of Current Month - Date Function](https://blog.sqlauthority.com/2007/05/13/sql-server-query-to-find-first-and-last-day-of-current-month/): Following query will run respective on today's date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month. Let us see how we can do this with the help of Date Function in SQL Server. - [SQL SERVER - UDF - Function to Parse AlphaNumeric Characters from String](https://blog.sqlauthority.com/2007/05/13/sql-server-udf-function-to-parse-alphanumeric-characters-from-string/): Following function keeps only Alphanumeric characters in string and removes all the other character from the string. This is very handy function when working with Alphanumeric String only. I have used this many times. CREATE FUNCTION dbo.UDF_ParseAlphaChars ( @string VARCHAR(8000) ) RETURNS VARCHAR(8000) AS BEGIN DECLARE @IncorrectCharLoc SMALLINT SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) WHILE @IncorrectCharLoc > 0 BEGIN SET @string = STUFF(@string, @IncorrectCharLoc, 1, '') SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) END SET @string = @string RETURN @string END GO —-Test SELECT dbo.UDF_ParseAlphaChars('ABC”_I+{D[]}4|:e;””5,<.F>/?6') GO Result Set : ABCID4e5F6 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List all the database](https://blog.sqlauthority.com/2007/05/12/sql-server-2005-list-all-the-database/): List all the database on SQL Servers. All the following Stored Procedure list all the Databases on Server. I personally use EXEC sp_databases because it gives the same results as other but it is self explaining. ----SQL SERVER 2005 System Procedures EXEC sp_databases EXEC sp_helpdb ----SQL 2000 Method still works in SQL Server 2005 SELECT name FROM sys.databases SELECT name FROM sys.sysdatabases ----SQL SERVER Un-Documented Procedure EXEC sp_msForEachDB 'PRINT ''?''' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support](https://blog.sqlauthority.com/2007/05/12/sql-server-fix-error-msg-6263-level-16-state-1-line-2-enabling-sql-server-2005-for-clr-support/): Error: Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support 1) Enable Server for CLR Support. - [SQL SERVER - Explanation SQL Command GO](https://blog.sqlauthority.com/2007/05/11/sql-server-explanation-sql-command-go/): GO is not a Transact-SQL statement; it is often used in T-SQL code. Go causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches. SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is... - [SQL SERVER - Download Microsoft SQL Server 2005 System Views Map](https://blog.sqlauthority.com/2007/05/11/sql-server-download-microsoft-sql-server-2005-system-views-map/): The Microsoft SQL Server 2005 System Views Map shows the key system views included in SQL Server 2005, and the relationships between them. It is available to download from Microsoft Site. It can be printed and mounted at Office Depot or Kinko’s. Download SQL SERVER 2005 System Views Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 Katmai - Download Datasheet Final from Microsoft](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-download-datasheet-final-from-microsoft/): Few interesting thing about Katmai. SQL Server “Katmai” will provide a more secure, reliable and manageable enterprise data platform. SQL Server “Katmai” will enable developers and administrators to save time by allowing them to store and consume any type of data from XML to documents. SQL Server “Katmai” provides a more scalable infrastructure that enables IT to drive business intelligence throughout the organization. SQL Server “Katmai” along with .NET Framework 3.0 will accelerate the development of the next generation of applications. Reference : Pinal Dave (https://blog.sqlauthority.com) MS SQL Server (All the above text) Download Final Datasheet of Katmai from Microsoft - [SQL SERVER - Fix: Error: HResult 0x2, Named Pipes Provider: Could not open a connection](https://blog.sqlauthority.com/2007/05/10/sql-server-fix-error-hresult-0x2-level-16-state-1-named-pipes-provider-could-not-open-a-connection-to-sql-server/): In this blog post we are going to fix the error which is related to Named Pipes Provider. - [SQL SERVER - 2008 Katmai - Your Data, Any Place, Any Time](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-your-data-any-place-any-time/): I was following up on the news of first Microsoft Business Intelligence (BI) Conference held at Seattle. Good news is – SQL Server 2008 code name ‘Katmai’ is announced. I went to the official website I like the catchy line “Your Data, Any Place, Any Time“. As per my opinion the most important thing about Katmai is that it can be used to manage any type of data, including relational data, documents, geographic information and XML. The question I received many times since yesterday is : I am still using SQL Server 2000, I was planning to upgrade to SQL Server... - [SQL SERVER - Fix : Error 2501 : Cannot find a table or object with the name . Check the system catalog.](https://blog.sqlauthority.com/2007/05/09/sql-server-fix-error-2501-cannot-find-a-table-or-object-with-the-name-check-the-system-catalog/): Error 2501 : Cannot find a table or object with the name . Check the system catalog. This is very generic error beginner DBAs or Developers faces. The solution is very simple and easy. Follow the direction below in order. Fix/Workaround/Solution: Make sure that correct Database is selected. If not please run USE YourDatabase. Check the object or table name. They must be spelled correct. If database is case sensitive please use correct case. Use object belongs to other owner use two parts name as scheme_name.object_name. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - MIS2007 Part II - Database Raid Discussion](https://blog.sqlauthority.com/2007/05/09/sqlauthority-news-author-visit-mis2007-part-ii-database-raid-discussion/): MIS2007 is really going good. There are many things going on. As I mentioned in my previous article, It is really pleasure to meet industry leaders. There was discussion about what is good for database RAID 5 configuration or RAID 10. This subject is always very interesting. We were discussing from small databases (5GB) to larger databases(5 TB). The question was which RAID 5 or RAID 10. Surprisingly, everybody who participated in discussion said their experience says RAID 10 is better for this particular application as there are lots of reads and writes in database. One of the expert suggested that... - [SQL SERVER - Index Optimization CheckList](https://blog.sqlauthority.com/2007/05/08/sql-server-index-optimization-checklist/): Index optimization is always interesting subject to me. Every time I receive requests to help optimize query or query on any specific table. I always ask Jr.DBA to go over following list first before I take a look at it. Most of the time the Query Speed is optimized just following basic rules mentioned below. Once following checklist applied interesting optimization part begins which only experiment and experience can resolve. - [SQLAuthority News - Author Visit - The 2007 Marketing Innovation Summit, Las Vegas](https://blog.sqlauthority.com/2007/05/08/sqlauthority-news-author-visit-the-2007-marketing-innovation-summit-las-vegas/): I am attending The 2007 Marketing Innovation Summit“, Las Vegas. It started on 5/6/2007 and will continue till 5/9/2007. Unica Corporation has arranged this conference. The MIS 2007 Agenda includes: Case studies and best practices Sessions focused on Relationship Marketing, Internet Marketing and Marketing Operations Hands on “how to” sessions General sessions from distinguished industry experts A one-day Pre-Summit Affinium New User Workshop and Getting Prepared for Affinium Plan Post-Summit Hands-On Training Evening networking activities In two days so far, I have learned a lot and have met many industry leaders. Talking about cutting edge technology and SQL Server was perfect... - [SQL SERVER - Top 10 Hidden Gems in SQL Server 2005](https://blog.sqlauthority.com/2007/05/07/sql-server-top-10-hidden-gems-in-sql-server-2005/): Top 10 Hidden Gems in SQL Server 2005 By Cihan Biyikoglu SQL Server 2005 has hundreds of new and improved components. Some of these improvements get a lot of the spotlight. However there is another set that are the hidden gems that help us improve performance, availability or greatly simplify some challenging scenarios. This paper lists the top 10 such features in SQL Server 2005 that we have discovered through the implementation with some of our top customers and partners. TableDiff.exe Triggers for Logon Events (New in Service Pack 2) Boosting performance with persisted-computed-columns (pcc). DEFAULT_SCHEMA setting in sys.database_principles Forced Parameterization... - [SQL SERVER - 2005/2000 Examples and Explanation for GOTO](https://blog.sqlauthority.com/2007/05/07/sql-server-20052000-examples-and-explanation-for-goto/): The GOTO statement causes the execution of the T-SQL batch to stop processing the following commands to GOTO and processing continues from the label where GOTO points. GOTO statement can be used anywhere within a procedure, batch, or function. GOTO can be nested as well. GOTO can be executed by any valid user on SQL SERVER. GOTO can co-exists with other control of flow statements (IF…ELSE, WHILE). GOTO can only go(jump) to label in the same batch, it can not go to label out side of the batch. Syntax: Define the label: label: ALTER the execution: GOTO label Notes from MSDN... - [SQL SERVER - Creating Comma Separate Values List from Table - UDF - SP](https://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/): Following script will create common separate values (CSV) or common separate list from tables. convert list to table. Following script is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. There are three ways to do this. 1) Using COALESCE 2) Using SELECT Smartly 3) Using CURSOR. The table is example is: TableName: NumberTable NumberCols first second third fourth fifth Output : first,second,third,fourth,fifth Option 1: This is... - [SQL SERVER - UDF - Function to Convert List to Table](https://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/): Following Users Defined Functions will convert list to table. It also supports user defined delimiter. Following UDF is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. CREATE FUNCTION dbo.udf_List2Table ( @List VARCHAR(MAX), @Delim CHAR ) RETURNS @ParsedList TABLE ( item VARCHAR(MAX) ) AS BEGIN DECLARE @item VARCHAR(MAX), @Pos INT SET @List = LTRIM(RTRIM(@List))+ @Delim SET @Pos = CHARINDEX(@Delim, @List, 1) WHILE @Pos > 0 BEGIN SET... - [SQL SERVER - 2005 Enable CLR using T-SQL script](https://blog.sqlauthority.com/2007/05/05/sql-server-2005-enable-clr-using-t-sql-script/): Before doing any .Net coding in SQL Server you must enable the CLR. In SQL Server 2005, the CLR is OFF by default. This is done in an effort to limit security vulnerabilities. Following is the script which will enable CLR. EXEC sp_CONFIGURE 'show advanced options' , '1'; GO RECONFIGURE; GO EXEC sp_CONFIGURE 'clr enabled' , '1' GO RECONFIGURE; GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - UDF - User Defined Function to Find Weekdays Between Two Dates](https://blog.sqlauthority.com/2007/05/05/sql-server-udf-user-defined-function-to-find-weekdays-between-two-dates/): Following user defined function returns number of weekdays between two dates specified. This function excludes the dates which are passed as input params. It excludes Saturday and Sunday as they are weekends. I always had this function with for reference but after some research I found original source website of the function. This function has been written by Author Alexander Chigrik. CREATE FUNCTION dbo.spDBA_GetWeekDays ( @StartDate datetime, @EndDate datetime ) RETURNS INT AS BEGIN DECLARE @WorkDays INT, @FirstPart INT DECLARE @FirstNum INT, @TotalDays INT DECLARE @LastNum INT, @LastPart INT IF (DATEDIFF(DAY, @StartDate, @EndDate) 0) THEN @LastPart - 1 ELSE 0 END... - [SQL SERVER - Fix : Error : Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset DBSCHEMA_TABLES_INFO for OLE DB provider SQLNCLI for linked server LinkedServerName](https://blog.sqlauthority.com/2007/05/04/sql-server-fix-error-msg-7311-level-16-state-2-line-1-cannot-obtain-the-schema-rowset-dbschema_tables_info-for-ole-db-provider-sqlncli-for-linked-server-linkedservername/): You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server. Error: The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator. Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset “DBSCHEMA_TABLES_INFO” for OLE DB provider “SQLNCLI” for linked server “<LinkedServerName>”. The provider supports the interface, but returns a failure code when it is used. Fix/WorkAround/Solution: Use Windows Authentication mode For a... - [SQL SERVER - Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts)](https://blog.sqlauthority.com/2007/05/04/sql-server-download-sql-server-management-studio-keyboard-shortcuts-ssms-shortcuts/): Download SQL Server Management Studio Keyboard Shortcuts I have received many emails appreciating my article Query Analyzer Shortcuts and requesting same for SQL Server Management Studio Keyboard Shortcuts. I see frequent downloads of the PDF generated by SQLAuthority for the same on server. There is original article on MSDN site. I have combined complete article in one PDF again. It is easy to refer, print and manage. Download SQL Server Management Studio Keyboard Shortcuts Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC Commands to Free SQL Server Memory Caches](https://blog.sqlauthority.com/2007/05/03/sql-server-dbcc-commands-to-free-several-sql-server-memory-caches/): Lots of people do not know that following command can be very helpful to clear your memory caches of SQL Server. I have often seen people restarting their entire system to clear the memory caches. - [SQL SERVER - Enable Login - Disable Login using ALTER LOGIN - Change name of the 'SA'](https://blog.sqlauthority.com/2007/05/03/sql-server-enable-login-disable-login-using-alter-login-change-name-of-the-sa/): Enable Login – Disable Login using ALTER LOGIN – Change name of the ‘SA’ - [SQL SERVER - FIX : ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup](https://blog.sqlauthority.com/2007/05/02/sql-server-fix-error-1101-could-not-allocate-a-new-page-for-database-because-of-insufficient-disk-space-in-filegroup/): ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup . Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. Fix/Workaround/Solution: Make sure there is enough Hard Disk space where database files are stored on server. Turn on AUTOGROW for file groups. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 TOP Improvements/Enhancements](https://blog.sqlauthority.com/2007/05/02/sql-server-2005-top-improvementsenhancements/): SQL Server 2005 introduces two enhancements to the TOP clause. 1) User can specify an expression as an input to the TOP keyword. 2) User can use TOP in modification statements (INSERT, UPDATE, and DELETE). Explanation : User can specify an expression as an input to the TOP keyword. In SQL SERVER 2000 usage of TOP is implemented in following query. SELECT TOP 10 TableColumnID FROM TableName   For ages Developers and DBAs wants to pass parameters to TOP keyword. IN SQL SERVER 2005 it is possible. Example, @iNum is variables set before SELECT statement is ran. DECLARE @iNum INT SET... - [SQL SERVER - User Defined Functions (UDF) to Reverse String - UDF_ReverseString](https://blog.sqlauthority.com/2007/05/01/sql-server-user-defined-functions-udf-to-reverse-string-udf_reversestring/): UDF_ReverseString UDF_ReverseString User Defined Functions returns the Reversed String starting from certain position. First parameters takes the string to be reversed. Second parameters takes the position from where the string starts reversing. Script of UDF_ReverseString function to return Reverse String. CREATE FUNCTION UDF_ReverseString ( @StringToReverse VARCHAR(8000), @StartPosition INT ) RETURNS VARCHAR(8000) AS BEGIN IF (@StartPosition <= 0) OR (@StartPosition > LEN(@StringToReverse)) RETURN (REVERSE(@StringToReverse)) RETURN (STUFF (@StringToReverse, @StartPosition, LEN(@StringToReverse) - @StartPosition + 1, REVERSE(SUBSTRING (@StringToReverse, @StartPosition LEN(@StringToReverse) - @StartPosition + 1)))) END GO Usage of above UDF_ReverseString: Reversing the string from third position SELECT dbo.UDF_ReverseString('forward string',3) Results Set : forgnirts draw Reversing... - [SQL SERVER - Copy Column Headers in Query Analyzers in Result Set](https://blog.sqlauthority.com/2007/05/01/sql-server-copy-column-headers-in-query-analyzers-in-result-set/): Copy Column Headers in Query Analyzers in Result Set. In Query Analyzer go to Menu >> Tools >> Options >> Results Select Default results Target: Results to Text Results output format:(*): Tab Delimited Print column headers(*): Checkbox ON(check) [youtube=http://www.youtube.com/watch?v=BL5GO-jH3HA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com 100th Post - Gratitude Note to Readers](https://blog.sqlauthority.com/2007/05/01/sqlauthoritycom-101st-post-gratitude-note-to-readers/): Hello All, I would like to express my deep gratitude to all of my readers for their emails, comments, suggestions and continuous support on the occasion of 101st post on this blog. I would like to extend my gratitude to my parents. In good times or trying times my parents are there with me always. Mom and Dad thank you for your encouragement, warmth, advise and continuous love. Kind Regards and Best Wishes, Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Collate - Case Sensitive SQL Query Search](https://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/): In this blog post we are going to learn about how to do Case Sensitive SQL Query Search. If Column1 of Table1 has following values ‘CaseSearch, casesearch, CASESEARCH, CaSeSeArCh’, following statement will return you all the four records. - [SQL SERVER - FIX : ERROR : Msg 3159, Level 16, State 1, Line 1 - Msg 3013, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/30/sql-server-fix-error-msg-3159-level-16-state-1-line-1-msg-3013-level-16-state-1-line-1/): While moving some of the script from SQL SERVER 2000 to SQL SERVER 2005 our migration team faced following error. Msg 3159, Level 16, State 1, Line 1 The tail of the log for the database “AdventureWorks” has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. Following is the similar script using AdventureWorks... - [SQL SERVER - SET ROWCOUNT - Retrieving or Limiting the First N Records from a SQL Query](https://blog.sqlauthority.com/2007/04/30/sql-server-set-rowcount-retrieving-or-limiting-the-first-n-records-from-a-sql-query/): A SET ROWCOUNT statement simply limits the number of records returned to the client during a single connection. As soon as the number of rows specified is found, SQL Server stops processing the query. The syntax looks like this: - [SQL SERVER - 2005 Security DataSheet](https://blog.sqlauthority.com/2007/04/29/sql-server-2005-security-datasheet/): Microsoft has implemented strong security features into the Microsoft® SQL Server™ 2005, which provides a security-enabled platform for enterprise-class relational database and analysis solutions. SQL Server 2005 provides cutting edge security technology and addresses several security issues, including automatic secured updates and encryption of sensitive data. Download the SQL Server 2005 Security DataSheet from SQLAuthority.com Download the SQL Server 2005 Security DataSheet from Microsoft.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Random Number Generator Script - SQL Query](https://blog.sqlauthority.com/2007/04/29/sql-server-random-number-generator-script-sql-query/): Random Number Generator. There are many methods to generate random numbers in SQL Server. Method 1: Generate Random Numbers (Int) between Rang - [SQL SERVER - Replication Keywords Explanation and Basic Terms](https://blog.sqlauthority.com/2007/04/29/sql-server-replication-keywords-explanation-and-basic-terms/): While discussing replication with Jr. DBAs at work, I realize some of them have not experienced replication feature of SQL SERVER. Following is quick reference of replication keywords I created for easy conversation. - [SQL SERVER - Explanation SQL SERVER Merge Join](https://blog.sqlauthority.com/2007/04/28/sql-server-explanation-sql-server-merge-join/): The Merge Join transformation provides an output that is generated by joining two sorted data sets using a FULL, LEFT, or INNER join. The Merge Join transformation requires that both inputs be sorted and that the joined columns have matching meta-data. User cannot join a column that has a numeric data type with a column that has a character data type. If the data has a string data type, the length of the column in the second input must be less than or equal to the length of the column in the first input with which it is merged. USE pubs... - [SQL SERVER - Restrictions of Views - T SQL View Limitations](https://blog.sqlauthority.com/2007/04/28/sql-server-restrictions-of-views-t-sql-view-limitations/): UPDATE: (5/15/2007) Thank you Ben Taylor for correcting errors and incorrect information from this post. He is Database Architect and writes Database Articles at www.sswug.org. I have been coding as T-SQL for many years. I never have to use view ever in my career. I do not see in my near future I am using Views. I am able to achieve same database architecture goal using either using Third Normal tables, Replications or other database design work around.SQL Views have many many restrictions. There are few listed below. I love T-SQL but I do not like using Views. - [SQL SERVER - Good, Better and Best Programming Techniques](https://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/): A week ago, I was invited to meeting of programmers. Subject of meeting was “Good, Better and Best Programming Techniques”. I had made small note before I went to meeting, so if I have to talk about or discuss SQL Server it can come handy. Well, I did not get chance to talk on that as it was very causal and just meeting and greetings. Everybody just talked about what they think about their job. I talked very briefly about SQL Server, my current job and some funny incident at work. Everybody laughed big when I talked about funny bug ticket... - [SQL SERVER - Query to Retrieve the Nth Maximum Value](https://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/): Replace Employee with your table name, and Salary with your column name. Where N is the level of Salary to be determined. Let us see a query to retrieve the Nth Maximum Value. - [SQL SERVER - Locking Hints and Examples](https://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/): Locking Hints and Examples are as follows. The usage of them is the same but the effect is different. Let us learn it today together. - [SQL SERVER - SELECT vs. SET Performance Comparison](https://blog.sqlauthority.com/2007/04/27/sql-server-select-vs-set-performance-comparison/): Usage: SELECT : Designed to return data. SET : Designed to assign values to local variables. While testing the performance of the following two scripts in query analyzer, interesting results are discovered. SET @foo1 = 1; SET @foo2 = 2; SET @foo3 = 3; SELECT @foo1 = 1, @foo2 = 2, @foo3 = 3; While comparing their performance in loop SELECT statement gives better performance then SET. In other words, SET is slower than SELECT. The reason is that each SET statement runs individually and updates on values per execution, whereas the entire SELECT statement runs once and update all three... - [SQL SERVER - Difference Between Unique Index vs Unique Constraint](https://blog.sqlauthority.com/2007/04/26/sql-server-difference-between-unique-index-vs-unique-constraint/): Unique Index and Unique Constraint are the same. They achieve same goal. SQL Performance is same for both. Add Unique Constraint ALTER TABLE dbo.<tablename> ADD CONSTRAINT <namingconventionconstraint> UNIQUE NONCLUSTERED ( <columnname> ) ON [PRIMARY] Add Unique Index CREATE UNIQUE NONCLUSTERED INDEX <namingconventionconstraint> ON dbo.<tablename> ( <columnname> ) ON [PRIMARY] There is no difference between Unique Index and Unique Constraint. Even though syntax are different the effect is the same. Unique Constraint creates Unique Index to maintain the constraint to prevent duplicate keys. Unique Index or Primary Key Index are physical structure that maintain uniqueness over some combination of columns across all... - [SQL SERVER - Enable xp_cmdshell using sp_configure](https://blog.sqlauthority.com/2007/04/26/sql-server-enable-xp_cmdshell-using-sp_configure/): The xp_cmdshell option is a server configuration option that enables system administrators to control whether the xp_cmdshell extended stored procedure can be executed on a system. - [SQL SERVER - 2005 - DBCC ROWLOCK - Deprecated](https://blog.sqlauthority.com/2007/04/26/sql-server-2005-dbcc-rowlock-deprecated/): Title says all. My search engine log says many web users are looking for DBCC ROWLOCK in SQL SERVER 2005. It is deprecated feature for SQL SERVER 2005. It is Automatically on for SQL SERVER 2005. More Deprecated Features of SQL SERVER 2005 Refer MSDN Discontinued Database Engine Functionality in SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Alternate Fix : ERROR 1222 : Lock request time out period exceeded](https://blog.sqlauthority.com/2007/04/25/sql-server-alternate-fix-error-1222-lock-request-time-out-period-exceeded/): ERROR 1222 : Lock request time out period exceeded. - [SQL SERVER - ERROR Messages - sysmessages error severity level](https://blog.sqlauthority.com/2007/04/25/sql-server-error-messages-sysmessages-error-severity-level/): SQL ERROR Messages Each error message displayed by SQL Server has an associated error message number that uniquely identifies the type of error. The error severity levels provide a quick reference for you about the nature of the error. The error state number is an integer value between 1 and 127; it represents information about the source that issued the error. The error message is a description of the error that occurred. The error messages are stored in the sysmessages system table. - [SQL SERVER - 2005 Take Off Line or Detach Database](https://blog.sqlauthority.com/2007/04/25/sql-server-2005-take-off-line-or-detach-database/): EXEC sp_dboption N'mydb', N'offline', N'true' OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK AFTER 30 SECONDS OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK IMMEDIATE Using the alter database statement (SQL Server 2k and beyond) is the preferred method. The rollback after statement will force currently executing statements to rollback after N seconds. The default is to wait for all currently running transactions to complete and for the sessions to be terminated. Use the rollback immediate clause to rollback transactions immediately. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - TRIM() Function - UDF TRIM()](https://blog.sqlauthority.com/2007/04/24/sql-server-trim-function-udf-trim/): SQL Server does not have function which can trim leading or trailing spaces of any string. TRIM() is very popular function in many languages. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. I was expecting SQL Server 2005 to have TRIM() function. Unfortunately, SQL Server 2005 does not have that either. I have created very simple UDF which does the same work. FOR SQL SERVER 2000: CREATE FUNCTION dbo.TRIM(@string VARCHAR(8000)) RETURNS VARCHAR(8000) BEGIN RETURN LTRIM(RTRIM(@string)) END GO FOR SQL SERVER 2005: CREATE FUNCTION dbo.TRIM(@string VARCHAR(MAX)) RETURNS VARCHAR(MAX) BEGIN RETURN LTRIM(RTRIM(@string)) END GO Both the above... - [SQL SERVER - Six Properties of Relational Tables](https://blog.sqlauthority.com/2007/04/24/sql-server-six-properties-of-relational-tables/): Relational tables have six properties: Values Are Atomic This property implies that columns in a relational table are not repeating group or arrays. The key benefit of the one value property is that it simplifies data manipulation logic. Such tables are referred to as being in the “first normal form” (1NF). Column Values Are of the Same Kind In relational terms this means that all values in a column come from the same domain. A domain is a set of values which a column may have. This property simplifies data access because developers and users can be certain of the type... - [SQL SERVER - 2005 Collation Explanation and Translation](https://blog.sqlauthority.com/2007/04/24/sql-server-2005-collation-explanation-and-translation/): Just a day before one of our SQL SERVER 2005 needed Case-Sensitive Binary Collation. When we install SQL SERVER 2005 it gives options to select one of the many collation. I says in words like ‘Dictionary order, case-insensitive, uppercase preference’. I was confused for little while as I am used to read collation like ‘SQL_Latin1_General_Pref_Cp1_CI_AS_KI_WI’. I did some research and find following link which explains many of the SQL SERVER 2005 collation. Complete documentation MSDN – SQL SERVER Collation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Query Analyzer - Microsoft SQL SERVER Management Studio](https://blog.sqlauthority.com/2007/04/23/sql-server-2005-query-analyzer-microsoft-sql-server-management-studio/): Following may be very simple to some and helpful to other type of question. I have seen this in my server log as well as this has been always first question in my Developer Team. Where is SQL SERVER 2005 Query Analyzer? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). To see the familiour Query Analyzer Window follow the image below. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Find Seed Values, Increment Values and Current Identity Column value of the table](https://blog.sqlauthority.com/2007/04/23/sql-server-query-to-find-seed-values-increment-values-and-current-identity-column-value-of-the-table/): Following script will return all the tables which has identity column. It will also return the Seed Values, Increment Values and Current Identity Column value of the table. SELECT IDENT_SEED(TABLE_NAME) AS Seed, IDENT_INCR(TABLE_NAME) AS Increment, IDENT_CURRENT(TABLE_NAME) AS Current_Identity, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1 AND TABLE_TYPE = 'BASE TABLE' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Understanding new Index Type of SQL Server 2005 Included Column Index along with Clustered Index and Non-clustered Index](https://blog.sqlauthority.com/2007/04/23/sql-server-understanding-new-index-type-of-sql-server-2005-included-column-index-along-with-clustered-index-and-non-clustered-index/): Clustered Index Only 1 allowed per table Physically rearranges the data in the table to conform to the index constraints. - [SQL SERVER - Raid Configuration - RAID 10](https://blog.sqlauthority.com/2007/04/22/sql-server-raid-configuration-raid-10/): I get question about what configuration of redundant array of inexpensive disks (RAID) I use for my SQL Servers. The answer is short is: RAID 10. Why? Excellent performance with Read and Write. RAID 10 has advantage of both RAID 0 and RAID 1. RAID 10 uses all the drives in the array to gain higher I/O rates so more drives in the array higher performance. RAID 5 has penalty for write performance because of the parity in check. There are many article already written about them. If you are interested in reading more please refer book online. Reference : Pinal... - [SQL SERVER - @@DATEFIRST and SET DATEFIRST Relations and Usage](https://blog.sqlauthority.com/2007/04/22/sql-server-datefirst-and-set-datefirst-relations-and-usage/): The master database’s syslanguages table has a DateFirst column that defines the first day of the week for a particular language. SQL Server with US English as default language, SQL Server sets DATEFIRST to 7 (Sunday) by default. We can reset any day as first day of the week using SET DATEFIRST 5 This will set Friday as first day of week. @@DATEFIRST returns the current value, for the session, of SET DATEFIRST. SET LANGUAGE italian GO SELECT @@DATEFIRST GO ----This will return result as 1(Monday) SET LANGUAGE us_english GO SELECT @@DATEFIRST GO ----This will return result as 7(Sunday) In this... - [SQL SERVER - Fix : Error 1418 - Microsoft SQL Server - The server network address can not be reached](https://blog.sqlauthority.com/2007/04/22/sql-server-fix-error-1418-microsoft-sql-server-the-server-network-address-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-reissue-the-command/): Error: 1418 – Microsoft SQL Server – The server network address can not be reached or does not exist. Check the network address name and reissue the command The server network endpoint did not respond because the specified server network address cannot be reached or does not exist. - [SQL Server Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/04/21/sql-server-interview-questions-and-answers-complete-list-download/): This is summary blog post for SQL Server Interview Questions and Answers. Click here to get free chapters (PDF) in the mailbox. - [SQL Server Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2007/04/20/sql-server-interview-questions-part-6/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2007/04/19/sql-server-interview-questions-part-5/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2007/04/18/sql-server-interview-questions-part-4/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/04/17/sql-server-interview-questions-part-3/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/04/16/sql-server-interview-questions-part-2/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions-and-answers-introduction/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL SERVER - 64 bit Architecture and White Paper](https://blog.sqlauthority.com/2007/04/14/sql-server-64-bit-architecture-and-white-paper/): In supportability, manageability, scalability, performance, interoperability, and business intelligence, SQL Server 2005 provides far richer 64-bit support than its predecessor. This paper describes these enhancements. Read the original paper here. Following abstract is taken from the same paper. Another interesting article on 64-bit Computing with SQL Server 2005 is here. The primary differences between the 64-bit and 32-bit versions of SQL Server 2005 are derived from the benefits of the underlying 64-bit architecture. Some of these are: The 64-bit architecture offers a larger directly-addressable memory space. SQL Server 2005 (64-bit) is not bound by the memory limits of 32-bit systems. Therefore,... - [SQL SERVER - CASE Statement/Expression Examples and Explanation](https://blog.sqlauthority.com/2007/04/14/sql-server-case-statementexpression-examples-and-explanation/): CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in functions. Two basic formulations for CASE expression 1) Simple CASE expressions A simple CASE expression checks one expression against multiple values. Within a SELECT statement, a simple CASE expression allows only an equality check; no other comparisons are made. A simple CASE expression operates by comparing the first expression to the expression in each WHEN clause for equivalency. If these expressions... - [SQL SERVER - Fix : Error: 18452 Login failed for user '(null)'. The user is not associated with a trusted SQL Server connection.](https://blog.sqlauthority.com/2007/04/14/sql-server-fix-error-18452-login-failed-for-user-null-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Some errors never got old. I have seen many new DBA or Developers struggling with this errors. Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection. Fix/Solution/Workaround: Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)” to “Mixed Mode (Windows Authentication and SQL Server Authentication)”. Run following script in SQL Analyzer to change the authentication LOGIN sa ENABLE GO ALTER LOGIN sa WITH PASSWORD = '<password>' GO OR In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties. On the General page, you may have to create... - [SQL SERVER - Stored Procedures Advantages and Best Advantage](https://blog.sqlauthority.com/2007/04/13/sql-server-stored-procedures-advantages-and-best-advantage/): There are many advantages of Stored Procedures. I was once asked what do I think is the most important feature of Stored Procedure? I have to pick only ONE. It is tough question. I answered : Execution Plan Retention and Reuse (SP are compiled and their execution plan is cached and used again to when the same SP is executed again) Not to mentioned I received the second question following my answer : Why? Because all the other advantage known (they are mentioned below) of SP can be achieved without using SP. Though Execution Plan Retention and Reuse can only be... - [SQLAuthority News - Microsoft SQL Server Compact 3.5 Server Tools Beta 2 Released](https://blog.sqlauthority.com/2007/08/03/sqlauthority-news-microsoft-sql-server-compact-35-server-tools-beta-2-released/): SQL Server Compact 3.5 Server Tools installs replication components on the IIS server enabling merge replication and remote data access (RDA) between SQL Server Compact 3.5 database on a Windows Desktop & Mobile devices and database servers running SQL Server 2005 and later versions of SQL Server 2005. Download SQL Server Compact 3.5 For more information please see the SQL Server Compact 3.5 Books Online Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Two Different Ways to Comment Code - Explanation and Example](https://blog.sqlauthority.com/2007/08/03/sql-server-two-different-ways-to-comment-code-explanation-and-example/): SQL Server has two different ways to comment code. Let us learn all of them here in this blog post. Various the options in the blog posts. - [SQLAuthority News - Book Review - SQL Server 2005 Practical Troubleshooting: The Database Engine](https://blog.sqlauthority.com/2007/08/02/sqlauthority-news-book-review-sql-server-2005-practical-troubleshooting-the-database-engine/): SQLAuthority.com Book Review : SQL Server 2005 Practical Troubleshooting: The Database Engine (SQL Server Series) (Paperback) by Ken Henderson Link to book on Amazon Short Review : Database Administrators can use this book on a daily basis in SQL Server 2005 troubleshooting and problem solving. Answers to SQL issues can be swiftly located using the index of this book.This book covers the topics and subjects which any other books, blogs or websites (including MSDN, BOL) do not cover. This book provides DBAs with solutions which can be used by user in highly dynamic environments to resolve common and specialized problems. This... - [SQL SERVER - FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details](https://blog.sqlauthority.com/2007/08/02/sql-server-fix-error-945-database-cannot-be-opened-due-to-inaccessible-files-or-insufficient-memory-or-disk-space-see-the-sql-server-error-log-for-details/): SQL SERVER – FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details This error is very common and many times, I have seen affect of this error as Suspected Database, Database Operation Ceased, Database Stopped transactions. Solution to this error is simple but very important. Fix/Solution/WorkAround: 1) If possible add more hard drive space either by removing of unnecessary files from hard drive or add new hard drive with larger size. 2) Check if the database is set to Autogrow on. 3) Check if... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Search SQL](https://blog.sqlauthority.com/2007/08/01/sql-server-sql-joke-sql-humor-sql-laugh-search-sql/): In meeting with DBA friends one of my friend suggested while searching for “MSSQL Client” Microsoft returns you suggestion as “MySQL Client“. I did not believe it so I tested it myself. He was correct. Here is the screen shot. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - July CTP Released](https://blog.sqlauthority.com/2007/08/01/sql-server-2008-july-ctp-released/): SQL Server 2008 July Community Technology Preview has been released. With SQL Server 2008 July CTP release, customers can immediately utilize new capabilities that support their mission-critical platform and enable pervasive insight across the enterprise. SQL Server 2008 lays the groundwork for innovative policy-based management that enables administrators to reduce their time spent on maintenance tasks. SQL Server 2008 provides enhancements in the SQL Server BI platform by enabling customers to provide up-to-date information with Change Data Capture and MERGE features, and develop highly scalable analysis services cubes with new development environments. - [SQLAuthority News - My Favorite Articles of This Blog](https://blog.sqlauthority.com/2007/07/31/sqlauthority-news-my-favorite-articles-of-this-blog/): The question I receive very often is I have more than 250 articles so far on this blog, which are my most favorite articles so far? Yesterday while talking with my parents on occasion of my birthday, they asked the same question to me. Answer is I keep running list of the my personal favorite articles on my personal website. I update it very frequently. Visit Author’s Personal Favorite Best Articles List Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Birthday of SQL Authority Author](https://blog.sqlauthority.com/2007/07/30/sqlauthority-news-birthday-of-sql-authority-author/): Today is Birthday of SQL Authority Author. Thought of the day : Family is everything. https://www.pinaldave.com/ http://www.SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Data Warehousing Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/07/29/sql-server-data-warehousing-interview-questions-and-answers-complete-list-download/): Click here to get free chapters (PDF) in the mailbox It was a great pleasure to write latest series about Data Warehousing Interview Questions and Answers. Just like always again, I received lots of suggestion and follow up questions. I have tried to accommodate all of them in the last post in the series. I hope this series is helpful to all candidates who are seeking a job as well interviewers. I have combined all the questions and answers in the one PDF which is available to download and refer at convenience. Complete Series of SQL Server Interview Questions and Answers... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/07/28/sql-server-data-warehousing-interview-questions-and-answers-part-3/): Click here to get free chapters (PDF) in the mailbox What are slowly changing dimensions (SCD)? SCD is abbreviation of Slowly changing dimensions. SCD applies to cases where the attribute for a record varies over time. There are three different types of SCD. 1) SCD1 : The new record replaces the original record. Only one record exist in database – current data. 2) SCD2 : A new record is added into the customer dimension table. Two records exist in database – current data and previous history data. 3) SCD3 : The original data is modified to include new data. One record... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/07/27/sql-server-data-warehousing-interview-questions-and-answers-part-2/): Click here to get free chapters (PDF) in the mailbox What are normalization forms? Please visit this article. Describes the foreign key columns in fact table and dimension table? Foreign keys of dimension tables are primary keys of entity tables. Foreign keys of facts tables are primary keys of Dimension tables. What is Data Mining? Data Mining is the process of analyzing data from different perspectives and summarizing it into useful information. What is the difference between view and materialized view? A view takes the output of a query and makes it appear like a virtual table and it can be... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/07/26/sql-server-data-warehousing-interview-questions-and-answers-part-1/): Let us learn about Data Warehousing Interview Questions and Answers. - [SQLAuthority News - Interesting Read - Programming Concepts, Structured Thinking Language (STL) and Relationary](https://blog.sqlauthority.com/2007/07/25/sqlauthority-news-interesting-read-programming-concepts-structured-thinking-language-stl-and-relationary/): I have always enjoyed reading articles and blogs which are different then others. There many be thousands of technology and programming blogs, only few makes difference in the tech world. One of the high quality blog, I enjoy reading is relationary by Grant Czerepak. Grant Czerepak is an IT professional with over 20 years experience in relational database technology specifically in the areas of design, development and administration. As per Grant Czerepak “In this blog I will be mixing, matching, shifting and sifting paradigms that have come up in my work with relational databases and other concepts I’ve picked up while... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/07/25/sql-server-data-warehousing-interview-questions-and-answers-introduction/): Click here to get free chapters (PDF) in the mailbox This series is in response to many of my reader’s continuous request to start Data Warehousing Interview Questions and Answers series. This series is written in the same spirit as previous two series which has received good response. Samples Question from Interview Questions and Answer Series What is Data Warehousing? A data warehouse is the main repository of an organization’s historical data, its corporate memory. It contains the raw material for management’s decision support system. The critical factor leading to the use of a data warehouse is that a data analyst... - [SQL SERVER - 2005 - Server and Database Level DDL Triggers Examples and Explanation](https://blog.sqlauthority.com/2007/07/24/sql-server-2005-server-and-database-level-ddl-triggers-examples-and-explanation/): Let's learn about Server and Database Level DDL Triggers Examples and Explanation here. Let us learn more about this topic. - [SQL SERVER - UDF - Function to Get Previous And Next Work Day - Exclude Saturday and Sunday](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-function-to-get-previous-and-next-work-day-exclude-saturday-and-sunday/): While reading ColdFusion blog of Ben Nadel Getting the Previous Day In ColdFusion, Excluding Saturday And Sunday, I realize that I use similar function on my SQL Server Database. This function excludes the Weekends (Saturday and Sunday), and it gets previous as well as next work day. - [SQL SERVER - UDF - Get the Day of the Week Function](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-get-the-day-of-the-week-function/): The day of the week can be retrieved in SQL Server by using the DatePart function. The value returned by function is between 1 (Sunday) and 7 (Saturday). To convert this to a string representing the day of the week, use a CASE statement. Method 1: Create function running following script: CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) SELECT @rtDayofWeek = CASE DATEPART(weekday,@dtDate) WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN 'Wednesday' WHEN 5 THEN 'Thursday' WHEN 6 THEN 'Friday' WHEN 7 THEN 'Saturday' END RETURN (@rtDayofWeek) END GO Call... - [SQLAuthority News - FQL - Facebook Query Language](https://blog.sqlauthority.com/2007/07/22/sqlauthority-news-fql-facebook-query-language/): I was exploring the new hype today, I found Facebook Developers Documentation very interesting. Facebook API can be queries using FQL - Facebook Query Language, which is similar to SQL. - [SQL SERVER - Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database 'yourdatabasename'. CREATE DATABASE is aborted.](https://blog.sqlauthority.com/2007/07/21/sql-server-fix-error-msg-1813-level-16-state-2-line-1-could-not-open-new-database-yourdatabasename-create-database-is-aborted/): Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database ‘yourdatabasename’. CREATE DATABASE is aborted. This errors happens when corrupt database log are attempted to attach to new server. Solution of this error is little long and it involves restart of the server. I recommend following all the steps below in order without skipping any of them. Fix/Solution/Workaround: SQL Server logs are corrupted and they need to be rebuilt to make the database operational. Follow all the steps in order. Replace the yourdatabasename name with real name of your database. 1. Create a new database... - [SQL SERVER - Fix : Error Msg 4214 - Error Msg 3013 - BACKUP LOG cannot be performed because there is no current database backup](https://blog.sqlauthority.com/2007/07/20/sql-server-fix-error-msg-4214-error-msg-3013-backup-log-cannot-be-performed-because-there-is-no-current-database-backup/): This is very interesting error as I could not found any documentation on-line. It took me nearly 1 hour to figure out what was creating error. - [SQL SERVER - 2005 - SSMS - View/Send Query Results to Text/Grid/Files](https://blog.sqlauthority.com/2007/07/19/sql-server-2005-ssms-viewsend-query-results-to-textgridfiles/): Many times I have been asked how to change the result window from Text to Grid and vice versa. There are three different ways to do it. Method 1 : Key-Board Short Cut Results to Text – CTRL + T Results to Grid – CTRL + D Results to File – CTRL + SHIFT + F Method 2 : Using Toolbar Method 3 : Using Menubar Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SPACE Function Example](https://blog.sqlauthority.com/2007/07/19/sql-server-space-function-example/): A month ago, I wrote about SQL SERVER – TRIM() Function – UDF TRIM() . I was asked in comment if SQL Server has space function? Yes. SELECT SPACE(100) will generate 100 space characters. The use of SPACE() function is demonstrated in BOL very fine. Example from BOL: USE AdventureWorks; GO SELECT RTRIM(LastName) + ',' + SPACE(2) + LTRIM(FirstName) FROM Person.Contact ORDER BY LastName, FirstName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Restore Database Without or With Backup - Everything About Restore and Backup](https://blog.sqlauthority.com/2007/07/18/sql-server-restore-database-without-or-with-backup-everything-about-restore-and-backup/): The questions I received in last two weeks: “I do not have backup, is it possible to restore database to previous state?” “How can restore the database without using backup file?” “I accidentally deleted tables in my database, how can I revert back?” “How to revert the changes, I have only logs but no complete backup?” “How to rollback the database changes, my backup file is corrupted?” Answer: You need complete backup to rollback your changes. If you do not have complete backup you can not revert back. Sorry. To restore the database to previous stage if you have full backup:... - [SQL SERVER - CASE Statement in ORDER BY Clause - ORDER BY using Variable](https://blog.sqlauthority.com/2007/07/17/sql-server-case-statement-in-order-by-clause-order-by-using-variable/): This article is as per request from Application Development Team Leader of my company. His team encountered code where application was preparing string for ORDER BY clause of SELECT statement. Application was passing this string as variable to Stored Procedure (SP) and SP was using EXEC to execute the SQL string. This is not good for performance as Stored Procedure has to recompile every time due to EXEC. sp_executesql can do the same task but still not the best performance. Previously: Application: Nesting logic to prepare variable OrderBy. Database: Stored Procedure takes variable OrderBy as input parameter. SP uses EXEC (or... - [SQL SERVER - Microsoft White Papers - Analysis Services Query Best Practices - Partial Database Availability](https://blog.sqlauthority.com/2007/07/16/sql-server-microsoft-white-papers-analysis-services-query-best-practices-partial-database-availability/): Microsoft TechNet frequently releases White Papers on SQL Server Technology. I have read the following two white papers recently. The summary of its content is here. Analysis Services Query Performance Top 10 Best Practices Optimize cube and measure group design Define effective aggregations Use partitions Write efficient MDX Use the query engine cache efficiently Ensure flexible aggregations are available to answer queries. Tune memory usage Tune processor usage Scale up where possible Scale out when you can no longer scale up Partial Database Availability Writer: Danny Tambs Download Word Document As databases become larger and larger, the infrastructure assets and technology... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - 15 Signs to Identify Bad DBA](https://blog.sqlauthority.com/2007/07/15/sql-server-sql-joke-sql-humor-sql-laugh-15-signs-to-identify-bad-dba/): 15 Signs to Identify Bad DBA They think it is bug in SQL Server when two NULL values compared with each other but SQL Server does not say they equal to each other. They do not rename the trigger name thinking it will not work after it is rename. They are looking for difference between Index Scan or Table Scan on Google. They reinstall the SQL Server if they forget the password of SA login. They use model database for testing their script. They believe compiled stored procedure is production ready. They prefix all stored procedures with ‘sp_’ to be consistent... - [SQL SERVER - 2005 Collation Explanation and Translation - Part 2](https://blog.sqlauthority.com/2007/07/14/sql-server-2005-collation-explanation-and-translation-part-2/): Following function return all the available collation of SQL Server 2005. My previous article about the SQL SERVER – 2005 Collation Explanation and Translation. SELECT * FROM sys.fn_HelpCollations() Result Set: (only few of 1011 records) Name Description Latin1_General_BIN Latin1-General, binary sort Latin1_General_BIN2 Latin1-General, binary code point comparison sort Latin1_General_CI_AI Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AI_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AI_KS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AI_KS_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-sensitive Latin1_General_CI_AS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AS_KS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AS_KS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-sensitive Latin1_General_CS_AI Latin1-General, case-sensitive, accent-insensitive, kanatype-insensitive,... - [SQL SERVER - 2005 - Use ALTER DATABASE MODIFY NAME Instead of sp_renameDB to rename](https://blog.sqlauthority.com/2007/07/13/sql-server-2005-use-alter-database-modify-name-instead-of-sp_renamedb-to-rename/): To rename database it is very common to use for SQL Server 2000 user : EXEC sp_renameDB 'oldDB','newDB' sp_renameDB syntax will be deprecated in the future version of SQL Server. It is supported in SQL Server 2005 for backwards compatibility only. It is recommended to use ALTER DATABASE MODIFY NAME instead. New syntax of ALTER DATABASE MODIFY NAME is simple as well. /* Create Test Database */ CREATE DATABASE Test GO /* Rename the Database Test to NewTest */ ALTER DATABASE Test MODIFY NAME = NewTest GO /* Cleanup NewTest Database Do not run following command if you want to use the database. It is dropped here for sample database clean up. */ DROP DATABASE NewTest GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Validate Field For DATE datatype using function ISDATE()](https://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/): This article is based on the a question from Jr. Developer at my company. He works with the system, where we import CSV file in our database. One of the fields in the database is DATETIME field. Due to architecture requirement, we insert all the CSV fields in the temp table which has all the fields VARCHAR. We validate all the data first in temp table (check for inconsistency, malicious code, incorrect data type) and if passed validation we insert them in the final table in the database. Let us learn about ISDate function in this blog post. - [SQLAuthority News - SQL Blog SQLAuthority.com Comment by Mr. Ben Forta](https://blog.sqlauthority.com/2007/07/11/sqlauthority-news-sql-blog-sqlauthoritycom-comment-by-mr-ben-forta/): Today is one of the most glorious day for SQLAuthority.com in history. Famous author of Sams Teach Yourself Microsoft SQL Server T-SQL In 10 Minutes, ColdFusion Guru, and well known evangelists Mr. Ben Forta has made comment on his blog about SQLAuthority.com. I encourage all my readers to visit comment link here. I am very thankful to Mr. Forta for finding time to visit my blog from his busy schedule. I am attaching screen shot of the original post along with this post for reference. Mr. Forta said, “Pinalkumar Dave is a DBA with extensive SQL Server (and ColdFusion) experience. I... - [SQL SERVER - 2005 - Features Comparison Chart](https://blog.sqlauthority.com/2007/07/11/sql-server-2005-features-comparison-chart/): This post in the response to all the readers who have asked what are the differences between SQL Server 2005 editions. The reason I have never posted article about this as Microsoft has wonderful comparison chart on Microsoft SQL Server web site. This chart explains the difference between features of Express, Workgroup, Standard, and Enterprise editions. Visit Microsoft SQL Server 2005 Editions Features Comparison Chart Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Scheduled Launch at an Event in Los Angeles on Feb. 27, 2008](https://blog.sqlauthority.com/2007/07/11/sql-server-2008-scheduled-launch-at-an-event-in-los-angeles-on-feb-27-2008/): SQL SERVER 2008 will be launched at an Event in Los Angeles on Feb. 27, 2008. “In anticipation for the most significant Microsoft enterprise event in the next year, Turner announced that Windows Server® 2008, Visual Studio® 2008 and Microsoft SQL Server™ 2008 will launch together at an event in Los Angeles on Feb. 27, 2008, kicking off hundreds of launch events around the world.” Read original article here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Count Duplicate Records - Rows](https://blog.sqlauthority.com/2007/07/11/sql-server-count-duplicate-records-rows/): In my previous article SQL SERVER – Delete Duplicate Records – Rows, we have seen how we can delete all the duplicate records in one simple query. In this article we will see how to find count of all the duplicate records in the table. Following query demonstrates usage of GROUP BY, HAVING, ORDER BY in one query and returns the results with duplicate column and its count in descending order. SELECT YourColumn, COUNT(*) TotalCount FROM YourTable GROUP BY YourColumn HAVING COUNT(*) > 1 ORDER BY COUNT(*) DESC Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com)... - [SQL SERVER - 2005 - List All Stored Procedure Modified in Last N Days](https://blog.sqlauthority.com/2007/07/10/sql-server-2005-list-all-stored-procedure-modified-in-last-n-days/): I usually run following script to check if any stored procedure was deployed on live server without proper authorization in last 7 days. If SQL Server suddenly start behaving in un-expectable behavior and if stored procedure were changed recently, following script can be used to check recently modified stored procedure. If stored procedure was created but never modified afterwards modified date and create date for that stored procedure are same. SELECT name FROM sys.objects WHERE type = 'P' AND DATEDIFF(D,modify_date, GETDATE()) < 7 ----Change 7 to any other day value Following script will provide name of all the stored procedure which... - [SQL SERVER - Result of EXP (Exponential) to the POWER of PI - Functions Explained](https://blog.sqlauthority.com/2007/07/09/sql-server-result-of-exp-exponential-to-the-power-of-pi-functions-explained/): SQL Server can do some intense Mathematical calculations. Following are three very basic and very necessary functions. All the three function does not need explanation. I will not introduce their definition but will demonstrate the usage of function. SELECT PI() GO SELECT POWER(2,5) GO SELECT POWER(8,-2) GO SELECT EXP(99) GO SELECT EXP(1) GO Results Set : PI ———————- 3.14159265358979 PowerEg1 ———– 32 PowerEg2 ———– 0 ExpEg1 ———————- 9.88903031934695E+42 ExpEg2 ———————- 2.71828182845905 Now the Questions asked in the Title of the Article – What is the result of EXP to the POWER of PI SELECT POWER(EXP(1), PI()) GO Results ———————- 23.1406926327793 Reference... - [SQL SERVER - FIX : ERROR Msg 244, Level 16, State 1 - FIX : ERROR Msg 245, Level 16, State 1](https://blog.sqlauthority.com/2007/07/08/sql-server-fix-error-msg-244-level-16-state-1-fix-error-msg-245-level-16-state-1/): FIX : ERROR Msg 244, Level 16, State 1, Line 1 FIX : ERROR Msg 245, Level 16, State 1, Line 1 This error can happen due to conversion of one data type to incompatible datatype. Few examples are: VARCHAR to INT, INT to TINYINT etc. I have spotted this error happening with CAST or ISNULL, please add comments if you have come across this error in other examples. Following scripts will create this error. SELECT CAST('111111' AS SMALLINT); SELECT CAST('This is not smallint' AS SMALLINT); The errors received from above two scripts are : Msg 244, Level 16, State 2,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Generic Quotes](https://blog.sqlauthority.com/2007/07/08/sql-server-sql-joke-sql-humor-sql-laugh-generic-quotes/): Few days ago, in meeting I was forced to answer one of the question from non-programmer was considered as funny quotes for long time. “Yes it is latest year 2005 version of SQL Server – still it will not play your flash movie” — Pinal Dave (SQLAuthority.com) Many of following quotes are well apply to SQL Server or any database and I find them humorous. Software is Too Important to be Left to Programmers — Meilir Page-Jones. A clever person solves a problem. A wise person avoids it. — Einstein If you think good architecture is expensive, try bad architecture. —... - [SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT](https://blog.sqlauthority.com/2007/07/07/sql-server-convert-text-to-numbers-integer-cast-and-convert/): Few of the questions I receive very frequently. I have collect them in spreadsheet and try to answer them frequently. How to convert text to integer in SQL? If table column is VARCHAR and has all the numeric values in it, it can be retrieved as Integer using CAST or CONVERT function. How to use CAST or CONVERT? SELECT CAST(YourVarcharCol AS INT) FROM Table SELECT CONVERT(INT, YourVarcharCol) FROM Table Will CAST or CONVERT thrown an error when column values converted from alpha-numeric characters to numeric? YES. Will CAST or CONVERT retrieve only numbers when column values converted from alpha-numeric characters to... - [SQL SERVER - FIX : Error : msg 8115, Level 16, State 2, Line 2 - Arithmetic overflow error converting expression to data type](https://blog.sqlauthority.com/2007/07/06/sql-server-fix-error-msg-8115-level-16-state-2-line-2-arithmetic-overflow-error-converting-expression-to-data-type/): Following errors can happen when any field in the database is attempted to insert or update larger data of the same type or other data type. Msg 8115, LEVEL 16, State 2, Line 2 Arithmetic overflow error converting expression TO data type <ANY DataType> Example is if integer 111111 is attempted to insert in TINYINT data type it will throw above error, as well as if integer 11111 is attempted to insert in VARCHAR(2) data type it will throw above error. Fix/Solution/Workaround: 1) Verify the inserted/updated value that it is of correct length and data type. 2) If inserted/updated value are... - [SQL SERVER - 2005 - Microsoft Document Explorer cannot be shown because the specified help collection 'ms-help://MS.SQLCC.v9](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-microsoft-document-explorer-cannot-be-shown-because-the-specified-help-collection-ms-helpmssqlccv9/): I have received six emails in last four days asking for the resolution of error when tried to open newly installed SQL Server Book On-Line. Microsoft Document Explorer cannot be shown because the specified help collection ‘ms-help://MS.SQLCC.v9 1) Uninstall the versions of Book On-line (different languages, different releases etc) using Add-Remove programs tools. 2) Re-install SQL Server Book On-line. Above solution is confirmed by MSDN site here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Best Practices Analyzer Tutorial - Sample Example](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-best-practices-analyzer-tutorial-sample-example/): Yesterday I posted small note about SQL SERVER – 2005 Best Practices Analyzer (July BPA). I received many request about how BPA is used. Some of readers has asked me to provide sample tutorial which can help start using BPA. This utility has many uses for best practice. I have created very simple and initial tutorial. I encourage to follow that and once used it create your own reports in your desired format. Do not hesitate to install this add-on as I have use this previously to tune our production servers. Following tutorial about BPA is ran on one of my... - [SQL SERVER - 2005 Best Practices Analyzer (July BPA)](https://blog.sqlauthority.com/2007/07/04/sql-server-2005-best-practices-analyzer-july-bpa/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD HERE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Definition, Comparison and Difference between HAVING and WHERE Clause](https://blog.sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/): In recent interview sessions in hiring process I asked this question to every prospect who said they know basic SQL. Surprisingly, none answered me correct. They knew lots of things in details but not this simple one. One prospect said he does not know cause it is not on this Blog. Well, here we are with same topic online. Answer in one line is : HAVING specifies a search condition for a group or an aggregate function used in SELECT statement. HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP... - [SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable](https://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/): #TempTable and @TempVariable are different things with different scope. Their purpose is different but highly overlapping. TempTables are originated for the storage and & storage & manipulation of temporal data. TempVariables are originated (SQL Server 2000 and onwards only) for returning date-sets from table-valued functions. Common properties of #TempTable and @TempVariable They are instantiated in tempdb. They are backed by physical disk. Changes to them are logged in the transaction log1. However, since tempdb always uses the simple recovery model, those transaction log records only last until the next tempdb checkpoint, at which time the tempdb log is truncated. Discussion of... - [SQL SERVER - 2005 Comparison SP_EXECUTESQL vs EXECUTE/EXEC](https://blog.sqlauthority.com/2007/07/02/sql-server-2005-comparison-sp_executesql-vs-executeexec/): Common Properties of SP_EXECUTESQL and EXECUTE/EXEC The Transact-SQL statements in the sp_executesql or EXECUTE string are not compiled into an execution plan until sp_executesql or the EXECUTE statement are executed. The strings are not parsed or checked for errors until they are executed. The names referenced in the strings are not resolved until they are executed. The Transact-SQL statements in the executed string do not have access to any of the variables declared in the batch that contains thesp_executesql or EXECUTE statement. The batch containing the sp_executesql or EXECUTE statement does not have access to variables or local cursors defined in... - [SQL SERVER - Explanation of WITH ENCRYPTION clause for Stored Procedure and User Defined Functions](https://blog.sqlauthority.com/2007/07/01/sql-server-explanation-of-with-encryption-clause-for-stored-procedure-and-user-defined-functions/): This article is written to answer following two questions I have received in last one week. Questions 1) How to hide code of my Stored Procedure that no one can see it? 2) Our DBA has left the job and one of the function which retrieves important information is encrypted, how can we decrypt it and find original code? Answers 1) Use WITH ENCRYPTION while creating Stored Procedure or User Defined Function. 2) Sorry, unfortunately there is no simple way to decrypt the code. Hard way is too hard to even attempt. Explanations of WITH ENCRYPTION clause If SP or UDF... - [SQL SERVER - Fix : Error : Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type 'varchar' exceeds the maximum allowed for any data type (8000)](https://blog.sqlauthority.com/2007/06/30/sql-server-fix-error-server-msg-131-level-15-state-3-line-1-the-size-given-to-the-type-varchar-exceeds-the-maximum-allowed-for-any-data-type-8000/): Error: Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type ‘varchar’ exceeds the maximum allowed for any data type (8000) When the the length is specified in declaring a VARCHAR variable or column, the maximum length allowed is still 8000. Fix/WorkAround/Solution: Use either VARCHAR(8000) or VARCHAR(MAX) . VARCHAR(MAX) of SQL Server 2005 is replacement of TEXT of SQL Server 2000. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recompile All The Stored Procedure on Specific Table](https://blog.sqlauthority.com/2007/06/29/sql-server-recompile-all-the-stored-procedure-on-specific-table/): I have noticed that after inserting many rows in one table many times the stored procedure on that table executes slower or degrades. This happens quite often after BCP or DTS. I prefer to recompile all the stored procedure on the table, which has faced mass insert or update. sp_recompiles marks stored procedures to recompile when they execute next time. Example: ----Following script will recompile all the stored procedure on table Sales.Customer in AdventureWorks database. USE AdventureWorks; GO EXEC sp_recompile N'Sales.Customer'; GO ----Following script will recompile specific stored procedure uspGetBillOfMaterials only. USE AdventureWorks; GO EXEC sp_recompile 'uspGetBillOfMaterials'; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - 2005 Improvements in TempDB](https://blog.sqlauthority.com/2007/06/28/sql-server-2005-improvements-in-tempdb/): Following are some important improvements in tempdb in SQL Server 2005 over SQL Server 2000 Input/Output traffic to TempDB is reduced as logging is improved. In SQL Server 2005 TempDB does not log “after value” everytime. E.g. For INSERT it does not log after value on log as that will be any way logged in the TempTable. Similar for DELETE as It does not have to log After value as it is not there. This is big improvement in performance in SQL Server 2005 for TempDB. Some other improvement in File System of operating system. (I am not listing them as... - [SQL SERVER - Running Batch File Using T-SQL - xp_cmdshell bat file](https://blog.sqlauthority.com/2007/06/27/sql-server-running-batch-file-using-t-sql/): In last month I received few emails emails regarding SQL SERVER – Enable xp_cmdshell using sp_configure. The questions are 1) What is the usage of xp_cmdshell and 2) How to execute BAT file using T-SQL? I really like the follow up questions of my posts/articles. Answer is xp_cmdshell can execute shell/system command, which includes batch file. 1) Example of running system command using xp_cmdshell is SQL SERVER – Script to find SQL Server on Network EXEC master..xp_CMDShell 'ISQL -L' 2) Example of running batch file using T-SQL i) Running standalone batch file (without passed parameters) EXEC master..xp_CMDShell 'c:findword.bat' ii) Running parameterized batch... - [SQL SERVER - 2005 List All Tables of Database](https://blog.sqlauthority.com/2007/06/26/sql-server-2005-list-all-tables-of-database/): This is very simple and can be achieved using system table sys.tables. USE YourDBName GO SELECT * FROM sys.Tables GO This will return all the tables in the database which user have created. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Explanation and Example Four Part Name](https://blog.sqlauthority.com/2007/06/26/sql-server-explanation-and-example-four-part-name/): What is four part name? Explanation : ServerName.DatabaseName.DatabaseOwner.TableName Example : localhost.AdventureWorks.Person.Contact Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Repeate String N Times Using String Function REPLICATE](https://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/): I came across this SQL String Function few days ago while searching for Database Replication. This is T-SQL Function and it repeats the string/character expression N number of times specified in the function. SELECT REPLICATE( ' https://blog.sqlauthority.com/ ' , 9 ) This repeats the string https://blog.sqlauthority.com/ to 9 times in result window. I think it is fun utility to generate repeated text if ever required. Result Set: https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com/) , BOL - [SQLAuthority News - Book Review - Microsoft(R) SQL Server 2005 Unleashed (Paperback)](https://blog.sqlauthority.com/2007/06/24/sqlauthority-news-book-review-microsoftr-sql-server-2005-unleashed-paperback/): SQLAuthority.com Book Review : Microsoft(R) SQL Server 2005 Unleashed (Paperback) by Ray Rankins, Paul Bertucci, Chris Gallelli, Alex T. Silverstein Link to book on Amazon Short Review : SQL Server 2005 Unleashed is focused on Database Administration and day-to-day administrative management aspects of SQL Server. All the chapters of this book are heavily based on Book On-line (BOL) and it continue discussing the topics, where BOL leaves off. This makes this book a good reference for those who are looking for additional information, tricks & tips, and behind the scene details. I recommend this book as a wonderful read and hands-on... - [SQL SERVER - Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild - SQL SERVER 2000 and SQL SERVER 2005](https://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/): Index Fragmentation: When a page of data fills to 100 percent and more data must be added to it, a page split occurs. To make room for the new data, SQL Server must move half of the data from the full page to a new page. The new page that is created is created after all the pages in database. Therefore, instead of going right from one page to the next when looking for data, SQL Server has to go one page to another page around the database looking for the next page it needs. This is Index Fragmentation. Severity of... - [SQL SERVER - 2005 Row Overflow Data Explanation](https://blog.sqlauthority.com/2007/06/23/sql-server-2005-row-overflow-data-explanation/): In SQL Server 2000 and SQL Server 2005 a table can have a maximum of 8060 bytes per row. One of my fellow DBA said that he believed that SQL Server 2000 had that restriction but SQL Server 2005 does not have that restriction and it can have a row of 2GB. I totally agreed with him but after we discussed this problem in depth, we realized that there are more into it than only 8060 bytes limit. It is still true for SQL Server 2005 that a table can have maximum of 8060 bytes per row however the restriction has... - [SQL SERVER - Explanation and Comparison of NULLIF and ISNULL](https://blog.sqlauthority.com/2007/06/22/sql-server-explanation-and-comparison-of-nullif-and-isnull/): Explanation of NULLIF Syntax: NULLIF ( expression , expression ) Returns a null value if the two specified expressions are equal. NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression. NULLIF is equivalent to a searched CASE function in which the two expressions are equal and the resulting expression is NULL. - [SQLAuthority.com News - iGoogle Gadget Published](https://blog.sqlauthority.com/2007/06/21/sqlauthoritycom-news-igoogle-gadget-published/): I have recently received many requests to add an iGoogle Gadget so it can be integrated on iGoogle home page so I’ve gone ahead and done so: Add iGoogle Gadget Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Retrieve Current DateTime in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}](https://blog.sqlauthority.com/2007/06/21/sql-server-retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/): There are three ways to retrieve the current datetime in SQL SERVER. CURRENT_TIMESTAMP, GETDATE(), {fn NOW()} - [SQL SERVER - Find Length of Text Field](https://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/): To measure the length of VARCHAR fields the function LEN(varcharfield) is useful. To measure the length of TEXT fields the function is DATALENGTH(textfield). Len will not work for text field. Example: SELECT DATALENGTH(yourtextfield) AS TEXTFieldSize Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com News - Journey to SQL Authority Milestone of SQL Server](https://blog.sqlauthority.com/2007/06/19/sqlauthoritycom-news-journey-to-sql-authority-milestone-of-sql-server/): SQLAuthority.com News – Journey to SQL Authority Milestone of SQL Server I am very glad to write this 200th post of this blog. I would like to express my gratitude to all of YOU – my readers for continuously reading this blog. I receive many comments and emails with feedback, questions and suggestion everyday. I enjoy meeting few of you during this journey as well. Please do send me feedback and your request to make this blog better. Following is milestone of Journey to SQL Authority. SQL Server Interview Questions and Answers Complete List Download (PDF) SQL Server Database Coding Standards... - [SQL SERVER - Delay Function - WAITFOR clause - Delay Execution of Commands](https://blog.sqlauthority.com/2007/06/18/sql-server-delay-function-waitfor-clause-delay-execution-of-commands/): Blocks the execution of a batch, stored procedure, or transaction until a specified time or time interval is reached, or a specified statement modifies or returns at least one row. This is very useful. Every day when I restore the database to backup server for reports post processing, I use WAITFOR clause. While executing the WAITFOR statement, the transaction is running and no other requests can run under the same transaction. If the server is busy, the thread may not be immediately scheduled; therefore, the time delay may be longer than the specified time. WAITFOR can be used with query but... - [SQL SERVER - De-fragmentation of Database at Operating System to Improve Performance](https://blog.sqlauthority.com/2007/06/17/sql-server-de-fragmentation-of-database-at-operating-system-to-improve-performance/): This issues was brought to me by our Sr. Network Engineer. While running operating system level de-fragmentation using either windows de-fragmentation or third party tool it always skip all the MDF file and never de-fragment them. He was wondering why this happens all the time. The reason MDF file are skipped all the time in de-fragmentation because they are in use when SQL Server is running. Windows operating system de-fragmentation skips all the file in are currently in use. After discovering this the real question was how to de-fragment when files are in use. Steps are Stop the Server, Re-start, keep... - [SQL SERVER - 2005 - UDF - User Defined Function to Strip HTML - Parse HTML - No Regular Expression](https://blog.sqlauthority.com/2007/06/16/sql-server-udf-user-defined-function-to-strip-html-parse-html-no-regular-expression/): One of the developers at my company asked is it possible to parse HTML and retrieve only TEXT from it without using regular expression. He wanted to remove everything between < and > and keep only Text. I found the question very interesting and quickly wrote UDF which does not use regular expression. Let us see how to parse HTML without regular expression. - [SQL SERVER - sp_HelpText for sp_HelpText - Puzzle](https://blog.sqlauthority.com/2007/06/15/sql-server-sp_helptext-for-sp_helptext-puzzle/): It was interesting to me. I was using sp_HelpText to see the text of the stored procedure. Stored Procedure were different so I had copied sp_HelpText on my clipboard and was pasting it in Query Editor of Management Studio. In rush I typed twice sp_HelpText and hit F5. Result was interesting. What are your guesses? My team mates and few of my readers suggested : SQL Server will be in recursive loop, SQL Server will be not responde, SQL Server will throw an error. Try this: sp_HelpText sp_HelpText Result was as expected. SQL Server did its job and displayed the text... - [SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases - Part 2](https://blog.sqlauthority.com/2007/06/15/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases-part-2/): I have mentioned the history of NorthWind, Pubs and AdventureWorks in my previous post SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases. I have been receiving very frequent request for NorthWind Database for SQL Server 2005 and installation method. - [SQL SERVER - Easy Sequence of SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY](https://blog.sqlauthority.com/2007/06/14/sql-server-easy-sequence-of-select-from-join-where-group-by-having-order-by/): I was called many times by Jr. Programmers in team to debug their SQL. I keep log of most of the problems and review them afterwards. This helps me to evaluate my team and identify most important next thing which I can do to improve the performance and productivity of it. Recently we have many new hires and they had almost similar questions. Since, I have send them following sequence of the SELECT clause I am not interrupted often, which helps me to focus on larger project architectural design. SELECT yourcolumns FROM tablenames JOIN tablenames WHERE condition GROUP BY yourcolumns HAVING... - [SQL SERVER - Explanation SQL SERVER Hash Join](https://blog.sqlauthority.com/2007/06/14/sql-server-explanation-sql-server-hash-join/): Hash Join works with large data set. I have seen this join used many times in data warehouses applications as well as data mining algorithms. While its characteristics are similar to merge join it does not required ordered result set to join. Hash join requiresequijoin predicate to join tables. Equijoin predicate is comparing values between one table to other table using “equals to” (“=”) operator. Hash join gives best performance when two more join tables are joined and at-least one of them have no index or is not sorted. It is also expected that smaller of the either of table can... - [SQL SERVER - Fix : Error 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time.](https://blog.sqlauthority.com/2007/06/13/sql-server-fix-error-8629-the-query-processor-could-not-produce-a-query-plan-from-the-optimizer-because-a-query-cannot-update-a-text-ntext-or-image-column-and-a-clustering-key-at-the-same-time/): Error : 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time. - [SQL SERVER - Download 2005 Books Online (May 2007)](https://blog.sqlauthority.com/2007/06/13/sql-server-download-2005-books-online-may-2007/): Microsoft has merged SQL Server 2005 Expressed to SQL Server 2005 Books Online. New Version of SQL Server 2005 Books Online is released on June 12, 2007. Download SQL Server Books Online (BOL) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recovery Models and Selection](https://blog.sqlauthority.com/2007/06/13/sql-server-recovery-models-and-selection/): SQL Server offers three recovery models: full recovery, simple recovery and bulk-logged recovery. The recovery models determine how much data loss is acceptable and determines whether and how transaction logs can be backed up. Select Simple Recovery Model if: * Your data is not critical. * Losing all transactions since the last full or differential backup is not an issue. * Data is derived from other data sources and is easily recreated. * Data is static and does not change often. Select Bulk-Logged Recovery Model if: * Data is critical, but logging large data loads bogs down the system. * Most... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2007/06/12/sql-server-sql-joke-sql-humor-sql-laugh-funny-quotes/): While searching WIKI I came across this oracle WIKI. I found this very funny. I have taken few quotes from this site. There are lot more stuff there. The degree of normality in a database is inversely proportional to that of its DBA. Program complexity grows until it exceeds the capability of the programmer who must maintain it. “Walking on water and developing software from a specification are easy if both are frozen.” — Edward V. Berard, “Life-Cycle Approaches” “Technology is dominated by two types of people: those who understand what they do not manage, and those who manage what they... - [SQL SERVER - LEN and DATALENGTH of NULL Simple Example](https://blog.sqlauthority.com/2007/06/12/sql-server-len-and-datalength-of-null-simple-example/): Simple but interesting – In recent survey I found that many developers making this generic mistake. I have seen following code in periodic code review. (The code below is not actual code, it is simple sample code) DECLARE @MyVar VARCHAR(10) SET @MyVar = NULL IF (LEN(@MyVar) = 0) … I decided to send following code to them. After running the following sample code it was clear that LEN of NULL values is not 0 (Zero) but it is NULL. Similarly, the result for DATALENGTH function is the same. DATALENGTH of NULL is NULL. Sample Test Version: DECLARE @MyVar VARCHAR(10) SET @MyVar... - [SQL SERVER - Cannot Resolve Collation Conflict For Equal to Operation](https://blog.sqlauthority.com/2007/06/11/sql-server-cannot-resolve-collation-conflict-for-equal-to-operation/): Cannot resolve collation conflict for equal to operation. In MS SQL SERVER, the collation can be set at the column level. - [SQL SERVER - 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) - CTE vs. Derived Table](https://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/): I have received few emails and comments about my post SQL SERVER – T-SQL Paging Query Technique Comparison – SQL 2000 vs SQL 2005. The main question was is this can be done using CTE? Absolutely! What about Performance? It is same! Please refer above mentioned article for history of paging. - [SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice](https://blog.sqlauthority.com/2007/06/10/sql-server-retrieve-select-only-date-part-from-datetime-best-practice/): Just a week ago, my Database Team member asked me what is the best way to only select date part from datetime. When ran following command it also provide the time along with the date. - [SQL SERVER - Fix : Error : An error has occurred while establishing a connect to the server. Solution with Images.](https://blog.sqlauthority.com/2007/06/10/sql-server-fix-error-an-error-has-occurred-while-establishing-a-connect-to-the-server-solution-with-images/): While reviewing my my blog search engine terms I find Error 40 is the most common error searched. I have previously wrote blog about how to fix this error here : SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server. Today I have added few screen shot of that error and their solution to help readers who need additional help to understand my post. Error Screen: Solution Part 1: Enable SQL Server Service Solution Part 2: Enable TCP/IP Protocol Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 9514 Xml data type is not supported in distributed queries. Remote object 'OPENROWSET' has xml column(s)](https://blog.sqlauthority.com/2007/06/09/sql-server-fix-error-msg-9514-level-16-state-1-line-1-xml-data-type-is-not-supported-in-distributed-queries-remote-object-openrowset-has-xml-columns/): In this blog post we are going to learn how to fix XML Data Type related error. - [SQL SERVER - Spatial Database Definition and Research Documents](https://blog.sqlauthority.com/2007/06/09/sql-server-spatial-database-definition-and-research-documents/): Recently I was asked in meeting of SQL SERVER user group, what my opinion about spatial database. I answered from my basic knowledge. Spatial database is like database of space (not the star wars or star trek kind space). SQL Server database can understand the numeric and string values. If we ask to SQL Server what is multiplication of 6 and 3 it will provide answer as 18. If we ask to SQL Server what is distance between two points in polygon, it will be not able to answer using native functions. Custom SQL code written by user can do similar... - [SQL SERVER - UDF - Function to Display Current Week Date and Day - Weekly Calendar](https://blog.sqlauthority.com/2007/06/08/sql-server-udf-function-to-display-current-week-date-and-day-weekly-calendar/): In analytics section of our product I frequently have to display the current week dates with days. Week starts from Sunday. We display the data considering days as column and date and other values in column. If today is Friday June 8, 2007. We need script which can provides days and dates for current week. Following script will generate the required script. DECLARE @day INT DECLARE @today SMALLDATETIME SET @today = CAST(CONVERT(VARCHAR(10), GETDATE(), 101) AS SMALLDATETIME) SET @day = DATEPART(dw, @today) SELECT DATEADD(dd, 1 - @day, @today) Sunday, DATEADD(dd, 2 - @day, @today) Monday, DATEADD(dd, 3 - @day, @today) Tuesday, DATEADD(dd,... - [SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL](https://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/): Update: For SQL Server 2008 there is even better method of Row Construction, please read it here : SQL SERVER – 2008 – Insert Multiple Records Using One Insert Statement – Use of Row Constructor This is very interesting question I have received from new developer. How can I insert multiple values in table using only one insert? Now this is interesting question. When there are multiple records are to be inserted in the table following is the common way using T-SQL. - [SQL SERVER - 2005 Download New Updated Book On Line (BOL)](https://blog.sqlauthority.com/2007/06/07/sql-server-2005-download-new-updated-book-on-line-bol/): Book On Line the primary source for help for many developers has been updated. It now includes the updates till SP2 release. I use book on line for accuracy for my definition and information on this blog. Download Book On Line (Update June 4th, 2007) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 (Katmai) June CTP Released - Improvement Pillars - Diagram](https://blog.sqlauthority.com/2007/06/07/sql-server-2008-katmai-june-ctp-released-improvement-pillars-diagram/): I received quite a few emails in last three days for not mentioning on my blog about SQL Server 2008 (Katmai) CPT June is released. The reason I did not mentioned because I was busy with my mini series SQL SERVER – Database Coding Standards and Guidelines Complete List Download. SQL Server 2008 (Katmai) June CTP (Community Technology Preview) is announced in TechNet 2007 and is available to download. SQL Server 2008 June CTP enables customers to immediately utilize new capabilities that support their mission-critical platform. The chart below explains important improvements coming online with each CTP. Please visit SQL Server... - [SQL SERVER - Fix : Error : Error 15401: Windows NT user or group 'username' not found. Check the name again.](https://blog.sqlauthority.com/2007/06/07/sql-server-fix-error-error-15401-windows-nt-user-or-group-username-not-found-check-the-name-again/): Fix : Error : Error 15401: Windows NT user or group ‘username’ not found. Check the name again. This is quite a famous error and I was asked to write about it by couple of readers. The reason I was not writing about this as the solution of this error is very well explained in Book On Line. All the potential causes and their solutions are explained well here. This post/article should be considered as book mark to solution. Fix/WorkAround/Solution: Refere Microsoft Help and Support : How to troubleshoot error 15401 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Database Coding Standards and Guidelines Complete List Download](https://blog.sqlauthority.com/2007/06/06/sql-server-database-coding-standards-and-guidelines-complete-list-download/): Download SQL SERVER Database Coding Standards and Guidelines Complete List - [SQL SERVER - Database Coding Standards and Guidelines - Part 2](https://blog.sqlauthority.com/2007/06/05/sql-server-database-coding-standards-and-guidelines-part-2/): SQL Server Database Coding Standards and Guidelines - Part 2 - [SQL SERVER - Database Coding Standards and Guidelines - Part 1](https://blog.sqlauthority.com/2007/06/04/sql-server-database-coding-standards-and-guidelines-part-1/): SQL Server Database Coding Standards and Guidelines - Part 1 - [SQL SERVER - Database Coding Standards and Guidelines - Introduction](https://blog.sqlauthority.com/2007/06/03/sql-server-database-coding-standards-and-guidelines-introduction/): I have received many many request to do another series since my series SQL Server Interview Questions and Answers Complete List Download. I have created small series of Coding Standards and Guidelines, as this is the second most request I have received from readers. This document can be extremely long but I have limited to very few pages as it is difficult to follow thousands of the rules. My experience says it is more productive developer and better code if coding standard has important fewer rules than lots of micro rules. - [SQL SERVER - 2005 Explanation and Example - SELF JOIN](https://blog.sqlauthority.com/2007/06/03/sql-server-2005-explanation-and-example-self-join/): A self-join is simply a normal SQL join that joins one table to itself. This is accomplished by using table name aliases to give each instance of the table a separate name. Joining a table to itself can be useful when you want to compare values in a column to other values in the same column. A join in which records from a table are combined with other records from the same table when there are matching values in the joined fields. A self-join can be an inner join or an outer join. A table is joined to itself based upon... - [SQL SERVER - 2005 - Microsoft SQL Server Management Pack for Microsoft Operations Manager 2005 - Download SQL Server MOM 2005](https://blog.sqlauthority.com/2007/06/02/sql-server-2005-microsoft-sql-server-management-pack-for-microsoft-operations-manager-2005-download-sql-server-mom-2005/): The Microsoft SQL Server Management Pack provides both proactive and reactive monitoring of SQL Server 2005 and SQL Server 2000 in an enterprise environment. Availability and configuration monitoring, performance data collection, and default thresholds are built for enterprise-level monitoring. Both local and remote connectivity checks help ensure database availability. Features description are available online. Download SQL Server MOM 2005 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Subscribe to Feed in Email](https://blog.sqlauthority.com/2007/06/02/sqlauthority-news-subscribe-to-feed-in-email/): You can subscribe to SQLAuthority.com Feed using Email. Email will be delivered to your preferred email address when new post appears on SQLAuthority.com Subscribe to SQLAuthority Feed Through Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Dedicated Search Engine for SQLAuthority - Search SQL Solutions](https://blog.sqlauthority.com/2007/06/01/sqlauthority-news-dedicated-search-engine-for-sqlauthority-search-sql-solutions/): Visit search.SQLAuthority.com I have been receiving many questions asking for tutorials, suggestions or questions about topics I already have wrote before but readers are have not found it or having difficulty to find them. I have almost around 200 articles on this blog so far and it is growing. One of the team member in my company keep on asking about search engine specific to SQLAuthority.com. He suggest that he always search in this blog first before he search on web. One of the loyal reader suggests that I should have search facilities in my SQL Interview Questions. I have created... - [SQL SERVER - 2005 Constraint on VARCHAR(MAX) Field To Limit It Certain Length](https://blog.sqlauthority.com/2007/06/01/sql-server-2005-constraint-on-varcharmax-field-to-limit-it-certain-length/): One of the Jr. DBA at in my Team Member asked me question the other day when he was replacing TEXT field with VARCHAR(MAX) : How can I limit the VARCHAR(MAX) field with maximum length of 12500 characters only. His Question was valid as our application was allowing 12500 characters. Traditionally thinking we only create the field as long as we need. SQL Server 2005 does support VARCHAR(MAX) but does not support VARCHAR(12500). If we try to create database field with VARCHAR(12500) it gives following error. Server: Msg 131, Level 15, State 3, Line 1 The size (12500) given to the... - [SQL SERVER - Retrieve Information of SQL Server Agent Jobs](https://blog.sqlauthority.com/2007/05/31/sql-server-retrieve-information-of-sql-server-agent-jobs/): sp_help_job returns information about jobs that are used by SQL Server Agent service to perform automated activities in SQL Server. When executed sp_help_job procedure with no parameters to return the information for all of the jobs currently defined in the msdb database. - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility - Part 2 - Management Studio](https://blog.sqlauthority.com/2007/05/31/sql-server-2005-change-database-compatible-level-backward-compatibility-part-2-management-studio/): I have received quite a few request about post I have two days ago SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility, if this can be done using SQL Server Management Studio. It is very simple to do this using Management Studio as well but I still prefer T-SQL way. Following steps will display the method to change the compatible levels. Write click on database. Click on Properties. Click on Options. Change the Compatibility level to desired compatibility. (See Attached image below) Click OK. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Must Not Contain NULL - Primary Key are NOT NULL](https://blog.sqlauthority.com/2007/05/31/sql-server-primary-key-must-not-contain-null-primary-key-are-not-null/): While reviewing the search engine log for this blog I found lots of search regarding Nullable Primary Key. It is not possible. This post is especially to clear the Not Nullable Primary Key Property. The Allow Nulls property can’t be set on a column that is part of the primary key. All columns that are part of a table’s a primary key must contain aggregate unique values other than NULL. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQLAuthority.com News - Best SQL Job Search - Best SQL Job List - Find SQL Jobs](https://blog.sqlauthority.com/2007/05/30/sqlauthoritycom-news-best-sql-job-search-best-sql-job-list-find-sql-jobs/): SQLAuthority.com News – Best SQL Job Search – Best SQL Job List – Find SQL Jobs Visit : I have been receiving two kind of requests almost every day. 1) Recruiters and Employers asking where can they find good candidates who are truly dedicated to SQL Server? 2) Job seeker asking where can they find only SQL related jobs? There are hundreds of web site which have great resources for all kind of jobs. Monster and Dice are examples of them. Many sites are bit ocean of the jobs and it is hard to find only SQL Jobs from there, many... - [SQL SERVER - Trace Flags - DBCC TRACEON](https://blog.sqlauthority.com/2007/05/30/sql-server-trace-flags-dbcc-traceon/): Trace flags are valuable tools as they allow DBA to enable or disable a database function temporarily. Once a trace flag is turned on, it remains on until either manually turned off or SQL Server restarted. Only users in the sysadmin fixed server role can turn on trace flags. If you want to enable/disable Detailed Deadlock Information (1205), use Query Analyzer and DBCC TRACEON to turn it on. 1205 trace flag sends detailed information about the deadlock to the error log. Enable Trace at current connection level: DBCC TRACEON(1205) Disable Trace: DBCC TRACEOFF(1205) Enable Multiple Trace at same time separating each... - [SQL SERVER - Fix : Error : Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table](https://blog.sqlauthority.com/2007/05/30/sql-server-fix-error-server-msg-544-level-16-state-1-line-1-cannot-insert-explicit-value-for-identity-column-in-table/): Error Message: Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF. This error message appears when you try to insert a value into a column for which the IDENTITY property was declared, but without having set the IDENTITY_INSERT setting for the table to ON. Fix/WorkAround/Solution: /* Turn Identity Insert ON so records can be inserted in the Identity Column  */ SET IDENTITY_INSERT [dbo].[TableName] ON GO INSERT INTO [dbo].[TableName] ( [ID], [Name] ) VALUES ( 2, 'InsertName') GO /* Turn Identity Insert OFF  */ SET IDENTITY_INSERT [dbo].[TableName] OFF GO Setting the IDENTITY_INSERT to ON allows explicit values to be inserted into the identity column of a table. Execute permissions... - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility](https://blog.sqlauthority.com/2007/05/29/sql-server-2005-change-database-compatible-level-backward-compatibility/): sp_dbcmptlevel Sets certain database behaviors to be compatible with the specified version of SQL Server. Example: ----SQL Server 2005 database compatible level to SQL Server 2000 EXEC sp_dbcmptlevel AdventureWorks, 80; GO ----SQL Server 2000 database compatible level to SQL Server 2005 EXEC sp_dbcmptlevel AdventureWorks, 90; GO Version of SQL Server database can be one of the following: 60 = SQL Server 6.0 65 = SQL Server 6.5 70 = SQL Server 7.0 80 = SQL Server 2000 90 = SQL Server 2005 The sp_dbcmptlevel stored procedure affects behaviors only for the specified database, not for the entire server. sp_dbcmptlevel provides only... - [SQL SERVER - 2008 - Server Consolidation WhitePaper Download](https://blog.sqlauthority.com/2007/10/28/sql-server-2008-server-consolidation-whitepaper-download/): Server Consolidation with SQL Server 2008 Writer: Martin Ellis Reviewer: Prem Mehra,Lindsey Allen, Tiffany Wissner, Sambit Samal Published: March 2009 Microsoft SQL Server 2008 supports multiple options for server consolidation, which provides organizations with the flexibility to choose the consolidation approach that best meets their requirements to centralize data services management and reduce hardware and maintenance costs. By providing centralized management, auditing, and monitoring capabilities, SQL Server 2008 makes it easy to manage multiple databases and data services, which significantly reduces administrative overheads in large enterprises. Finally, SQL Server 2008 provides the reassurance of industry-leading performance and scalability, and unprecedented control... - [SQL SERVER - 2005 - Get Current User - Get Logged In User](https://blog.sqlauthority.com/2007/10/27/sql-server-2005-get-current-user-get-logged-in-user/): Interesting enough Jr. DBA asked me how he can get current user for any particular query is ran. He said he wants it for debugging purpose as well for security purpose. I totally understand the need of this request. Knowing the current user can be extremely helpful in terms of security. To get current user run following script in Query Editor SELECT SYSTEM_USER SYSTEM_USER will return current user. From Book On-Line – SYSTEM_USER returns the name of the currently executing context. If the EXECUTE AS statement has been used to switch context, SYSTEM_USER returns the name of the impersonated context. Reference... - [SQL SERVER - Deterministic Functions and Nondeterministic Functions](https://blog.sqlauthority.com/2007/10/26/sql-server-deterministic-functions-and-nondeterministic-functions/): Deterministic functions always returns the same output result all the time it is executed for same input values. i.e. ABS, DATEDIFF, ISNULL etc. Nondeterministic functions may return different results each time they are executed. i.e. NEWID, RAND, @@CPU_BUSY etc. Functions that call extended stored procedures are nondeterministic. User-defined functions that create side effects on the database are not recommended. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Forced Parameterization and Simple Parameterization - T-SQL and SSMS](https://blog.sqlauthority.com/2007/10/25/sql-server-2005-forced-parameterization-and-simple-parameterization-t-sql-and-ssms/): SQL Server compiles query and saves the procedures cache plans in the database. When the same query is called it uses compiled execution plan which improves the performance by saving compilation time. Queries which are parametrized requires less recompilation and dynamically built queries needs compilations and recompilation very frequently. Forced parameterization may improve the performance of certain databases by reducing the frequency of query compilations and recompilations. Database which has high volumes of the queries can be most benefited from this feature. When the PARAMETERIZATION option is set to FORCED, any literal value that appears in a SELECT, INSERT, UPDATE or... - [SQL SERVER - Simple Example of WHILE Loop With CONTINUE and BREAK Keywords](https://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/): I have tried to explain the usage of simple WHILE loop in the first example. BREAK keywords will exit the stop the while loop and control is moved. - [SQL SERVER - Get Permissions of My Username / Userlogin on Server / Database](https://blog.sqlauthority.com/2007/10/23/sql-server-get-permissions-of-my-username-userlogin-on-server-database/): A few days ago, I was invited to one of the largest database company. I was asked to review database schema and propose changes to it. There was special username or user logic was created for me, so I can review their database. I was very much interested to know what kind of permissions I was assigned per server level and database level. I did not feel like asking their Sr. DBA the question about permissions. - [SQL SERVER - Difference Between @@Version and xp_msver - Retrieve SQL Server Information](https://blog.sqlauthority.com/2007/10/22/sql-server-difference-between-version-and-xp_msver-retrieve-sql-server-information/): Just a day ago, I was asked which SQL Server version I am using. I said SQL Server 2005. However, the person I was talking was looking for more information then that. He requested more detail about the version. I responded with SQL Server 2005 Service Pack 2. After the discussion was over I thought there must be some global variable which brings back this information. I took guess and typed following command in SQL Query Editor SELECT @@Version 'SQL Version' I was really glad when it worked and returned following result. Resultset: Microsoft SQL Server 2005 – 9.00.3054.00 (Intel X86)... - [SQL SERVER - 2005 - Limitation of Online Index Rebuld Operation](https://blog.sqlauthority.com/2007/10/21/sql-server-2005-limitation-of-online-index-rebuld-operation/): Just a day ago, during one interview question of Online Indexing come up. I really enjoy discussing this issue as I was talking with candidate who was very smart. Following two questions were discussed. 1) What is Online Index Rebuild Operation? Online operation means when online operations are happening the database are in normal operational condition, the processes which are participating in online operations does not require exclusive access to database. Read about this in-depth in my previous article SQL SERVER – 2005 – Explanation and Script for Online Index Operations – Create, Rebuild, Drop 2) What are the limitation of... - [SQL SERVER - Set Server Level FILLFACTOR Using T-SQL Script](https://blog.sqlauthority.com/2007/10/20/sql-server-set-server-level-fillfactor-using-t-sql-script/): As the title is very clear what this post is about I will not write long description. I have listed definition of FILLFACTOR from BOL here. - [SQL SERVER - Types of DBCC Commands When Used as Database Console Commands](https://blog.sqlauthority.com/2007/10/19/sql-server-types-of-dbcc-commands-when-used-as-database-console-commands/): Just a day ago, while discussing some SQL issues with one of the Sr. Database Administrator in India, we end up discussing DBCC as Database Console Commands when used as T-SQL. We both tried to remember what are the types of DBCC as Database Console Commands and could not come up with more than two types, however we both knew there are four. When the conversation was over, I looked up MSDN for the types of the DBCC. I found following documentation here. There are four types of the Database Console Commands. Maintenance Maintenance tasks on a database, index, or filegroup.... - [SQL SERVER - 2005 - Fix : Error : Msg 7411, Level 16, State 1 Server is not configured for RPC](https://blog.sqlauthority.com/2007/10/18/sql-server-2005-fix-error-msg-7411-level-16-state-1-server-is-not-configured-for-rpc/): Error : Msg 7411, Level 16, State 1 Server is not configured for RPC This was annoying error which was fixed by Jr. DBA, whom I am personally training at my organization. I think he is going to be great programmer. He worked in my organization for more than 8 months. I finally have decided to coach him myself. When I encountered this error, I gave him task to figure this out himself. I absolutely gave him no direction and very few min to fix this problem. As you might have guessed without using internet help (as there is no help... - [SQLAuthority News - Book Review - Backup & Recovery (Paperback)](https://blog.sqlauthority.com/2007/10/17/sqlauthority-news-book-review-backup-recovery-paperback/): Backup & Recovery [ILLUSTRATED] (Paperback) by W. Curtis Preston (Author) Link to Amazon Short Summary: This book’s does not only teaches you have to create safe backup but it takes you to the next level where a large organization can save tons of dollars a year by making their backup and restore faster and more reliable process. Detail Summary: Backup and Recovery is the most interesting subject to me. I have always enjoyed reading and writing about this subject. I personally believe that without proper backup and ability to restore the backup to recover the system to original state, any organization... - [SQL SERVER - Three T-SQL Script to Create Primary Keys on Table](https://blog.sqlauthority.com/2007/10/16/sql-server-three-t-sql-script-to-create-primary-keys-on-table/): I have always enjoyed writing about three topics Constraint and Keys, Backup and Restore and Datetime Functions. Primary Keys constraints prevents duplicate values for columns and provides unique identifier to each column, as well it creates clustered index on the columns. -- Primary Key Constraint upon Table Created Method 1 USE AdventureWorks GO CREATE TABLE ConstraintTable (ID INT CONSTRAINT Ct_ID PRIMARY KEY, ColSecond INT) GO --Clean Up DROP TABLE ConstraintTable GO -- Primary Key Constraint upon Table Created Method 2 USE AdventureWorks GO CREATE TABLE ConstraintTable (ID INT, ColSecond INT, CONSTRAINT Ct_ID PRIMARY KEY (ID)) GO --Clean Up DROP TABLE ConstraintTable... - [SQL SERVER - 2005 - Driver for PHP Community Technology Preview (October 2007)](https://blog.sqlauthority.com/2007/10/16/sql-server-2005-driver-for-php-community-technology-preview-october-2007/): In its continued commitment to interoperability, Microsoft has released a new SQL Server 2005 Driver for PHP. The SQL Server 2005 Driver for PHP Community Technology Preview (CTP) download is available to all SQL Server users at no additional charge. The SQL Server 2005 Driver for PHP is a PHP 5 extension that allows for the reading and writing of SQL Server data from within PHP scripts. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2000. How to install driver 1. Download sqlsrv-for-php_version_language.exe to a temporary directory. 2. Run sqlsrv-for-php_version_language.exe.... - [SQL SERVER - Explanation and Understanding NOT NULL Constraint](https://blog.sqlauthority.com/2007/10/15/sql-server-explanation-and-understanding-not-null-constraint/): NOT NULL is integrity CONSTRAINT. It does not allow creating of the row where column contains NULL value. Most discussed question about NULL is what is NULL? I will not go in depth analysis it. Simply put NULL is unknown or missing data. When NULL is present in database columns, it can affect the integrity of the database. I really do not prefer NULL in database unless they are absolutely necessary. (Please make sure it is just my preference, and I use NULL it is absolutely needed). To prevent nulls to be inserted in the database, table should have NOT NULL... - [SQL SERVER - Three Rules to Use UNION](https://blog.sqlauthority.com/2007/10/14/sql-server-three-rules-to-use-union/): I have previously written two articles on UNION and they are quite popular. I was reading SQL book Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes By Ben Forta and I came across three rules of UNION and I felt like mentioning them here. UNION RULES A UNION must be composed of two or more SELECT statements, each separated by the keyword UNION. Each query in a UNION must contain the same columns, expressions, or aggregate functions, and they must be listed in the same order. Column datatypes must be compatible: They need not be the same exact same... - [SQL SERVER - 2005 - SQL Server Surface Area Configuration Tool Examples and Explanation](https://blog.sqlauthority.com/2007/10/13/sql-server-2005-sql-server-surface-area-configuration-tool-examples-and-explanation/): Microsoft has turned off all the potential features of SQL Server 2005 that could be susceptible to security risks and hacker attacks. Many features of SQL Server 2005 i.e. xp_cmdshell, DAC etc comes disabled by default, this makes the vulnerable surface area less visible to potential attacks. The Surface Area Configuration tool provides DBAs with a single, easy-to-use method of configuring external security of SQL Server. Use SQL Server Surface Area Configuration to enable, disable, start, or stop the features, services, and remote connectivity of your SQL Server 2005 installations. You can use SQL Server Surface Area Configuration on local and... - [SQL SERVER - Pre-Code Review Tips - Tips For Enforcing Coding Standards](https://blog.sqlauthority.com/2007/10/12/sql-server-pre-code-review-tips-tips-for-enforcing-coding-standards/): Each organization has its own coding standards and enforcement rules. It is sometime difficult for DBAs to change the code following code review, as it may affect many different layers of the application. In large organizations, many stored procedures are written and modified every day. It is smart to keep watch on all stored procedures, at frequent intervals, before code comes to final code review. Pre-code reviewing in this manner will save lots of time. I run a few scripts every day to check the status of all the stored procedures on our development server. Doing so gives me a good... - [SQL SERVER - T-SQL Script to Add Clustered Primary Key](https://blog.sqlauthority.com/2007/10/11/sql-server-t-sql-script-to-add-clustered-primary-key/): Jr. DBA asked me three times in a day, how to create Clustered Primary Key. I gave him following sample example. That was the last time he asked “How to create Clustered Primary Key to table?” USE [AdventureWorks] GO ALTER TABLE [Sales].[Individual] ADD CONSTRAINT [PK_Individual_CustomerID] PRIMARY KEY CLUSTERED ( [CustomerID] ASC ) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF vs. Stored Procedures and Having vs. WHERE](https://blog.sqlauthority.com/2007/10/10/sql-server-udf-vs-stored-procedures-and-having-vs-where/): Read my First Article in SQL Server Magazine – Oct 2007 [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Sample Example of RANKING Functions - ROW_NUMBER, RANK, DENSE_RANK, NTILE](https://blog.sqlauthority.com/2007/10/09/sql-server-2005-sample-example-of-ranking-functions-row_number-rank-dense_rank-ntile/): I have not written about this subject for long time, as I strongly believe that Book On Line explains this concept very well. SQL Server 2005 has total of 4 ranking function. Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. ROW_NUMBER () OVER ([<partition_by_clause>] <order_by_clause>) Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. RANK () OVER ([<partition_by_clause>] <order_by_clause>) Returns the rank of each row within the partition of a result set. DENSE_RANK () OVER ([<partition_by_clause>]... - [SQL SERVER - 2005 - Connection Property of SQL Server Management Studio SSMS](https://blog.sqlauthority.com/2007/10/08/sql-server-2005-connection-property-of-sql-server-management-studio-ssms/): Following images quickly explain how to connect to SQL Server with different connection property. It can be useful when connection properties need to be changed for SQL Server when connected. I use this in my company when I connect to one of our servers using named pipes instead of TCP/IP. Let us learn about Connection Property of SQL Server Management Studio SSMS. - [SQLAuthority News - Latest Interesting Downloads and Articles](https://blog.sqlauthority.com/2007/10/07/sqlauthority-news-latest-interesting-downloads-and-articles/): White Paper: Precision Considerations for Analysis Services Users This white paper covers accuracy and precision considerations in SQL Server 2005 Analysis Services. For example, it is possible to query Analysis Services with similar queries and obtain two different answers. While this appears to be a bug, it actually is due to the fact that Analysis Services caches query results and the imprecision that is associated with approximate data types. This white paper discusses how these issues manifest themselves, why they occur, and best practices to minimize their effect. Microsoft SQL Server 2005 JDBC Driver 1.1 In its continued commitment to interoperability,... - [SQL SERVER - Executing Remote Stored Procedure - Calling Stored Procedure on Linked Server](https://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure-calling-stored-procedure-on-linked-server/): I was going through comments on various posts to see if I have missed to answer any comments. I realized that there are quite a few times I have answered question which discuss about how to call stored procedure or query on linked server or another server. This is very detailed topic, I will keep it very simple. I am making assumptions that remote server is already set up as linked server with proper permissions in application and network is arranged. Method 1 : Remote Stored Procedure can be called as four part name: Syntax: EXEC [RemoteServer] .DatabaseName.DatabaseOwner.StoredProcedureName ‘Params’ Example: EXEC... - [SQL SERVER - 2005 - Open SSMS From Command Prompt - sqlwb.exe Example](https://blog.sqlauthority.com/2007/10/05/sql-server-2005-open-ssms-from-command-prompt-sqlwbexe-example/): This article is written by request and suggestion of Sr. Web Developer at my organization. Due to nature of this article most of the content are referred from Book On-Line. sqlwb command prompt utility which opens SQL Server Management Studio. sqlwb command does not run queries from command prompt. sqlcmd utility runs queries from command prompt, read for more information. The syntax of this sqlwb is very simple. I will copy complete syntax from BOL here : sqlwb [scriptfile] [projectfile] [solutionfile] [-S servername] [-d databasename] [-U username] [-P password] [-E] [-nosplash] [-?] I use following script very frequently. 1) Open SQL... - [SQL SERVER - 2005 - Different Types of Cache Objects](https://blog.sqlauthority.com/2007/10/04/sql-server-2005-different-types-of-cache-objects/): About two months ago I reviewed book SQL Server 2005 Practical Troubleshooting: The Database Engine. Yesterday I received a request from reader, if I can write something from this book, which is not common knowledge in DBA community. I really like the idea, however I must respect the Authors copyright about this book. This book is unorthodox SQL book, it talks about things which can get you to fix your problem faster, if problem is discussed in book. There are few places it teaches behind the scene SQL stories. - [SQL SERVER - 2005 - Explanation of TRY…CATCH and ERROR Handling With RAISEERROR Function](https://blog.sqlauthority.com/2007/10/03/sql-server-2005-explanation-of-trycatch-and-error-handling-with-raiseerror-function/): One of the developer at my company thought that we can not use RAISEERROR function in new feature of SQL Server 2005 TRY…CATCH. When asked for explanation he suggested SQL SERVER – 2005 Explanation of TRY…CATCH and ERROR Handling article as excuse suggesting that I did not give example of RAISEERROR with TRY…CATCH. We all thought it was funny. Just to keep record straight, TRY…CATCH can sure use RAISEERROR function. First read original article for additional information about how TRY…CATCH works with ERROR codes. SQL SERVER – 2005 Explanation of TRY…CATCH and ERROR Handling Example 1 : Simple TRY…CATCH without RAISEERROR... - [SQL SERVER - Find Name of The SQL Server Instance](https://blog.sqlauthority.com/2007/10/02/sql-server-find-name-of-the-sql-server-instance/): Few days ago, there was complex condition when we had one database on two different server. We were migrating database from one server to another server using nightly backup and restore. Based on database server stored procedures has to run different logic. We came up with two different solutions. 1) When database schema is very much changed, we wrote completely new stored procedure and deprecated older version once it was not needed. 2) When logic depended on Server Name we used global variable @@SERVERNAME. It was very convenient while writing migrating script which depended on server name for the same database.... - [SQL SERVER - 2005 - OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE](https://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/): SQL Server 2005 has new OUTPUT clause, which is quite useful. OUTPUT clause has accesses to inserted and deleted tables (virtual tables) just like triggers. OUTPUT clause can be used to return values to client clause. OUTPUT clause can be used with INSERT, UPDATE, or DELETE to identify the actual rows affected by these statements. OUTPUT clause can generate table variable, a permanent table, or temporary table. Even though, @@Identity will still work in SQL Server 2005, however I find OUTPUT clause very easy and powerful to use. Let us understand OUTPUT clause using example. ———————————————————————————————————————— —-Example 1 : OUTPUT clause... - [SQL SERVER - 2005 Query Editor - Microsoft SQL Server Management Studio](https://blog.sqlauthority.com/2007/09/30/sql-server-2005-query-editor-microsoft-sql-server-management-studio/): This post may be very simple for most of the users of SQL Server 2005. Earlier this year, I have received one question many times – Where is Query Analyzer in SQL Server 2005? I wrote small post about it and pointed many users to that post – SQL SERVER – 2005 Query Analyzer – Microsoft SQL SERVER Management Studio. Recently I have been receiving similar question. Where is Query Editor in SQL Server 2005? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). I have been pointing my users to my... - [SQL SERVER - Two Connections Related Global Variables Explained - @@CONNECTIONS and @@MAX_CONNECTIONS](https://blog.sqlauthority.com/2007/09/29/sql-server-two-connections-related-global-variables-explained-connections-and-max_connections/): Few days ago, I was searching MSDN and I stumbled upon following two global variables. Following variables are very briefly explained in the BOL. I have taken their definition from BOL and modified BOL example to displayed both the global variable together. @@CONNECTIONS Returns the number of attempted connections, either successful or unsuccessful since SQL Server was last started. @@MAX_CONNECTIONS Returns the maximum number of simultaneous user connections allowed on an instance of SQL Server. The number returned is not necessarily the number currently configured. @@MAX_CONNECTIONS is the maximum number of connections allowed simultaneously to the server. @@CONNECTIONS is incremented with... - [SQL SERVER - Introduction and Example for DATEFORMAT Command](https://blog.sqlauthority.com/2007/09/28/sql-server-introduction-and-example-for-dateformat-command/): While doing surprise code review of Jr. DBA I found interesting syntax DATEFORMAT. This keywords is very less used as CONVERT and CAST can do much more than this command. It is still interesting to learn about learn about this new syntax. Sets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data. This command allows you to input strings that would normally not be recognized by SQL server as dates. The SET DATEFORMAT command lets you specify order of data parts. The options for DATEFORMAT are mdy, dmy, ymd, ydm, myd, or dym. The default DATEFORMAT is mdy.... - [SQL SERVER - FIX : Error 3154: The backup set holds a backup of a database other than the existing database](https://blog.sqlauthority.com/2007/09/27/sql-server-fix-error-3154-the-backup-set-holds-a-backup-of-a-database-other-than-the-existing-database/): Our Jr. DBA ran to me with this error just a few days ago while restoring the database. Error 3154: The backup set holds a backup of a database other than the existing database. Solution is very simple and not as difficult as he was thinking. He was trying to restore the database on another existing active database. Fix/WorkAround/Solution: 1) Use WITH REPLACE while using the RESTORE command. View Example 2) Delete the older database which is conflicting and restore again using RESTORE command. I understand my solution is little different than BOL but I use it to fix my database... - [SQLAuthority News - Book Review - Programming SQL Server 2005 [ILLUSTRATED]](https://blog.sqlauthority.com/2007/09/26/sqlauthority-news-book-review-programming-sql-server-2005-illustrated/): Programming SQL Server 2005 [ILLUSTRATED] (Paperback) by Bill Hamilton (Author) Link to Amazon User does not have to be experience SQL Server 2005 programmer to use this book; as it is designed for users of all levels. This book also suggests that user does not have to be experienced with SQL Server 2000. However, I disagree with that. This book only covers new features of SQL Server 2005. Understanding of fundamental relational database concepts is helpful to digest and accept the concepts introduced in this book. This book covers following perspective of SQL Server 2005 new features. Tools and utilities Data... - [SQL SERVER - Effect of TRANSACTION on Local Variable - After ROLLBACK and After COMMIT](https://blog.sqlauthority.com/2007/09/25/sql-server-effect-of-transaction-on-local-variable-after-rollback-and-after-commit/): Few days ago, one of the Jr. Developer asked me this question (What will be the Effect of TRANSACTION on Local Variable – After ROLLBACK and After COMMIT?) while I was rushing to an important meeting. I was getting late so I asked him to talk with his Application Tech Lead. When I came back from meeting both of them were looking for me. They said they are confused. I quickly wrote down following example for them. Example: PRINT 'After ROLLBACK example' DECLARE @FlagINT INT SET @FlagInt = 1 PRINT @FlagInt ---- @FlagInt Value will be 1 BEGIN TRANSACTION SET @FlagInt... - [SQL SERVER - Order of Result Set of SELECT Statement on Clustered Indexed Table When ORDER BY is Not Used](https://blog.sqlauthority.com/2007/09/24/sql-server-order-of-result-set-of-select-statement-on-clustered-indexed-table-when-order-by-is-not-used/): "What will be the order of the result set of a SELECT statement on clustered indexed table when the ORDER BY clause is not used?" - [SQL SERVER - Stored Procedure to Know Database Access Permission to Current User](https://blog.sqlauthority.com/2007/09/23/sql-server-stored-procedure-to-know-database-access-permission-to-current-user/): Jr. DBA in my company only have access to the database which they need to use. Often they try to access database and if they do not have permission they face error. Jr. DBAs always check which database they have access using following system stored procedure. It is very reliable and provides accurate information. Sytanx: EXEC sp_MShasdbaccess GO ResultSet: ( I have listed only one column) AdventureWorks AdventureWorksDW master model msdb MyDB ReportServer ReportServerTempDB tempdb Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Version Information and Additional Information - Extended Stored Procedure xp_msver](https://blog.sqlauthority.com/2007/09/22/sql-server-2005-version-information-and-additional-information-extended-stored-procedure-xp_msver/): I was glad when I discovered this Extended Stored Procedure myself. I always used different syntax to retrieve server information. Many of information I was looking up using system information of the windows operating system. Syntax: EXEC xp_msver ResultSet: Index Name Internal_Value Character_Value —— ——————————– ————– ————————————- 1 ProductName NULL Microsoft SQL Server 2 ProductVersion 589824 9.00.3042.00 3 Language 1033 English (United States) 4 Platform NULL NT INTEL X86 5 Comments NULL NT INTEL X86 6 CompanyName NULL Microsoft Corporation 7 FileDescription NULL SQL Server Windows NT 8 FileVersion NULL 2005.090.3042.00 9 InternalName NULL SQLSERVR 10 LegalCopyright NULL © Microsoft Corp.... - [SQL SERVER - 2005 - Multiple Language Support](https://blog.sqlauthority.com/2007/09/21/sql-server-2005-multiple-language-support/): SQL Server supports multiple languages. Information about all the languages are stored in sys.syslanguages system view. You can run following script in Query Editor and see all the information about each language. Information about Months and Days varies for each language. Syntax: SELECT Alias, * FROM sys.syslanguages ResultSet: (* results not included) Alias ————– English German French Japanese Danish Spanish Italian Dutch Norwegian Portuguese Finnish Swedish Czech Hungarian Polish Romanian Croatian Slovak Slovenian Greek Bulgarian Russian Turkish British English Estonian Latvian Lithuanian Brazilian Traditional Chinese Korean Simplified Chinese Arabic Thai Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : ERROR : 3260 An internal buffer has become full](https://blog.sqlauthority.com/2007/09/20/sql-server-fix-error-3260-an-internal-buffer-has-become-full/): ERROR : 3260 An internal buffer has become full The reason I have picked to write about this error is because we have encountered this error many times in one of our older server. Fix/WorkAround/Solution: We were not able to absolutely reduce this error but following changes helped. 1) Rebooted server if error is happening frequently. 2) Increased RAM to Server. 3) Increased RAM allocation to SQL Server application. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Rename Database to New Name Using Stored Procedure by Changing to Single User Mode](https://blog.sqlauthority.com/2007/09/19/sql-server-rename-database-to-new-name-using-stored-procedure-by-changing-to-single-user-mode/): In my organization we rename the database on development server when are refreshing the development server with live data. We save the old database with new name and restore the database from live with same name. If developer/Jr. DBA have not saved the SQL Script from development server, he/she can go back to old Server and retrieve the script. There are few interesting facts to note when the database is renamed. When renamed the database, filegroup name or filename (.mdf,.ldf) are not changed. User with SA privilege can rename the database with following script when the context of the database is... - [SQLAuthority News - Scale-Out Querying with Analysis Services Using SAN Snapshots](https://blog.sqlauthority.com/2007/09/18/sqlauthority-news-scale-out-querying-with-analysis-services-using-san-snapshots/): White paper describes the use of virtual copy Storage Area Network (SAN) snapshots in a load-balanced scalable querying environment for SQL Server 2005 Analysis Services. This architecture provides the following improvements Improves the utilization of disk resources Optimizes cube processing operations Supports dedicated snapshots for specific users at different points in time In selecting a snapshot implementation for use with for Analysis Services, users may wish to consider the following snapshot attributes: Provisioning of snapshots Writeability of snapshots Scalability of snapshots Performance of snapshots Efficiency of snapshots I have created this article here only to promote the original White Paper, which... - [SQL SERVER - UDF - Validate Positive Integer Function - Validate Natural Integer Function](https://blog.sqlauthority.com/2007/09/18/sql-server-udf-validate-positive-integer-function-validate-natural-integer-function/): Few days ago I wrote SQL SERVER – UDF – Validate Integer Function. It was very interesting to write this and developers at my company started to use it. One Jr. DBA modified this function to validate only positive integers. I will share this with everybody who are interested in similar functionality. Code: CREATE FUNCTION [dbo].[udf_IsNatural] ( @Number VARCHAR(100) ) RETURNS BIT BEGIN DECLARE @Ret BIT IF (PATINDEX('%[^0-9-]%', @Number) = 0 AND CHARINDEX('-', @Number) <= 1 AND @Number NOT IN ('.', '-', '+', '^') AND LEN(@Number)>0 AND @Number NOT LIKE '%-%') SET @Ret = 1 ELSE SET @Ret = 0 RETURN @Ret END GO... - [SQLAuthority News - NASDAQ Uses SQL Server 2005 - Reducing Costs through Better Data Management](https://blog.sqlauthority.com/2007/09/17/sqlauthority-news-nasdaq-uses-sql-server-2005-reducing-costs-through-better-data-management/): I just came across PDF published by Microsoft to promote SQL Server 2005. I find few things very interesting. I will list them here. NASDAQ - [SQL SERVER - Difference Between UPDATE and UPDATE()](https://blog.sqlauthority.com/2007/09/17/sql-server-difference-between-update-and-update/): What is the difference between UPDATE and UPDATE()? UPDATE is syntax used to update the database tables or database views. USE AdventureWorks ; GO UPDATE Production.Product SET ListPrice = ListPrice * 2; GO UPDATE() is used in triggers to check update/insert to the database tables or database views. Returns a Boolean value that indicates whether an INSERT or UPDATE attempt was made on a specified column of a table or view. UPDATE() is used anywhere inside the body of a Transact-SQL INSERT or UPDATE trigger to test whether the trigger should execute certain actions. USE AdventureWorks ; GO CREATE TRIGGER reminder... - [SQLAuthority News - Active Directory Integration Sample Script](https://blog.sqlauthority.com/2007/09/16/sqlauthority-news-active-directory-integration-sample-script/): A sample script that enables you to extract a list of computer names from your custom SQL Server database and add them to an Active Directory security group. The security group can then be referenced in the Agent Assignment and Failover Wizard to automate agent assignments to Management Servers. 1. Queries customer SQL asset database. 2. Populates custom security group with computer accounts of computers returned by the SQL query. Download from MSDN Abstract courtesy : Microsoft Reference :Pinal Dave (https://blog.sqlauthority.com), Text from MSDN - [SQL SERVER - 2005 - List All The Constraint of Database - Find Primary Key and Foreign Key Constraint in Database](https://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/): Following script are very useful to know all the constraint in the database. I use this many times to check the foreign key and primary key constraint in database. This is simple but useful script from my personal archive. USE AdventureWorks; GO SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint, SCHEMA_NAME(schema_id) AS SchemaName, OBJECT_NAME(parent_object_id) AS TableName, type_desc AS ConstraintType FROM sys.objects WHERE type_desc LIKE '%CONSTRAINT' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Pro T-SQL 2005 Programmer's Guide (Paperback)](https://blog.sqlauthority.com/2007/09/15/sqlauthority-news-book-review-pro-t-sql-2005-programmers-guide-paperback/): Pro T-SQL 2005 Programmer’s Guide (Paperback) Book Review - [SQLAuthority News - Random Article from SQLAuthority Blog](https://blog.sqlauthority.com/2007/09/14/sqlauthority-news-random-article-from-sqlauthority-blog/): It has been wonderful writing on this blog. Many times I visit my older articles and read them. One of my favorite feature on WordPress.com (where I host my blog) is Random Article Feature. I use it quite often to land on random page on my blog. It is really good to read articles written previously because there are so many new things to learn as well keep previously learned knowledge refreshed. I have added link to random article in the side bar of this blog. User can click on it to visit random article as well click in the link... - [SQL SERVER - Difference Between EXEC and EXECUTE vs EXEC() - Use EXEC/EXECUTE for SP always](https://blog.sqlauthority.com/2007/09/13/sql-server-difference-between-exec-and-execute-vs-exec-use-execexecute-for-sp-always/): What is the difference between EXEC and EXECUTE? They are the same. Both of them executes stored procedure when called as EXEC sp_help GO EXECUTE sp_help GO I have seen enough times developer getting confused between EXEC and EXEC(). EXEC command executes stored procedure where as EXEC() function takes dynamic string as input and executes them. EXEC('EXEC sp_help') GO Another common mistakes I have seen is not using EXEC before stored procedure. It is always good practice to use EXEC before stored procedure name even though SQL Server assumes any command as stored procedure when it does not recognize the first... - [SQLAuthority News - Scrum: Agile Software Development for Project Management](https://blog.sqlauthority.com/2007/09/12/sqlauthority-news-scrum-agile-software-development-for-project-management/): This is something I have learned while working for so many years as Project Manager. It is not as important to know how things are done but it is important to know how to get things done. Scrum is an Agile Software Development system which helps developers to get project done in reasonable time and with superior quality. Scrum is organized around the following roles: Product Owner – Determines what functionality is needed ScrumMaster – Leads the Scrum and is primarily responsible for making sure the Scrum process is followed and removing impediments that keep the Team from working The Team... - [SQL SERVER - Frequency of SQL Server Reboot and Restart](https://blog.sqlauthority.com/2007/09/11/sql-server-frequency-of-sql-server-reboot-and-restart/): This is very interesting question. I will keep the answer of this question very simple. First of all there is no scientific research or white paper I can backup my results with. Answer contains part simple observation and part experience. There is no need to reboot SQL Server. Once it is on it is ON! However, I have heard that frequent reboot improves performance. In my company our network administration department has policy to reboot all the servers every 15 days. We reboot all the servers at every 15 days. Regarding performance improvement, our servers are always up and running as... - [SQLAuthority News - Book Review - SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills](https://blog.sqlauthority.com/2007/09/11/sqlauthority-news-book-review-sql-server-2005-dba-street-smarts-a-real-world-guide-to-sql-server-2005-certification-skills/): SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills (Paperback) by Joseph L. Jorden Link to Amazon Short Review: Microsoft’s new generation of certifications is design not only to emphasize your proficiency with a specific technology but also to prove you have the skills needed to perform a specific role. This book is developed based on the exam objective of the 70-431, although its purpose is to server more as a reference than just an exam preparation book. Detail Review: This book is designed to give DBAs some insight into the world of typical... - [SQL SERVER - 2005 - White Paper - Integrating Visio 2007 and Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/09/10/sql-server-2005-white-paper-integrating-visio-2007-and-microsoft-sql-server-2005/): This article focuses on integration techniques specific to Microsoft Office Visio 2007 and Microsoft SQL Server 2005. Using Visio 2007, you can connect Visio shapes to data that was generated outside Visio. A large amount of data can be captured in a SQL Analysis Services database. Being able to analyze that data in a visual way enhances the value of the data. In the following example, sales data stored in an Analysis Services cube is used to generate a Visio PivotDiagram so that the data can be explored and graphically enhanced. View Integrating Visio 2007 and Microsoft SQL Server 2005 Reference... - [SQLAuthority News - Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide](https://blog.sqlauthority.com/2007/09/10/sqlauthority-news-job-opportunity-in-ahmedabad-india-to-work-with-technology-leaders-worldwide/): If you have one or more years of experience in any web based programming language (.NET, ColdFusion, PHP) and interested in SQL Server as well willing to locate Ahmadabad, India. Please send me your resume, if selected you may get chance to work with one of the most progressing industry in world as well some smartest technology leaders worldwide. Salary depends on Experience. If selected for interview I suggest you go over SQL Server Interview Questions and Answers Complete List Download, as there is great chance I may be participating in interview. Please send your resume at pinaldave “at” yahoo.com and... - [SQL SERVER - 2005 - Start Stop Restart SQL Server From Command Prompt](https://blog.sqlauthority.com/2007/09/09/sql-server-2005-start-stop-restart-sql-server-from-command-prompt/): Very frequently I use following command prompt script to start and stop default instance of SQL Server. Our network admin loves this commands as this is very easy. Click Start >> Run >> type cmd to start command prompt. Start default instance of SQL Server net start mssqlserver Stop default instance of SQL Server net stop mssqlserver Start and Stop default instance of SQL Server. You can create batch file to execute both the commands together. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF - User Defined Function - Get Number of Days in Month](https://blog.sqlauthority.com/2007/09/08/sql-server-udf-user-defined-function-get-number-of-days-in-month/): Following User Defined Function (UDF) returns the numbers of days in month. It is very simple yet very powerful and full proof UDF. CREATE FUNCTION [dbo].[udf_GetNumDaysInMonth] ( @myDateTime DATETIME ) RETURNS INT AS BEGIN DECLARE @rtDate INT SET @rtDate = CASE WHEN MONTH(@myDateTime) IN (1, 3, 5, 7, 8, 10, 12) THEN 31 WHEN MONTH(@myDateTime) IN (4, 6, 9, 11) THEN 30 ELSE CASE WHEN (YEAR(@myDateTime) % 4 = 0 AND YEAR(@myDateTime) % 100 != 0) OR (YEAR(@myDateTime) % 400 = 0) THEN 29 ELSE 28 END END RETURN @rtDate END GO Run following script in Query Editor: SELECT dbo.udf_GetNumDaysInMonth(GETDATE()) NumDaysInMonth... - [SQL SERVER - Correlated and Noncorrelated - SubQuery Introduction, Explanation and Example](https://blog.sqlauthority.com/2007/09/07/sql-server-correlated-and-noncorrelated-subquery-introduction-explanation-and-example/): A correlated subquery is an inner subquery which is referenced by the main outer query such that the inner query is considered as being executed repeatedly. Example: ----Example of Correlated Subqueries USE AdventureWorks; GO SELECT e.EmployeeID FROM HumanResources.Employee e WHERE e.ContactID IN ( SELECT c.ContactID FROM Person.Contact c WHERE MONTH(c.ModifiedDate) = MONTH(e.ModifiedDate) ) GO A noncorrelated subquery is subquery that is independent of the outer query and it can executed on its own without relying on main outer query. Example: ----Example of Noncorrelated Subqueries USE AdventureWorks; GO SELECT e.EmployeeID FROM HumanResources.Employee e WHERE e.ContactID IN ( SELECT c.ContactID FROM Person.Contact c... - [SQL SERVER - 2005 - Introduction and Explanation to sqlcmd](https://blog.sqlauthority.com/2007/09/06/sql-server-2005-introduction-and-explanation-to-sqlcmd/): I decided to write this article to respond to request of one of usergroup, which requested that they would like to learn sqlcmd 101. SQL Server 2005 has introduced new utility sqlcmd to run ad hoc Transact-SQL statements and scripts from command prompt. T-SQL commands are entered in command prompt window and result is displayed in the same window, unless result set are sent to output files. sqlcmd can execute single T-SQL statement as well as batch file. sqlcmd utility can connect to earlier versions of SQL Server as well. The sqlcmd utility uses the OLE DB provider to execute T-SQL... - [SQLAuthority News - SQL SERVER 2008 CTP 4 Released](https://blog.sqlauthority.com/2007/09/06/sqlauthority-news-sql-server-2008-ctp-4-released/): SQL Server 2008 CTP 4 is released as a pre-configured VHD. This allows you to trial SQL Server 2008 CTP 4 in a virtual environment. Download SQL Server 2008 CTP 4 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Valid SQL Error](https://blog.sqlauthority.com/2007/09/05/sql-server-sql-joke-sql-humor-sql-laugh-valid-sql-error/): Yesterday I had posted my 300th post and I missed the announcement. One of my reader sent me following Image in email congratulating SQLAuthority blog for completing 300th post and also informing me that it has been long time I have posted something funny. I have written few articles about frequent SQL Server Errors on this blog. He suggested that this humorous images goes along with it. If you know source of this image please let me know I would like to include that. Visit more SQL Server Humors. Reference : Pinal Dave (https://blog.sqlauthority.com) , Need original reference for image. - [SQLAuthority News - Interesting Read - Using A SQL JOIN In A SQL UPDATE/Delete Statement - Ben Nadel](https://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/): As everybody know SQL is what I like most. Before I was into SQL Server, I was very much into ColdFusion. ColdFusion is still my most favorite programming language. I still program in ColdFusion, infect my personal website https://www.pinaldave.com/ is in ColdFusion. I regularly read ColdFusion blog and latest updates in ColdFusion. Recently at company where I work, we upgraded to ColdFusion 8 and .NET 2.0 (C# is our preferred language in .NET technology). Both of this languags work with SQL Server 2005 very well in my company. My favorite blog for ColdFusion technology is blog of BEN NADEL . Ben... - [SQL SERVER - 2005 - Find Tables With Primary Key Constraint in Database](https://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/): My article SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key has received following question many times. I have deleted similar questions and kept only latest comment there. In SQL Server 2005 How to Find Tables With Primary Key Constraint in Database? Script to find all the primary key constraint in database: USE AdventureWorks; GO SELECT i.name AS IndexName, OBJECT_NAME(ic.OBJECT_ID) AS TableName, COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName FROM sys.indexes AS i INNER JOIN sys.index_columns AS ic ON i.OBJECT_ID = ic.OBJECT_ID AND i.index_id = ic.index_id WHERE i.is_primary_key = 1 In SQL Server 2005 How to Find Tables... - [SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database](https://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/): While writing article based on my SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key I got an idea about writing this article. I was thinking if you can find primary key for any table in the database, you can sure find foreign key for any table in the database as well. - [SQL SERVER - 2005 - Search Stored Procedure Code - Search Stored Procedure Text](https://blog.sqlauthority.com/2007/09/03/sql-server-2005-search-stored-procedure-code-search-stored-procedure-text/): I receive following question many times by my team members. How can I find if particular table is being used in the stored procedure? How to search in stored procedures? How can I do dependency check for objects in stored procedure without using sp_depends? I have previously wrote article about this SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored procedure. The same feature can be implemented using following script in SQL Server 2005. USE AdventureWorks GO --Searching for Empoloyee table SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Employee%' GO --Searching for Empoloyee table... - [SQL SERVER - Fix : Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward](https://blog.sqlauthority.com/2007/09/02/sql-server-fix-error-msg-3117-level-16-state-4-the-log-or-differential-backup-cannot-be-restored-because-no-files-are-ready-to-rollforward/): Following error occurs when tried to restored the differential backup. Fix : Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward Fix/WorkAround/Solution: This error happens when Full back up is not restored before attempting to restore differential backup or full backup is restored with WITH RECOVERY option. Make sure database is not in operational conditional when differential backup is attempted to be restored. Example of restoring differential backup successfully after restoring full backup. RESTORE DATABASE AdventureWorks FROM DISK = 'C:\AdventureWorksFull.bak' WITH NORECOVERY; RESTORE DATABASE AdventureWorks FROM DISK... - [SQL SERVER - 2005 - Find Database Status Using sys.databases or DATABASEPROPERTYEX](https://blog.sqlauthority.com/2007/08/31/sql-server-2005-find-database-status-using-sysdatabases-or-databasepropertyex/): While writing article about database collation, I came across sys.databases and DATABASEPROPERTYEX. It was very interesting to me that this two can tell user so much about database properties. Following are main database status: (Reference: BOL Database Status) ONLINE Database is available for access. OFFLINE Database is unavailable. RESTORING One or more files of the primary filegroup are being restored, or one or more secondary files are being restored offline. RECOVERING Database is being recovered. RECOVERY PENDING SQL Server has encountered a resource-related error during recovery. SUSPECT At least the primary filegroup is suspect and may be damaged. EMERGENCY User has... - [SQL SERVER - 2005 - Find Database Collation Using T-SQL and SSMS](https://blog.sqlauthority.com/2007/08/30/sql-server-2005-find-database-collation-using-t-sql-and-ssms/): This article is written based on feedback I have received on SQL SERVER – Cannot resolve collation conflict for equal to operation. Many reader asked me how to find collation of current database. There are two different ways to find out SQL Server database collation. 1) Using T-SQL (My Recommendation) Run following Script in Query Editor SELECT DATABASEPROPERTYEX('AdventureWorks', 'Collation') SQLCollation; ResultSet: SQLCollation ———————————— SQL_Latin1_General_CP1_CI_AS 2) Using SQL Server Management Studio Refer the following two diagram to find out the SQL Collation. Write Click on Database Click on Properties Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Difference and Explanation among DECIMAL, FLOAT and NUMERIC](https://blog.sqlauthority.com/2007/08/29/sql-server-difference-and-explanation-among-decimal-float-and-numeric/): The basic difference between Decimal and Numeric : They are the exactly same. Same thing different name. The basic difference between Decimal/Numeric and Float : Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly. Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type reane can be represented exactly with precision and scale. Converting from Decimal or Numeric to float can cause some loss of precision. For the Decimal or Numeric data types, SQL Server considers each specific combination of precision and scale as a... - [SQL SERVER - Actual Execution Plan vs. Estimated Execution Plan](https://blog.sqlauthority.com/2007/08/28/sql-server-actual-execution-plan-vs-estimated-execution-plan/): I was recently invited to participate in big discussion on one of the online forum, the topic was Actual Execution Plan vs. Estimated Execution Plan. I refused to participate in that particular discussion as I have very simple but strong opinion about this topic. I always use Actual Execution Plan as it is accurate. Why not Estimated Execution Plan? It is not accurate. Sometime it is easier or useful to to know the plan without running query. I just run query and have correct and accurate Execution Plan. Shortcut for Display Estimated Execution Plan : CTRL + L Shortcut for Include... - [SQL SERVER - 2005 - Use Always Outer Join Clause instead of (*= and =*)](https://blog.sqlauthority.com/2007/08/27/sql-server-2005-use-always-outer-join-clause-instead-of-and/): Yesterday I wrote about how SQL Server 2005 does not support named pipes. Today, my friend called me asking some of his query does not work. I asked him to send me the queries. I asked him to send me query. I noticed in his queries something, I have never practiced before and I never had any issue therefore. Instead of using LEFT OUTER JOIN clause he was using *= and similarly instead of using RIGHT OUTER JOIN clause he was using =*. Once I replaced did necessary modification, queries run just fine. I wish I can give you example of... - [SQL SERVER - 2005 - No Backup Support For Named Pipes](https://blog.sqlauthority.com/2007/08/26/sql-server-2005-no-backup-support-for-named-pipes/): While helping one of my DBA friend (who works in big company in LA) to upgrade SQL Server 2000 to SQL Server 2005 I just found one thing, which I have not paid attention before. SQL Server 2000 supported named pipe backup device. SQL Server 2005 does not support named pipe backup device, however SQL Server 2005 supports disk and tape devices. I receive following question many times, I have answered this question earlier on this blog. I will still answer it again. What is my preferred method of backup? We use SAN with RAID 10 configuration. Some industry experts suggested... - [SQL SERVER - FIX : Error : msg 2540 - The system cannot self repair this error](https://blog.sqlauthority.com/2007/08/25/sql-server-fix-error-msg-2540-the-system-cannot-self-repair-this-error/): SQL SERVER – FIX : Error : msg 2540 – The system cannot self repair this error This is most annoying error. I have only faced this error twice so far. I solved this error restoring the database back up. Read here for additional help on SQL Backup And Restore. This error is occurs when database is in state when it can not be heal itself, i.e. corrupted metadata or corrupted important system database files. Fix/WorkAround/Solution: My prefered order to fix the problem. 1) Restored database from backup. 2) Run DBCC with repair option, which will not bring much favorable answer.... - [SQL SERVER - T-SQL Script to Attach and Detach Database](https://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/): Following script can be used to detach or attach the database. If the database is to be from one database to another database following script can be used to detach from old server and attach to a new server. Let us learn about how to Attach and Detach Database. - [SQL SERVER - 2005 - Use of Non-deterministic Function in UDF - Find Day Difference Between Any Date and Today](https://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/): While writing few articles about SQL Server DataTime I accidentally wrote User Defined Function (UDF), which I would have not wrote usually. Once I wrote this function, I did not find it very interesting and decided to discard it. However, I suddenly noticed use of Non-Deterministic function in the UDF. I always thought that use of Non-Deterministic function is prohibited in UDF. I even wrote about it earlier SQL SERVER – User Defined Functions (UDF) Limitations. It seems like SQL Server 2005 either have removed this restriction or it is bug. I think I will not say this is bug but... - [SQL SERVER - T-SQL Script to Insert Carriage Return and New Line Feed in Code](https://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/): Very simple and very effective. We use all the time for many reasons - formatting, while creating dynamically generated SQL to separate GO command from other T-SQL, saving some user input text to database etc. Let us learn about T-SQL Script to Insert Carriage Return and New Line Feed in Code. - [SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects](https://blog.sqlauthority.com/2007/08/21/sql-server-2005-create-script-to-copy-database-schema-and-all-the-objects-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/): Update: This article is re-written with SQL Server 2008 R2 instance over here: SQL SERVER – 2008 – 2008 R2 – Create Script to Copy Database Schema and All The Objects – Data, Schema, Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects Following quick tutorial demonstrates how to create T-SQL script to copy complete database schema and all of its objects such as Stored Procedure, Functions, Triggers, Tables, Views, Constraints etc. You can review your schema, backup for reference or use it to compare with previous backup. Step 1 : Start Step 2 : Welcome Screen Step... - [SQLAuthority News - Principles of Simplicity](https://blog.sqlauthority.com/2007/08/20/sqlauthority-news-principles-of-simplicity/): Yesterday I came across Principles of Simplicity by Mads Kristensen. I think this is good write up and I enjoyed reading it. This are very generic and applies to all programming language and databases applications. Principles of Simplicity by Mads Kristensen 1. Simplicity or not at all Some developers tend to over-complicate a task and ends up writing too many classes to solve a simple problem. 2. Don’t build submarines It’s a common fact that IT projects take longer than scheduled even if you schedule for delays. 3. Test when appropriate Testing is one very important factor of the development cycle... - [SQL SERVER - Find Monday of the Current Week](https://blog.sqlauthority.com/2007/08/20/sql-server-find-monday-of-the-current-week/): Very Simple Script which find Monday of the Current Week SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0) MondayOfCurrentWeek Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes](https://blog.sqlauthority.com/2007/08/19/sqlauthority-news-book-review-sams-teach-yourself-microsoft-sql-server-t-sql-in-10-minutes/): Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes (Sams Teach Yourself) by Ben Forta Link to Amazon Short Review: If T-SQL (Transact-Structured Query Language) is foreign tongue to you, after reading this book, you will speak T-SQL. This book is SQL Server version of best-selling book Sams Teach Yourself SQL in 10 Minutes. This book teaches what a SQL developer must know methodically, systematically, and exactly. Anybody who are new to SQL Server and wants to learn most of T-SQL which can be implemented in short time in their application – BUY this book immediately. Detail Review: This is... - [SQL SERVER - Find Last Day of Any Month - Current Previous Next](https://blog.sqlauthority.com/2007/08/18/sql-server-find-last-day-of-any-month-current-previous-next/): Few questions are always popular. They keep on coming up through email, comments or from co-workers. Finding Last Day of Any Month is similar question. I have received it many times and I enjoy answering it as well. I have answered this question twice before here: SQL SERVER – Script/Function to Find Last Day of Month SQL SERVER – Query to Find First and Last Day of Current Month Today, we will see the same solution again. Please use the method you find appropriate to your requirement. Following script demonstrates the script to find last day of previous, current and next... - [SQL SERVER - 2005 - Explanation and Script for Online Index Operations - Create, Rebuild, Drop](https://blog.sqlauthority.com/2007/08/17/sql-server-2005-explanation-and-script-for-online-index-operations-create-rebuild-drop/): SQL Server 2005 Enterprise Edition supports online index operations. Index operations are creating, rebuilding and dropping indexes. The question which I receive quite often – what is online operation? Is online operation is related to web, internet or local network? Online operation means when online operations are happening the database are in normal operational condition, the processes which are participating in online operations does not require exclusive access to database. In case of Online Indexing Operations, when Index operations (create, rebuild, dropping) are occuring they do not require exclusive access to database, they do not lock any database tables. This is... - [SQLAuthority News - Subscribed to SQLAuthority Emails](https://blog.sqlauthority.com/2007/08/16/sqlauthority-news-subscribed-to-sqlauthority-emails/): I have got many request about alert system when new post is published on this blog. I use feedburner email service, which sends email whenever new post is published on my blog. Many times, I update my post based on feedback from comments or news. If you want updated information, visit the blog. Subscribe to SQLAuthority.com Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Book On-Line Link - BOL](https://blog.sqlauthority.com/2007/08/16/sql-server-2008-book-on-line-link/): I am researching SQL Server. Those who are asking me questions about SQL Server 2008, please refer following link. I will post my tutorials and articles very soon. Books Online is commonly known as BOL. - [SQL SERVER - 2005 - Difference and Similarity Between NEWSEQUENTIALID() and NEWID()](https://blog.sqlauthority.com/2007/08/16/sql-server-2005-difference-and-similarity-between-newsequentialid-and-newid/): NEWSEQUENTIALID() and NEWID() both generates the GUID of datatype of uniqueidentifier. NEWID() generates the GUID in random order whereas NEWSEQUENTIALID() generates the GUID in sequential order. Let us see example first demonstrating both of the function. USE AdventureWorks; GO ----Create Test Table for with default columns values CREATE TABLE TestTable (NewIDCol uniqueidentifier DEFAULT NEWID(), NewSeqCol uniqueidentifier DEFAULT NewSequentialID()) ----Inserting five default values in table INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES ----Test Table to see NewID() is random ----Test Table to see NewSequentialID()... - [SQL SERVER - Insert Data From One Table to Another Table - INSERT INTO SELECT - SELECT INTO TABLE](https://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table/): Following three questions are many times asked on this blog. How to insert data from one table to another table efficiently? How to insert data from one table using where condition to another table? How can I stop using cursor to move data from one table to another table? There are two different ways to implement inserting data from one table to another table. I strongly suggest to use either of the methods over the cursor. Performance of following two methods is far superior over the cursor. I prefer to use Method 1 always as I works in all the cases.... - [SQLAuthority News - Book Review - Learning SQL on SQL Server 2005 (Learning)](https://blog.sqlauthority.com/2007/08/14/sqlauthority-news-book-review-learning-sql-on-sql-server-2005-learning/): SQLAuthority.com Book Review : Learning SQL on SQL Server 2005 (Learning) [ILLUSTRATED] (Paperback) by Sikha Bagui, Richard Earp Link to book on Amazon Short Review: This books covers simple and complex concept in very easy language with lots of examples. Every beginner can learn a great amount of tips from experienced authors. Whether you are a self-learner, new to databases or in need of SQL refresher, this is good read. Detail Review: This book is written by two conceptual strong SQL Server Gurus. SQL Server is growing extremely popular in the area of high-performance data applications. It is very important to... - [SQL SERVER - What is SQL? How to pronounce SQL?](https://blog.sqlauthority.com/2007/08/14/sql-server-what-is-sql-how-to-pronounce-sql/): SQL is abbreviation of Structured Query Language. SQL is pronounced as S.Q.L. (ess-que-ell or ess-cue-ell) not sequel. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - Database Architecture and Implementation Discussion - New York, New Jersey Details](https://blog.sqlauthority.com/2007/08/13/sqlauthority-news-author-visit-database-architecture-and-implementation-discussion-new-york-new-jersey-details/): Last weekend I visited New York City (NY) and Edison (NJ) to attend database architecture meeting with a big environmental technology firm. It was very interesting to meet CEO and few of the lead database administrators. Lots of database related things were discussed. I will list few of the points discussed in the meeting here, due to privacy policy I will be not able to write many of the interesting details I have learned there. Please let me know if you are interested in any of the particular topic. I can elaborate more on the topic which interests everybody. 1) Database... - [SQL SERVER - Fix : ERROR : Msg 1033, Level 15, State 1 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.](https://blog.sqlauthority.com/2007/08/12/sql-server-fix-error-msg-1033-level-15-state-1-the-order-by-clause-is-invalid-in-views-inline-functions-derived-tables-subqueries-and-common-table-expressions-unless-top-or-for-xml-is-als/): Following error is encountered when view is attempted to created with ORDER BY clause in it. ORDER BY clause is not allowed in views in SQL Server 2005. This solution also displays the workaround to use ORDER BY in VIEW. I really do not prefer to use views. My views on SQL Views read it SQL SERVER – Restrictions of Views – T SQL View Limitations. Msg 1033, Level 15, State 1 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. This is error interested... - [SQL SERVER - UDF - Validate Integer Function](https://blog.sqlauthority.com/2007/08/11/sql-server-udf-validate-integer-function/): I received quite a good feedback about my post about SQL SERVER – Validate Field For DATE datatype using function ISDATE() One of the most interesting comment I received from my reader from Canada. I was suggested just like ISDATE() to write about ISNUMERIC() which can be used to validate numeric values. As per BOL: ISNUMERIC returns 1 when the input expression evaluates to a valid numeric data type; otherwise it returns 0. ISNUMERIC returns 1 for some characters that are not numbers, such as plus (+), minus (-), and valid currency symbols such as the dollar sign ($). Now this... - [SQL SERVER - 2005 - Find Stored Procedure Create Date and Modified Date](https://blog.sqlauthority.com/2007/08/10/sql-server-2005-find-stored-procedure-create-date-and-modified-date/): This post is second part of my previous post about SQL SERVER – 2005 – List All Stored Procedure Modified in Last N Days - [SQL SERVER - 2005 - List All The Column With Specific Data Types](https://blog.sqlauthority.com/2007/08/09/sql-server-2005-list-all-the-column-with-specific-data-types/): Since we upgraded to SQL Server 2005 from SQL Server 2000, we have used following script to find out columns with specific datatypes many times. It is very handy small script. SQL Server 2005 has new datatype of VARCHAR(MAX), we decided to change all our TEXT datatype columns to VARCHAR(MAX). The reason to do that as TEXT datatype will be deprecated in future version of SQL Server and VARCHAR(MAX) is superior to TEXT datatype in features. We run following script to identify all the columns which are TEXT datatype and developer converts them to VARCHAR(MAX) Script 1 : Simple script to... - [SQL SERVER - 2005 - SSMS - Enable Autogrowth Database Property](https://blog.sqlauthority.com/2007/08/08/sql-server-2005-ssms-enable-autogrowth-database-property/): We can use SSMS to Enable Autogrowth property of the Database. Right-click on Database click on Properties and click on Files. There will be column of Autogrowth, click on small box with three (…) dots. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List Tables in Database Without Primary Key](https://blog.sqlauthority.com/2007/08/07/sql-server-2005-list-tables-in-database-without-primary-key/): This is very simple but effective script. It list all the table without primary keys. USE DatabaseName; GO SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableName FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0 ORDER BY SchemaName, TableName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Fix: Error 2596 The repair statement was not processed. The database cannot be in read-only mode](https://blog.sqlauthority.com/2007/08/06/sql-server-fix-error-2596-the-repair-statement-was-not-processed-the-database-cannot-be-in-read-only-mode/): ERROR 2596 : The repair statement was not processed. The database cannot be in read-only mode. - [SQL SERVER - Stop SQL Server Immediately Using T-SQL](https://blog.sqlauthority.com/2007/08/05/sql-server-stop-sql-server-immediately-using-t-sql/): This question has came up many quite a few times with our development team as well as emails I have received about how to stop SQL Server immediately (due to accidentally ran t-sql, business logic or just need of to stop SQL Server using T-SQL). Answer is very simple, run following command in SQL Editor. SHUTDOWN If you want to shutdown the system without performing checkpoints in every database and without attempting to terminate all user processes use following command. SHUTDOWN WITH NOWAIT Server can be turned off using windows services as well. SHUTDOWN permissions are assigned to members of the... - [SQL SERVER - One Thing All DBA Must Know](https://blog.sqlauthority.com/2007/08/04/sql-server-one-thing-all-dba-must-know/): FULLY BACKUP DATABASE. Update : I posted this post with only line. However I received many comments and questions asking different questions related to it. I have compiled all of them and modified this post. Most asked Question : What is the best time when database should be backed up? Answer : When everything is running perfect. This is the time when backup should be taken because in troubled time this is the backup required to be restored. The best backup is when system was running PERFECT. Question : I am experienced DBA, what should be the frequency of backup when... - [SQLAuthority News - Download SQL Server 2005 Samples and Sample Databases](https://blog.sqlauthority.com/2007/08/04/sqlauthority-news-download-sql-server-2005-samples-and-sample-databases/): Microsoft has purchased GitHub, the world’s leading software development platform where more than 28 million developers learn, share and collaborate to create the future for 7.5 Billion dollars.  - [SQLAuthority News - Author Visit - Database Architecture and Implementation Discussion - New York, New Jersey](https://blog.sqlauthority.com/2007/08/04/sqlauthority-news-author-visit-database-architecture-and-implementation-discussion-new-york-new-jersey/): I will be traveling for next two days to New York and New Jersey for Database Architecture and Implementation Discussion with one of the largest software technology company. The major focus of this firm is environmental product analysis. I will be not able to answer any questions, comments and emails during next two days 8/5 Saturday and 8/6 Sunday. I will post all the interesting details (which I can disclose safely without violating privacy policy) once I am come back to my city – Las Vegas. I am looking forward to meet industry giants and prominent personalities for next two days.... - [SQLAuthority News - Book Review - Beginners Guide to SQL Server Integration Services Using Visual Studio 2005](https://blog.sqlauthority.com/2008/01/28/sqlauthority-news-book-review-beginners-guide-to-sql-server-integration-services-using-visual-studio-2005/): Beginners Guide to SQL Server Integration Services Using Visual Studio 2005 (Paperback) by Jayaram Krishnaswamy (Author) Link to Amazon Short Summary: SQL Server Integration Services Using Visual Studio 2005 contains all the information and education needed for one to begin with SSIS. It covers all the basic concepts in depth and moves towards advance concepts of Extraction, Transformation and Loading (ETL). One book for all the beginners in SSIS. Detail Summary: SQL Server Integration Services (SSIS) is a comprehensive ETL tool available in SQL Server 2005. It is integrated with Visual Studio 2005 (VS2K5). SSIS is replacement of Data Transformation Services... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2008/01/27/sqlauthority-news-sql-joke-sql-humor-sql-laugh-funny-quotes/): Following is the collection of some funny quotes regarding computers. Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Rich Cook. UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. Dennis Ritchie. The perfect computer has been developed. You just feed in your problems and they never come out again. Al Goodman. Computers make it easier to do a lot of things, but most of the things they make... - [SQLAuthority News - Microsoft SQL Server 2000 MSIT Configuration Pack for Configuration Manager 2007](https://blog.sqlauthority.com/2008/01/26/sqlauthority-news-microsoft-sql-server-2000-msit-configuration-pack-for-configuration-manager-2007/): Microsoft SQL Server 2000 MSIT Comprehensive Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2000 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2000 MSIT Intermediate Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2000 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2000 MSIT Basic Configuration Pack for Configuration Manager 2007 This... - [SQL SERVER - 2005 - Database Table Partitioning Tutorial - How to Horizontal Partition Database Table](https://blog.sqlauthority.com/2008/01/25/sql-server-2005-database-table-partitioning-tutorial-how-to-horizontal-partition-database-table/): I have received calls from my DBA friend who read my article SQL SERVER - 2005 - Introduction to Partitioning. He suggested that I should write a simple tutorial about how to horizontal partition database table. Here is a simple tutorial which explains how a table can be partitioned. - [SQL SERVER - 2005 - Introduction to Partitioning](https://blog.sqlauthority.com/2008/01/24/sql-server-2005-introduction-to-partitioning/): Partitioning is the database process or method where very large tables and indexes are divided in multiple smaller and manageable parts. SQL Server 2005 allows to partition tables using defined ranges and also provides management features and tools to keep partition tables in optimal performance. Tables are partition based on column which will be used for partitioning and the ranges associated to each partition. Example of this column will be incremental identity column, which can be partitioned in different ranges. Different ranges can be on different partitions, different partition can be on different filegroups, and different partition can be on different... - [SQLAuthority News - Download Microsoft SQL Server 2005 Assessment Configuration Pack](https://blog.sqlauthority.com/2008/01/23/sqlauthority-news-download-microsoft-sql-server-2005-assessment-configuration-pack/): Microsoft SQL Server 2005 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Gramm-Leach Bliley Act compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains... - [SQLAuthority News - Fix : Remote Desktop Copy Paste Stop Working](https://blog.sqlauthority.com/2008/01/22/sqlauthority-news-fix-remote-desktop-copy-paste-stop-working/): Today’s article is not related to SQL Server 100%, however it is quite related to SQL Server, or atleast I found it while working with SQL Server. Just two days ago, while I was working with remote SQL Server using Remote Desktop tool provided by Windows XP. Suddenly, copy/paste feature of windows stop working on remote desktop. I was not able to copy from local machine to remote machine and remote machine to local machine, both ways. I was able to copy/paste from remote machine to remote machine and local machine to local machine. I thought may be if I restart... - [SQL SERVER - Get a Row Per File of a Database as Stored in the Master Database](https://blog.sqlauthority.com/2008/01/21/sql-server-2005-get-a-row-per-file-of-a-database-as-stored-in-the-master-database/): Each database has a minimum of two files associated with the database. If a database has more than one filegroup it will have many files associated with one database. Following quick script will give you recordset per file of a database which is stored in master database. - [SQL SERVER - Introduction to Statistical Functions - VAR, STDEVP, STDEV, VARP](https://blog.sqlauthority.com/2008/01/20/sql-server-introduction-to-statistical-functions-var-stdevp-stdev-varp/): Yesterday I wrote article about SQL SERVER – Introduction to Aggregate Functions. I received one email that four of the aggregate functions are statistical function and I should write something about that. VAR, STDEVP, STDEV, VARP are statistical functions as well they absolutely fit in the definition of aggregate function as well. The usage of this function is pretty simple so instead of explaining them I will go to example right away. USE AdventureWorks; GO SELECT VAR(Bonus) 'Variance', STDEVP(Bonus) 'Standard Deviation', STDEV(Bonus) 'Standard Deviation', VARP(Bonus) 'Variance for the Population' FROM Sales.SalesPerson; GO All the functions returns result as datatype float. VAR... - [SQL SERVER - Introduction to Aggregate Functions](https://blog.sqlauthority.com/2008/01/19/sql-server-introduction-to-aggregate-functions/): Recently I have been taking many interviews to increase work force in my companies outsourcing establishment. One question I ask to all interview candidates. What is Aggregate Function? So far I have received two different kind of response. First, I do not know. Second, AVG, SUM, COUNT are aggregate functions. The second response is good enough but not technically correct. None of the candidate have gave me good definition of Aggregate Function. Definition from BOL is Aggregate functions perform a calculation on a set of values and return a single value. Following functions are aggregate functions. AVG, MIN, CHECKSUM_AGG, SUM, COUNT,... - [SQL SERVER - 2005 Best Practices Analyzer (January 2008)](https://blog.sqlauthority.com/2008/01/18/sql-server-2005-best-practices-analyzer-january-2008/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD TOOL HERE Best Practice Analyzer (BPA) Tutorial Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Job Description of Database Administrator (DBA) or Database Developer](https://blog.sqlauthority.com/2008/01/17/sqlauthority-news-job-description-of-database-administrator-dba-or-database-developer/): Job Description of Database Administrator (DBA) or Database Developer Develop standards and guidelines to guide the use and acquisition of software and to protect vulnerable information. Modify existing databases and database management systems or direct programmers and analysts to make changes. Test programs or databases, correct errors and make necessary modifications. Plan, coordinate and implement security measures to safeguard information in computer files against accidental or unauthorized damage, modification or disclosure. Approve, schedule, plan, and supervise the installation and testing of new products and improvements to computer systems, such as the installation of new databases. Train users and answer questions. Establish... - [SQLAuthroity News - Microsoft SQL Server 2000 Assessment Configuration Pack](https://blog.sqlauthority.com/2008/01/16/sqlauthroity-news-microsoft-sql-server-2000-assessment-configuration-pack/): Microsoft SQL Server 2000 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2000 servers in order to support your Federal Information Security Management Act compliance efforts. Microsoft SQL Server 2000 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2000 servers in order to support your Gramm-Leach Bliley Act compliance efforts. Microsoft SQL Server 2000 Assessment Configuration Pack for Health Insurance Portability... - [SQL SERVER - What is - DML, DDL, DCL and TCL - Introduction and Examples](https://blog.sqlauthority.com/2008/01/15/sql-server-what-is-dml-ddl-dcl-and-tcl-introduction-and-examples/): DML DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. Examples: SELECT, UPDATE, INSERT statements DDL DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. Examples: CREATE, ALTER, DROP statements DCL DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it. Examples: GRANT, REVOKE statements TCL TCL is abbreviation of Transactional Control Language. It is used to... - [SQL SERVER - Time Out Due to Executing DELETE on Large RecordSet](https://blog.sqlauthority.com/2008/01/14/sql-server-time-out-due-to-executing-delete-on-large-recordset/): Just a day ago, I received following question: “I have large table more than 1M rows. I want to delete every row in my table. Everytime I ran DELETE statement, it times out and does not do it job. The data in table is useless and I do not need it ever. Your suggestion please.” The reason I decided to write article about this question because I receive similar questions very often. I think many readers will find answer to this question useful. My answer to his question is here with: “If DELETE is timing out use TRUNCATE instead. It will... - [SQLAuthority News - Good Motivational Quotes for Interviews](https://blog.sqlauthority.com/2008/01/13/sqlauthority-news-good-motivational-quotes-interviews/): Here are few motivational quotes for candidates who are appearing for interview. I have collected this throughout the years and it is running list of the interview. Please feel free to let me know if you find any such good interview quote and I will update in this list. - [SQL SERVER - 2005 - Change Compatibility Level - T-SQL Procedure](https://blog.sqlauthority.com/2008/01/12/sql-server-2005-change-compatibility-level-t-sql-procedure/): Six months ago I wrote article about SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility. Yesterday I received an email asking that one of my blog reader is not able to use the sp_dbcmptlevel command with error that database is in use. He has asked me to write about proper procedure of changing database compatibility which will always work. First read my previous article SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility as it has explained many details about compatibility. The best practice to change the compatibility level of database is in following three steps.... - [SQL SERVER - Reclaim Space After Dropping Variable - Length Columns Using DBCC CLEANTABLE](https://blog.sqlauthority.com/2008/01/11/sql-server-reclaim-space-after-dropping-variable-length-columns-using-dbcc-cleantable/): All DBA and Developers must have observed when any variable length column is dropped from table, it does not reduce the size of table. Table size stays the same till Indexes are reorganized or rebuild. There is also DBCC command DBCC CLEANTABLE, which can be used to reclaim any space previously occupied with variable length columns. Variable length columns include varchar, nvarchar, varchar(max), nvarchar(max), varbinary, varbinary(max), text, ntext, image, sql_variant, and xml. Space can be reclaimed when variable length column is also modified to lesser length. - [SQL SERVER - 2005 - Display Fragmentation Information of Data and Indexes of Database Table](https://blog.sqlauthority.com/2008/01/10/sql-server-2005-display-fragmentation-information-of-data-and-indexes-of-database-table/): One of my friend involved with large business of medical transcript invited me for SQL Server improvement talk last weekend. I had great time talking with group of DBA and developers. One of the topic which was discussed was how to find out Fragmentation Information for any table in one particular database. For SQL Server 2000 it was easy to find using DBCC SHOWCONTIG command. DBCC SHOWCONTIG has some limitation for SQL Server 2000. SQL Server 2005 has sys.dm_db_index_physical_stats dynamic view which returns size and fragmentation information for the data and indexes of the specified table or view. You can run... - [SQL SERVER - Execute Same Query and Statement Multiple Times Using Command GO](https://blog.sqlauthority.com/2008/01/09/sql-server-execute-same-query-and-statement-multiple-times-using-command-go/): Following question was asking by one of long time reader who really liked trick of SQL SERVER – Explanation SQL Command GO and SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL. She asked how can I execute same code multiple times without Copy and Paste multiple times in Query Editor. The answer to this question is very simple. Use the command GO. Following example demonstrate how GO can be used to execute same code multiple times. SELECT GETDATE() AS CurrentTime GO 5 Above code will return current time 5 times as GO is followed... - [SQL SERVER - Export Data From SQL Server to Microsoft Excel Datasheet](https://blog.sqlauthority.com/2008/01/08/sql-server-2005-export-data-from-sql-server-2005-to-microsoft-excel-datasheet/): Question: How to Export Data From SQL Server to Microsoft Excel Datasheet? - [SQL SERVER - 2005 - Introduction and Explanation to SYNONYM - Helpful T-SQL Feature for Developer](https://blog.sqlauthority.com/2008/01/07/sql-server-2005-introduction-and-explanation-to-synonym-helpful-t-sql-feature-for-developer/): One of my friend and extremely smart DBA Jonathan from Las Vegas has pointed out nice little enhancement in T-SQL. I was very pleased when I learned about SYNONYM feature in SQL Server 2005. DBA have been referencing database objects in four part names. SQL Server 2005 introduces the concept of a synonym. A synonyms is a single-part name which can replace multi part name in SQL Statement. Use of synonyms cuts down typing long multi part server name and can replace it with one synonyms. It also provides an abstractions layer which will protect SQL statement using synonyms from changes... - [SQL SERVER - Download Frequently Asked Generic Interview Questions](https://blog.sqlauthority.com/2008/01/06/sql-server-download-frequently-asked-generic-interview-questions/): Yesterday I posted article about SQL SERVER – Most Frequently Asked Generic Interview Questions. I always enjoy when I receive emails and comments about my article. Many readers have asked me to write more about this, I suggest that my readers help me here and add their suggestion and answers to original article. The common question asked to me is why I have not included answers with this questions. Each question is very unique to each individual and its answer can be very different from person to person. There is no right or wrong answer here. Just answer what you feel... - [SQL SERVER - Most Frequently Asked Generic Interview Questions](https://blog.sqlauthority.com/2008/01/05/sql-server-most-frequently-asked-generic-interview-questions/): Tell me about yourself. What experience do you have in this field? How many years of experience do you have in area you are applying for? Why did you leave your last job? Why are you planning to leave your current job? What do you know about this organization? Why do you want to work for this organization? How would you describe your ideal job? How long would you expect to work for us if hired? What have you done to improve your knowledge recently? What do co-workers say about you? What irritates you about co-workers? What kind of person would... - [SQL SERVER - Quick Note on CROSS APPLY](https://blog.sqlauthority.com/2008/01/04/sql-server-2005-cross-apply/): Yesterday I wrote article about SQL SERVER – 2005 – Last Ran Query – Recently Ran Query. I had used CROSS APPLY in the query. I got email from one reader asking what is CROSS APPLY. In simpler words, cross apply is like inner join to table valued function which can take parameters. This particular operation is not possible to do using regular JOIN syntax You can see example of CROSS APPLY in my article here. - [SQL SERVER - 2005 - Last Ran Query - Recently Ran Query](https://blog.sqlauthority.com/2008/01/03/sql-server-2005-last-ran-query-recently-ran-query/): How many times we have wondered what were the last few queries ran on SQL Server? Following quick script demonstrates last ran query along with the time it was executed on SQL Server 2005. SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest ORDER BY deqs.last_execution_time DESC Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL – sys.dm_exec_query_stats, BOL – sys.dm_exec_sql_text - [SQLAuthority New - Best Practices for Speeding Up Your Web Site](https://blog.sqlauthority.com/2008/01/03/sqlauthority-new-best-practices-for-speeding-up-your-web-site/): Steve Souders, Chief Performance Yahoo! Best Practices for Speeding Up Your Web Site. I suggest everybody should read this basic guidelines. They are extremely important for high performance websites. 1. Make Fewer HTTP Requests 2. Use a Content Delivery Network 3. Add an Expires Header 4. Gzip Components 5. Put Stylesheets at the Top 6. Put Scripts at the Bottom 7. Avoid CSS Expressions 8. Make JavaScript and CSS External 9. Reduce DNS Lookups 10. Minify JavaScript 11. Avoid Redirects 12. Remove Duplicate Scripts 13. Configure ETags 14. Make Ajax Cacheable Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 15281 SQL Server blocked access to STATEMENT OpenRowset/OpenDatasource of](https://blog.sqlauthority.com/2008/01/02/sql-server-fix-error-15281-sql-server-blocked-access-statement-openrowsetopendatasource-component-ad-hoc-distributed-queries-component-turned-off/): Error 15281 Msg 15281, Level 16, State 1, Line 3 SQL Server blocked access to STATEMENT ‘OpenRowset/OpenDatasource’ of component ‘Ad Hoc Distributed Queries’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ad Hoc Distributed Queries’ by using sp_configure. For more information about enabling ‘Ad Hoc Distributed Queries’, see “Surface Area Configuration” in SQL Server Books Online. - [SQLAuthority New - Happy New Year 2008](https://blog.sqlauthority.com/2008/01/01/sqlauthority-new-happy-new-year-2008/): Today is New Year and I wish you all Best for Year 2008. Let us all start our new year with motivational new year quote. We will open the book. Its pages are blank. We are going to put words on them ourselves. The book is called “Opportunity” and its first chapter is New Year’s Day. – Edith Lovejoy Pierce Microsoft has big gift for all SQL Server fans and developers. It is realizing SQL Server 2008. Today in New Year let us have some laugh together. We will continue together with SQL Server articles from tomorrow. I hope you enjoy... - [SQLAuthority News - Thank You to Blog Readers](https://blog.sqlauthority.com/2007/12/31/sqlauthority-news-thank-you-to-blog-readers/): Thank You very much for reading SQLAuthority.com for entire 2007 year. Wish you the BEST for year 2008. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Remove Duplicate Characters From a String](https://blog.sqlauthority.com/2007/12/30/sql-server-remove-duplicate-characters-from-a-string/): Follow up of my previous article of Remove Duplicate Chars From String here is another great article written by Madhivanan where similar solution is suggested with alternate method of Number table approach. Check out Remove duplicate characters from a string Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Change Password of SA Login Using Management Studio](https://blog.sqlauthority.com/2007/12/29/sql-server-change-password-of-sa-login-using-management-studio/): Login into SQL Server using Windows Authentication. In Object Explorer, open Security folder, open Logins folder. Right Click on SA account and go to Properties. Change SA password, and confirm it. Click OK. Make sure to restart the SQL Server and all its services and test new password by log into system using SA login and new password. Reference : Pinal Dave (https://blog.sqlauthority.com) UPDATE : There has been discussion about restarting the SQL Server and all its services. Please read all of them before making final decision for your scenario. - [SQL SERVER - Difference Between Quality Assurance and Quality Control - QA vs QC](https://blog.sqlauthority.com/2007/12/28/sql-server-difference-between-quality-assurance-and-quality-control-qa-vs-qc/): Regular readers of this blog are aware of my current outsourcing assignment. I am managing very large outsourcing project in India. One thing is very special in all Indian offices are “Tea Time.” Everybody wants to attend Tea Time not only for tea or coffee but for the interesting discussion occurs at that time. This is the time when all the department employees are together and discussing whatever they wish.Today there was an interesting discussion about Quality Assurance (QA) and Quality Control (QC). - [SQLAuthority News - Book Review - A Practitioner's Guide to Software Test Design](https://blog.sqlauthority.com/2007/12/27/sqlauthority-news-book-review-a-practitioners-guide-to-software-test-design/): A Practitioner's Guide to Software Test Design is one book containing all the important latest test design approaches. This book makes life of software tester very easy. Software tester can find all the information in this book instead of searching through hundreds of books, periodicals and websites. - [SQL SERVER - TRUNCATE Can't be Rolled Back Using Log Files After Transaction Session Is Closed](https://blog.sqlauthority.com/2007/12/26/sql-server-truncate-cant-be-rolled-back-using-log-files-after-transaction-session-is-closed/): You might have listened and read either of following sentence many many times. “DELETE can be rolled back and TRUNCATE can not be rolled back”. OR “DELETE can be rolled back as well as TRUNCATE can be rolled back”. As soon as above sentence is completed, someone will object it saying either TRUNCATE can be or can not be rolled back. Let us make sure that we understand this today, in simple words without talking about theory in depth. While database is in full recovery mode, it can rollback any changes done by DELETE using Log files. TRUNCATE can not be... - [SQL SERVER - Mirrored Backup Introduction and Explanation](https://blog.sqlauthority.com/2007/12/25/sql-server-mirrored-backup-introduction-and-explanation/): SQL Server 2005 Enterprise Edition and Development Edition supports mirrored backup. Mirroring a media set increases backup reliability by adding redundancy of backup media which effectively reduces the impact of backup-device failing. While taking backup of database, same backup is taken on multiple media or locations. T-SQL code to take Mirrored Backup : BACKUP DATABASE AdventureWorks TO DISK = 'c:\AdventureWorksBackup.bak' MIRROR TO DISK = 'd:\AdventureWorksBackupCopy.bak' WITH FORMAT; Above script will create two backups at two different locations, if backup of one location is corrupted backup from another location will work fine. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Delete Duplicate Records - Count Duplicate Records Links](https://blog.sqlauthority.com/2007/12/25/sql-server-delete-duplicate-records-count-duplicate-records-links/): I have wrote following two articles for Duplicate Rows Management in SQL Server. SQL SERVER – Count Duplicate Records – Rows SQL SERVER – Delete Duplicate Records – Rows Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Object Oriented Database Management Systems](https://blog.sqlauthority.com/2007/12/24/sql-server-object-oriented-database-management-systems/): I have received few emails and comments about why I do not write about Object Oriented Database Management Systems (OODBMS). The reason for that is that I am big follower of Relational Database Management Systems (RDBMS) and that particularly of Microsoft SQL Server. If you are interested in reading about OODBMS, I have came across one interesting article, which I can share here. Visit : AN EXPLORATION OF OBJECT ORIENTED DATABASE MANAGEMENT SYSTEMS by Dare Obasanjo The purpose of above mentioned paper is to provide answers to the following questions What is an Object Oriented Database Management System (OODBMS)? Is an... - [SQLAuthority News - Download Microsoft SQL Server 2000/2005 Management Pack](https://blog.sqlauthority.com/2007/12/24/sqlauthority-news-download-microsoft-sql-server-20002005-management-pack/): Note: Download Microsoft SQL Server 2000/2005 Management Pack by Microsoft The SQL Server Management Pack monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems. Availability and performance monitoring is done using synthetic transactions. In addition, the Management Pack collects Event Log alerts and provides associated knowledge articles with additional user details, possible causes, and suggested resolutions. The Management Pack discovers Database Engines, Database Instances, and Databases and can optionally discover Database File and Database File Group objects. Feature Summary: Active Directory Helper Service SQL Server Agent Backup Databases and Tables DBCC Full... - [SQLAuthority News - Jobs, Search, Best Articles, Homepage](https://blog.sqlauthority.com/2007/12/24/sqlauthority-news-jobs-search-best-articles-homepage/): If you are looking for solution of any of your question : Search SQLAuthority If you are looking for best job in IT field : Find Job or email pinal@sqlauthority.com If you are looking for talented IT professional : Post Job or email pinal@sqlauthority.com If you want to read my personally selected articles : Best Articles If you want to know more about me : pinaldave.com If you want to subscribe to my blog : Email or Feed Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - New DataTypes DATE and TIME](https://blog.sqlauthority.com/2007/12/23/sql-server-2008-new-datatypes-date-and-time/): One of our project manager asked me why SQL Server does not have only DATE or TIME datatypes? I thought his question is very valid, he is not DBA however he understands the RDBMS concepts very well. I find his question very interesting. I told him that there are ways to do that in SQL Server 2005 and earlier versions. He asked me but if there are DATE and TIME datatypes not DATETIME combined. This question we all DBA had for many years and we all wanted DATE and TIME separate datatypes then DATETIME combined. Microsoft has incorporated this feature in... - [SQL SERVER - Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script](https://blog.sqlauthority.com/2007/12/22/sql-server-difference-between-index-rebuild-and-index-reorganize-explained-with-t-sql-script/): Index Rebuild : This process drops the existing Index and Recreates the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REBUILD GO Index Reorganize : This process physically reorganizes the leaf nodes of the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REORGANIZE GO Recommendation: Index should be rebuild when index fragmentation is great than 40%. Index should be reorganized when index fragmentation is between 10% to 40%. Index rebuilding process uses more CPU and it locks the database resources. SQL Server development version and Enterprise version has option ONLINE, which can be turned on when Index is rebuilt.... - [SQL SERVER - Enabling Clustered and Non-Clustered Indexes - Interesting Fact](https://blog.sqlauthority.com/2007/12/21/sql-server-enabling-clustered-and-non-clustered-indexes-interesting-fact/): While playing with Indexes I have found following interesting fact. I did some necessary tests to verify that it is true. When a clustered index is disabled, all the nonclustered indexes on the same tables are auto disabled as well. User do not need to disable non-clustered index separately. However, when clustered index is enabled, it does not automatically enable nonclustered index. All the nonclustered indexes needs to be enabled individually. I wondered if there is any short cut to enable all the indexes together. Index rebuilding came to my mind instantly. I ran T-SQL command of rebuilding all the indexes... - [SQL SERVER - DISTINCT Keyword Usage and Common Discussion](https://blog.sqlauthority.com/2007/12/20/sql-server-distinct-keyword-usage-and-common-discussion/): Jr. DBA asked me a day ago, how to apply DISTINCT keyword to only first column of SELECT. When asked for additional information about question, he showed me following query. SELECT Roles, FirstName, LastName FROM UserNames He wanted to apply DISTINCT to only Roles and not across FirstName and LastName. When he finished I realize that it is not possible and there is logical error in thinking query like that. I helped him with what he needed however, after he left I realize that answer to his original question was “NO”. Distinct can not be applied to only few columns it... - [SQL SERVER - Cumulative Update Package 5 for SQL Server 2005 Service Pack 2](https://blog.sqlauthority.com/2007/12/19/sql-server-cumulative-update-package-5-for-sql-server-2005-service-pack-2/): Microsoft SQL Server 2005 hotfixes are created for specific SQL Server service packs. You must apply a SQL Server 2005 Service Pack 2 hotfix to an installation of SQL Server 2005 Service Pack 2. By default, any hotfix that is provided in a SQL Server service pack is included in the next SQL Server service pack. Cumulative Update 5 contains hotfixes for SQL Server 2005 issues that have been fixed since the release of Service Pack 2. Latest Build 3215. Download Information Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - RML Utilities for SQL Server](https://blog.sqlauthority.com/2007/12/19/sqlauthority-news-rml-utilities-for-sql-server/): The RML utilities allow you to process SQL Server trace files and view reports showing how SQL Server is performing. For example, you can quickly see: Which application, database or login is using the most resources, and which queries are responsible for that Whether there were any plan changes for a batch during the time when the trace was captured and how each of those plans performed What queries are running slower in today’s data compared to a previous set of data Download RML Utilities for SQL Server (x86) Download RML Utilities for SQL Server (x64) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Get Information of Index of Tables and Indexed Columns](https://blog.sqlauthority.com/2007/12/18/sql-server-get-information-of-index-of-tables-and-indexed-columns/): Knowledge of T-SQL inbuilt functions and store procedure can save great amount of time for developers. Following is very simple store procedure which can display name of Indexes and the columns on which indexes are created. Very handy stored Procedure. USE AdventureWorks; GO EXEC sp_helpindex 'Person.Address' GO Above SP will return following information. IndexName – IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode Index_Description – nonclustered, unique located on PRIMARY Index_Keys – AddressLine1, AddressLine2, City, StateProvinceID, PostalCode Let me know if you think this kind of small tips are useful to you. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to Find Details About TempDB Information](https://blog.sqlauthority.com/2007/12/17/sql-server-t-sql-script-to-find-details-about-tempdb/): Two days ago I wrote an article about SQL SERVER - TempDB Restrictions - Temp Database Restrictions. Since then I have received few emails asking details about Temp DB. I use following T-SQL Script to know details about my TempDB. This script is a pretty old script but it does work great most of the time. I strongly encourage all of you to use a script to check your TempDB Information. - [SQL SERVER - Solution - Log File Very Large - Log Full](https://blog.sqlauthority.com/2007/12/16/sql-server-solution-log-file-very-large-log-full/): I have been receiving following question again and again either through email or through comments on this blog. My log file is too big, what should I do? Answer to this question is in three steps. Backup the log file to any device. Truncate the log file. Shrink the log file. I have previously written two article about this issue. Refer them for additional information and details. SQL SERVER – Shrinking Truncate Log File – Log Full(Script) SQL SERVER – Shrinking Truncate Log File – Log Full – Part 2(Management Studio) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - TempDB Restrictions - Temp Database Restrictions](https://blog.sqlauthority.com/2007/12/15/sql-server-tempdb-restrictions-temp-database-restrictions/): While conducting Interview for my outsourcing project, I asked one question to interviewer that what are the restrictions on TempDB? The candidate was not able to answer the question. I thought it would be good for all my readers to know the answer to this question so if you face this question in an interview or if you meet me in the interview you will be able to answer this question. - [SQLAuthority News - Top 10 Tips for Successful Software Outsourcing](https://blog.sqlauthority.com/2007/12/14/sqlauthority-news-top-10-tips-for-successful-software-outsourcing/): Few days ago, I wrote article about SQLAuthority Author Visit – IT Outsourcing to India – Top 10 Reasons Companies Outsource. I received quite a few emails regarding this article. I was really impressed that how much vendors care about their reputation and their client. I received so many requests from my blog readers who are interested in learning how to be successful at Software Outsourcing. I decided to write top 10 tips for the same. I have not described them in depth as they are pretty self explanatory. Define the scope of project clearly and as much as detail it... - [SQL SERVER - Do Not Store Images in Database - Store Location of Images (URL)](https://blog.sqlauthority.com/2007/12/13/sql-server-do-not-store-images-in-database-store-location-of-images-url/): Just a day ago I received phone call from my friend in Bangalore. He asked me What do I think of storing images in database and what kind of datatype he should use? I have very strong opinion about this issue. I suggest to store the location of the images in the database using VARCHAR datatype instead of any BLOB or other binary datatype. Storing the database location reduces the size of database greatly as well updating or replacing the image are much simpler as it is just an file operation instead of massive update/insert/delete in database. Reference : Pinal Dave... - [SQL SERVER - White Papers: Migration from Oracle Sybase, or Microsoft Access to Microsoft SQL Server](https://blog.sqlauthority.com/2007/12/12/sql-server-white-papers-migration-from-oracle-sybase-or-microsoft-access-to-microsoft-sql-server/): Guide to Migrating from Oracle to SQL Server 2005 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2005. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. The entire migration process using SQL Server Migration Assistant for Oracle (SSMA Oracle) is explained in depth, with a special focus on converting database objects and PL/SQL code. Guide to Migrating from Sybase ASE to SQL Server 2005 This white paper covers known issues for migrating Sybase Adaptive Server Enterprise database to SQL Server... - [SQL SERVER - Microsoft Synchronization Services for ADO.NET v2.0 CTP1 Refresh](https://blog.sqlauthority.com/2007/12/11/sql-server-microsoft-synchronization-services-for-adonet-v20-ctp1-refresh/): Microsoft Synchronization Services for ADO.NET provides the ability to synchronize data from disparate sources over two-tier, N-tier, and service-based architectures. Rather than simply replicating a database and its schema, the Synchronization Services application programming interface (API) provides a set of components to synchronize data between data services and a local store. Applications are increasingly used on mobile clients, such as laptops and devices, that do not have a consistent or reliable network connection to a central server. It is crucial for these applications to work against a local copy of data on the client. Equally important is the need to synchronize... - [SQLAuthority News - Microsoft SQL Server 2008 Community Technology Preview (November 2007) VHD](https://blog.sqlauthority.com/2007/12/10/sqlauthority-news-microsoft-sql-server-2008-community-technology-preview-november-2007-vhd/): SQL Server 2008, the next release of Microsoft SQL Server, will provide a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with relevant insights. This download comes as a pre-configured VHD. This allows you to trial SQL Server 2008 CTP in a virtual environment. Download from here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ACID (Atomicity, Consistency, Isolation, Durability)](https://blog.sqlauthority.com/2007/12/09/sql-server-acid-atomicity-consistency-isolation-durability/): ACID (an acronym for Atomicity Consistency Isolation Durability) is a concept that Database Professionals generally look for when evaluating databases and application architectures. For a reliable database all this four attributes should be achieved. - [SQL SERVER - Generic Architecture Image](https://blog.sqlauthority.com/2007/12/08/sql-server-generic-architecture-image/): Just a day ago, while I was surfing Wikipedia about SQL Server, I came across this generic architecture image. I found it interesting. Click on image to view it in large size. The physical structure of the database is divided into the MDF and LDF. The part of MDF contains file group, data files, tables and indexes, extended and page. The LDF file contains a transaction log file. The physical architecture is about how the data is actually stored in the file system. Page, extend, database files are physical architecture. - [SQL SERVER - FIX : Error : 3702 Cannot drop database because it is currently in use.](https://blog.sqlauthority.com/2007/12/07/sql-server-fix-error-3702-cannot-drop-database-because-it-is-currently-in-use/): Msg 3702, Level 16, State 3, Line 2 Cannot drop database “DataBaseName” because it is currently in use. This is a very generic error when DROP Database is command is executed and the database is not dropped. The common mistake user is kept the connection open with this database and trying to drop the database. The following commands will raise above error: USE AdventureWorks; GO DROP DATABASE AdventureWorks; GO Fix/Workaround/Solution: The following commands will not raise an error and successfully drop the database: USE Master; GO DROP DATABASE AdventureWorks; GO If you want to drop the database use master database first... - [SQL SERVER - 2005 - Dynamic Management Views (DMV) and Dynamic Management Functions (DMF)](https://blog.sqlauthority.com/2007/12/06/sql-server-2005-dynamic-management-views-dmv-and-dynamic-management-functions-dmf/): Dynamic Management Views (DMV) and Dynamic Management Functions (DMF) return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance. They can exactly tell what is going on with SQL Server and its objects at the moment.There are tow kinds of DMVs and DMFs. Server-scoped dynamic management views and functions. Database-scoped dynamic management views and functions. All dynamic management views and functions exist in the sys schema and follow this naming convention dm_*. When you use a dynamic management view or function, you must prefix the name of the view or... - [SQL SERVER - UDF - Remove Duplicate Chars From String](https://blog.sqlauthority.com/2007/12/05/sql-server-udf-remove-duplicate-chars-from-string/): Few days ago, I received following wonderful UDF from one of this blog reader. This UDF is written for specific purpose of removing duplicate chars string from one large string. Virendra Chauhan, author of this UDF is working as DBA in Lutheran Health Network. CREATE FUNCTION dbo.REMOVE_DUPLICATE_INSTR (@datalen_tocheck INT,@string VARCHAR(255)) RETURNS VARCHAR(255) AS BEGIN DECLARE @str VARCHAR(255) DECLARE @count INT DECLARE @start INT DECLARE @result VARCHAR(255) DECLARE @end INT SET @start=1 SET @end=@datalen_tocheck SET @count=@datalen_tocheck SET @str = @string WHILE (@count <=255) BEGIN IF (@result IS NULL) BEGIN SET @result='' END SET @result=@result+SUBSTRING(@str,@start,@end) SET @str=REPLACE(@str,SUBSTRING(@str,@start,@end),'') SET @count=@count+@datalen_tocheck END RETURN @result END... - [SQLAuthority Author Visit - IT Outsourcing to India - Top 10 Reasons Companies Outsource](https://blog.sqlauthority.com/2007/12/04/sqlauthority-author-visit-it-outsourcing-to-india-top-10-reasons-companies-outsource/): Yesterday I had meeting with few of the leading outsourcing companies in Ahmedabad, India. Regular readers of this blog knows that I am currently in India handling large scale outsourcing assignment. My responsibilities includes managing application development, system architecture and database architecture. The purpose of meeting was to exchange the views and learn methodologies from one another regarding how to provide quality service to offshore clients. There were about 10-15 Sr. Managers from different outsourcing company. The conversation was excellent and we all felt that we have learned a lot from each other. Two major things discussed were quality of products... - [SQL SERVER - Grouping JOIN Clauses In SQL](https://blog.sqlauthority.com/2007/12/03/sql-server-grouping-join-clauses-in-sql/): I always enjoy writing and reading articles about JOIN Clauses. One of my friend and the best ColdFusion Expert Ben Nadel has written good article about SQL JOINs. There are few interesting comments as well at the end of article. “JOIN grouping is pretty powerful and can get you out of those sticky situations that involve mixed table relationship rules. ” Ben Nadel – Grouping JOIN Clauses In SQL Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Q and A with Database Administrators](https://blog.sqlauthority.com/2007/12/02/sql-server-qa-with-database-administrators/): I have been in India for more than a month now, as I am leading a very large outsourcing project. We have conducted few interviews since the project required more Database Administrators and Senior Developers. I am listing few of the questions discussed during all the interviews. The whole event of interviews was very interesting. I met some very good programmers from all over the country. Many interesting questions were discussed between interviewers and candidates. I am listing some of those questions here. Some are technical and some are just my personal opinions. I will appreciate your thought about this article.... - [SQL SERVER - Sharpen Your Skills: Brush up on FILLFACTOR, ISNULL, NULLIF, and % as wildcard and operator](https://blog.sqlauthority.com/2007/12/01/sql-server-sharpen-your-skills-brush-up-on-fillfactor-isnull-nullif-and-as-wildcard-and-operator/): Read my article in SQL Server Magazine December 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download SQL Server 2005 Books Online (September 2007)](https://blog.sqlauthority.com/2007/11/30/sqlauthority-news-download-sql-server-2005-books-online-september-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The September 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - Database Interview Questions and Answers Complete List](https://blog.sqlauthority.com/2007/11/29/sql-server-database-interview-questions-and-answers-complete-list/): Update: I have updated this article series and newly updated article series is over here. If you are subscribed to my blog you will know that I receive request to send Database or SQL Server very frequently. Following is list of articles of my questions and answers series. Download SQL Server Interview Questions and Answers Complete List Complete Series of SQL Server Interview Questions and Answers SQL Server Interview Questions and Answers – Introduction SQL Server Interview Questions and Answers – Part 1 SQL Server Interview Questions and Answers – Part 2 SQL Server Interview Questions and Answers – Part 3... - [SQL SERVER - Correct Syntax for Stored Procedure SP](https://blog.sqlauthority.com/2007/11/28/sql-server-correct-syntax-for-stored-procedure-sp/): Just a day ago, I received interesting question about correct syntax for Stored Procedure. Many readers of this blog will think that it is very simple question. The reason this is interesting is the question behavior of BEGIN … END statements and GO command in Stored Procedure. Let us first see what is correct syntax. Correct Syntax: CREATE PROCEDURE usp_SelectRecord AS BEGIN SELECT * FROM TABLE END GO I have seen many new developers write statements after END statement. This will not work but will probably execute first fine when stored procedure is created. Rule is anything between BEGIN and END... - [SQL SERVER - 2005 - List All Stored Procedure in Database](https://blog.sqlauthority.com/2007/11/27/sql-server-2005-list-all-stored-procedure-in-database/): Run following simple script on SQL Server 2005 to retrieve all stored procedure in database. SELECT * FROM sys.procedures; This will ONLY work with SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Rules of Third Normal Form and Normalization Advantage - 3NF](https://blog.sqlauthority.com/2007/11/26/sql-server-rules-of-third-normal-form-and-normalization-advantage-3nf/): I always ask question about Third Normal Form in interviews I take. Q. What is Third Normal Form and what is its advantage? A. Third Normal Form (3NF) is most preferable normal form in RDBMS. Normalization is the process of designing a data model to efficiently store data in a database. The rules of 3NF are mentioned here Make a separate table for each set of related attributes, and give each table a primary key. If an attribute depends on only part of a multi-valued key, remove it to a separate table If attributes do not contribute to a description of... - [SQLAuthority News - SQL Server Compact 3.5 Downloads and ReportViewer Visual Studio Download](https://blog.sqlauthority.com/2007/11/25/sqlauthority-news-sql-server-compact-35-downloads-and-reportviewer-visual-studio-download/): SQL Server Compact 3.5 Books Online and Samples SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the Books Online and Samples for SQL Server Compact 3.5 SQL Server Compact 3.5 for Windows Mobile SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the CAB files and DLL’s that are used to install SQL Server Compact 3.5 on the Windows Mobile Devices platform SQL Server... - [SQL SERVER - Upgrade Advise - From 2000 to 2005 or 2008](https://blog.sqlauthority.com/2007/11/24/sql-server-upgrade-advise-from-2000-to-2005-or-2008/): There has some good amount of discussion going on in SQL Server community about should we upgrade from SQL Server 2000 to SQL Server 2005 or wait for SQL Server 2008. I have received quite a few email and invitations to participate in forums on this topic. Instead of talking about this topic on different places, I have decided to write my opinion on my blog. I recommend to upgrade to SQL Server 2000 users to SQL Server 2005. SQL Server 2008 is due next year. The RTM may or may not be available till February 2008. After the release the... - [SQL SERVER - 2008 - November CPT5 New Improvement](https://blog.sqlauthority.com/2007/11/23/sql-server-2008-november-cpt5-new-improvement/): The progress map of SQL Server 2008 is diagrammatically listed here. I am listing the new improvements here as list. Data Collection and Performance Warehouse for Relational Engine Service Broker Enhancements Registered Servers Enhancements Synchronous net-changes change tracking for SQL Server T-SQL IntelliSense Declarative Management Framework (DMF) Enhancements Geo-spatial Support Analysis Services Query and Writeback Performance Robust Report Server Platform Integration Services – Lookup Enhancements Analysis Services MDX Query Optimizer – Block Computation Analysis Services Aggregation Design Analysis Services Cube Design Reporting Services Scale Engine Transparent Data Encryption Resource Governor – Limit Specification Backup Compression Plan Freezing Fully Parallel Plans Scale... - [SQL SERVER - Shrinking Truncate Log File - Log Full - Part 2](https://blog.sqlauthority.com/2007/11/22/sql-server-shrinking-truncate-log-file-log-full-part-2/): About a year ago, I wrote SQL SERVER - Shrinking Truncate Log File - Log Full. I was just going through some of the earlier posts and comments. - [SQL SERVER - Generate Incremented Linear Number Sequence](https://blog.sqlauthority.com/2007/11/21/sql-server-generate-incremented-linear-number-sequence/): Just a day ago, I received interesting question on this blog. Read original question here. This is very good question and after reading this question I quickly wrote small script as answer. Let us see the question and answer together. Q. How can we generate incremented linear number in sql server as in oracle we generate in via sequence? - [SQL SERVER - Sharpen Your Skills: Joins, Groupings, and Data Types](https://blog.sqlauthority.com/2007/11/20/sql-server-sharpen-your-skills-joins-groupings-and-data-types/): Read my article in SQL Server Magazine November 2007 Edition [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server 2008 Community Technology Preview (CTP) Download Now Available](https://blog.sqlauthority.com/2007/11/19/sqlauthority-news-sql-server-2008-community-technoloypreview-ctp-download-now-available/): Download the latest SQL Server 2008 Community Technology Preview (CTP) and try out the latest features of SQL Server 2008! The SQL Server development team uses your CTP feedback to help refine and enhance product features. Download it today and send your feedback. Microsoft SQL Server 2008, the next release of Microsoft SQL Server, provides a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with... - [SQLAuthority News - Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide - SQL Server, ColdFusion, ASP.NET](https://blog.sqlauthority.com/2007/11/18/sqlauthority-news-job-opportunity-in-ahmedabad-india-to-work-with-technology-leaders-worldwide-sql-server-coldfusion-aspnet/): If you have one or more years of experience in any web based programming language (.NET, ColdFusion, PHP) and interested in SQL Server as well willing to locate Ahmadabad, India. Please send me your resume, if selected you may get chance to work with one of the most progressing industry in world as well some smartest technology leaders worldwide. Salary depends on Experience. If selected for interview I suggest you go over SQL Server Interview Questions and Answers Complete List Download, as there is great chance I may be participating in interview. Please send your resume at pinaldave “at” yahoo.com and... - [SQL SERVER - 2005 - Best Practices for SQL Server Health Check](https://blog.sqlauthority.com/2007/11/17/sql-server-2005-best-practices-for-sql-server-health-check/): Here are few of the best practices one should follow for SQL Server Health Check. - [SQL SERVER - Generate Script with Data from Database - Database Publishing Wizard](https://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/): I really enjoyed writing about SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects. Since then the I have received question that how to copy data as well along with schema. The answer to this is Database Publishing Wizard. This wizard is very flexible and works with modes like schema only, data only or both. It generates a single SQL script file which can be used to recreate the contents of a database by manually executing the script on a target server. - [SQLAuthority News - Microsoft SQL Server 2005 Assessment Configuration Pack Download](https://blog.sqlauthority.com/2007/11/15/sqlauthority-news-microsoft-sql-server-2005-assessment-configuration-pack-download/): Microsoft SQL Server 2005 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Gramm-Leach Bliley Act compliance efforts Microsoft SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Database Dilbert](https://blog.sqlauthority.com/2007/11/14/sqlauthority-news-sql-joke-sql-humor-sql-laugh-database-dilbert/): This is my favorite Dilbert. Dilbert is an American comic strip written and illustrated by Scott Adams, first published in the year 1969. - [SQLAuthority News - Microsoft SQL Server 2005 MSIT Three Configuration Pack for Configuration Manager 2007](https://blog.sqlauthority.com/2007/11/14/sqlauthority-news-microsoft-sql-server-2005-msit-three-configuration-pack-for-configuration-manager-2007/): Microsoft SQL Server 2005 MSIT Basic Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2005 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2005 MSIT Intermediate Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2005 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2005 MSIT Comprehensive Configuration Pack for Configuration Manager 2007 This... - [SQL SERVER - DBCC CHECKDB Introduction and Explanation - DBCC CHECKDB Errors Solution](https://blog.sqlauthority.com/2007/11/13/sql-server-dbcc-checkdb-introduction-and-explanation-dbcc-checkdb-errors-solution/): DBCC CHECKDB checks the logical and physical integrity of all the objects in the specified database. If DBCC CHECKDB ran on database user should not run DBCC CHECKALLOC, DBCC CHECKTABLE, and DBCC CHECKCATALOG on database as DBCC CHECKDB includes all the three command. Usage of these included DBCC commands is listed below. - [SQL SERVER - FIX : ERROR Msg 1803 The CREATE DATABASE statement failed. The primary file must be at least 2 MB to accommodate a copy of the model database](https://blog.sqlauthority.com/2007/11/12/sql-server-fix-error-msg-1803-the-create-database-statement-failed-the-primary-file-must-be-at-least-2-mb-to-accommodate-a-copy-of-the-model-database/): Following error occurs when database which is attempted to be created is smaller than Model Database. It is must that all the databases are larger than Model database and 512KB. Following code will create the error discussed in this post. CREATE DATABASE Tests ON ( NAME = 'Tests', FILENAME = 'c:\tests.mdf', SIZE = 512KB ) GO Msg 1803, Level 16, State 1, Line 1 The CREATE DATABASE statement failed. The primary file must be at least 2 MB to accommodate a copy of the model database. Fix/WorkAround/Solution : Create database which is larger than Model database and 512KB. Size of the... - [SQLAuthority News - The Equations of Relativist](https://blog.sqlauthority.com/2007/11/12/sqlauthority-news-the-equations-of-relativist/): F = mg ….. Galileo F = ma ….. Newton E = mc²….. Einstein Reference : Pinal Dave (https://blog.sqlauthority.com) , Great Site – relationary) - [SQL SERVER - FIX : ERROR Msg 5174 Each file size must be greater than or equal to 512 KB](https://blog.sqlauthority.com/2007/11/12/sql-server-fix-error-msg-5174-each-file-size-must-be-greater-than-or-equal-to-512-kb/): Following error occurs when database which is attempted to be created is smaller than 512KB. It is must that all the databases are larger than 512KB. It will also follow with another error 1802, which is due to previous error 5174. Following code will create the error discussed in this post. CREATE DATABASE Tests ON ( NAME = 'Tests', FILENAME = 'c:\tests.mdf', SIZE = 12KB ) GO Msg 5174, Level 16, State 1, Line 1 Each file size must be greater than or equal to 512 KB. Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names... - [SQLAuthority News - SQL Server 2005 Powers Global Forensic Data Security Tool](https://blog.sqlauthority.com/2007/11/11/sqlauthority-news-sql-server-2005-powers-global-forensic-data-security-tool/): Note :  Download Whitepaper by Microsoft Find out how SQL Server 2005 powers a 27 TB data management system called ICE 3.0 that gathers forensic data from more than 85 Microsoft corporate proxy servers into a single database. The Information Security team at Microsoft uses an internal tool called Information Security Consolidated Event Management (ICE 3.0) to gather forensic data from more than 85 proxy servers around the world. Powered by SQL Server 2005, the 27 TB data management system collects different types of global evidence, such as inbound and outbound e-mail traffic, Login events, and Web browsing, into a single... - [SQL SERVER - 2005 2000 - Search String in Stored Procedure](https://blog.sqlauthority.com/2007/11/10/sql-server-2005-2000-search-string-in-stored-procedure/): SQL Server has released SQL Server 2000 edition before 7 years and SQL Server 2005 edition before 2 years now. There are still few users who have not upgraded to SQL Server 2005 and they are waiting for SQL Server 2008 in February 2008 to SQL Server 2008 to release. This blog has is heavily visited by users from both the SQL Server products. I have two previous posts which demonstrate the code which can be searched string in stored procedure. Many users get confused with the script version and try to execute SQL Server 2005 version on SQL Server 2000,... - [SQL SERVER - Versions, CodeNames, Year of Release](https://blog.sqlauthority.com/2007/11/09/sql-server-versions-codenames-year-of-release/): Just a day ago, while I was discussing one of the project with another outsourcing team lead in India (who is leading team of 100+ programmer and developer) he asked me if I know all the codenames of the SQL Server releases so far. I knew only two code names SQL Server 2005 – Yukon and SQL Server 2008 – Katmai. Once our meeting was over, I could not stop thinking about this question. I search online and very easily I found answer to this question on wikipedia. 1993 – SQL Server 4.21 for Windows NT 1995 – SQL Server 6.0,... - [SQLAuthority News - Book Review - SQL Server 2005 Management and Administration (Paperback)](https://blog.sqlauthority.com/2007/11/08/sqlauthority-news-book-review-sql-server-2005-management-and-administration-paperback/): SQL Server 2005 Management and Administration (Paperback) by Ross Mistry (Author), Chris Amaris (Author), Alec Minty (Author), Rand Morimoto (Author) Link to Amazon Short Summary: SQL SERVER 2005 is a trusted database platform that provides organizations a competitive advantage by allowing them to obtain faster results and make better business decisions. This book covers all the topics which can help Database Administrators to be successful and effective. Detail summary: This book is covers all the topics and modules of the SQL Server 2005, e.g. database engine, Analysis Services, Integration Services, replication, Reporting Services, Notification Services, services broker and full text search.... - [SQLAuthority News - 1 Million Visitors in last 1 year - [Update 2019]](https://blog.sqlauthority.com/2007/11/07/sqlauthority-news-1-million-visitors-in-last-1-year-update-2019/): It is indeed a bit day for me. I am very happy that I have 1 million visitors in just last 1 year. Read my story of 365 days. - [SQLAuthority News - Microsoft Synchronization Services for ADO.NET v2.0 CTP1](https://blog.sqlauthority.com/2007/11/06/sqlauthority-news-microsoft-synchronization-services-for-adonet-v20-ctp1/): Microsoft Synchronization Services for ADO.NET provides the ability to synchronize data from disparate sources over two-tier, N-tier, and service-based architectures. Rather than simply replicating a database and its schema, the Synchronization Services application programming interface (API) provides a set of components to synchronize data between data services and a local store. Applications are increasingly used on mobile clients, such as laptops and devices, that do not have a consistent or reliable network connection to a central server. It is crucial for these applications to work against a local copy of data on the client. Equally important is the need to synchronize... - [SQLAuthority News - Few Add-ons for SQLAuthority](https://blog.sqlauthority.com/2007/11/05/sqlauthority-news-few-add-ons-for-sqlauthority/): SQL Random Article Find Post SQL Jobs Search SQLAuthority Subscribe Email Update SQLAuthority Feed My Other Blog Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Best Articles on SQLAuthority.com](https://blog.sqlauthority.com/2007/11/04/sqlauthority-news-best-articles-on-sqlauthoritycom/): SQL SERVER – Cursor to Kill All Process in Database SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored procedure SQL SERVER – Shrinking Truncate Log File – Log Full SQL SERVER – Simple Example of Cursor SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case SQL SERVER – Restore Database Backup using SQL Script (T-SQL) SQL SERVER – T-SQL Script to find the CD key from Registry SQL SERVER – Delete Duplicate Records – Rows SQL SERVER – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation SQL SERVER... - [SQLAuthority News - Best SQLAuthority Articles on Other Popular Sites](https://blog.sqlauthority.com/2007/11/03/sqlauthority-news-best-sqlauthority-articles-on-other-popular-sites/): Best SQLAuthority Articles on Other Popular Sites SQL SERVER – UDF vs. Stored Procedures and Having vs. WHERE (SQL Server Magazine) SQL SERVER – Pre-Code Review Tips – Tips For Enforcing Coding Standards (dotnetslackers.com) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Best Downloads on SQLAuthority.com](https://blog.sqlauthority.com/2007/11/02/sqlauthority-news-best-downloads-on-sqlauthoritycom/): Best Downloads on SQLAuthority.com SQL SERVER – Query Analyzer Shortcuts SQL Server Interview Questions and Answers Complete List Download SQL SERVER – Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts) SQL SERVER Database Coding Standards and Guidelines Complete List Download SQL SERVER – Data Warehousing Interview Questions and Answers Complete List Download Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - First Birthday of Blog - 365 Post in One Year](https://blog.sqlauthority.com/2007/11/01/sqlauthority-news-first-birthday-of-blog-365-post-in-one-year/): Hello Everyone, Today is birthday of this blog. Exactly one year ago, I started this journey of SQL Server and today I have reached first mile stone. There are so many great experience I had during this year. One thing I enjoyed the most is My Extremely Knowledgeable and Friendly Readers. I have learned a lot from all my readers, their emails and comments on this blog. You have been wonderful part of this blog. I was very surprised when I counted how many articles I had posted last year. It was perfect 365! One article a day!! Once again, I... - [SQL SERVER - Importance of Master Database for SQL Server Startup](https://blog.sqlauthority.com/2007/10/31/sql-server-importance-of-master-database-for-sql-server-startup/): I have received following questions. I will list all the questions here and answer them together. What is the purpose of Master database? - [SQL SERVER - Business Intelligence (BI) Basic Terms Explanation](https://blog.sqlauthority.com/2007/10/30/sql-server-business-intelligence-bi-basic-terms-explanation/): Business Intelligence Business intelligence is a method of storing and presenting key enterprise data so that anyone in your company can quickly and easily ask questions of accurate and timely data. Effective BI allows end users to use data to understand why your business go the particular results that it did, to decide on courses of action based on past data, and to accurately forecast future results. Data Warehouse A single structure that usually, but not always, consists of one or more cubes. Data Mart A defined subset of a data warehouse, often a single cube from a group. It represents... - [SQL SERVER - Disable All Triggers on a Database - Disable All Triggers on All Servers](https://blog.sqlauthority.com/2007/10/29/sql-server-disable-all-triggers-on-a-database-disable-all-triggers-on-all-servers/): Just a day ago, I received question in email regarding my article SQL SERVER – 2005 Disable Triggers – Drop Triggers. Question : How to disable all the triggers for database? Additionally, how to disable all the triggers for all servers? Answer: Disable all the triggers for a single database: USE AdventureWorks; GO DISABLE TRIGGER Person.uAddress ON AdventureWorks; GO Disable all the triggers for all servers: USE AdventureWorks; GO DISABLE TRIGGER ALL ON ALL SERVER; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL-Triggers - [SQL SERVER - Find Table in Every Database of SQL Server - Part 2 Extension](https://blog.sqlauthority.com/2008/05/05/sql-server-find-table-every-database-sql-server-part-2-extension/): Long time blog reader and SQL Server Expert Simon Worth has suggested two additional method to achieve same results as described in article SQL SERVER – Find Table in Every Database of SQL Server. Method 1 sp_msforeachdb "SELECT '?' DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE '%address%'" Method 2 CREATE TABLE #TableNameResults (DatabaseName VARCHAR(100) NOT NULL, TableName VARCHAR(100) NOT NULL) INSERT INTO #TableNameResults EXEC sp_msforeachdb "SELECT '?' DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE '%address%'" SELECT * FROM #TableNameResults DROP TABLE #TableNameResults Reference : Pinal Dave (https://blog.sqlauthority.com), Simon Worth - [SQL SERVER - 2000 - SQL SERVER - Delete Duplicate Records - Rows - Readers Contribution](https://blog.sqlauthority.com/2008/05/04/sql-server-2000-sql-server-delete-duplicate-records-rows-readers-contribution/): I am proud on readers of this blog. One of the reader asked asked question on article SQL SERVER – Delete Duplicate Records – Rows and another reader followed up with nice quick answer. Let us read them both together. - [SQL SERVER 2005 - Vista Ultimate and SQL Server 2005 DEV Edition](https://blog.sqlauthority.com/2008/05/03/sql-server-2005-vista-ultimate-and-sql-server-2005-dev-edition/): I have been asked many times before “Does SQL Server Dev edition can be installed on Vista operating system?” I decided to find out the answer of this myself. I have just got new system which has Vista Ultimate Installed on it. I installed SQL Server 2005 dev edition on it. While installing it suggested that there are few component will not work with Vista and to make them work make sure to install SQL Server 2005 SP2. I was any way planning to install that. Once installation of SQL Server 2005 over, I installed SQL Server 2005 SP2. After restart... - [SQL SERVER - How to Rename Database Objects to Comply With Naming Conventions](https://blog.sqlauthority.com/2008/05/02/sql-server-how-to-rename-database-objects-to-comply-with-naming-conventions/): Christopher Miller read article of SQL SERVER Database Coding Standards and Guidelines Complete List Download and came up with wonderful SQL Server Script to rename all their database constraint with more organized constraint names, which helps to easily identify the constraint database exist on. Christopher Miller – “When we submit our schema updates internally, we usually catch any deviation from our naming conventions.  It’s not a perfect process and every now and then, something slips through the cracks.  We then correct the schema update to use the appropriate naming convention.  if we have been using the schema changes internally, we may... - [SQLAuthority News - Write for SQLAuthority](https://blog.sqlauthority.com/2008/05/01/sqlauthority-news-write-for-sqlauthority/): I always enjoy writing for my readers. Many times, I receive very good note, comments or article from my great experts of SQL Server. I really enjoy learning from my reader. If you are reader of SQLAuthority and you think you have knowledge, script or concept which benefit other readers of this blog, please feel free to send that to me. I love sharing good article and knowledge with my readers. You do not have to be well known to write article, just something which can interest other fellow readers like you, will be good article for this blog. It will... - [SQL SERVER - Find Table in Every Database of SQL Server - Part 2](https://blog.sqlauthority.com/2008/04/30/sql-server-find-table-in-every-database-of-sql-server-part-2/): Yesterday I wrote about SQL SERVER – Find Table in Every Database of SQL Server. Today we will see another method how we can achieve the same result using Information_Schema view. Refer my previous article here for additional information. CREATE PROCEDURE usp_FindTableNameInAllDatabase @TableName VARCHAR(256) AS DECLARE @DBName VARCHAR(256) DECLARE @varSQL VARCHAR(512) DECLARE @getDBName CURSOR SET @getDBName = CURSOR FOR SELECT name FROM sys.databases CREATE TABLE #TmpTable (TABLE_CATALOG VARCHAR(128), TABLE_SCHEMA VARCHAR(128), TABLE_NAME VARCHAR(256), TABLE_TYPE VARCHAR(10)) OPEN @getDBName FETCH NEXT FROM @getDBName INTO @DBName WHILE @@FETCH_STATUS = 0 BEGIN SET @varSQL = 'USE ' + @DBName + '; INSERT INTO #TmpTable SELECT *... - [SQL SERVER - Find Table in Every Database of SQL Server](https://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/): Just a day ago, one of the Jr. Developer requested that if I can help her with finding one particular table in every database on SQL Server. We have many Database Server and on some of the Database Server we have nearly 200 databases on it. The requirement was to find out one particular table from all the database. This was not possible by visual inspection as it might take lots of time and human error was possible. She was aware of the system view sys.tables. SELECT * FROM sys.Tables WHERE name LIKE '%Address%' The limitation of query mentioned above is... - [SQL SERVER - Download FAQ Sheet - SQL Server in One Page](https://blog.sqlauthority.com/2008/04/28/sql-server-download-faq-sheet-sql-server-in-one-page/): One of the most popular request I have received on this blog is to create one page which list all the SQL Server FAQs. SQL Server technology is very broad as well very deep. This is my humble attempt to list few of the daily used details in one page. Let me know your opinion and suggestion. Download SQL Server FAQ Sheet in PDF format Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query Analyzer Shortcuts - Part 2](https://blog.sqlauthority.com/2008/04/27/sql-server-query-analyzer-shortcuts-part-2/): I enjoy reader’s articles to read as much as I enjoy expert’s articles. One of blog reader Praveen Barath always have good ideas to share. Here is Praveen Barath’s comment on my previous article Query Analyzer Shortcuts. MSSQL server 2005 is a database platform , Platform because from one window you can connect to any of MSSQL services like SSMS, SSRS,SSIS,SSAS..etc. I am coming to your doubt why they shifted to SSMS as it s far slow. As the matter of fact MSSQL 2005 is more graphical more user friendly and handy tool, I hope once you will aware of all... - [SQL SERVER - Optimization Rules of Thumb - Best Practices - Reader's Article](https://blog.sqlauthority.com/2008/04/26/sql-server-optimization-rules-of-thumb-best-practices-readers-article/): This article has been written by blog reader and SQL Server Expert Praveen Barath in response to my previous article SQL SERVER – Optimization Rules of Thumb – Best Practices. Well Query Optimizations rules are not limited. It depends on business needs as well, For example we always suggest to have a relationship between tables but if they are heavily used for Update insert delete, I personally don’t recommended coz it will effect performance as I mentioned it all depends on Business needs; Here are few more tips I hope will help you to understand. One: only “tune” SQL after code... - [SQL SERVER - Optimization Rules of Thumb - Best Practices](https://blog.sqlauthority.com/2008/04/25/sql-server-optimization-rules-of-thumb-best-practices/): There are few rules for optimizing slow running query. Let us look at them one by one see how it can help. Rule # 1 : Always look at query plan first. I always start looking at query plan. There is always something which catches eyes. I pay special attention to part which has taken the most expensive part of whole execution plan. Rule # 2 : Table scan or clustered index scan needs to be optimized to table seek (if your table is small it does not matter and table scan gives you better result). Table scan happens when index... - [SQLAuthority News - Authors Personal Bookmarks](https://blog.sqlauthority.com/2008/04/25/sqlauthority-news-authors-personal-bookmarks/): Just like everybody else I also keep my personal bookmarks of websites. Recently I have reorganized my bookmarks in two categories. Please visit them and let me know your opinion. SQLAuthority BEST Articles SQLAuthority FAVORITE Articles Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Microsoft Office Visio 2007 Professional SQL Server Add-In](https://blog.sqlauthority.com/2008/04/24/sqlauthority-news-download-microsoft-office-visio-2007-professional-sql-server-add-in/): Note : Download Microsoft Office Visio 2007 Professional SQL Server Add-In by Microsoft Visio Infrastructure for SQL Servers is a tool which is meant for IT administrators who require constant interactions with the users for the installations of the SQL server in any IT infrastructure. Visio Infrastructure for SQL Servers is a tool which is meant for IT administrators who require constant interactions with the users for the installations of the SQL server in any IT infrastructure. This tool eases the constant communication between the end user and the administrator where administrators will have a ready to install visual representation of... - [SQL SERVER - Converting Subqueries to Joins](https://blog.sqlauthority.com/2008/04/23/sql-server-converting-subqueries-to-joins/): There is always more than one way to do one thing in any programming languages. In SQL Server there is always more than one way to achieve same result set. It is quite often I see that developers write subqueries in place of joins or joins in place subqueries. - [SQL SERVER - Join Better Performance - LEFT JOIN or NOT IN?](https://blog.sqlauthority.com/2008/04/22/sql-server-better-performance-left-join-or-not-in/): First of all answer this question : Which method of T-SQL is better for performance LEFT JOIN or NOT IN when writing a query? The answer is: It depends! It all depends on what kind of data is and what kind query it is etc. In that case just for fun guess one option LEFT JOIN or NOT IN. If you need to refer the query which demonstrates the mentioned clauses, review following two queries for Join Better Performance. - [SQL SERVER - 2008 - Update Resolving Conflict Between SQL Server 2005 and SQL Server 2008](https://blog.sqlauthority.com/2008/04/21/sql-server-2008-update-resolving-conflict-between-sql-server-2005-and-sql-server-2008/): I have been receiving many complains where user has installed SQL Server 2008 and when trying to install SQL Server 2005 after that installation never completed. Well, Microsoft has provided solution for this issue. Download the patch and install it first and then try to install SQL Server 2005 and it should install fine. Update for Windows Server 2008 for Itanium-based Systems (KB950636) Install this update to resolve an issue where SQL Server 2005 installation is not completed successfully on a system running Windows Server 2008. Update for Windows Server 2008 x64 Edition (KB950636) Install this update to resolve an issue... - [SQL SERVER - Identifiers As Valid Object Names](https://blog.sqlauthority.com/2008/04/20/sql-server-identifiers-as-valid-object-names/): Previous I wrote blog post about SQL SERVER – Explanation and Example Four Part Name. It was explaining the new feature of SQL Server 2005 of Schema. Few days ago I received email from Chi-Ho, Min of Taiwan, he suggested that he was successfully able to use column without completely specifying all the parts but just using servername…tablename. Please note the three dots (.) between servername and table. It was interesting what Chi-Ho observed so I decided to share with all of you. Please visit SQL SERVER – Explanation and Example Four Part Name for basic understanding of the four part... - [SQL SERVER - Is Cursor Database Object or Datatype?](https://blog.sqlauthority.com/2008/04/19/sql-server-is-cursor-database-object-or-datatype/): Whenever we want to loop something we always look for logic like WHILE LOOP or FOR LOOP. Trust me on my word that both of them are cursor when it is about SQL Server. - [SQL SERVER - Generate Foreign Key Scripts For Database](https://blog.sqlauthority.com/2008/04/18/sql-server-generate-foreign-key-scripts-for-database/): Regular reader of SQLAuthority.com blog Madhaiyan Seenivasan has send email with one very interesting script. This script generates all the foreign key addition script for your database. Many times there are situations where one need to drop all the foreign key and add them back. This SQL Script can be used for the same purpose. You can execute the SP by executing its name like EXEC DBO.SPGetForeignKeyInfo IF EXISTS ( SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[SPGetForeignKeyInfo]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) DROP PROCEDURE dbo.SPGetForeignKeyInfo GO CREATE PROCEDURE DBO.SPGetForeignKeyInfo AS /* Author : Seenivasan This procedure is used for Generating Foreign Key script. */ SET NOCOUNT ON DECLARE @FKName NVARCHAR(128) DECLARE @FKColumnName NVARCHAR(128)... - [SQLAuthority News - My Favorite Link of This Blog](https://blog.sqlauthority.com/2008/04/17/sqlauthority-news-my-favorite-link-of-this-blog/): I have written more than 500 article on this blog so far and the number is increasing. Many times I get this question, which one link do I click the most. It is very interesting for myself to read my previous articles, as I often like to read them and update it if I am missing anything or post a follow up articles or post a answer to any question in comment. There is no simple pattern for me to read my previous article. I like the random article of my blog. I use following link which send me to random... - [SQL SERVER - 2008 - Row Constructors - Load Temp Tables From Stored Procedures](https://blog.sqlauthority.com/2008/04/16/sql-server-2008-row-constructors-load-temp-tables-from-stored-procedures/): While playing with SQL Server 2008 I found new feature of “Row Constructors”, where I can load temp table from stored procedure directly. Look at the following SQL where I have to use OpenQuery from server to itself creating loopback server and execute stored procedure and insert into temp table. INSERT INTO #TempTable SELECT * FROM OPENQUERY(ServerName, 'exec StoredProc') Above mentioned same query can be now written with simpler statement as described here. INSERT INTO #TempTable EXEC StoredProc Note that this does not work with real tables or any other objects. This feature is only available to load temp tables. Reference... - [SQL SERVER - Surface Area Configuration Tools Reduce Exposure To Security Risks](https://blog.sqlauthority.com/2008/04/15/sql-server-surface-area-configuration-tools-reduce-exposure-to-security-risks/): Read my article published at SQL Server Magazine Surface Area Configuration Tools Reduce Exposure To Security Risks [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Slammer (Computer Worm)](https://blog.sqlauthority.com/2008/04/14/sql-server-sql-slammer-computer-worm/): Just a day ago, while talking with my outsourcing team one of the DBA asked me question. Is there any virus associated with SQL Server? I really find this question very interesting as I did not know if there are any viruses associated with SQL Server. I searched Google for this answer and I found link on wikipedia about SQL slammer, which is computer worm. Following excerpt is taken from wikipedia : The SQL slammer worm is a computer worm that caused a denial of service on some Internet hosts and dramatically slowed down general Internet traffic, starting at 05:30 UTC... - [SQL SERVER - 2008 - Important Resources](https://blog.sqlauthority.com/2008/04/13/sql-server-2008-important-resources/): In one of the recent public speaking event I was asked if I can list some important resources of SQL Server 2008. I promised that I will post the links on my blog. Here are Important Resources for SQL Server 2008. Learn more about data programmability http://www.microsoft.com/sql/2008/technologies/dataprogrammability.mspx Learn more about spatial data http://www.microsoft.com/sql/2008/technologies/spatial.mspx Learn more about SQL Server 2008 http://www.microsoft.com/sql/2008/default.mspx Discover SQL Server 2008: Webcasts, Virtual Labs, and White Papers http://www.microsoft.com/sql/2008/learning/default.mspx SQL Server 2008 training http://www.microsoft.com/learning/sql/2008/default.mspx Download latest SQL Server CTP http://www.microsoft.com/sql/2008/prodinfo/download.mspx Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Download Presentation and Whitepapers](https://blog.sqlauthority.com/2008/04/12/sql-server-2008-download-presentation-and-whitepapers/): SQL Server 2008 Manageability Learn about the new manageability improvements in SQL server 2008 that enables you to administer, monitor and maintain your data platform infrastructure while reducing the time and cost of management. This session provides an overview of the new manageability improvements that enables you to manage the infrastructure with policies, monitor and optimize your platform with insights and relevant information and scale your management across multiple servers. SQL Server 2008 Business Intelligence platform Learn how the new enhancements in SQL server 2008 provide a comprehensive and scalable Business Intelligence platform that enables you to integrate and manage your... - [SQL SERVER - 2005 - Find Database Collation Using T-SQL and SSMS - Part 2](https://blog.sqlauthority.com/2008/04/11/sql-server-2005-find-database-collation-using-t-sql-and-ssms-part-2/): Previously I have written two different ways to find database collation SQL SERVER – 2005 – Find Database Collation Using T-SQL and SSMS. One of blog reader jwwishart has posted another method for doing the same. SELECT collation_name FROM sys.databases WHERE name = 'AdventureWorks' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Restore Database Using Corrupt Datafiles (.mdf and .ldf) - Part 2](https://blog.sqlauthority.com/2008/04/10/sql-server-2005-restore-database-using-corrupt-datafiles-mdf-and-ldf-part-2/): Blog reader Donald Crowther has posted following comment. I have not tested this solution and when I tried to test it, it did not work for me. However, I have received email from two of my Jr. DBA who have done experiment about this and they are suggesting it works. If you have tried everything and you have given up to find solution. Try following suggestion. Make sure you have taken backup of your physical file and also this exercise you do at your own risk. ALTER DATABASE test SET emergency GO ALTER DATABASE test SET single_user GO DBCC checkdb (test,... - [SQL SERVER - 2005 - Connection Strings For .NET](https://blog.sqlauthority.com/2008/04/09/sql-server-2005-connection-strings-for-net/): SQL Native Client ODBC Driver Standard security Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Uid=myUsername;Pwd=myPassword; Trusted Connection Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes; Connecting to an SQL Server instance Driver={SQL Native Client};Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes; SQL Native Client OLE DB Provider Standard security Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase; Uid=myUsername;Pwd=myPassword; Trusted connection Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes; Connecting to an SQL Server instance Provider=SQLNCLI;Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes; SqlConnection (.NET) Standard Security Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; Trusted Connection Server=myServerAddress;Database=myDataBase;Trusted_Connection=True; Connecting to an SQL Server instance Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=True; Connecting to an SQL Server instance via an IP address Data Source=192.168.1.100,1433;Network Library=DBMSSOCN; Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword; Reference : Pinal Dave (https://blog.sqlauthority.com), ConnectionStrings - [SQL SERVER - Change Order of Column In Database Tables](https://blog.sqlauthority.com/2008/04/08/sql-server-change-order-of-column-in-database-tables/): One question I received quite often. How to change the order of the column in database table? It happens many times table with few columns is already created. After a while there is need to add new column to the previously existing table. Sometime it makes sense to add new column in middle of columns at specific places. There is no direct way to do this in SQL Server currently. Many users want to know if there is any workaround or solution to this situation. First of all, If there is any application which depends on the order of column it... - [SQL SERVER - 2005 - Restore Database Using Corrupt Datafiles (.mdf and .ldf)](https://blog.sqlauthority.com/2008/04/07/sql-server-2005-restore-database-using-corrupt-datafiles-mdf-and-ldf/): Just received question from one of the DBA Question: I do not have full backup of my database. My .mdf and .ldf are corrupted. Is there any way I can restore database now? Answer: Sorry. I do not think there is any way you can do it. Try attaching this files to database using db_attach but if that does not work, it will be very difficult make it work. If any of blog reader know fix for this, please post here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 15 Best Practices for Better Database Performance](https://blog.sqlauthority.com/2008/04/06/sql-server-15-best-practices-for-better-database-performance/): In this blog post we will see 15 best practices for better Database Performance. - [SQL SERVER - 2005 - Transferring Ownership of a Schema to a User](https://blog.sqlauthority.com/2008/04/05/sql-server-2005-transferring-ownership-of-a-schema-to-a-user/): One of the blog reader asked me how transfer of ownership of schema to another users. Follow the simple script and you will be able to transfer ownership of schema to another user. ALTER AUTHORIZATION ON SCHEMA::SchemaName TO UserName; GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL Server - Good Articles on Database Collation](https://blog.sqlauthority.com/2008/04/04/sql-server-good-articles-collation-databases/): I often get asked what is Database Collation in SQL Server and if there are some good articles related to Collation. Here are some articles. - [SQLAuthority News - Learn New Things - Self Criticism](https://blog.sqlauthority.com/2008/04/03/sqlauthority-news-learn-new-things-self-criticism/): I came across two interesting web pages and I really thought they had very good articles. I would like to share that with my blog readers today. I am just listing the abstract here. Please read the original articles they are much more interesting and enjoyable. Readers if you find any interesting site like this, let me know and I will write about it. 10 Ways to Learn New Things in Development 1. Read books. 2. Read Code 3. Write Code 4. Talk to other developers 5. Teach others 6. Listen to podcasts 7. Read blogs 8. Learn a new language... - [SQL SERVER - Find Nth Highest Salary of Employee - Query to Retrieve the Nth Maximum value](https://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/): This question is quite a popular question and it is interesting that I have been receiving this question every other day. I have already answer this question here. “How to find Nth Highest Salary of Employee”. Please read my article here to find Nth Highest Salary of Employee table : SQL SERVER – Query to Retrieve the Nth Maximum value I have re-wrote the same article here with example of SQL Server 2005 Database AdventureWorks : SQL SERVER – 2005 – Find Nth Highest Record from Database Table Just a day ago, I have received another script to get the same... - [SQL SERVER - Microsoft SQL Server 2000/2005 Management Pack Download](https://blog.sqlauthority.com/2008/04/01/sql-server-microsoft-sql-server-20002005-management-pack-download/): The SQL Server Management Pack monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems. Availability and performance monitoring is done using synthetic transactions. In addition, the Management Pack collects Event Log alerts and provides associated knowledge articles with additional user details, possible causes, and suggested resolutions. The Management Pack discovers Database Engines, Database Instances, and Databases and can optionally discover Database File and Database File Group objects. Feature Summary: • Active Directory Helper Service • SQL Server Agent • Backup • Databases and Tables • DBCC • Full Text Search • Log... - [SQL SERVER - Popular Articles of SQLAuthority Blog](https://blog.sqlauthority.com/2008/03/31/sql-server-popular-articles-of-sqlauthority-blog/): I receive this email quite often that which are most popular articles on my blog. There is already list on right navigation bar of my weekly popular article. If you are interested to know which are most popular articles as per readers and my opinion here are two listed. SQL SERVER Database Coding Standards and Guidelines Complete List Download SQL Server Interview Questions and Answers Complete List Download Let me know which articles is your favorite article on this blog. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Heap Structure - What is Heap?](https://blog.sqlauthority.com/2008/03/30/sql-server-introduction-to-heap-structure-what-is-heap/): Sometime simple questions are very interesting. A day ago, jr. developer asked me question : What is Heap? In SQL Server 2005 data is stored within tables. Data within a table is grouped together into allocation unites based on their column data types, what it means is one kind of data types are stored together in allocation unites. Data within this allocation unit is stored in pages. Each pages are of size 8KB. Group of 8 pages is stored together and they are referred as Extent. Pages within a table store the data rows with structure which helps to search/locate data... - [SQL SERVER - 2005 - List All Column With Identity Key In Specific Database](https://blog.sqlauthority.com/2008/03/29/sql-server-2005-list-all-column-with-indentity-key-in-specific-database/): Question I received in Email : How to list all the columns in the database which are used as identity key in my database? - [SQL SERVER - Introduction to sys.dm_exec_query_optimizer_info](https://blog.sqlauthority.com/2008/03/28/sql-server-2005-introduction-to-sysdm_exec_query_optimizer_info/): Many times when I am just bored I surf Book On Line for SQL Server 2005. Almost all the time I find something new which makes me believe that I have lot to learn and there are so many things I am not aware of. Today I found system catalog view sys.dm_exec_query_optimizer_info. I just enjoyed reading about it and now I will share this with you. - [SQL SERVER - 2005 - Find Index Fragmentation Details - Slow Index Performance](https://blog.sqlauthority.com/2008/03/27/sql-server-2005-find-index-fragmentation-details-slow-index-performance/): Just a day ago, while using one index I was not able to get the desired performance from the table where it was applied. I just looked for its fragmentation and found it was heavily fragmented. After I reorganized index it worked perfectly fine. Here is the quick script I wrote to find fragmentation of the database for all the indexes. SELECT ps.database_id, ps.OBJECT_ID, ps.index_id, b.name, ps.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps INNER JOIN sys.indexes AS b ON ps.OBJECT_ID = b.OBJECT_ID AND ps.index_id = b.index_id WHERE ps.database_id = DB_ID() ORDER BY ps.OBJECT_ID GO You can REBUILD or... - [SQLAuthority News - Few Links About SQLAuthority](https://blog.sqlauthority.com/2008/03/26/sqlauthority-news-few-links-about-sqlauthority/): I have listed few important links of SQLAuthority.com, I still receive some repeated questions. I do my best to respond to all of my readers, however, most of the time I am sending them link to one of my previously written article. Many times most of the answers can be found right away by searching in this blog. I have created special search engine, which exclusively searches in this blog. Search SQLAuthority.com – http://search.sqlauthority.com Finding good database developer job is very hard and finding good database developer is even harder. For the same reason I have attempted to created only SQL... - [SQL SERVER - Simple Puzzle Using Union and Union All - Answer](https://blog.sqlauthority.com/2008/03/25/sql-server-simple-puzzle-using-union-and-union-all-answer/): Yesterday I posted a puzzle SQL SERVER – Simple Puzzle Using Union and Union All, today we will see the answer of this. Following image explains the answer of puzzle. You can read the explanation of why this is answer read my previous article SQL SERVER – Union vs. Union All – Which is better for performance? Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Simple Puzzle Using Union and Union All](https://blog.sqlauthority.com/2008/03/24/sql-server-simple-puzzle-using-union-and-union-all/): I often get request to write puzzles using SQL Server. Today, I am presenting one very simple but very interesting puzzle. What will be the output of following two SQL Scripts. First try to answer without running this two script in Query Editor. Script 1 SELECT 1 UNION ALL (SELECT 1 UNION SELECT 2) GO Script 2 (SELECT 1 UNION ALL SELECT 1) UNION SELECT 2 GO Hint : This puzzle is based on my previous article SQL SERVER – Union vs. Union All – Which is better for performance? Answer : SQL SERVER – Simple Puzzle Using Union and Union... - [SQL SERVER - 2005 - Mechanisms to Ensure Integrity and Consistency of Databases - Locking and Row Versioning](https://blog.sqlauthority.com/2008/03/23/sql-server-2005-mechanisms-to-ensure-integrity-and-consistency-of-databases-locking-and-row-versioning/): Today I was going through Book On Line while researching something, I come across one interesting small article about two mechanisms to ensure integrity and consistency of databases – 1) Locking 2) Row Versioning Let us see their definition from Book Online Itself. Locking Each transaction requests locks of different types on the resources, such as rows, pages, or tables, on which the transaction is dependent. The locks block other transactions from modifying the resources in a way that would cause problems for the transaction requesting the lock. Each transaction frees its locks when it no longer has a dependency on... - [SQL SERVER - 2005 - Find Highest / Most Used Stored Procedure](https://blog.sqlauthority.com/2008/03/22/sql-server-2005-find-highest-most-used-stored-procedure/): How many times we all DBA’s might have wonder which stored procedure is executing most in the database? I have wondered it often and I have written following small script which gives me answer to my above questions. I am also retrieving few additional data along with the highest used SP names. You can change the name of the database from AdventureWorks to any database which you are curious about. If WHERE clause is completely removed it will give results for all the database. SELECT TOP 10 qt.TEXT AS 'SP Name', qs.execution_count AS 'Execution Count', qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime', qs.total_worker_time AS 'TotalWorkerTime',... - [SQL SERVER - Introduction to Live Lock - What is Live Lock?](https://blog.sqlauthority.com/2008/03/21/sql-server-introduction-to-live-lock-what-is-live-lock/): Some questions are very interesting to answer. I just received following question in Email. What is Live Lock? A Live lock is one, where a request for exclusive lock is denied continuously because a series of overlapping shared locks keeps on interfering each other and to adapt from each other they keep on changing the status which further prevents them to complete the task. In SQL Server Live Lock occurs when read transactions are applied on table which prevents write transaction to wait indefinitely. This is different then deadlock as in deadlock both the processes wait on each other. A human... - [SQLAuthority News - Book Review - Joe Celkos SQL Puzzles and Answers, Second Edition, Second Edition](https://blog.sqlauthority.com/2008/03/20/sqlauthority-news-book-review-joe-celkos-sql-puzzles-and-answers-second-edition-second-edition/): Joe Celko’s SQL Puzzles and Answers, Second Edition, Second Edition (The Morgan Kaufmann Series in Data Management Systems) (Paperback) by Joe Celko (Author) Link to Amazon Short Review: This book is for all of them who enjoy little puzzles or just something which gives them challenge. Some puzzles took hours to solve and some were straight forward. This book teaches you some basic principles and patterns as well satisfy your need for brain teasers. Detail Review: This book for all the SQL programmers regardless of database language you prefer. Book contains examples in different languages (SQL Server, Oracle, Sybase, Informix etc).... - [SQL SERVER - Add Column With Default Column Constraint to Table](https://blog.sqlauthority.com/2008/03/19/sql-server-add-column-with-default-column-constraint-to-table/): Just a day ago while working with database Jr. Developer asked me question how to add column along with column constraint. He also wanted to specify the name of the constraint. The newly added column should not allow NULL value. He requested my help as he thought he might have to write many lines to achieve what was requested. - [SQL SERVER - 2005 - Analysis Services Query Performance Top 10 Best Practices](https://blog.sqlauthority.com/2008/03/18/sql-server-2005-analysis-services-query-performance-top-10-best-practices/): Analysis Services Query Performance Top 10 Best Practices Optimize cube and measure group design Define effective aggregations Use partitions Write efficient MDX Use the query engine cache efficiently Ensure flexible aggregations are available to answer queries. Tune memory usage Tune processor usage Scale up where possible Scale out when you can no longer scale up Technet Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download White Papers - Migration from MySQL, Oracle, Sybase, or Microsoft Access to Microsoft SQL Server](https://blog.sqlauthority.com/2008/03/17/sqlauthority-news-download-white-papers-migration-from-mysql-oracle-sybase-or-microsoft-access-to-microsoft-sql-server/): Note : Download White Papers by Microsoft Guide to Migrating from MySQL to SQL Server 2005 This migration guide explains the differences between the MySQL and SQL Server 2005 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2005 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2005. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. Guide to Migrating from Sybase ASE to SQL Server 2005 This... - [SQL SERVER - 2005 - Retrieve Any User Defined Object Details Using sys objects Database](https://blog.sqlauthority.com/2008/03/16/sql-server-2005-retrieve-any-user-defined-object-details-using-sysobjects-database/): sys.objects object catalog view contains a row for each user-defined, schema-scoped object that is created within a database. You can retrieve any user defined object details by querying sys.objects database. Let us see one example of sys.objects database usage. You can run following query to retrieve all the information regarding name of foreign key, name of the table it FK belongs and the schema owner name of table. USE AdventureWorks; GO SELECT name AS ObjectName, OBJECT_NAME(schema_id) SchemaName, OBJECT_NAME(parent_object_id) ParentObjectName, name, * FROM sys.objects WHERE type = 'F' GO You can use any of the following in your WHERE clause and retrieve... - [SQL SERVER - 2005 - Retrieve Processes Using Specified Database](https://blog.sqlauthority.com/2008/03/15/sql-server-2005-retrieve-processes-using-specified-database/): Blog Reader Jim Sz posted quick but very interesting script. If user want to know how many processes are there in any particular database it can be retrieved querying sys.processes database. USE master GO DECLARE @dbid INT SELECT @dbid = dbid FROM sys.sysdatabases WHERE name = 'AdventureWorks' IF EXISTS (SELECT spid FROM sys.sysprocesses WHERE dbid = @dbid) BEGIN SELECT 'These processes are using current database' AS Note, spid, last_batch, status, hostname, loginame FROM sys.sysprocesses WHERE dbid = @dbid END GO Reference : Pinal Dave (https://blog.sqlauthority.com), Jim Sz - [SQL SERVER - 2005 - What is CLR?](https://blog.sqlauthority.com/2008/03/14/sql-server-2005-clr/): CLR is Common Language Runtime. Here is the diagram which explains the architecture of the CLR. - [SQL SERVER - FIX : Error : 3702 Cannot drop database because it is currently in use - Part 2](https://blog.sqlauthority.com/2008/03/13/sql-server-fix-error-3702-cannot-drop-database-because-it-is-currently-in-use-part-2/): Following error is very generic error and I have previously written SQL SERVER – FIX : Error : 3702 Cannot drop database because it is currently in use. Msg 3702, Level 16, State 3, Line 2 Cannot drop database “DataBaseName” because it is currently in use. One of the reader Dave have posted additional information in comments. I will list his advise here. First read the original post here. If you are still getting the error after you try using USE master GO DROP DATABASE (databaseName) GO Close SQL Server Management Studio completely. Open it again and connect as normal. Now... - [SQL SERVER - 2005 - Find Nth Highest Record from Database Table - Using Ranking Function ROW_NUMBER](https://blog.sqlauthority.com/2008/03/12/sql-server-2005-find-nth-highest-record-from-database-table-using-ranking-function-row_number/): I have previously written SQL SERVER – 2005 – Find Nth Highest Record from Database Table where I have shown query to find 4th highest record from database table. Everytime when I write blog I am always very eager to read comments of readers. Some of regular readers are industry leaders and and their comments always teach us all something new. One of them is Nicholas Paldino [.NET/C# MVP]. He has always provided valuable solution and comments to this blog. His recent comment about finding Nth Highest Record is quite an interesting. USE AdventureWorks GO SELECT t.* FROM ( SELECT e1.*,... - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - Part 3](https://blog.sqlauthority.com/2008/03/11/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql-part-3/): Please read SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL before continuing this article. I had asked users to come up with alternate solution of the same problem. Khadar Khan came up with good solution using CTE SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL – Part 2. Today we will see the solution suggested by Dave Arthur. This solution is quite good as it uses UNION ALL instead of OR clause. USE AdventureWorks GO SELECT A.* FROM ( SELECT TOP 1 * FROM Sales.SalesOrderDetail ORDER BY SalesOrderDetailID) A UNION ALL SELECT B.*... - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - Part 2 - CTE](https://blog.sqlauthority.com/2008/03/10/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql-part-2/): Please read SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL before continuing this article. I had asked users to come up with an alternate solution of the same problem. In this blog post we will see solution with the help of CTE.  - [SQLAuthority News - Authors Most Visited Article on Blog](https://blog.sqlauthority.com/2008/03/09/sqlauthority-news-authors-most-visited-article-on-blog/): I received many emails regarding SQLAuthority News – 500th Post – An Interesting Journey with SQL Server. One of the email asked interesting question regarding my most visited article on this blog. It was interesting to know that reader wants to know which article I visit the most. Following is the link to the article which I personal visit most of the time while working as Principal Database Administrator. SQL SERVER – 2005 – Search Stored Procedure Code – Search Stored Procedure Text Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Nth Highest Record from Database Table](https://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/): I had previously written SQL SERVER - Query to Retrieve the Nth Maximum value. I just received an email that if I can write this using AdventureWorks database as it is a default sample database for SQL Server 2005 and the user can run the query against it and understand it better. Let us see how we can find highest record from database. - [SQLAuthority News - 500th Post - An Interesting Journey with SQL Server](https://blog.sqlauthority.com/2008/03/07/sqlauthority-news-500th-post-an-interesting-journey-with-sql-server/): I am very pleased to write my 500th post. After 500 posts, I still have same feeling when I wrote first post on this blog. I would like to thank my family for their continuous support in writing this blog. Most of all I want to thank all of YOU for being wonderful readers of this blog, without your continuous participation and communication, this blog could not be what it is right now. THANK YOU. Some of the milestones in this wonderful Journey to SQL Authority. Search SQLAuthority Feature to search exclusively SQLAuthoritive.com. Readers can search the blog for immediate answers.... - [SQLAuthority News - SQL Server 2005 is The Data Platform Leader](https://blog.sqlauthority.com/2008/03/06/sqlauthority-news-sql-server-2005-is-the-data-platform-leader/): Questions I often get asked : How big is market for SQL Server? Is SQL Server industry leader? Does learning SQL Server technology will help future career? Why did you pick SQL Server as your expertise? I just love SQL Server. Let us read following article taken directly from Microsoft, which explains why SQL Server is Data Platform Leader. Microsoft is positioned in Leaders Quadrant for Magic Quadrant for Business Intelligence Platforms, 2008 Microsoft is positioned in Leaders Quadrant for Magic Quadrant for Data Warehouse Database Management Systems, 2007 SQL Server is the fastest growing Database and Business Intelligence vendor SQL... - [SQL SERVER - Simple Example of Cursor - Sample Cursor Part 2](https://blog.sqlauthority.com/2008/03/05/sql-server-simple-example-of-cursor-sample-cursor-part-2/): I have recently received email that I should update SQL SERVER – Simple Example of Cursor with example of AdventureWorks database. Simple Example of Cursor using AdventureWorks Database is listed here. USE AdventureWorks GO DECLARE @ProductID INT DECLARE @getProductID CURSOR SET @getProductID = CURSOR FOR SELECT ProductID FROM Production.Product OPEN @getProductID FETCH NEXT FROM @getProductID INTO @ProductID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @ProductID FETCH NEXT FROM @getProductID INTO @ProductID END CLOSE @getProductID DEALLOCATE @getProductID GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold](https://blog.sqlauthority.com/2008/03/04/sql-server-2005-a-simple-way-to-defragment-all-indexes-in-a-database-that-is-fragmented-above-a-declared-threshold/): Just a day ago, I received email from regular reader Rajiv Kayasthy about a script which demonstrates the A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold. He found this script on TechNet BOL and was attempting to run on SQL Server but was getting continuous error Msg 2501, Level 16, State 45, Line 1 Cannot find a table or object with the name “TableName”. Check the system catalog. After looking at the script provided on BOL I found that it has very small error. It was retrieving data without prefixing database schema.... - [SQL SERVER - Sharpen Your Basic SQL Server Skills - Learn the distinctions between unique constraint and primary key constraint and the easiest way to get random rows from a table](https://blog.sqlauthority.com/2008/03/03/sql-server-sharpen-your-basic-sql-server-skills-learn-the-distinctions-between-unique-constraint-and-primary-key-constraint-and-the-easiest-way-to-get-random-rows-from-a-table/): Read my article in SQL Server Magazine March 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL](https://blog.sqlauthority.com/2008/03/02/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql/): Just a day ago, while working with some inventory related projects, I faced one interesting situation. I had to find TOP 1 and BOTTOM 1 record together. I right away that I should just do UNION but then I realize that UNION will not work as it will only accept one ORDER BY clause. If you specify more than one ORDER BY clause. It will give an error. Let us see how we can retrieve top and bottom rows together. - [SQL SERVER - Transfer The Logins and The Passwords Between Instances of SQL Server 2005](https://blog.sqlauthority.com/2008/03/01/sql-server-transfer-the-logins-and-the-passwords-between-instances-of-sql-server-2005/): This question was asked to me by one of reader. “I just upgraded my server with better hardware and newer operating system. How can I transfer the logins and the passwords between two of my SQL Server?” I think Microsoft has wonderful documentation for this issue. kb 918992 I will briefly describe the solution here : Run the script in Query Editor. It will generate the script of username and password in the windows. USE master GO IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL DROP PROCEDURE sp_hexadecimal GO CREATE PROCEDURE sp_hexadecimal @binvalue varbinary(256), @hexvalue varchar(256) OUTPUT AS DECLARE @charvalue varchar(256) DECLARE @i... - [SQL SERVER - Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial](https://blog.sqlauthority.com/2008/02/29/sql-server-introduction-to-sql-server-encryption-and-symmetric-key-encryption-tutorial/): SQL Server 2005 provides encryption as a new feature to protect data against the attacks of hackers. Hackers may be able to get hold of the database or tables, but they wouldn’t understand the data or be able to use it. It is very important to encrypt crucial security related data when stored in the database, as well while transmitting across a network between the client and the server. Read my complete article here : Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Dynamic Case Statement - FIX : ERROR 156 : Incorrect syntax near the keyword](https://blog.sqlauthority.com/2008/02/28/sql-server-dynamic-case-statement-fix-error-156-incorrect-syntax-near-the-keyword/): One of my friend sent me query asking me how to generate dynamic case statements in SQL. Every time he tries to run following query he is getting Error 156 : Incorrect syntax near the keyword. He was frustrated with following two queries. There are two different ways to solve the problem when user want to Incorrect Query 1 : USE AdventureWorks GO DECLARE @OrderDirection VARCHAR(5) SET @OrderDirection = ‘DESC’ SELECT * FROM Production.WorkOrder WHERE ProductID = 722 ORDER BY OrderQty CASE WHEN @OrderDirection = ‘DESC’ THEN DESC ELSE ASC END GO ResultSet: Msg 156, Level 15, State 1, Line 8... - [SQLAuthority News - SQL Server 2008 R2 Support Ends on July 9, 2019](https://blog.sqlauthority.com/2008/02/27/sqlauthority-news-sql-server-2008-r2-support-ends-on-july-9-2019/): It is indeed true Microsoft will official support ends of the product on July 9, 2019. Comprehensive Database Performance Health Check.  - [SQL SERVER - SELECT 1 vs SELECT * - An Interesting Observation](https://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/): Many times I have seen issue of SELECT 1 vs SELECT * discussed in terms of performance or readability while checking for existence of rows in table. I ran quick 4 tests about this observed that I am getting same result when used SELECT 1 and SELECT *. I think smart readers of this blog will come up the situation when SELECT 1 and SELECT * have different execution plan when used to find existence of rows. - [SQLAuthority News - Latest SQL Server Management Studio Blogs](https://blog.sqlauthority.com/2008/02/25/sqlauthority-news-latest-sql-server-management-studio-blogs/): SQL Server Management Studio is an amazing product and I am personally a big fan of the same. Here are the few latest blog written on the same subject. - [SQL SERVER - 2005 - Licensing Model Compared to Other Database Products](https://blog.sqlauthority.com/2008/02/24/sql-server-2005-licensing-model-compared-to-other-database-products/): Yesterday on this blog I wrote about SQL SERVER – 2005 – Understanding Licensing Model. I have received many questions about pricing and comparing SQL Server with other RDBMS. One of the reason I like SQL Server because I am strong believer of licensed software usage and SQL Server is feature rich and dirt cheap compared to other comparable products. Let us review following chart and table which explains the difference. https://www.microsoft.com/en-us/sql-server/sql-server-2016 If you are interested to read about more about this you can review original article from where I have taken above information. Reference : Pinal Dave (https://blog.sqlauthority.com) , SQL... - [SQL SERVER - Understanding Licensing Models](https://blog.sqlauthority.com/2008/02/23/sql-server-understanding-licensing-models/): The licensing structure has evolved to reflect advances in technology and diverse use cases. Below are the primary licensing models available: - [SQL SERVER - Find All The User Defined Functions (UDF) - Part 2](https://blog.sqlauthority.com/2008/02/22/sql-server-find-all-the-user-defined-functions-udf-part-2/): Few days ago, I wrote about SQL SERVER – Find All The User Defined Functions (UDF) in a Database. Regular reader of this blog Madhivanan has suggested following alternate method to do the same task of finding all the user defined functions in database. USE AdventureWorks GO SELECT specific_name,specific_schema FROM information_schema.routines WHERE routine_type='function' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download SQL Server 2017](https://blog.sqlauthority.com/2008/02/21/sqlauthority-news-download-sql-server-2017/): This was a very old blog post and I have decided to re-write this as it was no longer useful. In this blog post, we will learn about SQL Server 2017. Here is how you can download SQL Server 2017 related material. - [SQLAuthority New - SQL Server 2008 Books Online CTP (February 2008)](https://blog.sqlauthority.com/2008/02/21/sqlauthority-new-sql-server-2008-books-online-ctp-february-2008/): Download a Community Technology Preview (CTP) version of the documentation and tutorials for Microsoft SQL Server 2008. SQL Server 2008 Books Online CTP (February 2008) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF to Return a Calendar for Any Date for Any Year](https://blog.sqlauthority.com/2008/02/20/sql-server-udf-to-return-a-calendar-for-any-date-for-any-year/): It gives me great pleasure to write articles like today’s one because I have received great comment from one of regular reader who has taken UDF written by me and created another UDF using that UDF which enhances functionality of it. I had written previous article about SQL SERVER – UDF – Function to Display Current Week Date and Day – Weekly Calendar. Reader of this blog and great SQL expert Dan Golden has wrote another UDF which uses UDF written by me. I thank Dan Golden for his contribution to this blog. I have modified his function a bit to... - [SQL SERVER - 2005 - FIX: Error message when you run a query against a table that does not have a clustered index in SQL Server 2005: "A severe error occurred on the current command"](https://blog.sqlauthority.com/2008/02/19/sql-server-2005-fix-error-message-when-you-run-a-query-against-a-table-that-does-not-have-a-clustered-index-in-sql-server-2005-a-severe-error-occurred-on-the-current-command/): In SQL Server 2005 while testing Indexes I had created a table with one non clustered index only. I did not create any clustered index on table. After that I ran SELECT statement, it gave me following error. I was very surprised when I looked at error. It says Msg 0, what it means is that this error is not known error to Microsoft and it might be bug. Msg 0, Level 11, State 0, Line 0 A severe error occurred on the current command. The results, if any, should be discarded. Msg 0, Level 20, State 0, Line 0 A... - [SQLAuthority News - Download SQL Server 2008 February CTP (CTP 6)](https://blog.sqlauthority.com/2008/02/18/sqlauthority-news-download-sql-server-2008-february-ctp-ctp-6/): SQL Server 2008 February CTP (CTP 6) has been released. Download from here. It will direct you to page which is dated November 2007. Continue with November 2007 which will take you to February 2008 CTP 6 Download page. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - How to Escape Single Quotes - Fix: Error: 105 Unclosed quotation mark after the character string](https://blog.sqlauthority.com/2008/02/17/sql-server-how-to-escape-single-quotes-fix-error-105-unclosed-quotation-mark-after-the-character-string/): Jr. Developer asked me other day how to escape single quote? User can escape single quote using two single quotes (NOT double quote). - [SQL SERVER - Msg: 2593 : There are ROWCOUNT rows in PAGECOUNT pages for object 'OBJECT'.](https://blog.sqlauthority.com/2008/02/16/sql-server-msg-2593-there-are-rowcount-rows-in-pagecount-pages-for-object-object/): There are ROWCOUNT rows in PAGECOUNT pages for object 'OBJECT'. This message is displayed when DBCC command is ran for any database. It is harmless and displayed for information purpose only. For each database DBCC commands displays number of rows and number of pages it is using. DBCC CHECKALLOC is exception for this messages. - [SQL SERVER - Index Reorganize or Index Rebuild](https://blog.sqlauthority.com/2008/02/15/sql-server-index-reorganize-or-index-rebuild/): Recently, I have received one question quite often about when to Index Reorganize and when to Index Rebuild. I have already written about this topic earlier but it seems that many are unable to search it. SQL SERVER – Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script If you have any question you can search exclusively SQLAuthority at http://search.SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Performance Monitor - How to Use Perfmon](https://blog.sqlauthority.com/2008/02/14/sql-server-introduction-to-performance-monitor-how-to-use-perfmon/): Yesterday I wrote about SQL SERVER – Introduction to Three Important Performance Counters. I received few questions about how to use Perfmon. Here is very brief introduction to Perfmon. There are three ways to launch Perfmon. 1) Type “start perfmon” at the command prompt. 2) Go to Start | Programs | Administrative Tools | Performance Monitor. 3) Go to Start | Run | Perfmon. Follow the images which explains how to use Perfmon and add different counters. Right click to bring up Add Counters Menu. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Three Important Performance Counters](https://blog.sqlauthority.com/2008/02/13/sql-server-introduction-to-three-important-performance-counters/): Performance Counters are very important to evaluate. There are more than thousands of Performance Counters. Today I will cover three basic but very important Performance Counters. Processor:% Processor Time It reports the total processor time with respect to the available capacity of the server. If counter is between 50 to 70 % consistently, investigate the process which is taking long time. PhysicalDisk:Avg.Disk Queue Length It indicates wait time for processes to use disk resources. As a disk is reading and writing data some requests cannot be immediately filled, those requests are queued. If many simultaneous requests are waiting, investigate the process... - [SQL SERVER - Get Current Database Name](https://blog.sqlauthority.com/2008/02/12/sql-server-get-current-database-name/): Yesterday while I was writing script for SQL SERVER – 2005 – Find Unused Indexes of Current Database . I realized that I needed SELECT statement where I get the name of the current Database. It was very simple script. SELECT DB_NAME() AS DataBaseName It will give you the name the database you are running using while running the query. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Find Unused Indexes of Current Database](https://blog.sqlauthority.com/2008/02/11/sql-server-2005-find-unused-indexes-of-current-database/): Simple but accurate following script will give you list of all the indexes in the database which are unused. If indexes are not used they should be dropped as Indexes reduces the performance for INSERT/UPDATE statement. Indexes are only useful when used with SELECT statement. Script to find unused Indexes. USE AdventureWorks GO DECLARE @dbid INT SELECT @dbid = DB_ID(DB_NAME()) SELECT OBJECTNAME = OBJECT_NAME(I.OBJECT_ID), INDEXNAME = I.NAME, I.INDEX_ID FROM SYS.INDEXES I JOIN SYS.OBJECTS O ON I.OBJECT_ID = O.OBJECT_ID WHERE OBJECTPROPERTY(O.OBJECT_ID,'IsUserTable') = 1 AND I.INDEX_ID NOT IN ( SELECT S.INDEX_ID FROM SYS.DM_DB_INDEX_USAGE_STATS S WHERE S.OBJECT_ID = I.OBJECT_ID AND I.INDEX_ID = S.INDEX_ID AND DATABASE_ID = @dbid)... - [SQLAuthority News - RIP: Ken Henderson, 1967 - 2008](https://blog.sqlauthority.com/2008/02/10/sqlauthority-news-rip-ken-henderson-1967-2008/): Ken Henderson, a nationally recognized consultant and leading DBMS practitioner, consults on high-end client/server projects away on Sunday, January 27, in Meeker, Oklahoma. Ken was an inspirational author of the SQL Server Guru’s Guide series of books. We will miss his forever. He was the author I respected the most. I have reviewed his book SQLAuthority News – Book Review – SQL Server 2005 Practical Troubleshooting: The Database Engine earlier on this blog. That was one great book. You can read sample chapter from that book here. Download Sample Chapter of SQL Server 2005 Practical Troubleshooting: The Database Engine. Let us... - [SQLAuthority News - 2008 - Download - SQL Server 2008 Brochure](https://blog.sqlauthority.com/2008/02/09/sqlauthority-news-2008-download-sql-server-2008-brochure/): SQL Server 2008 Brochure is available to download. It contains many information like available Server Editions, Top New Features, New Available Technologies and additional resources. - [SQL SERVER - Microsoft SQL Server Compact 3.5 SP1 Beta for ADO.Net Entity Framework Beta 3](https://blog.sqlauthority.com/2008/02/08/sql-server-microsoft-sql-server-compact-35-sp1-beta-for-adonet-entity-framework-beta-3/): SQL Server Compact 3.5 SP1 Beta release for the ADO.Net Entity Framework Beta 3 enables the following scenarios: Applications can work in terms of a more application-centric conceptual model, including types with inheritance, complex members, and relationships Applications are freed from hard-coded dependencies on a particular data engine or storage schema Mappings between the conceptual application model and the storage-specific schema can change without changing the application code Developers can work with a consistent application object model that can be mapped to various storage schemas, possibly implemented in different database management systems Multiple application models can be mapped to a single... - [SQL SERVER - Sharpen Your Basic SQL Server Skills - Database backup demystified](https://blog.sqlauthority.com/2008/02/07/sql-server-sharpen-your-basic-sql-server-skills-database-backup-demystified/): Read my article in SQL Server Magazine January 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Import CSV File Into SQL Server Using Bulk Insert - Load Comma Delimited File Into SQL Server](https://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/): This is a very common request recently – How to import CSV file into SQL Server? How to load CSV file into SQL Server Database Table? How to load comma delimited file into SQL Server? Let us see the solution in quick steps. CSV stands for Comma Separated Values, sometimes also called Comma Delimited Values. Create TestTable USE TestData GO CREATE TABLE CSVTest (ID INT, FirstName VARCHAR(40), LastName VARCHAR(40), BirthDate SMALLDATETIME) GO Create CSV file in drive C: with name sweetest. text with the following content. The location of the file is C:\csvtest.txt 1,James,Smith,19750101 2,Meggie,Smith,19790122 3,Robert,Smith,20071101 4,Alex,Smith,20040202 Now run following script to load... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Funny Microsoft Quotes](https://blog.sqlauthority.com/2008/02/05/sqlauthority-news-sql-joke-sql-humor-sql-laugh-funny-microsoft-quotes/): I have received many emails that I should write more post like SQLAuthority News – SQL Joke, SQL Humor, SQL Laugh – Funny Quotes. - [SQL SERVER - Simple Example of WHILE Loop with BREAK and CONTINUE](https://blog.sqlauthority.com/2008/02/04/sql-server-simple-example-of-while-loop-with-break-and-continue/): WHILE statement sets a condition for the repeated execution of an SQL statement or statement block. Following is very simple example of WHILE Loop with BREAK and CONTINUE. USE AdventureWorks; GO DECLARE @Flag INT SET @Flag = 1 WHILE (@Flag < 10) BEGIN BEGIN PRINT @Flag SET @Flag = @Flag + 1 END IF(@Flag > 5) BREAK ELSE CONTINUE END WHILE loop can use SELECT queries as well. You can find following example of BOL very useful. USE AdventureWorks; GO WHILE ( SELECT AVG(ListPrice) FROM Production.Product) < $300 BEGIN UPDATE Production.Product SET ListPrice = ListPrice * 2 SELECT MAX(ListPrice) FROM Production.Product... - [SQL SERVER - FIX : ERROR : Cannot find template file for new query (C:\Program Files\Microsoft SQL Server\90\Tools\ Binn\VSShell\Common7\ IDE\sqlworkbenchprojectitems\Sql\ SQLFile.sql)](https://blog.sqlauthority.com/2008/02/03/sql-server-fix-error-cannot-find-template-file-for-new-query-cprogram-filesmicrosoft-sql-server90toolsbinnvsshellcommon7idesqlworkbenchprojectitemssqlsqlfilesql/): Just a day ago while playing with SQL Server I suddenly faced a new kind of error, which I have never seen before. This error happens when clicked on New Query in SQL Server Management Studio. Let us learn in this blog post how we will fix the error - cannot find template file for a new query.  - [SQL SERVER - Find All The User Defined Functions (UDF) in a Database](https://blog.sqlauthority.com/2008/02/02/sql-server-find-all-the-user-defined-functions-udf-in-a-database/): Following script is very simple script which returns all the User Defined Functions for particular database. USE AdventureWorks; GO SELECT name AS function_name ,SCHEMA_NAME(schema_id) AS schema_name ,type_desc FROM sys.objects WHERE type_desc LIKE '%FUNCTION%'; GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Great Job with Great Pay](https://blog.sqlauthority.com/2008/02/01/sql-server-find-great-job-with-great-pay/): One question I have been asked consistently “Where can I find Great Job with Great Pay related to SQL Server?”. I have been aware of the fact that there are many jobs in market but finding one job which gives satisfaction in job as well has great salary are few. All the great places are usually taken by best employees and they do not change their job. Due to the same reason, I have created job board where companies can list their jobs as well all good candidate can find best job according to their requirement. Find Great Job with Great... - [SQL SERVER - Top 10 Best Practices for SQL Server Maintenance for SAP](https://blog.sqlauthority.com/2008/01/31/sql-server-top-10-best-practices-for-sql-server-maintenance-for-sap/): Top 10 Best Practices for SQL Server Maintenance for SAP By Takayuki Hoshino SQL Server provides an excellent database platform for SAP applications. The following recommendations provide an outline of best practices for maintaining SQL Server database for an SAP implementation. 1) Perform a full database backup daily 2) Perform transaction log backup Every 10 to 30 minutes 3) Back up system partition in case of configuration changes 4) Back up system databases in case of configuration changes 5) Run DBCC CHECKDB periodically (ideally before the full database backup) 6) Evaluate security patches monthly (and install them if they are necessary)... - [SQL SERVER - FIX : ERROR : The query processor could not start the necessary thread resources for parallel query execution](https://blog.sqlauthority.com/2008/01/30/sql-server-fix-error-the-query-processor-could-not-start-the-necessary-thread-resources-for-parallel-query-execution/): ERROR : The query processor could not start the necessary thread resources for parallel query execution. - [SQLAuthority New - O'relly Style Book Cover for SQLAuthority](https://blog.sqlauthority.com/2008/01/29/sqlauthority-new-orelly-style-book-cover-for-sqlauthority/): Yo Ming, Chin regular reader from Los Angeles, CA has sent me following image for SQLAuthority. Checkout O’reillymaker and create your own Book Cover. Reference : Pinal Dave (https://blog.sqlauthority.com) , O’reillymaker - [SQL SERVER - Script to Find SQL Server on Network](https://blog.sqlauthority.com/2007/04/13/sql-server-script-to-find-sql-server-on-network/): I manage lots of SQL Servers. Many times I forget how many server I have and what are their names. New servers are added frequently and old servers are replaced with powerful servers. I run following script to check if server is properly set up and announcing itself. This script requires execute permissions on XP_CMDShell. CREATE TABLE #servers(sname VARCHAR(255)) INSERT #servers (sname) EXEC master..xp_CMDShell 'ISQL -L' DELETE FROM #servers WHERE sname='Servers:' OR sname IS NULL SELECT LTRIM(sname) FROM #servers DROP TABLE #servers Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Disable Triggers - Drop Triggers](https://blog.sqlauthority.com/2007/04/13/sql-server-2005-disable-triggers-drop-triggers/): There are two ways to prevent trigger from firing. 1) Drop Trigger Example: DROP TRIGGER TriggerName GO 2) Disable Trigger DML trigger can be disabled two ways. Using ALETER TABLE statement or use DISABLE TRIGGER. I prefer DISABLE TRIGGER statement. Syntax: DISABLE TRIGGER { [ schema . ] trigger_name [ ,...n ] | ALL } ON { OBJECT_NAME | DATABASE | ALL SERVER } [ ; ] Example: DISABLE TRIGGER TriggerName ON TableName Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-1702-create-table-failed-because-column-in-table-exceeds-the-maximum-of-columns/): Error Received: Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns SQL Server 2000 supports table with maximum 1024 columns. This errors happens when we try to create table with 1024 columns or try to add columns to table which exceeds more than 1024. Fix/Solution/WorkAround: Reduce the number of columns in the table to 1,024 or less. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error: 3902, Severity: 16; State: 1 : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-3902-severity-16-state-1-the-commit-transaction-request-has-no-corresponding-begin-transaction/): SQL Server Integration Services Error : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. (Microsoft OLE DB Provider for SQL Server) Fix/Workaround/Solution: Option 1: To work around this problem, do not call the stored procedure by using ODBC Call syntax. You can call the stored procedure in may ways by using ADO. One of the methods is to call a stored procedure by using a command object. (View Example) Option 2: If the sql statements are like BEGIN TRAN SQL Statements END TRAN SET “RetainSameConnection” property on the connection manager to true. This will fix the problem. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Running 64 bit SQL SERVER 2005 on 32 bit Operating System](https://blog.sqlauthority.com/2007/04/12/sql-server-running-64-bit-sql-server-2005-on-32-bit-operating-system/): Few days ago, I have received email from users asking question :How to run 64 bit SQL SERVER 2005 on 32 bit operating system? - [SQL SERVER - UDF - User Defined Function to Extract Only Numbers From String](https://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/): Following SQL User Defined Function will extract/parse numbers from the string. CREATE FUNCTION ExtractInteger(@String VARCHAR(2000)) RETURNS VARCHAR(1000) AS BEGIN DECLARE @Count INT DECLARE @IntNumbers VARCHAR(1000) SET @Count = 0 SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1) END SET @Count = @Count + 1 END RETURN @IntNumbers END GO Run following script in query analyzer. SELECT dbo.ExtractInteger('My 3rd Phone Number is 323-111-CALL') GO It will return following values. 3323111 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Explanation of TRY...CATCH and ERROR Handling](https://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/): SQL Server 2005 offers a more robust set of tools for handling errors than in previous versions of SQL Server. Deadlocks, which are virtually impossible to handle at the database level in SQL Server 2000, can now be handled with ease. By taking advantage of these new features, you can focus more on IT business strategy development and less on what needs to happen when errors occur. In SQL Server 2005, @@ERROR variable is no longer needed after every statement executed, as was the case in SQL Server 2000. SQL Server 2005 provides the TRY…CATCH construct, which is already present in... - [SQL SERVER - 2005 - Silent Installation - Unattended Installation](https://blog.sqlauthority.com/2007/04/10/sql-server-2005-silent-installation-unattended-installation/): Silent SQL Server 2005 Installation is possible in two steps. 1) Creating an .ini file The SQL Server CD contains a template file called template.ini . Based on that create another required .ini file which includes a single [Options] section containing multiple parameters, each relating to a different feature or configuration setting. 2) Run Setup on command prompt On command prompt type following script setup.exe /settings <path TO .ini FILE> If location of sqlinstall.ini file is at C:\SQLSetup folder. The command to initiate silent installation is: setup.exe /settings C:SQLSetup sqlinstall.ini Specify the /qn switch to perform a silent installation (with no... - [SQL SERVER - SP Performance Improvement without changing T-SQL](https://blog.sqlauthority.com/2007/04/10/sql-server-sp-performance-improvement-without-changing-t-sql/): There are two ways, which can be used to improve the performance of Stored Procedure (SP) without making T-SQL changes in SP. Do not prefix your Stored Procedure with sp_. In SQL Server, all system SPs are prefixed with sp_. When any SP is called which begins sp_ it is looked into masters database first before it is looked into the database it is called in. Call your Stored Procedure prefixed with dbo.SPName – fully qualified name. When SP are called prefixed with dbo. or database.dbo. it will prevent SQL Server from placing a COMPILE lock on the procedure. While SP... - [SQL SERVER - 2005 Reserved Keywords](https://blog.sqlauthority.com/2007/04/09/sql-server-2005-reserved-keywords/): Microsoft SQL Server 2005 uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language that is used by SQL Server to parse and understand Transact-SQL statements and batches. It is not legal to include the reserved keywords in a Transact-SQL statement in any location except that defined by SQL Server. No objects in the database should be given a name that matches a reserved keyword. Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using... - [SQL SERVER - Search Text Field - CHARINDEX vs PATINDEX](https://blog.sqlauthority.com/2007/04/08/sql-server-search-text-field-charindex-vs-patindex/): We can use either CHARINDEX or PATINDEX to search in TEXT field in SQL SERVER. The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. Both functions take two arguments. With PATINDEX, you must include percent signs before and after the pattern, unless you are looking for the pattern as the first (omit the first %) or last (omit the last %) characters in a column. For CHARINDEX, the pattern cannot include wildcard characters. The second argument is a character expression, usually a column name, in which Adaptive Server searches for the specified pattern. Example of CHARINDEX:... - [SQL SERVER - DBCC Commands Introduced in SQL Server 2005](https://blog.sqlauthority.com/2007/04/07/sql-server-dbcc-commands-introduced-in-sql-server-2005/): SQL Server 2005 has introduced following two documented and five undocumented DBCC Commands. I was able to find documentation for only first one online. If you find any documentation of any other DBCC Commands please add comments. It will be helpful to all of us. Documented: freesessioncache () — no parameters Flushes the distributed query connection cache used by distributed queries against an instance of Microsoft SQL Server. View Details requeststats ({clear} | {setfastdecayrate, rate} | {setslowdecayrate, rate}) UnDocumented: mapallocunit (I8AllocUnitId | {I4part, I2part}) metadata ({‘print’ [, printopt = {0 |1}] | ‘drop’ | ‘clone’ [, ” | ….]}, {‘object’ [,... - [SQL SERVER - Fix: Server: Msg 7391, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/06/sql-server-fix-server-msg-7391-level-16-state-1-line-1/): I have received this error many times on different servers in my careers. There is no single fix for this Error. Server: Msg 7391, Level 16, State 1, Line 1 can happen due to many reasons. I have used various of this reasons with few of my servers. Please refer them and try them one by one. One of them should be applicable to your problem. You may receive a 7391 error message in SQLOLEDB when you run a distributed transaction against a linked server after you install Windows XP Service Pack 2 or Windows XP Tablet PC Edition 200. View... - [SQL SERVER - Performance Optimization of SQL Query and FileGroups](https://blog.sqlauthority.com/2007/04/05/sql-server-performance-optimization-of-sql-query-and-filegroups/): It is suggested to place transaction logs on separate physical hard drives. In this manner, data can be recovered up to the second in the event of a media failure. In SQL 2005 When database is created without specifying a transaction log size, the transaction log will be re-sized to 25 percent of the size of data files. Tables and their non-clustered indexes separated into separate file groups can improve performance, because modifications to the table can be written to both the table and the index at the same time. If tables and their corresponding indexes in a different file group,... - [SQL SERVER - Fix: HResult 0x274D, SQLCMD Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired](https://blog.sqlauthority.com/2007/04/04/sql-server-fix-hresult-0x274d-level-16-state-1-error-microsoft-sql-native-client-login-timeout-expired/): While Working with SQLCMD in SQL Server 2005 I encountered following error. Let us learn in this blog post how we can solve Fix: HResult 0x274D, Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired. - [SQL SERVER - T-SQL Paging Query Technique Comparison - SQL 2000 vs SQL 2005](https://blog.sqlauthority.com/2007/04/03/sql-server-t-sql-paging-query-technique-comparison-sql-2000-vs-sql-2005/): I was doing paging in SQL Server 2000 using Temp Table or Derived Tables. I decided to checkout new function ROW_NUMBER() in SQL Server 2005. ROW_NUMBER() returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. I have compared both the following query on SQL Server 2005. SQL 2005 Paging Method USE AdventureWorks GO DECLARE @StartRow INT DECLARE @EndRow INT SET @StartRow = 120 SET @EndRow = 140 SELECT FirstName, LastName, EmailAddress FROM ( SELECT PC.FirstName, PC.LastName, PC.EmailAddress, ROW_NUMBER() OVER( ORDER BY PC.FirstName, PC.LastName,PC.ContactID) AS RowNumber FROM... - [SQL SERVER - 2005 - Performance Dashboard Reports](https://blog.sqlauthority.com/2007/04/02/sql-server-2005-performance-dashboard-reports/): The Microsoft SQL Server 2005 Performance Dashboard Reports are used to monitor and resolve performance problems on your SQL Server 2005 database server. The SQL Server instance being monitored and the Management Studio client used to run the reports must both be running SP2 or later. Common performance problems that the dashboard reports may help to resolve include: – CPU bottlenecks (and what queries are consuming the most CPU) – IO bottlenecks (and what queries are performing the most IO). – Index recommendations generated by the query optimizer (missing indexes) – Blocking – Latch contention The SQL Server 2005 Performance Dashboard... - [SQL SERVER - TempDB is Full. Move TempDB from one drive to another drive.](https://blog.sqlauthority.com/2007/04/01/sql-server-tempdb-is-full-move-tempdb-from-one-drive-to-another-drive/): If you ever find your TEmpDB to be full and if you want to move TempDB, you will find this blog post very helpful. Here is the error message which may come across. Event ID: 17052 Description: The LOG FILE FOR DATABASE 'tempdb' IS FULL. Back up the TRANSACTION LOG FOR the DATABASE TO free Up SOME LOG SPACE - [SQL SERVER - 2005 Best Practices Analyzer (February 2007 CTP)](https://blog.sqlauthority.com/2007/03/31/sql-server-2005-best-practices-analyzer-february-2007-ctp/): Microsoft has released a tool called the Microsoft SQL Server Best Practices Analyzer. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. Download SQL Server 2005 Best Practices Analyzer (February 2007 Community Technology Preview) Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Index Seek Vs. Index Scan (Table Scan)](https://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/): Index Scan retrieves all the rows from the table. Index Seek retrieves selective rows from the table. - [SQL SERVER - Difference between DISTINCT and GROUP BY - Distinct vs Group By](https://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/): This question is asked many times to me. What is difference between DISTINCT and GROUP BY? A DISTINCT and GROUP BY usually generate the same query plan, so performance should be the same across both query constructs. GROUP BY should be used to apply aggregate operators to each group. If all you need is to remove duplicates then use DISTINCT. If you are using sub-queries execution plan for that query varies so in that case you need to check the execution plan before making decision of which is faster. Example of DISTINCT: SELECT DISTINCT Employee, Rank FROM Employees Example of GROUP... - [SQL SERVER - Fix : Error 8101 An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON](https://blog.sqlauthority.com/2007/03/28/sql-server-fix-error-8101-an-explicit-value-for-the-identity-column-in-table-can-only-be-specified-when-a-column-list-is-used-and-identity_insert-is-on/): This error occurs when the user has attempted to insert a row containing a specific identity value into a table that contains an identity column. Run following commands according to your SQL Statement. Let us learn about the IDENTITY_INSERT. - [SQL SERVER - Fix : Error 701 There is insufficient system memory to run this query](https://blog.sqlauthority.com/2007/03/27/sql-server-fix-error-701-there-is-insufficient-system-memory-to-run-this-query/): Generic Solution: Check the settings for both min server memory (MB) and max server memory (MB). If max server memory (MB) is a value close to the value of min server memory (MB), then increase the max server memory (MB) value. Check the size of the virtual memory paging file. If possible, increase the size of the file. For SQL Server 2005: Install following HotFix and Restart Server. Additionally following DBCC Commands can be ran to free memory: DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT - Retrieve Last Inserted Identity of Record](https://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/): SELECT @@IDENTITY It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value. @@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it. SELECT SCOPE_IDENTITY()... - [SQL SERVER - Stored Procedure - Clean Cache and Clean Buffer](https://blog.sqlauthority.com/2007/03/23/sql-server-stored-procedure-clean-cache-and-clean-buffer/): DBCC FREEPROCCACHE will invalidate all stored procedure plans that the optimizer has cached in memory. Let us learn how to clean cache.  - [SQL SERVER - Fix: Error Msg 128 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.](https://blog.sqlauthority.com/2007/03/22/sql-server-fix-error-msg-128-the-name-is-not-permitted-in-this-context-only-constants-expressions-or-variables-allowed-here-column-names-are-not-permitted/): Error Message: Server: Msg 128, Level 15, State 1, Line 3 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Causes: This error occurs when using a column as the DEFAULT value of another column when a table is created. CREATE TABLE [dbo].[Items] ( [OrderCount] INT, [ProductAmount] INT, [TotalAmount] DEFAULT ([OrderCount] + [ProductAmount]) ) Executing this CREATE TABLE statement will generate the following error message: Server: Msg 128, Level 15, State 1, Line 5 The name ‘TotalAmount’ is not permitted in this context. Only constants, expressions, or variables allowed here.... - [SQL SERVER - 2005 Security Best Practices - Operational and Administrative Tasks](https://blog.sqlauthority.com/2007/03/21/sql-server-2005-security-best-practices-operational-and-administrative-tasks/): This white paper covers some of the operational and administrative tasks associated with SQL Server 2005 security and enumerates best practices and operational and administrative tasks that will result in a more secure SQL Server system. - [SQL SERVER - SQL Commandments - Suggestions, Tips, Tricks](https://blog.sqlauthority.com/2007/03/20/sql-server-sql-commandments-suggestions-tips-tricks/): Few days ago, while searching for something on web site, I came across a very good article of 25 SQL Commandments. I really enjoyed reading it. It was for Oracle, I re-wrote it for SQL Server. First 18 points are taken from original article and last 2 I added to complete total of 20 Commandments. Many more rules and suggestions can be added to this list, this list is just a beginning. 1. Know your data and business application well. Familiarize yourself with these sources; you must be aware of the data volume and distribution in your database. 2. Test your... - [SQL SERVER - Fix: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17](https://blog.sqlauthority.com/2007/03/16/sql-server-fix-sqllib-error-oledb-error-encountered-calling-idbinitializeinitialize-hr-0x80004005-sqlstate-08001-native-error-17/): Error received: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17 Error state: 1, Severity: 16 Source: Microsoft OLE DB Provider for SQL Server Error message: [DBNETLIB]SQL Server does not exist or access denied The simple fix: Microsoft SQL Server 2005 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server 2005 Network Configuration >> Enable TCP-IP. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC command to RESEED Table Identity Value - Reset Table Identity](https://blog.sqlauthority.com/2007/03/15/sql-server-dbcc-reseed-table-identity-value-reset-table-identity/): DBCC CHECKIDENT can reseed (reset) the identity value of the table. For example, YourTable has 25 rows with 25 as last identity. If we want next record to have identity as 35 we need to run following T SQL script in Query Analyzer. DBCC CHECKIDENT (yourtable, reseed, 34) If table has to start with an identity of 1 with the next insert then the table should be reseeded with the identity to 0. If identity seed is set below values that currently are in table, it will violate the uniqueness constraint as soon as the values start to duplicate and will... - [SQL SERVER - Union vs. Union All - Which is better for performance?](https://blog.sqlauthority.com/2007/03/10/sql-server-union-vs-union-all-which-is-better-for-performance/): This article is completely re-written with better example SQL SERVER – Difference Between Union vs. Union All – Optimal Performance Comparison. I suggest all of my readers to go here for update article. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values. The difference between Union and Union all... - [SQL SERVER - Download 2005 SP2a](https://blog.sqlauthority.com/2007/03/07/sql-server-2005-sp2a/): Microsoft released an updated SQL Server 2005 SP2 on March 5th, 2007. The build number is 9.00.3042.01. The previous build number was 9.00.3042.00.Microsoft released a SP2a patch for the second service pack for SQL Server 2005 to fix the issues with the maintenance plans.If you have upgraded to SP2, use the download from here to patch the system. KB 933508 has more information on this patch. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Script to Determine Which Version of SQL Server 2000-2005 is Running](https://blog.sqlauthority.com/2007/03/07/sql-server-script-to-determine-which-version-of-sql-server-2000-2005-is-running/): To determine which version of SQL Server 2000/2005 is running, connect to SQL Server 2000/2005 by using Query Analyzer, and then run the following code: SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') The results are: The product version (for example, 8.00.534). The product level (for example, “RTM” or “SP2”). The edition (for example, “Standard Edition”). For example, the result looks similar to: 8.00.534 RTM Standard Edition Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation](https://blog.sqlauthority.com/2007/03/05/sql-server-quoted_identifier-onoff-and-ansi_null-onoff-explanation/): When create or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF? SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO--SQL PROCEDURE, SQL FUNCTIONS, SQL OBJECTGO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO ANSI NULL ON/OFF: This option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares a value with a null returns a 0. When off, any query that compares a value with a null returns a null value. QUOTED IDENTIFIER ON/OFF:... - [SQL SERVER - Delete Duplicate Records - Rows](https://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/): Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3. DELETE FROM MyTable WHERE ID NOT IN ( SELECT MAX(ID) FROM MyTable GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3) Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to find the CD key from Registry](https://blog.sqlauthority.com/2007/02/28/sql-server-t-sql-script-to-find-the-cd-key-from-registry/): Here is the way to find SQL Server CD key, which was used to install it on machine. If user do not have permission on the SP, please login using SA username. Expended stored procedure xp_regread can read any registry values. I have used this XP to read CD_KEY. This is undocumented Stroed Procedure and may not be supported in Future Version of SQL Server. USE master GO EXEC xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Microsoft SQL Server\80\Registration','CD_KEY' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - What is New in SQL Server Agent for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/02/26/sql-server-whats-new-in-sql-server-agent-for-microsoft-sql-server-2005/): I came across this interesting and detailed article ‘What’s New in SQL Server Agent for Microsoft SQL Server 2005’ on Microsoft TechNet. This article describes Security Improvements, New Roles in the msdb Database, Multiple Proxy Accounts, Performance Improvements, Performance Counters, New SQL Server Agent Subsystems, Shared Schedules, WMI Event Alerts, SQL Server Agent Sessions, Database Mail Support, Stored Procedure Changes in depth. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Restore Database Backup using SQL Script (T-SQL)](https://blog.sqlauthority.com/2007/02/25/sql-server-restore-database-backup-using-sql-script-t-sql/): In this blog post we are going to learn how to restore database backup using T-SQL script. We have already database which we will use to take a backup first and right after that we will use it to restore to the server. Taking backup is an easy thing, but I have seen many times when a user tries to restore the database, it throws an error. - [SQL SERVER - Download SQL Server 2005 Books Online (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-download-sql-server-2005-books-online-february-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The February 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - SQL Server 2005 Samples and Sample Databases (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-sql-server-2005-samples-and-sample-databases-february-2007/): The samples download provides over 100 samples for SQL Server 2005, demonstrating the following components: Database Engine, including administration, data access, Full-Text Search, Common Language Runtime (CLR) integration, Server Management Objects (SMO), Service Broker, and XML Analysis Services Integration Services Notification Services Reporting Services Replication The samples databases downloads include the AdventureWorks sample online transaction processing (OLTP) database, the AdventureWorksDW sample data warehouse, and the AdventureWorksAS sample projects which you can use to build the AdventureWorksAS BI database. These databases are used in the samples and in the code examples in the SQL Server 2005 Books Online. There is also a... - [SQL SERVER - Creating Comma Separate List From Table](https://blog.sqlauthority.com/2007/02/20/deprecate-dec-2007-creating-comma-separate-list-from-table/): Update : (5/5/2007) I have updated the script to support SQL SERVER 2005. Visit :SQL SERVER – Creating Comma Separate Values List from Table – UDF – SP Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 15023: User already exists in current database.](https://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/): Error 15023: User already exists in current database. 1) This is the best Solution. First of all run following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan. USE YourDB GO EXEC sp_change_users_login 'Report' GO Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist. In following example ‘ColdFusion’ is UserName, ‘cf’ is Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in... - [SQL SERVER - Function to Convert List to Table](https://blog.sqlauthority.com/2007/02/10/sql-server-function-to-convert-list-to-table/): Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005. Visit :SQL SERVER – UDF – Function to Convert List to Table Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Constraints and Unique Key Constraints](https://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/): Primary Key: Primary Key enforces uniqueness of the column on which they are defined. Primary Key creates a clustered index on the column. Primary Key does not allow Nulls. Create table with Primary Key: CREATE TABLE Authors ( AuthorID INT NOT NULL PRIMARY KEY, Name VARCHAR(100) NOT NULL ) GO Alter table with Primary Key: ALTER TABLE Authors ADD CONSTRAINT pk_authors PRIMARY KEY (AuthorID) GO Unique Key: Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value. Alter table to add unique constraint... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case](https://blog.sqlauthority.com/2007/02/01/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case/): Following function will convert any string to Title Case. I have this function for long time. I do not remember that if I wrote it myself or I modified from original source. Run Following T-SQL statement in query analyzer: SELECT dbo.udf_TitleCase('This function will convert this string to title case!') The output will be displayed in Results pan as follows: This Function Will Convert This String To Title Case! T-SQL code of the function is: CREATE FUNCTION udf_TitleCase (@InputString VARCHAR(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(1) DECLARE @OutputString VARCHAR(255) SET @OutputString = LOWER(@InputString) SET @Index = 2... - [SQL SERVER - ReIndexing Database Tables and Update Statistics on Tables](https://blog.sqlauthority.com/2007/01/31/sql-server-reindexing-database-tables-and-update-statistics-on-tables/): SQL SERVER 2005 uses ALTER INDEX syntax to reindex database. SQL SERVER 2005 supports DBREINDEX but it will be deprecated in future versions. Let us learn how to do ReIndexing Database Tables and Update Statistics on Tables. - [SQL SERVER - Query Analyzer Short Cut to display the text of Stored Procedure](https://blog.sqlauthority.com/2007/01/30/query-analyzer-short-cut-to-display-the-text-of-stored-procedure/): This is quick but interesting trick to display the text of Stored Procedure in the result window. Open SQL Query Analyzer >> Tools >> Customize >> Custom Tab type sp_helptext against Ctrl+3 (or shortcut key of your choice) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2007/01/26/sql-server-sql-joke-sql-humor-sql-laugh/): I have heard this joke from my friend. I always wanted to write it but I was not able to find the source of the joke. This joke I have located on DavidM’s Blog on SQLTeam. It is March 1st and the first day of DBMS school The teacher starts off with a role call.. Teacher: Oracle? “Present sir” Teacher: DB2? “Present sir” Teacher: SQL Server? “Present sir” Teacher: MySQL? [Silence] Teacher: MySQL? [Silence] Teacher: Where the hell is MySQL [In rushes MySQL, unshaven, hair a mess] Teacher: Where have you been MySQL “Sorry sir I thought it was February 31st”... - [SQL SERVER - Query Analyzer Shortcuts](https://blog.sqlauthority.com/2007/01/20/sql-server-query-analyzer-shortcuts/): Download Query Analyzer Shortcuts (PDF) Shortcut Function Shortcut Function ALT+BREAK Cancel a query CTRL+SHIFT+F2 Clear all bookmarks ALT+F1 Database object information CTRL+SHIFT+INSERT Insert a template ALT+F4 Exit CTRL+SHIFT+L Make selection lowercase CTRL+A Select all CTRL+SHIFT+M Replace template parameters CTRL+B Move the splitter CTRL+SHIFT+P Open CTRL+C Copy CTRL+SHIFT+R Remove comment CTRL+D Display results in grid format CTRL+SHIFT+S Show client statistics CTRL+Delete Delete through the end of the line CTRL+SHIFT+T Show server trace CTRL+E Execute query CTRL+SHIFT+U Make selection uppercase CTRL+F Find CTRL+T Display results in text format CTRL+F2 Insert/remove bookmark CTRL+U Change database CTRL+F4 Disconnect CTRL+V Paste CTRL+F5 Parse query and check... - [SQL SERVER - Query to find number Rows, Columns, ByteSize for each table in the current database - Find Biggest Table in Database](https://blog.sqlauthority.com/2007/01/10/sql-server-query-to-find-number-rows-columns-bytesize-for-each-table-in-the-current-database-find-biggest-table-in-database/): USE DatabaseName GO CREATE TABLE #temp ( table_name sysname , row_count INT, reserved_size VARCHAR(50), data_size VARCHAR(50), index_size VARCHAR(50), unused_size VARCHAR(50)) SET NOCOUNT ON INSERT #temp EXEC sp_msforeachtable 'sp_spaceused ''?''' SELECT a.table_name, a.row_count, COUNT(*) AS col_count, a.data_size FROM #temp a INNER JOIN information_schema.columns b ON a.table_name collate database_default = b.table_name collate database_default GROUP BY a.table_name, a.row_count, a.data_size ORDER BY CAST(REPLACE(a.data_size, ' KB', '') AS integer) DESC DROP TABLE #temp Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Simple Example of Cursor](https://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/): UPDATE: For working example using AdventureWorks visit : SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2 This is the simplest example of the SQL Server Cursor. I have used this all the time for any use of Cursor in my T-SQL. DECLARE @AccountID INT DECLARE @getAccountID CURSOR SET @getAccountID = CURSOR FOR SELECT Account_ID FROM Accounts OPEN @getAccountID FETCH NEXT FROM @getAccountID INTO @AccountID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @AccountID FETCH NEXT FROM @getAccountID INTO @AccountID END CLOSE @getAccountID DEALLOCATE @getAccountID Reference: Pinal Dave (http://www.SQLAuthority.com), BOL - [SQL SERVER - Shrinking Truncate Log File - Log Full](https://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/): UPDATE: Please follow link for SQL SERVER – SHRINKFILE and TRUNCATE Log File in SQL Server 2008. Sometime, it looks impossible to shrink the Truncated Log file. Following code always shrinks the Truncated Log File to minimum size possible. USE DatabaseName GO DBCC SHRINKFILE(<TransactionLogName>, 1) BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY DBCC SHRINKFILE(<TransactionLogName>, 1) GO [Update: Please note, there are much more to this subject, read my more recent blogs. This breaks the chain of the logs and in future you will not be able to restore point in time. If you have followed this advise, you are recommended to take full... - [SQL SERVER - Fix : Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved.](https://blog.sqlauthority.com/2006/12/20/sql-server-fix-error-14274-cannot-add-update-or-delete-a-job-or-its-steps-or-schedules-that-originated-from-an-msx-server-the-job-was-not-saved/): To fix the error which occurs after the Windows server name been changed, when trying to update or delete the jobs previously created in a SQL Server 2000 instance, or attaching msdb database. Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved. Reason: SQL Server 2000 supports multi-instances, the originating_server field contains the instance name in the format ‘server\instance’. Even for the default instance of the server, the actual server name is used instead of ‘(local)’. Therefore, after the Windows server is renamed, these jobs... - [SQL SERVER - Find Stored Procedure Related to Table in Database - Search in All Stored Procedure](https://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/): Following code will help to find all the Stored Procedures (SP) which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results. ----Option 1 SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so ON sc.id=so.id WHERE sc.TEXT LIKE '%tablename%' ----Option 2 SELECT DISTINCT o.name, o.xtype FROM syscomments c INNER JOIN sysobjects o ON c.id=o.id WHERE c.TEXT LIKE '%tablename%' Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Cursor to Kill All Process in Database](https://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/): When you run the script please make sure that you run it in different database then the one you want all the processes to be killed. CREATE TABLE #TmpWho (spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150), hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150)) INSERT INTO #TmpWho EXEC sp_who DECLARE @spid INT DECLARE @tString VARCHAR(15) DECLARE @getspid CURSOR SET @getspid =   CURSOR FOR SELECT spid FROM #TmpWho WHERE dbname = 'mydb'OPEN @getspid FETCH NEXT FROM @getspid INTO @spid WHILE @@FETCH_STATUS = 0 BEGIN SET @tString = 'KILL ' + CAST(@spid AS VARCHAR(5)) EXEC(@tString) FETCH NEXT FROM @getspid INTO @spid END CLOSE @getspid DEALLOCATE @getspid DROP TABLE #TmpWho... - [SQL SERVER - Simple Cursor to Select Tables in Database with Static Prefix and Date Created](https://blog.sqlauthority.com/2006/11/30/sql-server-cursor-to-process-tables-in-database-with-static-prefix-and-date-created/): Following cursor query runs through the database and find all the table with certain prefixed ('b_','delete_'). It also checks if the Table is more than certain days old or created before certain days, it will delete it. We can have any other operation on that table like to delete, print or index. - [SQL SERVER - Auto Generate Script to Delete Deprecated Fields in Current Database](https://blog.sqlauthority.com/2006/11/20/sql-server-auto-generate-script-to-delete-deprecated-fields-in-current-database/): I always mark fields to be deprecated with “dep_” as prefix. In this way, after few days, when I am sure that I do not need the field any more I run the query to auto generate the deprecation script. The script also checks for any constraint in the system and auto generate the script to drop it also. SELECT 'ALTER TABLE ['+po.name+'] DROP CONSTRAINT [' + so.name + ']' FROM sysobjects so INNER JOIN sysconstraints sc ON so.id = sc.constid INNER JOIN syscolumns col ON sc.colid = col.colid AND so.parent_obj = col.id AND col.name LIKE 'dep[_]%' INNER JOIN sysobjects po ON so.parent_obj = po.id WHERE so.xtype = 'D' ORDER BY po.name, col.name SELECT... - [SQL SERVER - Query to Find ByteSize of All the Tables in Database](https://blog.sqlauthority.com/2006/11/10/sql-server-query-to-find-byte-size/): SELECT CASE WHEN (GROUPING(sob.name)=1) THEN 'All_Tables'    ELSE ISNULL(sob.name, 'unknown') END AS Table_name,    SUM(sys.length) AS Byte_Length FROM sysobjects sob, syscolumns sys WHERE sob.xtype='u' AND sys.id=sob.id GROUP BY sob.name WITH CUBE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database](https://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/): UPDATE : SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database This is very long query. Optionally, we can limit the query to return results for one or more than one table. SELECT K_Table = FK.TABLE_NAME, FK_Column = CU.COLUMN_NAME, PK_Table = PK.TABLE_NAME, PK_Column = PT.COLUMN_NAME, Constraint_Name = C.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME INNER JOIN ( SELECT i1.TABLE_NAME, i2.COLUMN_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1 INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME WHERE i1.CONSTRAINT_TYPE = 'PRIMARY KEY' ) PT ON PT.TABLE_NAME = PK.TABLE_NAME ---- optional: ORDER BY 1,2,3,4 WHERE PK.TABLE_NAME='something'WHERE FK.TABLE_NAME='something'... - [SQL SERVER - Fix : Error : 1326 Cannot connect to Database Server Error: 40 - Could not open a connection to SQL Server](https://blog.sqlauthority.com/2008/08/09/sql-server-fix-error-1326-cannot-connect-to-database-server-error-40-could-not-open-a-connection-to-sql-server/): If you are receiving the following error related to connection to SQL Server, this blog is for you.  - [SQLAuthority News - Security Update for SQL Server 2000 Service Pack 4 and MSDE 2000](https://blog.sqlauthority.com/2008/08/08/sqlauthority-news-security-update-for-sql-server-2000-service-pack-4-and-msde-2000/): If you are still using SQL Server 2000 (you should have upgraded to SQL Server 2005 by now), there is Security Upgrade for Service Pack 4 and MSDE. Download SQL Server 2000 Security Upgrade Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Released To Manufacturing Available](https://blog.sqlauthority.com/2008/08/08/sql-server-2008-released-to-manufacturing-available/): Microsoft has Released To Manufacturing available for SQL Server 2008. Released To Manufacturing (RTM) means that code of SQL Server 2008 has been approved by MS team and it is being send to manufacture. It will be while before it is available on distribute media on store shelves. Currently it is available for download by MSDN and TechNet subscribers. I want to congratulate MS SQL Server team for releasing the version of SQL Server on time. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - EXCEPT Clause in SQL Server is Similar to MINUS Clause in Oracle](https://blog.sqlauthority.com/2008/08/07/sql-server-except-clause-in-sql-server-is-similar-to-minus-clause-in-oracle/): One of the JR. Developer asked me a day ago, does SQL Server has similar operation like MINUS clause in Oracle. Absolutely, EXCEPT clause in SQL Server is exactly similar to MINUS operation in Oracle. The EXCEPT query and MINUS query returns all rows in the first query that are not returned in the second query. Each SQL statement within the EXCEPT query and MINUS query must have the same number of fields in the result sets with similar data types. Let us see that using example below. First create table in SQL Server and Oracle. CREATE TABLE EmployeeRecord (EmpNo INT... - [SQL SERVER - Query to Find Column From All Tables of Database](https://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/): One question came up just a day ago while I was writing SQL SERVER – 2005 – Difference Between INTERSECT and INNER JOIN – INTERSECT vs. INNER JOIN. How many tables in database AdventureWorks have column name like ‘EmployeeID’? It was quite an interesting question and I thought if there are scripts which can do this would be great. I quickly wrote down following script which will go return all the tables containing specific column along with their schema name. USE AdventureWorks GO SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name, c.name AS column_name FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID... - [SQL SERVER - 2005 - Get Field Name and Type of Database Table](https://blog.sqlauthority.com/2008/08/05/sql-server-2005-get-field-name-and-type-of-database-table/): In today’s article we will see question of one of reader Mohan and answer from expert Imran Mohammed. Imran thank you for answering question of Mohan. Question of Mohan: hi all, how can i get field name and type etc. in MS-SQL server 2005. is there any query available??? Answer from Imran Mohammed: @mohan use database_name Sp_help table_name This stored procedure gives all the details of column, their types, any indexes, any constraints, any identity columns and some good information for that particular table. Second method: select column_name ‘Column Name’, data_type ‘Data Type’, character_maximum_length ‘Maximum Length’ from information_schema.columns where table_name =... - [SQLAuthority News - SQLAuthority Site With New Banner](https://blog.sqlauthority.com/2008/08/04/sqlauthority-news-sqlauthority-site-with-new-banner/): I am glad to inform all the blog readers regarding new updated banner of this site. I would like to thank Ritesh, Sanjay and Rashmika who have spent their time to create the banner and gift to SQLAuthority. I really liked the new banner and I think it goes better with the theam of this site. Let me know what is your opinion about new banner. Old Banner : New Banner : (Click on banner) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Difference Between INTERSECT and INNER JOIN - INTERSECT vs. INNER JOIN](https://blog.sqlauthority.com/2008/08/03/sql-server-2005-difference-between-intersect-and-inner-join-intersect-vs-inner-join/): INTERSECT operator in SQL Server 2005 is used to retrieve the common records from both the left and the right query of the Intersect Operator. INTERSECT operator returns almost same results as INNER JOIN clause many times. When using INTERSECT operator the number and the order of the columns must be the same in all queries as well data type must be compatible. Let us see understand how INTERSECT and INNER JOIN are related.We will be using AdventureWorks database to demonstrate our example. Example 1: Simple Example of INTERSECT SELECT * FROM HumanResources.EmployeeDepartmentHistory WHERE EmployeeID IN (1,2,3) INTERSECT SELECT * FROM... - [SQL SERVER - Effect of Order of Join In Query](https://blog.sqlauthority.com/2008/08/02/sql-server-effect-of-order-of-join-in-query/): Let us try to understand this subject with example. We will use Adventurworks database for this purpose. Table which we will be using are HumanResources.Employee (290 rows), HumanResources.EmployeeDepartmentHistory (296 rows) and HumanResources.Department (16 rows). We will be running following two queries and observe the output. In the resultset the order of first column (EmployeeID) is different in both the cases when whole resultset is same. When compared both the results they are same but the order of rows is different in both the resultset. Query 1 : SELECT he.EmployeeID, he.Title, hd.Name, hd.GroupName, hdh.StartDate FROM HumanResources.Employee he LEFT JOIN HumanResources.EmployeeDepartmentHistory hdh ON... - [SQL SERVER - 2008 - Get Current System Date Time](https://blog.sqlauthority.com/2008/08/01/sql-server-2008-get-current-system-date-time/): How to get current system date time in SQL Server? - [SQL SERVER - 2008 - Find Current System Date Time and Time Offset](https://blog.sqlauthority.com/2008/07/31/sql-server-2008-find-current-system-date-time-and-time-offset/): If you want to find current datetime in SQL Server I suggest to read the following post : SQL SERVER – Retrieve Current Date Time in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()} This post is related to new feature available in SQL Server 2008. In SQL Server 2008 there is a function which provides current offset of the system from GMT time as well. Basically it shows the system datetime with offset. I think this can be useful in some of the instances where SQL Server are depending on the time offset. SELECT SYSDATETIMEOFFSET() AS 'Windows System Time' GO Reference : Pinal Dave... - [SQLAuthority News - Author BirthDay - SQL Server Birthday](https://blog.sqlauthority.com/2008/07/30/sqlauthority-news-author-birthday-sql-server-birthday/): It always suprise me how many people remember my birthday and take time from their busy life to call me, email me, wish me or send me their warm greetings. I would like to express my gratitude to them. Today is my birthday and I had decided to take a day off and does not talk about SQL Server. Due to urgent matter at my work, I am at office working just like usual. Well, when I decide not to talk about SQL Server today on blog, let us talk about birthdays. Let me ask all of you one question about... - [SQL SERVER - SQL SERVER - Simple Example of Recursive CTE - Part 2 - MAXRECURSION - Prevent CTE Infinite Loop](https://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/): Yesterday I wrote about SQL SERVER – SQL SERVER – Simple Example of Recursive CTE. I right away received email from regular reader John Mildred that if I can prevent infinite recursion of CTE. Sure! recursion can be limited. Use the option of MAXRECURSION. USE AdventureWorks GO WITH Emp_CTE AS ( SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate FROM HumanResources.Employee WHERE ManagerID IS NULL UNION ALL SELECT e.EmployeeID, e.ContactID, e.LoginID, e.ManagerID, e.Title, e.BirthDate FROM HumanResources.Employee e INNER JOIN Emp_CTE ecte ON ecte.EmployeeID = e.ManagerID ) SELECT * FROM Emp_CTE OPTION (MAXRECURSION 5) GO Now if your CTE goes beyond 5th recursion it will throw an... - [SQL SERVER - Simple Example of Recursive CTE](https://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/): Recursive is the process in which the query executes itself. It is used to get results based on the output of base query. We can use CTE as Recursive CTE (Common Table Expression). You can read my previous articles about CTE by searching at http://search.SQLAuthority.com . Here, the result of CTE is repeatedly used to get the final resultset. The following example will explain in detail where I am using AdventureWorks database and try to find hierarchy of Managers and Employees. USE AdventureWorks GO WITH Emp_CTE AS ( SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate FROM HumanResources.Employee WHERE ManagerID IS NULL... - [SQL SERVER - mssqlsystemresource - Resource Database](https://blog.sqlauthority.com/2008/07/27/sql-server-mssqlsystemresource-resource-database/): Just a day ago I received following email “Dear Pinal, While I was exploring my computer in directory C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data I have found database mssqlsystemresource. What is mssqlsystemresource? Thanks, Joseph Kazeka” Simple question like this are very interesting. mssqlsystemresource is Resource Database. It is read only database and contains system objects (i.e. sys.objects, sys.modules and other sys schema objects). Resource database does not contain any of user data. The purpose of resource database is to facilitates upgrading to new version of SQL Server without any hassle. In previous versions whenever version of SQL Server was upgraded all the previous... - [SQLAuthority News - Readers Selection - Readers Most Favorite Articles](https://blog.sqlauthority.com/2008/07/26/sqlauthority-news-readers-selection-readers-most-favorite-articles/): I have been receiving many emails from my readers about their favorite article. Few days ago, I asked in one of my post SQLAuthority News – Updated My Personal Book Mark Pages, which articles are most favorite articles of my readers. I have received tremendous response to my question and my mailbox overflowed. Based on readers response I have created list of readers most favorite articles. Let me know which one is your most favorite article. SQLAuthority News – Reader’s Selection Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQLAuthority T-Shirts, Mug, Hat and Other Product](https://blog.sqlauthority.com/2008/07/25/sqlauthority-news-sqlauthority-t-shirts-mug-hat-and-other-product/): I frequently get request for SQLAuthority T-Shirts. After continuous requests from many of loyal readers, I am posting link to SQLAuthoirty Products. SQLAuthority Products I have no intention to make money from this site or any product sale. All the product are sold from the site directly at no profit or profit sent to Child Rights and You directly. If this blog has been helpful to you and if you want to help me. Please stand up for the child rights. Donate money to Child Rights and You by visiting their site directly. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC SHRINKFILE Takes Long Time to Run](https://blog.sqlauthority.com/2008/07/25/sql-server-dbcc-shrinkfile-takes-long-time-to-run/): If you are DBA who are involved with Database Maintenance and file group maintenance, you must have experience that many times DBCC SHRINKFILE operations takes long time but any other operations with Database are relative quicker. Rebuilding index is quite resource intensive task but that happens faster than DBCC SHRINKFILE. Well, answer to this is very simple. DBCC SHRINKFILE is a single threaded operation. A single threaded operation does not take advantage of multiple CPUs and have no effect how many RAM are available. Hyperthreaded CPU even provides worst performance. If you rebuild indexes before you run DBCC SHRINKFILE operations, shrinking... - [SQL SERVER - 2005 -Track Down Active Transactions Using T-SQL](https://blog.sqlauthority.com/2008/07/24/sql-server-2005-track-down-active-transactions-using-t-sql/): Just a day ago, I was wondering how many active transaction are currently in my database. I found following DMV very useful – very simple and to the point. Following SQL will return currently active transaction. SELECT * FROM sys.dm_tran_session_transactions Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Log Viewer](https://blog.sqlauthority.com/2008/07/23/sql-server-introduction-to-log-viewer/): SQL Server log data is very important for any DBA to troubleshoot SQL Server related problems. In SQL Server 2000 there was no facility to check System and Application log, however in SQL Server 2005 there is facility of the log viewer. It is very useful tool and very easy to use as well. In SQL Server 2005 all the windows event logs can be seen along with SQL Server logs. Interface for all the logs is same and can be launched from the same place. This log can be exported and filtered as well. Following two images describes the how... - [SQL SERVER - Clear SQL Server Memory Caches](https://blog.sqlauthority.com/2008/07/22/sql-server-clear-sql-server-memory-caches/): If SQL Server is running slow and operations are throwing errors due to lack of memory, it is necessary to look into memory issue. If SQL Server is restarted all the cache memory is automatically cleaned up. In production server it is not possible to restart the server. In this scenario following three commands can be very useful. When executed following three commands will free up memory for SQL Server by cleaning up its cache. DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX - ERROR : 9004 An error occurred while processing the log for database. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log.](https://blog.sqlauthority.com/2008/07/21/sql-server-fix-error-9004-an-error-occurred-while-processing-the-log-for-database-if-possible-restore-from-backup-if-a-backup-is-not-available-it-might-be-necessary-to-rebuild-the-log/): ERROR : 9004 An error occurred while processing the log for database. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log. If you receive above error it means you are in great trouble. This error occurs when database is attempted to attach and it does not get attached. I have solved this error using following methods. Hope this will help anybody who is facing the same error. Microsoft suggest there are two solution to this problem. 1) Restore from a backup. Create Empty Database with same name and physical files (.ldf... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - July 19 2008](https://blog.sqlauthority.com/2008/07/21/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-july-19-2008/): Ahmedabad SQL Server User Group is just 2 months old chapter but it is getting extremely popular among enthusiastic IT professionals. I have joined this group and suggest all the developers of Ahmedabad and surrounding areas to join this group. It does not matter which application you are using but SQL Server is same everywhere. Ahmedabad SQL Server User Group is very fortunate to have Jacob Sebastian (SQL Server MVP) as President of the Usergroup. Jacob is co-founder and CTO of Excellence Infonet, Ahmedabad. You can read his articles at http://jacobsebastian.blogspot.com and www.sqlkatmai.com. In recent meeting I had presented learning session... - [SQL SERVER - Change the Port of Service Broker Configuration](https://blog.sqlauthority.com/2008/07/20/sql-server-change-the-port-of-service-broker-configuration/): Just two days ago, I wrote a small note about SQL SERVER - Introduction to Service Broker. - [SQL Server - Fix - Error : 9692 The _MSG protocol transport cannot listen on port because it is in use by another process.](https://blog.sqlauthority.com/2008/07/19/sql-server-fix-error-9692-the-_msg-protocol-transport-cannot-listen-on-port-because-it-is-in-use-by-another-process/): If you face following error the solution of this is very simple. Error : 9692 The _MSG protocol transport cannot listen on port because it is in use by another process. Above error comes up with Service Broker. Service Broker is used to send Database Emails. Read more about SQL SERVER – Introduction to Service Broker. Solution/Fix/WorkAround: Option 1: Run netstat -aon on command prompt and determine what program is using the port described in the error. Once figured out disable the application which is using that port. Option 2: Alternatively, the port on which Service Broker is running can be... - [SQL SERVER - Introduction to Service Broker](https://blog.sqlauthority.com/2008/07/18/sql-server-introduction-to-service-broker/): Service Broker is message queuing for SQL Server. It is used for sending emails and through Database Mails. You can read about SQL SERVER – Difference Between Database Mail and SQLMail here. Service Broker is feature which provides facility to SQL Server to send an asynchronous, transactional message. - [SQLAuthority News - Updated My Personal Book Mark Pages](https://blog.sqlauthority.com/2008/07/18/sqlauthority-news-updated-my-personal-book-mark-pages/): It has been long time since I have updated my personal book mark list. I have just refreshed it. You are all welcome to checkout my personally picked articles. SQLAuthority Best Articles SQLAuthority Favorite Articles I often visit above two links to read my selected articles. If you have any personal favorite from SQLAuthority.com and I have not included that to my list you can let me know and if I like it I will add to that list. I am also going to start new list very soon, which will be Readers Chosen Articles. So I suggest you start suggesting... - [SQLAuthority News - Ahmedabad SQL Server Usergroup Meeting](https://blog.sqlauthority.com/2008/07/17/sqlauthority-news-ahmedabad-sql-server-usergroup-meeting/): I will be attending Ahmedabad SQL Server Usergroup Meeting on July 19, 2008. I will be taking session about “SQL Server Best Practices“. I invite all of the SQL enthusiastic to stop by User Group Meeting and meet all the fellow developers, DBAs and members. Location : 401, TIME SQUARE, CG road, Op Bazar Calcutta, Ahmedabad, India Date and Time : July 19, 2008 6:30 PM onwards Hope to see all of you there. If you with to attend the meeting, please register your name by sending an email to jacob.reliancesp[at]gmail.com latest by Saturday 12 Noon. And for those of you... - [SQL SERVER - Readers Contribution to Site - Simple Example of Cursor](https://blog.sqlauthority.com/2008/07/16/sql-server-readers-contribution-to-site-simple-example-of-cursor/): eaders are very important to me. Without their active participation this site would not be the community helping web site. I encourage readers participation and request that you help other users with your knowledge. I recently come across very good communication between two of blog readers. I want to thank you Imran Mohammed for taking time to answer this question as well many other questions. Expert like Imran makes this world better. Let us read the question from Anthony from here. All, I am using Microsoft SQL 2005 and am trying to create a cursor that will take data from several... - [SQL SERVER - Deferred Name Resolution](https://blog.sqlauthority.com/2008/07/15/sql-server-deferred-name-resolution/): One of my Jr. Developer always wondered when she creates any Stored Procedure (SP) and if there is incorrect table name in the SP it creates the SP fine but while executing it gives run time error. However, if there is any valid table from database is referenced in SP with incorrect column name it will not let user create SP at all. Question : How come when table name is incorrect SP can be created successfully but when incorrect column is used SP can not be created? Answer : Deferred Name Resolution of database is the root cause for this... - [SQL SERVER - 2008 - Introduction to SPARSE Columns - Part 2](https://blog.sqlauthority.com/2008/07/14/sql-server-2008-introduction-to-sparse-columns-part-2/): Previously I wrote about SQL SERVER – 2008 – Introduction to SPARSE Columns. Let us understand the concept of SPARSE column in more detail. I suggest you read the first part before continuing reading this article. All SPARSE columns are stored as one XML column in database. Let us see some of the advantage and disadvantage of SPARSE column. Advantages of SPARSE column are: INSERT, UPDATE, and DELETE statements can reference the sparse columns by name. SPARSE column can work as one XML column as well. SPARSE column can take advantage of filtered Indexes, where data are filled in the row.... - [SQL SERVER - SP_CONFIGURE - Displays or Changes Global Configuration Settings](https://blog.sqlauthority.com/2008/07/13/sql-server-sp_configure-displays-or-changes-global-configuration-settings/): It is very good to know our server and its feature which are available for configurations. SQL Server always has many features which can be enabled or disabled. One should at least know what are the options SQL Server provides. This blog post we will learn how to display or change global configuration settings. - [SQL SERVER - 2008 - User Account - sa or sysadmin](https://blog.sqlauthority.com/2008/07/12/sql-server-2008-user-account-sa-or-sysadmin/): Just a day ago, I noticed ‘sysadmin’ user in SQL Server 2008. While looking more into it, I found that it has same account rights as ‘sa’ account. ‘sysadmin’ is actually replacement for legacy ‘sa’ account. ‘sa’ still exist in SQL Server 2008, however, it will be deprecated in future versions of SQL Server. It is recommended to all the users who switch to SQL Server 2008 to start migrating to ‘sysadmin’ from ‘sa’. - [SQL SERVER - 2005 - Two Important Security Update](https://blog.sqlauthority.com/2008/07/11/sql-server-2005-two-important-security-update/): If you are using SQL Server 2005, following two are very important security updates not to be missed. Security Update for SQL Server 2005 Service Pack 2 (KB948108) A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. Security Update for SQL Server 2005 Service Pack 2 (KB948109) A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Introduction to SPARSE Columns](https://blog.sqlauthority.com/2008/07/10/sql-server-2008-introduction-to-sparse-columns/): I have been writing recently about how SQL Server 2008 is better in terms of Data Stage and Backup Management. I have received very good replies from many users and have requested to write more about it. Today we will look into another interesting concept of SPARSE column. The reason I like this feature because it is way better in terms of how columns are managed in SQL Server. SPARSE column are better at managing NULL and ZERO values in SQL Server. It does not take any space in database at all. If column is created with SPARSE clause with it... - [SQL SERVER - 2008 - Two Convenient Features Inline Assignment - Inline Operations](https://blog.sqlauthority.com/2008/07/09/sql-server-2008-two-convenient-features-inline-assignment-inline-operations/): Sometimes things just go very convenient and we wish that how come it was not available in earlier versions. Let us see two features here. If it was SQL Server earlier versions we might have to write more lines to achieve what we can achieve in lesser lines. Following small example with only one variable demonstrates this feature. SQL Server 2005 version: DECLARE @idx INT SET @idx = 0 SET @idx = @idx + 1 SELECT @idx GO SQL Server 2008 version: This version demonstrates two important feature of Inline Assignment and Inline Operations DECLARE @idx INT = 0 SET @idx+=1 SELECT... - [SQL SERVER - Find Space Used For Any Particular Table](https://blog.sqlauthority.com/2008/07/08/sql-server-find-space-used-for-any-particular-table/): We often run out of the space in our drive and that is the number 1 cause of SQL Server engine stop running on various machines. Quite often we wonder how much space if any of the objects takes in the database. It is very simple to find out the space used by any table in the database. - [SQLAuthority News - Thank You to Awarding Author SQL MVP](https://blog.sqlauthority.com/2008/07/07/sqlauthority-news-thank-you-to-awarding-author-sql-mvp/): I received award from Microsoft for SQL Server Most Valuable Professional a week ago. I have received many many congratulations messages from many readers for getting this award. I thank all of you for sending me messages and your wishes. Honestly, I think this is all of yours award and I am just receiving this award for everybody who is reading and participating on this community forum. My goal is that more and more user participation occurs on this website and I publish few articles which are really contribution from readers. If you are reading this blog and have any idea... - [SQL SERVER - 2008 - Introduction to Row Compression](https://blog.sqlauthority.com/2008/07/06/sql-server-2008-introduction-to-row-compression/): In my previous article SQL SERVER – 2008 – Introduction to New Feature of Backup Compression I wrote about Row Compression and I have received many request to write in detail about Row Compression. I like when I get request about any subject to write about from my readers. Row Compression feature apply to zeros and null values and optimize their space in SQL Server. In fact, due to Row Compression feature SQL Server does not take any disk space for zero or null values. Any datatypes (decimal, datetime, money, int etc) if they are storing zero or null values in... - [SQL SERVER - Difference Between Database Mail and SQLMail](https://blog.sqlauthority.com/2008/07/05/sql-server-difference-between-database-mail-and-sqlmail/): In recent user group meeting in my city Ahmedabad, I have found that not every user knows difference between these two features of SQL Server. I do not blame any user for not knowing difference between Database Mail and SQLMail as this is very confusing sometime. I will try to explain this concept here. - [SQL SERVER - Deprecated DataType vardecimal](https://blog.sqlauthority.com/2008/07/04/sql-server-deprecated-datatype-vardecimal/): I received following email yesterday from Satnam Singh- Computer Programmer from Bangalore. “Dear Pinal, Congratulations for being MVP. You truely deserved it. I wonder why have you never written newly introduced feature of vardecimal. Keep up good work! Satnam Singh Developer – Bangalore.” In SQL Server 2005 SP2 they have introduced new concept of vardecimal, which reduces the size of zero and null values. Generically vardecimal values ranges upto 20 bytes in storage place, however when zero or null values are used it reduces the values to only 2 bytes, this way it saves valuable storage place. This feature is now... - [SQL SERVER - 2008 - Introduction to New Feature of Backup Compression](https://blog.sqlauthority.com/2008/07/03/sql-server-2008-introduction-to-new-feature-of-backup-compression/): Backup and Data Storage is my most favorite subject and I have not written about this for some time. I was experimenting with new feature of SQL Server 2008 and I come across very interesting feature of Backup compression. Let us see example of Database AdventureWorks with and without compression. After taking backup with compression enabled and without compression the file size can be compared to see the difference it makes with compressing the database. BACKUP DATABASE AdventureWorks TO DISK='C:\Backup\AW_NoCompression.bak' GO BACKUP DATABASE AdventureWorks TO DISK='C:\Backup\AW_WithCompression.bak' WITH COMPRESSION GO SQL Server 2008 supports backup data compression at database level. First of... - [SQL SERVER - 2008 - Insert Multiple Records Using One Insert Statement - Use of Row Constructor](https://blog.sqlauthority.com/2008/07/02/sql-server-2008-insert-multiple-records-using-one-insert-statement-use-of-row-constructor/): I previously wrote article about SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL. I am glad that in SQL Server 2008 we have new feature which will make our life much more easier. We will be able to insert multiple rows in SQL with using only one SELECT statement. Previous method 1: USE YourDB GO INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('First',1); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Second',2); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Third',3); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Fourth',4); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Fifth',5); GO Previous method 2:... - [SQLAuthority News - Microsoft Most Valuable Professional Award for SQL Server - MVP](https://blog.sqlauthority.com/2008/07/01/sqlauthority-news-microsoft-most-valuable-professional-award-for-sql-server-mvp/): I am very glad to announce that Microsoft has awarded me Most Valuable Professional Award for SQL Server. I would like to thank Microsoft and MVP Lead Abhishek for awarding this honor to me. MVP is most prestigious award and I am very pleased to receive it. I thank all of my readers for their continuous support in my journey. Please feel free to contact me if you need any help or assistance. Pinal Dave SQL – MVP, MCDBA, MCAD, MCP Bachelors of Engineering (Electronics and Communications), Masters of Science (Computer Networks) Founder – SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - High Availability - Hot Add Memory](https://blog.sqlauthority.com/2008/06/30/sql-server-2008-high-availability-hot-add-memory/): After reading my previous article about SQL SERVER – 2008 – High Availability – Hot Add CPU the same developer who suggested Hot Add CPU asked me if there are any restrictions in Hot Adding Memory. Yes, there are few restictions to Hot Add Memory as well. I am listing them here. 1) Underlying hardware is always key concern. Hardware should be capable to add memory when previous memories are operational. 2) Operating system should be either Windows Server 2003 or 2008 Enterprise or Datacenter Edition. 3) This feature is only available in 64-bit SQL Server Enterprise Edition, or the 32-bit... - [SQLAuthority News - Rise in SQL Injection Attacks Exploiting Unverified User Data Input](https://blog.sqlauthority.com/2008/06/29/sqlauthority-news-rise-in-sql-injection-attacks-exploiting-unverified-user-data-input/): Microsoft is aware of a recent escalation in a class of attacks targeting Web sites that use Microsoft ASP and ASP.NET technologies but do not follow best practices for secure Web application development. These SQL injection attacks do not exploit a specific software vulnerability, but instead target Web sites that do not follow secure coding practices for accessing and manipulating data stored in a relational database. When a SQL injection attack succeeds, an attacker can compromise data stored in these databases and possibly execute remote code. Clients browsing to a compromised server could be forwarded unknowingly to malicious sites that may... - [SQL SERVER - 2008 - High Availability - Hot Add CPU](https://blog.sqlauthority.com/2008/06/28/sql-server-2008-high-availability-hot-add-cpu/): One of team member suggested that we should upgrade to SQL Server 2008 because its new feature is very cool “Hot Add CPU”. Yes, I agree it is very cool feature. I am eagerly waiting for RTM of SQL Server 2008 so I can upgrade our servers to SQL Server 2008. However, to use the feature of High Availability of “Hot Add CPU” has many restrictions and I am not sure we will be in need of that right away or for atleast couple of year. Let us look at few of the restrictions for using Hot Add CPU 1) Hardware... - [SQL SERVER - Difference Between DBMS and RDBMS](https://blog.sqlauthority.com/2008/06/27/sql-server-difference-between-dbms-and-rdbms/): What is the difference between DBMS and RDBMS? DBMS – Data Base Management System RDBMS – Relational Data Base Management System or Relational DBMS A DBMS has to be persistent, that is it should be accessible when the program created the data ceases to exist or even the application that created the data restarted. A DBMS also has to provide some uniform methods independent of a specific application for accessing the information that is stored. RDBMS adds the additional condition that the system supports a tabular structure of the data, with enforced relationships between the tables. This excludes the databases that... - [SQLAuthority News - Famous Quotes From Bill Gates - Part 2](https://blog.sqlauthority.com/2008/06/26/sqlauthority-news-famous-quotes-from-bill-gates-part-2/): My previous article about Bill Gates SQLAuthority News – Famous Quotes From Bill Gates got really lots of readers and got lots of request in email that I should have follow up article about other famous quotes from Bill Gates which are missing from original article. This blog is not about Quotes but SQL Server, but little fun never hurts. SQL Server is product of Microsoft, which Bill Gates is Chairman of, so indirectly this article is about SQL Server. “The computer was born to solve problems that did not exist before.” – Bill Gates “Your most unhappy customers are your... - [SQLAuthority Download - SQL Server Cheatsheet](https://blog.sqlauthority.com/2008/06/25/sqlauthority-download-sql-server-cheatsheet/): I think this is most popular question I receive in email, if I have SQL Server cheat sheet. Well, SQL Server is very wide subject and covering all the main topics of SQL Server will take 100 pages book as cheat sheet. I have tried to create one page cheat sheet which I use for my daily use. I use this quite often and my teammates uses them as well. You can download and print this cheat sheet and use it for your personal reference. If you have any suggestions, please let me know and I will see if I can... - [SQLAuthority News - Microsoft Source Code Analyzer for SQL Injection](https://blog.sqlauthority.com/2008/06/24/sqlauthority-news-microsoft-source-code-analyzer-for-sql-injection/): Microsoft Source Code Analyzer for SQL Injection is a static code analysis tool for finding SQL Injection vulnerabilities in ASP code. Customers can run the tool on their ASP source code to help identify code paths that are vulnerable to SQL Injection attacks. Perform the following steps to download and install the Microsoft Source Code Analyzer for SQL Injection: 1. Download msscasi_asp_pkg.exe to a temporary directory. 2. Run msscasi_asp_pkg.exe. 3. Enter an installation directory when prompted. 4. After extracting the files, read the usage section of the Readme.htm file for next steps. Download Code Analyzer Abstract courtesy : Microsoft Reference :... - [SQLAuthority News - Release Notes for SQL Server 2008 Release Candidate 0](https://blog.sqlauthority.com/2008/06/23/sqlauthority-news-release-notes-for-sql-server-2008-release-candidate-0/): All product should be documented. Particularly when any release happens product must have release notes because release notes educates people about product and its usage. Microsoft has also release notes for SQL Server 2008. This Release Notes document contains information for Microsoft SQL Server 2008 Release Candidate 0 (RC0) that supplements the SQL Server 2008 RC0 Readme and Books Online documentation. Download Release Notes Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Create Check Constraint on Column](https://blog.sqlauthority.com/2008/06/22/sql-server-create-check-constraint-on-column/): I found one of the Jr. Developer writing trigger for the requirement where he wanted to make sure invalidate data does not enter in table column. I suggested him to write Check Constraint. Check Constraints are very handy to make sure all the data in the table is validated before it enters in the database. Let us check constraint on over one of the table on postalcode table in database AdventureWorks database. Constraint will suggest that value which is larger than 11 character can not be inserted into the column. Once constraint is created, it can be tested by tring to... - [SQLAuthority News - White Paper: Security Overview for Database Administrators](https://blog.sqlauthority.com/2008/06/21/sqlauthority-news-white-paper-security-overview-for-database-administrators/): Note:   Download White Paper by Microsoft SQL Server 2008 is secure by design, default, and deployment. Microsoft is committed to communicating information about threats, countermeasures, and security enhancements as necessary to keep your data as secure as possible. This paper covers some of the most important security features in SQL Server 2008. It tells you how, as an administrator, you can install SQL Server securely and keep it that way, even as applications and users make use of the data stored within. Included in This Document * Introduction * Secure Configuration o Windows Update o Surface Area Configuration * Authorization o... - [SQL SERVER - Find Current Identity of Table](https://blog.sqlauthority.com/2008/06/20/sql-server-find-current-identity-of-table/): Many times we need to know what is the current identity of the column. I have found one of my developer using aggregated function MAX() to find the current identity. USE AdventureWorks GO SELECT MAX(AddressID) FROM Person.Address GO However, I prefer following DBCC command to figure out current identity. USE AdventureWorks GO DBCC CHECKIDENT ('Person.Address') GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - White Paper: SQL Server 2008 Compared to Oracle Database 11g](https://blog.sqlauthority.com/2008/06/19/sqlauthority-news-white-paper-sql-server-2008-compared-to-oracle-database-11g/): Note: Download White Paper by Microsoft Microsoft SQL Server has steadily gained ground on other database systems and now surpasses the competition in terms of performance, scalability, security, developer productivity, business intelligence (BI), and compatibility with the 2007 Microsoft Office System. It achieves this at a considerably lower cost than does Oracle Database 11g. - [SQLAuthority News - Famous Quotes From Bill Gates](https://blog.sqlauthority.com/2008/06/18/sqlauthority-news-famous-quotes-from-bill-gates/): Bill Gates Quotes – “Success is a lousy teacher. It seduces smart people into thinking they can’t lose.” “Until we’re educating every kid in a fantastic way, until every inner city is cleaned up, there is no shortage of things to do.” “If I’d had some set idea of a finish line, don’t you think I would have crossed it years ago?” “If I had to say what is the thing that I feel best about, it’s being involved in this whole software revolution and what comes out of that.” “Whenever new technologies come along, parents have a legitimate concern about... - [SQL SERVER - 2008 - SQL Server Start Time](https://blog.sqlauthority.com/2008/06/17/sql-server-2008-sql-server-start-time/): I have been playing with SQL Server 2008 recently. There are many new features which SQL Server 2008 have. One of the interesting addition to SQL Server 2008 is system table field which records when SQL Server was started. This field has data type as datetime that is why it is precise to 3 milisecond. Note : This will not work with SQL Server 2005 or earlier version. This works with SQL Server 2008 only. SELECT sqlserver_start_time FROM sys.dm_os_sys_info ResultSet: sqlserver_start_time ———————– 2008-06-27 20:51:53.317 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to SERVERPROPERTY and example](https://blog.sqlauthority.com/2008/06/16/sql-server-introduction-to-serverproperty-and-example/): SERVERPROPERTY is very interesting system function. It returns many of the system values. I use it very frequently to get different server values like Server Collation, Server Name etc. Run following script to see all the properties of server. SELECT 'BuildClrVersion' ColumnName, SERVERPROPERTY('BuildClrVersion') ColumnValue UNION ALL SELECT 'Collation', SERVERPROPERTY('Collation') UNION ALL SELECT 'CollationID', SERVERPROPERTY('CollationID') UNION ALL SELECT 'ComparisonStyle', SERVERPROPERTY('ComparisonStyle') UNION ALL SELECT 'ComputerNamePhysicalNetBIOS', SERVERPROPERTY('ComputerNamePhysicalNetBIOS') UNION ALL SELECT 'Edition', SERVERPROPERTY('Edition') UNION ALL SELECT 'EditionID', SERVERPROPERTY('EditionID') UNION ALL SELECT 'EngineEdition', SERVERPROPERTY('EngineEdition') UNION ALL SELECT 'InstanceName', SERVERPROPERTY('InstanceName') UNION ALL SELECT 'IsClustered', SERVERPROPERTY('IsClustered') UNION ALL SELECT 'IsFullTextInstalled', SERVERPROPERTY('IsFullTextInstalled') UNION ALL SELECT 'IsIntegratedSecurityOnly', SERVERPROPERTY('IsIntegratedSecurityOnly') UNION ALL... - [SQL SERVER - 2008 - Inline Variable Assignment](https://blog.sqlauthority.com/2008/06/15/sql-server-2008-inline-variable-assignment/): I loved this feature. I have always wanted this feature to be present in SQL Server. Last time when I met developers from Microsoft SQL Server, I had talked about this feature. I think this feature saves some time but make the code more readable. ---- SQL Server 2005 Way DECLARE @MyVar INT SET @MyVar = 5 SELECT @MyVar AS TestVar GO ---- SQL Server 2008 Way DECLARE @MyVar INT&nbsp;= 5 SELECT @MyVar AS TestVar GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 600 Article and Over 3 Million Readers](https://blog.sqlauthority.com/2008/06/14/sqlauthority-news-600-article-and-over-3-million-readers/): Today is 600th article on this blog and so far over 3 Million readers have visited this blog. Popularity of this blog is increating everyday due to active participation from some good readers. When people share their ideas and their opinion whole world becomes better place. I encourage all of my readers to send me their thoughts, articles and ideas. I will be happy to share tips and tricks of readers with this blog. I have received many emails where people have asked me why I do not write about my favorite articles on this blog. Well, actually I do write... - [SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server](https://blog.sqlauthority.com/2008/06/13/sql-server-2008-introduction-to-policy-management-enforcing-rules-on-sql-server/): I have previous written article about SQL SERVER Database Coding Standards and Guidelines Complete List Download. I just received question from one of the blog reader is there any way we can just prevent violation of company policy. Well Policy Management can come into handy in this scenario. - [SQL SERVER - 2008 - Step By Step Installation Guide With Images](https://blog.sqlauthority.com/2008/06/12/sql-server-2008-step-by-step-installation-guide-with-images/): SQL SERVER 2008 Release Candidate 0 has been released for some time and I have got numerous request about how to install SQL Server 2008. I have created this step by step guide Installation Guide. Images are used to explain the process easier. - [SQL SERVER - 2008 - Four Key Pillars](https://blog.sqlauthority.com/2008/06/11/sql-server-2008-four-key-pillars/): As SQL Server 2008 is now ready to ship its final product in few months, I get many questions about what is new and attractive in SQL Server 2008. SQL SERVER 2008 has four key pillars. 1) Enterprise Data Platform It has heavily reliable database platform and can be expanded very quickly. IT also supports Hardware Security Module and Enterprise Key Management tools. Performance is key feature of SQL Server 2008. 2) Beyond Relational This edition supports spatial datatypes, which can be used for Global Positioning System and Geographic Information System. Additionally, arbitrary size of the files can be stored in... - [SQL SERVER - Microsoft SQL Server 2008 Reporting Services Add-in for Microsoft SharePoint Technologies](https://blog.sqlauthority.com/2008/06/10/sql-server-microsoft-sql-server-2008-reporting-services-add-in-for-microsoft-sharepoint-technologies/): Note: Download Here by Microsoft Microsoft SQL Server 2008 Reporting Services Add-in for SharePoint Technologies Release Candidate (RC0) (Reporting Services Add-in) enables you to take advantage of SQL Server 2008 Release Candidate (RC0) report processing and management capabilities within Windows SharePoint Services (WSS) 3.0 or Microsoft Office SharePoint Server 2007. The download provides the following functionality: A Report Viewer Web Part that provides report viewing capability, export to other rendering formats, page navigation, search, print, and zoom. Web application pages so that you can create subscriptions and schedules, and manage reports, models, and data sources. Support for using standard Windows SharePoint... - [SQLAuthority News - SQL Server 2008 Release Candidate 0](https://blog.sqlauthority.com/2008/06/09/sqlauthority-news-sql-server-2008-release-candidate-0/): Download Microsoft SQL Server 2008 Release Candidate 0 (RC0) and preview the latest features of SQL Server 2008! The SQL Server development team uses your feedback to help refine and enhance product features. Evaluate SQL Server 2008 RC0 today and send your feedback. SQL Server 2008 provides a comprehensive data platform that is secure, reliable, manageable, and scalable for your mission critical applications. With it, developers can create new applications that can store and consume any type of data on any device, enabling your users to make informed decisions with relevant insights. SQL Server 2008 RC0 will automatically expire after 180... - [SQL SERVER - Order of Conditions in WHERE Clause](https://blog.sqlauthority.com/2008/06/08/sql-server-order-of-conditions-in-where-clauses/): Sr. Developer in my organization asked me the following question about WHERE clause.  Question: Does the order of conditions matter in WHERE clause? - [SQL SERVER - PIVOT and UNPIVOT Table Examples](https://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/): I previously wrote two articles about PIVOT and UNPIVOT tables. I really enjoyed writing about them as it was interesting concept. One of the Jr. DBA at my organization asked me following question. “If we PIVOT any table and UNPIVOT that table do we get our original table?” I really think this is good question. Answers is Yes, you can but not always. When we pivot the table we use aggregated functions. If due to use of this function if data is aggregated, it will be not possible to get original data back. Let me explain this issue demonstrating simple example.... - [SQLAuthority News - Subscribe to the Newsletter for 3 Important Scripts](https://blog.sqlauthority.com/2008/06/06/sqlauthority-news-subscribe-to-the-newsletter-for-3-important-scripts/): Lots of people ask me how to stay in touch with SQLAuthority.com. Well, the answer is very simple, you can subscribe to the newsletter of SQLAuthority.com by going to URL here: https://go.sqlauthority.com.  - [SQL SERVER - Compound Assignment Operators - A Simple Example](https://blog.sqlauthority.com/2008/06/05/sql-server-2008-compound-assignment-operators/): SQL SERVER 2008 has introduced new concept of Compound Assignment Operators. Compound Assignment Operators are available in many other programming languages for quite some time. Compound Assignment Operators is operator where variables are operated upon and assigned on the same line. - [SQL SERVER - Create a Comma Delimited List Using SELECT Clause From Table Column](https://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/): I received following question in email : How to create a comma delimited list using SELECT clause from table column? - [SQL SERVER - Example of DISTINCT in Aggregate Functions](https://blog.sqlauthority.com/2008/06/03/sql-server-example-of-distinct-in-aggregate-functions/): Just a day ago, I was was asked this question in one of the teaching session to my team members. One of the member asked me if I can use DISTINCT in Aggregate Function and does it make any difference. Of course! It does make difference. DISTINCT can be used to return unique rows from a result set and it can be used to force unique column values within an aggregate function. USE AdventureWorks GO SELECT SUM(DISTINCT ReorderPoint) ResultDistinct FROM Production.Product GO SELECT SUM(ReorderPoint) ResultNoDistinct FROM Production.Product GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Order Of Column In Index](https://blog.sqlauthority.com/2008/06/02/sql-server-order-of-column-in-index/): I just found one of my Jr. DBA to create many indexes with lots of column in it. After talking with him I found out that he really does not understand how really Index works. He was under impression that if he has more columns in one index, that index has higher chance of getting selected during execution of query and speed up the query. It was very much incorrect. He did not understand important of the order of column in created index. Order really matters and the column which is at first order matters the most in Index. The selection... - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 4](https://blog.sqlauthority.com/2008/06/01/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-4/): I have been asked many times when there is DATENAME function available why do I go in exercise of writing UDF For the getting the day of the week. Answer is : I just like it! SELECT DATENAME(dw, GETDATE()) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Create Default Constraint Over Table Column](https://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/): Very frequently Jr. Developers request script for creating default constraint over table column. I have written following small script for creating default constraint. I think this will be useful to many other developers who want this script to keep handy. - [SQLAuthority News - 3 Million Readers and Continuing Journey](https://blog.sqlauthority.com/2008/05/30/sqlauthority-news-3-million-readers-and-continuing-journey/): I would like to express my deep gratitude towards your active participation on this blog. There are more than 3 Million of you have visited this site as well contributed to make it successful. You can read my personally selected articles here. SQLAuthority – Best Articles SQLAuthority – Favorite Articles Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UNPIVOT Table Example](https://blog.sqlauthority.com/2008/05/29/sql-server-unpivot-table-example/): My previous article SQL SERVER – PIVOT Table Example encouraged few of my readers to ask me question about UNPIVOT table. UNPIVOT table is reverse of PIVOT Table. USE AdventureWorks GO CREATE TABLE #Pvt ([CA] INT NOT NULL, [AZ] INT NOT NULL, [TX] INT NOT NULL); INSERT INTO #Pvt ([CA], [AZ], [TX]) SELECT [CA], [AZ], [TX] FROM ( SELECT sp.StateProvinceCode FROM Person.Address a INNER JOIN Person.StateProvince sp ON a.StateProvinceID = sp.StateProvinceID ) p PIVOT ( COUNT (StateProvinceCode) FOR StateProvinceCode IN ([CA], [AZ], [TX]) ) AS pvt; SELECT StateProvinceCode, Customer_Count FROM ( SELECT [CA], [AZ], [TX] FROM #Pvt ) t UNPIVOT (... - [SQLAuthority News - Download - Windows Server 2008 w/ SQL Server 2005](https://blog.sqlauthority.com/2008/05/28/sqlauthority-news-download-windows-server-2008-w-sql-server-2005/): Note: Download Here by Microsoft This download comes as a pre-configured VHD. This download enables testing of application designs on the Windows Server Platform. As design gets more closely integrated into the process of building websites and web applications it becomes more critical to have all the necessary software installed on your machine to enable you to preview and review the designs you are working on. Often this is the only way of ensuring your designs will remain intact and look as intended when the finished project goes live on the web. Working on a web based project today generally involves... - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 3](https://blog.sqlauthority.com/2008/05/27/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-3/): Datetime functions and stored procedures always interests me. Nanda Kumar has suggested modification to previous written article about SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 2. He has improved on UDF. CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) DECLARE @weekDay INT ----Here I have subtracted 7 For keeping Sunday as the First day like wise for Monday we need to subtract 2 and so on SET @weekDay=((DATEPART(dw,@dtDate)+@@DATEFIRST-7)%7) SELECT @rtDayofWeek = CASE @weekDay WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN... - [SQLAuthority News - SQL SERVER 2008 - New Logo](https://blog.sqlauthority.com/2008/05/26/sqlauthority-news-sql-server-2008-new-logo/): Microsoft SQL Server 2008 has new logo. I really liked the new design. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to Devide One Column into Two Column](https://blog.sqlauthority.com/2008/05/25/sql-server-t-sql-script-to-devide-one-column-into-two-column/): Just a day ago, we faced situation where one column in database contained two values which were separated by comma. We wanted to separate this two values in their own columns. It was interesting that value of the column was variable and something dynamic needed to be written. Following is quick script which separates one column into two columns. The separate between two values in comma. CREATE TABLE EMP_Demo (EMP_PAY VARCHAR(20), EMP_NAME VARCHAR(20), PAY_SCALE VARCHAR(20)); INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('ALPESH,7009') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('KRUTI,9909') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('TANMAY,16000.7') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('NESHA,6060.8') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('DEVANG,14000') UPDATE... - [SQL Authority News - SQL Server Interview Questions - SQL Related Jobs - DBA Job Description](https://blog.sqlauthority.com/2008/05/24/sql-authority-news-sql-server-interview-questions-sql-related-jobs-dba-job-description/): I like to help every candidate who are finding job. I have previously written article here which can help all the people who are looking for job or looking for candidates. SQL Server Interview Questions and Answers Complete List Download Find Job Related to SQL SERVER SQL Server DBA- Job Description Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 2](https://blog.sqlauthority.com/2008/05/23/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-2/): I have written article about SQL SERVER – UDF – Get the Day of the Week Function. I have received good modified script from reader Mihir Popat has suggested another code where Sunday does not have to be necessary the first day of the week. CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) DECLARE @weekDay INT -- Here I have subtracted 7 For keeping Sunday as the First day -- like wise for Monday we need to subtract 2 and so on SET @weekDay = ((DATEPART(dw,GETDATE())+@@DATEFIRST-7)%7) SELECT @rtDayofWeek = CASE @weekDay WHEN 1 THEN 'Sunday' WHEN 2 THEN... - [SQL SERVER - PIVOT Table Example](https://blog.sqlauthority.com/2008/05/22/sql-server-pivot-table-example/): This is quite a popular question and I have never wrote about this on my blog. A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table. - [SQL SERVER - 2005 - Twelve Tips For Optimizing Sql Server 2005 Query Performance](https://blog.sqlauthority.com/2008/05/21/sql-server-2005-twelve-tips-for-optimizing-sql-server-2005-query-performance/): I recently came across very nice article about optimization tips for SQL Server 2005. Here is the list of those 12 tips. Twelve Tips For Optimizing Sql Server 2005 Query Performance 1. Turn on the execution plan, and statistics 2. Use Clustered Indexes 3. Use Indexed Views 4. Use Covering Indexes 5. Keep your clustered index small. 6. Avoid cursors 7. Archive old data 8. Partition your data correctly 9. Remove user-defined inline scalar functions 10. Use APPLY 11. Use computed columns 12. Use the correct transaction isolation level Reference : Pinal Dave (https://blog.sqlauthority.com) , Original Article - [SQL SERVER - 2008 - Choosing the Right Edition for Your Needs](https://blog.sqlauthority.com/2008/05/20/sql-server-2008-choosing-the-right-edition-for-your-needs/): Enterprise SQL Server 2008 is a comprehensive data platform that meets the high demands of enterprise online transaction processing and data warehousing applications. Standard SQL Server 2008 Standard is a complete data management and business intelligence platform providing best-in-class ease of use and manageability for running departmental applications. Workgroup Run branch locations on this reliable data management and reporting platform that provides secure remote synchronization and management capabilities. Compact Available as a free download, build stand-alone and occasionally connected applications for mobile devices, desktops, and Web clients on all Microsoft Windows platforms. Express Available as a free download, Express is ideal... - [SQLAuthority Download - Providing Security for Web Applications and Infrastructure: Best Practices for Managing Security Risks](https://blog.sqlauthority.com/2008/05/19/sqlauthority-download-providing-security-for-web-applications-and-infrastructure-best-practices-for-managing-security-risks/): Note :  Download PPT by Microsoft Providing Security for Web Applications and Infrastructure: Best Practices for Managing Security Risks The Windows Live Security team shares best practices – from platform and network security to incident management – in providing security for web applications and infrastructure. Organizations across the globe face unique challenges in enhancing security for Web applications and their IT infrastructures. Issues such as improper Web server configuration, weak authentication policies, and invalidated Web requests can lead to unauthorized user access and potential attacks. The Microsoft Windows Live team provides services to millions of customers each month for e-mail, mobile... - [SQLAuthority News - SQL SERVER Database Administrator Job Description](https://blog.sqlauthority.com/2008/05/18/sqlauthority-news-sql-server-database-administrator-job-description/): I have previously written article about SQLAuthority News – Job Description of Database Administrator (DBA) or Database Developer. I have received quite a lot of request to update it or post something similar. Writing SQL Articles are easier then writing Job description for DBA. I have read many job description and job posting at Best SQL Jobs and found following job description. DBA Job Description The Data Base Administrator (DBA) is responsible for providing technical support for the database environment including overseeing the development and organization of the databases, assessment and implementation of new technologies, and providing Information Technology with a... - [SQL SERVER - Ideal TempDB FileGrowth Value](https://blog.sqlauthority.com/2008/05/17/sql-server-ideal-tempdb-filegrowth-value/): Just a day ago, while installing SQL Server on our development machine Jr. DBA asked me what should be kept file growth of the TempDB. I really have not thought about this till moment and I looked at MS site. - [SQL SERVER - Find Table in Every Database of SQL Server - Part 3](https://blog.sqlauthority.com/2008/05/16/sql-server-find-table-in-every-database-of-sql-server-part-3/): Previously I wrote two articles about SQL SERVER – Find Table in Every Database of SQL Server SQL SERVER – Find Table in Every Database of SQL Server – Part 2 I recently received email from SQL Expert and Blog Reader Greg Steinkuhler. People like Greg Steinkuhler makes this whole world better place. He wrote absolutely wonderful script which runs on network and have shared with community. Hats Off to you! His original email is listed here: Hi Pinal Dave, After reading the article on your website in reference to “Find Table in Every Database of SQL Server” I tried to... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Silly Mistake](https://blog.sqlauthority.com/2008/05/15/sql-server-sql-joke-sql-humor-sql-laugh-silly-mistake/): It is really very bad of person to laugh on others misfortune, however dark humor is based on the same concept. It has been long time since I wrote something funny on this blog. Recently, I have came across forum discussion regarding backup misery of one of the developer. I feel very sorry for the DBA who lost their backup but I found the suggestions of other “SQL Experts” really humorous and helpful as well. Read whole communication here Some of the witty lines are : OK, take a deep breath. Write a resignation letter. Go into your bosses office. Own... - [SQL SERVER - Orphaned MS DTC Transaction Information](https://blog.sqlauthority.com/2008/05/14/sql-server-orphaned-ms-dtc-transaction-information/): Few days ago, one of our application was crashing IIS application pool because of unhandled exception. After researched we figured out the case of it was orphaned MS DTC transaction. When multiple connections are operating over one MS DTC transaction, this problem sometime shows up. As many connection are working none of them try to roll back the MS DTC transaction, this creates orphaned connection, which crashes IIS application pool. You can figure out if there is orphaned connection or not in your application from following quick script. If there are orphaned connection it will show up in result otherwise script... - [SQL SERVER - Four Basic SQL Statements - SQL Operations](https://blog.sqlauthority.com/2008/05/13/sql-server-four-basic-sql-statements-sql-operations/): There are four basic SQL Operations or SQL Statements. SELECT – This statement selects data from database tables. UPDATE – This statement updates existing data into database tables. INSERT – This statement inserts new data into database tables. DELETE – This statement deletes existing data from database tables. If you want complete syntax for this four basic statement, please download FAQ (PDF) from SQL SERVER – Download FAQ Sheet – SQL Server in One Page Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable - Part 2](https://blog.sqlauthority.com/2008/05/12/sql-server-sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable-part-2/): Some questions never get old. One of them is temp table variable and temp table in SQL Server. I have previously wrote about this indepth here : SQL SERVER – Comparison : Similarity and Difference #TempTable vs @TempVariable Recently I received question: Can temporary table have indexes? If yes, are they really useful and efficient? When nonclustered index are created a separate table is created, what happens in the case of when temporary table? I really liked the question of user. Yes, temporary table can have indexes. If you have to use temporary table more than one time in your operation,... - [SQL SERVER 2005 - Microsoft Will Release SP3 Soon](https://blog.sqlauthority.com/2008/05/11/sql-server-2005-microsoft-will-release-sp3-soon/): I have received quite a few inquires if Microsoft is going to release SP3 for SQL Server or not? Yes! Microsoft is going to release SP3 very soon. The exact date is not announced yet. You can read the announcement of SP3 here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Function Property - Deterministic or Non-Deterministic](https://blog.sqlauthority.com/2008/05/10/sql-server-function-property-deterministic-or-non-deterministic/): I recently received question through email that how to determine if any user defined function is deterministic or non-deterministic? First go through two articles I have written about deterministic and non-deterministic function. SQL SERVER – Deterministic Functions and Nondeterministic Functions SQL SERVER – 2005 – Use of Non-deterministic Function in UDF – Find Day Difference Between Any Date and Today You can run following code to determine if function is deterministic or not. SELECT OBJECTPROPERTY(OBJECT_ID('dbo.ufnGetAccountingStartDate'), 'IsDeterministic') IsFunctionDeterministic Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 7311 - You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server](https://blog.sqlauthority.com/2008/05/09/sql-server-fix-error-7311-you-may-receive-an-error-message-when-you-try-to-run-distributed-queries-from-a-64-bit-sql-server-2005-client-to-a-linked-32-bit-sql-server-2000-server-or-to-a-linked-s/): Following email is received from SQL Server Expert Roy Cheung. He faced issue of creating and running distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server. He has found solution and would like to share with SQLAuthority Blog Readers. Hi Pinal, Recently, I’ve a problem on create and run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server. The solution below works perfect for us, I think it is good to share. http://blogs.msdn.com/sql_protocols/archive/2006/08/10/694657.aspx Thanks, Roy If you have tip or solution like this and would... - [SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database - Part 2](https://blog.sqlauthority.com/2008/05/08/sql-server-2005-find-tables-with-foreign-key-constraint-in-database-part-2/): What I love most about this blog is active readers participation. If readers are becoming contributor is the true success for any blog or online community. Recently many readers have contributed their suggestions and script to this blog. Joffery has provided nice script which is modification to previous article of SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database. Following note is from Joffery: Hi Pinal Very interesting article and of great help. I made a little addition to your code. As I wanted also to know what the FKs are doing in the Table (referential integrity... - [SQL SERVER - Create Database Error in Windows Vista](https://blog.sqlauthority.com/2008/05/07/sql-server-create-database-error-in-windows-vista/): I recently receive question from one of the blog reader that he is having problem creating database in Windows Vista. Read original comment here. I have installed vista ultimate and sql server 2005 developer edition in my computer.I also connect SQL 2005 in window authentication but when I CREATE any database in following query CREATE DATABASE MANEESH USE MANEESH Its give me everytime following error:- Msg 262, Level 14, State 1, Line 1 CREATE DATABASE permission denied in database ‘master’. & Msg 911, Level 16, State 1, Line 1 Could not locate entry in sysdatabases for database ‘maneesh’. No entry found with... - [SQL SERVER 2005 - FIX Error: 18456 : VISTA Windows Authentication](https://blog.sqlauthority.com/2008/05/06/sql-server-2005-fix-error-18456-vista-windows-authentication/): In previous post I have mentioned about SQL SERVER 2005 – Vista Ultimate and SQL Server 2005 DEV Edition. There was one simple issue with the installation. I was not able to login using windows authentication method. I was able to successful login using sa username and password. I kept on receiving following error. TITLE: Connect to Server —————————— Cannot connect to SQLAUTHORITY. —————————— ADDITIONAL INFORMATION: Login failed for user ‘SQLAUTHORITY\Pinal’. (Microsoft SQL Server, Error: 18456) For help, click: —————————— BUTTONS: OK —————————— After a while I realize that this may be due to one needs Administrator rights to do any... - [SQL SERVER - User Defined Functions (UDF) Limitations](https://blog.sqlauthority.com/2007/05/29/sql-server-user-defined-functions-udf-limitations/): UDF have its own advantage and usage but in this article we will see the limitation of UDF. Things UDF can not do and why Stored Procedure are considered as more flexible then UDFs. Stored Procedure are more flexibility then User Defined Functions(UDF). UDF has No Access to Structural and Permanent Tables. UDF can call Extended Stored Procedure, which can have access to structural and permanent tables. (No Access to Stored Procedure) UDF Accepts Lesser Numbers of Input Parameters. UDF can have upto 1023 input parameters, Stored Procedure can have upto 21000 input parameters. UDF Prohibit Usage of Non-Deterministic Built-in Functions... - [SQLAuthority News - Author Visit - Meeting with Readers - Top Three Features of SQL SERVER 2005](https://blog.sqlauthority.com/2007/05/28/sqlauthority-news-author-visit-meeting-with-readers-top-three-features-of-sql-server-2005/): Lots of travelers are visiting to Las Vegas due to long weekend of Memorial Day. I was invited to dinner meeting by two of my readers. It was wonderful discussion with them. We primarily discussed about scalability and upgrading issues about SQL Server. I received feedback about SQLAuthority.com site. There were two primarily request for them. I have been working on both of them already as I have received quite a few request for them from other readers as well. Beta testing has been completed, I will announce them on 1st June. While enjoying dinner I was asked interesting question and... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - SP](https://blog.sqlauthority.com/2007/05/28/sql-server-sql-joke-sql-humor-sql-laugh-sp/): One of my Friend send me(in email) following stored procedure. I laughed when I read it. Please enjoy it. It is here for amusement purpose only. Never use on development or production server. This is already dangerous you have been warned. CREATE PROCEDURE MyMarriage @ BrideGroom CHAR(NotBad), @ Bride CHAR(Good) AS BEGIN SELECT Bride FROM india_ Brides WHERE FatherInLaw = 'Millionaire' AND CarCount > 2 AND HouseStatus ='TwoStoreyed' AND BrideEduStatus='PG or Above' AND HavingBrothers='NO' AND HavingSisters ='No' AND AllowRelocate ='YES' SELECT Gold ,Cash,Car,BankBalance FROM FatherInLaw UPDATE MyBankAccout SET MyBal = MyBal + FatherinLawBal UPDATE MyLocker SET MyLockerContents = MyLockerContents + FatherinLawGold... - [SQL SERVER - Download Feature Pack for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/05/27/sql-server-download-feature-pack-for-microsoft-sql-server-2005/): Feature Pack for Microsoft SQL Server 2005 – February 2007 Download the February 2007 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. I have listed all the stand alone packages here. Even though title says February 2007, publication day of this package is 5/25/2007. All DBA should go through following list and see if their organization is using any of the application/feature and update is required for them. Microsoft ADOMD.NET Microsoft Core XML Services (MSXML) 6.0 Microsoft OLEDB Provider for DB2 Microsoft SQL Server Management Pack for MOM... - [SQL SERVER - 2005 Limiting Result Sets by Using TABLESAMPLE - Examples](https://blog.sqlauthority.com/2007/05/27/sql-server-2005-limiting-result-sets-by-using-tablesample-examples/): Introduced in SQL Server 2005, TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set. Example 1: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (10 PERCENT) Example 2: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (1000 ROWS) If you run above script many times you will notice that different numbers of... - [SQL SERVER - 2005 Replace TEXT with VARCHAR(MAX) - Stop using TEXT, NTEXT, IMAGE Data Types](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-replace-text-with-varcharmax-stop-using-text-ntext-image-data-types/): Yesterday, in Friday Afternoon team meeting. I was asked question by one of application developer “I am asked in new coding standards to use VARHCAR(MAX) instead of TEXT. Is VARCHAR(MAX) big enough to store TEXT field?” Well, I realize that I was not clear enough in my coding standard. It is extremely important for coding standards to be clear and have a enough explanation that developer have no doubt about them. I updated coding standards after the meeting. The answer is “Yes, VARCHAR(MAX) is big enough to accommodate TEXT field. TEXT, NTEXT and IMAGE data types of SQL Server 2000 will... - [SQL SERVER - 2005 Find Table without Clustered Index - Find Table with no Primary Key](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-find-table-without-clustered-index-find-table-with-no-primary-key/): One of the basic Database Rule I have is that all the table must Clustered Index. Clustered Index speeds up performance of the query ran on that table. Clustered Index are usually Primary Key but not necessarily. I frequently run following query to verify that all the Jr. DBAs are creating all the tables with no Clustered Index. USE AdventureWorks ----Replace AdventureWorks with your DBName GO SELECT DISTINCT [TABLE] = OBJECT_NAME(OBJECT_ID) FROM SYS.INDEXES WHERE INDEX_ID = 0 AND OBJECTPROPERTY(OBJECT_ID,'IsUserTable') = 1 ORDER BY [TABLE] GO Result set for AdventureWorks: TABLE ——————————————————- DatabaseLog ProductProductPhoto (2 row(s) affected) Related Post: SQL SERVER –... - [SQL SERVER - Change Default Fill Factor For Index](https://blog.sqlauthority.com/2007/05/25/sql-server-change-default-fill-factor-for-index/): SQL Server has default value for fill factor is Zero (0). The fill factor is implemented only when the index is created; it is not maintained after the index is created as data is added, deleted, or updated in the table. When creating an index, you can specify a fill factor to leave extra gaps and reserve a percentage of free space on each leaf level page of the index to accommodate future expansion in the storage of the table's data and reduce the potential for page splits. Let us learn about how to change default fill factor of index. - [SQL SERVER - Stored Procedure to display code (text) of Stored Procedure, Trigger, View or Object](https://blog.sqlauthority.com/2007/05/25/sql-server-stored-procedure-to-display-code-text-of-stored-procedure-trigger-view-or-object/): This is another popular question I receive. How to see text/content/code of Stored Procedure. System stored procedure that prints the text of a rule, a default, or an unencrypted stored procedure, user-defined function, trigger, or view. Syntax sp_helptext @objname = 'name' sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name Displaying the definition of a trigger or stored procedure sp_helptext 'dbo.nameofsp' Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Disadvantages (Problems) of Triggers](https://blog.sqlauthority.com/2007/05/24/sql-server-disadvantages-problems-of-triggers/): One of my team member asked me should I use triggers or stored procedure. Both of them has its usage and needs. I just basically told him few issues with triggers. This is small note about our discussion. Disadvantages(Problems) of Triggers It is easy to view table relationships , constraints, indexes, stored procedure in database but triggers are difficult to view. Triggers execute invisible to client-application application. They are not visible or can be traced in debugging code. It is hard to follow their logic as it they can be fired before or after the database insert/update happens. It is easy... - [SQL SERVER - 2005 Retrieve Configuration of Server](https://blog.sqlauthority.com/2007/05/24/sql-server-2005-retrieve-configuration-of-server/): Few days ago I was asked what is our SQL Server’s configuration. I provided way more information then they requested. Run following script and it will provide all the information about SQL Server . SQL Server provides in detailed information if Advanced Options are turned on. It is very clear from this that maximum number of object SQL Server can have is 2,147,483,647. It is considerably very big number. I am not worried yet about my database reaching its limit. EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure GO EXEC sp_configure 'show advanced options', 0 GO To change... - [SQL SERVER - NorthWind Database or AdventureWorks Database - Samples Databases](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases/): SQL Server 2005 does not install sample databases by default due to security reasons.I have received many questions regarding where is sample database in SQL Server 2005. One can install it afterward. AdventureWorks and AdvetureWorksDS are the new sample databases for SQL Server 2005, they can be download from here. Let us learn how to install NorthWind Database - samples databases.  - [SQL SERVER - 2005 Explanation Left Semi Join Showplan Operator and Other Operator](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-explanation-left-semi-join-showplan-operator-and-other-operator/): I come across very interesting documentation about Joins, while I was researching about article about EXCEPT yesterday. There are few interesting kind of join operations exists when execution plan is displayed in text format. Left Semi Join Showplan Operator The Left Semi Join operator returns each row from the first (top) input when there is a matching row in the second (bottom) input. If no join predicate exists in the Argument column, each row is a matching row. Left Anti Semi Join Showplan Operator The Left Anti Semi Join operator returns each row from the first (top) input when there is... - [SQLAuthority News - Funny One Liners - Humor](https://blog.sqlauthority.com/2007/05/23/sqlauthority-news-funny-one-liners-humor/): Once in a while we should laugh and relax. Here are few of my favorite funny one liners which I often use in my presentations. Let us start- Just read that 4,153,237 people got married last year, not to cause any trouble, but shouldn't that be an even number? - [SQLAuthority News - T-Shirts in Action](https://blog.sqlauthority.com/2007/05/22/sqlauthority-news-t-shirts-in-action/): Thank you All for great response to SQLAuthority T-Shirts. I have ran out of all of them. Please put your request here. I will go over all of them soon and see what I can do. They are made from high quality fiber and very comfortable. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Comparison EXCEPT operator vs. NOT IN](https://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/): The EXCEPT operator returns all of the distinct rows from the query to the left of the EXCEPT operator when there are no matching rows in the right query. The EXCEPT operator is equivalent of the Left Anti Semi Join. EXCEPT operator works the same way NOT IN. EXCEPTS returns any distinct values from the query to the left of the EXCEPT operand that do not also return from the right query. - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - T-Shirt](https://blog.sqlauthority.com/2007/05/21/sql-server-sql-joke-sql-humor-sql-laugh-t-shirt/): My friend sent me this in an email two days ago as he wanted me to have SQLAuthority T-Shirt with this image. I found it funny, I am not sure if I will have this on SQLAuthority T-Shirts. Please pay attention to the options available to select. I spend more than 3 hours to find the original source as my friend did not remember the source. Let's see some SQL Humor here: - [SQL SERVER - Top 15 free SQL Injection Scanners - Link to Security Hacks](https://blog.sqlauthority.com/2007/05/21/sql-server-top-15-free-sql-injection-scanners-link-to-security-hacks/): SQL injection is a technique for exploiting web applications that use client-supplied data in SQL queries, but without first stripping potentially harmful characters. Checking for SQL Injection vulnerabilities involves auditing your web applications and the best way to do it is by using automated SQL Injection Scanners. Security-Hacks.com compiled a list of free SQL Injection Scanners. I really enjoy reading the article. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Build List Link](https://blog.sqlauthority.com/2007/05/21/sql-server-2005-build-list-link/): What is Build List? All SQL Server has build list, this is incremental list of numbers which indicates which version SQL Server is running and what are its compatibility, patches etc. Regular Columnist Steve Jones of SQL Server Central has created build list. It is updated and informative. Microsoft Hot fixes are always cumulative. You can find your build number with: SELECT@@Version Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Code Formatting Tools](https://blog.sqlauthority.com/2007/05/20/sql-server-sql-code-formatter-tools/): SQL Code Formatting is very important. Every SQL Server DBA has its own preference about formatting. I like to format all keywords to uppercase. Following are two online tools, which formats SQL Code very good. I tested following script with those tools and I found two of the tools worth mentioning here. - [SQL SERVER - Script/Function to Find Last Day of Month](https://blog.sqlauthority.com/2007/05/20/sql-server-scriptfunction-to-find-last-day-of-month/): Following query will find the last day of the month. Query also take care of Leap Year. Script: DECLARE @date DATETIME SET @date='2008-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO DECLARE @date DATETIME SET @date='2007-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO ResultSet: LastDayOfMonth ----------------------- 2008-02-29 00:00:00.000 (1 row(s) affected) LastDayOfMonth ----------------------- 2007-02-28 00:00:00.000 (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ASCII to Decimal and Decimal to ASCII Conversion](https://blog.sqlauthority.com/2007/05/19/sql-server-ascii-to-decimal-and-decimal-to-ascii/): In this blog post we will see how we can convert ASCII to Decimal and Decimal to ASCII. In simple words, we will see the decimal and ASCII conversion. - [SQL SERVER - Math Functions Available in SQL Server](https://blog.sqlauthority.com/2007/05/19/sql-server-math-functions-for-2005/): The large majority of math functions is specific to applications using trigonometry, calculus, and geometry. This is very important and it is very difficult to have all of them together at place. - [SQL SERVER - 2005 Understanding Trigger Recursion and Nesting with examples](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-understanding-trigger-recursion-and-nesting-with-examples/): Trigger events can be fired within another trigger action. One Trigger execution can trigger even on another table or same table. This trigger is called NESTED TRIGGER or RECURSIVE TRIGGER. Nested triggers SQL Server supports the nesting of triggers up to a maximum of 32 levels. Nesting means that when a trigger is fired, it will also cause another trigger to be fired. If a trigger creates an infinitive loop, the nesting level of 32 will be exceeded and the trigger will cancel with an error message. Recursive triggers When a trigger fires and performs a statement that will cause the... - [SQL SERVER - 2005 - SSMS Change T-SQL Batch Separator](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-ssms-change-t-sql-batch-separator/): I recently received one big file with many T-SQL batches. It was a very big file and I was asked that this file was tested many times and it can run one transaction. I noticed the separator of the batches is not GO but it was EndBatch. I have followed two options to run the whole batch in one transaction. Let us learn how to change T-SQL Batch Separator. - [SQLAuthority News - Limited Edition T-Shirts Arrived](https://blog.sqlauthority.com/2007/05/17/sqlauthority-news-limited-edition-t-shirts-arrived/): I have received quite a few request for SQLAuthority.com T-shirts. Every day I receive lots of emails and suggestions. Many readers have great suggestions and have helped to improve content. First of all I express my gratitude to all of you. Few of my loyal and enthusiastic readers will receive the T-shirt by tomorrow. T-shirts are very limited. I have kept only two for me and have shipped all other. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Disable Index - Enable Index - ALTER Index](https://blog.sqlauthority.com/2007/05/17/sql-server-disable-index-enable-index-alter-index/): There are few requirements in real world when Index on table needs to be disabled and re-enabled afterwards. e.g. DTS, BCP, BULK INSERT etc. Index can be dropped and recreated. I prefer to disable the Index if I am going to re-enable it again. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO ----Enable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact REBUILD GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-1205-transaction-process-id-was-deadlocked-on-resources-with-another-process-and-has-been-chosen-as-the-deadlock-victim-rerun-the-transaction/): Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction. - [SQL SERVER - Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-130-cannot-perform-an-aggregate-function-on-an-expression-containing-an-aggregate-or-a-subquery/): Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery Following statement will give the following error: “Cannot perform an aggregate function on an expression containing an aggregate or a subquery.” MS SQL Server doesn’t support it. USE PUBS GO SELECT AVG(COUNT(royalty)) RoyaltyAvg FROM dbo.roysched GO You can get around this problem by breaking out the computation of the average in derived tables. USE PUBS GO SELECT AVG(t.RoyaltyCounts) FROM ( SELECT COUNT(royalty) AS RoyaltyCounts FROM dbo.roysched ) T GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL. - [SQL SERVER - Binary Sequence Generator - Truth Table Generator](https://blog.sqlauthority.com/2007/05/15/sql-server-binary-sequence-generator-truth-table-generator/): Run following script in query editor to generate truth table with its decimal value and binary sequence. The truth table is 512 rows long. This can be extended or reduced by adding or removing cross joins respectively. Script: USE AdventureWorks; DECLARE @Binary TABLE ( Digit bit) INSERT @Binary VALUES (0) INSERT @Binary VALUES (1) SELECT ((a.Digit*256) + (b.Digit*128) + (c.Digit*64) + (d.Digit*32) + (e.Digit*16) + (f.Digit*8) + (g.Digit*4) + (h.Digit*2) + (i.Digit*1)) DecimalValue, a.Digit '256', b.Digit '128' , c.Digit '64', d.Digit '32', e.Digit '16', f.Digit '8', g.Digit '4', h.Digit '2', i.Digit '1' FROM @Binary a CROSS JOIN @Binary b CROSS JOIN... - [SQL SERVER - DBCC commands List - documented and undocumented](https://blog.sqlauthority.com/2007/05/15/sql-server-dbcc-commands-list-documented-and-undocumented/): Database Consistency Checker (DBCC) commands can gives valuable insight into what’s going on inside SQL Server system. DBCC commands have powerful documented functions and many undocumented capabilities. Current DBCC commands are most useful for performance and troubleshooting exercises. To learn about all the DBCC commands run following script in query analyzer. DBCC TRACEON(2520) DBCC HELP (‘?’) GO To learn about syntax of an individual DBCC command run following script in query analyzer. DBCC HELP(<command>) GO Following is the list of all the DBCC commands and their syntax. List contains all documented and undocumented DBCC commands. DBCC activecursors [(spid)] DBCC addextendedproc (function_name,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Photo](https://blog.sqlauthority.com/2007/05/14/sql-server-sql-joke-sql-humor-sql-laugh-photo/): Pay attention to the last line of the ingredients. I found this entry at Worse Than Failure. I found it humorous. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - MS TechNet : Storage Top 10 Best Practices](https://blog.sqlauthority.com/2007/05/14/sql-server-ms-technet-storage-top-10-best-practices/): This one of the very interesting article I read regarding SQL Server 2005 Storage. Please refer original article at MS TechNet here. Understand the IO characteristics of SQL Server and the specific IO requirements / characteristics of your application. More / faster spindles are better for performance. Try not to “over” optimize the design of the storage; simpler designs generally offer good performance and more flexibility. Validate configurations prior to deployment. Always place log files on RAID 1+0 (or RAID 1) disks. Isolate log from data at the physical disk level. Consider configuration of TEMPDB database. Lining up the number of... - [SQL SERVER - Query to Find First and Last Day of Current Month - Date Function](https://blog.sqlauthority.com/2007/05/13/sql-server-query-to-find-first-and-last-day-of-current-month/): Following query will run respective on today's date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month. Let us see how we can do this with the help of Date Function in SQL Server. - [SQL SERVER - UDF - Function to Parse AlphaNumeric Characters from String](https://blog.sqlauthority.com/2007/05/13/sql-server-udf-function-to-parse-alphanumeric-characters-from-string/): Following function keeps only Alphanumeric characters in string and removes all the other character from the string. This is very handy function when working with Alphanumeric String only. I have used this many times. CREATE FUNCTION dbo.UDF_ParseAlphaChars ( @string VARCHAR(8000) ) RETURNS VARCHAR(8000) AS BEGIN DECLARE @IncorrectCharLoc SMALLINT SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) WHILE @IncorrectCharLoc > 0 BEGIN SET @string = STUFF(@string, @IncorrectCharLoc, 1, '') SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) END SET @string = @string RETURN @string END GO —-Test SELECT dbo.UDF_ParseAlphaChars('ABC”_I+{D[]}4|:e;””5,<.F>/?6') GO Result Set : ABCID4e5F6 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List all the database](https://blog.sqlauthority.com/2007/05/12/sql-server-2005-list-all-the-database/): List all the database on SQL Servers. All the following Stored Procedure list all the Databases on Server. I personally use EXEC sp_databases because it gives the same results as other but it is self explaining. ----SQL SERVER 2005 System Procedures EXEC sp_databases EXEC sp_helpdb ----SQL 2000 Method still works in SQL Server 2005 SELECT name FROM sys.databases SELECT name FROM sys.sysdatabases ----SQL SERVER Un-Documented Procedure EXEC sp_msForEachDB 'PRINT ''?''' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support](https://blog.sqlauthority.com/2007/05/12/sql-server-fix-error-msg-6263-level-16-state-1-line-2-enabling-sql-server-2005-for-clr-support/): Error: Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support 1) Enable Server for CLR Support. - [SQL SERVER - Explanation SQL Command GO](https://blog.sqlauthority.com/2007/05/11/sql-server-explanation-sql-command-go/): GO is not a Transact-SQL statement; it is often used in T-SQL code. Go causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches. SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is... - [SQL SERVER - Download Microsoft SQL Server 2005 System Views Map](https://blog.sqlauthority.com/2007/05/11/sql-server-download-microsoft-sql-server-2005-system-views-map/): The Microsoft SQL Server 2005 System Views Map shows the key system views included in SQL Server 2005, and the relationships between them. It is available to download from Microsoft Site. It can be printed and mounted at Office Depot or Kinko’s. Download SQL SERVER 2005 System Views Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 Katmai - Download Datasheet Final from Microsoft](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-download-datasheet-final-from-microsoft/): Few interesting thing about Katmai. SQL Server “Katmai” will provide a more secure, reliable and manageable enterprise data platform. SQL Server “Katmai” will enable developers and administrators to save time by allowing them to store and consume any type of data from XML to documents. SQL Server “Katmai” provides a more scalable infrastructure that enables IT to drive business intelligence throughout the organization. SQL Server “Katmai” along with .NET Framework 3.0 will accelerate the development of the next generation of applications. Reference : Pinal Dave (https://blog.sqlauthority.com) MS SQL Server (All the above text) Download Final Datasheet of Katmai from Microsoft - [SQL SERVER - Fix: Error: HResult 0x2, Named Pipes Provider: Could not open a connection](https://blog.sqlauthority.com/2007/05/10/sql-server-fix-error-hresult-0x2-level-16-state-1-named-pipes-provider-could-not-open-a-connection-to-sql-server/): In this blog post we are going to fix the error which is related to Named Pipes Provider. - [SQL SERVER - 2008 Katmai - Your Data, Any Place, Any Time](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-your-data-any-place-any-time/): I was following up on the news of first Microsoft Business Intelligence (BI) Conference held at Seattle. Good news is – SQL Server 2008 code name ‘Katmai’ is announced. I went to the official website I like the catchy line “Your Data, Any Place, Any Time“. As per my opinion the most important thing about Katmai is that it can be used to manage any type of data, including relational data, documents, geographic information and XML. The question I received many times since yesterday is : I am still using SQL Server 2000, I was planning to upgrade to SQL Server... - [SQL SERVER - Fix : Error 2501 : Cannot find a table or object with the name . Check the system catalog.](https://blog.sqlauthority.com/2007/05/09/sql-server-fix-error-2501-cannot-find-a-table-or-object-with-the-name-check-the-system-catalog/): Error 2501 : Cannot find a table or object with the name . Check the system catalog. This is very generic error beginner DBAs or Developers faces. The solution is very simple and easy. Follow the direction below in order. Fix/Workaround/Solution: Make sure that correct Database is selected. If not please run USE YourDatabase. Check the object or table name. They must be spelled correct. If database is case sensitive please use correct case. Use object belongs to other owner use two parts name as scheme_name.object_name. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - MIS2007 Part II - Database Raid Discussion](https://blog.sqlauthority.com/2007/05/09/sqlauthority-news-author-visit-mis2007-part-ii-database-raid-discussion/): MIS2007 is really going good. There are many things going on. As I mentioned in my previous article, It is really pleasure to meet industry leaders. There was discussion about what is good for database RAID 5 configuration or RAID 10. This subject is always very interesting. We were discussing from small databases (5GB) to larger databases(5 TB). The question was which RAID 5 or RAID 10. Surprisingly, everybody who participated in discussion said their experience says RAID 10 is better for this particular application as there are lots of reads and writes in database. One of the expert suggested that... - [SQL SERVER - Index Optimization CheckList](https://blog.sqlauthority.com/2007/05/08/sql-server-index-optimization-checklist/): Index optimization is always interesting subject to me. Every time I receive requests to help optimize query or query on any specific table. I always ask Jr.DBA to go over following list first before I take a look at it. Most of the time the Query Speed is optimized just following basic rules mentioned below. Once following checklist applied interesting optimization part begins which only experiment and experience can resolve. - [SQLAuthority News - Author Visit - The 2007 Marketing Innovation Summit, Las Vegas](https://blog.sqlauthority.com/2007/05/08/sqlauthority-news-author-visit-the-2007-marketing-innovation-summit-las-vegas/): I am attending The 2007 Marketing Innovation Summit“, Las Vegas. It started on 5/6/2007 and will continue till 5/9/2007. Unica Corporation has arranged this conference. The MIS 2007 Agenda includes: Case studies and best practices Sessions focused on Relationship Marketing, Internet Marketing and Marketing Operations Hands on “how to” sessions General sessions from distinguished industry experts A one-day Pre-Summit Affinium New User Workshop and Getting Prepared for Affinium Plan Post-Summit Hands-On Training Evening networking activities In two days so far, I have learned a lot and have met many industry leaders. Talking about cutting edge technology and SQL Server was perfect... - [SQL SERVER - Top 10 Hidden Gems in SQL Server 2005](https://blog.sqlauthority.com/2007/05/07/sql-server-top-10-hidden-gems-in-sql-server-2005/): Top 10 Hidden Gems in SQL Server 2005 By Cihan Biyikoglu SQL Server 2005 has hundreds of new and improved components. Some of these improvements get a lot of the spotlight. However there is another set that are the hidden gems that help us improve performance, availability or greatly simplify some challenging scenarios. This paper lists the top 10 such features in SQL Server 2005 that we have discovered through the implementation with some of our top customers and partners. TableDiff.exe Triggers for Logon Events (New in Service Pack 2) Boosting performance with persisted-computed-columns (pcc). DEFAULT_SCHEMA setting in sys.database_principles Forced Parameterization... - [SQL SERVER - 2005/2000 Examples and Explanation for GOTO](https://blog.sqlauthority.com/2007/05/07/sql-server-20052000-examples-and-explanation-for-goto/): The GOTO statement causes the execution of the T-SQL batch to stop processing the following commands to GOTO and processing continues from the label where GOTO points. GOTO statement can be used anywhere within a procedure, batch, or function. GOTO can be nested as well. GOTO can be executed by any valid user on SQL SERVER. GOTO can co-exists with other control of flow statements (IF…ELSE, WHILE). GOTO can only go(jump) to label in the same batch, it can not go to label out side of the batch. Syntax: Define the label: label: ALTER the execution: GOTO label Notes from MSDN... - [SQL SERVER - Creating Comma Separate Values List from Table - UDF - SP](https://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/): Following script will create common separate values (CSV) or common separate list from tables. convert list to table. Following script is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. There are three ways to do this. 1) Using COALESCE 2) Using SELECT Smartly 3) Using CURSOR. The table is example is: TableName: NumberTable NumberCols first second third fourth fifth Output : first,second,third,fourth,fifth Option 1: This is... - [SQL SERVER - UDF - Function to Convert List to Table](https://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/): Following Users Defined Functions will convert list to table. It also supports user defined delimiter. Following UDF is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. CREATE FUNCTION dbo.udf_List2Table ( @List VARCHAR(MAX), @Delim CHAR ) RETURNS @ParsedList TABLE ( item VARCHAR(MAX) ) AS BEGIN DECLARE @item VARCHAR(MAX), @Pos INT SET @List = LTRIM(RTRIM(@List))+ @Delim SET @Pos = CHARINDEX(@Delim, @List, 1) WHILE @Pos > 0 BEGIN SET... - [SQL SERVER - 2005 Enable CLR using T-SQL script](https://blog.sqlauthority.com/2007/05/05/sql-server-2005-enable-clr-using-t-sql-script/): Before doing any .Net coding in SQL Server you must enable the CLR. In SQL Server 2005, the CLR is OFF by default. This is done in an effort to limit security vulnerabilities. Following is the script which will enable CLR. EXEC sp_CONFIGURE 'show advanced options' , '1'; GO RECONFIGURE; GO EXEC sp_CONFIGURE 'clr enabled' , '1' GO RECONFIGURE; GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - UDF - User Defined Function to Find Weekdays Between Two Dates](https://blog.sqlauthority.com/2007/05/05/sql-server-udf-user-defined-function-to-find-weekdays-between-two-dates/): Following user defined function returns number of weekdays between two dates specified. This function excludes the dates which are passed as input params. It excludes Saturday and Sunday as they are weekends. I always had this function with for reference but after some research I found original source website of the function. This function has been written by Author Alexander Chigrik. CREATE FUNCTION dbo.spDBA_GetWeekDays ( @StartDate datetime, @EndDate datetime ) RETURNS INT AS BEGIN DECLARE @WorkDays INT, @FirstPart INT DECLARE @FirstNum INT, @TotalDays INT DECLARE @LastNum INT, @LastPart INT IF (DATEDIFF(DAY, @StartDate, @EndDate) 0) THEN @LastPart - 1 ELSE 0 END... - [SQL SERVER - Fix : Error : Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset DBSCHEMA_TABLES_INFO for OLE DB provider SQLNCLI for linked server LinkedServerName](https://blog.sqlauthority.com/2007/05/04/sql-server-fix-error-msg-7311-level-16-state-2-line-1-cannot-obtain-the-schema-rowset-dbschema_tables_info-for-ole-db-provider-sqlncli-for-linked-server-linkedservername/): You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server. Error: The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator. Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset “DBSCHEMA_TABLES_INFO” for OLE DB provider “SQLNCLI” for linked server “<LinkedServerName>”. The provider supports the interface, but returns a failure code when it is used. Fix/WorkAround/Solution: Use Windows Authentication mode For a... - [SQL SERVER - Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts)](https://blog.sqlauthority.com/2007/05/04/sql-server-download-sql-server-management-studio-keyboard-shortcuts-ssms-shortcuts/): Download SQL Server Management Studio Keyboard Shortcuts I have received many emails appreciating my article Query Analyzer Shortcuts and requesting same for SQL Server Management Studio Keyboard Shortcuts. I see frequent downloads of the PDF generated by SQLAuthority for the same on server. There is original article on MSDN site. I have combined complete article in one PDF again. It is easy to refer, print and manage. Download SQL Server Management Studio Keyboard Shortcuts Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC Commands to Free SQL Server Memory Caches](https://blog.sqlauthority.com/2007/05/03/sql-server-dbcc-commands-to-free-several-sql-server-memory-caches/): Lots of people do not know that following command can be very helpful to clear your memory caches of SQL Server. I have often seen people restarting their entire system to clear the memory caches. - [SQL SERVER - Enable Login - Disable Login using ALTER LOGIN - Change name of the 'SA'](https://blog.sqlauthority.com/2007/05/03/sql-server-enable-login-disable-login-using-alter-login-change-name-of-the-sa/): Enable Login – Disable Login using ALTER LOGIN – Change name of the ‘SA’ - [SQL SERVER - FIX : ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup](https://blog.sqlauthority.com/2007/05/02/sql-server-fix-error-1101-could-not-allocate-a-new-page-for-database-because-of-insufficient-disk-space-in-filegroup/): ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup . Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. Fix/Workaround/Solution: Make sure there is enough Hard Disk space where database files are stored on server. Turn on AUTOGROW for file groups. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 TOP Improvements/Enhancements](https://blog.sqlauthority.com/2007/05/02/sql-server-2005-top-improvementsenhancements/): SQL Server 2005 introduces two enhancements to the TOP clause. 1) User can specify an expression as an input to the TOP keyword. 2) User can use TOP in modification statements (INSERT, UPDATE, and DELETE). Explanation : User can specify an expression as an input to the TOP keyword. In SQL SERVER 2000 usage of TOP is implemented in following query. SELECT TOP 10 TableColumnID FROM TableName   For ages Developers and DBAs wants to pass parameters to TOP keyword. IN SQL SERVER 2005 it is possible. Example, @iNum is variables set before SELECT statement is ran. DECLARE @iNum INT SET... - [SQL SERVER - User Defined Functions (UDF) to Reverse String - UDF_ReverseString](https://blog.sqlauthority.com/2007/05/01/sql-server-user-defined-functions-udf-to-reverse-string-udf_reversestring/): UDF_ReverseString UDF_ReverseString User Defined Functions returns the Reversed String starting from certain position. First parameters takes the string to be reversed. Second parameters takes the position from where the string starts reversing. Script of UDF_ReverseString function to return Reverse String. CREATE FUNCTION UDF_ReverseString ( @StringToReverse VARCHAR(8000), @StartPosition INT ) RETURNS VARCHAR(8000) AS BEGIN IF (@StartPosition <= 0) OR (@StartPosition > LEN(@StringToReverse)) RETURN (REVERSE(@StringToReverse)) RETURN (STUFF (@StringToReverse, @StartPosition, LEN(@StringToReverse) - @StartPosition + 1, REVERSE(SUBSTRING (@StringToReverse, @StartPosition LEN(@StringToReverse) - @StartPosition + 1)))) END GO Usage of above UDF_ReverseString: Reversing the string from third position SELECT dbo.UDF_ReverseString('forward string',3) Results Set : forgnirts draw Reversing... - [SQL SERVER - Copy Column Headers in Query Analyzers in Result Set](https://blog.sqlauthority.com/2007/05/01/sql-server-copy-column-headers-in-query-analyzers-in-result-set/): Copy Column Headers in Query Analyzers in Result Set. In Query Analyzer go to Menu >> Tools >> Options >> Results Select Default results Target: Results to Text Results output format:(*): Tab Delimited Print column headers(*): Checkbox ON(check) [youtube=http://www.youtube.com/watch?v=BL5GO-jH3HA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com 100th Post - Gratitude Note to Readers](https://blog.sqlauthority.com/2007/05/01/sqlauthoritycom-101st-post-gratitude-note-to-readers/): Hello All, I would like to express my deep gratitude to all of my readers for their emails, comments, suggestions and continuous support on the occasion of 101st post on this blog. I would like to extend my gratitude to my parents. In good times or trying times my parents are there with me always. Mom and Dad thank you for your encouragement, warmth, advise and continuous love. Kind Regards and Best Wishes, Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Collate - Case Sensitive SQL Query Search](https://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/): In this blog post we are going to learn about how to do Case Sensitive SQL Query Search. If Column1 of Table1 has following values ‘CaseSearch, casesearch, CASESEARCH, CaSeSeArCh’, following statement will return you all the four records. - [SQL SERVER - FIX : ERROR : Msg 3159, Level 16, State 1, Line 1 - Msg 3013, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/30/sql-server-fix-error-msg-3159-level-16-state-1-line-1-msg-3013-level-16-state-1-line-1/): While moving some of the script from SQL SERVER 2000 to SQL SERVER 2005 our migration team faced following error. Msg 3159, Level 16, State 1, Line 1 The tail of the log for the database “AdventureWorks” has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. Following is the similar script using AdventureWorks... - [SQL SERVER - SET ROWCOUNT - Retrieving or Limiting the First N Records from a SQL Query](https://blog.sqlauthority.com/2007/04/30/sql-server-set-rowcount-retrieving-or-limiting-the-first-n-records-from-a-sql-query/): A SET ROWCOUNT statement simply limits the number of records returned to the client during a single connection. As soon as the number of rows specified is found, SQL Server stops processing the query. The syntax looks like this: - [SQL SERVER - 2005 Security DataSheet](https://blog.sqlauthority.com/2007/04/29/sql-server-2005-security-datasheet/): Microsoft has implemented strong security features into the Microsoft® SQL Server™ 2005, which provides a security-enabled platform for enterprise-class relational database and analysis solutions. SQL Server 2005 provides cutting edge security technology and addresses several security issues, including automatic secured updates and encryption of sensitive data. Download the SQL Server 2005 Security DataSheet from SQLAuthority.com Download the SQL Server 2005 Security DataSheet from Microsoft.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Random Number Generator Script - SQL Query](https://blog.sqlauthority.com/2007/04/29/sql-server-random-number-generator-script-sql-query/): Random Number Generator. There are many methods to generate random numbers in SQL Server. Method 1: Generate Random Numbers (Int) between Rang - [SQL SERVER - Replication Keywords Explanation and Basic Terms](https://blog.sqlauthority.com/2007/04/29/sql-server-replication-keywords-explanation-and-basic-terms/): While discussing replication with Jr. DBAs at work, I realize some of them have not experienced replication feature of SQL SERVER. Following is quick reference of replication keywords I created for easy conversation. - [SQL SERVER - Explanation SQL SERVER Merge Join](https://blog.sqlauthority.com/2007/04/28/sql-server-explanation-sql-server-merge-join/): The Merge Join transformation provides an output that is generated by joining two sorted data sets using a FULL, LEFT, or INNER join. The Merge Join transformation requires that both inputs be sorted and that the joined columns have matching meta-data. User cannot join a column that has a numeric data type with a column that has a character data type. If the data has a string data type, the length of the column in the second input must be less than or equal to the length of the column in the first input with which it is merged. USE pubs... - [SQL SERVER - Restrictions of Views - T SQL View Limitations](https://blog.sqlauthority.com/2007/04/28/sql-server-restrictions-of-views-t-sql-view-limitations/): UPDATE: (5/15/2007) Thank you Ben Taylor for correcting errors and incorrect information from this post. He is Database Architect and writes Database Articles at www.sswug.org. I have been coding as T-SQL for many years. I never have to use view ever in my career. I do not see in my near future I am using Views. I am able to achieve same database architecture goal using either using Third Normal tables, Replications or other database design work around.SQL Views have many many restrictions. There are few listed below. I love T-SQL but I do not like using Views. - [SQL SERVER - Good, Better and Best Programming Techniques](https://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/): A week ago, I was invited to meeting of programmers. Subject of meeting was “Good, Better and Best Programming Techniques”. I had made small note before I went to meeting, so if I have to talk about or discuss SQL Server it can come handy. Well, I did not get chance to talk on that as it was very causal and just meeting and greetings. Everybody just talked about what they think about their job. I talked very briefly about SQL Server, my current job and some funny incident at work. Everybody laughed big when I talked about funny bug ticket... - [SQL SERVER - Query to Retrieve the Nth Maximum Value](https://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/): Replace Employee with your table name, and Salary with your column name. Where N is the level of Salary to be determined. Let us see a query to retrieve the Nth Maximum Value. - [SQL SERVER - Locking Hints and Examples](https://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/): Locking Hints and Examples are as follows. The usage of them is the same but the effect is different. Let us learn it today together. - [SQL SERVER - SELECT vs. SET Performance Comparison](https://blog.sqlauthority.com/2007/04/27/sql-server-select-vs-set-performance-comparison/): Usage: SELECT : Designed to return data. SET : Designed to assign values to local variables. While testing the performance of the following two scripts in query analyzer, interesting results are discovered. SET @foo1 = 1; SET @foo2 = 2; SET @foo3 = 3; SELECT @foo1 = 1, @foo2 = 2, @foo3 = 3; While comparing their performance in loop SELECT statement gives better performance then SET. In other words, SET is slower than SELECT. The reason is that each SET statement runs individually and updates on values per execution, whereas the entire SELECT statement runs once and update all three... - [SQL SERVER - Difference Between Unique Index vs Unique Constraint](https://blog.sqlauthority.com/2007/04/26/sql-server-difference-between-unique-index-vs-unique-constraint/): Unique Index and Unique Constraint are the same. They achieve same goal. SQL Performance is same for both. Add Unique Constraint ALTER TABLE dbo.<tablename> ADD CONSTRAINT <namingconventionconstraint> UNIQUE NONCLUSTERED ( <columnname> ) ON [PRIMARY] Add Unique Index CREATE UNIQUE NONCLUSTERED INDEX <namingconventionconstraint> ON dbo.<tablename> ( <columnname> ) ON [PRIMARY] There is no difference between Unique Index and Unique Constraint. Even though syntax are different the effect is the same. Unique Constraint creates Unique Index to maintain the constraint to prevent duplicate keys. Unique Index or Primary Key Index are physical structure that maintain uniqueness over some combination of columns across all... - [SQL SERVER - Enable xp_cmdshell using sp_configure](https://blog.sqlauthority.com/2007/04/26/sql-server-enable-xp_cmdshell-using-sp_configure/): The xp_cmdshell option is a server configuration option that enables system administrators to control whether the xp_cmdshell extended stored procedure can be executed on a system. - [SQL SERVER - 2005 - DBCC ROWLOCK - Deprecated](https://blog.sqlauthority.com/2007/04/26/sql-server-2005-dbcc-rowlock-deprecated/): Title says all. My search engine log says many web users are looking for DBCC ROWLOCK in SQL SERVER 2005. It is deprecated feature for SQL SERVER 2005. It is Automatically on for SQL SERVER 2005. More Deprecated Features of SQL SERVER 2005 Refer MSDN Discontinued Database Engine Functionality in SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Alternate Fix : ERROR 1222 : Lock request time out period exceeded](https://blog.sqlauthority.com/2007/04/25/sql-server-alternate-fix-error-1222-lock-request-time-out-period-exceeded/): ERROR 1222 : Lock request time out period exceeded. - [SQL SERVER - ERROR Messages - sysmessages error severity level](https://blog.sqlauthority.com/2007/04/25/sql-server-error-messages-sysmessages-error-severity-level/): SQL ERROR Messages Each error message displayed by SQL Server has an associated error message number that uniquely identifies the type of error. The error severity levels provide a quick reference for you about the nature of the error. The error state number is an integer value between 1 and 127; it represents information about the source that issued the error. The error message is a description of the error that occurred. The error messages are stored in the sysmessages system table. - [SQL SERVER - 2005 Take Off Line or Detach Database](https://blog.sqlauthority.com/2007/04/25/sql-server-2005-take-off-line-or-detach-database/): EXEC sp_dboption N'mydb', N'offline', N'true' OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK AFTER 30 SECONDS OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK IMMEDIATE Using the alter database statement (SQL Server 2k and beyond) is the preferred method. The rollback after statement will force currently executing statements to rollback after N seconds. The default is to wait for all currently running transactions to complete and for the sessions to be terminated. Use the rollback immediate clause to rollback transactions immediately. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - TRIM() Function - UDF TRIM()](https://blog.sqlauthority.com/2007/04/24/sql-server-trim-function-udf-trim/): SQL Server does not have function which can trim leading or trailing spaces of any string. TRIM() is very popular function in many languages. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. I was expecting SQL Server 2005 to have TRIM() function. Unfortunately, SQL Server 2005 does not have that either. I have created very simple UDF which does the same work. FOR SQL SERVER 2000: CREATE FUNCTION dbo.TRIM(@string VARCHAR(8000)) RETURNS VARCHAR(8000) BEGIN RETURN LTRIM(RTRIM(@string)) END GO FOR SQL SERVER 2005: CREATE FUNCTION dbo.TRIM(@string VARCHAR(MAX)) RETURNS VARCHAR(MAX) BEGIN RETURN LTRIM(RTRIM(@string)) END GO Both the above... - [SQL SERVER - Six Properties of Relational Tables](https://blog.sqlauthority.com/2007/04/24/sql-server-six-properties-of-relational-tables/): Relational tables have six properties: Values Are Atomic This property implies that columns in a relational table are not repeating group or arrays. The key benefit of the one value property is that it simplifies data manipulation logic. Such tables are referred to as being in the “first normal form” (1NF). Column Values Are of the Same Kind In relational terms this means that all values in a column come from the same domain. A domain is a set of values which a column may have. This property simplifies data access because developers and users can be certain of the type... - [SQL SERVER - 2005 Collation Explanation and Translation](https://blog.sqlauthority.com/2007/04/24/sql-server-2005-collation-explanation-and-translation/): Just a day before one of our SQL SERVER 2005 needed Case-Sensitive Binary Collation. When we install SQL SERVER 2005 it gives options to select one of the many collation. I says in words like ‘Dictionary order, case-insensitive, uppercase preference’. I was confused for little while as I am used to read collation like ‘SQL_Latin1_General_Pref_Cp1_CI_AS_KI_WI’. I did some research and find following link which explains many of the SQL SERVER 2005 collation. Complete documentation MSDN – SQL SERVER Collation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Query Analyzer - Microsoft SQL SERVER Management Studio](https://blog.sqlauthority.com/2007/04/23/sql-server-2005-query-analyzer-microsoft-sql-server-management-studio/): Following may be very simple to some and helpful to other type of question. I have seen this in my server log as well as this has been always first question in my Developer Team. Where is SQL SERVER 2005 Query Analyzer? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). To see the familiour Query Analyzer Window follow the image below. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Find Seed Values, Increment Values and Current Identity Column value of the table](https://blog.sqlauthority.com/2007/04/23/sql-server-query-to-find-seed-values-increment-values-and-current-identity-column-value-of-the-table/): Following script will return all the tables which has identity column. It will also return the Seed Values, Increment Values and Current Identity Column value of the table. SELECT IDENT_SEED(TABLE_NAME) AS Seed, IDENT_INCR(TABLE_NAME) AS Increment, IDENT_CURRENT(TABLE_NAME) AS Current_Identity, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1 AND TABLE_TYPE = 'BASE TABLE' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Understanding new Index Type of SQL Server 2005 Included Column Index along with Clustered Index and Non-clustered Index](https://blog.sqlauthority.com/2007/04/23/sql-server-understanding-new-index-type-of-sql-server-2005-included-column-index-along-with-clustered-index-and-non-clustered-index/): Clustered Index Only 1 allowed per table Physically rearranges the data in the table to conform to the index constraints. - [SQL SERVER - Raid Configuration - RAID 10](https://blog.sqlauthority.com/2007/04/22/sql-server-raid-configuration-raid-10/): I get question about what configuration of redundant array of inexpensive disks (RAID) I use for my SQL Servers. The answer is short is: RAID 10. Why? Excellent performance with Read and Write. RAID 10 has advantage of both RAID 0 and RAID 1. RAID 10 uses all the drives in the array to gain higher I/O rates so more drives in the array higher performance. RAID 5 has penalty for write performance because of the parity in check. There are many article already written about them. If you are interested in reading more please refer book online. Reference : Pinal... - [SQL SERVER - @@DATEFIRST and SET DATEFIRST Relations and Usage](https://blog.sqlauthority.com/2007/04/22/sql-server-datefirst-and-set-datefirst-relations-and-usage/): The master database’s syslanguages table has a DateFirst column that defines the first day of the week for a particular language. SQL Server with US English as default language, SQL Server sets DATEFIRST to 7 (Sunday) by default. We can reset any day as first day of the week using SET DATEFIRST 5 This will set Friday as first day of week. @@DATEFIRST returns the current value, for the session, of SET DATEFIRST. SET LANGUAGE italian GO SELECT @@DATEFIRST GO ----This will return result as 1(Monday) SET LANGUAGE us_english GO SELECT @@DATEFIRST GO ----This will return result as 7(Sunday) In this... - [SQL SERVER - Fix : Error 1418 - Microsoft SQL Server - The server network address can not be reached](https://blog.sqlauthority.com/2007/04/22/sql-server-fix-error-1418-microsoft-sql-server-the-server-network-address-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-reissue-the-command/): Error: 1418 – Microsoft SQL Server – The server network address can not be reached or does not exist. Check the network address name and reissue the command The server network endpoint did not respond because the specified server network address cannot be reached or does not exist. - [SQL Server Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/04/21/sql-server-interview-questions-and-answers-complete-list-download/): This is summary blog post for SQL Server Interview Questions and Answers. Click here to get free chapters (PDF) in the mailbox. - [SQL Server Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2007/04/20/sql-server-interview-questions-part-6/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2007/04/19/sql-server-interview-questions-part-5/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2007/04/18/sql-server-interview-questions-part-4/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/04/17/sql-server-interview-questions-part-3/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/04/16/sql-server-interview-questions-part-2/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions-and-answers-introduction/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL SERVER - 64 bit Architecture and White Paper](https://blog.sqlauthority.com/2007/04/14/sql-server-64-bit-architecture-and-white-paper/): In supportability, manageability, scalability, performance, interoperability, and business intelligence, SQL Server 2005 provides far richer 64-bit support than its predecessor. This paper describes these enhancements. Read the original paper here. Following abstract is taken from the same paper. Another interesting article on 64-bit Computing with SQL Server 2005 is here. The primary differences between the 64-bit and 32-bit versions of SQL Server 2005 are derived from the benefits of the underlying 64-bit architecture. Some of these are: The 64-bit architecture offers a larger directly-addressable memory space. SQL Server 2005 (64-bit) is not bound by the memory limits of 32-bit systems. Therefore,... - [SQL SERVER - CASE Statement/Expression Examples and Explanation](https://blog.sqlauthority.com/2007/04/14/sql-server-case-statementexpression-examples-and-explanation/): CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in functions. Two basic formulations for CASE expression 1) Simple CASE expressions A simple CASE expression checks one expression against multiple values. Within a SELECT statement, a simple CASE expression allows only an equality check; no other comparisons are made. A simple CASE expression operates by comparing the first expression to the expression in each WHEN clause for equivalency. If these expressions... - [SQL SERVER - Fix : Error: 18452 Login failed for user '(null)'. The user is not associated with a trusted SQL Server connection.](https://blog.sqlauthority.com/2007/04/14/sql-server-fix-error-18452-login-failed-for-user-null-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Some errors never got old. I have seen many new DBA or Developers struggling with this errors. Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection. Fix/Solution/Workaround: Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)” to “Mixed Mode (Windows Authentication and SQL Server Authentication)”. Run following script in SQL Analyzer to change the authentication LOGIN sa ENABLE GO ALTER LOGIN sa WITH PASSWORD = '<password>' GO OR In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties. On the General page, you may have to create... - [SQL SERVER - Stored Procedures Advantages and Best Advantage](https://blog.sqlauthority.com/2007/04/13/sql-server-stored-procedures-advantages-and-best-advantage/): There are many advantages of Stored Procedures. I was once asked what do I think is the most important feature of Stored Procedure? I have to pick only ONE. It is tough question. I answered : Execution Plan Retention and Reuse (SP are compiled and their execution plan is cached and used again to when the same SP is executed again) Not to mentioned I received the second question following my answer : Why? Because all the other advantage known (they are mentioned below) of SP can be achieved without using SP. Though Execution Plan Retention and Reuse can only be... - [SQL SERVER - Clear Drop Down List of Recent Connection From SQL Server Management Studio](https://blog.sqlauthority.com/2008/11/05/sql-server-clear-drop-down-list-of-recent-connection-from-sql-server-management-studio/): Quite often it happens that SQL Server Management Studio’s Dropdown box is cluttered with many different SQL Server’s name. Sometime it contains the name of the server which does not exist or developer does not have access to it. It is very easy to clean the list and start over. Delete mru.dat file from following location. For SQL Server 2005: C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat If you can not find mru.dat at above location look for mru.dat in following folder. C:\Documents and Settings\[user]\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM\mru.dat For SQL Server 2008: C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\mru.dat If you can not... - [SQL SERVER - Fix : Error: 4064 - Cannot open user default database. Login failed. Login failed for user](https://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/): I have received following question nearly 10 times in last week though emails. Many users have received following error while connecting to the database. This error happens when database is dropped for which is default for some of the database user. When user try to login and their default database is dropped following error shows up. Cannot open user default database. Login failed. Login failed for user ‘UserName’. (Microsoft SQL Server, Error: 4064) The fix for this problem is very simple. Fix/Workaround/Solution: First click on Option>> Button of “Connect to Server” Prompt. Now change the connect to database to any existing... - [SQLAuthority News - SQL Server Security Whitepapers](https://blog.sqlauthority.com/2008/11/03/sqlauthority-news-sql-server-security-whitepapers/): Microsoft has published following three security related white papers. I suggest to all my readers to read them. Read the summary know what is covered in those  white papers. Engine Separation of Duties for the Application Developer – Separation of duties is an important consideration for databases and database applications. By properly defining schemas and roles, you can create a distinction between users who can manipulate data from those that administer the database. This paper discusses the topics of which application developers should be aware and provides a heuristic example to guide you in achieving separation of duties. Database Encryption in... - [SQL SERVER - Fix : Error : Login failed for user 'UserName'. The user is not associated with a trusted SQL Server connection](https://blog.sqlauthority.com/2008/11/02/sql-server-fix-error-login-failed-for-user-username-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Recently I have got two desktop computers at home and both of them are very powerful machine. Machine 1 : Windows Vista SP1 with SQL Server 2008 Machine 2 : Windows 2003 with SQL Server 2005 with SP2 When I was trying to connect from SQL Server 2008 to SQL Server 2005 using Windows Authentication I was getting following error. Login failed for user ‘UserName’. The user is not associated with a trusted SQL Server connection. To resolve this error follow the steps below on computer with SQL Server 2005. Create new user with Administrator privilege with same username and password... - [SQL SERVER - Stored Procedure WITH ENCRYPTION and Execution Plan](https://blog.sqlauthority.com/2008/11/01/sql-server-stored-procedure-with-encryption-and-execution-plan/): Stored Procedures are very important and most of the business logic of my applications are always coded in Stored Procedures. Sometime it is necessary to hide the business logic from end user due to security reasons or any other reason. Keyword WITH ENCRYPTION is used to encrypt the text of the Stored Procedure. One SP are encrypted it is not possible to get original text of the SP from SP itself. User who created SP will need to save the text to be used to create SP somewhere safe to reuse it again. Interesting observation: What prompted me to write this... - [SQL SERVER - DECLARE Multiple Variables in One Statement](https://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/): Just a day ago, while I was enjoying mini vacation during festival of Diwali I met one of the .NET developer who is big fan of Oracle. While discussing he suggested that he wished SQL Server should have feature where multiple variable can be declared in one statement. I requested him to not judge wonderful product like SQL Server with just one feature. SQL Server is great product and it has many feature which are very unique to SQL Server. Regarding feature of SQL Server where multiple variable can be declared in one statement, it is absolutely possible to do. Method... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2008/10/30/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007/): Note:   Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Feature Bullet Summary: The following list gives an overview of the features of the SQL Server management pack. Refer to the SQL Server management pack guide for more detail. Support for Enterprise, Standard and Express... - [SQLAuthority News - Download SQL Server 2005 Service Pack 3 - CTP](https://blog.sqlauthority.com/2008/10/29/sqlauthority-news-download-sql-server-2005-service-pack-3-ctp/): The CTP version of SQL Server 2005 Service Pack 3 (SP3) is now available. You can use these packages to upgrade any of the following SQL Server 2005 editions: Enterprise Enterprise Evaluation Developer Standard Workgroup For a summary list of What’s new in SQL Server 2005 SP3 CTP, review the What’s New document. These packages have been made available for general testing purposes only. Do not deploy the CTP software in production. Download SQL Server 2005 Service Pack 3 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Happy Diwali to All of You](https://blog.sqlauthority.com/2008/10/28/sqlauthority-news-happy-diwali-to-all-of-you/): SQLAuthority Wishes Happy Diwali to All of You. Diwali is one of the important Hindu festivals, which comprises of four consecutive days of celebrations. - [SQLAuthority News - Download Microsoft SQL Server 2008 Feature Pack, October 2008](https://blog.sqlauthority.com/2008/10/27/sqlauthority-news-download-microsoft-sql-server-2008-feature-pack-october-2008/): Note: Download Microsoft SQL Server 2008 Feature Pack, October 2008 by Microsoft - [SQLAuthority News - Definition - Outsourcing, Offshoring, Nearshoring, Offshore Outsourcing](https://blog.sqlauthority.com/2008/10/26/sqlauthority-news-definition-outsourcing-offshoring-nearshoring-offshore-outsourcing/): Outsourcing - Outsourcing is subcontracting a process, such as product design or manufacturing, to a third-party company. Outsourcing involves the transfer of the management and/or day-to-day execution of an entire business function to an external service provider. - [SQL SERVER - INNER JOIN using LEFT JOIN statement - Performance Analysis](https://blog.sqlauthority.com/2008/10/25/sql-server-inner-join-using-left-join-statement-performance-analysis/): Just a day ago, while I was working with JOINs I find one interesting observation, which has prompted me to create following example. Before we continue further let me make very clear that INNER JOIN should be used where it can not be used and simulating INNER JOIN using any other JOINs will degrade the performance. If there are scopes to convert any OUTER JOIN to INNER JOIN it should be done with priority. Run following two script and observe the resultset. Resultset will be identical. USE AdventureWorks GO / Example of INNER JOIN / SELECT p.ProductID, piy.ProductID FROM Production.Product p INNER JOIN Production.ProductInventory piy ON piy.ProductID = p.ProductID... - [SQLAuthority News - TOP Downloads - Bookmark](https://blog.sqlauthority.com/2008/10/24/sqlauthority-news-top-downloads-bookmark/): Recently I have gotten many, many requests for SQL Server Interview Questions and Answers as well as related articles. It seems many people are looking for Job or appearing for an interview at this time of the year. I have included lists of the my top downloads in the sidebar of the blog, still I receive many curious questions as side bar does not show up in the RSS feed. - [Author Visit - MVP Open Day 2008 - Goa - November 15-17](https://blog.sqlauthority.com/2008/10/23/author-visit-mvp-open-day-2008-goa-november-15-17/): I will be attending MVP Open Day 2008 in Goa from November 15 to November 17. I am eagerly waiting to attend the Open Day. If you are in Goa during that time we can meet sometime in evening after sessions are over. Following is the comics related to MVP Open Day 2008. - [SQLAuthority News - Running SQL Server 2008 in a Hyper-V Environment Best Practices and Performance Considerations](https://blog.sqlauthority.com/2008/10/22/sqlauthority-news-running-sql-server-2008-in-a-hyper-v-environment-best-practices-and-performance-considerations/): Hyper-V in Windows Server 2008 is a powerful virtualization technology that can be used by corporate IT to consolidate under-utilized servers, lowering TCO and maintaining or improving Quality of Service. Through a series of test scenarios that are representative of SQL Server application fundamentals, this document provides best practice recommendations on running SQL Server in Windows Hyper-V environment. White paper talks about many subjects and various topics. I enjoyed reading following sections. Setup and Configuration of Hyper-V Configurations Hyper-V Preinstall Checklist and Considerations Storage Configuration Recommendations Monitoring SQL Server on Hyper-V Configurations Test Methodology, Workloads Results, Observations, and Recommendations Different kind... - [SQL SERVER - Fix : Error : Incorrect syntax near. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel](https://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/): I have seen developers confused many times when they receive the following error message. Incorrect syntax near. Let us learn. - [SQL SERVER - Transaction and Local Variables - Swap Variables - Update All At Once Concept](https://blog.sqlauthority.com/2008/10/20/sql-server-transaction-and-local-variables-swap-variables-update-all-at-once-concept/): This article is inspired from two sources. Let us learn today about how to swap variables by updating everything at once concepts. 1) My year old article - SQL SERVER - Effect of TRANSACTION on Local Variable - After ROLLBACK and After COMMIT 2) Discussion with SQL Server MVP - Jacob Sebastian - SQLAuthority News - Author Visit - SQL Hour at Patni Computer Systems I usually summarize my article at the end, but this time let me summarize first and we will understand the article next. - [SQL SERVER - Introduction to CLR - Simple Example of CLR Stored Procedure](https://blog.sqlauthority.com/2008/10/19/sql-server-introduction-to-clr-simple-example-of-clr-stored-procedure/): CLR is abbreviation of Common Language Runtime. In SQL Server 2005 and later version of it database objects can be created which are created in CLR. Stored Procedures, Functions, Triggers can be coded in CLR. CLR is faster than T-SQL in many cases. CLR is mainly used to accomplish task which are not possible by T-SQL or can use lots of resources. CLR can be usually implemented where there is intense string operation, thread management or iteration methods which can be complicated for T-SQL. Implementing CLR provides more security to Extended Stored Procedure. Let us create one very simple CLR where... - [SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice - Part 2](https://blog.sqlauthority.com/2008/10/18/sql-server-retrieve-select-only-date-part-from-datetime-best-practice-part-2/): A year ago I wrote post about SQL SERVER – Retrieve – Select Only Date Part From DateTime – Best Practice where I have discussed two different methods of getting datepart from datetime. Method 1: SELECT DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())) Method 2: SELECT CONVERT(VARCHAR(10),GETDATE(),111) I have summarized my post suggesting that either method works fine and I prefer to use Method 2. However, with additional tests and looking at SQL Server internals very carefully, I want to suggest that Method 1 is better in terms of performance. While running on GETDATE() both of the above functions are equally fast and... - [SQL SERVER - Get Common Records From Two Tables Without Using Join](https://blog.sqlauthority.com/2008/10/17/sql-server-get-common-records-from-two-tables-without-using-join/): I really enjoy answering questions which I receive from either comments or Email. My passion is shared by SQL Server Expert Imran Mohammed. He frequently SQL community members by answering their questions frequently and promptly. Sachin Asked: Following is my scenario, Suppose Table 1 and Table 2 has same column e.g. Column1 Following is the query, 1. Select column1,column2 From Table1 2. Select column1 From Table2 I want to find common records from these tables, but i don’t want to use Join clause bcoz for that i need to specify the column name for Join condition. Will you help me to... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting - October 2008](https://blog.sqlauthority.com/2008/10/17/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-october-2008/): Tomorrow is third Saturday of the Month and every third Saturday we have Ahmedabad User Group Meeting. Our user group is growing and getting interesting. Everybody who attended last months User Group (UG) Meeting realized that how important it is to attend UG meetings. UG President Jacob Sebastian (SQL Server – MVP) presented excellent session on “Real World example of CTE”.I personally enjoyed the session very much. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my article here where... - [SQL SERVER - Downgrade Database to Previous Version](https://blog.sqlauthority.com/2008/10/16/sql-server-downgrade-database-to-previous-version/): Today I am writing on the topic which I do not like to write much. I enjoy writing usually positive or affirmative posts. Recently I got email from two different DBA where they upgraded to SQL Server 2005 trial version on their production server and now as their trial version was expire they wanted to downgrade their database to previous licensed version they had. The main questions is how they can downgrade the from SQL Server 2005 to SQL Server 2000? Answer is : Not Possible. There are no tools or native SQL Server facility which does this. I am also... - [SQL SERVER - Introduction and Example of UNION and UNION ALL](https://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/): It is very much interesting when I get request from blog reader to re-write my previous articles. I have received few request to rewrite my article SQL SERVER – Union vs. Union All – Which is better for performance? wi.th examples. I request you to read my previous article first to understand what is the concept and read this article to understand the same concept with example. xe=”color:green;”>/* Create First Table */ DECLARE @Table1 TABLE (Col INT) INSERT INTO @Table1 SELECT 1 INSERT INTO @Table1 SELECT 2 INSERT INTO @Table1 SELECT 3 INSERT INTO @Table1 SELECT 4 INSERT INTO @Table1 SELECT 5 /* Create Second Table */ DECLARE @Table2 TABLE (Col INT) INSERT INTO @Table2... - [SQL SERVER - Get Numeric Value From Alpha Numeric String - UDF for Get Numeric Numbers Only](https://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/): SQL is great with String operations. Many times, I use T-SQL to do my string operation. Let us see User Defined Function, which I wrote few days ago, which will return only Numeric values from AlphaNumeric values. CREATE FUNCTION dbo.udf_GetNumeric (@strAlphaNumeric VARCHAR(256)) RETURNS VARCHAR(256) AS BEGIN DECLARE @intAlpha INT SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric) BEGIN WHILE @intAlpha > 0 BEGIN SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' ) SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric ) END END RETURN ISNULL(@strAlphaNumeric,0) END GO /* Run the UDF with different test values */ SELECT dbo.udf_GetNumeric('') AS 'EmptyString'; SELECT dbo.udf_GetNumeric('asdf1234a1s2d3f4@@@') AS 'asdf1234a1s2d3f4@@@'; SELECT dbo.udf_GetNumeric('123456') AS '123456'; SELECT dbo.udf_GetNumeric('asdf') AS 'asdf'; SELECT dbo.udf_GetNumeric(NULL) AS 'NULL'; GO As... - [SQLAuthority News - Book Review - Pro SQL Server 2005 Replication (Definitive Guide)](https://blog.sqlauthority.com/2008/10/13/sqlauthority-news-book-review-pro-sql-server-2005-replication-definitive-guide/): Pro SQL Server 2005 Replication (Definitive Guide) (Hardcover) by Sujoy Paul (Author) Link to Amazon Quick Review: This is good book for any novice developer to start in the world of database replication implementation and maintenance. Replication is important part of highly availability and one book covers all the concept and methodology at one place. Detail Review: Replication is the process of sharing information so as to ensure consistency between redundant resources, such as software or hardware components, to improve reliability, fault-tolerance, or accessibility. Database replication can be used on many database management systems, usually with a master/slave relationship between the... - [SQLAuthority News - SQL Injection - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2008/10/12/sqlauthority-news-sql-injection-sql-joke-sql-humor-sql-laugh/): It has been a long time since I wrote about SQL Humor. Following is the cartoon sent to me by many (more than 10 times) so far by many users. I did not publish it till now as it has been quite popular and I believed many people had already seen it. However, recently by one of the quite big personality asked me why I have not included this in my blog, so I have finally decided to include that in my blog. Let us read humor about SQL Injection. - [SQLAuthority News - Download - Microsoft SQL Server 2008 Feature Pack, August 2008](https://blog.sqlauthority.com/2008/10/11/sqlauthority-news-download-microsoft-sql-server-2008-feature-pack-august-2008/): Download the 2008 Feature Pack for Microsoft SQL Server 2008, a collection of stand-alone install packages that provide additional value for SQL Server 2008. The Feature Pack is a collection of stand-alone install packages that provide additional value for SQL Server 2008. It includes the latest versions of: Redistributable components for SQL Server 2008. Add-on providers for SQL Server 2008. Backward compatibility components for SQL Server 2008. Download Feature Pack Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Enhenced TRIM() Function - Remove Trailing Spaces, Leading Spaces, White Space, Tabs, Carriage Returns, Line Feeds](https://blog.sqlauthority.com/2008/10/10/sql-server-2008-enhenced-trim-function-remove-trailing-spaces-leading-spaces-white-space-tabs-carriage-returns-line-feeds/): After reading my article SQL SERVER – 2008 – TRIM() Function – User Defined Function, I have received email and comments where user are asking if it is possible to remove trailing spaces, leading spaces, white space, tabs, carriage returns, line feeds etc. I found following script posted by Russ and Erik. It is modified a bit from original script. CREATE FUNCTION dbo.LTrimX(@str VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN DECLARE @trimchars VARCHAR(10) SET @trimchars = CHAR(9)+CHAR(10)+CHAR(13)+CHAR(32) IF @str LIKE '[' + @trimchars + ']%' SET @str = SUBSTRING(@str, PATINDEX('%[^' + @trimchars + ']%', @str), 8000) RETURN @str END GO CREATE FUNCTION dbo.RTrimX(@str VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN... - [SQL SERVER - 2008 - TRIM() Function - User Defined Function](https://blog.sqlauthority.com/2008/10/09/sql-server-2008-trim-function-user-defined-function/): I just received following question in email by James Louren. “How come SQL Server 2000, 2005 does not have function TRIM()? Is there any way to get similar results. What about SQL Server 2008?” James has asked very interesting question. I have previously wrote about SQL SERVER – TRIM() Function – UDF TRIM(). Today my answer is no different than what I answered in earlier post. SQL Server does not have function which can trim leading or trailing spaces of any string at the same time. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. SQL... - [SQLAuthority News - SQL Server 2008 - Microsoft Certifications for 70-432 70-433 70-450 70-452](https://blog.sqlauthority.com/2008/10/08/sqlauthority-news-sql-server-2008-microsoft-certifications-for-70-432-70-433-70-450-70-452/): I have received many emails requesting information about SQL Server certifications examples. Microsoft has released new set of exams for SQL Server 2008 certifications. I am listing them here for quick reference. Exam 70-432 – TS: Microsoft SQL Server 2008, Implementation and Maintenance Installing and Configuring SQL Server 2008 (10 percent) Maintaining SQL Server Instances (13 percent) Managing SQL Server Security (15 percent) Maintaining a SQL Server Database (16 percent) Performing Data Management Tasks (14 percent) Monitoring and Troubleshooting SQL Server (13 percent) Optimizing SQL Server Performance (10 percent) Implementing High Availability (9 percent) ————————————— Exam 70-433 – TS: Microsoft SQL... - [SQL SERVER - 2008 - High Resolution Wallpaper and Screen Saver](https://blog.sqlauthority.com/2008/10/07/sql-server-2008-high-resolution-wallpaper-and-screen-saver/): Recently I came across two very interesting ‘objects’ of SQL Server 2008. SQL Server 2008 High Resolution Wallpaper SQL Server 2008 Screen Saver Click Here to Download Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - SQL Hour at Patni Computer Systems](https://blog.sqlauthority.com/2008/10/07/sqlauthority-news-author-visit-sql-hour-at-patni-computer-systems/): Ahmedabad SQL Server User Group has started organizing a special event, “SQL Hour”, where we visit IT companies and interact with the SQL Server professionals. We had the first meeting this Saturday, 4th October 2008 at Patni Computer Systems, Gandhinangar. This meeting was lead by SQL Server User Group President Jacob Sebastian, who is known for his knowledge of “SQL Server – Behind the Scene”. He presented first session where he explained what is User Group and importance of “SQL Hour”. The meeting was very interesting and attendees were very responsive. We want to congratulate all the attendees as they really... - [SQLAuthority News - Upgrade SQL Server With SA Renamed - Rebuild System Databases - SQL Server 2008](https://blog.sqlauthority.com/2008/10/06/sqlauthority-news-upgrade-sql-server-with-sa-renamed-rebuild-system-databases-sql-server-2008/): I recently came across two interesting blog post by PSS SQL Server Engineers. They have written two interesting SQL Server 2008 related post and it can be very helpful to those who come across the issues mentioned in them. How to Rebuild System Databases in SQL Server 2008 Rarely but sometime there is need to rebuilding the System Databases. In SQL Server 2008 there is no facility to rebuild only msdb database. All the system database have to be rebuilt if any of the database has to be rebuild. System Databases like mssqlsystemresource can be rebuilt only by running Repair from... - [SQL SERVER - 2008 - Fix Connection Error with Visual Studio 2008 - Server Version is not supported - VS SP1 ISO Download](https://blog.sqlauthority.com/2008/10/05/sql-server-2008-fix-connection-error-with-visual-studio-2008-server-version-is-not-supported-vs-sp1-iso-download/): I previously wrote article SQL SERVER – 2008 – Fix Connection Error with Visual Studio 2008 – Server Version is not supported where I discussed how downloading Visual Studio SP1 will fix the error of Visual Studio 2008 connecting to SQL Server 2008. I have provided link to SP1 which was downloading only installer and after that it downloads SP1 component from internet. .NET Expert Vidya Vrat Agarwal has pointed out that Visual Studio SP1 can be downloaded as ISO. It is really good that now after downloading only one it can be used again to installed SP1 on multiple computers.... - [SQLAuthority News - Cumulative update package 1 for SQL Server 2008](https://blog.sqlauthority.com/2008/10/04/sqlauthority-news-cumulative-update-package-1-for-sql-server-2008/): Cumulative update package 1 for SQL Server 2008 is released. Click on link : http://support.microsoft.com/kb/956717/en-us Update : I have received few emails where developer did not find where to click on the support page to download the update package. Following image describes the link which is on very top of the page. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Find If Index is Being Used in Database](https://blog.sqlauthority.com/2008/10/03/sql-server-2008-find-if-index-is-being-used-in-database/): It is very often I get query that how to find if any index is being used in database or not. If any database has many indexes and not all indexes are used it can adversely affect performance. If number of index is higher it reduces the INSERT / UPDATE / DELETE operation but increase the SELECT operation. It is recommended to drop any unused indexes from table to improve the performance. Before dropping the index it is important to check if index is being used or not. I have wrote quick script which can find out quickly if index is... - [SQLAuthority News - Download - Visual Studio Team System 2008 Database Edition GDR September CTP](https://blog.sqlauthority.com/2008/10/03/sqlauthority-news-download-visual-studio-team-system-2008-database-edition-gdr-september-ctp/): In addition to providing support for SQL Server 2008 database projects, this release incorporates many previously released Power Tools as well as several new features. The new features include distinct Build and Deploy phases, Static Code Analysis and improved integration with SQL CLR projects. Database Edition no longer requires a Design Database. Therefore, it is no longer necessary to install an instance of SQL Express or SQL Server prior to using Database Edition. Let us learn about Visual Studio Team System. - [SQLAuthority News - Download - Microsoft SQL Server 2008 Books Online (August 2008)](https://blog.sqlauthority.com/2008/10/02/sqlauthority-news-download-microsoft-sql-server-2008-books-online-august-2008/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Descriptions of the... - [SQL Server - 2008 - Cheat Sheet - One Page PDF Download](https://blog.sqlauthority.com/2008/10/02/sql-server-2008-cheat-sheet-one-page-pdf-download/): Very frequently I have been asked to create a page, post or article where in one page all the important concepts of SQL Server are covered. SQL Server 2008 is very large subject and can not be even covered 1000 of pages. In daily life of DBA there are few commands very frequently used and for novice developers it is good to keep all the important SQL Script and SQL Statements handy. I have attempted to create cheat sheet for SQL Server 2008 most important commands. User can print this in one A4 size page and keep along with them. This can be used in interviews where T-SQL scripts are being asked. - [SQL SERVER - Example of PIVOT UNPIVOT Cross Tab Query in Different SQL Server Versions](https://blog.sqlauthority.com/2008/10/01/sql-server-example-of-pivot-unpivot-cross-tab-query-in-different-sql-server-versions/): Transforming rows to columns (PIVOT/CROSS TAB) and columns to rows (UNPIVOT) may be one of the common requirements that all of us must have seen several times in our programming life. SQL Server 2005 introduced two new operators: PIVOT and UNPIVOT that made writing cross-tab queries easier. My friend and SQL Server MVP Jacob Sebastian has posted an example that transform rows to columns using PIVOT operator. The reverse operation of PIVOT is UNPIVOT. PIVOT operator is available only in SQL Server 2005/2008. It does not exists in SQL Server 2000. Developers who are still using SQL Server 2000 should upgrade... - [SQLAuthority News - Security Update for SQL Server 2005 Service Pack 2](https://blog.sqlauthority.com/2008/09/30/sqlauthority-news-security-update-for-sql-server-2005-service-pack-2/): Developers who are using SQL Server Service Pack 2 must install this security patch for it. A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. You can help protect your computer by installing this update from Microsoft. After you install this item, you may have to restart your computer. Download Security Patch for SQL Server Service Pack 2 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Puzzle - Solution - Computed Columns Datatype Explanation](https://blog.sqlauthority.com/2008/09/29/sql-server-puzzle-solution-computed-columns-datatype-explanation/): Just a day before I wrote article SQL SERVER – Puzzle – Computed Columns Datatype Explanation which was inspired by SQL Server MVP Jacob Sebastian. I suggest that before continuing this article read original puzzle question SQL SERVER – Puzzle – Computed Columns Datatype Explanation. The question was if computed column was of datatype TINYINT how to create Computed Column of datatype INT? Before we continue with the answer let us run following script and understand how computed column is created. USE AdventureWorks GO CREATE TABLE MyTable ( ID TINYINT NOT NULL IDENTITY (1, 1), FirstCol TINYINT NOT NULL, SecondCol TINYINT NOT NULL, ThirdCol TINYINT NOT NULL, ComputedCol AS (FirstCol+SecondCol)*ThirdCol... - [SQL SERVER - Renaming SP is Not Good Idea - Renaming Stored Procedure Does Not Update sys.procedures](https://blog.sqlauthority.com/2008/09/28/sql-server-renaming-stored-procedure-does-not-update-sysprocedures/): I have written many articles about renaming a table, columns, and procedures SQL SERVER - How to Rename a Column Name or Table Name, here I found something interesting about renaming the stored procedures and felt like sharing it with you all. Let us learn about how renaming stored procedure does not update sys.procedures. - [SQL SERVER - Puzzle - Computed Columns Datatype Explanation](https://blog.sqlauthority.com/2008/09/27/sql-server-puzzle-computed-columns-datatype-explanation/): Yesterday I wrote post about SQL SERVER – Get Answer in Float When Dividing of Two Integer. I received excellent comment from SQL Server MVP Jacob Sebastian. Jacob has clarified the concept which I was trying to convey. He is famous for his “behind the scene insight“. When I read his comment, I realize another interesting concept which is related to same idea which is being discussed in this post. Let us read what Jacob says first. Jacob Sebastian: Nice post and something that is very much useful in the day-to-day programming life. Just wanted to add to what is already... - [SQL SERVER - Get Answer in Float When Dividing of Two Integer](https://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/): Many times we have requirements of some calculations amongst different fields in Tables. One of the software developers here was trying to calculate some fields having integer values and divide it which gave incorrect results in integer where accurate results including decimals was expected. Something as follows, Example, USE [AdventureWorks] GO CREATE TABLE [dbo].ConvertExample( [ID] [int] NULL, [Field1] [int] NULL, [Field2] [int] NULL, [Field3] [int] NULL, [Field4] [int] NULL ) GO INSERT INTO [dbo].ConvertExample VALUES (1,30,40,60,80) GO INSERT INTO [dbo].ConvertExample VALUES (2,20,10,50,80) GO INSERT INTO [dbo].ConvertExample VALUES (3,15,140,90,60) GO INSERT INTO [dbo].ConvertExample VALUES (1,60,0,5,2) GO SELECT * FROM [dbo].ConvertExample GO SELECT... - [SQL SERVER - Guidelines and Coding Standards Complete List Download](https://blog.sqlauthority.com/2008/09/25/sql-server-guidelines-and-coding-standards/): Coding standards and guidelines are very important for any developer on the path to a successful career. A coding standard is a set of guidelines, rules and regulations on how to write code. Coding standards should be flexible enough or should take care of the situation where they should not prevent best practices for coding. They are basically the guidelines that one should follow for better understanding. - [SQL SERVER - Guidelines and Coding Standards Part - 2](https://blog.sqlauthority.com/2008/09/24/sql-server-coding-standards-guidelines-part-2/): To express apostrophe within a string, nest single quotes (two single quotes). Example: SET @sExample = 'SQL''s Authority' When working with branch conditions or complicated expressions, use parenthesis to increase readability. IF ((SELECT 1 FROM TableName WHERE 1=2) ISNULL) To mark a single line as comment use (–) before the statement. To mark a section of code as comment use (/*…*/). If there is no need for resultset then use syntax that doesn’t return a resultset. IF EXISTS   (SELECT 1 FROM UserDetails WHERE UserID = 50) Rather than, IF EXISTS  (SELECT COUNT (UserID) FROM UserDetails WHERE UserID = 50) Use a graphical execution plan... - [SQL SERVER - Guidelines and Coding Standards Part - 1](https://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/): Use “Pascal” notation for SQL server Objects Like Tables, Views, Stored Procedures. Also tables and views should have ending “s”. Example: UserDetails Emails If you have big subset of table group than it makes sense to give prefix for this table group. Prefix should be separated by _. Example: Page_ UserDetails Page_ Emails Use following naming convention for Stored Procedure. sp<Application Name>_[<group name >_]<action type><table name or logical instance> Where action is: Get, Delete, Update, Write, Archive, Insert… i.e. verb Example: spApplicationName_GetUserDetails spApplicationName_UpdateEmails Use following Naming pattern for triggers: TR_<TableName>_<action><description> Example: TR_Emails_LogEmailChanges TR_UserDetails_UpdateUserName Indexes : IX_<tablename>_<columns separated by_> Example: IX_UserDetails_UserID Primary... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - September 2008](https://blog.sqlauthority.com/2008/09/22/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-september-2008/): On September 20, 2008 was one of the best day so far for Ahmedabad SQL Server User Group Meeting. We had two very interesting sessions by two SQL Server MVPs. SQL Server MVP Jacob Sebastian had began the meeting with very interesting introduction note. Along with many news Usergroup President Jacob Sebastian announced that SQL Server 2008 RTM (Release to Manufactor) is out. Jacob explained that difference between CTP ( Community Technology Preview) and RTM. RTM means MS SQL Server developer team has signed off on final version of product. Currently, SQL Server 2008 is available to MSDN Subscribers, TechNet Subscribers,... - [SQL SERVER - 2008 - Fix Connection Error with Visual Studio 2008 - Server Version is not supported](https://blog.sqlauthority.com/2008/09/21/sql-server-2008-fix-connection-error-with-visual-studio-2008-server-version-is-not-supported/): While attending conference SQLAuthority Author Visit – Microsoft Student Partner Conference, some developers informed me that SQL SERVER 2008 cannot be connected to Visual Studio 2008 and error displays as MS does not support SQL Server version. I was surprised initially as I could not believe that two MS products are not compatible. When trying myself I got the same error. SQL Server 2008 when connected to Visual Studio 2008 gives the error that “This server version is not supported.  Only servers up to Microsoft SQL Server 2005 are supported“. This error can be easily resolved by just installing Service pack. Download... - [SQLAuthority Author Visit - Ahmedabad User Group Meeting September 2008](https://blog.sqlauthority.com/2008/09/20/sqlauthority-author-visit-ahmedabad-user-group-meeting-september-2008/): Today is third Saturday of the Month and every third Saturday we have Ahmedabad User Group Meeting. Our user group is growing and getting interesting. Everybody who attended last months User Group (UG) Meeting realized that how important it is to attend UG meetings. UG President Jacob Sebastian (SQL Server – MVP) presented excellent session on “Transaction Isolation Levels and Locks in SQL Server”.I personally enjoyed the session very much. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my... - [Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/): The interview is a very important event for any person. A good interview questions leads to good career if the candidate is willing to learn. - [SQL SERVER - 2008 - Interview Questions and Answers - Part 8](https://blog.sqlauthority.com/2008/09/19/sql-server-2008-interview-questions-and-answers-part-8/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download What is Data Compression? In SQL SERVE 2008 Data Compression comes in two flavors: Row Compression Page Compression Row Compression Row compression changes the format of physical storage of data. It minimize the metadata (column information, length, offsets etc) associated with each record. Numeric data types and fixed length strings are stored in variable-length storage format, just like Varchar.  (Read More Here) Page Compression Page compression allows common data to be shared between rows for a given page. Its... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 7](https://blog.sqlauthority.com/2008/09/18/sql-server-2008-interview-questions-and-answers-part-7/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download How can we rewrite sub-queries into simple select statements or with joins? Yes we can write using Common Table Expression (CTE). A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. E.g. USE AdventureWorks... - [SQL SERVER - Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2008/09/17/sql-server-2008-interview-questions-and-answers-part-6/): Interview Questions and Answers - [SQL SERVER - 2008 - Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2008/09/16/sql-server-2008-interview-questions-and-answers-part-5/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download What command do we use to rename a db, a table and a column? To rename db sp_renamedb 'oldname' , 'newname' If someone is using db it will not accept sp_renmaedb. In that case first bring db to single user using sp_dboptions. Use sp_renamedb to rename database. Use sp_dboptions to bring database to multi user mode. E.g. USE master; GO EXEC sp_dboption AdventureWorks, 'Single User', True GO EXEC sp_renamedb 'AdventureWorks', 'AdventureWorks_New' GO EXEC sp_dboption AdventureWorks, 'Single User', False GO... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2008/09/15/sql-server-2008-interview-questions-and-answers-part-4/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER Which command using Query Analyzer will give you the version of SQL server and operating system? SELECT SERVERPROPERTY ('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') What is SQL Server Agent? SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose is to ease the implementation of tasks for the DBA, with its full-function... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2008/09/14/sql-server-2008-interview-questions-and-answers-part-3/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER 2) Common Questions Asked Which TCP/IP port does SQL Server run on? How can it be changed? SQL Server runs on port 1433. It can be changed from the Network Utility TCP/IP properties -> Port number, both on client and the server. What are the difference between clustered and a non-clustered index? (Read More Here) A clustered index is a special type of index that reorders the way records in the table are... - [SQL SERVER - Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2008/09/13/sql-server-2008-interview-questions-and-answers-part-2/): This is the second part of the blog post series Interview Questions and Answers.Click here to get free chapters (PDF) in the mailbox - [SQL SERVER - 2008 - Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2008/09/12/sql-server-2008-interview-questions-and-answers-part-1/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER What is RDBMS? Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the... - [SQLAuthority News - 700 Articles and Author Updates](https://blog.sqlauthority.com/2008/09/11/sqlauthority-news-700-articles-and-author-updates/): It is always interested to write article when reached at milestone. I start to receive many emails and suggestions just about when this blog is reaching any milestone. One question keep on coming to me is why do I write or what is in it for me? Satisfaction! I enjoy writing and helping community and by writing blog that is what I get. Lots of things have happened since last milestone of 600th article. 1) Microsoft presented most prestigious Microsoft SQL Server MVP Award. This award is given to Exceptional Technical Community Leader. 2) I am vice president of SQL Server... - [SQLAuthority News - SharePoint - Steps To Create A Custom WebPart - Deploy It SharePoint Site](https://blog.sqlauthority.com/2008/09/10/steps-to-create-a-custom-webpart-and-deploy-it-in-sharepoint-site/): SharePoint is one interesting software from Microsoft. My outsourcing location unit is working on one large project of SharePoint. Based on users feedback and overwhelming response to article SQL Server – Error : Fix : SharePoint Stop Working After Changing Server (Computer) Name I am posting one more article which is very important for SharePoint developers. SharePoint does not allow custom coding for any of the webpart. It is possible to create webpart in Visual Studio and integrate it with SharePoint. The process to create webpart in .NET framework and make it working in SharePoint often fails due to lack of... - [SQL Server - Error : Fix : SharePoint Stop Working After Changing Server (Computer) Name](https://blog.sqlauthority.com/2008/09/09/sql-server-error-fix-sharepoint-stop-working-after-changing-server-computer-name/): If Microsoft Office SharePoint Server (MOSS) and your database (MS SQL Server) are running together on same physical server, changing the name of the server (computer) using operating system may create non-functional SharePoint website. When you change the physical server name the SharePoint is already connected to the SQL instance of old computer name (OldServerName/SQLInstance) and on changing the name the SharePoint will not able to connect the SQL Server  as now the SQL Server instance will run on new computer name (NewServerName/SQLInstance). To solve this problem you need to reconfigure the entire Microsoft Office SharePoint Server with SQL Server Instance.... - [SQL SERVER - 2008 - Creating Primary Key, Foreign Key and Default Constraint](https://blog.sqlauthority.com/2008/09/08/sql-server-2008-creating-primary-key-foreign-key-and-default-constraint/): Primary key, Foreign Key and Default constraint are the 3 main constraints that need to be considered while creating tables or even after that. It seems very easy to apply these constraints but still we have some confusions and problems while implementing it. So I tried to write about these constraints that can be created or added at different levels and in different ways or methods. Primary Key Constraint: Primary Keys constraints prevents duplicate values for columns and provides unique identifier to each column, as well it creates clustered index on the columns. 1)      Create Table Statement  to create Primary Key... - [SQL SERVER - Explanation about Usage of Unique Index and Unique Constraint](https://blog.sqlauthority.com/2008/09/07/sql-server-explanation-about-usage-of-unique-index-and-unique-constraint/): I enjoy reading questions from blog readers and answering them. One of the another SQL enthusiastic is Imran who also regularly answer questions of users on this community blog. Recently he has answered in detail about when to use Unique Index and when to use Unique Constraint. Cristiano asked following questions : i need to know how work when there is a situation that there is a Unique Key and this field “alow null”, but when i am going to create a Unique Key the SQLSERVER saw that there were values duplicated and the values are “nulls”. How do i sove... - [SQL SERVER - Find Primary Key Using SQL Server Management Studio](https://blog.sqlauthority.com/2008/09/06/sql-server-find-primary-key-using-sql-server-management-studio/): Imran Mohammed is great SQL Expert and always eager to help community members. He enjoys answering question and solving problems of other community fellows. His answers are always detailed and trustworthy. Today we will see interesting question from Prasant and excellent answer from Imran Mohammed. Question from Prasant: Hi, I want to drop the primary key on one table but i cannot know which constraint is there. Is there a way to drop the primary key without specifying constraint. The basic idea of doing this is : I have one table with 4 columns e.g. 1. SrNo 2. NodeID 3. EnrollmentNo... - [SQL SERVER - 2008 - Creating Full Text Catalog and Full Text Search](https://blog.sqlauthority.com/2008/09/05/sql-server-creating-full-text-catalog-and-index/): Full Text Index helps to perform complex queries against character data. These queries can include words or phrase searching. We can create a full-text index on a table or indexed view in a database. Only one full-text index is allowed per table or indexed view. The index can contain up to 1024 columns. Software developer Monica Monica, who helped with screenshots also informed that this feature works with the RTM (Ready to Manufacture) version of SQL Server 2008 and does not work on CTP (Community Technology Preview) versions. Let us learn about Creating Full Text Catalog and Full Text Search in this blog post. - [SQLAuthority News - Download SQL Server Related Products](https://blog.sqlauthority.com/2008/09/05/sqlauthority-news-download-sql-server-related-products/): Configuration Manager 2007 R2 Evaluation Configuration Manager R2 now also supports Windows Vista SP1 and Windows Server 2008, integrates support for application virtualization, and provides an update to operating system deployment capability initially shipped in Configuration Manager. In addition, Client Status Reporting, SQL Reporting, and Forefront Client reporting are all now available. System Center Operations Manager 2007 SP1 Documentation This download contains documentation for System Center Operations Manager 2007 SP1. Microsoft® Visual Studio Team System 2008 Database Edition GDR August CTP Microsoft® Visual Studio Team System 2008 Database Edition GDR implements support for SQL Server 2008. Abstract courtesy : Microsoft Reference... - [SQLAuthirty Author Visit - SQL SERVER - User Group Meeting - Ahmedabad - August 30, 2008](https://blog.sqlauthority.com/2008/09/04/sqlauthirty-author-visit-sql-server-user-group-meeting-ahmedabad-august-30-2008/): I always enjoy participating in SQL Server User Group. We had recent meeting of Ahmedabad User Group on August 30. We had many things discussed in meeting. I enjoyed meeting fellows from different company who visited user group. The major discussion we had was quality of programmers and quality of work done by programmers. We all felt that looking at current market everybody is rushing for IT jobs. Finding right job is difficult and finding right candidate for job is even more difficult. User groups are the place for good developers to show up for good networking with industry leads and... - [SQLAuthority Author Visit - Microsoft Student Partner Conference](https://blog.sqlauthority.com/2008/09/03/sqlauthority-author-visit-microsoft-student-partner-conference/): The Microsoft Student Partner Program is a worldwide initiative to sponsor students who are interested in technology. The program mainly focuses on improving students skills for enjoyability, called Microsoft Student Partners (MSP). I was recently (August 30, 2008) invited to present technical session at conference held in my City. I really enjoyed presenting the session with very enthusiastic students. I see all the students as future strong members of developer community and Microsoft is doing great job encouraging them and giving them global platform. The program allows selected students to work along with professionals from Microsoft and to be a student... - [SQL SERVER - 2008 - Hardware and Software Requirements for Installing SQL Server 2008](https://blog.sqlauthority.com/2008/09/02/sql-server-hardware-and-software-requirements-for-installing-sql-server-2008/): The following sections list the minimum hardware and software requirements to install and run SQL Server 2008. The following requirements apply to all SQL Server 2008 installations: 1.Framework SQL Server Setup installs the following software components required by the product: – NET Framework 3.5 – SQL Server Native Client – SQL Server Setup support files 2. Software SQL Server Setup requires Microsoft Windows Installer 4.5 or a later version, and Microsoft Data Access Components (MDAC) 2.8 SP1 or a later version. You can download MDAC 2.8 SP1 from the MDAC downloads Web site. 3. Internet Software Microsoft Internet Explorer 6 SP1... - [SQL SERVER - Introduction to Filtered Index - Improve performance with Filtered Index](https://blog.sqlauthority.com/2008/09/01/sql-server-2008-introduction-to-filtered-index-improve-performance-with-filtered-index/): Filtered Index is a new feature in SQL SERVER 2008. Filtered Index is used to index a portion of rows in a table that means it applies filter on INDEX which improves query performance, reduce index maintenance costs, and reduce index storage costs compared with full-table indexes. - [SQL SERVER - 2008 - Introduction to Table-Valued Parameters with Example](https://blog.sqlauthority.com/2008/08/31/sql-server-table-valued-parameters-in-sql-server-2008/): Table-Valued Parameters is a new feature introduced in SQL SERVER 2008. In earlier versions of SQL SERVER it is not possible to pass a table variable in stored procedure as a parameter, but now in SQL SERVER 2008 we can use Table-Valued Parameter to send multiple rows of data to a stored procedure or a function without creating a temporary table or passing so many parameters. Table-valued parameters are declared using user-defined table types. To use a Table Valued Parameters we need follow steps shown below: Create a table type and define the table structure Declare a stored procedure that has... - [SQL SERVER - FIX : ERROR : Could Not Connect to SQL Server - TDSSNIClient initialization failed with error 0x7e, status code 0x60](https://blog.sqlauthority.com/2008/08/30/sql-server-fix-error-could-not-connect-to-sql-server-tdssniclient-initialization-failed-with-error-0x7e-status-code-0x60/): This is a very common error faced by so many people and I get lots of questions regarding this error. This error occurs due to many reasons and I have already posted few solutions on this error, see if you can find your solution here SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server SQL SERVER – Fix : Error : 1326 Cannot connect to Database Server Error: 40 – Could not open a connection to SQL Server or Recently when I was trying to create new user and connect to SQL SERVER... - [SQL SERVER - Few Useful DateTime Functions to Find Specific Dates](https://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/): Recently I have recieved email from Vivek Jamwal, which contains many useful SQL Server Date functions. ----Today SELECT GETDATE() 'Today' ----Yesterday SELECT DATEADD(d,-1,GETDATE()) 'Yesterday' ----First Day of Current Week SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) 'First Day of Current Week' ----Last Day of Current Week SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) 'Last Day of Current Week' ----First Day of Last Week SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0) 'First Day of Last Week' ----Last Day of Last Week SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6) 'Last Day of Last Week' ----First Day of Current Month SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) 'First Day of Current Month' ----Last Day of Current Month SELECT DATEADD(ms,- 3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0))) 'Last Day of Current Month' ----First Day of Last Month SELECT DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)) 'First Day of Last Month' ----Last Day of Last Month SELECT DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))) 'Last Day of Last Month' ----First Day of Current Year SELECT DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0) 'First Day of Current Year' ----Last Day of Current Year SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE())+1,0))) 'Last Day of Current Year' ----First Day of Last Year SELECT DATEADD(yy,-1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)) 'First Day of Last Year' ----Last Day of Last Year SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0))) 'Last Day of Last Year' ResultSet: Today ———————– 2008-08-29 21:54:58.967 Yesterday ———————– 2008-08-28 21:54:58.967 First Day of Current Week ————————- 2008-08-25 00:00:00.000 Last Day of Current Week ———————— 2008-08-31 00:00:00.000 First Day of... - [SQL SERVER - 2008 - Introduction to Merge Statement - One Statement for INSERT, UPDATE, DELETE](https://blog.sqlauthority.com/2008/08/28/sql-server-2008-introduction-to-merge-statement-one-statement-for-insert-update-delete/): MERGE is a new feature that provides an efficient way to perform multiple DML operations. In previous versions of SQL Server, we had to write separate statements to INSERT, UPDATE, or DELETE data based on certain conditions, but now, using MERGE statement we can include the logic of such data modifications in one statement that even checks when the data is matched then just update it and when unmatched then insert it. - [SQLAuthority News - Microsoft SQL Server 2008 R2 Report Builder 3.0](https://blog.sqlauthority.com/2008/08/27/sqlauthority-news-download-sql-server-2008-report-builder-20-rc1/): Microsoft SQL Server 2008 Reporting Services Report Builder 2.0 supports the full capabilities of SQL Server 2008 Reporting Services including flexible report layout, data visualizations and richly formatted text. The download includes the following functionality above the RC0 release of Report Builder: - [SQLAuthority News - SQL Server Express 2008 Downloads](https://blog.sqlauthority.com/2008/08/27/sqlauthority-news-sql-server-express-2008-downloads/): Microsoft SQL Server 2008 Express with Tools Microsoft SQL Server 2008 Express with Tools (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes graphical management tools. SQL Server 2008 Express provides powerful and reliable data management tools and rich features, data protection, and fast performance. It is ideal for small server applications and local data stores. Download Microsoft SQL Server 2008 Express with Tools Microsoft SQL Server 2008 Express with Advanced Services Microsoft SQL Server 2008 Express with Advanced Services (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes... - [SQL SERVER - How to Rename a Column Name or Table Name](https://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/): I often get requests from blog reader for T-SQL script to rename database table column name or rename table itself. Here is a video demonstrating the discussion [youtube=http://www.youtube.com/watch?v=5xviNDISwis] The script for renaming any column : sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN' The script for renaming any object (table, sp etc) : sp_RENAME '[OldTableName]' , '[NewTableName]' This article demonstrates two examples of renaming database object. Renaming database table column to new name. Renaming database table to new name. In both the cases we will first see existing table. Rename the object. Test object again with new name. 1. Renaming database table column to... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting - August 2008](https://blog.sqlauthority.com/2008/08/25/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-august-2008/): I will be attending Ahmedabad SQL Server Usergroup Meeting on August 30, 2008. I will be taking session about “SQL Server CTE and Recursive CTE“. The most important part of August Meeting is there will be presentation on “Transaction Isolation Levels and Locks in SQL Server” from user group President Jacob Sebastian. I invite all of the SQL enthusiastic to stop by User Group Meeting and meet all the fellow developers, DBAs and members. Location : 401, TIME SQUARE, CG road, Op Bazar Calcutta, Ahmedabad, India Date and Time : August 30, 2008 6:30 PM onwards Hope to see all of... - [SQLAuthority News - 4 Million Visits - over 675 SQL Server Articles](https://blog.sqlauthority.com/2008/08/25/sqlauthority-news-4-million-visits-over-675-sql-server-articles/): Thank you to all of my readers for supporting this blog. It has been wonderful journey all the way. I strongly encourage all my readers to actively contribute in discussion and writing article for blog. Today this blog has completed 4 Million visits and there are over 675 articles published on this blog. I have been awarded SQL MVP award from Microsoft during course of this “Journey of SQL Server”. I would like to thank Microsoft and all of my readers for their continuous support. If you have good idea about any SQL Server article please let me know and I... - [SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server - Fix Connection Problems of SQL Server](https://blog.sqlauthority.com/2008/08/24/sql-server-fix-error-40-could-not-open-a-connection-to-sql-server-fix-connection-problems-of-sql-server/): Everyday I get lots of question regarding error : An error has occurred while establishing a connection to the server when connecting to SQL server 2005, this failure may be caused by the fact that under default settings SQL server does not allow remote connection. ( provider: Named Pipes Provider, error: 40 – could not open a connection to SQL server. ) This error happens due to many reasons. There are few solutions already given on my original threads.I encourage to read following two articles first and see if you can find your solution. If you can not find any solution... - [SQL SERVER - 2008 - Configure Database Mail - Send Email From SQL Database](https://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/): Today in this article I would discuss about the Database Mail which is used to send the Email using SQL Server.  Previously I had discussed about SQL SERVER – Difference Between Database Mail and SQLMail. Database mail is the replacement of the SQLMail with many enhancements. So one should stop using the SQL Mail and upgrade to the Database Mail. Special thanks to Software Developer Monica, who helped with all the images and extensive testing of subject matter of this article. Here is the video of the same subject: [youtube=http://www.youtube.com/watch?v=ZGDBB2uwNp8] In order to send mail using Database Mail in SQL Server, there... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case - Part 2](https://blog.sqlauthority.com/2008/08/22/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case-part-2/): I had previously written SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case and I had really enjoyed writing it. Above script converts first letter of each word from sentence to upper case. For example this function will convert this string to title case! will be converted to This Function Will Convert This String To Title Case! However if you just want to convert first word of complete sentence you can use following quick script. USE AdventureWorks GO DECLARE @varString VARCHAR(100) SET @varString = 'this function will convert this string to title case!' SELECT... - [SQL SERVER - Behind the Scene of SQL Server Activity of - Transaction Log - Shrinking Log](https://blog.sqlauthority.com/2008/08/21/sql-server-behind-the-scene-of-sql-server-activity-of-transaction-log-shrinking-log/): Imran Mohammed continues to help community of SQL Server with his very enthusiastic writing and deep understanding of SQL Server architecture. Let us read what Imran has to say about how Transaction Log works and Shrinking of Log works. Question from lauraV Please help me understand. I am taking a full backup once a day, and transaction logs once every hour. Why is my LDF file not retaining a “normal” size? It continues to grow. I do not want to break the chain and use truncate only, though I have done this and it fixes the problem. I would very much... - [SQLAuthority News - Microsoft SQL Server Management Pack for Microsoft Operations Manager 2005](https://blog.sqlauthority.com/2008/08/21/sqlauthority-news-microsoft-sql-server-management-pack-for-microsoft-operations-manager-2005/): Note:  Download Microsoft Operations Manager 2005 by Microsoft The Microsoft SQL Server Management Pack provides both proactive and reactive monitoring of SQL Server 2008, 2005 and SQL Server 2000 in an enterprise environment. Availability and configuration monitoring, performance data collection, and default thresholds are built for enterprise-level monitoring. Both local and remote connectivity checks help ensure database availability. With the embedded expertise in the SQL Server Management Pack, you can proactively manage SQL Server, and identify issues before they become critical. This Management Pack increases the security, availability, and performance of your SQL Server infrastructure. The Microsoft SQL Server Management Pack... - [SQLAuthority News - Find Your IP Address - What Is My IP Address](https://blog.sqlauthority.com/2008/08/20/sqlauthority-news-find-your-ip-address-what-is-my-ip-address/): While developing often my developers need to know which IP address is of local network when looked from outside. I am working in large outsourcing company and we have local intranet setup. When connecting to remote servers from local system or from remote servers to local system we always want to know our Live IP address. Previously we have used many different methods to know our Live IP but nothing is reliable. External services often go down or provide incorrect information. I have added new feature to my site where any user can visit the page and find out their outgoing... - [SQL SERVER - Disable All the Trigger of Current Database](https://blog.sqlauthority.com/2008/08/19/sql-server-disable-all-the-trigger-of-current-database/): I have previously written article about SQL SERVER – Disable All Triggers on a Database – Disable All Triggers on All Servers. This is alternate method to achieve the same task. Following article is sent by Manish Kaushik. I recommend all of you to read original article along with this article for complete idea. CREATE PROCEDURE [dbo].[DisableAllTriggers] AS DECLARE @string VARCHAR(8000) DECLARE @tableName NVARCHAR(500) DECLARE cur CURSOR FOR SELECT name AS tbname FROM sysobjects WHERE id IN(SELECT parent_obj FROM sysobjects WHERE xtype='tr') OPEN cur FETCH next FROM cur INTO @tableName WHILE @@fetch_status = 0 BEGIN SET @string ='Alter table '+ @tableName + ' Disable trigger all' EXEC (@string)... - [SQL SERVER - Detailed Explanation of Transaction Lock, Lock Type, Avoid Locks](https://blog.sqlauthority.com/2008/08/18/sql-server-detailed-explanation-of-transaction-lock-lock-type-avoid-locks/): Loyal reader of this blog and “Great SQL Expert” Imran Mohammed always have good attitude towards any problem. Many times his answers very interesting to read and details are very accurate. I came across his two interesting comment on this blog and I would like to share this all of you. Priyank asked following question. Can u tell us something about how to find which sql table is having the lock and of what type. also please tell us how to remove a lock from a locked table thanks Priyank Imran Mohammed answered in great depth to this question. I personally... - [SQL SERVER - 2005 - Best Practices Analyzer (August 2008)](https://blog.sqlauthority.com/2008/08/17/sql-server-2005-best-practices-analyzer-august-2008/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. This download is the August 2008 release of SQL Server 2005 Best Practices Analyzer. Download Best Practices Analyzer Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - XML - Split a Delimited String - Generate a Delimited String](https://blog.sqlauthority.com/2008/08/17/sql-server-xml-split-a-delimited-string-generate-a-delimited-string/): SQL Server MVP and my very good friend Jacob Sebastian has written two wonderful articles about SQL Server and XML. I encourage to read this two articles to anybody who are interested in learning SQL and XML. Let us see how to Split a Delimited String. - [SQLAuthority News - Tip of the Minute](https://blog.sqlauthority.com/2008/08/16/sqlauthority-news-tip-of-the-minute/): Since my new personal website is launched I have received many comments and emails regarding new section of Tip of the Minute. Right navigation bar of the my personal website https://www.pinaldave.com/ contains section of the Tip of the Minute. Every time when page is refreshed it displays one new tip related to SQL Server. Few of the tips from the page I am listing here. Avoid unnecessary use of temporary tables. Try to use constraints instead of triggers, rules, and defaults whenever possible. SQL Server agent, allows you to schedule your own jobs and scripts. If any reader who will send... - [SQLAuthority News - Happy Indepedance Day to India](https://blog.sqlauthority.com/2008/08/15/sqlauthority-news-happy-indepedance-day-to-india/): India’s Independence Day is celebrated on August 15 to commemorate its independence on that day in 1947. The day is a national holiday in India. India will celebrate its 61st Independent day on August 15, 2008. Happy Independence Day to India Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Introduction to Online Indexing Operation](https://blog.sqlauthority.com/2008/08/15/sql-server-2008-introduction-to-online-indexing-operation/): When index is created or recreated it usually decreases performance of database. Either SQL takes long time for response or it does not response at all as transactions are blocked. When new table or database goes live it is not possible to find out exactly how many indexes are needed. After running queries on near to production data it is possible to find out which index can perform better. It is important in highly sensitive application to have data always available. SQL Server 2005 and later versions have provided feature called “Online Indexing”. Everytime index is updated it puts lock on... - [SQL SERVER - Get Date Time in Any Format - UDF - User Defined Functions](https://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/): One of the reader Nanda of SQLAuthority.com has posted very detailed script of converting any date time in desired format. I suggest every reader of this blog to save this script in your permanent code bookmark and use it when you need it. Let us learn about User Defined Functions. - [SQLAuthority News - Authors Personal Website Renovate - SQL Centric Website](https://blog.sqlauthority.com/2008/08/13/sqlauthority-news-authors-personal-website-renovate-sql-centric-website/): I am very pleased to announce my newly renovated website. I always liked my previous website as it was “Valid XHTML 1.1” and “Valid CSS 2.0”. Since I become MVP last month I have been receiving many emails where people were expecting more from my personal website. My blog http://www.SQLAuthority.com and my personal website https://www.pinaldave.com/ both are my heavily visited website but there was something missing when connecting them together. New website which went live today has all the missing elements to connect both my blog and website together. New website is also “Valid XHTML 1.1” and “Valid CSS 2.0”. One... - [SQLAuthority News - SQL Server 2008 Pricing and Licensing](https://blog.sqlauthority.com/2008/08/12/sqlauthority-news-sql-server-2008-pricing-and-licensing/): Note: SQL Server 2008 Pricing and Licensing by Microsoft SQL Server licensing and pricing are to intervined subjects and very important. I strongly suggest to use properly licensed SQL Server in any production environment. The concept of licensing can be confusing sometime to new administrators. If there is any confusion one should read following documentation from Microsoft for the purpose of clear idea and understanding. SQL Server 2008 is available under three licensing models: Server plus device client access license (CAL). Requires a license for the computer running the Microsoft server product, as well as CALs for each client device. Server... - [SQLAuthority News - Microsoft SQL Server 2008 Books Online - BOL - English](https://blog.sqlauthority.com/2008/08/12/sqlauthority-news-microsoft-sql-server-2008-books-online-bol-english/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. The Help viewer used by Books Online requires the Microsoft .NET Framework version 2.0. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and... - [SQLAuthority News - SQL Server 2008 Downloads Availables](https://blog.sqlauthority.com/2008/08/11/sqlauthority-news-sql-server-2008-downloads-availables/): SQL Server Compact 3.5 SP1 for Windows Mobile SQL Server Compact 3.5 SP1 for devices Windows Installer (MSI) file contains the CAB files and the DLLs for installing SQL Server Compact 3.5 SP1 on the Windows mobile devices. SQL Server Compact 3.5 SP1 and Synchronization Services for ADO.NET v1.0 SP1 for Windows Desktop SQL Server Compact 3.5 SP1 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP1 and Synchronization Services for ADO.NET version 1.0 SP1 on Windows desktop. SQL Server Compact... - [SQL SERVER - Download and Install Sample Database AdventureWorks 2005 - Detail Tutorial](https://blog.sqlauthority.com/2008/08/10/sql-server-2008-download-and-install-samples-database-adventureworks-2005-detail-tutorial/): Just a day ago I received a question from a reader who just installed SQL Server 2008. After the installation user did not find any sample database along with installation. The user wants to install the sample database which he is very much used to. Let us learn about Sample Database AdventureWorks. - [SQLAuthority News - Microsoft SQL Server Compact 3.5 Server Tools Beta 2 Released](https://blog.sqlauthority.com/2007/08/03/sqlauthority-news-microsoft-sql-server-compact-35-server-tools-beta-2-released/): SQL Server Compact 3.5 Server Tools installs replication components on the IIS server enabling merge replication and remote data access (RDA) between SQL Server Compact 3.5 database on a Windows Desktop & Mobile devices and database servers running SQL Server 2005 and later versions of SQL Server 2005. Download SQL Server Compact 3.5 For more information please see the SQL Server Compact 3.5 Books Online Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Two Different Ways to Comment Code - Explanation and Example](https://blog.sqlauthority.com/2007/08/03/sql-server-two-different-ways-to-comment-code-explanation-and-example/): SQL Server has two different ways to comment code. Let us learn all of them here in this blog post. Various the options in the blog posts. - [SQLAuthority News - Book Review - SQL Server 2005 Practical Troubleshooting: The Database Engine](https://blog.sqlauthority.com/2007/08/02/sqlauthority-news-book-review-sql-server-2005-practical-troubleshooting-the-database-engine/): SQLAuthority.com Book Review : SQL Server 2005 Practical Troubleshooting: The Database Engine (SQL Server Series) (Paperback) by Ken Henderson Link to book on Amazon Short Review : Database Administrators can use this book on a daily basis in SQL Server 2005 troubleshooting and problem solving. Answers to SQL issues can be swiftly located using the index of this book.This book covers the topics and subjects which any other books, blogs or websites (including MSDN, BOL) do not cover. This book provides DBAs with solutions which can be used by user in highly dynamic environments to resolve common and specialized problems. This... - [SQL SERVER - FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details](https://blog.sqlauthority.com/2007/08/02/sql-server-fix-error-945-database-cannot-be-opened-due-to-inaccessible-files-or-insufficient-memory-or-disk-space-see-the-sql-server-error-log-for-details/): SQL SERVER – FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details This error is very common and many times, I have seen affect of this error as Suspected Database, Database Operation Ceased, Database Stopped transactions. Solution to this error is simple but very important. Fix/Solution/WorkAround: 1) If possible add more hard drive space either by removing of unnecessary files from hard drive or add new hard drive with larger size. 2) Check if the database is set to Autogrow on. 3) Check if... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Search SQL](https://blog.sqlauthority.com/2007/08/01/sql-server-sql-joke-sql-humor-sql-laugh-search-sql/): In meeting with DBA friends one of my friend suggested while searching for “MSSQL Client” Microsoft returns you suggestion as “MySQL Client“. I did not believe it so I tested it myself. He was correct. Here is the screen shot. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - July CTP Released](https://blog.sqlauthority.com/2007/08/01/sql-server-2008-july-ctp-released/): SQL Server 2008 July Community Technology Preview has been released. With SQL Server 2008 July CTP release, customers can immediately utilize new capabilities that support their mission-critical platform and enable pervasive insight across the enterprise. SQL Server 2008 lays the groundwork for innovative policy-based management that enables administrators to reduce their time spent on maintenance tasks. SQL Server 2008 provides enhancements in the SQL Server BI platform by enabling customers to provide up-to-date information with Change Data Capture and MERGE features, and develop highly scalable analysis services cubes with new development environments. - [SQLAuthority News - My Favorite Articles of This Blog](https://blog.sqlauthority.com/2007/07/31/sqlauthority-news-my-favorite-articles-of-this-blog/): The question I receive very often is I have more than 250 articles so far on this blog, which are my most favorite articles so far? Yesterday while talking with my parents on occasion of my birthday, they asked the same question to me. Answer is I keep running list of the my personal favorite articles on my personal website. I update it very frequently. Visit Author’s Personal Favorite Best Articles List Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Birthday of SQL Authority Author](https://blog.sqlauthority.com/2007/07/30/sqlauthority-news-birthday-of-sql-authority-author/): Today is Birthday of SQL Authority Author. Thought of the day : Family is everything. https://www.pinaldave.com/ http://www.SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Data Warehousing Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/07/29/sql-server-data-warehousing-interview-questions-and-answers-complete-list-download/): Click here to get free chapters (PDF) in the mailbox It was a great pleasure to write latest series about Data Warehousing Interview Questions and Answers. Just like always again, I received lots of suggestion and follow up questions. I have tried to accommodate all of them in the last post in the series. I hope this series is helpful to all candidates who are seeking a job as well interviewers. I have combined all the questions and answers in the one PDF which is available to download and refer at convenience. Complete Series of SQL Server Interview Questions and Answers... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/07/28/sql-server-data-warehousing-interview-questions-and-answers-part-3/): Click here to get free chapters (PDF) in the mailbox What are slowly changing dimensions (SCD)? SCD is abbreviation of Slowly changing dimensions. SCD applies to cases where the attribute for a record varies over time. There are three different types of SCD. 1) SCD1 : The new record replaces the original record. Only one record exist in database – current data. 2) SCD2 : A new record is added into the customer dimension table. Two records exist in database – current data and previous history data. 3) SCD3 : The original data is modified to include new data. One record... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/07/27/sql-server-data-warehousing-interview-questions-and-answers-part-2/): Click here to get free chapters (PDF) in the mailbox What are normalization forms? Please visit this article. Describes the foreign key columns in fact table and dimension table? Foreign keys of dimension tables are primary keys of entity tables. Foreign keys of facts tables are primary keys of Dimension tables. What is Data Mining? Data Mining is the process of analyzing data from different perspectives and summarizing it into useful information. What is the difference between view and materialized view? A view takes the output of a query and makes it appear like a virtual table and it can be... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/07/26/sql-server-data-warehousing-interview-questions-and-answers-part-1/): Let us learn about Data Warehousing Interview Questions and Answers. - [SQLAuthority News - Interesting Read - Programming Concepts, Structured Thinking Language (STL) and Relationary](https://blog.sqlauthority.com/2007/07/25/sqlauthority-news-interesting-read-programming-concepts-structured-thinking-language-stl-and-relationary/): I have always enjoyed reading articles and blogs which are different then others. There many be thousands of technology and programming blogs, only few makes difference in the tech world. One of the high quality blog, I enjoy reading is relationary by Grant Czerepak. Grant Czerepak is an IT professional with over 20 years experience in relational database technology specifically in the areas of design, development and administration. As per Grant Czerepak “In this blog I will be mixing, matching, shifting and sifting paradigms that have come up in my work with relational databases and other concepts I’ve picked up while... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/07/25/sql-server-data-warehousing-interview-questions-and-answers-introduction/): Click here to get free chapters (PDF) in the mailbox This series is in response to many of my reader’s continuous request to start Data Warehousing Interview Questions and Answers series. This series is written in the same spirit as previous two series which has received good response. Samples Question from Interview Questions and Answer Series What is Data Warehousing? A data warehouse is the main repository of an organization’s historical data, its corporate memory. It contains the raw material for management’s decision support system. The critical factor leading to the use of a data warehouse is that a data analyst... - [SQL SERVER - 2005 - Server and Database Level DDL Triggers Examples and Explanation](https://blog.sqlauthority.com/2007/07/24/sql-server-2005-server-and-database-level-ddl-triggers-examples-and-explanation/): Let's learn about Server and Database Level DDL Triggers Examples and Explanation here. Let us learn more about this topic. - [SQL SERVER - UDF - Function to Get Previous And Next Work Day - Exclude Saturday and Sunday](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-function-to-get-previous-and-next-work-day-exclude-saturday-and-sunday/): While reading ColdFusion blog of Ben Nadel Getting the Previous Day In ColdFusion, Excluding Saturday And Sunday, I realize that I use similar function on my SQL Server Database. This function excludes the Weekends (Saturday and Sunday), and it gets previous as well as next work day. - [SQL SERVER - UDF - Get the Day of the Week Function](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-get-the-day-of-the-week-function/): The day of the week can be retrieved in SQL Server by using the DatePart function. The value returned by function is between 1 (Sunday) and 7 (Saturday). To convert this to a string representing the day of the week, use a CASE statement. Method 1: Create function running following script: CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) SELECT @rtDayofWeek = CASE DATEPART(weekday,@dtDate) WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN 'Wednesday' WHEN 5 THEN 'Thursday' WHEN 6 THEN 'Friday' WHEN 7 THEN 'Saturday' END RETURN (@rtDayofWeek) END GO Call... - [SQLAuthority News - FQL - Facebook Query Language](https://blog.sqlauthority.com/2007/07/22/sqlauthority-news-fql-facebook-query-language/): I was exploring the new hype today, I found Facebook Developers Documentation very interesting. Facebook API can be queries using FQL - Facebook Query Language, which is similar to SQL. - [SQL SERVER - Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database 'yourdatabasename'. CREATE DATABASE is aborted.](https://blog.sqlauthority.com/2007/07/21/sql-server-fix-error-msg-1813-level-16-state-2-line-1-could-not-open-new-database-yourdatabasename-create-database-is-aborted/): Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database ‘yourdatabasename’. CREATE DATABASE is aborted. This errors happens when corrupt database log are attempted to attach to new server. Solution of this error is little long and it involves restart of the server. I recommend following all the steps below in order without skipping any of them. Fix/Solution/Workaround: SQL Server logs are corrupted and they need to be rebuilt to make the database operational. Follow all the steps in order. Replace the yourdatabasename name with real name of your database. 1. Create a new database... - [SQL SERVER - Fix : Error Msg 4214 - Error Msg 3013 - BACKUP LOG cannot be performed because there is no current database backup](https://blog.sqlauthority.com/2007/07/20/sql-server-fix-error-msg-4214-error-msg-3013-backup-log-cannot-be-performed-because-there-is-no-current-database-backup/): This is very interesting error as I could not found any documentation on-line. It took me nearly 1 hour to figure out what was creating error. - [SQL SERVER - 2005 - SSMS - View/Send Query Results to Text/Grid/Files](https://blog.sqlauthority.com/2007/07/19/sql-server-2005-ssms-viewsend-query-results-to-textgridfiles/): Many times I have been asked how to change the result window from Text to Grid and vice versa. There are three different ways to do it. Method 1 : Key-Board Short Cut Results to Text – CTRL + T Results to Grid – CTRL + D Results to File – CTRL + SHIFT + F Method 2 : Using Toolbar Method 3 : Using Menubar Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SPACE Function Example](https://blog.sqlauthority.com/2007/07/19/sql-server-space-function-example/): A month ago, I wrote about SQL SERVER – TRIM() Function – UDF TRIM() . I was asked in comment if SQL Server has space function? Yes. SELECT SPACE(100) will generate 100 space characters. The use of SPACE() function is demonstrated in BOL very fine. Example from BOL: USE AdventureWorks; GO SELECT RTRIM(LastName) + ',' + SPACE(2) + LTRIM(FirstName) FROM Person.Contact ORDER BY LastName, FirstName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Restore Database Without or With Backup - Everything About Restore and Backup](https://blog.sqlauthority.com/2007/07/18/sql-server-restore-database-without-or-with-backup-everything-about-restore-and-backup/): The questions I received in last two weeks: “I do not have backup, is it possible to restore database to previous state?” “How can restore the database without using backup file?” “I accidentally deleted tables in my database, how can I revert back?” “How to revert the changes, I have only logs but no complete backup?” “How to rollback the database changes, my backup file is corrupted?” Answer: You need complete backup to rollback your changes. If you do not have complete backup you can not revert back. Sorry. To restore the database to previous stage if you have full backup:... - [SQL SERVER - CASE Statement in ORDER BY Clause - ORDER BY using Variable](https://blog.sqlauthority.com/2007/07/17/sql-server-case-statement-in-order-by-clause-order-by-using-variable/): This article is as per request from Application Development Team Leader of my company. His team encountered code where application was preparing string for ORDER BY clause of SELECT statement. Application was passing this string as variable to Stored Procedure (SP) and SP was using EXEC to execute the SQL string. This is not good for performance as Stored Procedure has to recompile every time due to EXEC. sp_executesql can do the same task but still not the best performance. Previously: Application: Nesting logic to prepare variable OrderBy. Database: Stored Procedure takes variable OrderBy as input parameter. SP uses EXEC (or... - [SQL SERVER - Microsoft White Papers - Analysis Services Query Best Practices - Partial Database Availability](https://blog.sqlauthority.com/2007/07/16/sql-server-microsoft-white-papers-analysis-services-query-best-practices-partial-database-availability/): Microsoft TechNet frequently releases White Papers on SQL Server Technology. I have read the following two white papers recently. The summary of its content is here. Analysis Services Query Performance Top 10 Best Practices Optimize cube and measure group design Define effective aggregations Use partitions Write efficient MDX Use the query engine cache efficiently Ensure flexible aggregations are available to answer queries. Tune memory usage Tune processor usage Scale up where possible Scale out when you can no longer scale up Partial Database Availability Writer: Danny Tambs Download Word Document As databases become larger and larger, the infrastructure assets and technology... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - 15 Signs to Identify Bad DBA](https://blog.sqlauthority.com/2007/07/15/sql-server-sql-joke-sql-humor-sql-laugh-15-signs-to-identify-bad-dba/): 15 Signs to Identify Bad DBA They think it is bug in SQL Server when two NULL values compared with each other but SQL Server does not say they equal to each other. They do not rename the trigger name thinking it will not work after it is rename. They are looking for difference between Index Scan or Table Scan on Google. They reinstall the SQL Server if they forget the password of SA login. They use model database for testing their script. They believe compiled stored procedure is production ready. They prefix all stored procedures with ‘sp_’ to be consistent... - [SQL SERVER - 2005 Collation Explanation and Translation - Part 2](https://blog.sqlauthority.com/2007/07/14/sql-server-2005-collation-explanation-and-translation-part-2/): Following function return all the available collation of SQL Server 2005. My previous article about the SQL SERVER – 2005 Collation Explanation and Translation. SELECT * FROM sys.fn_HelpCollations() Result Set: (only few of 1011 records) Name Description Latin1_General_BIN Latin1-General, binary sort Latin1_General_BIN2 Latin1-General, binary code point comparison sort Latin1_General_CI_AI Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AI_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AI_KS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AI_KS_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-sensitive Latin1_General_CI_AS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AS_KS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AS_KS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-sensitive Latin1_General_CS_AI Latin1-General, case-sensitive, accent-insensitive, kanatype-insensitive,... - [SQL SERVER - 2005 - Use ALTER DATABASE MODIFY NAME Instead of sp_renameDB to rename](https://blog.sqlauthority.com/2007/07/13/sql-server-2005-use-alter-database-modify-name-instead-of-sp_renamedb-to-rename/): To rename database it is very common to use for SQL Server 2000 user : EXEC sp_renameDB 'oldDB','newDB' sp_renameDB syntax will be deprecated in the future version of SQL Server. It is supported in SQL Server 2005 for backwards compatibility only. It is recommended to use ALTER DATABASE MODIFY NAME instead. New syntax of ALTER DATABASE MODIFY NAME is simple as well. /* Create Test Database */ CREATE DATABASE Test GO /* Rename the Database Test to NewTest */ ALTER DATABASE Test MODIFY NAME = NewTest GO /* Cleanup NewTest Database Do not run following command if you want to use the database. It is dropped here for sample database clean up. */ DROP DATABASE NewTest GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Validate Field For DATE datatype using function ISDATE()](https://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/): This article is based on the a question from Jr. Developer at my company. He works with the system, where we import CSV file in our database. One of the fields in the database is DATETIME field. Due to architecture requirement, we insert all the CSV fields in the temp table which has all the fields VARCHAR. We validate all the data first in temp table (check for inconsistency, malicious code, incorrect data type) and if passed validation we insert them in the final table in the database. Let us learn about ISDate function in this blog post. - [SQLAuthority News - SQL Blog SQLAuthority.com Comment by Mr. Ben Forta](https://blog.sqlauthority.com/2007/07/11/sqlauthority-news-sql-blog-sqlauthoritycom-comment-by-mr-ben-forta/): Today is one of the most glorious day for SQLAuthority.com in history. Famous author of Sams Teach Yourself Microsoft SQL Server T-SQL In 10 Minutes, ColdFusion Guru, and well known evangelists Mr. Ben Forta has made comment on his blog about SQLAuthority.com. I encourage all my readers to visit comment link here. I am very thankful to Mr. Forta for finding time to visit my blog from his busy schedule. I am attaching screen shot of the original post along with this post for reference. Mr. Forta said, “Pinalkumar Dave is a DBA with extensive SQL Server (and ColdFusion) experience. I... - [SQL SERVER - 2005 - Features Comparison Chart](https://blog.sqlauthority.com/2007/07/11/sql-server-2005-features-comparison-chart/): This post in the response to all the readers who have asked what are the differences between SQL Server 2005 editions. The reason I have never posted article about this as Microsoft has wonderful comparison chart on Microsoft SQL Server web site. This chart explains the difference between features of Express, Workgroup, Standard, and Enterprise editions. Visit Microsoft SQL Server 2005 Editions Features Comparison Chart Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Scheduled Launch at an Event in Los Angeles on Feb. 27, 2008](https://blog.sqlauthority.com/2007/07/11/sql-server-2008-scheduled-launch-at-an-event-in-los-angeles-on-feb-27-2008/): SQL SERVER 2008 will be launched at an Event in Los Angeles on Feb. 27, 2008. “In anticipation for the most significant Microsoft enterprise event in the next year, Turner announced that Windows Server® 2008, Visual Studio® 2008 and Microsoft SQL Server™ 2008 will launch together at an event in Los Angeles on Feb. 27, 2008, kicking off hundreds of launch events around the world.” Read original article here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Count Duplicate Records - Rows](https://blog.sqlauthority.com/2007/07/11/sql-server-count-duplicate-records-rows/): In my previous article SQL SERVER – Delete Duplicate Records – Rows, we have seen how we can delete all the duplicate records in one simple query. In this article we will see how to find count of all the duplicate records in the table. Following query demonstrates usage of GROUP BY, HAVING, ORDER BY in one query and returns the results with duplicate column and its count in descending order. SELECT YourColumn, COUNT(*) TotalCount FROM YourTable GROUP BY YourColumn HAVING COUNT(*) > 1 ORDER BY COUNT(*) DESC Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com)... - [SQL SERVER - 2005 - List All Stored Procedure Modified in Last N Days](https://blog.sqlauthority.com/2007/07/10/sql-server-2005-list-all-stored-procedure-modified-in-last-n-days/): I usually run following script to check if any stored procedure was deployed on live server without proper authorization in last 7 days. If SQL Server suddenly start behaving in un-expectable behavior and if stored procedure were changed recently, following script can be used to check recently modified stored procedure. If stored procedure was created but never modified afterwards modified date and create date for that stored procedure are same. SELECT name FROM sys.objects WHERE type = 'P' AND DATEDIFF(D,modify_date, GETDATE()) < 7 ----Change 7 to any other day value Following script will provide name of all the stored procedure which... - [SQL SERVER - Result of EXP (Exponential) to the POWER of PI - Functions Explained](https://blog.sqlauthority.com/2007/07/09/sql-server-result-of-exp-exponential-to-the-power-of-pi-functions-explained/): SQL Server can do some intense Mathematical calculations. Following are three very basic and very necessary functions. All the three function does not need explanation. I will not introduce their definition but will demonstrate the usage of function. SELECT PI() GO SELECT POWER(2,5) GO SELECT POWER(8,-2) GO SELECT EXP(99) GO SELECT EXP(1) GO Results Set : PI ———————- 3.14159265358979 PowerEg1 ———– 32 PowerEg2 ———– 0 ExpEg1 ———————- 9.88903031934695E+42 ExpEg2 ———————- 2.71828182845905 Now the Questions asked in the Title of the Article – What is the result of EXP to the POWER of PI SELECT POWER(EXP(1), PI()) GO Results ———————- 23.1406926327793 Reference... - [SQL SERVER - FIX : ERROR Msg 244, Level 16, State 1 - FIX : ERROR Msg 245, Level 16, State 1](https://blog.sqlauthority.com/2007/07/08/sql-server-fix-error-msg-244-level-16-state-1-fix-error-msg-245-level-16-state-1/): FIX : ERROR Msg 244, Level 16, State 1, Line 1 FIX : ERROR Msg 245, Level 16, State 1, Line 1 This error can happen due to conversion of one data type to incompatible datatype. Few examples are: VARCHAR to INT, INT to TINYINT etc. I have spotted this error happening with CAST or ISNULL, please add comments if you have come across this error in other examples. Following scripts will create this error. SELECT CAST('111111' AS SMALLINT); SELECT CAST('This is not smallint' AS SMALLINT); The errors received from above two scripts are : Msg 244, Level 16, State 2,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Generic Quotes](https://blog.sqlauthority.com/2007/07/08/sql-server-sql-joke-sql-humor-sql-laugh-generic-quotes/): Few days ago, in meeting I was forced to answer one of the question from non-programmer was considered as funny quotes for long time. “Yes it is latest year 2005 version of SQL Server – still it will not play your flash movie” — Pinal Dave (SQLAuthority.com) Many of following quotes are well apply to SQL Server or any database and I find them humorous. Software is Too Important to be Left to Programmers — Meilir Page-Jones. A clever person solves a problem. A wise person avoids it. — Einstein If you think good architecture is expensive, try bad architecture. —... - [SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT](https://blog.sqlauthority.com/2007/07/07/sql-server-convert-text-to-numbers-integer-cast-and-convert/): Few of the questions I receive very frequently. I have collect them in spreadsheet and try to answer them frequently. How to convert text to integer in SQL? If table column is VARCHAR and has all the numeric values in it, it can be retrieved as Integer using CAST or CONVERT function. How to use CAST or CONVERT? SELECT CAST(YourVarcharCol AS INT) FROM Table SELECT CONVERT(INT, YourVarcharCol) FROM Table Will CAST or CONVERT thrown an error when column values converted from alpha-numeric characters to numeric? YES. Will CAST or CONVERT retrieve only numbers when column values converted from alpha-numeric characters to... - [SQL SERVER - FIX : Error : msg 8115, Level 16, State 2, Line 2 - Arithmetic overflow error converting expression to data type](https://blog.sqlauthority.com/2007/07/06/sql-server-fix-error-msg-8115-level-16-state-2-line-2-arithmetic-overflow-error-converting-expression-to-data-type/): Following errors can happen when any field in the database is attempted to insert or update larger data of the same type or other data type. Msg 8115, LEVEL 16, State 2, Line 2 Arithmetic overflow error converting expression TO data type <ANY DataType> Example is if integer 111111 is attempted to insert in TINYINT data type it will throw above error, as well as if integer 11111 is attempted to insert in VARCHAR(2) data type it will throw above error. Fix/Solution/Workaround: 1) Verify the inserted/updated value that it is of correct length and data type. 2) If inserted/updated value are... - [SQL SERVER - 2005 - Microsoft Document Explorer cannot be shown because the specified help collection 'ms-help://MS.SQLCC.v9](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-microsoft-document-explorer-cannot-be-shown-because-the-specified-help-collection-ms-helpmssqlccv9/): I have received six emails in last four days asking for the resolution of error when tried to open newly installed SQL Server Book On-Line. Microsoft Document Explorer cannot be shown because the specified help collection ‘ms-help://MS.SQLCC.v9 1) Uninstall the versions of Book On-line (different languages, different releases etc) using Add-Remove programs tools. 2) Re-install SQL Server Book On-line. Above solution is confirmed by MSDN site here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Best Practices Analyzer Tutorial - Sample Example](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-best-practices-analyzer-tutorial-sample-example/): Yesterday I posted small note about SQL SERVER – 2005 Best Practices Analyzer (July BPA). I received many request about how BPA is used. Some of readers has asked me to provide sample tutorial which can help start using BPA. This utility has many uses for best practice. I have created very simple and initial tutorial. I encourage to follow that and once used it create your own reports in your desired format. Do not hesitate to install this add-on as I have use this previously to tune our production servers. Following tutorial about BPA is ran on one of my... - [SQL SERVER - 2005 Best Practices Analyzer (July BPA)](https://blog.sqlauthority.com/2007/07/04/sql-server-2005-best-practices-analyzer-july-bpa/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD HERE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Definition, Comparison and Difference between HAVING and WHERE Clause](https://blog.sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/): In recent interview sessions in hiring process I asked this question to every prospect who said they know basic SQL. Surprisingly, none answered me correct. They knew lots of things in details but not this simple one. One prospect said he does not know cause it is not on this Blog. Well, here we are with same topic online. Answer in one line is : HAVING specifies a search condition for a group or an aggregate function used in SELECT statement. HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP... - [SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable](https://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/): #TempTable and @TempVariable are different things with different scope. Their purpose is different but highly overlapping. TempTables are originated for the storage and & storage & manipulation of temporal data. TempVariables are originated (SQL Server 2000 and onwards only) for returning date-sets from table-valued functions. Common properties of #TempTable and @TempVariable They are instantiated in tempdb. They are backed by physical disk. Changes to them are logged in the transaction log1. However, since tempdb always uses the simple recovery model, those transaction log records only last until the next tempdb checkpoint, at which time the tempdb log is truncated. Discussion of... - [SQL SERVER - 2005 Comparison SP_EXECUTESQL vs EXECUTE/EXEC](https://blog.sqlauthority.com/2007/07/02/sql-server-2005-comparison-sp_executesql-vs-executeexec/): Common Properties of SP_EXECUTESQL and EXECUTE/EXEC The Transact-SQL statements in the sp_executesql or EXECUTE string are not compiled into an execution plan until sp_executesql or the EXECUTE statement are executed. The strings are not parsed or checked for errors until they are executed. The names referenced in the strings are not resolved until they are executed. The Transact-SQL statements in the executed string do not have access to any of the variables declared in the batch that contains thesp_executesql or EXECUTE statement. The batch containing the sp_executesql or EXECUTE statement does not have access to variables or local cursors defined in... - [SQL SERVER - Explanation of WITH ENCRYPTION clause for Stored Procedure and User Defined Functions](https://blog.sqlauthority.com/2007/07/01/sql-server-explanation-of-with-encryption-clause-for-stored-procedure-and-user-defined-functions/): This article is written to answer following two questions I have received in last one week. Questions 1) How to hide code of my Stored Procedure that no one can see it? 2) Our DBA has left the job and one of the function which retrieves important information is encrypted, how can we decrypt it and find original code? Answers 1) Use WITH ENCRYPTION while creating Stored Procedure or User Defined Function. 2) Sorry, unfortunately there is no simple way to decrypt the code. Hard way is too hard to even attempt. Explanations of WITH ENCRYPTION clause If SP or UDF... - [SQL SERVER - Fix : Error : Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type 'varchar' exceeds the maximum allowed for any data type (8000)](https://blog.sqlauthority.com/2007/06/30/sql-server-fix-error-server-msg-131-level-15-state-3-line-1-the-size-given-to-the-type-varchar-exceeds-the-maximum-allowed-for-any-data-type-8000/): Error: Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type ‘varchar’ exceeds the maximum allowed for any data type (8000) When the the length is specified in declaring a VARCHAR variable or column, the maximum length allowed is still 8000. Fix/WorkAround/Solution: Use either VARCHAR(8000) or VARCHAR(MAX) . VARCHAR(MAX) of SQL Server 2005 is replacement of TEXT of SQL Server 2000. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recompile All The Stored Procedure on Specific Table](https://blog.sqlauthority.com/2007/06/29/sql-server-recompile-all-the-stored-procedure-on-specific-table/): I have noticed that after inserting many rows in one table many times the stored procedure on that table executes slower or degrades. This happens quite often after BCP or DTS. I prefer to recompile all the stored procedure on the table, which has faced mass insert or update. sp_recompiles marks stored procedures to recompile when they execute next time. Example: ----Following script will recompile all the stored procedure on table Sales.Customer in AdventureWorks database. USE AdventureWorks; GO EXEC sp_recompile N'Sales.Customer'; GO ----Following script will recompile specific stored procedure uspGetBillOfMaterials only. USE AdventureWorks; GO EXEC sp_recompile 'uspGetBillOfMaterials'; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - 2005 Improvements in TempDB](https://blog.sqlauthority.com/2007/06/28/sql-server-2005-improvements-in-tempdb/): Following are some important improvements in tempdb in SQL Server 2005 over SQL Server 2000 Input/Output traffic to TempDB is reduced as logging is improved. In SQL Server 2005 TempDB does not log “after value” everytime. E.g. For INSERT it does not log after value on log as that will be any way logged in the TempTable. Similar for DELETE as It does not have to log After value as it is not there. This is big improvement in performance in SQL Server 2005 for TempDB. Some other improvement in File System of operating system. (I am not listing them as... - [SQL SERVER - Running Batch File Using T-SQL - xp_cmdshell bat file](https://blog.sqlauthority.com/2007/06/27/sql-server-running-batch-file-using-t-sql/): In last month I received few emails emails regarding SQL SERVER – Enable xp_cmdshell using sp_configure. The questions are 1) What is the usage of xp_cmdshell and 2) How to execute BAT file using T-SQL? I really like the follow up questions of my posts/articles. Answer is xp_cmdshell can execute shell/system command, which includes batch file. 1) Example of running system command using xp_cmdshell is SQL SERVER – Script to find SQL Server on Network EXEC master..xp_CMDShell 'ISQL -L' 2) Example of running batch file using T-SQL i) Running standalone batch file (without passed parameters) EXEC master..xp_CMDShell 'c:findword.bat' ii) Running parameterized batch... - [SQL SERVER - 2005 List All Tables of Database](https://blog.sqlauthority.com/2007/06/26/sql-server-2005-list-all-tables-of-database/): This is very simple and can be achieved using system table sys.tables. USE YourDBName GO SELECT * FROM sys.Tables GO This will return all the tables in the database which user have created. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Explanation and Example Four Part Name](https://blog.sqlauthority.com/2007/06/26/sql-server-explanation-and-example-four-part-name/): What is four part name? Explanation : ServerName.DatabaseName.DatabaseOwner.TableName Example : localhost.AdventureWorks.Person.Contact Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Repeate String N Times Using String Function REPLICATE](https://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/): I came across this SQL String Function few days ago while searching for Database Replication. This is T-SQL Function and it repeats the string/character expression N number of times specified in the function. SELECT REPLICATE( ' https://blog.sqlauthority.com/ ' , 9 ) This repeats the string https://blog.sqlauthority.com/ to 9 times in result window. I think it is fun utility to generate repeated text if ever required. Result Set: https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com/) , BOL - [SQLAuthority News - Book Review - Microsoft(R) SQL Server 2005 Unleashed (Paperback)](https://blog.sqlauthority.com/2007/06/24/sqlauthority-news-book-review-microsoftr-sql-server-2005-unleashed-paperback/): SQLAuthority.com Book Review : Microsoft(R) SQL Server 2005 Unleashed (Paperback) by Ray Rankins, Paul Bertucci, Chris Gallelli, Alex T. Silverstein Link to book on Amazon Short Review : SQL Server 2005 Unleashed is focused on Database Administration and day-to-day administrative management aspects of SQL Server. All the chapters of this book are heavily based on Book On-line (BOL) and it continue discussing the topics, where BOL leaves off. This makes this book a good reference for those who are looking for additional information, tricks & tips, and behind the scene details. I recommend this book as a wonderful read and hands-on... - [SQL SERVER - Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild - SQL SERVER 2000 and SQL SERVER 2005](https://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/): Index Fragmentation: When a page of data fills to 100 percent and more data must be added to it, a page split occurs. To make room for the new data, SQL Server must move half of the data from the full page to a new page. The new page that is created is created after all the pages in database. Therefore, instead of going right from one page to the next when looking for data, SQL Server has to go one page to another page around the database looking for the next page it needs. This is Index Fragmentation. Severity of... - [SQL SERVER - 2005 Row Overflow Data Explanation](https://blog.sqlauthority.com/2007/06/23/sql-server-2005-row-overflow-data-explanation/): In SQL Server 2000 and SQL Server 2005 a table can have a maximum of 8060 bytes per row. One of my fellow DBA said that he believed that SQL Server 2000 had that restriction but SQL Server 2005 does not have that restriction and it can have a row of 2GB. I totally agreed with him but after we discussed this problem in depth, we realized that there are more into it than only 8060 bytes limit. It is still true for SQL Server 2005 that a table can have maximum of 8060 bytes per row however the restriction has... - [SQL SERVER - Explanation and Comparison of NULLIF and ISNULL](https://blog.sqlauthority.com/2007/06/22/sql-server-explanation-and-comparison-of-nullif-and-isnull/): Explanation of NULLIF Syntax: NULLIF ( expression , expression ) Returns a null value if the two specified expressions are equal. NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression. NULLIF is equivalent to a searched CASE function in which the two expressions are equal and the resulting expression is NULL. - [SQLAuthority.com News - iGoogle Gadget Published](https://blog.sqlauthority.com/2007/06/21/sqlauthoritycom-news-igoogle-gadget-published/): I have recently received many requests to add an iGoogle Gadget so it can be integrated on iGoogle home page so I’ve gone ahead and done so: Add iGoogle Gadget Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Retrieve Current DateTime in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}](https://blog.sqlauthority.com/2007/06/21/sql-server-retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/): There are three ways to retrieve the current datetime in SQL SERVER. CURRENT_TIMESTAMP, GETDATE(), {fn NOW()} - [SQL SERVER - Find Length of Text Field](https://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/): To measure the length of VARCHAR fields the function LEN(varcharfield) is useful. To measure the length of TEXT fields the function is DATALENGTH(textfield). Len will not work for text field. Example: SELECT DATALENGTH(yourtextfield) AS TEXTFieldSize Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com News - Journey to SQL Authority Milestone of SQL Server](https://blog.sqlauthority.com/2007/06/19/sqlauthoritycom-news-journey-to-sql-authority-milestone-of-sql-server/): SQLAuthority.com News – Journey to SQL Authority Milestone of SQL Server I am very glad to write this 200th post of this blog. I would like to express my gratitude to all of YOU – my readers for continuously reading this blog. I receive many comments and emails with feedback, questions and suggestion everyday. I enjoy meeting few of you during this journey as well. Please do send me feedback and your request to make this blog better. Following is milestone of Journey to SQL Authority. SQL Server Interview Questions and Answers Complete List Download (PDF) SQL Server Database Coding Standards... - [SQL SERVER - Delay Function - WAITFOR clause - Delay Execution of Commands](https://blog.sqlauthority.com/2007/06/18/sql-server-delay-function-waitfor-clause-delay-execution-of-commands/): Blocks the execution of a batch, stored procedure, or transaction until a specified time or time interval is reached, or a specified statement modifies or returns at least one row. This is very useful. Every day when I restore the database to backup server for reports post processing, I use WAITFOR clause. While executing the WAITFOR statement, the transaction is running and no other requests can run under the same transaction. If the server is busy, the thread may not be immediately scheduled; therefore, the time delay may be longer than the specified time. WAITFOR can be used with query but... - [SQL SERVER - De-fragmentation of Database at Operating System to Improve Performance](https://blog.sqlauthority.com/2007/06/17/sql-server-de-fragmentation-of-database-at-operating-system-to-improve-performance/): This issues was brought to me by our Sr. Network Engineer. While running operating system level de-fragmentation using either windows de-fragmentation or third party tool it always skip all the MDF file and never de-fragment them. He was wondering why this happens all the time. The reason MDF file are skipped all the time in de-fragmentation because they are in use when SQL Server is running. Windows operating system de-fragmentation skips all the file in are currently in use. After discovering this the real question was how to de-fragment when files are in use. Steps are Stop the Server, Re-start, keep... - [SQL SERVER - 2005 - UDF - User Defined Function to Strip HTML - Parse HTML - No Regular Expression](https://blog.sqlauthority.com/2007/06/16/sql-server-udf-user-defined-function-to-strip-html-parse-html-no-regular-expression/): One of the developers at my company asked is it possible to parse HTML and retrieve only TEXT from it without using regular expression. He wanted to remove everything between < and > and keep only Text. I found the question very interesting and quickly wrote UDF which does not use regular expression. Let us see how to parse HTML without regular expression. - [SQL SERVER - sp_HelpText for sp_HelpText - Puzzle](https://blog.sqlauthority.com/2007/06/15/sql-server-sp_helptext-for-sp_helptext-puzzle/): It was interesting to me. I was using sp_HelpText to see the text of the stored procedure. Stored Procedure were different so I had copied sp_HelpText on my clipboard and was pasting it in Query Editor of Management Studio. In rush I typed twice sp_HelpText and hit F5. Result was interesting. What are your guesses? My team mates and few of my readers suggested : SQL Server will be in recursive loop, SQL Server will be not responde, SQL Server will throw an error. Try this: sp_HelpText sp_HelpText Result was as expected. SQL Server did its job and displayed the text... - [SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases - Part 2](https://blog.sqlauthority.com/2007/06/15/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases-part-2/): I have mentioned the history of NorthWind, Pubs and AdventureWorks in my previous post SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases. I have been receiving very frequent request for NorthWind Database for SQL Server 2005 and installation method. - [SQL SERVER - Easy Sequence of SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY](https://blog.sqlauthority.com/2007/06/14/sql-server-easy-sequence-of-select-from-join-where-group-by-having-order-by/): I was called many times by Jr. Programmers in team to debug their SQL. I keep log of most of the problems and review them afterwards. This helps me to evaluate my team and identify most important next thing which I can do to improve the performance and productivity of it. Recently we have many new hires and they had almost similar questions. Since, I have send them following sequence of the SELECT clause I am not interrupted often, which helps me to focus on larger project architectural design. SELECT yourcolumns FROM tablenames JOIN tablenames WHERE condition GROUP BY yourcolumns HAVING... - [SQL SERVER - Explanation SQL SERVER Hash Join](https://blog.sqlauthority.com/2007/06/14/sql-server-explanation-sql-server-hash-join/): Hash Join works with large data set. I have seen this join used many times in data warehouses applications as well as data mining algorithms. While its characteristics are similar to merge join it does not required ordered result set to join. Hash join requiresequijoin predicate to join tables. Equijoin predicate is comparing values between one table to other table using “equals to” (“=”) operator. Hash join gives best performance when two more join tables are joined and at-least one of them have no index or is not sorted. It is also expected that smaller of the either of table can... - [SQL SERVER - Fix : Error 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time.](https://blog.sqlauthority.com/2007/06/13/sql-server-fix-error-8629-the-query-processor-could-not-produce-a-query-plan-from-the-optimizer-because-a-query-cannot-update-a-text-ntext-or-image-column-and-a-clustering-key-at-the-same-time/): Error : 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time. - [SQL SERVER - Download 2005 Books Online (May 2007)](https://blog.sqlauthority.com/2007/06/13/sql-server-download-2005-books-online-may-2007/): Microsoft has merged SQL Server 2005 Expressed to SQL Server 2005 Books Online. New Version of SQL Server 2005 Books Online is released on June 12, 2007. Download SQL Server Books Online (BOL) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recovery Models and Selection](https://blog.sqlauthority.com/2007/06/13/sql-server-recovery-models-and-selection/): SQL Server offers three recovery models: full recovery, simple recovery and bulk-logged recovery. The recovery models determine how much data loss is acceptable and determines whether and how transaction logs can be backed up. Select Simple Recovery Model if: * Your data is not critical. * Losing all transactions since the last full or differential backup is not an issue. * Data is derived from other data sources and is easily recreated. * Data is static and does not change often. Select Bulk-Logged Recovery Model if: * Data is critical, but logging large data loads bogs down the system. * Most... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2007/06/12/sql-server-sql-joke-sql-humor-sql-laugh-funny-quotes/): While searching WIKI I came across this oracle WIKI. I found this very funny. I have taken few quotes from this site. There are lot more stuff there. The degree of normality in a database is inversely proportional to that of its DBA. Program complexity grows until it exceeds the capability of the programmer who must maintain it. “Walking on water and developing software from a specification are easy if both are frozen.” — Edward V. Berard, “Life-Cycle Approaches” “Technology is dominated by two types of people: those who understand what they do not manage, and those who manage what they... - [SQL SERVER - LEN and DATALENGTH of NULL Simple Example](https://blog.sqlauthority.com/2007/06/12/sql-server-len-and-datalength-of-null-simple-example/): Simple but interesting – In recent survey I found that many developers making this generic mistake. I have seen following code in periodic code review. (The code below is not actual code, it is simple sample code) DECLARE @MyVar VARCHAR(10) SET @MyVar = NULL IF (LEN(@MyVar) = 0) … I decided to send following code to them. After running the following sample code it was clear that LEN of NULL values is not 0 (Zero) but it is NULL. Similarly, the result for DATALENGTH function is the same. DATALENGTH of NULL is NULL. Sample Test Version: DECLARE @MyVar VARCHAR(10) SET @MyVar... - [SQL SERVER - Cannot Resolve Collation Conflict For Equal to Operation](https://blog.sqlauthority.com/2007/06/11/sql-server-cannot-resolve-collation-conflict-for-equal-to-operation/): Cannot resolve collation conflict for equal to operation. In MS SQL SERVER, the collation can be set at the column level. - [SQL SERVER - 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) - CTE vs. Derived Table](https://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/): I have received few emails and comments about my post SQL SERVER – T-SQL Paging Query Technique Comparison – SQL 2000 vs SQL 2005. The main question was is this can be done using CTE? Absolutely! What about Performance? It is same! Please refer above mentioned article for history of paging. - [SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice](https://blog.sqlauthority.com/2007/06/10/sql-server-retrieve-select-only-date-part-from-datetime-best-practice/): Just a week ago, my Database Team member asked me what is the best way to only select date part from datetime. When ran following command it also provide the time along with the date. - [SQL SERVER - Fix : Error : An error has occurred while establishing a connect to the server. Solution with Images.](https://blog.sqlauthority.com/2007/06/10/sql-server-fix-error-an-error-has-occurred-while-establishing-a-connect-to-the-server-solution-with-images/): While reviewing my my blog search engine terms I find Error 40 is the most common error searched. I have previously wrote blog about how to fix this error here : SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server. Today I have added few screen shot of that error and their solution to help readers who need additional help to understand my post. Error Screen: Solution Part 1: Enable SQL Server Service Solution Part 2: Enable TCP/IP Protocol Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 9514 Xml data type is not supported in distributed queries. Remote object 'OPENROWSET' has xml column(s)](https://blog.sqlauthority.com/2007/06/09/sql-server-fix-error-msg-9514-level-16-state-1-line-1-xml-data-type-is-not-supported-in-distributed-queries-remote-object-openrowset-has-xml-columns/): In this blog post we are going to learn how to fix XML Data Type related error. - [SQL SERVER - Spatial Database Definition and Research Documents](https://blog.sqlauthority.com/2007/06/09/sql-server-spatial-database-definition-and-research-documents/): Recently I was asked in meeting of SQL SERVER user group, what my opinion about spatial database. I answered from my basic knowledge. Spatial database is like database of space (not the star wars or star trek kind space). SQL Server database can understand the numeric and string values. If we ask to SQL Server what is multiplication of 6 and 3 it will provide answer as 18. If we ask to SQL Server what is distance between two points in polygon, it will be not able to answer using native functions. Custom SQL code written by user can do similar... - [SQL SERVER - UDF - Function to Display Current Week Date and Day - Weekly Calendar](https://blog.sqlauthority.com/2007/06/08/sql-server-udf-function-to-display-current-week-date-and-day-weekly-calendar/): In analytics section of our product I frequently have to display the current week dates with days. Week starts from Sunday. We display the data considering days as column and date and other values in column. If today is Friday June 8, 2007. We need script which can provides days and dates for current week. Following script will generate the required script. DECLARE @day INT DECLARE @today SMALLDATETIME SET @today = CAST(CONVERT(VARCHAR(10), GETDATE(), 101) AS SMALLDATETIME) SET @day = DATEPART(dw, @today) SELECT DATEADD(dd, 1 - @day, @today) Sunday, DATEADD(dd, 2 - @day, @today) Monday, DATEADD(dd, 3 - @day, @today) Tuesday, DATEADD(dd,... - [SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL](https://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/): Update: For SQL Server 2008 there is even better method of Row Construction, please read it here : SQL SERVER – 2008 – Insert Multiple Records Using One Insert Statement – Use of Row Constructor This is very interesting question I have received from new developer. How can I insert multiple values in table using only one insert? Now this is interesting question. When there are multiple records are to be inserted in the table following is the common way using T-SQL. - [SQL SERVER - 2005 Download New Updated Book On Line (BOL)](https://blog.sqlauthority.com/2007/06/07/sql-server-2005-download-new-updated-book-on-line-bol/): Book On Line the primary source for help for many developers has been updated. It now includes the updates till SP2 release. I use book on line for accuracy for my definition and information on this blog. Download Book On Line (Update June 4th, 2007) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 (Katmai) June CTP Released - Improvement Pillars - Diagram](https://blog.sqlauthority.com/2007/06/07/sql-server-2008-katmai-june-ctp-released-improvement-pillars-diagram/): I received quite a few emails in last three days for not mentioning on my blog about SQL Server 2008 (Katmai) CPT June is released. The reason I did not mentioned because I was busy with my mini series SQL SERVER – Database Coding Standards and Guidelines Complete List Download. SQL Server 2008 (Katmai) June CTP (Community Technology Preview) is announced in TechNet 2007 and is available to download. SQL Server 2008 June CTP enables customers to immediately utilize new capabilities that support their mission-critical platform. The chart below explains important improvements coming online with each CTP. Please visit SQL Server... - [SQL SERVER - Fix : Error : Error 15401: Windows NT user or group 'username' not found. Check the name again.](https://blog.sqlauthority.com/2007/06/07/sql-server-fix-error-error-15401-windows-nt-user-or-group-username-not-found-check-the-name-again/): Fix : Error : Error 15401: Windows NT user or group ‘username’ not found. Check the name again. This is quite a famous error and I was asked to write about it by couple of readers. The reason I was not writing about this as the solution of this error is very well explained in Book On Line. All the potential causes and their solutions are explained well here. This post/article should be considered as book mark to solution. Fix/WorkAround/Solution: Refere Microsoft Help and Support : How to troubleshoot error 15401 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Database Coding Standards and Guidelines Complete List Download](https://blog.sqlauthority.com/2007/06/06/sql-server-database-coding-standards-and-guidelines-complete-list-download/): Download SQL SERVER Database Coding Standards and Guidelines Complete List - [SQL SERVER - Database Coding Standards and Guidelines - Part 2](https://blog.sqlauthority.com/2007/06/05/sql-server-database-coding-standards-and-guidelines-part-2/): SQL Server Database Coding Standards and Guidelines - Part 2 - [SQL SERVER - Database Coding Standards and Guidelines - Part 1](https://blog.sqlauthority.com/2007/06/04/sql-server-database-coding-standards-and-guidelines-part-1/): SQL Server Database Coding Standards and Guidelines - Part 1 - [SQL SERVER - Database Coding Standards and Guidelines - Introduction](https://blog.sqlauthority.com/2007/06/03/sql-server-database-coding-standards-and-guidelines-introduction/): I have received many many request to do another series since my series SQL Server Interview Questions and Answers Complete List Download. I have created small series of Coding Standards and Guidelines, as this is the second most request I have received from readers. This document can be extremely long but I have limited to very few pages as it is difficult to follow thousands of the rules. My experience says it is more productive developer and better code if coding standard has important fewer rules than lots of micro rules. - [SQL SERVER - 2005 Explanation and Example - SELF JOIN](https://blog.sqlauthority.com/2007/06/03/sql-server-2005-explanation-and-example-self-join/): A self-join is simply a normal SQL join that joins one table to itself. This is accomplished by using table name aliases to give each instance of the table a separate name. Joining a table to itself can be useful when you want to compare values in a column to other values in the same column. A join in which records from a table are combined with other records from the same table when there are matching values in the joined fields. A self-join can be an inner join or an outer join. A table is joined to itself based upon... - [SQL SERVER - 2005 - Microsoft SQL Server Management Pack for Microsoft Operations Manager 2005 - Download SQL Server MOM 2005](https://blog.sqlauthority.com/2007/06/02/sql-server-2005-microsoft-sql-server-management-pack-for-microsoft-operations-manager-2005-download-sql-server-mom-2005/): The Microsoft SQL Server Management Pack provides both proactive and reactive monitoring of SQL Server 2005 and SQL Server 2000 in an enterprise environment. Availability and configuration monitoring, performance data collection, and default thresholds are built for enterprise-level monitoring. Both local and remote connectivity checks help ensure database availability. Features description are available online. Download SQL Server MOM 2005 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Subscribe to Feed in Email](https://blog.sqlauthority.com/2007/06/02/sqlauthority-news-subscribe-to-feed-in-email/): You can subscribe to SQLAuthority.com Feed using Email. Email will be delivered to your preferred email address when new post appears on SQLAuthority.com Subscribe to SQLAuthority Feed Through Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Dedicated Search Engine for SQLAuthority - Search SQL Solutions](https://blog.sqlauthority.com/2007/06/01/sqlauthority-news-dedicated-search-engine-for-sqlauthority-search-sql-solutions/): Visit search.SQLAuthority.com I have been receiving many questions asking for tutorials, suggestions or questions about topics I already have wrote before but readers are have not found it or having difficulty to find them. I have almost around 200 articles on this blog so far and it is growing. One of the team member in my company keep on asking about search engine specific to SQLAuthority.com. He suggest that he always search in this blog first before he search on web. One of the loyal reader suggests that I should have search facilities in my SQL Interview Questions. I have created... - [SQL SERVER - 2005 Constraint on VARCHAR(MAX) Field To Limit It Certain Length](https://blog.sqlauthority.com/2007/06/01/sql-server-2005-constraint-on-varcharmax-field-to-limit-it-certain-length/): One of the Jr. DBA at in my Team Member asked me question the other day when he was replacing TEXT field with VARCHAR(MAX) : How can I limit the VARCHAR(MAX) field with maximum length of 12500 characters only. His Question was valid as our application was allowing 12500 characters. Traditionally thinking we only create the field as long as we need. SQL Server 2005 does support VARCHAR(MAX) but does not support VARCHAR(12500). If we try to create database field with VARCHAR(12500) it gives following error. Server: Msg 131, Level 15, State 3, Line 1 The size (12500) given to the... - [SQL SERVER - Retrieve Information of SQL Server Agent Jobs](https://blog.sqlauthority.com/2007/05/31/sql-server-retrieve-information-of-sql-server-agent-jobs/): sp_help_job returns information about jobs that are used by SQL Server Agent service to perform automated activities in SQL Server. When executed sp_help_job procedure with no parameters to return the information for all of the jobs currently defined in the msdb database. - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility - Part 2 - Management Studio](https://blog.sqlauthority.com/2007/05/31/sql-server-2005-change-database-compatible-level-backward-compatibility-part-2-management-studio/): I have received quite a few request about post I have two days ago SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility, if this can be done using SQL Server Management Studio. It is very simple to do this using Management Studio as well but I still prefer T-SQL way. Following steps will display the method to change the compatible levels. Write click on database. Click on Properties. Click on Options. Change the Compatibility level to desired compatibility. (See Attached image below) Click OK. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Must Not Contain NULL - Primary Key are NOT NULL](https://blog.sqlauthority.com/2007/05/31/sql-server-primary-key-must-not-contain-null-primary-key-are-not-null/): While reviewing the search engine log for this blog I found lots of search regarding Nullable Primary Key. It is not possible. This post is especially to clear the Not Nullable Primary Key Property. The Allow Nulls property can’t be set on a column that is part of the primary key. All columns that are part of a table’s a primary key must contain aggregate unique values other than NULL. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQLAuthority.com News - Best SQL Job Search - Best SQL Job List - Find SQL Jobs](https://blog.sqlauthority.com/2007/05/30/sqlauthoritycom-news-best-sql-job-search-best-sql-job-list-find-sql-jobs/): SQLAuthority.com News – Best SQL Job Search – Best SQL Job List – Find SQL Jobs Visit : I have been receiving two kind of requests almost every day. 1) Recruiters and Employers asking where can they find good candidates who are truly dedicated to SQL Server? 2) Job seeker asking where can they find only SQL related jobs? There are hundreds of web site which have great resources for all kind of jobs. Monster and Dice are examples of them. Many sites are bit ocean of the jobs and it is hard to find only SQL Jobs from there, many... - [SQL SERVER - Trace Flags - DBCC TRACEON](https://blog.sqlauthority.com/2007/05/30/sql-server-trace-flags-dbcc-traceon/): Trace flags are valuable tools as they allow DBA to enable or disable a database function temporarily. Once a trace flag is turned on, it remains on until either manually turned off or SQL Server restarted. Only users in the sysadmin fixed server role can turn on trace flags. If you want to enable/disable Detailed Deadlock Information (1205), use Query Analyzer and DBCC TRACEON to turn it on. 1205 trace flag sends detailed information about the deadlock to the error log. Enable Trace at current connection level: DBCC TRACEON(1205) Disable Trace: DBCC TRACEOFF(1205) Enable Multiple Trace at same time separating each... - [SQL SERVER - Fix : Error : Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table](https://blog.sqlauthority.com/2007/05/30/sql-server-fix-error-server-msg-544-level-16-state-1-line-1-cannot-insert-explicit-value-for-identity-column-in-table/): Error Message: Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF. This error message appears when you try to insert a value into a column for which the IDENTITY property was declared, but without having set the IDENTITY_INSERT setting for the table to ON. Fix/WorkAround/Solution: /* Turn Identity Insert ON so records can be inserted in the Identity Column  */ SET IDENTITY_INSERT [dbo].[TableName] ON GO INSERT INTO [dbo].[TableName] ( [ID], [Name] ) VALUES ( 2, 'InsertName') GO /* Turn Identity Insert OFF  */ SET IDENTITY_INSERT [dbo].[TableName] OFF GO Setting the IDENTITY_INSERT to ON allows explicit values to be inserted into the identity column of a table. Execute permissions... - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility](https://blog.sqlauthority.com/2007/05/29/sql-server-2005-change-database-compatible-level-backward-compatibility/): sp_dbcmptlevel Sets certain database behaviors to be compatible with the specified version of SQL Server. Example: ----SQL Server 2005 database compatible level to SQL Server 2000 EXEC sp_dbcmptlevel AdventureWorks, 80; GO ----SQL Server 2000 database compatible level to SQL Server 2005 EXEC sp_dbcmptlevel AdventureWorks, 90; GO Version of SQL Server database can be one of the following: 60 = SQL Server 6.0 65 = SQL Server 6.5 70 = SQL Server 7.0 80 = SQL Server 2000 90 = SQL Server 2005 The sp_dbcmptlevel stored procedure affects behaviors only for the specified database, not for the entire server. sp_dbcmptlevel provides only... - [SQL SERVER - Introduction to Force Index Query Hints - Index Hint - Part2](https://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/): In my previous article SQL SERVER – Introduction to Force Index Query Hints – Index Hint I have discussed regarding how we can use Index Hints with any query. I just received email from one of my regular reader that are there any another methods for the same as it will be difficult to read the syntax of join.Yes, there is alternate way to do the same using OPTION clause however, as OPTION clause is specified at the end of the query we have to specify which table the index hint is put on. Example 1: Using Inline Query Hint USE... - [SQL SERVER - Introduction to Force Index Query Hints - Index Hint](https://blog.sqlauthority.com/2009/02/07/sql-server-introduction-to-force-index-query-hints-index-hint/): This article, I will start with disclaimer instead of having it at the end of article. “SQL Server query optimizer selects the best execution plan for a query, it is recommended to use query hints by experienced developers and database administrators in case of special circumstances.” When any query is ran SQL Server Engine determines which index has to be used. SQL Server makes uses Index which has lowest cost based on performance. Index which is the best for performance is automatically used. There are some instances when Database Developer is best judge of the index used. DBA can direct SQL... - [SQL SERVER - Quickest Way to - Kill All Threads - Kill All User Session - Kill All Processes](https://blog.sqlauthority.com/2009/02/06/sql-server-quickest-way-to-kill-all-threads-kill-all-user-session-kill-all-processes/): More than a year ago, I wrote how to kill all the processes running in SQL Server. Just a day ago, I found the quickest way to kill the processes of SQL Server. While searching online I found very similar methods to my previous method everywhere. Today in this article, I will write the quickest way to achieve the same goal. Read here for older method of using cursor – SQL SERVER – Cursor to Kill All Process in Database. USE master; GO ALTER DATABASE AdventureWorks SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE AdventureWorks SET MULTI_USER; GO Running above script will give following result.... - [SQLAuthority News - Two Promotion to Help Community](https://blog.sqlauthority.com/2009/02/05/sqlauthority-news-two-promotion-to-help-community/): In this difficult time of recession I have two promotion to share with SQL Server community. 1) Discount on Microsoft Exams and Free Second Retake Due to bad job market, the ratio to available jobs to available candidates is lower than usual. Microsoft exams are key to stand up in mass and prove your potential. Click Here to Get Discount Code and Read more about this subject 2) Post your Tech Job and Get 10% Discount Jobs @ SQLAuthority.com has come up as prominent job portal and have been getting very high traffic. I receive lots of email and comments from... - [SQL SERVER - Observation - Effect of Clustered Index over Nonclustered Index](https://blog.sqlauthority.com/2009/02/04/sql-server-observation-effect-of-clustered-index-over-nonclustered-index/): Today I came across very interesting observation while I was working on query optimization. Let us run the example first. Make sure to to enable Execution Plan (Using CTRL + M) before running comparison queries. USE [AdventureWorks] GO /* */ CREATE TABLE [dbo].[MyTable]( [ID] [int] NOT NULL, [First] [nchar](10) NULL, [Second] [nchar](10) NULL ) ON [PRIMARY] GO /* Create Sample Table */ INSERT INTO [AdventureWorks].[dbo].[MyTable] ([ID],[First],[Second]) SELECT 1,'First1','Second1' UNION ALL SELECT 2,'First2','Second2' UNION ALL SELECT 3,'First3','Second3' UNION ALL SELECT 4,'First4','Second4' UNION ALL SELECT 5,'First5','Second5' GO Now let us create nonclustered index over this table. /* Create Nonclustered Index over Table */... - [SQLAuthority News - Download SQL Server 2008 System Views Poster - PDF - A Wall Poster](https://blog.sqlauthority.com/2009/02/03/sqlauthority-news-download-sql-server-2008-system-views-poster-pdf-a-wall-poster/): Microsoft has published SQL Server 2008 System Views Poster. This poster should be must have poster for any SQL Server Developer. I have this poster on my wall. If you have extra copy of this postered in print. Do send it to me and I will forward it to developer who are very good but can not afford to get this poster printed in glossy pages. The Microsoft SQL Server 2008 System Views Map shows the key system views included in SQL Server 2008, and the relationships between them. The map is similar to the Microsoft SQL Server 2005 version and... - [SQL SERVER - T-SQL Script for FizzBuzz Logic](https://blog.sqlauthority.com/2009/02/02/sql-server-t-sql-script-for-fizzbuzz-logic/): Following is quite common Interview Question asked in many interview questions. FizzBuzz is popular but very simple puzzle and have been very popular to solve. FizzBuzz problem can be attempted in any programming language. Let us attempt it in T-SQL. Definition of FizzBuzz Puzzle : Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. DECLARE @counter INT DECLARE @output VARCHAR(8) SET @counter = 1 WHILE @counter < 101... - [SQLAuthority News - Download Microsoft SQL Server 2008 Books Online (January 2009)](https://blog.sqlauthority.com/2009/02/01/sqlauthority-news-download-microsoft-sql-server-2008-books-online-january-2009/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - FIX : ERROR : Msg 5834, Level 16, State 1, Line 1 The affinity mask specified conflicts with the IO affinity mask specified. Use the override option to force this configuration](https://blog.sqlauthority.com/2009/01/31/sql-server-fix-error-msg-5834-level-16-state-1-line-1-the-affinity-mask-specified-conflicts-with-the-io-affinity-mask-specified-use-the-override-option-to-force-this-configuration/): Yesterday I came across following error while enabling fill factor for my database server, when I was trying to write article SQL SERVER – 2008 – 2005 – Rebuild Every Index of All Tables of Database – Rebuild Index with FillFactor. I ran following T-SQL script and it gave me error. sp_configure 'show advanced options', 1 GO RECONFIGURE GO sp_configure 'fill factor', 90 GO RECONFIGURE GO In result pan following error showed up. Msg 5834, Level 16, State 1, Line 1 The affinity mask specified conflicts with the IO affinity mask specified. Use the override option to force this configuration. Fix/Solution/Workaround:... - [SQL SERVER - 2008 - 2005 - Rebuild Every Index of All Tables of Database - Rebuild Index with FillFactor](https://blog.sqlauthority.com/2009/01/30/sql-server-2008-2005-rebuild-every-index-of-all-tables-of-database-rebuild-index-with-fillfactor/): I just wrote down following script very quickly for one of the project which I am working on. The requirement of the project was that every index existed in database should be rebuilt with fillfactor of  80. One common question I receive why fillfactor 80, answer is I just think having it 80 will do the job.Fillfactor determines how much percentage of the space on each leaf-level page are filled with data. The space which is left empty on leaf-level page is not at end of the page but the empty space is reserved between rows of data. This ensures that... - [SQLAuthority News - Microsoft Certification Exam - Discount Code - Free Second Chance - MCTS, MCITP, MCPD](https://blog.sqlauthority.com/2009/01/29/sqlauthority-news-microsoft-certification-exam-discount-code-free-second-chance-mcts-mcitp-mcpd/): Please note down this important code or share with your colleagues who are keen to take Microsoft Certification Exam. This unique code is only available through Microsoft MVP’s and only published here to help community and no other intention. In this challenging economic climate, upgrading your IT skills becomes crucial to staying ahead. Invest in a Microsoft Certification to get the right IT skills. Register today with your MVP Certification Promotion Code:  and enjoy 2 chances to pass a Microsoft Certification Examination plus a 10% discount! If you fail on your first attempt, you will receive a free retake of the... - [SQL SERVER - Generate A Single Random Number for Range of Rows of Any Table - Very interesting Question from Reader](https://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/): Just a day ago I received email from reader how to get single random number for range of rows of any table. The question was not very clear to me so I had asked him to send me question in simpler words. He sent me question back in simple words. Let us understand this problem using database AdventureWorks. In AdventureWorks database we have table called Person.Address. How to get single random number generated for PostalCode ‘98011’ and another single random number for PostalCode ‘98033’. So far I have never received scenario like this. I had previously faced situation where I had... - [SQLAuthority News - Download Cumulative update package 3 for SQL Server 2008](https://blog.sqlauthority.com/2009/01/27/sqlauthority-news-download-cumulative-update-package-3-for-sql-server-2008/): For almost one year I have been using SQL Server 2008 and I keep watch on its update. Cumulative Update Package 3 has been made available now. Latest SQL Server 2008 version is 10.0.1787.0. Download Cumulative update package 3 for SQL Server 2008 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Microsoft SQL Server JDBC Driver 2.0 Community Technology Preview](https://blog.sqlauthority.com/2009/01/27/sqlauthority-news-download-microsoft-sql-server-jdbc-driver-20-community-technology-preview/): Note:  Download Microsoft SQL Server JDBC Driver 2.0 Community Technology Preview by Microsoft In its continued commitment to interoperability, Microsoft has released a new Java Database Connectivity (JDBC) driver. The SQL Server JDBC Driver 2.0 download is available to all SQL Server users at no additional charge, and provides access to SQL Server 2000, SQL Server 2005, and SQL Server 2008 from any Java application, application server, or Java-enabled applet. This is a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform, Enterprise Edition 5. This Community Technology Preview (CTP)... - [SQLAuthority News - Happy 60th Republic Day to India - Database Tip](https://blog.sqlauthority.com/2009/01/26/sqlauthority-news-happy-60th-republic-day-to-india-database-tip/): Kaleidoscopic images of India’s rich cultural diversity and the might of its military were on full display on the magnificent Rajpath Republic Day celebrations as the nation celebrated its 60th Republic Day amid an unprecedented security cover. An impressive and colourful parade, a traditional attraction of the national event, marched down the thoroughfare connecting the Rashtrapati Bhawan and the historic India Gate as President Pratibha Patil took the salute from marching contingents. (PTI) Database Tip of Today: Always check your execution plan first if your query is running slower and identify the part of query which is taking the highest execution... - [SQL SERVER - Shrinking NDF and MDF Files - A Safe Operation](https://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/): Just a day ago I have received following email from Siddhi and I found it interesting so I am sharing with all of you. Hello Pinal, I have seen many blogs from you on SQL server and i have always found them useful and easy to understand. Thanks for all the information you provide. I have one query about shrinking NDF and MDF files. Can we shrink NDF and MDF files?? If you do so is there any data loss? I have been shrinking the .LDF files every now and then but I am not too sure about NDF and MDF... - [SQLAuthority News - Download Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007](https://blog.sqlauthority.com/2009/01/24/sqlauthority-news-download-microsoft-sql-server-2005-data-mining-add-ins-for-microsoft-office-2007/): Note:  Download Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007 by Microsoft Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007 (Data Mining Add-ins) allow you take advantage of SQL Server 2005 predictive analytics in Office Excel 2007 and Office Visio 2007. The download includes the following components: Table Analysis Tools for Excel: This add-in provides easy-to-use tasks that leverage SQL Server 2005 Data Mining to perform powerful analytics on your spreadsheet data. Data Mining Client for Excel: This add-in allows you to go through the full data mining model development lifecycle within Excel 2007 using... - [SQL SERVER - 2008 - 2005 - Find Longest Running Query - TSQL - Part 2](https://blog.sqlauthority.com/2009/01/23/sql-server-2008-2005-find-longest-running-query-tsql-part-2/): Just another day I was playing with my query which I posted earlier SQL SERVER – 2008 – 2005 – Find Longest Running Query – TSQL and I found that I got error devide by zero. I have fixed this error in following query as well I have updated query to return time in millisecond instead of microsecond. Jerry Hung has also posted similar solution in comments of original article. I strongly suggest to read original article to now more about introduction and learn about DBCC command which clears cache. SELECT DISTINCT TOP 10 t.TEXT QueryName, s.execution_count AS ExecutionCount, s.max_elapsed_time AS MaxElapsedTime, ISNULL(s.total_elapsed_time... - [SQLAuthority News - Milestone of 6 Million Visits - 60 Lak Visits - Search and Job](https://blog.sqlauthority.com/2009/01/22/sqlauthority-news-milestone-of-6-million-visits-60-lak-visits-search-and-job/): Today SQLAuthority.com has completed 6 Million Visits. In 2 years 3 months miles stone of 6 million visits has been crossed. I want to thank all of my readers for their continuous support and help. On milestone of 6 million visits I want to announce small gratitude towards my readers who are continuously participating on this blog. I will be sending small surprise to all the readers who have been consistently participating on this blog. Those who have occasional participated with comments, suggestion or articles, I suggest them to participate more to get the surprise. Additionally, on this occasion I want... - [SQLAuthority News - SQLAuthority News - Ahmedabad User Group Meeting January 17 2009 - Review](https://blog.sqlauthority.com/2009/01/21/sqlauthority-news-sqlauthority-news-ahmedabad-user-group-meeting-january-17-2009-review/): User Group Meeting is the the event I always wait during whole month. User Group meetings are the place where we can meet various people from all around the city and expand our networking. Meeting new people and exchanging new tips and tricks is always interesting. For year 2009 we had our first User Group Meeting held on January 17, 2009. You can read the announcement here SQLAuthority News – Ahmedabad User Group Meeting January 17 2009. As this was first UG Meet of the year it was full of action with 3 back to back Performance Tuning related sessions. If... - [SQL SERVER - Rules for Optimizining Any Query - Best Practices for Query Optimization](https://blog.sqlauthority.com/2009/01/20/sql-server-rules-for-optimizining-any-query-best-practices-for-query-optimization/): This subject is very deep subject but today we will see it very quickly and most important points. May be following up on few of the points of this point will help users to right away improve the performance of query. In this article I am not focusing on in depth analysis of database but simple tricks which DBA can apply to gain immediate performance gain. Table should have primary key Table should have minimum of one clustered index Table should have appropriate amount of non-clustered index Non-clustered index should be created on columns of table based on query which is... - [SQLAuthority News - CWE/SANS TOP 25 Most Dangerous Programming Errors](https://blog.sqlauthority.com/2009/01/19/sqlauthority-news-cwesans-top-25-most-dangerous-programming-errors/): I just came across very interesting article from SANS Institute. Experts from more than 30 US and international cyber security organizations have released list of 25 most dangerous programming errors and their resolution. It may be possible that many of the programmers may not understand what this errors are and how to implement their solution. As said this are 25 most dangerous errors and all the developers should atleast know what they are so they do not are prevented from origin. Here are four major advantages listed by SANS. Software buyers will be able to buy much safer software. Programmers will... - [SQL SERVER - Difference Between Index Scan and Index Seek](https://blog.sqlauthority.com/2009/01/18/sql-server-difference-between-index-scan-and-index-seek/): I have explained the concept of Index Scan and Index Seek earlier but I keep on receiving the same question again and again. Let us today look into it with little more depth. Before we go over the concept of scan and seek we need to understand what SQL Server does before applying any kind of index on query. When any query is ran SQL Server has to determine that if any particular index can be applied on that particular query or not. SQL Server uses search predicates to make decision right before applying indexes to any given query. Let us... - [SQLAuthority News - Download Microsoft SQL Server Protocol Documentation](https://blog.sqlauthority.com/2009/01/17/sqlauthority-news-download-microsoft-sql-server-protocol-documentation/): he Microsoft SQL Server protocol documentation provides detailed technical specifications for Microsoft proprietary protocols (including extensions to industry-standard or other published protocols) that are implemented and used in Microsoft SQL Server to interoperate or communicate with Microsoft products. The documentation includes a set of companion overview and reference documents that supplement the technical specifications with conceptual background, overviews of inter-protocol relationships and interactions, and technical reference information. Download Microsoft SQL Server Protocol Documentation Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad User Group Meeting January 17 2009](https://blog.sqlauthority.com/2009/01/16/sqlauthority-news-ahmedabad-user-group-meeting-january-17-2009/): It is my pleasure to announce that SQL Server User Group Meeting is held on January 17, 2009. This is the first meeting of year 2009 and will be one interesting meeting as we will have back to back three presentation from SQL Experts. The agenda of meeting will be as following. Query Optimization Part 3 – Jacob Sebastian (SQL Server MVP) Understanding of Index Usage and Order By – Pinal Dave (SQL Server MVP) MERGE statement in SQL Server 2008 – Imran Bhadelia (MCTS) I encourage every SQL enthusiastic in city to attend this meeting as this will be one... - [SQL SERVER - Remove Duplicate Entry from Comma Delimited String - UDF](https://blog.sqlauthority.com/2009/01/15/sql-server-remove-duplicate-entry-from-comma-delimited-string-udf/): I love reader’s contribution this blog as that brings variety in articles. I encourage my readers to provide their contribution and I will publish then with their name. Blog Reader Ashish Jain has posted very simple script which will remove duplicate entry from comma delimited string. User Defined Function has very simple logic behind it. It takes comma delimited string and then converts it to table and runs DISTINCT operation on the table. DISTINCT operation removes duplicate value. After that it converts the table again into the string and it can be used. I have modified original contribution from Ashish so... - [SQL SERVER - Find Number of Rows and Disk Space Reserved - Using sp_spaceused Interesting Observation](https://blog.sqlauthority.com/2009/01/14/sql-server-find-number-of-rows-and-disk-space-reserved-using-sp_spaceused-interesting-observation/): Previously I posted SQL SERVER – Find Row Count in Table – Find Largest Table in Database – T-SQL. Today we will look into the same issue but with some additional interesting detail. We can find the row count using another system SP sp_spaceused. This SP gives additional information regarding disk space reserved on database as well. Well, when I ran the SP on AdventureWorks first time, I suspected that database SP is not providing me correct results. After a bit investigating I found that it may be possible that due to any reason may be the usage on AdventureWorks database... - [SQL SERVER - Find Row Count in Table - Find Largest Table in Database - T-SQL](https://blog.sqlauthority.com/2009/01/13/sql-server-find-row-count-in-table-find-largest-table-in-database-t-sql/): I have written following script every time when I am asked by our team leaders or managers that how many rows are there in any particular table or sometime I am even asked which table has highest number of rows. Being Sr. Project Manager, sometime I just write down following script myself rather than asking my developers. This script will gives row number for every table in database. USE AdventureWorks GO SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count FROM sys.dm_db_partition_stats st WHERE index_id < 2 ORDER BY st.row_count DESC GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Humor - Favorite Website - Funny Image](https://blog.sqlauthority.com/2009/01/12/sqlauthority-news-humor-favorite-website-funny-image/): I just received this image in email and I found it really funny. I do not know the source of the image or is it photoshopped. Thanks David Marsee for the image and email. If you have something really funny like this, please send them to me. Please do not leave comment regarding grammatical mistake in image as I am sure David (who send email) did not mean it. Reference : Pinal Dave https://blog.sqlauthority.com/ ) - [SQL SERVER - Top Five Articles of Year 2008](https://blog.sqlauthority.com/2009/01/11/sql-server-top-five-articles-of-year-2008/): Year 2008 was great year for me. I got plenty of request from readers asking for Top 10 or Top 5 articles of the year 2008. I am including Top 5 Articles of Year 2008 in two different categories. First is my blog SQLAuthority.com and another one is my home page pinaldave.com TOP 5 Articles at SQLAuthority.com This section has six links as very first link is repeated again in top 5 pages at pinaldave.com SQL SERVER – 2008 – Interview Questions and Answers Complete List Download Most popular and most visited page. Very first and compilation of SQL Server Interview... - [SQLAuthority News - Security White Papers](https://blog.sqlauthority.com/2009/01/10/sqlauthority-news-security-white-papers/): Microsoft Dynamics AX 2009 White Paper: Configuring Kerberos Authentication with Role Centers This document describes how to configure Kerberos authentication with Enterprise Portal and Role Centers. Kerberos authentication is required to display reports created using Microsoft SQL Server Reporting Services and Microsoft SQL Server Analysis Services on Role Center pages. Microsoft Dynamics AX 2009 White Paper: Configuring Enterprise Portal and Role Centers with SQL Reporting This document contains checklists and information to help administrators set up and configure Microsoft Dynamics AX 2009 Enterprise Portal and Role Centers with Microsoft SQL Server® Reporting Services® and Microsoft SQL Server Analysis Services. Reference :... - [SQL SERVER - sqlcmd - Using a Dedicated Administrator Connection to Kill Currently Running Query](https://blog.sqlauthority.com/2009/01/09/sql-server-sqlcmd-using-a-dedicated-administrator-connection-to-kill-currently-running-query/): People are judged from their questions and not their answers. I received wonderful question the other day. How sqlcmd can be used along with currently running query script posted on your blog? Please read following two posts before continuing this article as they cover background of this article. SQL SERVER – Interesting Observation – Using sqlcmd From SSMS Query Editor SQL SERVER – Find Currently Running Query – T-SQL If due to a long running query or any resource hogging query SQL Server is not responding sqlcmd can be used to connect to the server from another computer and kill the... - [SQLAuthority News - Author Visit - Mumbai, India - From January 8, 2008 to January 11, 2008](https://blog.sqlauthority.com/2009/01/08/sqlauthority-news-author-visit-mumbai-india-from-january-8-2008-to-january-11-2008/): I will be traveling to Mumbai from From January 8, 2008 to January 11, 2008. If any of readers wants to meet up for cup of coffee in evening leave a comment or send me email and we can arrange something. I will be visiting various places and my access to emails are limited. Regular readers, those who have my phone number can call me at any time. I will post review of my trip to Mumbai once I am back from trip. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Currently Running Query - T-SQL](https://blog.sqlauthority.com/2009/01/07/sql-server-find-currently-running-query-t-sql/): This is the script which I always had in my archive. Following script find out which are the queries running currently on your server. SELECT sqltext.TEXT, req.session_id, req.status, req.command, req.cpu_time, req.total_elapsed_time FROM sys.dm_exec_requests req CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext While running above query if you find any query which is running for long time it can be killed using following command. KILL [session_id] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interesting Observation - Using sqlcmd From SSMS Query Editor](https://blog.sqlauthority.com/2009/01/06/sql-server-interesting-observation-using-sqlcmd-from-ssms-query-editor/): A day before I wrote article SQL SERVER – sqlcmd vs osql – Basic Comparison. Today while I was displaying how sqlcmd can be used instead of osql to one of my companies team leader, I found another neat feature of SSMS Query Editor. sqlcmd can be used from Query Editor but it has to be enabled first. - [SQL SERVER - sqlcmd vs osql - Basic Comparison](https://blog.sqlauthority.com/2009/01/05/sql-server-sqlcmd-vs-osql-basic-comparison/): Today we will go over very simple but to the point comparison of two SQL Server utilities or SQL Server tools. This comes often to users which one to use sqlcmd or osql, when in need of running SQL Server queries from command prompt. Answer to this is very simple use “sqlcmd”. sqlcmd has all the feature which osql has to offer, additionally sqlcmd has many added feature than osql. isql was introduced in earlier versions of SQL Server. osql was introduced in SQL Server 2000 version. sqlcmd is newly added in SQL Server 2005 and offers additionally functionality which SQL... - [SQL SERVER - 2008 - Change Color of Status Bar of SSMS Query Editor](https://blog.sqlauthority.com/2009/01/04/sql-server-2008-change-color-of-status-bar-of-ssms-query-editor/): This is one very interesting issue which I have started to follow recently. Just like any other organization my company has many servers. Some are production and some are development. It is very much necessary that query which are written for developer environment does not run for production environment accidentally. In SQL Server 2008 there is special feature which can change the color of the task bar. This will alert developer to run query on server. Let us see quick tutorial with images which explains how the color of the status bar in SQL Server management studio can be changed. Another... - [SQL SERVER - Time Delay While Running T-SQL Query - WAITFOR Introduction](https://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/): Today we will look at one very small but interesting feature of SQL Server. Please note that this is not much known feature of SQL Server. In SQL Server sometime there are requirement when T-SQL script has to wait for some time before executing next statement. It is quite common that developers depends on application to take over this delay issue. However, SQL Server itself has very strong time management function of WAITFOR. Let us see two usage of WAITFOR clause. Official explanation of WAITFOR clause from Book Online is “Blocks the execution of a batch, stored procedure, or transaction until... - [SQL SERVER - 2008 - 2005 - Find Longest Running Query - TSQL](https://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/): UPDATE : Updated this query with bug fixed with one more enhancement SERVER – 2008 – 2005 – Find Longest Running Query – TSQL – Part 2. Recently my company owner asked me to find which query is running longest. It was very interesting that I was not able to find any T-SQL script online which can give me this data directly. Finally, I wrote down very quick script which gives me T-SQL which has ran on server along with average time and maximum time of that T-SQL execution. As I keep on writing I needed to know when exactly logging was started for the same T-SQL so I had added Logging start time in the query as well. - [SQLAuthority News - Happy New Year - 5 SQL New Year Resolutions](https://blog.sqlauthority.com/2009/01/01/sqlauthority-news-happy-new-year-5-sql-new-year-resolutions/): Happy New Year to All of YOU! Let us start year 2009 with word of wisdom from Albert Einstein. I feel that you are justified in looking into the future with true assurance, because you have a mode of living in which we find the joy of life and the joy of work harmoniously combined. Added to this is the spirit of ambition which pervades your very being, and seems to make the day’s work like a happy child at play. – Albert Einstein “May this new year all your dreams turn into reality and all your efforts into great achievements.”... - [SQLAuthority News - Recap Year 2008 - Two Most Important Event of My Life](https://blog.sqlauthority.com/2008/12/31/sqlauthority-news-recap-year-2008-two-most-important-event-of-my-life/): Year 2008 is about to complete in next few hours. It was one of the most interesting year for me in my life. There were so many things happened and fortunately all of them are good. If I have to list events special to me in year 2008 there can be many, I will list two most important events of my life in year 2008. I am awarded as SQL Server MVP by Microsoft I am very thankful to Microsoft to recognize my talent as SQL Server Expert and Community Leader. I had great fun this year when I visited MVP... - [SQLAuthority Author Visit Report - Tech Meetings - Recession - Job Market - Consolidation of Servers](https://blog.sqlauthority.com/2008/12/30/sqlauthority-author-visit-report-tech-meetings-recession-job-market-consolidation-of-servers/): In this blog post, I will discuss various topics which are related to various DBAs and Developers discussed in the recent market. - [SQL SERVER - 2008 - Certification Path Complete Download PDF](https://blog.sqlauthority.com/2008/12/29/sql-server-2008-certification-path-complete-download-pdf/): Microsoft Certification are very important for any developer’s career. I personally have acquired MS certification before and while practicing for MS Certification I learned a lot personally. Developers who are interesting in upgrading themselves with Microsoft Certification must download certification path PDF. - [SQL SERVER - Fix : Msg 15151, Level 16, State 1, Line 3 Cannot drop the login 'test', because it does not exist or you do not have permission](https://blog.sqlauthority.com/2008/12/28/sql-server-fix-msg-15151-level-16-state-1-line-3-cannot-drop-the-login-test-because-it-does-not-exist-or-you-do-not-have-permission/): I got following error when I was trying to delete user ‘test’ with ‘SA’ login. I was little surprised but then I tried to delete with the windows authenticated systemadmin account. Once again I got the same error. Msg 15151, Level 16, State 1, Line 3 Cannot drop the login ‘test’, because it does not exist or you do not have permission. The reason I was surprised that I was systemadmin and I should be allowed to delete the login. I am including the script which I used to delete the account here. IF EXISTS (SELECT * FROM sys.server_principals WHERE name =... - [SQL SERVER - Add Any User to SysAdmin Role - Add Users to System Roles](https://blog.sqlauthority.com/2008/12/27/sql-server-add-any-user-to-sysadmin-role-add-users-to-system-roles/): The reason I like blogging is follow up questions. I have wrote following two articles earlier this week. I just received question based on both of them. Before I go on questions, I recommend to read both of the article first. Both of them are very small article so they are quick to read. - [SQL SERVER - Fix : Error : Msg 15151, Level 16, State 1, Line 2 Cannot alter the login 'sa', because it does not exist or you do not have permission](https://blog.sqlauthority.com/2008/12/26/sql-server-fix-error-msg-15151-level-16-state-1-line-2-cannot-alter-the-login-sa-because-it-does-not-exist-or-you-do-not-have-permission/): Few days ago, I have wrote about SQL SERVER – DISABLE and ENABLE user SA I received following email from one of the user who received following error. Msg 15151, Level 16, State 1, Line 2 Cannot alter the login ‘sa’, because it does not exist or you do not have permission. Fix/Workaround/Solution: This error had occurred because of insufficient rights. Please read my previous post here before reading further article. SA is system admin user and it is the highest level of user in system. If any user have to modify the permissions of SA that user needs to have... - [SQLAuthority Author Visit - Valsad, Daman, Silvassa, Vapi - Tech Meetings](https://blog.sqlauthority.com/2008/12/25/sqlauthority-author-visit-valsad-daman-silvassa-vapi-tech-meetings/): I am currently traveling to South Gujarat doing Tech Meetings with leading organizations. Following is my tour schedule. Valsad – December 25, 2008 Daman – December 26, 2008 Silvassa – December 27, 2008 Vapi – December 28, 2008 I will be visiting some of the local IT industries and User Groups. If any of the readers who wants to meet me there can contact me by email. I will be bringing my new DELL XPS 1530 (wireless enabled) along with me so I will reply quickly. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Merry Christmas - Search SQLAuthority](https://blog.sqlauthority.com/2008/12/25/sqlauthority-news-merry-christmas-search-sqlauthority/): Merry Christmas and a prosperous New Year. Thanks for the love and support you give me. I pray to the god that recession will be over soon around the world and everybody is happy. I have been receiving increasing emails for asking question about where is the Search on SQLAuthority.com blog. I have created custom search engine using Google which exclusively searches into SQLAuthority and if needed in the web. If you have not tried SQLAuthority.com search before I suggest you give it a show as this surely improves the experience with this blog. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DISABLE and ENABLE user SA](https://blog.sqlauthority.com/2008/12/24/sql-server-disable-and-enable-user-sa/): Just a day ago, I received question from blog reader Mike McDonald. “How can I modify permissions for SA user? I tried to modify dbo users permission but now I am having problems.” First of all, there may be no relation between dbo user and SA user. They are different and should be left separate. Modifying the permission of SA user is not possible. However, SA can be disable or enabled using following script. Make sure that you are logged in using windows authentication account. /* Disable SA Login */ ALTER LOGIN [sa] DISABLE GO /* Enable SA Login */ ALTER LOGIN [sa] ENABLE GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Download Copy of Developer Edition for Free Is Myth](https://blog.sqlauthority.com/2008/12/23/sql-server-2008-download-copy-of-developer-edition-for-free-is-myth/): It is quite common myth that SQL Server 2008 Developer Edition is FREE. SQL Server 2008 developer edition has same code base and same features which are available in SQL Server 2008 enterprise edition. Only difference between them is licensing terms. Developer Edition can not be used in production environment and it can be used on development server only. I have received quite a lots of emails how this can be downloaded for free. First of this version is not free. It is available for $50 to download. However, those developer who are really looking for free edition of SQL Server... - [SQL SERVER - Find Next Running Time of Scheduled Job Using T-SQL](https://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/): I often receive a good question on the blog, however, I do not always receive a good answer for the questions. Recently someone asked on a blog about Finding next run time for Schedule Job using T-SQL. My friend came up with a nice script. I have modified it a bit to adjust needs. This blog post is about finding the next running time of scheduled job using T-SQL.  - [SQLAuthority News - SQL Server Related Downloads from Microsoft](https://blog.sqlauthority.com/2008/12/21/sqlauthority-news-sql-server-related-downloads-from-microsoft/): Feature Pack for SQL Server 2005 December 2008 Download the December 2008 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. Microsoft SQL Server Protocol Documentation The Microsoft SQL Server protocol documentation provides technical specifications for Microsoft proprietary protocols that are implemented and used in Microsoft SQL Server 2008. SQL Server 2005 Express Edition with Advanced Services SP3 Microsoft SQL Server 2005 Express Edition with Advanced Services is a free, easy-to use version of SQL Server Express that includes more features and makes it easier than ever to start... - [SQL SERVER - Change Collation of Database Column - T-SQL Script](https://blog.sqlauthority.com/2008/12/20/sql-server-change-collation-of-database-column-t-sql-script/): Just a day before I wrote about SQL SERVER – Find Collation of Database and Table Column Using T-SQL and I have received some good comments and one particular question was about how to change collation of database. It is quite simple do so. Let us see following example. USE AdventureWorks GO /* Create Test Table */ CREATE TABLE TestTable (FirstCol VARCHAR(10)) GO /* Check Database Column Collation */ SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN ( SELECT OBJECT_ID FROM sys.objects WHERE type = 'U' AND name = 'TestTable') GO /* Change the database collation */ ALTER TABLE TestTable ALTER COLUMN FirstCol VARCHAR(10) COLLATE SQL_Latin1_General_CP1_CS_AS NULL GO /* Check Database Column Collation */ SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN ( SELECT... - [SQLAuthority News - Download - SQL Server 2005 Books Online (December 2008)](https://blog.sqlauthority.com/2008/12/19/sqlauthority-news-download-sql-server-2005-books-online-december-2008/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The December 2008 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the December 2008 update, SQL Server 2005 Books Online includes documentation updates for... - [SQLAuthority News - Download Microsoft SQL Server 2005 Service Pack 3](https://blog.sqlauthority.com/2008/12/18/sqlauthority-news-download-microsoft-sql-server-2005-service-pack-3/): Service Pack 3 for Microsoft SQL Server 2005 is now available. SQL Server 2005 service packs are cumulative, and this service pack upgrades all service levels of SQL Server 2005 to SP3. You can use these packages to upgrade any of the following SQL Server 2005 editions: Enterprise Enterprise Evaluation Developer Standard Workgroup Download Service Pack 3 for Microsoft SQL Server 2005 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interesting Interview Questions - Revisited](https://blog.sqlauthority.com/2008/12/17/sql-server-interesting-interview-questions-revisited/): I really enjoyed users participation in my previous question. Read SQL SERVER – Interesting Interview Questions before continuing reading this article. This interview question was about user participation and about how good and how different you can come with your T-SQL script. What I really liked is that many users took this test seriously and did their best to answer. I really want to congratulate all the readers who have attempted to answer this question. As I have said earlier it did not matter what is the database structure, but it mattered what should be the good database architecture design. Here... - [SQL SERVER - Find Collation of Database and Table Column Using T-SQL](https://blog.sqlauthority.com/2008/12/16/sql-server-find-collation-of-database-and-table-column-using-t-sql/): Today we will go over very quick tip about finding out collation of database and table column. Collations specify the rules for how strings of character data are sorted and compared, based on the norms of particular languages and locales Today’s script are self explanatory so I will not explain it much. /* Find Collation of SQL Server Database */ SELECT DATABASEPROPERTYEX('AdventureWorks', 'Collation') GO /* Find Collation of SQL Server Database Table Column */ USE AdventureWorks GO SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN (SELECT OBJECT_ID FROM sys.objects WHERE type = 'U' AND name = 'Address') AND name = 'City' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Wedding Day of Author - Photographs - Mr. and Mrs. SQLAuthority](https://blog.sqlauthority.com/2008/12/15/sqlauthority-news-wedding-day-of-author-photographs/): On December 12, 2008 I had posted a note on blog when I completed 800th Article on this blog. The same day was also my wedding day. Read more about the same here SQLAuthority News – Wedding Day of Author. Thank you very much for your wishes and wonderful emails. I have received many emails and I have replied almost all of them with thank you note. Almost all of them have requested to send photographs of my wedding day. I have shared few of the photographs here. Those who were present at the occasion and want their own personal copy... - [SQL SERVER - Connect using Enterprise Manager to SQL Server 2005/2008](https://blog.sqlauthority.com/2008/12/14/sql-server-connect-using-enterprise-manager-to-sql-server-20052008/): I received the following email from Mike Bikinis. about enterprise manager. "How can I connect to SQL Server 2005 or SQL Server 2008 using SQL Server 2000's Enterprise Manager?" - [SQL SERVER - Email from Blog Reader - Not a Potential Bug in SQL - Puzzle](https://blog.sqlauthority.com/2008/12/13/sql-server-interesting-email-from-blog-reader-puzzle/): Few days ago, I received wonderful email from blog reader and it was like good puzzle. I enjoyed solving this puzzle. I did not write the name of the blog reader because I am not sure if he wants his name here or not. Please read this article and run the script described in email. You can download the SQL Script here. Also can any of you help this reader why SQL Server is behaving like this. I have already replied him with correct answer where I suggest that it is not bug and have explained him the reason for the... - [SQLAuthority News - Wedding Day of Author - 800th Article of Blog](https://blog.sqlauthority.com/2008/12/12/sqlauthority-news-wedding-day-of-author-800th-article-of-blog/): Today is big day for me. I am getting married today. Wedding is just one hour away and I am writing this article. I will post more information tomorrow about this event of my life. While assigning categories to this article, I laughed when I selected “SQLAuthority Author Visit” tag. The way I receive one question repetitively “What are the differences between SQL Server 2008 Standard and Enterprise Edition?”, I think Microsoft receives the same question again and again so they have created PDF answering the same question. Download SQL Server 2008 Enterprise and Standard Feature Compare. In November 2008 I... - [SQL SERVER - Interesting Interview Questions - Part 2 - Puzzle - Solution](https://blog.sqlauthority.com/2008/12/11/sql-server-interesting-interview-questions-part-2-puzzle-solution/): Yesterday we looked at Puzzle and I did got great response to this question. Very interestingly not many got it right. First go through the puzzle first and then come back here and read answer. Read Original Interview Question and Puzzle. Question: Select all the person from table PersonColor who have same color as ColorCode or have more colors than table ColorCode. UPDATE: Following solution is written with assumption that in SelectedColors table Name and ColorCode are Primary Key. This requirement was not specified in original question. /*Answer to Interview Question*/ SELECT Name FROM PersonColors pc INNER JOIN SelectedColors sc ON sc.ColorCode = pc.ColorCode GROUP BY pc.Name HAVING... - [SQLAuthority News - SQL SERVER 2008 Upgrade Technical Reference Guide Download](https://blog.sqlauthority.com/2008/12/11/sqlauthority-news-sql-server-2008-upgrade-technical-reference-guide-download/): Note:   SQL SERVER 2008 Upgrade Technical Reference Guide Download by Microsoft This 490-page document covers the essential phases and steps to upgrade existing instances of SQL Server 2000 and 2005 to SQL Server 2008 by using best practices. These include preparation tasks, upgrade tasks, and post-upgrade tasks. It is intended to be a supplement to SQL Server 2008 Books Online. A successful upgrade to SQL Server 2008 should be smooth and trouble-free. To achieve that smooth transition, you must devote plan sufficiently for the upgrade, and match the complexity of your database application. Otherwise, you risk costly and stressful errors and... - [SQL SERVER - Top 10 SQL Server 2008 Features for Independent Software Vendor Applications](https://blog.sqlauthority.com/2008/12/10/sql-server-2008-top-10-sql-server-2008-features-for-independent-software-vendor-applications/): Microsoft SQL Server 2008 has hundreds of new and improved features, many of which are specifically designed for large scale independent software vendor (ISV) applications, which need to leverage the power of the underlying database while keeping their code database agnostic. This article presents details of the top 10 features that we believe are most applicable to such applications based on our work with strategic ISV partners. Along with the description of each feature, the main pain-points the feature helps resolve and some of the important limitations that need to be considered are also presented. - [SQL SERVER - Interesting Interview Questions - Part 2 - Puzzle](https://blog.sqlauthority.com/2008/12/10/sql-server-interesting-interview-questions-part-2-puzzle/): In the recent time of recession my company is able to continue its progress and we are hiring. It is very surprising to me that many developers who have experience with SQL Server could not get following simple question right. There were nearly 40 candidates I interviewed but none of the candidate was able to solve this problem. When I displayed final answer they could not believe that it is that simple. When I asked some of the MCITP or Oracle certified candidate about why they can not get this simple question, they smiled and answered that I did not have... - [SQL SERVER - Find Table Row Count Without Using T-SQL and Without Opening Table](https://blog.sqlauthority.com/2008/12/09/sql-server-find-table-rowcount-without-using-t-sql-and-without-opening-table/): Recently I have been busy with interviewing many candidates for my organization. We are looking for some smart and experienced developers for some senior positions. I have wrote this previously SQL SERVER - Interesting Interview Questions. This blog post is about finding a table row count without using T-SQL. - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2008/12/08/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-2/): Note:   Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Note: Scripts in the SQL Server 2008 management pack rely on SQL Data Management Objects (SQL-DMO) to query information from the SQL Server. SQL-DMO is now deprecated and is not shipped as a part of... - [SQLAuthority News - Author Photographs Updated](https://blog.sqlauthority.com/2008/12/08/sqlauthority-news-author-photographs-updated/): I have received many emails about one of page in on personal site – Photos. I have updated all but one photo on my photo web page. There are new photos of my User Group Presentation and MVP activities. Visit my new photos page Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interview Questions - Difficult SQL Puzzle](https://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/): Today at my organization, we had nearly 30 interviews scheduled of DBA and .NET developers. Let us see a difficult SQL puzzle. - [SQLAuthority News - 10 Motivational Quotes from Technologiest of the Past](https://blog.sqlauthority.com/2008/12/06/sqlauthority-news-10-motivational-quotes-technologiest-past/): Once in a while it is a good idea to read what the greatest technologies of the past said about their time as well as the future. This is the running list of the motivational quotes which I have liked so far from various technologies. Please feel free to add yours as well. One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. – Elbert Hubbard - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/12/05/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008-2/): Ahmedabad SQL Server User Group Meeting was organized on November 29, 2008 at famous C.G. Road in Ahmedabad. We had great response and wonderful back to back technical sessions. The highlight of whole meeting was participation of UG President Jacob Sebastian – SQL MVP from New York. Meeting started with introduction and welcome to all the members from SQL Server MVP – Pinal Daveand followed by technical session of “SQL Server 2008 – Backup and Compression” by Pinal Dave. This session was very special because not every database user is aware of the special feature of SQL Server 2008 and how... - [SQL SERVER - Microsoft SQL Server 2008 Enterprise Evaluation: Trial Experience for IT Professionals / Developers](https://blog.sqlauthority.com/2008/12/04/sql-server-microsoft-sql-server-2008-enterprise-evaluation-trial-experience-for-it-professionals-developers/): Download SQL Server 2008 180-day Trial Software. Microsoft SQL Server 2008 is a database platform for large-scale online transaction processing (OLTP), data warehousing, and e-commerce applications; it is also a business intelligence platform for data analysis and reporting solutions. SQL Server 2008 is a trusted, productive, and intelligent data platform for all your data needs. SQL Server 2008 delivers on Microsoft’s Data Platform vision by helping your organization manage any data, any place, any time. It enables you to store structured, semi-structured, and unstructured data, such as documents, images and music, directly in the database. SQL Server 2008 delivers a rich... - [SQL SERVER - Default Collation of SQL Server 2008](https://blog.sqlauthority.com/2008/12/03/sql-server-default-collation-of-sql-server-2008/): Recently I wrote article about SQL SERVER – 2008 – Install SQL Server 2008 – How to Upgrade to SQL Server 2008 – Installation Tutorial, I received couple of comment suggesting that I did not talk about SQL Server default collation setting or how to change default collation when installing SQL Server 2008. While installing SQL Server 2008 on Server Configuration setting select “Collation” tab. It will bring up setting displayed in following image. You can check the default collation of SQL Server as well can change it from the same. SQL Server offers the SQL_Latin1_General_CP1_CI_AS collation as the default collation... - [SQL SERVER - 2008 - Install SQL Server 2008 - How to Upgrade to SQL Server 2008 - Installation Tutorial](https://blog.sqlauthority.com/2008/12/02/sql-server-2008-install-sql-server-2008-how-to-upgrade-to-sql-server-2008-installation-tutorial/): SQL SERVER 2008 RTM has been released for some time and I have got numerous request about how to install SQL Server 2008. I have created this step by step guide Installation Guide. Images are used to explain the process easier. I had previously written the same article earlier. It seemed necessary to re post it again as request of me posting Step by Step tutorial has increased for quite some time. - [SQL SERVER - Roadmap of Microsoft Certifications - SQL Server Certifications](https://blog.sqlauthority.com/2008/12/01/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications/): In these times of economical slowdown, more and more IT professionals are concerned about their jobs and their qualifications. It is a common trend for developers to start looking for ways to update their skills when jobs are not secure. Pure knowledge and real world work experience are always a good way to help secure your future. One way to demonstrate knowledge is by having a certification in the technology one claims to be expert in. Microsoft offers a series of certifications for IT professional and developers. In this article we will cover the following topics. Importance of Certificates Certification Structure... - [SQL SERVER - Interesting Observation - Use of Index and Execution Plan](https://blog.sqlauthority.com/2008/11/30/sql-server-interesting-observation-use-of-index-and-execution-plan/): Previously I wrote article about SQL SERVER – Interesting Observation about Order of Resultset without ORDER BY and I have received tremendous response from my readers by emails and comments. Readers demanded that I should have written little more for the same subject. As I really liked the subject myself very much, I have decided to write more about the same again. Those readers who have not read my previous article, I request them to go over my previous article one time before reading this article as that will give them history. Read my previous article here. Let us see three... - [SQLAuthority News - Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/11/29/sqlauthority-news-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008/): Today is special day for SQL Server enthusiastic as we will have SQL Server User Group Meeting today in Ahmedabad. Today in User Group we will have UG President Jacob Sebastian (MVP) participating from New York and UG Vice President Pinal Dave (MVP) will talk about “How to become MVP?” Agenda for today’s meeting is as following: Agenda: 1) Introduction by Pinal Dave 2) Direct from New York – Live Meeting by Jacob Sebastian– SQL Pass Roundup and Other News 3) Technical Session by Pinal Dave – Compressed Backup and Restore Techniques 4) Technical Session by Tejas Shah – What is... - [SQL Server - Switch Between Result Pan and Query Pan - SQL Shortcut](https://blog.sqlauthority.com/2008/11/28/sql-server-switch-between-result-pan-and-query-pan-sql-shortcut/): Many times when I am writing query I have to scroll the result displayed in the result set. Let us learn about the shortcut today. - [SQLAuthority News - Download Tools and Documentation for SQL SERVER](https://blog.sqlauthority.com/2008/11/27/sqlauthority-news-download-tools-and-documentation-for-sql-server/): SQL Server 2008 Report Definition Language Specification The goal of Report Definition Language (RDL) is to promote the interoperability of commercial reporting products by defining a common schema that allows interchange of report definitions. An important aspect to understand is that RDL is a schema definition, not a programmatic interface or protocol like HTTP or ODBC. RDL does not specify how report definitions are passed between applications or how reports are processed. Also, RDL is meant to be fully encapsulated; meaning that successfully interpreting an RDL document should not require any understanding of the source application. Microsoft Visual Studio Team System... - [SQLAuthority News - Help to Find Recession Proof Job](https://blog.sqlauthority.com/2008/11/26/sqlauthority-news-help-to-find-recession-proof-job/): Recently I have been receiving a lot of emails from employees asking where they can find good employee. I was under impression that due to global recession job market is down but from looking at recent increase in emails for looking for right candidate I have to say that there are good jobs still out there. There are few jobs in market which are recession proof. There are few decisions one has to make when their job is at risk. Use the website created by SQLAuthority.com for finding right job and right candidate. Click here to go to find right job... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/11/25/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008/): It is time again to announce SQL Hour – SQL Server User Group Meeting for November 2008. This time it is going to be one really interesting event. Our User Group is growing and getting more interesting. Lots of new SQL Server enthusiastic have contacted me recently for User Group meeting. It is the time for all the SQL Server developers to meet again for SQL Hour. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my article here where... - [SQL SERVER - Interesting Observation about Order of Resultset without ORDER BY](https://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/): Today I observed very interesting little thing about SQL Server and I felt that I should share this with my readers. I ran following two queries and found that I am getting different result-set. When I carefully observed I found that actually the result was same but order of the records returned is different. USE AdventureWorks GO SELECT ContactID FROM Person.Contact GO SELECT * FROM Person.Contact GO This particular thing interested me. I knew that when “ORDER BY” is not used order of the table is not guaranteed but I was not able to reproduce simple example for the same. Every... - [SQL SERVER - 2008 - Download and Install Sample Database AdventureWorks 2008](https://blog.sqlauthority.com/2008/11/23/sql-server-2008-download-and-install-samples-database-adventureworks-2008/): The following sample database is currently available for Microsoft SQL Server 2005 and Microsoft SQL Server 2008: - [SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database Including Schema](https://blog.sqlauthority.com/2008/11/22/sql-server-simple-use-of-cursor-to-print-all-stored-procedures-of-database-including-schema/): I love active participation from my readers. Just a day ago I wrote article about SQL SERVER – Simple Use of Cursor to Print All Stored Procedures of Database. I just received comment from Jerry Hung who have improved on previously written article of generating text of Stored Procedure. DECLARE @procName VARCHAR(100) DECLARE @getprocName CURSOR SET @getprocName = CURSOR FOR SELECT Name = '[' + SCHEMA_NAME(SCHEMA_ID) + '].[' + Name + ']' FROM sys.all_objects WHERE TYPE = 'P' AND is_ms_shipped 1 OPEN @getprocName FETCH NEXT FROM @getprocName INTO @procName WHILE @@FETCH_STATUS = 0 BEGIN PRINT 'sp_HelpText ' + @procName EXEC sp_HelpText @procName FETCH NEXT FROM @getprocName... - [SQLAuthority News - SQL Server White Paper: SQL Server 2008 Compliance Guide](https://blog.sqlauthority.com/2008/11/21/sqlauthority-news-sql-server-white-paper-sql-server-2008-compliance-guide/): Note: Download White Paper by Microsoft Organizations across the globe are being inundated with regulatory requirements. They also have a strong need to better manage their IT systems to ensure they are operating efficiently and staying secure. Microsoft is often asked to provide guidance and technology to assist organizations struggling with compliance. The SQL Server 2008 Compliance Guidance white paper was written to help organizations and individuals understand how to use the features of the Microsoft SQL Server 2008 database software to address their compliance needs. This paper serves as an accompaniment to the SQL Server 2008 compliance software development kit... - [SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database](https://blog.sqlauthority.com/2008/11/20/sql-server-simple-use-of-cursor-to-print-all-stored-procedures-of-database/): SQLAuthority Blog reader YordanGeorgiev has submitted very interesting SP, which uses cursor to generate text of all the Stored Procedure of current Database. This task can be done many ways, however, this is also interesting method. USE AdventureWorks GO DECLARE @procName VARCHAR(100) DECLARE @getprocName CURSOR SET @getprocName = CURSOR FOR SELECT s.name FROM sysobjects s WHERE type = 'P' OPEN @getprocName FETCH NEXT FROM @getprocName INTO @procName WHILE @@FETCH_STATUS = 0 BEGIN EXEC sp_HelpText @procName FETCH NEXT FROM @getprocName INTO @procName END CLOSE @getprocName DEALLOCATE @getprocName GO Just give this script a try and it will print text of all the SP in your... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Group Photo](https://blog.sqlauthority.com/2008/11/19/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-group-photo/): MVP Open day 2008 is one of the best event happened so far. I have previously written about this event in detail on this blog. - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 3](https://blog.sqlauthority.com/2008/11/18/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-3/): Yesterday was our last day at South Asia MVP Open Day. For three days continuously we are having great time along with fellow MVP. Every MVP was having great time because the way whole event was planned. We had plenty of time for networking as well lots of interesting sessions were going on. Most of the MVPs had slept late the day before because everybody was preparing their presentation for community buzz. The day before we had wonderful Open Space sessions at Midnight. The most avaited sessions was Nitin Paranjape – Do’s and Dont’s of being an entrepreneur (Monetizing your expertise).... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 2](https://blog.sqlauthority.com/2008/11/17/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-2/): At MVP Open Day we were promised that we will have 8 to 8 action packed day but we all observed much longer hours where we all MVP’s were busy with activity. I will say instead of 8 AM to 8 PM we actually had fun from 8 AM to 2 AM (next day). Day 2 at MVP Open day was filled with technical sessions followed by River Cruise and Dance party at Casino. On day 2 we had team photo, as I was part of team photo I could not take this photo myself. I will request Abhishek Kant to... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 1](https://blog.sqlauthority.com/2008/11/16/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-1/): It is great fun! Perfect Event and Great start. Yesterday I wrote about agenda of South Asia MVP Open Day 2008 which is at Hotel Kenilworth Resorts, Goa. November 15 – Day 1 of Open Day started with plain journey and ended with Goan Team Party at beach with fellow MVP. I have more than hundreds of the photos of this event. I will share few of the them with you. First of all let me thank three four people, without their support this event might have not possible. Howard Lo – Microsoft, Singapore – Regional Manager, Asia Pacific and Greater... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Link List](https://blog.sqlauthority.com/2008/11/15/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-link-list/): Today is very exciting day as I will start my trip to South Asia MVP Open Day 2008 – Goa. Yesterday I wrote about my visit. I will be attending South Asia MVP Open Day 2008 on November 15 – 17, 2008 at Hotel Kenilworth Resorts, Goa. Those who have asked how can they meet me in Goa is that you will have to send me email and I will respond to them. At this moment I have reached goa and writing using my new USB Data Card internet. I will post more photos and event details as I receive them.... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa](https://blog.sqlauthority.com/2008/11/14/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa/): I will be attending South Asia MVP Open Day 2008 on November 15 – 17, 2008 at Hotel Kenilworth Resorts, Goa. I am very excited as this will be my first Open Day event after being MVP. Microsoft Most Valuable Professionals (MVPs) are exceptional technical community leaders from around the world who are awarded for voluntarily sharing their high quality, real world expertise in offline and online technical communities. Microsoft MVPs are a highly select group of experts that represents the technical community’s best and brightest, and they share a deep commitment to community and a willingness to help others. There... - [SQLAuthority News - RML Utilities - Usage and Additional Help](https://blog.sqlauthority.com/2008/11/13/sqlauthority-news-rml-utilities-usage-and-additional-help/): Yesterday I wrote about SQLAuthority News – Download RML Utilities for SQL Server. I received many emails where different developers requested how to find additional help regarding RML Utilities. Few users reported that they are not able to install RML Utilities because of some reporting service pre-requisite. If RML Utilities are not being installed due to pre-requisite, install Microsoft Report Viewer 2008 SP1 Redistributable and then try to install RML Utilities. If there is need of additional help once RML Utilities are installed click on Start >> All Programs >> RML Utilities for SQL Server >> Help >> RML Help. Once... - [SQLAuthority News - Download RML Utilities for SQL Server](https://blog.sqlauthority.com/2008/11/12/sqlauthority-news-download-rml-utilities-for-sql-server/): Note:   Download RML Utilities for SQL Server by Microsoft The RML utilities allow you to process SQL Server trace files and view reports showing how SQL Server is performing. For example, you can quickly see: Which application, database or login is using the most resources, and which queries are responsible for that Whether there were any plan changes for a batch during the time when the trace was captured and how each of those plans performed What queries are running slower in today’s data compared to a previous set of data You can also test how the system will behave with... - [SQL SERVER - Delete Backup History - Cleanup Backup History](https://blog.sqlauthority.com/2008/11/11/sql-server-delete-backup-history-cleanup-backup-history/): SQL Server stores history of all the taken backup forever. History of all the backup is stored in msdb database. Many times older history is no more required. Following Stored Procedure can be executed with parameter which takes days of history to keep. In following example 30 is passed to keep history of month. USE msdb GO DECLARE @DaysToKeepHistory DATETIME SET @DaysToKeepHistory = CONVERT(VARCHAR(10), DATEADD(dd, -30, GETDATE()), 101) EXEC sp_delete_backuphistory @DaysToKeepHistory GO Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Check Database Integrity for All Databases of Server - DBCC CHECKDB](https://blog.sqlauthority.com/2008/11/10/sql-server-check-database-integrity-for-all-databases-of-server/): Today we will see quick script which will check integrity of all the databases of SQL Server. We will learn about DBCC CHECKDB in this blog post.  - [SQLAuthority News - SQL Server 2008 Book Online Updated in October 2008](https://blog.sqlauthority.com/2008/11/09/sqlauthority-news-sql-server-2008-book-online-updated-in-october-2008/): SQL Server 2008 Books Online is updated on 31 October 2008. I always bookmark latest BOL for my easy reference. Getting Started: New and Updated Topics (31 October 2008) Analysis Services – Multidimensional Data: New and Updated Topics (31 October 2008) Database Engine: New and Updated Topics (31 October 2008) Integration Services: New and Updated Topics (31 October 2008) Analysis Services – Data Mining: New and Updated Topics (31 October 2008) Reporting Services: New and Updated Topics (31 October 2008) Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER 2008 - Connect Visual Studio 2005 Patch Download](https://blog.sqlauthority.com/2008/11/08/sql-server-2008-connect-visual-studio-2005-patch-download/): It was not possible to connect SQL Server 2008 to Visual Studio 2005 so far. Microsoft has released Service Pack once it is installed SQL Server 2008. - [SQL SERVER - Refresh Database Using T-SQL](https://blog.sqlauthority.com/2008/11/07/sql-server-refresh-database-using-t-sql/): Yesterday I received following questions on blog. Ashish Agarwal asked following question. Hi Pinal, Can we refresh a database (like we do by right clicking database node in object explorer and clicking on refresh) thru SQL Query? If yes, can you please tell me the query? Thanks, Ashish Agarwal Answer to above question is NO. It is not possible to do the same task using SQL Query. However, if you have changed some SP or any other object and if they are cached in the database, database can be refreshed using DBCC commands. Read my previous article about SQL SERVER –... - [SQLAuthority News - 5 Millions Visitors - 2 Anniversary - Authors Note on Economy Slow Down and Job Opportunity - SQL Server](https://blog.sqlauthority.com/2008/11/06/sqlauthority-news-5-millions-visitors-2-anniversary-authors-note-on-economy-slow-down-and-job-opportunity-sql-server/): I just received the following screen shot from one of the regular readers of the SQLAuthority.com blog. He pointed out important milestone for our blog. We have crossed 5 million visitors. In less than 2 years SQLAuthority.com blog has been visited by 5 million visitors. I even missed the anniversary our blog. On November 1st, 2008 SQLAuthority.com has completed 2 years of its existence and now continuing in 3rd year. - [SQL SERVER - 2008 - Server Consolidation WhitePaper Download](https://blog.sqlauthority.com/2007/10/28/sql-server-2008-server-consolidation-whitepaper-download/): Server Consolidation with SQL Server 2008 Writer: Martin Ellis Reviewer: Prem Mehra,Lindsey Allen, Tiffany Wissner, Sambit Samal Published: March 2009 Microsoft SQL Server 2008 supports multiple options for server consolidation, which provides organizations with the flexibility to choose the consolidation approach that best meets their requirements to centralize data services management and reduce hardware and maintenance costs. By providing centralized management, auditing, and monitoring capabilities, SQL Server 2008 makes it easy to manage multiple databases and data services, which significantly reduces administrative overheads in large enterprises. Finally, SQL Server 2008 provides the reassurance of industry-leading performance and scalability, and unprecedented control... - [SQL SERVER - 2005 - Get Current User - Get Logged In User](https://blog.sqlauthority.com/2007/10/27/sql-server-2005-get-current-user-get-logged-in-user/): Interesting enough Jr. DBA asked me how he can get current user for any particular query is ran. He said he wants it for debugging purpose as well for security purpose. I totally understand the need of this request. Knowing the current user can be extremely helpful in terms of security. To get current user run following script in Query Editor SELECT SYSTEM_USER SYSTEM_USER will return current user. From Book On-Line – SYSTEM_USER returns the name of the currently executing context. If the EXECUTE AS statement has been used to switch context, SYSTEM_USER returns the name of the impersonated context. Reference... - [SQL SERVER - Deterministic Functions and Nondeterministic Functions](https://blog.sqlauthority.com/2007/10/26/sql-server-deterministic-functions-and-nondeterministic-functions/): Deterministic functions always returns the same output result all the time it is executed for same input values. i.e. ABS, DATEDIFF, ISNULL etc. Nondeterministic functions may return different results each time they are executed. i.e. NEWID, RAND, @@CPU_BUSY etc. Functions that call extended stored procedures are nondeterministic. User-defined functions that create side effects on the database are not recommended. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Forced Parameterization and Simple Parameterization - T-SQL and SSMS](https://blog.sqlauthority.com/2007/10/25/sql-server-2005-forced-parameterization-and-simple-parameterization-t-sql-and-ssms/): SQL Server compiles query and saves the procedures cache plans in the database. When the same query is called it uses compiled execution plan which improves the performance by saving compilation time. Queries which are parametrized requires less recompilation and dynamically built queries needs compilations and recompilation very frequently. Forced parameterization may improve the performance of certain databases by reducing the frequency of query compilations and recompilations. Database which has high volumes of the queries can be most benefited from this feature. When the PARAMETERIZATION option is set to FORCED, any literal value that appears in a SELECT, INSERT, UPDATE or... - [SQL SERVER - Simple Example of WHILE Loop With CONTINUE and BREAK Keywords](https://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/): I have tried to explain the usage of simple WHILE loop in the first example. BREAK keywords will exit the stop the while loop and control is moved. - [SQL SERVER - Get Permissions of My Username / Userlogin on Server / Database](https://blog.sqlauthority.com/2007/10/23/sql-server-get-permissions-of-my-username-userlogin-on-server-database/): A few days ago, I was invited to one of the largest database company. I was asked to review database schema and propose changes to it. There was special username or user logic was created for me, so I can review their database. I was very much interested to know what kind of permissions I was assigned per server level and database level. I did not feel like asking their Sr. DBA the question about permissions. - [SQL SERVER - Difference Between @@Version and xp_msver - Retrieve SQL Server Information](https://blog.sqlauthority.com/2007/10/22/sql-server-difference-between-version-and-xp_msver-retrieve-sql-server-information/): Just a day ago, I was asked which SQL Server version I am using. I said SQL Server 2005. However, the person I was talking was looking for more information then that. He requested more detail about the version. I responded with SQL Server 2005 Service Pack 2. After the discussion was over I thought there must be some global variable which brings back this information. I took guess and typed following command in SQL Query Editor SELECT @@Version 'SQL Version' I was really glad when it worked and returned following result. Resultset: Microsoft SQL Server 2005 – 9.00.3054.00 (Intel X86)... - [SQL SERVER - 2005 - Limitation of Online Index Rebuld Operation](https://blog.sqlauthority.com/2007/10/21/sql-server-2005-limitation-of-online-index-rebuld-operation/): Just a day ago, during one interview question of Online Indexing come up. I really enjoy discussing this issue as I was talking with candidate who was very smart. Following two questions were discussed. 1) What is Online Index Rebuild Operation? Online operation means when online operations are happening the database are in normal operational condition, the processes which are participating in online operations does not require exclusive access to database. Read about this in-depth in my previous article SQL SERVER – 2005 – Explanation and Script for Online Index Operations – Create, Rebuild, Drop 2) What are the limitation of... - [SQL SERVER - Set Server Level FILLFACTOR Using T-SQL Script](https://blog.sqlauthority.com/2007/10/20/sql-server-set-server-level-fillfactor-using-t-sql-script/): As the title is very clear what this post is about I will not write long description. I have listed definition of FILLFACTOR from BOL here. - [SQL SERVER - Types of DBCC Commands When Used as Database Console Commands](https://blog.sqlauthority.com/2007/10/19/sql-server-types-of-dbcc-commands-when-used-as-database-console-commands/): Just a day ago, while discussing some SQL issues with one of the Sr. Database Administrator in India, we end up discussing DBCC as Database Console Commands when used as T-SQL. We both tried to remember what are the types of DBCC as Database Console Commands and could not come up with more than two types, however we both knew there are four. When the conversation was over, I looked up MSDN for the types of the DBCC. I found following documentation here. There are four types of the Database Console Commands. Maintenance Maintenance tasks on a database, index, or filegroup.... - [SQL SERVER - 2005 - Fix : Error : Msg 7411, Level 16, State 1 Server is not configured for RPC](https://blog.sqlauthority.com/2007/10/18/sql-server-2005-fix-error-msg-7411-level-16-state-1-server-is-not-configured-for-rpc/): Error : Msg 7411, Level 16, State 1 Server is not configured for RPC This was annoying error which was fixed by Jr. DBA, whom I am personally training at my organization. I think he is going to be great programmer. He worked in my organization for more than 8 months. I finally have decided to coach him myself. When I encountered this error, I gave him task to figure this out himself. I absolutely gave him no direction and very few min to fix this problem. As you might have guessed without using internet help (as there is no help... - [SQLAuthority News - Book Review - Backup & Recovery (Paperback)](https://blog.sqlauthority.com/2007/10/17/sqlauthority-news-book-review-backup-recovery-paperback/): Backup & Recovery [ILLUSTRATED] (Paperback) by W. Curtis Preston (Author) Link to Amazon Short Summary: This book’s does not only teaches you have to create safe backup but it takes you to the next level where a large organization can save tons of dollars a year by making their backup and restore faster and more reliable process. Detail Summary: Backup and Recovery is the most interesting subject to me. I have always enjoyed reading and writing about this subject. I personally believe that without proper backup and ability to restore the backup to recover the system to original state, any organization... - [SQL SERVER - Three T-SQL Script to Create Primary Keys on Table](https://blog.sqlauthority.com/2007/10/16/sql-server-three-t-sql-script-to-create-primary-keys-on-table/): I have always enjoyed writing about three topics Constraint and Keys, Backup and Restore and Datetime Functions. Primary Keys constraints prevents duplicate values for columns and provides unique identifier to each column, as well it creates clustered index on the columns. -- Primary Key Constraint upon Table Created Method 1 USE AdventureWorks GO CREATE TABLE ConstraintTable (ID INT CONSTRAINT Ct_ID PRIMARY KEY, ColSecond INT) GO --Clean Up DROP TABLE ConstraintTable GO -- Primary Key Constraint upon Table Created Method 2 USE AdventureWorks GO CREATE TABLE ConstraintTable (ID INT, ColSecond INT, CONSTRAINT Ct_ID PRIMARY KEY (ID)) GO --Clean Up DROP TABLE ConstraintTable... - [SQL SERVER - 2005 - Driver for PHP Community Technology Preview (October 2007)](https://blog.sqlauthority.com/2007/10/16/sql-server-2005-driver-for-php-community-technology-preview-october-2007/): In its continued commitment to interoperability, Microsoft has released a new SQL Server 2005 Driver for PHP. The SQL Server 2005 Driver for PHP Community Technology Preview (CTP) download is available to all SQL Server users at no additional charge. The SQL Server 2005 Driver for PHP is a PHP 5 extension that allows for the reading and writing of SQL Server data from within PHP scripts. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2000. How to install driver 1. Download sqlsrv-for-php_version_language.exe to a temporary directory. 2. Run sqlsrv-for-php_version_language.exe.... - [SQL SERVER - Explanation and Understanding NOT NULL Constraint](https://blog.sqlauthority.com/2007/10/15/sql-server-explanation-and-understanding-not-null-constraint/): NOT NULL is integrity CONSTRAINT. It does not allow creating of the row where column contains NULL value. Most discussed question about NULL is what is NULL? I will not go in depth analysis it. Simply put NULL is unknown or missing data. When NULL is present in database columns, it can affect the integrity of the database. I really do not prefer NULL in database unless they are absolutely necessary. (Please make sure it is just my preference, and I use NULL it is absolutely needed). To prevent nulls to be inserted in the database, table should have NOT NULL... - [SQL SERVER - Three Rules to Use UNION](https://blog.sqlauthority.com/2007/10/14/sql-server-three-rules-to-use-union/): I have previously written two articles on UNION and they are quite popular. I was reading SQL book Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes By Ben Forta and I came across three rules of UNION and I felt like mentioning them here. UNION RULES A UNION must be composed of two or more SELECT statements, each separated by the keyword UNION. Each query in a UNION must contain the same columns, expressions, or aggregate functions, and they must be listed in the same order. Column datatypes must be compatible: They need not be the same exact same... - [SQL SERVER - 2005 - SQL Server Surface Area Configuration Tool Examples and Explanation](https://blog.sqlauthority.com/2007/10/13/sql-server-2005-sql-server-surface-area-configuration-tool-examples-and-explanation/): Microsoft has turned off all the potential features of SQL Server 2005 that could be susceptible to security risks and hacker attacks. Many features of SQL Server 2005 i.e. xp_cmdshell, DAC etc comes disabled by default, this makes the vulnerable surface area less visible to potential attacks. The Surface Area Configuration tool provides DBAs with a single, easy-to-use method of configuring external security of SQL Server. Use SQL Server Surface Area Configuration to enable, disable, start, or stop the features, services, and remote connectivity of your SQL Server 2005 installations. You can use SQL Server Surface Area Configuration on local and... - [SQL SERVER - Pre-Code Review Tips - Tips For Enforcing Coding Standards](https://blog.sqlauthority.com/2007/10/12/sql-server-pre-code-review-tips-tips-for-enforcing-coding-standards/): Each organization has its own coding standards and enforcement rules. It is sometime difficult for DBAs to change the code following code review, as it may affect many different layers of the application. In large organizations, many stored procedures are written and modified every day. It is smart to keep watch on all stored procedures, at frequent intervals, before code comes to final code review. Pre-code reviewing in this manner will save lots of time. I run a few scripts every day to check the status of all the stored procedures on our development server. Doing so gives me a good... - [SQL SERVER - T-SQL Script to Add Clustered Primary Key](https://blog.sqlauthority.com/2007/10/11/sql-server-t-sql-script-to-add-clustered-primary-key/): Jr. DBA asked me three times in a day, how to create Clustered Primary Key. I gave him following sample example. That was the last time he asked “How to create Clustered Primary Key to table?” USE [AdventureWorks] GO ALTER TABLE [Sales].[Individual] ADD CONSTRAINT [PK_Individual_CustomerID] PRIMARY KEY CLUSTERED ( [CustomerID] ASC ) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF vs. Stored Procedures and Having vs. WHERE](https://blog.sqlauthority.com/2007/10/10/sql-server-udf-vs-stored-procedures-and-having-vs-where/): Read my First Article in SQL Server Magazine – Oct 2007 [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Sample Example of RANKING Functions - ROW_NUMBER, RANK, DENSE_RANK, NTILE](https://blog.sqlauthority.com/2007/10/09/sql-server-2005-sample-example-of-ranking-functions-row_number-rank-dense_rank-ntile/): I have not written about this subject for long time, as I strongly believe that Book On Line explains this concept very well. SQL Server 2005 has total of 4 ranking function. Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. ROW_NUMBER () OVER ([<partition_by_clause>] <order_by_clause>) Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. RANK () OVER ([<partition_by_clause>] <order_by_clause>) Returns the rank of each row within the partition of a result set. DENSE_RANK () OVER ([<partition_by_clause>]... - [SQL SERVER - 2005 - Connection Property of SQL Server Management Studio SSMS](https://blog.sqlauthority.com/2007/10/08/sql-server-2005-connection-property-of-sql-server-management-studio-ssms/): Following images quickly explain how to connect to SQL Server with different connection property. It can be useful when connection properties need to be changed for SQL Server when connected. I use this in my company when I connect to one of our servers using named pipes instead of TCP/IP. Let us learn about Connection Property of SQL Server Management Studio SSMS. - [SQLAuthority News - Latest Interesting Downloads and Articles](https://blog.sqlauthority.com/2007/10/07/sqlauthority-news-latest-interesting-downloads-and-articles/): White Paper: Precision Considerations for Analysis Services Users This white paper covers accuracy and precision considerations in SQL Server 2005 Analysis Services. For example, it is possible to query Analysis Services with similar queries and obtain two different answers. While this appears to be a bug, it actually is due to the fact that Analysis Services caches query results and the imprecision that is associated with approximate data types. This white paper discusses how these issues manifest themselves, why they occur, and best practices to minimize their effect. Microsoft SQL Server 2005 JDBC Driver 1.1 In its continued commitment to interoperability,... - [SQL SERVER - Executing Remote Stored Procedure - Calling Stored Procedure on Linked Server](https://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure-calling-stored-procedure-on-linked-server/): I was going through comments on various posts to see if I have missed to answer any comments. I realized that there are quite a few times I have answered question which discuss about how to call stored procedure or query on linked server or another server. This is very detailed topic, I will keep it very simple. I am making assumptions that remote server is already set up as linked server with proper permissions in application and network is arranged. Method 1 : Remote Stored Procedure can be called as four part name: Syntax: EXEC [RemoteServer] .DatabaseName.DatabaseOwner.StoredProcedureName ‘Params’ Example: EXEC... - [SQL SERVER - 2005 - Open SSMS From Command Prompt - sqlwb.exe Example](https://blog.sqlauthority.com/2007/10/05/sql-server-2005-open-ssms-from-command-prompt-sqlwbexe-example/): This article is written by request and suggestion of Sr. Web Developer at my organization. Due to nature of this article most of the content are referred from Book On-Line. sqlwb command prompt utility which opens SQL Server Management Studio. sqlwb command does not run queries from command prompt. sqlcmd utility runs queries from command prompt, read for more information. The syntax of this sqlwb is very simple. I will copy complete syntax from BOL here : sqlwb [scriptfile] [projectfile] [solutionfile] [-S servername] [-d databasename] [-U username] [-P password] [-E] [-nosplash] [-?] I use following script very frequently. 1) Open SQL... - [SQL SERVER - 2005 - Different Types of Cache Objects](https://blog.sqlauthority.com/2007/10/04/sql-server-2005-different-types-of-cache-objects/): About two months ago I reviewed book SQL Server 2005 Practical Troubleshooting: The Database Engine. Yesterday I received a request from reader, if I can write something from this book, which is not common knowledge in DBA community. I really like the idea, however I must respect the Authors copyright about this book. This book is unorthodox SQL book, it talks about things which can get you to fix your problem faster, if problem is discussed in book. There are few places it teaches behind the scene SQL stories. - [SQL SERVER - 2005 - Explanation of TRY…CATCH and ERROR Handling With RAISEERROR Function](https://blog.sqlauthority.com/2007/10/03/sql-server-2005-explanation-of-trycatch-and-error-handling-with-raiseerror-function/): One of the developer at my company thought that we can not use RAISEERROR function in new feature of SQL Server 2005 TRY…CATCH. When asked for explanation he suggested SQL SERVER – 2005 Explanation of TRY…CATCH and ERROR Handling article as excuse suggesting that I did not give example of RAISEERROR with TRY…CATCH. We all thought it was funny. Just to keep record straight, TRY…CATCH can sure use RAISEERROR function. First read original article for additional information about how TRY…CATCH works with ERROR codes. SQL SERVER – 2005 Explanation of TRY…CATCH and ERROR Handling Example 1 : Simple TRY…CATCH without RAISEERROR... - [SQL SERVER - Find Name of The SQL Server Instance](https://blog.sqlauthority.com/2007/10/02/sql-server-find-name-of-the-sql-server-instance/): Few days ago, there was complex condition when we had one database on two different server. We were migrating database from one server to another server using nightly backup and restore. Based on database server stored procedures has to run different logic. We came up with two different solutions. 1) When database schema is very much changed, we wrote completely new stored procedure and deprecated older version once it was not needed. 2) When logic depended on Server Name we used global variable @@SERVERNAME. It was very convenient while writing migrating script which depended on server name for the same database.... - [SQL SERVER - 2005 - OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE](https://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/): SQL Server 2005 has new OUTPUT clause, which is quite useful. OUTPUT clause has accesses to inserted and deleted tables (virtual tables) just like triggers. OUTPUT clause can be used to return values to client clause. OUTPUT clause can be used with INSERT, UPDATE, or DELETE to identify the actual rows affected by these statements. OUTPUT clause can generate table variable, a permanent table, or temporary table. Even though, @@Identity will still work in SQL Server 2005, however I find OUTPUT clause very easy and powerful to use. Let us understand OUTPUT clause using example. ———————————————————————————————————————— —-Example 1 : OUTPUT clause... - [SQL SERVER - 2005 Query Editor - Microsoft SQL Server Management Studio](https://blog.sqlauthority.com/2007/09/30/sql-server-2005-query-editor-microsoft-sql-server-management-studio/): This post may be very simple for most of the users of SQL Server 2005. Earlier this year, I have received one question many times – Where is Query Analyzer in SQL Server 2005? I wrote small post about it and pointed many users to that post – SQL SERVER – 2005 Query Analyzer – Microsoft SQL SERVER Management Studio. Recently I have been receiving similar question. Where is Query Editor in SQL Server 2005? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). I have been pointing my users to my... - [SQL SERVER - Two Connections Related Global Variables Explained - @@CONNECTIONS and @@MAX_CONNECTIONS](https://blog.sqlauthority.com/2007/09/29/sql-server-two-connections-related-global-variables-explained-connections-and-max_connections/): Few days ago, I was searching MSDN and I stumbled upon following two global variables. Following variables are very briefly explained in the BOL. I have taken their definition from BOL and modified BOL example to displayed both the global variable together. @@CONNECTIONS Returns the number of attempted connections, either successful or unsuccessful since SQL Server was last started. @@MAX_CONNECTIONS Returns the maximum number of simultaneous user connections allowed on an instance of SQL Server. The number returned is not necessarily the number currently configured. @@MAX_CONNECTIONS is the maximum number of connections allowed simultaneously to the server. @@CONNECTIONS is incremented with... - [SQL SERVER - Introduction and Example for DATEFORMAT Command](https://blog.sqlauthority.com/2007/09/28/sql-server-introduction-and-example-for-dateformat-command/): While doing surprise code review of Jr. DBA I found interesting syntax DATEFORMAT. This keywords is very less used as CONVERT and CAST can do much more than this command. It is still interesting to learn about learn about this new syntax. Sets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data. This command allows you to input strings that would normally not be recognized by SQL server as dates. The SET DATEFORMAT command lets you specify order of data parts. The options for DATEFORMAT are mdy, dmy, ymd, ydm, myd, or dym. The default DATEFORMAT is mdy.... - [SQL SERVER - FIX : Error 3154: The backup set holds a backup of a database other than the existing database](https://blog.sqlauthority.com/2007/09/27/sql-server-fix-error-3154-the-backup-set-holds-a-backup-of-a-database-other-than-the-existing-database/): Our Jr. DBA ran to me with this error just a few days ago while restoring the database. Error 3154: The backup set holds a backup of a database other than the existing database. Solution is very simple and not as difficult as he was thinking. He was trying to restore the database on another existing active database. Fix/WorkAround/Solution: 1) Use WITH REPLACE while using the RESTORE command. View Example 2) Delete the older database which is conflicting and restore again using RESTORE command. I understand my solution is little different than BOL but I use it to fix my database... - [SQLAuthority News - Book Review - Programming SQL Server 2005 [ILLUSTRATED]](https://blog.sqlauthority.com/2007/09/26/sqlauthority-news-book-review-programming-sql-server-2005-illustrated/): Programming SQL Server 2005 [ILLUSTRATED] (Paperback) by Bill Hamilton (Author) Link to Amazon User does not have to be experience SQL Server 2005 programmer to use this book; as it is designed for users of all levels. This book also suggests that user does not have to be experienced with SQL Server 2000. However, I disagree with that. This book only covers new features of SQL Server 2005. Understanding of fundamental relational database concepts is helpful to digest and accept the concepts introduced in this book. This book covers following perspective of SQL Server 2005 new features. Tools and utilities Data... - [SQL SERVER - Effect of TRANSACTION on Local Variable - After ROLLBACK and After COMMIT](https://blog.sqlauthority.com/2007/09/25/sql-server-effect-of-transaction-on-local-variable-after-rollback-and-after-commit/): Few days ago, one of the Jr. Developer asked me this question (What will be the Effect of TRANSACTION on Local Variable – After ROLLBACK and After COMMIT?) while I was rushing to an important meeting. I was getting late so I asked him to talk with his Application Tech Lead. When I came back from meeting both of them were looking for me. They said they are confused. I quickly wrote down following example for them. Example: PRINT 'After ROLLBACK example' DECLARE @FlagINT INT SET @FlagInt = 1 PRINT @FlagInt ---- @FlagInt Value will be 1 BEGIN TRANSACTION SET @FlagInt... - [SQL SERVER - Order of Result Set of SELECT Statement on Clustered Indexed Table When ORDER BY is Not Used](https://blog.sqlauthority.com/2007/09/24/sql-server-order-of-result-set-of-select-statement-on-clustered-indexed-table-when-order-by-is-not-used/): "What will be the order of the result set of a SELECT statement on clustered indexed table when the ORDER BY clause is not used?" - [SQL SERVER - Stored Procedure to Know Database Access Permission to Current User](https://blog.sqlauthority.com/2007/09/23/sql-server-stored-procedure-to-know-database-access-permission-to-current-user/): Jr. DBA in my company only have access to the database which they need to use. Often they try to access database and if they do not have permission they face error. Jr. DBAs always check which database they have access using following system stored procedure. It is very reliable and provides accurate information. Sytanx: EXEC sp_MShasdbaccess GO ResultSet: ( I have listed only one column) AdventureWorks AdventureWorksDW master model msdb MyDB ReportServer ReportServerTempDB tempdb Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Version Information and Additional Information - Extended Stored Procedure xp_msver](https://blog.sqlauthority.com/2007/09/22/sql-server-2005-version-information-and-additional-information-extended-stored-procedure-xp_msver/): I was glad when I discovered this Extended Stored Procedure myself. I always used different syntax to retrieve server information. Many of information I was looking up using system information of the windows operating system. Syntax: EXEC xp_msver ResultSet: Index Name Internal_Value Character_Value —— ——————————– ————– ————————————- 1 ProductName NULL Microsoft SQL Server 2 ProductVersion 589824 9.00.3042.00 3 Language 1033 English (United States) 4 Platform NULL NT INTEL X86 5 Comments NULL NT INTEL X86 6 CompanyName NULL Microsoft Corporation 7 FileDescription NULL SQL Server Windows NT 8 FileVersion NULL 2005.090.3042.00 9 InternalName NULL SQLSERVR 10 LegalCopyright NULL © Microsoft Corp.... - [SQL SERVER - 2005 - Multiple Language Support](https://blog.sqlauthority.com/2007/09/21/sql-server-2005-multiple-language-support/): SQL Server supports multiple languages. Information about all the languages are stored in sys.syslanguages system view. You can run following script in Query Editor and see all the information about each language. Information about Months and Days varies for each language. Syntax: SELECT Alias, * FROM sys.syslanguages ResultSet: (* results not included) Alias ————– English German French Japanese Danish Spanish Italian Dutch Norwegian Portuguese Finnish Swedish Czech Hungarian Polish Romanian Croatian Slovak Slovenian Greek Bulgarian Russian Turkish British English Estonian Latvian Lithuanian Brazilian Traditional Chinese Korean Simplified Chinese Arabic Thai Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : ERROR : 3260 An internal buffer has become full](https://blog.sqlauthority.com/2007/09/20/sql-server-fix-error-3260-an-internal-buffer-has-become-full/): ERROR : 3260 An internal buffer has become full The reason I have picked to write about this error is because we have encountered this error many times in one of our older server. Fix/WorkAround/Solution: We were not able to absolutely reduce this error but following changes helped. 1) Rebooted server if error is happening frequently. 2) Increased RAM to Server. 3) Increased RAM allocation to SQL Server application. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Rename Database to New Name Using Stored Procedure by Changing to Single User Mode](https://blog.sqlauthority.com/2007/09/19/sql-server-rename-database-to-new-name-using-stored-procedure-by-changing-to-single-user-mode/): In my organization we rename the database on development server when are refreshing the development server with live data. We save the old database with new name and restore the database from live with same name. If developer/Jr. DBA have not saved the SQL Script from development server, he/she can go back to old Server and retrieve the script. There are few interesting facts to note when the database is renamed. When renamed the database, filegroup name or filename (.mdf,.ldf) are not changed. User with SA privilege can rename the database with following script when the context of the database is... - [SQLAuthority News - Scale-Out Querying with Analysis Services Using SAN Snapshots](https://blog.sqlauthority.com/2007/09/18/sqlauthority-news-scale-out-querying-with-analysis-services-using-san-snapshots/): White paper describes the use of virtual copy Storage Area Network (SAN) snapshots in a load-balanced scalable querying environment for SQL Server 2005 Analysis Services. This architecture provides the following improvements Improves the utilization of disk resources Optimizes cube processing operations Supports dedicated snapshots for specific users at different points in time In selecting a snapshot implementation for use with for Analysis Services, users may wish to consider the following snapshot attributes: Provisioning of snapshots Writeability of snapshots Scalability of snapshots Performance of snapshots Efficiency of snapshots I have created this article here only to promote the original White Paper, which... - [SQL SERVER - UDF - Validate Positive Integer Function - Validate Natural Integer Function](https://blog.sqlauthority.com/2007/09/18/sql-server-udf-validate-positive-integer-function-validate-natural-integer-function/): Few days ago I wrote SQL SERVER – UDF – Validate Integer Function. It was very interesting to write this and developers at my company started to use it. One Jr. DBA modified this function to validate only positive integers. I will share this with everybody who are interested in similar functionality. Code: CREATE FUNCTION [dbo].[udf_IsNatural] ( @Number VARCHAR(100) ) RETURNS BIT BEGIN DECLARE @Ret BIT IF (PATINDEX('%[^0-9-]%', @Number) = 0 AND CHARINDEX('-', @Number) <= 1 AND @Number NOT IN ('.', '-', '+', '^') AND LEN(@Number)>0 AND @Number NOT LIKE '%-%') SET @Ret = 1 ELSE SET @Ret = 0 RETURN @Ret END GO... - [SQLAuthority News - NASDAQ Uses SQL Server 2005 - Reducing Costs through Better Data Management](https://blog.sqlauthority.com/2007/09/17/sqlauthority-news-nasdaq-uses-sql-server-2005-reducing-costs-through-better-data-management/): I just came across PDF published by Microsoft to promote SQL Server 2005. I find few things very interesting. I will list them here. NASDAQ - [SQL SERVER - Difference Between UPDATE and UPDATE()](https://blog.sqlauthority.com/2007/09/17/sql-server-difference-between-update-and-update/): What is the difference between UPDATE and UPDATE()? UPDATE is syntax used to update the database tables or database views. USE AdventureWorks ; GO UPDATE Production.Product SET ListPrice = ListPrice * 2; GO UPDATE() is used in triggers to check update/insert to the database tables or database views. Returns a Boolean value that indicates whether an INSERT or UPDATE attempt was made on a specified column of a table or view. UPDATE() is used anywhere inside the body of a Transact-SQL INSERT or UPDATE trigger to test whether the trigger should execute certain actions. USE AdventureWorks ; GO CREATE TRIGGER reminder... - [SQLAuthority News - Active Directory Integration Sample Script](https://blog.sqlauthority.com/2007/09/16/sqlauthority-news-active-directory-integration-sample-script/): A sample script that enables you to extract a list of computer names from your custom SQL Server database and add them to an Active Directory security group. The security group can then be referenced in the Agent Assignment and Failover Wizard to automate agent assignments to Management Servers. 1. Queries customer SQL asset database. 2. Populates custom security group with computer accounts of computers returned by the SQL query. Download from MSDN Abstract courtesy : Microsoft Reference :Pinal Dave (https://blog.sqlauthority.com), Text from MSDN - [SQL SERVER - 2005 - List All The Constraint of Database - Find Primary Key and Foreign Key Constraint in Database](https://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/): Following script are very useful to know all the constraint in the database. I use this many times to check the foreign key and primary key constraint in database. This is simple but useful script from my personal archive. USE AdventureWorks; GO SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint, SCHEMA_NAME(schema_id) AS SchemaName, OBJECT_NAME(parent_object_id) AS TableName, type_desc AS ConstraintType FROM sys.objects WHERE type_desc LIKE '%CONSTRAINT' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Pro T-SQL 2005 Programmer's Guide (Paperback)](https://blog.sqlauthority.com/2007/09/15/sqlauthority-news-book-review-pro-t-sql-2005-programmers-guide-paperback/): Pro T-SQL 2005 Programmer’s Guide (Paperback) Book Review - [SQLAuthority News - Random Article from SQLAuthority Blog](https://blog.sqlauthority.com/2007/09/14/sqlauthority-news-random-article-from-sqlauthority-blog/): It has been wonderful writing on this blog. Many times I visit my older articles and read them. One of my favorite feature on WordPress.com (where I host my blog) is Random Article Feature. I use it quite often to land on random page on my blog. It is really good to read articles written previously because there are so many new things to learn as well keep previously learned knowledge refreshed. I have added link to random article in the side bar of this blog. User can click on it to visit random article as well click in the link... - [SQL SERVER - Difference Between EXEC and EXECUTE vs EXEC() - Use EXEC/EXECUTE for SP always](https://blog.sqlauthority.com/2007/09/13/sql-server-difference-between-exec-and-execute-vs-exec-use-execexecute-for-sp-always/): What is the difference between EXEC and EXECUTE? They are the same. Both of them executes stored procedure when called as EXEC sp_help GO EXECUTE sp_help GO I have seen enough times developer getting confused between EXEC and EXEC(). EXEC command executes stored procedure where as EXEC() function takes dynamic string as input and executes them. EXEC('EXEC sp_help') GO Another common mistakes I have seen is not using EXEC before stored procedure. It is always good practice to use EXEC before stored procedure name even though SQL Server assumes any command as stored procedure when it does not recognize the first... - [SQLAuthority News - Scrum: Agile Software Development for Project Management](https://blog.sqlauthority.com/2007/09/12/sqlauthority-news-scrum-agile-software-development-for-project-management/): This is something I have learned while working for so many years as Project Manager. It is not as important to know how things are done but it is important to know how to get things done. Scrum is an Agile Software Development system which helps developers to get project done in reasonable time and with superior quality. Scrum is organized around the following roles: Product Owner – Determines what functionality is needed ScrumMaster – Leads the Scrum and is primarily responsible for making sure the Scrum process is followed and removing impediments that keep the Team from working The Team... - [SQL SERVER - Frequency of SQL Server Reboot and Restart](https://blog.sqlauthority.com/2007/09/11/sql-server-frequency-of-sql-server-reboot-and-restart/): This is very interesting question. I will keep the answer of this question very simple. First of all there is no scientific research or white paper I can backup my results with. Answer contains part simple observation and part experience. There is no need to reboot SQL Server. Once it is on it is ON! However, I have heard that frequent reboot improves performance. In my company our network administration department has policy to reboot all the servers every 15 days. We reboot all the servers at every 15 days. Regarding performance improvement, our servers are always up and running as... - [SQLAuthority News - Book Review - SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills](https://blog.sqlauthority.com/2007/09/11/sqlauthority-news-book-review-sql-server-2005-dba-street-smarts-a-real-world-guide-to-sql-server-2005-certification-skills/): SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills (Paperback) by Joseph L. Jorden Link to Amazon Short Review: Microsoft’s new generation of certifications is design not only to emphasize your proficiency with a specific technology but also to prove you have the skills needed to perform a specific role. This book is developed based on the exam objective of the 70-431, although its purpose is to server more as a reference than just an exam preparation book. Detail Review: This book is designed to give DBAs some insight into the world of typical... - [SQL SERVER - 2005 - White Paper - Integrating Visio 2007 and Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/09/10/sql-server-2005-white-paper-integrating-visio-2007-and-microsoft-sql-server-2005/): This article focuses on integration techniques specific to Microsoft Office Visio 2007 and Microsoft SQL Server 2005. Using Visio 2007, you can connect Visio shapes to data that was generated outside Visio. A large amount of data can be captured in a SQL Analysis Services database. Being able to analyze that data in a visual way enhances the value of the data. In the following example, sales data stored in an Analysis Services cube is used to generate a Visio PivotDiagram so that the data can be explored and graphically enhanced. View Integrating Visio 2007 and Microsoft SQL Server 2005 Reference... - [SQLAuthority News - Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide](https://blog.sqlauthority.com/2007/09/10/sqlauthority-news-job-opportunity-in-ahmedabad-india-to-work-with-technology-leaders-worldwide/): If you have one or more years of experience in any web based programming language (.NET, ColdFusion, PHP) and interested in SQL Server as well willing to locate Ahmadabad, India. Please send me your resume, if selected you may get chance to work with one of the most progressing industry in world as well some smartest technology leaders worldwide. Salary depends on Experience. If selected for interview I suggest you go over SQL Server Interview Questions and Answers Complete List Download, as there is great chance I may be participating in interview. Please send your resume at pinaldave “at” yahoo.com and... - [SQL SERVER - 2005 - Start Stop Restart SQL Server From Command Prompt](https://blog.sqlauthority.com/2007/09/09/sql-server-2005-start-stop-restart-sql-server-from-command-prompt/): Very frequently I use following command prompt script to start and stop default instance of SQL Server. Our network admin loves this commands as this is very easy. Click Start >> Run >> type cmd to start command prompt. Start default instance of SQL Server net start mssqlserver Stop default instance of SQL Server net stop mssqlserver Start and Stop default instance of SQL Server. You can create batch file to execute both the commands together. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF - User Defined Function - Get Number of Days in Month](https://blog.sqlauthority.com/2007/09/08/sql-server-udf-user-defined-function-get-number-of-days-in-month/): Following User Defined Function (UDF) returns the numbers of days in month. It is very simple yet very powerful and full proof UDF. CREATE FUNCTION [dbo].[udf_GetNumDaysInMonth] ( @myDateTime DATETIME ) RETURNS INT AS BEGIN DECLARE @rtDate INT SET @rtDate = CASE WHEN MONTH(@myDateTime) IN (1, 3, 5, 7, 8, 10, 12) THEN 31 WHEN MONTH(@myDateTime) IN (4, 6, 9, 11) THEN 30 ELSE CASE WHEN (YEAR(@myDateTime) % 4 = 0 AND YEAR(@myDateTime) % 100 != 0) OR (YEAR(@myDateTime) % 400 = 0) THEN 29 ELSE 28 END END RETURN @rtDate END GO Run following script in Query Editor: SELECT dbo.udf_GetNumDaysInMonth(GETDATE()) NumDaysInMonth... - [SQL SERVER - Correlated and Noncorrelated - SubQuery Introduction, Explanation and Example](https://blog.sqlauthority.com/2007/09/07/sql-server-correlated-and-noncorrelated-subquery-introduction-explanation-and-example/): A correlated subquery is an inner subquery which is referenced by the main outer query such that the inner query is considered as being executed repeatedly. Example: ----Example of Correlated Subqueries USE AdventureWorks; GO SELECT e.EmployeeID FROM HumanResources.Employee e WHERE e.ContactID IN ( SELECT c.ContactID FROM Person.Contact c WHERE MONTH(c.ModifiedDate) = MONTH(e.ModifiedDate) ) GO A noncorrelated subquery is subquery that is independent of the outer query and it can executed on its own without relying on main outer query. Example: ----Example of Noncorrelated Subqueries USE AdventureWorks; GO SELECT e.EmployeeID FROM HumanResources.Employee e WHERE e.ContactID IN ( SELECT c.ContactID FROM Person.Contact c... - [SQL SERVER - 2005 - Introduction and Explanation to sqlcmd](https://blog.sqlauthority.com/2007/09/06/sql-server-2005-introduction-and-explanation-to-sqlcmd/): I decided to write this article to respond to request of one of usergroup, which requested that they would like to learn sqlcmd 101. SQL Server 2005 has introduced new utility sqlcmd to run ad hoc Transact-SQL statements and scripts from command prompt. T-SQL commands are entered in command prompt window and result is displayed in the same window, unless result set are sent to output files. sqlcmd can execute single T-SQL statement as well as batch file. sqlcmd utility can connect to earlier versions of SQL Server as well. The sqlcmd utility uses the OLE DB provider to execute T-SQL... - [SQLAuthority News - SQL SERVER 2008 CTP 4 Released](https://blog.sqlauthority.com/2007/09/06/sqlauthority-news-sql-server-2008-ctp-4-released/): SQL Server 2008 CTP 4 is released as a pre-configured VHD. This allows you to trial SQL Server 2008 CTP 4 in a virtual environment. Download SQL Server 2008 CTP 4 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Valid SQL Error](https://blog.sqlauthority.com/2007/09/05/sql-server-sql-joke-sql-humor-sql-laugh-valid-sql-error/): Yesterday I had posted my 300th post and I missed the announcement. One of my reader sent me following Image in email congratulating SQLAuthority blog for completing 300th post and also informing me that it has been long time I have posted something funny. I have written few articles about frequent SQL Server Errors on this blog. He suggested that this humorous images goes along with it. If you know source of this image please let me know I would like to include that. Visit more SQL Server Humors. Reference : Pinal Dave (https://blog.sqlauthority.com) , Need original reference for image. - [SQLAuthority News - Interesting Read - Using A SQL JOIN In A SQL UPDATE/Delete Statement - Ben Nadel](https://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/): As everybody know SQL is what I like most. Before I was into SQL Server, I was very much into ColdFusion. ColdFusion is still my most favorite programming language. I still program in ColdFusion, infect my personal website https://www.pinaldave.com/ is in ColdFusion. I regularly read ColdFusion blog and latest updates in ColdFusion. Recently at company where I work, we upgraded to ColdFusion 8 and .NET 2.0 (C# is our preferred language in .NET technology). Both of this languags work with SQL Server 2005 very well in my company. My favorite blog for ColdFusion technology is blog of BEN NADEL . Ben... - [SQL SERVER - 2005 - Find Tables With Primary Key Constraint in Database](https://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/): My article SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key has received following question many times. I have deleted similar questions and kept only latest comment there. In SQL Server 2005 How to Find Tables With Primary Key Constraint in Database? Script to find all the primary key constraint in database: USE AdventureWorks; GO SELECT i.name AS IndexName, OBJECT_NAME(ic.OBJECT_ID) AS TableName, COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName FROM sys.indexes AS i INNER JOIN sys.index_columns AS ic ON i.OBJECT_ID = ic.OBJECT_ID AND i.index_id = ic.index_id WHERE i.is_primary_key = 1 In SQL Server 2005 How to Find Tables... - [SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database](https://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/): While writing article based on my SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key I got an idea about writing this article. I was thinking if you can find primary key for any table in the database, you can sure find foreign key for any table in the database as well. - [SQL SERVER - 2005 - Search Stored Procedure Code - Search Stored Procedure Text](https://blog.sqlauthority.com/2007/09/03/sql-server-2005-search-stored-procedure-code-search-stored-procedure-text/): I receive following question many times by my team members. How can I find if particular table is being used in the stored procedure? How to search in stored procedures? How can I do dependency check for objects in stored procedure without using sp_depends? I have previously wrote article about this SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored procedure. The same feature can be implemented using following script in SQL Server 2005. USE AdventureWorks GO --Searching for Empoloyee table SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Employee%' GO --Searching for Empoloyee table... - [SQL SERVER - Fix : Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward](https://blog.sqlauthority.com/2007/09/02/sql-server-fix-error-msg-3117-level-16-state-4-the-log-or-differential-backup-cannot-be-restored-because-no-files-are-ready-to-rollforward/): Following error occurs when tried to restored the differential backup. Fix : Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward Fix/WorkAround/Solution: This error happens when Full back up is not restored before attempting to restore differential backup or full backup is restored with WITH RECOVERY option. Make sure database is not in operational conditional when differential backup is attempted to be restored. Example of restoring differential backup successfully after restoring full backup. RESTORE DATABASE AdventureWorks FROM DISK = 'C:\AdventureWorksFull.bak' WITH NORECOVERY; RESTORE DATABASE AdventureWorks FROM DISK... - [SQL SERVER - 2005 - Find Database Status Using sys.databases or DATABASEPROPERTYEX](https://blog.sqlauthority.com/2007/08/31/sql-server-2005-find-database-status-using-sysdatabases-or-databasepropertyex/): While writing article about database collation, I came across sys.databases and DATABASEPROPERTYEX. It was very interesting to me that this two can tell user so much about database properties. Following are main database status: (Reference: BOL Database Status) ONLINE Database is available for access. OFFLINE Database is unavailable. RESTORING One or more files of the primary filegroup are being restored, or one or more secondary files are being restored offline. RECOVERING Database is being recovered. RECOVERY PENDING SQL Server has encountered a resource-related error during recovery. SUSPECT At least the primary filegroup is suspect and may be damaged. EMERGENCY User has... - [SQL SERVER - 2005 - Find Database Collation Using T-SQL and SSMS](https://blog.sqlauthority.com/2007/08/30/sql-server-2005-find-database-collation-using-t-sql-and-ssms/): This article is written based on feedback I have received on SQL SERVER – Cannot resolve collation conflict for equal to operation. Many reader asked me how to find collation of current database. There are two different ways to find out SQL Server database collation. 1) Using T-SQL (My Recommendation) Run following Script in Query Editor SELECT DATABASEPROPERTYEX('AdventureWorks', 'Collation') SQLCollation; ResultSet: SQLCollation ———————————— SQL_Latin1_General_CP1_CI_AS 2) Using SQL Server Management Studio Refer the following two diagram to find out the SQL Collation. Write Click on Database Click on Properties Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Difference and Explanation among DECIMAL, FLOAT and NUMERIC](https://blog.sqlauthority.com/2007/08/29/sql-server-difference-and-explanation-among-decimal-float-and-numeric/): The basic difference between Decimal and Numeric : They are the exactly same. Same thing different name. The basic difference between Decimal/Numeric and Float : Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly. Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type reane can be represented exactly with precision and scale. Converting from Decimal or Numeric to float can cause some loss of precision. For the Decimal or Numeric data types, SQL Server considers each specific combination of precision and scale as a... - [SQL SERVER - Actual Execution Plan vs. Estimated Execution Plan](https://blog.sqlauthority.com/2007/08/28/sql-server-actual-execution-plan-vs-estimated-execution-plan/): I was recently invited to participate in big discussion on one of the online forum, the topic was Actual Execution Plan vs. Estimated Execution Plan. I refused to participate in that particular discussion as I have very simple but strong opinion about this topic. I always use Actual Execution Plan as it is accurate. Why not Estimated Execution Plan? It is not accurate. Sometime it is easier or useful to to know the plan without running query. I just run query and have correct and accurate Execution Plan. Shortcut for Display Estimated Execution Plan : CTRL + L Shortcut for Include... - [SQL SERVER - 2005 - Use Always Outer Join Clause instead of (*= and =*)](https://blog.sqlauthority.com/2007/08/27/sql-server-2005-use-always-outer-join-clause-instead-of-and/): Yesterday I wrote about how SQL Server 2005 does not support named pipes. Today, my friend called me asking some of his query does not work. I asked him to send me the queries. I asked him to send me query. I noticed in his queries something, I have never practiced before and I never had any issue therefore. Instead of using LEFT OUTER JOIN clause he was using *= and similarly instead of using RIGHT OUTER JOIN clause he was using =*. Once I replaced did necessary modification, queries run just fine. I wish I can give you example of... - [SQL SERVER - 2005 - No Backup Support For Named Pipes](https://blog.sqlauthority.com/2007/08/26/sql-server-2005-no-backup-support-for-named-pipes/): While helping one of my DBA friend (who works in big company in LA) to upgrade SQL Server 2000 to SQL Server 2005 I just found one thing, which I have not paid attention before. SQL Server 2000 supported named pipe backup device. SQL Server 2005 does not support named pipe backup device, however SQL Server 2005 supports disk and tape devices. I receive following question many times, I have answered this question earlier on this blog. I will still answer it again. What is my preferred method of backup? We use SAN with RAID 10 configuration. Some industry experts suggested... - [SQL SERVER - FIX : Error : msg 2540 - The system cannot self repair this error](https://blog.sqlauthority.com/2007/08/25/sql-server-fix-error-msg-2540-the-system-cannot-self-repair-this-error/): SQL SERVER – FIX : Error : msg 2540 – The system cannot self repair this error This is most annoying error. I have only faced this error twice so far. I solved this error restoring the database back up. Read here for additional help on SQL Backup And Restore. This error is occurs when database is in state when it can not be heal itself, i.e. corrupted metadata or corrupted important system database files. Fix/WorkAround/Solution: My prefered order to fix the problem. 1) Restored database from backup. 2) Run DBCC with repair option, which will not bring much favorable answer.... - [SQL SERVER - T-SQL Script to Attach and Detach Database](https://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/): Following script can be used to detach or attach the database. If the database is to be from one database to another database following script can be used to detach from old server and attach to a new server. Let us learn about how to Attach and Detach Database. - [SQL SERVER - 2005 - Use of Non-deterministic Function in UDF - Find Day Difference Between Any Date and Today](https://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/): While writing few articles about SQL Server DataTime I accidentally wrote User Defined Function (UDF), which I would have not wrote usually. Once I wrote this function, I did not find it very interesting and decided to discard it. However, I suddenly noticed use of Non-Deterministic function in the UDF. I always thought that use of Non-Deterministic function is prohibited in UDF. I even wrote about it earlier SQL SERVER – User Defined Functions (UDF) Limitations. It seems like SQL Server 2005 either have removed this restriction or it is bug. I think I will not say this is bug but... - [SQL SERVER - T-SQL Script to Insert Carriage Return and New Line Feed in Code](https://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/): Very simple and very effective. We use all the time for many reasons - formatting, while creating dynamically generated SQL to separate GO command from other T-SQL, saving some user input text to database etc. Let us learn about T-SQL Script to Insert Carriage Return and New Line Feed in Code. - [SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects](https://blog.sqlauthority.com/2007/08/21/sql-server-2005-create-script-to-copy-database-schema-and-all-the-objects-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/): Update: This article is re-written with SQL Server 2008 R2 instance over here: SQL SERVER – 2008 – 2008 R2 – Create Script to Copy Database Schema and All The Objects – Data, Schema, Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects Following quick tutorial demonstrates how to create T-SQL script to copy complete database schema and all of its objects such as Stored Procedure, Functions, Triggers, Tables, Views, Constraints etc. You can review your schema, backup for reference or use it to compare with previous backup. Step 1 : Start Step 2 : Welcome Screen Step... - [SQLAuthority News - Principles of Simplicity](https://blog.sqlauthority.com/2007/08/20/sqlauthority-news-principles-of-simplicity/): Yesterday I came across Principles of Simplicity by Mads Kristensen. I think this is good write up and I enjoyed reading it. This are very generic and applies to all programming language and databases applications. Principles of Simplicity by Mads Kristensen 1. Simplicity or not at all Some developers tend to over-complicate a task and ends up writing too many classes to solve a simple problem. 2. Don’t build submarines It’s a common fact that IT projects take longer than scheduled even if you schedule for delays. 3. Test when appropriate Testing is one very important factor of the development cycle... - [SQL SERVER - Find Monday of the Current Week](https://blog.sqlauthority.com/2007/08/20/sql-server-find-monday-of-the-current-week/): Very Simple Script which find Monday of the Current Week SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0) MondayOfCurrentWeek Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes](https://blog.sqlauthority.com/2007/08/19/sqlauthority-news-book-review-sams-teach-yourself-microsoft-sql-server-t-sql-in-10-minutes/): Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes (Sams Teach Yourself) by Ben Forta Link to Amazon Short Review: If T-SQL (Transact-Structured Query Language) is foreign tongue to you, after reading this book, you will speak T-SQL. This book is SQL Server version of best-selling book Sams Teach Yourself SQL in 10 Minutes. This book teaches what a SQL developer must know methodically, systematically, and exactly. Anybody who are new to SQL Server and wants to learn most of T-SQL which can be implemented in short time in their application – BUY this book immediately. Detail Review: This is... - [SQL SERVER - Find Last Day of Any Month - Current Previous Next](https://blog.sqlauthority.com/2007/08/18/sql-server-find-last-day-of-any-month-current-previous-next/): Few questions are always popular. They keep on coming up through email, comments or from co-workers. Finding Last Day of Any Month is similar question. I have received it many times and I enjoy answering it as well. I have answered this question twice before here: SQL SERVER – Script/Function to Find Last Day of Month SQL SERVER – Query to Find First and Last Day of Current Month Today, we will see the same solution again. Please use the method you find appropriate to your requirement. Following script demonstrates the script to find last day of previous, current and next... - [SQL SERVER - 2005 - Explanation and Script for Online Index Operations - Create, Rebuild, Drop](https://blog.sqlauthority.com/2007/08/17/sql-server-2005-explanation-and-script-for-online-index-operations-create-rebuild-drop/): SQL Server 2005 Enterprise Edition supports online index operations. Index operations are creating, rebuilding and dropping indexes. The question which I receive quite often – what is online operation? Is online operation is related to web, internet or local network? Online operation means when online operations are happening the database are in normal operational condition, the processes which are participating in online operations does not require exclusive access to database. In case of Online Indexing Operations, when Index operations (create, rebuild, dropping) are occuring they do not require exclusive access to database, they do not lock any database tables. This is... - [SQLAuthority News - Subscribed to SQLAuthority Emails](https://blog.sqlauthority.com/2007/08/16/sqlauthority-news-subscribed-to-sqlauthority-emails/): I have got many request about alert system when new post is published on this blog. I use feedburner email service, which sends email whenever new post is published on my blog. Many times, I update my post based on feedback from comments or news. If you want updated information, visit the blog. Subscribe to SQLAuthority.com Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Book On-Line Link - BOL](https://blog.sqlauthority.com/2007/08/16/sql-server-2008-book-on-line-link/): I am researching SQL Server. Those who are asking me questions about SQL Server 2008, please refer following link. I will post my tutorials and articles very soon. Books Online is commonly known as BOL. - [SQL SERVER - 2005 - Difference and Similarity Between NEWSEQUENTIALID() and NEWID()](https://blog.sqlauthority.com/2007/08/16/sql-server-2005-difference-and-similarity-between-newsequentialid-and-newid/): NEWSEQUENTIALID() and NEWID() both generates the GUID of datatype of uniqueidentifier. NEWID() generates the GUID in random order whereas NEWSEQUENTIALID() generates the GUID in sequential order. Let us see example first demonstrating both of the function. USE AdventureWorks; GO ----Create Test Table for with default columns values CREATE TABLE TestTable (NewIDCol uniqueidentifier DEFAULT NEWID(), NewSeqCol uniqueidentifier DEFAULT NewSequentialID()) ----Inserting five default values in table INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES ----Test Table to see NewID() is random ----Test Table to see NewSequentialID()... - [SQL SERVER - Insert Data From One Table to Another Table - INSERT INTO SELECT - SELECT INTO TABLE](https://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table/): Following three questions are many times asked on this blog. How to insert data from one table to another table efficiently? How to insert data from one table using where condition to another table? How can I stop using cursor to move data from one table to another table? There are two different ways to implement inserting data from one table to another table. I strongly suggest to use either of the methods over the cursor. Performance of following two methods is far superior over the cursor. I prefer to use Method 1 always as I works in all the cases.... - [SQLAuthority News - Book Review - Learning SQL on SQL Server 2005 (Learning)](https://blog.sqlauthority.com/2007/08/14/sqlauthority-news-book-review-learning-sql-on-sql-server-2005-learning/): SQLAuthority.com Book Review : Learning SQL on SQL Server 2005 (Learning) [ILLUSTRATED] (Paperback) by Sikha Bagui, Richard Earp Link to book on Amazon Short Review: This books covers simple and complex concept in very easy language with lots of examples. Every beginner can learn a great amount of tips from experienced authors. Whether you are a self-learner, new to databases or in need of SQL refresher, this is good read. Detail Review: This book is written by two conceptual strong SQL Server Gurus. SQL Server is growing extremely popular in the area of high-performance data applications. It is very important to... - [SQL SERVER - What is SQL? How to pronounce SQL?](https://blog.sqlauthority.com/2007/08/14/sql-server-what-is-sql-how-to-pronounce-sql/): SQL is abbreviation of Structured Query Language. SQL is pronounced as S.Q.L. (ess-que-ell or ess-cue-ell) not sequel. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - Database Architecture and Implementation Discussion - New York, New Jersey Details](https://blog.sqlauthority.com/2007/08/13/sqlauthority-news-author-visit-database-architecture-and-implementation-discussion-new-york-new-jersey-details/): Last weekend I visited New York City (NY) and Edison (NJ) to attend database architecture meeting with a big environmental technology firm. It was very interesting to meet CEO and few of the lead database administrators. Lots of database related things were discussed. I will list few of the points discussed in the meeting here, due to privacy policy I will be not able to write many of the interesting details I have learned there. Please let me know if you are interested in any of the particular topic. I can elaborate more on the topic which interests everybody. 1) Database... - [SQL SERVER - Fix : ERROR : Msg 1033, Level 15, State 1 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.](https://blog.sqlauthority.com/2007/08/12/sql-server-fix-error-msg-1033-level-15-state-1-the-order-by-clause-is-invalid-in-views-inline-functions-derived-tables-subqueries-and-common-table-expressions-unless-top-or-for-xml-is-als/): Following error is encountered when view is attempted to created with ORDER BY clause in it. ORDER BY clause is not allowed in views in SQL Server 2005. This solution also displays the workaround to use ORDER BY in VIEW. I really do not prefer to use views. My views on SQL Views read it SQL SERVER – Restrictions of Views – T SQL View Limitations. Msg 1033, Level 15, State 1 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. This is error interested... - [SQL SERVER - UDF - Validate Integer Function](https://blog.sqlauthority.com/2007/08/11/sql-server-udf-validate-integer-function/): I received quite a good feedback about my post about SQL SERVER – Validate Field For DATE datatype using function ISDATE() One of the most interesting comment I received from my reader from Canada. I was suggested just like ISDATE() to write about ISNUMERIC() which can be used to validate numeric values. As per BOL: ISNUMERIC returns 1 when the input expression evaluates to a valid numeric data type; otherwise it returns 0. ISNUMERIC returns 1 for some characters that are not numbers, such as plus (+), minus (-), and valid currency symbols such as the dollar sign ($). Now this... - [SQL SERVER - 2005 - Find Stored Procedure Create Date and Modified Date](https://blog.sqlauthority.com/2007/08/10/sql-server-2005-find-stored-procedure-create-date-and-modified-date/): This post is second part of my previous post about SQL SERVER – 2005 – List All Stored Procedure Modified in Last N Days - [SQL SERVER - 2005 - List All The Column With Specific Data Types](https://blog.sqlauthority.com/2007/08/09/sql-server-2005-list-all-the-column-with-specific-data-types/): Since we upgraded to SQL Server 2005 from SQL Server 2000, we have used following script to find out columns with specific datatypes many times. It is very handy small script. SQL Server 2005 has new datatype of VARCHAR(MAX), we decided to change all our TEXT datatype columns to VARCHAR(MAX). The reason to do that as TEXT datatype will be deprecated in future version of SQL Server and VARCHAR(MAX) is superior to TEXT datatype in features. We run following script to identify all the columns which are TEXT datatype and developer converts them to VARCHAR(MAX) Script 1 : Simple script to... - [SQL SERVER - 2005 - SSMS - Enable Autogrowth Database Property](https://blog.sqlauthority.com/2007/08/08/sql-server-2005-ssms-enable-autogrowth-database-property/): We can use SSMS to Enable Autogrowth property of the Database. Right-click on Database click on Properties and click on Files. There will be column of Autogrowth, click on small box with three (…) dots. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List Tables in Database Without Primary Key](https://blog.sqlauthority.com/2007/08/07/sql-server-2005-list-tables-in-database-without-primary-key/): This is very simple but effective script. It list all the table without primary keys. USE DatabaseName; GO SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableName FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0 ORDER BY SchemaName, TableName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Fix: Error 2596 The repair statement was not processed. The database cannot be in read-only mode](https://blog.sqlauthority.com/2007/08/06/sql-server-fix-error-2596-the-repair-statement-was-not-processed-the-database-cannot-be-in-read-only-mode/): ERROR 2596 : The repair statement was not processed. The database cannot be in read-only mode. - [SQL SERVER - Stop SQL Server Immediately Using T-SQL](https://blog.sqlauthority.com/2007/08/05/sql-server-stop-sql-server-immediately-using-t-sql/): This question has came up many quite a few times with our development team as well as emails I have received about how to stop SQL Server immediately (due to accidentally ran t-sql, business logic or just need of to stop SQL Server using T-SQL). Answer is very simple, run following command in SQL Editor. SHUTDOWN If you want to shutdown the system without performing checkpoints in every database and without attempting to terminate all user processes use following command. SHUTDOWN WITH NOWAIT Server can be turned off using windows services as well. SHUTDOWN permissions are assigned to members of the... - [SQL SERVER - One Thing All DBA Must Know](https://blog.sqlauthority.com/2007/08/04/sql-server-one-thing-all-dba-must-know/): FULLY BACKUP DATABASE. Update : I posted this post with only line. However I received many comments and questions asking different questions related to it. I have compiled all of them and modified this post. Most asked Question : What is the best time when database should be backed up? Answer : When everything is running perfect. This is the time when backup should be taken because in troubled time this is the backup required to be restored. The best backup is when system was running PERFECT. Question : I am experienced DBA, what should be the frequency of backup when... - [SQLAuthority News - Download SQL Server 2005 Samples and Sample Databases](https://blog.sqlauthority.com/2007/08/04/sqlauthority-news-download-sql-server-2005-samples-and-sample-databases/): Microsoft has purchased GitHub, the world’s leading software development platform where more than 28 million developers learn, share and collaborate to create the future for 7.5 Billion dollars.  - [SQLAuthority News - Author Visit - Database Architecture and Implementation Discussion - New York, New Jersey](https://blog.sqlauthority.com/2007/08/04/sqlauthority-news-author-visit-database-architecture-and-implementation-discussion-new-york-new-jersey/): I will be traveling for next two days to New York and New Jersey for Database Architecture and Implementation Discussion with one of the largest software technology company. The major focus of this firm is environmental product analysis. I will be not able to answer any questions, comments and emails during next two days 8/5 Saturday and 8/6 Sunday. I will post all the interesting details (which I can disclose safely without violating privacy policy) once I am come back to my city – Las Vegas. I am looking forward to meet industry giants and prominent personalities for next two days.... - [SQL SERVER - Find Last Date Time Updated for Any Table](https://blog.sqlauthority.com/2009/05/09/sql-server-find-last-date-time-updated-for-any-table/): I just received an email from one of my regular readers who is curious to know if there is any way to find out when a table is recently updated (or last date time updated). I was ready with my answer! I promptly suggested him that if a table contains UpdatedDate or ModifiedDate date column with default together with value GETDATE(), he should make use of it. On close observation, the table is not required to keep history when any row is inserted. However, the sole prerequisite is to be aware of when any table has been updated. That’s it! - [SQLAuthority News - Future of Business Intelligence and Databases - Article by Nupur Dave](https://blog.sqlauthority.com/2009/05/08/sqlauthority-news-future-of-business-intelligence-and-databases-article-by-nupur-dave/): This article is submitted by Nupur Dave Future of Business Intelligence and Databases The term business intelligence (BI) was coined by Howard Dresner in the early 1990s. He defined Business Intelligence as “a set of concepts and methodologies to improve decision making in business through use of facts and fact-based systems.” In a time when data warehousing was considered leading-edge he created the vision that led to the development of business intelligence, as it is known today.  The once visionary BI is now commonplace and in near future a momentous transformation is about to take place. BI is all set to... - [SQL SERVER - FIX : Error : Windows Update; Error Code 8000FFFF ](https://blog.sqlauthority.com/2009/05/07/sql-server-fix-error-windows-update-error-code-8000ffff/): At present, I am running Windows Vista Ultimate as OS in my computer. I have installed SQL Server 2008 developer’s version in my computer. A couple of months back, I learnt that SQL Server Book On-Line (BOL) update has been released. I usually depend on my Windows Update of SQL Server to install all updates in my OS, so I do not have to  bother myself with installing updates manually. However, this time I was quite taken aback to find that my computer was not updated with the latest updates released by Microsoft. Further, I noticed that my SQL Server Book... - [SQLAuthority News - Book Review - SQL Server 2008 Management and Administration by Ross Mistry](https://blog.sqlauthority.com/2009/05/06/sqlauthority-news-book-review-sql-server-2008-management-and-administration-by-ross-mistry/): SQL Server 2008 Management and Administration (Paperback) - [SQLAuthority News - Author Visit - TechEd India 2009 - Hyderabad](https://blog.sqlauthority.com/2009/05/05/sqlauthority-news-author-visit-teched-india-2009-hyderabad/): I am sure most of you have already heard the good news -Microsoft TechEd India 2009 finally arrives! Tech.Ed-India is a great opportunity to gear yourself up to keep pace with the latest technology innovations and trends.  This event offers you the platform to get comprehensive hands-on-training and free certifications in some of the most sought after technologies of today. In fact, it is a must-attend event for all developers and IT Professionals. Tech.Ed-India will see Steve Balmer, CEO of Microsoft, giving the Keynote and the presence of some renowned speakers. The event will offer you the opportunity to interact with... - [SQL SERVER - Roadmap of Microsoft Certifications - SQL Server Certifications](https://blog.sqlauthority.com/2009/05/04/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications-2/): Introduction In these times of economic slowdown and uncertainties, more and more IT professionals are concerned about their job security and their qualifications. With job insecurity looming on their minds, it is a common trend for developers to start hunting for ways to update their skills. Sound knowledge and real world work experience are always a good way to help secure your future. However, a great way to demonstrate knowledge and competence is by having a certification in the technology one claims to be proficient in. Download Roadmap of Microsoft Certifications – SQL Server Certifications Microsoft offers a series of certifications... - [SQL SERVER - Add or Remove Identity Property on Column](https://blog.sqlauthority.com/2009/05/03/sql-server-add-or-remove-identity-property-on-column/): This article contribution from one of my favorite SQL Expert Imran Mohammed. He is one man who has lots of ideas and helps people from all over the world with passion using this community as platform. His constant zeal to learn more about SQL Server keeps him engaging him to do new SQL Server related activity every time. 1. Adding Identity Property to an existing column in a table. How difficult is it to add an Identity property to an existing column in a table? Is there any T-SQL that can perform this action? For most, the answer to the above... - [SQL SERVER - Example of DDL, DML, DCL and TCL Commands](https://blog.sqlauthority.com/2009/05/02/sql-server-example-of-ddl-dml-dcl-and-tcl-commands/): DML DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. SELECT – Retrieves data from a table INSERT –  Inserts data into a table UPDATE – Updates existing data into a table DELETE – Deletes all records from a table DDL DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. CREATE – Creates objects in the database ALTER – Alters objects of the database DROP – Deletes objects of the database TRUNCATE – Deletes all records from... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting April 24, 2009](https://blog.sqlauthority.com/2009/05/01/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-april-24-2009-2/): We had another successful Gandhinagar SQL Server User Group Meeting on April 24, 2009. In spite of our User Group being just two months old, it received overwhelming warm response from the audience! The meeting once again saw around 50 SQL Server enthusiasts eagerly looking forward to brush up their knowledge and gain some vital tips. The agenda of the meeting was as follows: 6:30 PM – 6:45 PM – Query Optimization Tricks – Jacob Sebastian 6:45 PM – 7:10 PM – Back to Basics – Pinal Dave 7:10 PM – 7:20 PM – Questions and Answers 7:20 PM – 7:30... - [SQL SERVER - FIX : ERROR : is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)](https://blog.sqlauthority.com/2009/04/30/sql-server-fix-error-is-not-a-valid-win32-application-exception-from-hresult-0x800700c1/): Just a day ago, one of my friend sent me email requesting help with following error: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) In fact this is not SQL Server error but it is of .NET application. The solution of this error is just changing configuration of IIS7. Fix/Solution/Workaround: Go to IIS. Click on Application Pool. Look for your web application in application pool. Go to Advanced Settings by right clicking on previously selected application pool. Enable 32-Bit Applications by checking it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Solution to Puzzle - Shortest Code to Perform SSN Validation](https://blog.sqlauthority.com/2009/04/29/sql-server-solution-to-puzzle-shortest-code-to-perform-ssn-validation/): One of my friends – a SQL Server MVP- Jacob Sebastian has a knack for coming up with interesting ideas and stuffs, the latest example being SQL Server Puzzles on his blog. Jacob is a regular blogger and a talented writer. I enjoy reading his blogs and books. He has recently published his new book – The Art of XSD – SQL Server XML Schema Collections. I have based my present article on his most recent brainteaser – Write the shortest T-SQL Code that removes invalid SSN values and returns a result set with only valid SSN values. There are few... - [SQL SERVER - Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial with Script](https://blog.sqlauthority.com/2009/04/28/sql-server-introduction-to-sql-server-encryption-and-symmetric-key-encryption-tutorial-with-script/): SQL Server 2005 and SQL Server 2008 provide encryption as a new feature to protect data against hackers’ attacks. Hackers might be able to penetrate the database or tables, but owing to encryption they would not be able to understand the data or make use of it. Nowadays, it has become imperative to encrypt crucial security-related data while storing in the database as well as during transmission across a network between the client and the server. - [SQLAuthority News - Starting the SQL Journey - How Did I Get Started With SQL?](https://blog.sqlauthority.com/2009/04/27/sqlauthority-news-starting-the-sql-journey-how-did-i-get-started-with-sql/): This is the very first time I am answering any online tag. SQL Expert Jorge Segarra (a.k.a @SQLChicken) recently tagged me with a very simple yet significant question related to my journey on the path of SQL Server. Let me introduce you all to Jorge first before moving on to his question. Jorge lives in Tampa, Florida, with his beautiful wife, an adorable dog and two naughty cats. He is currently working as a SQL DBA and system administrator for the University Community Hospital. His in-depth knowledge of SQL Server and comprehensive understanding of the subject has gained him incredible popularity... - [SQL SERVER - List All the Tables for All Databases Using System Tables](https://blog.sqlauthority.com/2009/04/26/sql-server-list-all-the-tables-for-all-databases-using-system-tables/): Today we will go over very simple script which will list all the tables for all the database. sp_msforeachdb 'select "?" AS db, * from [?].sys.tables' Update: Based on comments received below I have updated this article. Thank you to all the readers. This is good example where something small like this have good participation from readers. Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQLAuthority News - Interview of Author on 60 Seconds with Pinal Dave](https://blog.sqlauthority.com/2009/04/25/sqlauthority-news-interview-of-author-on-60-seconds-with-pinal-dave/): Vijaya Kadiyala is my fellow .NET and SQL Expert and very respected member of the technology community in India. He is known for his easy but to the point attitude for technology. He regularly writes on his blog : DotNetVJ. I happen to meet him at MVP Summit in Seattle and have learned a lot about him. In my recent travel to South India, I have learned a great deal about his community services and enthusiasm about cutting edge technology. Vijaya has started interview series on his blog where he takes very quick interviews of community leaders. He asked following five... - [SQL SERVER - Leading Zero to Number ](https://blog.sqlauthority.com/2009/04/24/sql-server-leading-zero-to-number/): I have received few emails asking how to prefix any number with zero. I have previously written two articles for the same subject. Please refer to my previous articles. SQL SERVER – Pad Ride Side of Number with 0 – Fixed Width Number Display SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display Let me know if you are aware of any other method. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to SQL Server 2008 Profiler - Summary](https://blog.sqlauthority.com/2009/04/24/sql-server-introduction-to-sql-server-2008-profiler/): Introduction SQL Server Profiler is a powerful tool that is available with SQL Server since a long time; however, it has mostly been underutilized by DBAs. SQL Server Profiler can perform various significant functions such as tracing what is running under the SQL Server Engine’s hood, and finding out how queries are resolved internally and what scripts are running to accomplish any T-SQL command. The major functions this tool can perform have been listed below: Creating trace Watching trace Storing trace Replaying trace Trace includes all the T-SQL scripts that run simultaneously on SQL Server. As trace contains all the T-SQL... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting April 24, 2009](https://blog.sqlauthority.com/2009/04/23/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-april-24-2009/): Gandhinagar SQL Server User Group launch event was held on March 27, 2009. This successful, well-attended event received very positive and warm community response. Visit Gandhinagar SQL Server User Group Portal and register yourself now! We are going to meet again this month on April 24, 2009 Friday from 6:30PM to 7:30 PM. We will be very fortunate that we will have outside guest and another SQL Server MVP visiting us. Jacob Sebastian is president of Ahmedabad SQL Server User Group and fellow MVP. He has taken many technical sessions in meetings and famous speaker in SQL Server arena. The agenda... - [SQL SERVER - FIX : Error: 18486 Login failed for user 'sa' because the account is currently locked out. The system administrator can unlock it. - Unlock SA Login](https://blog.sqlauthority.com/2009/04/23/sql-server-fix-error-18486-login-failed-for-user-sa-because-the-account-is-currently-locked-out-the-system-administrator-can-unlock-it-unlock-sa-login/): Today, we will riffle through a very simple, yet common issue – How to unlock a locked “sa” login? It is quite a common practice that SQL Server is hosted on a separate server than application server. In most cases, SQL Server ports or IP are exposed to the web, which makes them risk prone. For hackers, System Admin login “sa” is the preferred account which they use for hacking. In fact, a majority of hackers try to hack into SQL Server by attempting to login using “sa” account. Once hackers gain access to server using “sa” login, they get a... - [SQL SERVER - Difference Between SQL Server Compact Edition (CE) and SQL Server Express Edition](https://blog.sqlauthority.com/2009/04/22/sql-server-difference-between-sql-server-compact-edition-ce-and-sql-server-express-edition/): I often received question regarding what are difference between SQL Server Compact Edition (CE) and SQL Server Express Edition. In one line – SQL Server CE is for mobile application and embaded systems where as SQL Server Express Edition is limited feature light version of SQL Server Standard. SQL Server Compact Edition SQL Server Express Edition ClickOnce Deployment ClickOnce Deployment Installed centrally with an MSI Installed centrally with an MSI XML storage XML storage Transact-SQL Transact-SQL Subscriber for merge replication Subscriber for merge replication Simple transactions Simple transactions Database size support – 4GB Database size support – 4GB Number of concurrent... - [SQL SERVER - What is Cloud Computing - Introduction to Cloud Computing](https://blog.sqlauthority.com/2009/04/21/sql-server-what-is-cloud-computing-introduction-to-cloud-computing/): “Cloud Computing,” to put it simply, means “Internet Computing.” The Internet is commonly visualized as clouds; hence the term “cloud computing” for computation done through the Internet. With Cloud Computing users can access database resources via the Internet from anywhere, for as long as they need, without worrying about any maintenance or management of actual resources. Besides, databases in cloud are very dynamic and scalable. Cloud computing is unlike grid computing, utility computing, or autonomic computing. In fact, it is a very independent platform in terms of computing. The best example of cloud computing is Google Apps where any application can... - [SQLAuthority Book Review - Pro T-SQL 2008 Programmer’s Guide by Michael Coles](https://blog.sqlauthority.com/2009/04/20/sqlauthority-book-review-pro-t-sql-2008-programmers-guide-by-michael-coles/): Pro T-SQL 2008 Programmer’s Guide by Michael Coles Link to Amazon Short Summary: Pro T-SQL 2008 Programmer’s Guide examines SQL Server 2008 T-SQL from a developer’s perspective. This information-rich book covers a wide array of developer-specific topics in SQL Server 2008. In addition, it provides in-depth knowledge of various newly introduced topics. This book is written as a practical guide to help database developers who mainly deal with T-SQL. It has really hit the spot with appropriate .NET code at a few places where required. The book assumes a basic knowledge of SQL, but it is very easy to understand for... - [SQL SERVER - Fix : SQL Server 2008 Developer Edition Install fail due to .NET Framework 3.5 missing](https://blog.sqlauthority.com/2009/04/19/sql-server-fix-sql-server-2008-developer-edition-install-fail-due-to-net-framework-35-missing/): It goes without saying that computer running slow is a common problem we all face, a pestering one indeed! Last week, I had to format my computer as it was running at an annoyingly tortoise pace. After formatting it, I installed Visual Studio 2008. When tested Visual Studio 2008 worked all fine. However, when I attempted to install SQL Server 2008, I was confronted with an error about NET Framework 3.5 missing. - [SQLAuthority News - Troubleshooting Performance Problems in SQL Server 2008](https://blog.sqlauthority.com/2009/04/18/sqlauthority-news-troubleshooting-performance-problems-in-sql-server-2008/): Troubleshooting Performance Problems in SQL Server 2008 SQL Server Technical Article Writers: Sunil Agarwal, Boris Baryshnikov, Keith Elmore, Juergen Thomas, Kun Cheng, Burzin Patel Technical Reviewers: Jerome Halmans, Fabricio Voznika, George Reynya Published: March 2009 - [SQLAuthority News - Authors Website Redesigned - http://www.pinaldave.com - Feedback Requested](https://blog.sqlauthority.com/2009/04/17/sqlauthority-news-authors-website-redesigned-httpwwwpinaldavecom-feedback-requested/): I’m pleased to inform you all that I’ve recently launched my personal website. It’s been a long time since I’ve been writing on my blog https://blog.sqlauthority.com, but I’ve been keeping my personal notes at my homepage http://www.pinaldave.com. I’ve completely rehauled the website to give it the much-needed makeover, right from redesigning the layout to writing fresh content. But, I would be extremely happy to have your feedback so that I can enhance my website further. I’ve always been a people’s person who believes in sharing his knowledge. Also, I want to see myself growing as an individual and as a professional.... - [SQLAuthority News - Microsoft Certification Exam - Discount Code](https://blog.sqlauthority.com/2009/04/16/sqlauthority-news-microsoft-certification-exam-discount-code/): Note: I am republishing this blog post as the offer of this code is extended to April 30, 2009. Please note down this important code or share with your colleagues who are keen to take Microsoft Certification Exam. This unique code is only available through Microsoft MVP’s and only published here to help community and no other intention. In this challenging economic climate, upgrading your IT skills becomes crucial to staying ahead. Invest in a Microsoft Certification to get the right IT skills. Register today with your MVP Certification Promotion Code:  and enjoy 2 chances to pass a Microsoft Certification Examination... - [SQL SERVER - Poll Result - What is Your Favorite Database?](https://blog.sqlauthority.com/2009/04/15/sql-server-poll-result-what-is-your-favorite-database/): I previously posted a Poll about What is Your Favorite Database? I got great response from users. In fact, I received some of the best poll-related comments on this blog  and they are worth reading. Let us check the result first. Here are the votes I received on different database. Total votes received are 1,697. SQL Server – 1,121 – 64% Oracle – 432 – 25% MySQL – 144 – 8% Other – 64 – 4% SQL Server is a clear winner with  1,121 votes, which is an astounding 64% of the total votes. As a matter of fact, it is... - [SQL SERVER - Check if Current Login is Part of Server Role Member](https://blog.sqlauthority.com/2009/04/14/sql-server-check-if-current-login-is-part-of-server-role-member/): I often work on consulting projects with umpteen clients from across the globe. The nature of the works I usually receive necessitates me to take on the role of a system admin. Now, this role is trailed by come common issues. This article revolves around one such concern. Let us learn about Server Role Member. - [SQL SERVER - Introduction to JOINs - Basic of JOINs](https://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/): The launch of Gandhinagar SQL Server User Group was a tremendous, astonishing success! It was overwhelming to see a large gathering of enthusiasts looking up to me (I was the Key Speaker) eager to enhance their knowledge and participate in some brainstorming discussions. Some members of User Group had requested me to write a simple article on JOINS elucidating its different types. INNER JOIN This join returns rows when there is at least one match in both the tables. OUTER JOIN There are three different Outer Join methods. LEFT OUTER JOIN This join returns all the rows from the left table... - [SQL SERVER - FIX : ERROR : The SQL Server System Configuration Checker cannot be executed due to WMI configuration on the machine Error:2147749896 (0×80041008)](https://blog.sqlauthority.com/2009/04/12/sql-server-fix-error-the-sql-server-system-configuration-checker-cannot-be-executed-due-to-wmi-configuration-on-the-machine-error2147749896-0%c3%9780041008/): A couple of days back I  had my computer formatted. I reinstalled it with Vista SP1 32bit. Subsequent to installing other indispensable software  I tried to install SQL Server 2005 .  However, it instantly displayed the following error message. The SQL Server System Configuration Checker cannot be executed due to WMI configuration on the machine Error:2147749896 (0×80041008). It was a bit frustrating for me as it was pretty late and I ardently wanted to install SQL Server 2008 right after I was done  with installing SQL Server 2005. I pinged my friend James Locazicoski with the above error message. James came... - [SQL SERVER - Interesting Observation of DMV of Active Transactions and DMV of Current Transactions](https://blog.sqlauthority.com/2009/04/11/sql-server-interesting-observation-of-dmv-of-active-transactions-and-dmv-of-current-transactions/): This post is about a riveting observation I made a few days back. While playing with transactions I came across two DMVs  that are associated with Transactions. 1) sys.dm_tran_active_transactions – Returns information about transactions for the instance of SQL Server. 2) sys.dm_tran_current_transaction – Returns a single row that displays the state information of the transaction in the current session. Now, what really interests me is the following observation. These two DMVs , in actual fact, display the distinction between active transactions and current transactions. Current transaction can be active transaction at the time of execution, but not all active transactions are... - [SQL SERVER - Restore or Attach Database Without .NDF or .MDF is Not Possible](https://blog.sqlauthority.com/2009/04/10/sql-server-restore-or-attach-database-without-ndf-or-mdf-is-not-possible/): This article revolves around a trivial yet common issue. There might be a set of people for whom the current topic might appear to be insignificant. But I have been asked this question innumerable times, particularly from   people who are frequenting using forums or have blog related to storage and highly availability, which instigated me to write this article. Here goes this frequently asked question. Question: Is it possible to restore database if one of the files of .mdf (primary data file) or .ndf (secondary data file) is missing? Answer: In one word the answer is NO. All the .mdf and... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2009/04/10/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-3/): Note: Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Scripts in the SQL Server 2008 management pack rely on SQL Data Management Objects (SQL-DMO) to query information from the SQL Server. SQL-DMO is now deprecated and is not shipped as a part of SQL Server... - [SQLAuthority News - Download SQL Server 2005 Report Packs - SQL Server Sample Reports - Report Templates](https://blog.sqlauthority.com/2009/04/10/sqlauthority-news-download-sql-server-2005-report-packs-sql-server-sample-reports-report-templates/): Note:   Download SQL Server 2005 Report Packs by Microsoft SQL Server 2005 Reporting Services is a comprehensive, server-based reporting solution designed to help you author, manage, and deliver both paper-based, ad hoc, and interactive Web-based reports. Each report pack consists of a set of predefined reports, a sample database, a readme file, and an End User License Agreement (EULA). You can use these sample reports as templates to quickly author and distribute new interactive reports. Report Pack contains following sample reports SQL Server 2005 Integration Services Log Reports SQL Server 2005 Report Pack for Microsoft Dynamics Axapta 3.0 SQL Server 2005... - [SQL SERVER - Fix Error 9803. Invalid data for type "numeric" - Data Type Mapping](https://blog.sqlauthority.com/2009/04/09/sql-server-fix-error-msg-9803-level-16-invalid-data-for-type-numeric-data-type-mapping-for-oracle-publishers/): My present article talks about an error that you will encounter when connecting to Oracle database using OPENQUERY. Let us learn about how to fix error 9803. - [SQL SERVER - Maximum Columns per Primary Key - Fix : Error : Msg 1904, Level 16, The index on table has column names in index key list. The maximum limit for index or statistics key column list is 16](https://blog.sqlauthority.com/2009/04/08/sql-server-maximum-columns-per-primary-key-fix-error-msg-1904-level-16-the-index-on-table-has-column-names-in-index-key-list-the-maximum-limit-for-index-or-statistics-key-column-list-is-16/): My present article covers two fundamental questions. 1) What is the maximum number of columns included in Primary Key Index/Constraint? 2) What is fix/solution for the following error: Msg 1904, Level 16, State 1, Line 1 The index ” on table ‘dbo.Table_2’ has 17 column names in index key list. The maximum limit for index or statistics key column list is 16. The same error surfaces when example is created using SSMS. Fix/Solution/Workaround: Maximum columns per Primary Key Index is 16. In fact, 16 is the limit for columns per Foreign Key and Index Key. You cannot have more than 16... - [SQLAuthority News - SQL Server 2008 Service Pack 1 Released - Available for Download](https://blog.sqlauthority.com/2009/04/08/sqlauthority-news-sql-server-2008-service-pack-1-released-available-for-download/): SQL Server 2008 Service Pack 1 (SP1) is now available. You can use these packages to upgrade any SQL Server 2008 edition. Download SQL Server 2008 Service Pack 1 Build of SP1 is SP1 is build 10.00.2531.00. Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Server Type and File Extention](https://blog.sqlauthority.com/2009/04/07/sql-server-server-type-and-file-extention/): Owing to my personal experience so far, I can undeniably say that Microsoft Windows products are outstanding. One of the reasons that make them exceptional is their little nifty tricks. For instance, every time I double click myfilename.sql it opens Microsoft SQL Server Management Studio (SSMS). The reason how Windows discerns that it has to open SSMS is because the extension of file I had clicked is .sql. I explored and found that SQL Server has few more filetypes associated with it, which are as follows. SQL Server – .sql SQL Server Compact 3.5 SP1 – .sqlce SQL Server Analysis Service... - [SQL SERVER - Logical Query Processing Phases - Order of Statement Execution](https://blog.sqlauthority.com/2009/04/06/sql-server-logical-query-processing-phases-order-of-statement-execution/): Of late, I penned down an article – SQL SERVER – Interesting Observation of ON Clause on LEFT JOIN – How ON Clause Effects Resultset in LEFT JOIN – which received a very intriguing comment from one of my regular blog readers Craig. According to him this phenomenon happens due to Logical Query Processing. His comment instigated a question in my mind. I have put forth this question to all my readers at the end of the article. Let me first give you an introduction to Logical Query Processing Phase. What actually sets SQL Server apart from other programming languages is... - [SQL SERVER - 2008 - Management Studio New Features](https://blog.sqlauthority.com/2009/04/05/sql-server-2008-management-studio-new-features/): Pinalkumar Dave describes the top 5 features of SQL Server Management Studio 2008. This article describes the top 5 features of SQL Server Management Studio 2008. With the release of SQL Server 2008 Microsoft has upgraded SSMS with many new features as well as added tons of new functionalities requested by DBAs for long time. SQL Server 2008 has been released for a year now. In SQL Server 2000, DBA had to use two different tools to maintain the database as well as the query database, specifically SQL Server Enterprise Manager and SQL Server Query Analyzer. With the release of SQL... - [SQL SERVER - Mirrored Backup and Restore and Split File Backup](https://blog.sqlauthority.com/2009/04/05/sql-server-mirrored-backup-and-restore-and-split-file-backup/): Introduction This article is based on a real life experience of the author while working with database backup and restore during his consultancy work for various organizations. We will go over the following important concepts of database backup and restore. Conventional Backup and Restore Spilt File Backup and Restore Mirror File Backup Understanding FORMAT Clause Miscellaneous details about Backup and Restore Conventional and Split File Backup and Restore Just a day before working on one of the projects, I had to take a backup of one database of 14 GB. My hard drive lacked sufficient space at that moment. Fortunately, I... - [SQL SERVER - Automated Index Defragmentation Script](https://blog.sqlauthority.com/2009/04/04/sql-server-automated-index-defragmentation-script/): Index Defragmentation is one of the key processes to significantly improve performance of any database. Index fragments occur when any transaction takes place in database table.  Fragmentation typically happens owing to insert, update and delete transactions. Having said that, fragmented data can produce unnecessary reads thereby reducing performance of heavy fragmented tables. I have often been asked to share my personal Index Defragmentation Script. Well, I use Automated Index Defragmentation Script created by my friend – a SQL Expert – Michelle Ufford (a.k.a SQLFool). Michelle is a SQL Server Developer, DBA, a humble blogger, and an absolute geek! She is also... - [SQLAuthority News - Launch of Gandhinagar SQL Server User Group](https://blog.sqlauthority.com/2009/04/03/sqlauthority-news-launch-of-gandhinagar-sql-server-user-group/): Gandhinagar SQL Server User Group launch event was held on March 27, 2009. This successful, well-attended event received very positive and warm community response. This launch event, unexpectedly, saw over 50 database enthusiasts participating. It was really a moment of pleasant surprise when we ran out of chairs. The otherwise spacious room started getting smaller as more and more people joined in, and unquestionably, we felt ecstatic about it! Visit Gandhinagar SQL Server User Group Portal and register yourself now! We commenced Gandhinagar SQL Server User Group launch event sharp at 6:30 and completed it precisely at 7:30. During these 60... - [SQL SERVER - Very Powerful and Feature-Rich Backup, Zip and FTP Utility SQLBackupAndFTP](https://blog.sqlauthority.com/2009/04/02/sql-server-very-powerful-and-feature-rich-backup-zip-and-ftp-utility-sqlbackupandftp/): It goes without saying that Database Backup is the most important task for any Database Administrator (DBA). Naturally, large organizations always have a team of DBAs who execute Database Backup tasks. No matter how big or small an organization is, the importance of database backup remains the same across the board. It’s a common practice in several organizations to upload the backup to their remote location for additional safety. I totally vouch for this safety measure of having their additional backup on remote/satellite location. This redundancy comes in handy whenever a catastrophe of not having proper backup surfaces abruptly. While I... - [SQL SERVER - Reseed Identity of Table - Table Missing Identity Values - Gap in Identity Column](https://blog.sqlauthority.com/2009/04/01/sql-server-reseed-identity-of-table-table-missing-identity-values-gap-in-identity-column/): Some time ago I was helping one of my Junior Developers who presented me with an interesting situation. He had a table with Identity Column. Because of some reasons he was compelled to delete few rows from the table. On inserting new rows in the table he noticed that the rows started from the next identity value which created gap in the identity value. His application required all the identities to be in sequence, so this was certainly not a small issue for him. The solution to this issue regarding gap in identity column is very simple. Let us first take... - [SQL SERVER - IntelliSense Does Not Work - Enable IntelliSense](https://blog.sqlauthority.com/2009/03/31/sql-server-2008-intellisense-does-not-work-enable-intellisense/): While I was working with SQL Server 2008 IntelliSense, I realized that it was not functioning as I expected. Even after I had enabled IntelliSense it was still not opening any suggestions at all. After a while, I figured out some vital information regarding how to make sure IntelliSense smoothly works all the time without you giving any trouble. Let us learn how we can Enable IntelliSense. - [SQLAuthority News - Top 10 Strategic Technologies for 2009](https://blog.sqlauthority.com/2009/03/30/sqlauthority-news-top-10-strategic-technologies-for-2009/): Gartner, Inc. analysts highlighted the top 10 technologies and trends that will be strategic for most organizations. Factors that denote significant impact include a high potential for disruption to IT or the business, the need for a major dollar investment, or the risk of being late to adopt. The top 10 strategic technologies for 2009 include: Virtualization. Much of the current buzz is focused on server virtualization, but virtualization in storage and client devices is also moving rapidly. Cloud Computing. Cloud computing is a style of computing that characterizes a model in which providers deliver a variety of IT-enabled capabilities to... - [SQL SERVER - Fix : Error : Msg 2714, Level 16, State 6 - There is already an object named '#temp' in the database](https://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/): Recently, one of my regular blog readers emailed me with a question concerning the following error: Msg 2714, Level 16, State 6, Line 4 There is already an object named ‘#temp’ in the database. This reader has been encountering the above-mentioned error, and he is curious to know the reason behind this. Here’s Rakesh’s email. Hi Pinal, I’m a  regular visitor to your blog and I thoroughly enjoy your articles and especially the way you solve your readers’ queries. I work as a junior SQL developer in Austin. Today, when I started to create a TSQL application, I detected an interesting... - [SQLAuthority News - SQL SERVER 2008 - Updated Brochure Available for Download](https://blog.sqlauthority.com/2009/03/28/sqlauthority-news-sql-server-2008-updated-brochure-available-for-download/): SQL Server 2008 new brochure is available for download. Microsoft® SQL Server® 2008 provides a trusted, productive, and intelligent data platform that enables you to: Run your most demanding mission-critical applications. Reduce time and cost of development and management of applications. Deliver actionable insight to your entire organization. Your Data, Any Place, Any Time. Download SQL Server 2008 Brochure Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Database Poll and Gandhinagar SQL Server User Group Launch Today](https://blog.sqlauthority.com/2009/03/27/sqlauthority-news-database-poll-and-gandhinagar-sql-server-user-group-launch-today/): I have published a poll on website few days ago for favorite database of SQLAuthority.com readers. The best comment will win USB drive. The poll will close on April 1, 2009. Looking at the poll result, it seems that Oracle has gained a lot over SQL Server from last time when I checked. Please share this poll with your friends, your UG and community to get better sample. If you are not interested in poll there are many interesting comments, please read them. Additionally, Gandhinagar SQL Server User Group has launch event today. I suggest all of you from surrounding area... - [SQLAuthority News - Author Video Interview Published Online - Microsoft MVP Summit 2009](https://blog.sqlauthority.com/2009/03/27/sqlauthority-news-author-video-interview-published-online-microsoft-mvp-summit-2009/): Microsoft MVP Award Blog and Microsoft South Asian MVP Blog has published my video interview online. My interview was conducted by Abhishek Kant – Microsoft MVP Lead and Technology Blogger. I am thankful to Abhishek Kant for conducting my interview, Abhishek Baxi for publishing on South Asian Blog and Jas Dhaliwal for producing the video. Above All I am very thankful to Microsoft for awarding me MVP Award. This video was shot at Microsoft MVP Summit 2009 at Seattle. Watch my Video on Microsoft MVP Award Blog Watch my Video on Microsoft South Asian MVP Blog Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error: Msg 15123, Level 16 - The configuration option 'advance option' does not exist, or it may be an advanced option.](https://blog.sqlauthority.com/2009/03/26/sql-server-fix-error-msg-15123-level-16-the-configuration-option-advance-option-does-not-exist-or-it-may-be-an-advanced-option/): I received another email describing error received due to my executing script from my previous article . Error : Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51 The configuration option ‘optimize for ad hoc workloads’ does not exist, or it may be an advanced option. Let us quickly see the reproduction of this error in following image. Fix/Workaround/Solution: The reason this error is happening because of not enabling advance option. Run complete following script and it should fix the problem. sp_CONFIGURE 'show advanced options',1 RECONFIGURE GO sp_CONFIGURE ‘optimize for ad hoc workloads’,1 RECONFIGURE GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 4621, Level 16, State 10 : Permissions at the server scope can only be granted when the current database is master](https://blog.sqlauthority.com/2009/03/26/sql-server-fix-error-msg-4621-level-16-state-10-permissions-at-the-server-scope-can-only-be-granted-when-the-current-database-is-master/): I have received comment from Radha Goswami on my previous blog article SQL SERVER – 2008 – Activity Monitor is Empty – Fix Activity Monitor for All Users. Radha is facing following error when she is tring to grant permission to login. Error: Msg 4621, Level 16, State 10, Line 1 Permissions at the server scope can only be granted when the current database is master Following image is I have recreated based on the above error message. Fix/Workaround/Solution: If you look at the database in use is AdventureWorks and when any server level persmission has to be granted the database... - [SQLAuthority News - Announcement - Gandhinagar SQL Server User Group - March 27, 2009](https://blog.sqlauthority.com/2009/03/25/sqlauthority-news-announcement-gandhinagar-sql-server-user-group-march-27-2009/): It is my pleasure to announce new SQL Server User Group – Gandhinagar SQL Server User Group. We will be meeting every 2nd and 4th Friday of the month. Here is the detail for this months meeting. We will be having one gift for best participant in the meeting. I request all the SQL enthusiast to attend this meeting and do not miss it. You can be member at sqlpass @ . Meeting Date Time: March 27, 2009 6:30 PM -7:30 PM Friday Meeting Agenda: 6:30 PM – 7:00 PM – Introduction to Joins and Real Life Scenario 7:00 PM –... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting Review - March 21, 2009](https://blog.sqlauthority.com/2009/03/25/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-review-march-21-2009/): We had fun session with Ahmedabad SQL Server Usre Group last week on March 21, 2009. It was short session but one interesting one. We discussed about how query profiler works and how to find most popular query from SQL Server instance. We had also prepared Trace Template as well query which can ran to identify longest running query along with popular query. I received nearly 10 questions after my session and lots of time was spent answering them. The whole session was very interactive. I want to congratulate everybody who attended it, if you need my Profiler Template and Query... - [SQL SERVER - 2008 - SCOPE_IDENTITY Bug with Multi Processor Parallel Plan and Solution](https://blog.sqlauthority.com/2009/03/24/sql-server-2008-scope_identity-bug-with-multi-processor-parallel-plan-and-solution/): This article is very serious and I would like to explain this as simple as I can. SCOPE_IDENTITY() which is commonly used in place of @@Identity has bug when run in Parallel Plan. You can read my explanation of @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT in earlier article. The bug is listed here in connect site SCOPE_IDENTITY() sometimes returns incorrect value. Additionally, the bug is also listed in Book Online on last line of the SCOPE_IDENTITY() documentation. When parallel plan is executed SCOPE_IDENTITY or IDENTITY may produce inconsistent results. The bug will be fixed in future versions of SQL Server. For SQL... - [SQL SERVER - 2008 - Location of Activity Monitor - Where is SQL Serve Activity Monitor Located](https://blog.sqlauthority.com/2009/03/23/sql-server-2008-location-of-activity-monitor-where-is-sql-serve-activity-monitor-located/): I received question from Aloke Sinha after reading my article SQL SERVER – 2008 – Activity Monitor is Empty – Fix Activity Monitor for All Users. Hello Pinalbhai, Thank you for your post about activity monitor, but I can not find activity monitor under Menu — Tools. How to activate it? [Other unrelated information removed] Take care, Aloke Sinha The reason I decided to write about this subject is because I totally understand why Aloke is confused here. Activity Monitor can not be activated from any menu from top menu bar. There are two different methods to activate Activity Monitors. From... - [SQL SERVER - 2008 - Activity Monitor is Empty - Fix Activity Monitor for All Users](https://blog.sqlauthority.com/2009/03/22/sql-server-2008-activity-monitor-is-empty-fix-activity-monitor-for-all-users/): This article is an outcome of the technical discussion of activity monitor and its behavior with my friend and SQL Expert Tejas Shah. Tejas told me that he does not like to re-write content from MSDN, but rather prefer to write real life scenarios, as that prepares him to become a better SQL Expert. While discussing about Activity Monitor he informed that it throws an error when there is a permissions issue. He has even blogged about how to give permissions to user to launch activity monitor on his blog . Tejas asked me to write on the same subject for SQL Server 2008. Here is the article covering the discussion I had with Tejas. - [SQL SERVER - 2008 - Optimize for Ad hoc Workloads - Advance Performance Optimization](https://blog.sqlauthority.com/2009/03/21/sql-server-2008-optimize-for-ad-hoc-workloads-advance-performance-optimization/): Every batch (T-SQL, SP etc) when ran creates execution plan which is stored in system for re-use. Due to this reason large number of query plans are stored in system. However, there are plenty of plans which are only used once and have never re-used again. One time ran batch plans wastes memory and resources. SQL Server 2008 has feature of optimizing ad hoc workloads. Before we move to it, let us understand the behavior of SQL Server without optimizing ad hoc workload. Please run following script for testing. Make sure to not to run whole batch together. Just run each... - [SQL SERVER - AWE (Address Windowing Extensions) Explained in Simple Words](https://blog.sqlauthority.com/2009/03/20/sql-server-awe-address-windowing-extensions-explained-in-simple-words/): I was asked question by Jr. DBA that “What is AWE?”. For those who do know what is AWE or where is it located, it can be found at SQL Server Level properties. AWE is properly explained in BOL so we will just have our simple explanation. Address Windowing Extensions API is commonly known as AWE.  AWE is used by SQL Server when it has to support very large amounts of physical memory. AWE feature is only available in SQL Server Enterprise, Standard, and Developer editions with of SQL Server 32 bit version. Microsoft Windows 2000/2003 server supports maximum of 64GB... - [SQLAuthority News - 900th Article - 9 Best Practices - Important Milestones](https://blog.sqlauthority.com/2009/03/19/sqlauthority-news-900th-article-9-best-practices-important-milestones/): Today is my 900th article on this blog. You can see list of all the 900 articles here. I suggest you go over the list and read any article you like. - [SQL SERVER - Find All Servers From Local Network - Using sqlcmd - Detect Installed SQL Server on Network](https://blog.sqlauthority.com/2009/03/18/sql-server-find-all-servers-from-local-network-using-sqlcmd/): I recently had requirement to create list of all the SQL Server on local network. I remembered that I had written similar script a year ago SQL SERVER – Script to Find SQL Server on Network. When I looked at it, I realize that I had written it for SQL Server 2000 and used “isql” utility, which is deprecated now. I quickly wrote down updated script using “sqlcmd”. Command “osql” still works in SQL Server 2008. Go to command prompt and type in “osql -L” or “sqlcmd -L”. Note one change between osql and sqlcmd is that osql has additional server... - [SQL SERVER - Practical SQL Server XML: Part One - Query Plan Cache and Cost of Operations in the Cache](https://blog.sqlauthority.com/2009/03/17/sql-server-practical-sql-server-xml-part-one-query-plan-cache-and-cost-of-operations-in-the-cache/): I am very fortunate that I have friends like Michael Coles. Michael Coles is SQL Server and XML expert and have written many books on SQL Server as well XML. He has previously written book which I have reviewed on this blog SQLAuthority News – Book Review – Pro T-SQL 2005 Programmer’s Guide (Paperback). I am currently reading his latest book Pro SQL Server 2008 XML (Hardcover) which can be found on amazon. I will be writing review of the book once I am done reading it. Michael Coles and I met last at Microsoft MVP Summit 2009 at Seattle and... - [SQL SERVER - UDF - Pad Ride Side of Number with 0 - Fixed Width Number Display](https://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/): SQL SERVER - UDF - Pad Ride Side of Number with 0 - Fixed Width Number Display. Let us learn more about this blog. - [SQL SERVER - Interesting Observation of ON Clause on LEFT JOIN - How ON Clause affects Resultset in LEFT JOIN ](https://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/): Today I received email from Yoel from Israel. He is one smart man always bringing up interesting questions. Let us see his latest email first. Hi Pinal, I am subscribed to your blog and enjoy reading it. I have a question which has been bothering me for some time now. When I want to filter records in a query, I usually put the condition in the WHERE clause. When I make an inner join, I can put the condition in the ON clause instead, giving the same result. But with left joins this is not the case. Here is a quote... - [SQLAuthority News - Lots of SQL Server News - Tip of the Article](https://blog.sqlauthority.com/2009/03/14/sqlauthority-news-lots-of-sql-server-news/): I have been reeving lots of feedback from blog readers and what I have learned that they all wanted me to write about SQL Server Community news at least once a week. I am not sure if I can write every week what are happening in SQL Server world but I promise to write about news when I have collected few important news. Let me try this time how it goes and we will see in future how do you like it based on on your feedback. IPD Guide: Let me start with what has been keeping me busy recently. I... - [SQL SERVER - Profiler - Adding Filters - Observation on CPU Load](https://blog.sqlauthority.com/2009/03/13/sql-server-profiler-adding-filters-observation-on-cpu-load/): Today I am blog about something which I found recently while working with SQL Server Profiler. Profiler can be invoked just typing profiler in command prompt. I am using Windows Vista Ultimate 32 bit (License Version) and SQL Server 2008 Development (License Version). The reason I have put “License Version” because I encourage everybody to use only licensed software. SQL Server Profiler gives feature where we can specify which column filter. Column filter can have value which can be validated with atucal data and based on it, it will store information in profiler stress. I was always under impression that adding... - [SQL SERVER - What is Your Favorite Database? - Poll Continuous](https://blog.sqlauthority.com/2009/03/12/sql-server-what-is-your-favorite-database-poll-continuous/): I have published SQL Server Poll about What is Your Favorite Database? to get feedback from readers of this blog about what is their favorite database. I have received so far tremendous response. This poll will continue through out this month and will close on 1st of April. I will post all the statistic once the poll is over. I encourage all of you to spread the word about it to different channels, blogs, linked list and emails. It is not only important to vote for your favorite database but it is equally important to leave comment justifying why and which... - [SQL SERVER - Difference Between Union vs. Union All - Optimal Performance Comparison](https://blog.sqlauthority.com/2009/03/11/sql-server-difference-between-union-vs-union-all-optimal-performance-comparison/): More than a year ago I had written article SQL SERVER – Union vs. Union All – Which is better for performance? I have got many request to update this article. It is not fair to update already written article so I am rewriting it again with additional information. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the... - [SQL SERVER - Pad Ride Side of Number with 0 - Fixed Width Number Display](https://blog.sqlauthority.com/2009/03/10/sql-server-pad-ride-side-of-number-with-0-fixed-width-number-display/): Today we will look something which is very quick and but quite frequently useful string operation over numeric datatype. This article is written based on a question asked by one of the users (name not disclosed as per request). Let us see how to show a fixed width number display.  - [SQLAuthority News - Author Visit - Complete Wrapup of Microsoft MVP Summit 2009 Trip](https://blog.sqlauthority.com/2009/03/09/sqlauthority-news-author-visit-complete-wrapup-of-microsoft-mvp-summit-2009-trip/): Today I have arrived in India and back to Ahmedabad. I have left my home on 27th February and arrived back at my home on 9th March. I was traveling for total of 10 days out of 2 days were just technically included as they were very little occupied. I was traveling for 3 days out of remaining 8 days. This leaves me with total of 5 business day. This five days I worked for nearly 16 hours everyday attending Microsoft MVP summit technical sessions, having meetings with industry leaders and learning new things. I have posted my complete tour details... - [SQLAuthority News - Author Visit - South Asian MVPs at Global MVP Summit 2009](https://blog.sqlauthority.com/2009/03/08/sqlauthority-news-author-visit-south-asian-mvps-at-global-mvp-summit-2009/): I am currently at Mumbai Airport and waiting for my flight to Ahmedabad. I am little exhausted but had great time at Global MVP Summit 2009. There were lots of South Asian MVPs present at global event as well. We all had great time to network with each other and few of the MVPs who had arrived day before summit had great time touring Seattle together. We all MVPs had learned so many things about each other and shared some internal tips with each other. One thing we all decided is guest blogging, where we will write blog article for each... - [SQLAuthority News - Author Visit - Tech User Group Meeting, Markham, Canada and Toronto CA Solutions](https://blog.sqlauthority.com/2009/03/07/sqlauthority-news-author-visit-tech-user-group-meeting-markham-canada-and-toronto-ca-solutions/): I can talk about database almost all the day. Yesterday I had two technical meetings. One with Tech User Group of Markham and another with TorontoCASolutions. Let us go over my summary of both the meetings. Tech User Group of Markham, Canada Steve Jagadishan is very enthusiastic leader of the Tech User Group. This user group is very new UG and learning all the tricks and treads. UG is still very small and it has only 6 members so far. There are lots of challenges they are facing and we had interesting discussion at Timothy’s Coffee (a famous Canadian coffee chain).... - [SQLAuthority News - Author Visit - Toronto, Canada - Insert Image in Database](https://blog.sqlauthority.com/2009/03/06/sqlauthority-news-author-visit-toronto-canada-insert-image-in-database/): I am traveling to Toronto from Microsoft MVP Sumeet. I will be very tired as I am continuously working very hard from last 27th Feb. I am still Jet Legged from my trip from India to USA and now I am again changing time zones by visiting Canada. I get all my energy from feeling that what I am doing is helping community and I am working hard to help people who are looking for help. Interestingly Steven Biggins, a reader of this blog was with me in same flight to Canada. He recognized me and asked me following question. As... - [SQLAuthority News - MVP Summit 2009 - Day 4 - Keynote of Steve Ballmer](https://blog.sqlauthority.com/2009/03/05/sqlauthority-news-mvp-summit-2009-day-4-keynote-of-steve-ballmer/): An action pack day with lots of tech session and 4 back to back Keynote sessions is over. Steve Ballmer presented one of the keynote where all attendees really felt energetic. Steve is the person who has so much energy that may be 16 year old kid feel older in front of him. Just like his style, he came in and took over complete session under his charm. I really wish, I could have shared more information but due to NDA I can not share it. It was explicitly expressed that photographs are allowed to take and publish so I am... - [SQLAuthority News - MVP Summit 2009 - Day 3 - Party Day and SQL Celebrity Photos](https://blog.sqlauthority.com/2009/03/04/sqlauthority-news-mvp-summit-2009-day-3-party-day-and-sql-celebrity-photos/): Today was the third day of MVP Summit 2009 and it was wonderful. I had my dream come true as I was able to meet Kalen Delaney – a legendary author of SQL Server and truly living SQL God. If I had not met her today, my trip to USA would have not been complete. I am awaiting for famous book Microsoft SQL Server 2008 Internals (Pro – Developer) to release and I will be the first one to purchase for sure. I really wish if I can get early copy of the book as I just can not wait for... - [SQLAuthority News - MVP Summit 2009 - Day 2 - Most Contributing MVP of Year](https://blog.sqlauthority.com/2009/03/03/sqlauthority-news-mvp-summit-2009-day-2-most-contributing-mvp-of-year/): Day 2 of MVP Summit 2009 was filled with Back to Back Technical session. However, due to NDA I will be not able to share the details about the session. I even verified that I can not even post the title of the session which I have attended. I can only talk general details about the event. In one line – “It is one GREAT event!” Interested readers can read about MVP event schedule here : Agenda of Microsoft MVP Summit 2009. It was the best day for me as I was chosen to have honor by fellow MVP for one... - [SQLAuthority News - MVP Summit 2009 - Day 1 - Summit Welcome and Keynotes](https://blog.sqlauthority.com/2009/03/02/sqlauthority-news-mvp-summit-2009-day-1-summit-welcome-and-keynotes/): My regular blog readers must be aware of my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today was day 1 of MVP Summit and we had started it with big gala event. In morning few of Indian MVP visited Seattle Space Needle and had too much fun there. The Space Needle is a tower in Seattle, Washington, but similar to the one in tokyo, Japan, and is a major landmark of the Pacific Northwest region of the United States and a symbol of Seattle. Located at the Seattle Center, it was built for... - [SQLAuthority News - MVP Summit 2009 - Day 0 - About Pinal Dave](https://blog.sqlauthority.com/2009/03/01/sqlauthority-news-mvp-summit-2009-day-0-about-pinal-dave/): Today is first day of MVP Summit 2009 in Seattle and I am very excited to attend it. This is first time I am in Seattle and I am really liking it. I am planning to visit Seattle Needle and Starbucks coffee shops. One question I have received many times so far is Where am I am from? and once I answer that question I get follow up question about Why I did so? Let me answer this question on my blog today so my readers know about it. I am currently located in Ahmedabad, Gujarat, India and working as SQL... - [SQLAuthority News - MVP Summit 2009 - Database Industry Discussion - Live From London Airport and Sheraton Seattle](https://blog.sqlauthority.com/2009/02/28/sqlauthority-news-mvp-summit-2009-database-industry-discussion-live-from-london-airport-and-sheraton-seattle/): My regular blog readers must be aware of my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today I have very interesting day and my tour has converted to technical discussion from the airport itself. I accidentally met my friend and fellow MVP as well SQL Server Expert Suprotim Agarwal at Mumbai Airport. We will be traveling all the way to Seattle together in same flights. Suprotim is wonderful person to meet as a top notch tech geek of India. We both have same interest and love for technologies. We discussed many tech related... - [SQLAuthority News - MVP Summit 2009 - Journey Begins](https://blog.sqlauthority.com/2009/02/27/sqlauthority-news-mvp-summit-2009-journey-begins/): I will be blogging actively about my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today I will be leaving for Mumbai. I will be at Mumbai International Airport between 10 PM to 2 AM. If you are traveling and in Mumbai during this four hours, let us meet and talk about Microsoft and SQL Server. I already have received couple of email from SQL Enthusiastics who will be coming to Airport to meet me, so look for 3-4 people sitting gather looking at Dell XPS and having fun. While I am traveling to... - [SQL SERVER - 2008 - Find Relationship of Foreign Key and Primary Key using T-SQL - Find Tables With Foreign Key Constraint in Database](https://blog.sqlauthority.com/2009/02/26/sql-server-2008-find-relationship-of-foreign-key-and-primary-key-using-t-sql-find-tables-with-foreign-key-constraint-in-database/): While searching for how to find Primary Key and Foreign Key relationship using T-SQL, I came across my own blog article written earlier SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database. It is really handy script and not found written on line anywhere. This is one really unique script and must be bookmarked. There may be situations when there is need to find out on relationship between Primary Key and Foreign Key. I have modified my previous script to add schema name along with table name. It would be really great if any of you can... - [The Poll - What is Your Favorite Database?](https://blog.sqlauthority.com/2009/02/25/the-poll-what-is-your-favorite-database/): What is Your Favorite Database? - [SQLAuthority News - Author Visit - MVP Global Summit 2009 - Seattle and Redmond](https://blog.sqlauthority.com/2009/02/24/sqlauthority-news-author-visit-mvp-global-summit-2009-seattle-and-redmond/): MVP Global Summit 2009 is just a less than a week away and I am very all ready for attending my first MVP Global Summit. Microsoft Most Valuable Professionals (MVPs) are invited to attend the MVP Global Summit at the Washington State Convention & Trade Center in Seattle and at Microsoft headquarters in Redmond, Washington, from March 1 through 4. This year’s event promises to provide opportunities for MVPs to network and socialize with their technical peers, build stronger relationships with Microsoft product teams, and represent their communities by sharing real world insight and feedback. Following is my travel itinerary: Feb... - [SQL SERVER - Disable Windows Authentication - Remove Windows Authentication Login Account](https://blog.sqlauthority.com/2009/02/24/sql-server-disable-windows-authentication-remove-windows-authentication-login-account/): I just received following email from one of the blog reader. Question : “How to disable Windows Authentication?” Answer : It can not be disabled. Windows Authentication is the most secure way to login in system. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad User Group Meeting February 21 2009](https://blog.sqlauthority.com/2009/02/23/sqlauthority-news-ahmedabad-user-group-meeting-february-21-2009-2/): We had Ahmedabad SQL Server User Group meeting on February 21, 2009 and it was wonderful to see so many people showing up for meeting. Gradually our group is growing and more and more developers and DBA are showing up. We had two session in this meeting. From the feedback which we have received I can say that it went excellent and developer loved it. In fact there was request to repeat similar kind of sessions to continue. We had started the session little earlier based on attendee’s feedback at 6:15. The agenda of our meeting today was as following. Interesting... - [SQL SERVER - Download - Microsoft SQL Server 2008 Management Studio Express](https://blog.sqlauthority.com/2009/02/22/sql-server-download-microsoft-sql-server-2008-management-studio-express/): Microsoft SQL Server 2008 Management Studio Express is a free, integrated environment for accessing, configuring, managing, administering, and developing all components of SQL Server. SQL Server 2008 Management Studio Express combines a broad group of graphical tools with a number of rich script editors to provide access to SQL Server to developers and administrators of all skill levels. Download – Microsoft SQL Server 2008 Management Studio Express Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - My Observation - Effect of Clustered Index over Nonclustered Index](https://blog.sqlauthority.com/2009/02/21/sql-server-observation-effect-clustered-index-nonclustered-index/): Note: This article is re-write of my previous article SQL SERVER – Observation – Effect of Clustered Index over Nonclustered Index. I have received so many request that re-write it as it is little confusing. I am going to re-write this with simpler words. Query optimization is one art which is difficult to master. Just like any other art this requires creativity and imagination as well understanding of subject matter. Let us look at interesting observation which I came across. First of all download the script from here and run it in SSMS. Now enable Execution Plan (Using CTRL + M)... - [SQLAuthority News - Ahmedabad User Group Meeting February 21 2009](https://blog.sqlauthority.com/2009/02/20/sqlauthority-news-ahmedabad-user-group-meeting-february-21-2009/): It is my pleasure to announce that SQL Server User Group Meeting is held on February 21, 2009. This is the second meeting of year 2009 and will be one interesting meeting as we will have back to back two presentation from SQL Experts. The agenda of meeting will be as following. Working with IDENTITY values in SQL Server – Jacob Sebastian (SQL Server MVP) Interesting Observation – SQL Server Index Usage – Pinal Dave (SQL Server MVP) I encourage every SQL enthusiastic in city to attend this meeting as this will be one memorable event. From this month onwards we... - [SQL SERVER - Disabling Indexes - Non Clustered Indexes](https://blog.sqlauthority.com/2009/02/19/sql-server-disabling-indexes-non-clustered-indexes/): I came across a fantastic T-SQL script that offers an additional feature for changing the recovery mode while enabling and disabling indexes. - [SQLAuthority Author Visit - A True Outsourcing Giant and Technology Leader DigiCorp in Ahmedabad India](https://blog.sqlauthority.com/2009/02/18/sqlauthority-author-visit-a-true-outsourcing-giant-and-technology-leader-digicorp-in-ahmedabad-india/): Last week, I happen to visit one of the tech company in Ahmedabad, India. I visit different IT organization for two purpose – learn more about technology advancement in different organization and help them with any issues if they are facing with Microsoft technology and in particular SQL Server. I visited DigiCorp Information Systems Pvt. Ltd. and I was impressed by its technological advancement and exposure to cutting edge technology. DigiCorp was founded in Jan 2004 and now maintains between 60 and 70 employees in bustling Ahmedabad, India. The company specializes in customized application development in .NET, PHP, Windows Mobile, iPhone... - [SQL SERVER - Find Current Location of Data and Log File of All the Database](https://blog.sqlauthority.com/2009/02/17/sql-server-find-current-location-of-data-and-log-file-of-all-the-database/): As I am doing lots of experiments on my SQL Server test box, I sometime gets too many files in SQL Server data installation folder – the place where I have all the .mdf and .ldf files are stored. I often go to that folder and clean up all unnecessary files I have left there taking up my hard drive space. I run following query to find out which .mdf and .ldf files are used and delete all other files. If your SQL Server is up and running OS will not let you delete .mdf and .ldf files any way giving... - [SQL SERVER - List All Server Wide Configurations Values](https://blog.sqlauthority.com/2009/02/16/sql-server-list-all-server-wide-configurations-values/): Just a day ago, while working on one of the project, I needed to see what is the two digit year cutoff of my current SQL Server. I did not remember what was the exact syntax to search for the same so I ran following query to list all server wide configurations. While looking at quickly I found out value of two digit year cutoff on line 19th. A small but very important script to save for getting server information. - [SQL SERVER - Reasons to Backup Master Database - Why Should Master Database Backedup](https://blog.sqlauthority.com/2009/02/15/sql-server-reasons-to-backup-master-database-why-should-master-database-backedup/): The most interesting thing about writing blog at SQLAuthority.com is follow up question. Just a day before I wrote article about SQL SERVER – Restore Master Database – An Easy Solution, right following it, I received email from user requesting reason for importance of backing up master database. Master database contains all the system level information of server. Information about all the login account, system configurations and information required to access all the other database are stored in master database. If master database is damaged, it will be difficult to use any other database in SQL Server and that makes it... - [SQL SERVER - Restore Master Database - An Easy Solution](https://blog.sqlauthority.com/2009/02/14/sql-server-restore-master-database-an-easy-solution/): Today we will go over two step easy method to restore ‘master’ database. It is really unusal to have need of restoring the master database. In very rare situation this need should arises. It is important to have full backup of master database, without full backup file of master database it can not be restored. It is necessary to start SQL Server in single user mode before master database can be restored. It is very easy to start SQL Server server in single user mode. Follow the tutorial SQL SERVER – Start SQL Server Instance in Single User Mode. Once SQL... - [SQL SERVER - Simple Example of Reading XML File Using T-SQL](https://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/): In one of the previous article we have seen how we can create XML file using SELECT statement SQL SERVER – Simple Example of Creating XML File Using T-SQL. Today we will see how we can read the XML file using the SELECT statement. Following is the XML which we will read using T-SQL: Following is the T-SQL script which we will be used to read the XML: DECLARE @MyXML XML SET @MyXML = '<SampleXML> <Colors> <Color1>White</Color1> <Color2>Blue</Color2> <Color3>Black</Color3> <Color4 Special="Light">Green</Color4> <Color5>Red</Color5> </Colors> <Fruits> <Fruits1>Apple</Fruits1> <Fruits2>Pineapple</Fruits2> <Fruits3>Grapes</Fruits3> <Fruits4>Melon</Fruits4> </Fruits> </SampleXML>' SELECT a.b.value(‘Colors[1]/Color1[1]’,‘varchar(10)’) AS Color1, a.b.value(‘Colors[1]/Color2[1]’,‘varchar(10)’) AS Color2, a.b.value(‘Colors[1]/Color3[1]’,‘varchar(10)’) AS Color3, a.b.value(‘Colors[1]/Color4[1]/@Special’,‘varchar(10)’)+‘ ‘+ +a.b.value(‘Colors[1]/Color4[1]’,‘varchar(10)’)... - [SQL SERVER - Simple Example of Creating XML File Using T-SQL](https://blog.sqlauthority.com/2009/02/12/sql-server-simple-example-of-creating-xml-file-using-t-sql/): I always want to learn SQL Server and XML file. Let us go over a very simple example, today about how to create XML using SQL Server. - [SQL SERVER - Technical Articles - Performance Optimizations for the XML Data Type in SQL Server 2005](https://blog.sqlauthority.com/2009/02/11/sql-server-technical-articles-performance-optimizations-for-the-xml-data-type-in-sql-server-2005/): I always wanted to learn XML and its usage. My friend and fellow MVP Jacob Sebastian is expert in XML, so if you are interested in XML please visit his blog here. If you are interested in performance optimization for XML Data type in SQL Server following article is must read for you. Performance Optimizations for the XML Data Type in SQL Server 2005 by  Shankar Pal, Babu Krishnaswamy, Vasili Zolotov, and Leo Giakoumakis – Microsoft Corporation Articles covers following subjects. Introduction Data Modeling with the XML Data Type Bulk Loading XML Data Indexing XML Data Query and Data Modification Conclusion... - [SQL SERVER - Start SQL Server Instance in Single User Mode](https://blog.sqlauthority.com/2009/02/10/sql-server-start-sql-server-instance-in-single-user-mode/): There are certain situation when user wants to start SQL Server Engine in “single user” mode from the start up. To start SQL Server in single user mode is very simple procedure as displayed below. Go to SQL Server Configuration Manager and click on  SQL Server 2005 Services. Click on desired SQL Server instance and right click go to properties. On the Advance table enter param ‘-m;‘ before existing params in Startup Parameters box. Make sure that you entered semi-comma after -m. Once that is completed, restart SQL Server services to take this in effect. Once this is done, now you... - [SQL SERVER - 2008 - Download Microsoft SQL Server 2008 Express with Tools Free](https://blog.sqlauthority.com/2009/02/09/sql-server-2008-download-microsoft-sql-server-2008-express-with-tools-free/): Note: Download Microsoft SQL Server 2008 Express with Tools Free by Microsoft SQL Server 2008 Express Edition was much awaited version of SQL Server 2008. It is FREE and available to download from web. Microsoft SQL Server 2008 Express with Tools (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes graphical management tools. SQL Server 2008 Express provides powerful and reliable data management tools and rich features, data protection, and fast performance. It is ideal for small server applications and local data stores. SQL Server 2008 Express with Tools has all of the features in... - [SQLAuthority News - Book Review - Beginners Guide to SQL Server Integration Services Using Visual Studio 2005](https://blog.sqlauthority.com/2008/01/28/sqlauthority-news-book-review-beginners-guide-to-sql-server-integration-services-using-visual-studio-2005/): Beginners Guide to SQL Server Integration Services Using Visual Studio 2005 (Paperback) by Jayaram Krishnaswamy (Author) Link to Amazon Short Summary: SQL Server Integration Services Using Visual Studio 2005 contains all the information and education needed for one to begin with SSIS. It covers all the basic concepts in depth and moves towards advance concepts of Extraction, Transformation and Loading (ETL). One book for all the beginners in SSIS. Detail Summary: SQL Server Integration Services (SSIS) is a comprehensive ETL tool available in SQL Server 2005. It is integrated with Visual Studio 2005 (VS2K5). SSIS is replacement of Data Transformation Services... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2008/01/27/sqlauthority-news-sql-joke-sql-humor-sql-laugh-funny-quotes/): Following is the collection of some funny quotes regarding computers. Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Rich Cook. UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. Dennis Ritchie. The perfect computer has been developed. You just feed in your problems and they never come out again. Al Goodman. Computers make it easier to do a lot of things, but most of the things they make... - [SQLAuthority News - Microsoft SQL Server 2000 MSIT Configuration Pack for Configuration Manager 2007](https://blog.sqlauthority.com/2008/01/26/sqlauthority-news-microsoft-sql-server-2000-msit-configuration-pack-for-configuration-manager-2007/): Microsoft SQL Server 2000 MSIT Comprehensive Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2000 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2000 MSIT Intermediate Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2000 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2000 MSIT Basic Configuration Pack for Configuration Manager 2007 This... - [SQL SERVER - 2005 - Database Table Partitioning Tutorial - How to Horizontal Partition Database Table](https://blog.sqlauthority.com/2008/01/25/sql-server-2005-database-table-partitioning-tutorial-how-to-horizontal-partition-database-table/): I have received calls from my DBA friend who read my article SQL SERVER - 2005 - Introduction to Partitioning. He suggested that I should write a simple tutorial about how to horizontal partition database table. Here is a simple tutorial which explains how a table can be partitioned. - [SQL SERVER - 2005 - Introduction to Partitioning](https://blog.sqlauthority.com/2008/01/24/sql-server-2005-introduction-to-partitioning/): Partitioning is the database process or method where very large tables and indexes are divided in multiple smaller and manageable parts. SQL Server 2005 allows to partition tables using defined ranges and also provides management features and tools to keep partition tables in optimal performance. Tables are partition based on column which will be used for partitioning and the ranges associated to each partition. Example of this column will be incremental identity column, which can be partitioned in different ranges. Different ranges can be on different partitions, different partition can be on different filegroups, and different partition can be on different... - [SQLAuthority News - Download Microsoft SQL Server 2005 Assessment Configuration Pack](https://blog.sqlauthority.com/2008/01/23/sqlauthority-news-download-microsoft-sql-server-2005-assessment-configuration-pack/): Microsoft SQL Server 2005 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Gramm-Leach Bliley Act compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains... - [SQLAuthority News - Fix : Remote Desktop Copy Paste Stop Working](https://blog.sqlauthority.com/2008/01/22/sqlauthority-news-fix-remote-desktop-copy-paste-stop-working/): Today’s article is not related to SQL Server 100%, however it is quite related to SQL Server, or atleast I found it while working with SQL Server. Just two days ago, while I was working with remote SQL Server using Remote Desktop tool provided by Windows XP. Suddenly, copy/paste feature of windows stop working on remote desktop. I was not able to copy from local machine to remote machine and remote machine to local machine, both ways. I was able to copy/paste from remote machine to remote machine and local machine to local machine. I thought may be if I restart... - [SQL SERVER - Get a Row Per File of a Database as Stored in the Master Database](https://blog.sqlauthority.com/2008/01/21/sql-server-2005-get-a-row-per-file-of-a-database-as-stored-in-the-master-database/): Each database has a minimum of two files associated with the database. If a database has more than one filegroup it will have many files associated with one database. Following quick script will give you recordset per file of a database which is stored in master database. - [SQL SERVER - Introduction to Statistical Functions - VAR, STDEVP, STDEV, VARP](https://blog.sqlauthority.com/2008/01/20/sql-server-introduction-to-statistical-functions-var-stdevp-stdev-varp/): Yesterday I wrote article about SQL SERVER – Introduction to Aggregate Functions. I received one email that four of the aggregate functions are statistical function and I should write something about that. VAR, STDEVP, STDEV, VARP are statistical functions as well they absolutely fit in the definition of aggregate function as well. The usage of this function is pretty simple so instead of explaining them I will go to example right away. USE AdventureWorks; GO SELECT VAR(Bonus) 'Variance', STDEVP(Bonus) 'Standard Deviation', STDEV(Bonus) 'Standard Deviation', VARP(Bonus) 'Variance for the Population' FROM Sales.SalesPerson; GO All the functions returns result as datatype float. VAR... - [SQL SERVER - Introduction to Aggregate Functions](https://blog.sqlauthority.com/2008/01/19/sql-server-introduction-to-aggregate-functions/): Recently I have been taking many interviews to increase work force in my companies outsourcing establishment. One question I ask to all interview candidates. What is Aggregate Function? So far I have received two different kind of response. First, I do not know. Second, AVG, SUM, COUNT are aggregate functions. The second response is good enough but not technically correct. None of the candidate have gave me good definition of Aggregate Function. Definition from BOL is Aggregate functions perform a calculation on a set of values and return a single value. Following functions are aggregate functions. AVG, MIN, CHECKSUM_AGG, SUM, COUNT,... - [SQL SERVER - 2005 Best Practices Analyzer (January 2008)](https://blog.sqlauthority.com/2008/01/18/sql-server-2005-best-practices-analyzer-january-2008/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD TOOL HERE Best Practice Analyzer (BPA) Tutorial Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Job Description of Database Administrator (DBA) or Database Developer](https://blog.sqlauthority.com/2008/01/17/sqlauthority-news-job-description-of-database-administrator-dba-or-database-developer/): Job Description of Database Administrator (DBA) or Database Developer Develop standards and guidelines to guide the use and acquisition of software and to protect vulnerable information. Modify existing databases and database management systems or direct programmers and analysts to make changes. Test programs or databases, correct errors and make necessary modifications. Plan, coordinate and implement security measures to safeguard information in computer files against accidental or unauthorized damage, modification or disclosure. Approve, schedule, plan, and supervise the installation and testing of new products and improvements to computer systems, such as the installation of new databases. Train users and answer questions. Establish... - [SQLAuthroity News - Microsoft SQL Server 2000 Assessment Configuration Pack](https://blog.sqlauthority.com/2008/01/16/sqlauthroity-news-microsoft-sql-server-2000-assessment-configuration-pack/): Microsoft SQL Server 2000 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2000 servers in order to support your Federal Information Security Management Act compliance efforts. Microsoft SQL Server 2000 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2000 servers in order to support your Gramm-Leach Bliley Act compliance efforts. Microsoft SQL Server 2000 Assessment Configuration Pack for Health Insurance Portability... - [SQL SERVER - What is - DML, DDL, DCL and TCL - Introduction and Examples](https://blog.sqlauthority.com/2008/01/15/sql-server-what-is-dml-ddl-dcl-and-tcl-introduction-and-examples/): DML DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. Examples: SELECT, UPDATE, INSERT statements DDL DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. Examples: CREATE, ALTER, DROP statements DCL DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it. Examples: GRANT, REVOKE statements TCL TCL is abbreviation of Transactional Control Language. It is used to... - [SQL SERVER - Time Out Due to Executing DELETE on Large RecordSet](https://blog.sqlauthority.com/2008/01/14/sql-server-time-out-due-to-executing-delete-on-large-recordset/): Just a day ago, I received following question: “I have large table more than 1M rows. I want to delete every row in my table. Everytime I ran DELETE statement, it times out and does not do it job. The data in table is useless and I do not need it ever. Your suggestion please.” The reason I decided to write article about this question because I receive similar questions very often. I think many readers will find answer to this question useful. My answer to his question is here with: “If DELETE is timing out use TRUNCATE instead. It will... - [SQLAuthority News - Good Motivational Quotes for Interviews](https://blog.sqlauthority.com/2008/01/13/sqlauthority-news-good-motivational-quotes-interviews/): Here are few motivational quotes for candidates who are appearing for interview. I have collected this throughout the years and it is running list of the interview. Please feel free to let me know if you find any such good interview quote and I will update in this list. - [SQL SERVER - 2005 - Change Compatibility Level - T-SQL Procedure](https://blog.sqlauthority.com/2008/01/12/sql-server-2005-change-compatibility-level-t-sql-procedure/): Six months ago I wrote article about SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility. Yesterday I received an email asking that one of my blog reader is not able to use the sp_dbcmptlevel command with error that database is in use. He has asked me to write about proper procedure of changing database compatibility which will always work. First read my previous article SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility as it has explained many details about compatibility. The best practice to change the compatibility level of database is in following three steps.... - [SQL SERVER - Reclaim Space After Dropping Variable - Length Columns Using DBCC CLEANTABLE](https://blog.sqlauthority.com/2008/01/11/sql-server-reclaim-space-after-dropping-variable-length-columns-using-dbcc-cleantable/): All DBA and Developers must have observed when any variable length column is dropped from table, it does not reduce the size of table. Table size stays the same till Indexes are reorganized or rebuild. There is also DBCC command DBCC CLEANTABLE, which can be used to reclaim any space previously occupied with variable length columns. Variable length columns include varchar, nvarchar, varchar(max), nvarchar(max), varbinary, varbinary(max), text, ntext, image, sql_variant, and xml. Space can be reclaimed when variable length column is also modified to lesser length. - [SQL SERVER - 2005 - Display Fragmentation Information of Data and Indexes of Database Table](https://blog.sqlauthority.com/2008/01/10/sql-server-2005-display-fragmentation-information-of-data-and-indexes-of-database-table/): One of my friend involved with large business of medical transcript invited me for SQL Server improvement talk last weekend. I had great time talking with group of DBA and developers. One of the topic which was discussed was how to find out Fragmentation Information for any table in one particular database. For SQL Server 2000 it was easy to find using DBCC SHOWCONTIG command. DBCC SHOWCONTIG has some limitation for SQL Server 2000. SQL Server 2005 has sys.dm_db_index_physical_stats dynamic view which returns size and fragmentation information for the data and indexes of the specified table or view. You can run... - [SQL SERVER - Execute Same Query and Statement Multiple Times Using Command GO](https://blog.sqlauthority.com/2008/01/09/sql-server-execute-same-query-and-statement-multiple-times-using-command-go/): Following question was asking by one of long time reader who really liked trick of SQL SERVER – Explanation SQL Command GO and SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL. She asked how can I execute same code multiple times without Copy and Paste multiple times in Query Editor. The answer to this question is very simple. Use the command GO. Following example demonstrate how GO can be used to execute same code multiple times. SELECT GETDATE() AS CurrentTime GO 5 Above code will return current time 5 times as GO is followed... - [SQL SERVER - Export Data From SQL Server to Microsoft Excel Datasheet](https://blog.sqlauthority.com/2008/01/08/sql-server-2005-export-data-from-sql-server-2005-to-microsoft-excel-datasheet/): Question: How to Export Data From SQL Server to Microsoft Excel Datasheet? - [SQL SERVER - 2005 - Introduction and Explanation to SYNONYM - Helpful T-SQL Feature for Developer](https://blog.sqlauthority.com/2008/01/07/sql-server-2005-introduction-and-explanation-to-synonym-helpful-t-sql-feature-for-developer/): One of my friend and extremely smart DBA Jonathan from Las Vegas has pointed out nice little enhancement in T-SQL. I was very pleased when I learned about SYNONYM feature in SQL Server 2005. DBA have been referencing database objects in four part names. SQL Server 2005 introduces the concept of a synonym. A synonyms is a single-part name which can replace multi part name in SQL Statement. Use of synonyms cuts down typing long multi part server name and can replace it with one synonyms. It also provides an abstractions layer which will protect SQL statement using synonyms from changes... - [SQL SERVER - Download Frequently Asked Generic Interview Questions](https://blog.sqlauthority.com/2008/01/06/sql-server-download-frequently-asked-generic-interview-questions/): Yesterday I posted article about SQL SERVER – Most Frequently Asked Generic Interview Questions. I always enjoy when I receive emails and comments about my article. Many readers have asked me to write more about this, I suggest that my readers help me here and add their suggestion and answers to original article. The common question asked to me is why I have not included answers with this questions. Each question is very unique to each individual and its answer can be very different from person to person. There is no right or wrong answer here. Just answer what you feel... - [SQL SERVER - Most Frequently Asked Generic Interview Questions](https://blog.sqlauthority.com/2008/01/05/sql-server-most-frequently-asked-generic-interview-questions/): Tell me about yourself. What experience do you have in this field? How many years of experience do you have in area you are applying for? Why did you leave your last job? Why are you planning to leave your current job? What do you know about this organization? Why do you want to work for this organization? How would you describe your ideal job? How long would you expect to work for us if hired? What have you done to improve your knowledge recently? What do co-workers say about you? What irritates you about co-workers? What kind of person would... - [SQL SERVER - Quick Note on CROSS APPLY](https://blog.sqlauthority.com/2008/01/04/sql-server-2005-cross-apply/): Yesterday I wrote article about SQL SERVER – 2005 – Last Ran Query – Recently Ran Query. I had used CROSS APPLY in the query. I got email from one reader asking what is CROSS APPLY. In simpler words, cross apply is like inner join to table valued function which can take parameters. This particular operation is not possible to do using regular JOIN syntax You can see example of CROSS APPLY in my article here. - [SQL SERVER - 2005 - Last Ran Query - Recently Ran Query](https://blog.sqlauthority.com/2008/01/03/sql-server-2005-last-ran-query-recently-ran-query/): How many times we have wondered what were the last few queries ran on SQL Server? Following quick script demonstrates last ran query along with the time it was executed on SQL Server 2005. SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest ORDER BY deqs.last_execution_time DESC Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL – sys.dm_exec_query_stats, BOL – sys.dm_exec_sql_text - [SQLAuthority New - Best Practices for Speeding Up Your Web Site](https://blog.sqlauthority.com/2008/01/03/sqlauthority-new-best-practices-for-speeding-up-your-web-site/): Steve Souders, Chief Performance Yahoo! Best Practices for Speeding Up Your Web Site. I suggest everybody should read this basic guidelines. They are extremely important for high performance websites. 1. Make Fewer HTTP Requests 2. Use a Content Delivery Network 3. Add an Expires Header 4. Gzip Components 5. Put Stylesheets at the Top 6. Put Scripts at the Bottom 7. Avoid CSS Expressions 8. Make JavaScript and CSS External 9. Reduce DNS Lookups 10. Minify JavaScript 11. Avoid Redirects 12. Remove Duplicate Scripts 13. Configure ETags 14. Make Ajax Cacheable Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 15281 SQL Server blocked access to STATEMENT OpenRowset/OpenDatasource of](https://blog.sqlauthority.com/2008/01/02/sql-server-fix-error-15281-sql-server-blocked-access-statement-openrowsetopendatasource-component-ad-hoc-distributed-queries-component-turned-off/): Error 15281 Msg 15281, Level 16, State 1, Line 3 SQL Server blocked access to STATEMENT ‘OpenRowset/OpenDatasource’ of component ‘Ad Hoc Distributed Queries’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ad Hoc Distributed Queries’ by using sp_configure. For more information about enabling ‘Ad Hoc Distributed Queries’, see “Surface Area Configuration” in SQL Server Books Online. - [SQLAuthority New - Happy New Year 2008](https://blog.sqlauthority.com/2008/01/01/sqlauthority-new-happy-new-year-2008/): Today is New Year and I wish you all Best for Year 2008. Let us all start our new year with motivational new year quote. We will open the book. Its pages are blank. We are going to put words on them ourselves. The book is called “Opportunity” and its first chapter is New Year’s Day. – Edith Lovejoy Pierce Microsoft has big gift for all SQL Server fans and developers. It is realizing SQL Server 2008. Today in New Year let us have some laugh together. We will continue together with SQL Server articles from tomorrow. I hope you enjoy... - [SQLAuthority News - Thank You to Blog Readers](https://blog.sqlauthority.com/2007/12/31/sqlauthority-news-thank-you-to-blog-readers/): Thank You very much for reading SQLAuthority.com for entire 2007 year. Wish you the BEST for year 2008. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Remove Duplicate Characters From a String](https://blog.sqlauthority.com/2007/12/30/sql-server-remove-duplicate-characters-from-a-string/): Follow up of my previous article of Remove Duplicate Chars From String here is another great article written by Madhivanan where similar solution is suggested with alternate method of Number table approach. Check out Remove duplicate characters from a string Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Change Password of SA Login Using Management Studio](https://blog.sqlauthority.com/2007/12/29/sql-server-change-password-of-sa-login-using-management-studio/): Login into SQL Server using Windows Authentication. In Object Explorer, open Security folder, open Logins folder. Right Click on SA account and go to Properties. Change SA password, and confirm it. Click OK. Make sure to restart the SQL Server and all its services and test new password by log into system using SA login and new password. Reference : Pinal Dave (https://blog.sqlauthority.com) UPDATE : There has been discussion about restarting the SQL Server and all its services. Please read all of them before making final decision for your scenario. - [SQL SERVER - Difference Between Quality Assurance and Quality Control - QA vs QC](https://blog.sqlauthority.com/2007/12/28/sql-server-difference-between-quality-assurance-and-quality-control-qa-vs-qc/): Regular readers of this blog are aware of my current outsourcing assignment. I am managing very large outsourcing project in India. One thing is very special in all Indian offices are “Tea Time.” Everybody wants to attend Tea Time not only for tea or coffee but for the interesting discussion occurs at that time. This is the time when all the department employees are together and discussing whatever they wish.Today there was an interesting discussion about Quality Assurance (QA) and Quality Control (QC). - [SQLAuthority News - Book Review - A Practitioner's Guide to Software Test Design](https://blog.sqlauthority.com/2007/12/27/sqlauthority-news-book-review-a-practitioners-guide-to-software-test-design/): A Practitioner's Guide to Software Test Design is one book containing all the important latest test design approaches. This book makes life of software tester very easy. Software tester can find all the information in this book instead of searching through hundreds of books, periodicals and websites. - [SQL SERVER - TRUNCATE Can't be Rolled Back Using Log Files After Transaction Session Is Closed](https://blog.sqlauthority.com/2007/12/26/sql-server-truncate-cant-be-rolled-back-using-log-files-after-transaction-session-is-closed/): You might have listened and read either of following sentence many many times. “DELETE can be rolled back and TRUNCATE can not be rolled back”. OR “DELETE can be rolled back as well as TRUNCATE can be rolled back”. As soon as above sentence is completed, someone will object it saying either TRUNCATE can be or can not be rolled back. Let us make sure that we understand this today, in simple words without talking about theory in depth. While database is in full recovery mode, it can rollback any changes done by DELETE using Log files. TRUNCATE can not be... - [SQL SERVER - Mirrored Backup Introduction and Explanation](https://blog.sqlauthority.com/2007/12/25/sql-server-mirrored-backup-introduction-and-explanation/): SQL Server 2005 Enterprise Edition and Development Edition supports mirrored backup. Mirroring a media set increases backup reliability by adding redundancy of backup media which effectively reduces the impact of backup-device failing. While taking backup of database, same backup is taken on multiple media or locations. T-SQL code to take Mirrored Backup : BACKUP DATABASE AdventureWorks TO DISK = 'c:\AdventureWorksBackup.bak' MIRROR TO DISK = 'd:\AdventureWorksBackupCopy.bak' WITH FORMAT; Above script will create two backups at two different locations, if backup of one location is corrupted backup from another location will work fine. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Delete Duplicate Records - Count Duplicate Records Links](https://blog.sqlauthority.com/2007/12/25/sql-server-delete-duplicate-records-count-duplicate-records-links/): I have wrote following two articles for Duplicate Rows Management in SQL Server. SQL SERVER – Count Duplicate Records – Rows SQL SERVER – Delete Duplicate Records – Rows Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Object Oriented Database Management Systems](https://blog.sqlauthority.com/2007/12/24/sql-server-object-oriented-database-management-systems/): I have received few emails and comments about why I do not write about Object Oriented Database Management Systems (OODBMS). The reason for that is that I am big follower of Relational Database Management Systems (RDBMS) and that particularly of Microsoft SQL Server. If you are interested in reading about OODBMS, I have came across one interesting article, which I can share here. Visit : AN EXPLORATION OF OBJECT ORIENTED DATABASE MANAGEMENT SYSTEMS by Dare Obasanjo The purpose of above mentioned paper is to provide answers to the following questions What is an Object Oriented Database Management System (OODBMS)? Is an... - [SQLAuthority News - Download Microsoft SQL Server 2000/2005 Management Pack](https://blog.sqlauthority.com/2007/12/24/sqlauthority-news-download-microsoft-sql-server-20002005-management-pack/): Note: Download Microsoft SQL Server 2000/2005 Management Pack by Microsoft The SQL Server Management Pack monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems. Availability and performance monitoring is done using synthetic transactions. In addition, the Management Pack collects Event Log alerts and provides associated knowledge articles with additional user details, possible causes, and suggested resolutions. The Management Pack discovers Database Engines, Database Instances, and Databases and can optionally discover Database File and Database File Group objects. Feature Summary: Active Directory Helper Service SQL Server Agent Backup Databases and Tables DBCC Full... - [SQLAuthority News - Jobs, Search, Best Articles, Homepage](https://blog.sqlauthority.com/2007/12/24/sqlauthority-news-jobs-search-best-articles-homepage/): If you are looking for solution of any of your question : Search SQLAuthority If you are looking for best job in IT field : Find Job or email pinal@sqlauthority.com If you are looking for talented IT professional : Post Job or email pinal@sqlauthority.com If you want to read my personally selected articles : Best Articles If you want to know more about me : pinaldave.com If you want to subscribe to my blog : Email or Feed Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - New DataTypes DATE and TIME](https://blog.sqlauthority.com/2007/12/23/sql-server-2008-new-datatypes-date-and-time/): One of our project manager asked me why SQL Server does not have only DATE or TIME datatypes? I thought his question is very valid, he is not DBA however he understands the RDBMS concepts very well. I find his question very interesting. I told him that there are ways to do that in SQL Server 2005 and earlier versions. He asked me but if there are DATE and TIME datatypes not DATETIME combined. This question we all DBA had for many years and we all wanted DATE and TIME separate datatypes then DATETIME combined. Microsoft has incorporated this feature in... - [SQL SERVER - Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script](https://blog.sqlauthority.com/2007/12/22/sql-server-difference-between-index-rebuild-and-index-reorganize-explained-with-t-sql-script/): Index Rebuild : This process drops the existing Index and Recreates the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REBUILD GO Index Reorganize : This process physically reorganizes the leaf nodes of the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REORGANIZE GO Recommendation: Index should be rebuild when index fragmentation is great than 40%. Index should be reorganized when index fragmentation is between 10% to 40%. Index rebuilding process uses more CPU and it locks the database resources. SQL Server development version and Enterprise version has option ONLINE, which can be turned on when Index is rebuilt.... - [SQL SERVER - Enabling Clustered and Non-Clustered Indexes - Interesting Fact](https://blog.sqlauthority.com/2007/12/21/sql-server-enabling-clustered-and-non-clustered-indexes-interesting-fact/): While playing with Indexes I have found following interesting fact. I did some necessary tests to verify that it is true. When a clustered index is disabled, all the nonclustered indexes on the same tables are auto disabled as well. User do not need to disable non-clustered index separately. However, when clustered index is enabled, it does not automatically enable nonclustered index. All the nonclustered indexes needs to be enabled individually. I wondered if there is any short cut to enable all the indexes together. Index rebuilding came to my mind instantly. I ran T-SQL command of rebuilding all the indexes... - [SQL SERVER - DISTINCT Keyword Usage and Common Discussion](https://blog.sqlauthority.com/2007/12/20/sql-server-distinct-keyword-usage-and-common-discussion/): Jr. DBA asked me a day ago, how to apply DISTINCT keyword to only first column of SELECT. When asked for additional information about question, he showed me following query. SELECT Roles, FirstName, LastName FROM UserNames He wanted to apply DISTINCT to only Roles and not across FirstName and LastName. When he finished I realize that it is not possible and there is logical error in thinking query like that. I helped him with what he needed however, after he left I realize that answer to his original question was “NO”. Distinct can not be applied to only few columns it... - [SQL SERVER - Cumulative Update Package 5 for SQL Server 2005 Service Pack 2](https://blog.sqlauthority.com/2007/12/19/sql-server-cumulative-update-package-5-for-sql-server-2005-service-pack-2/): Microsoft SQL Server 2005 hotfixes are created for specific SQL Server service packs. You must apply a SQL Server 2005 Service Pack 2 hotfix to an installation of SQL Server 2005 Service Pack 2. By default, any hotfix that is provided in a SQL Server service pack is included in the next SQL Server service pack. Cumulative Update 5 contains hotfixes for SQL Server 2005 issues that have been fixed since the release of Service Pack 2. Latest Build 3215. Download Information Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - RML Utilities for SQL Server](https://blog.sqlauthority.com/2007/12/19/sqlauthority-news-rml-utilities-for-sql-server/): The RML utilities allow you to process SQL Server trace files and view reports showing how SQL Server is performing. For example, you can quickly see: Which application, database or login is using the most resources, and which queries are responsible for that Whether there were any plan changes for a batch during the time when the trace was captured and how each of those plans performed What queries are running slower in today’s data compared to a previous set of data Download RML Utilities for SQL Server (x86) Download RML Utilities for SQL Server (x64) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Get Information of Index of Tables and Indexed Columns](https://blog.sqlauthority.com/2007/12/18/sql-server-get-information-of-index-of-tables-and-indexed-columns/): Knowledge of T-SQL inbuilt functions and store procedure can save great amount of time for developers. Following is very simple store procedure which can display name of Indexes and the columns on which indexes are created. Very handy stored Procedure. USE AdventureWorks; GO EXEC sp_helpindex 'Person.Address' GO Above SP will return following information. IndexName – IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode Index_Description – nonclustered, unique located on PRIMARY Index_Keys – AddressLine1, AddressLine2, City, StateProvinceID, PostalCode Let me know if you think this kind of small tips are useful to you. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to Find Details About TempDB Information](https://blog.sqlauthority.com/2007/12/17/sql-server-t-sql-script-to-find-details-about-tempdb/): Two days ago I wrote an article about SQL SERVER - TempDB Restrictions - Temp Database Restrictions. Since then I have received few emails asking details about Temp DB. I use following T-SQL Script to know details about my TempDB. This script is a pretty old script but it does work great most of the time. I strongly encourage all of you to use a script to check your TempDB Information. - [SQL SERVER - Solution - Log File Very Large - Log Full](https://blog.sqlauthority.com/2007/12/16/sql-server-solution-log-file-very-large-log-full/): I have been receiving following question again and again either through email or through comments on this blog. My log file is too big, what should I do? Answer to this question is in three steps. Backup the log file to any device. Truncate the log file. Shrink the log file. I have previously written two article about this issue. Refer them for additional information and details. SQL SERVER – Shrinking Truncate Log File – Log Full(Script) SQL SERVER – Shrinking Truncate Log File – Log Full – Part 2(Management Studio) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - TempDB Restrictions - Temp Database Restrictions](https://blog.sqlauthority.com/2007/12/15/sql-server-tempdb-restrictions-temp-database-restrictions/): While conducting Interview for my outsourcing project, I asked one question to interviewer that what are the restrictions on TempDB? The candidate was not able to answer the question. I thought it would be good for all my readers to know the answer to this question so if you face this question in an interview or if you meet me in the interview you will be able to answer this question. - [SQLAuthority News - Top 10 Tips for Successful Software Outsourcing](https://blog.sqlauthority.com/2007/12/14/sqlauthority-news-top-10-tips-for-successful-software-outsourcing/): Few days ago, I wrote article about SQLAuthority Author Visit – IT Outsourcing to India – Top 10 Reasons Companies Outsource. I received quite a few emails regarding this article. I was really impressed that how much vendors care about their reputation and their client. I received so many requests from my blog readers who are interested in learning how to be successful at Software Outsourcing. I decided to write top 10 tips for the same. I have not described them in depth as they are pretty self explanatory. Define the scope of project clearly and as much as detail it... - [SQL SERVER - Do Not Store Images in Database - Store Location of Images (URL)](https://blog.sqlauthority.com/2007/12/13/sql-server-do-not-store-images-in-database-store-location-of-images-url/): Just a day ago I received phone call from my friend in Bangalore. He asked me What do I think of storing images in database and what kind of datatype he should use? I have very strong opinion about this issue. I suggest to store the location of the images in the database using VARCHAR datatype instead of any BLOB or other binary datatype. Storing the database location reduces the size of database greatly as well updating or replacing the image are much simpler as it is just an file operation instead of massive update/insert/delete in database. Reference : Pinal Dave... - [SQL SERVER - White Papers: Migration from Oracle Sybase, or Microsoft Access to Microsoft SQL Server](https://blog.sqlauthority.com/2007/12/12/sql-server-white-papers-migration-from-oracle-sybase-or-microsoft-access-to-microsoft-sql-server/): Guide to Migrating from Oracle to SQL Server 2005 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2005. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. The entire migration process using SQL Server Migration Assistant for Oracle (SSMA Oracle) is explained in depth, with a special focus on converting database objects and PL/SQL code. Guide to Migrating from Sybase ASE to SQL Server 2005 This white paper covers known issues for migrating Sybase Adaptive Server Enterprise database to SQL Server... - [SQL SERVER - Microsoft Synchronization Services for ADO.NET v2.0 CTP1 Refresh](https://blog.sqlauthority.com/2007/12/11/sql-server-microsoft-synchronization-services-for-adonet-v20-ctp1-refresh/): Microsoft Synchronization Services for ADO.NET provides the ability to synchronize data from disparate sources over two-tier, N-tier, and service-based architectures. Rather than simply replicating a database and its schema, the Synchronization Services application programming interface (API) provides a set of components to synchronize data between data services and a local store. Applications are increasingly used on mobile clients, such as laptops and devices, that do not have a consistent or reliable network connection to a central server. It is crucial for these applications to work against a local copy of data on the client. Equally important is the need to synchronize... - [SQLAuthority News - Microsoft SQL Server 2008 Community Technology Preview (November 2007) VHD](https://blog.sqlauthority.com/2007/12/10/sqlauthority-news-microsoft-sql-server-2008-community-technology-preview-november-2007-vhd/): SQL Server 2008, the next release of Microsoft SQL Server, will provide a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with relevant insights. This download comes as a pre-configured VHD. This allows you to trial SQL Server 2008 CTP in a virtual environment. Download from here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ACID (Atomicity, Consistency, Isolation, Durability)](https://blog.sqlauthority.com/2007/12/09/sql-server-acid-atomicity-consistency-isolation-durability/): ACID (an acronym for Atomicity Consistency Isolation Durability) is a concept that Database Professionals generally look for when evaluating databases and application architectures. For a reliable database all this four attributes should be achieved. - [SQL SERVER - Generic Architecture Image](https://blog.sqlauthority.com/2007/12/08/sql-server-generic-architecture-image/): Just a day ago, while I was surfing Wikipedia about SQL Server, I came across this generic architecture image. I found it interesting. Click on image to view it in large size. The physical structure of the database is divided into the MDF and LDF. The part of MDF contains file group, data files, tables and indexes, extended and page. The LDF file contains a transaction log file. The physical architecture is about how the data is actually stored in the file system. Page, extend, database files are physical architecture. - [SQL SERVER - FIX : Error : 3702 Cannot drop database because it is currently in use.](https://blog.sqlauthority.com/2007/12/07/sql-server-fix-error-3702-cannot-drop-database-because-it-is-currently-in-use/): Msg 3702, Level 16, State 3, Line 2 Cannot drop database “DataBaseName” because it is currently in use. This is a very generic error when DROP Database is command is executed and the database is not dropped. The common mistake user is kept the connection open with this database and trying to drop the database. The following commands will raise above error: USE AdventureWorks; GO DROP DATABASE AdventureWorks; GO Fix/Workaround/Solution: The following commands will not raise an error and successfully drop the database: USE Master; GO DROP DATABASE AdventureWorks; GO If you want to drop the database use master database first... - [SQL SERVER - 2005 - Dynamic Management Views (DMV) and Dynamic Management Functions (DMF)](https://blog.sqlauthority.com/2007/12/06/sql-server-2005-dynamic-management-views-dmv-and-dynamic-management-functions-dmf/): Dynamic Management Views (DMV) and Dynamic Management Functions (DMF) return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance. They can exactly tell what is going on with SQL Server and its objects at the moment.There are tow kinds of DMVs and DMFs. Server-scoped dynamic management views and functions. Database-scoped dynamic management views and functions. All dynamic management views and functions exist in the sys schema and follow this naming convention dm_*. When you use a dynamic management view or function, you must prefix the name of the view or... - [SQL SERVER - UDF - Remove Duplicate Chars From String](https://blog.sqlauthority.com/2007/12/05/sql-server-udf-remove-duplicate-chars-from-string/): Few days ago, I received following wonderful UDF from one of this blog reader. This UDF is written for specific purpose of removing duplicate chars string from one large string. Virendra Chauhan, author of this UDF is working as DBA in Lutheran Health Network. CREATE FUNCTION dbo.REMOVE_DUPLICATE_INSTR (@datalen_tocheck INT,@string VARCHAR(255)) RETURNS VARCHAR(255) AS BEGIN DECLARE @str VARCHAR(255) DECLARE @count INT DECLARE @start INT DECLARE @result VARCHAR(255) DECLARE @end INT SET @start=1 SET @end=@datalen_tocheck SET @count=@datalen_tocheck SET @str = @string WHILE (@count <=255) BEGIN IF (@result IS NULL) BEGIN SET @result='' END SET @result=@result+SUBSTRING(@str,@start,@end) SET @str=REPLACE(@str,SUBSTRING(@str,@start,@end),'') SET @count=@count+@datalen_tocheck END RETURN @result END... - [SQLAuthority Author Visit - IT Outsourcing to India - Top 10 Reasons Companies Outsource](https://blog.sqlauthority.com/2007/12/04/sqlauthority-author-visit-it-outsourcing-to-india-top-10-reasons-companies-outsource/): Yesterday I had meeting with few of the leading outsourcing companies in Ahmedabad, India. Regular readers of this blog knows that I am currently in India handling large scale outsourcing assignment. My responsibilities includes managing application development, system architecture and database architecture. The purpose of meeting was to exchange the views and learn methodologies from one another regarding how to provide quality service to offshore clients. There were about 10-15 Sr. Managers from different outsourcing company. The conversation was excellent and we all felt that we have learned a lot from each other. Two major things discussed were quality of products... - [SQL SERVER - Grouping JOIN Clauses In SQL](https://blog.sqlauthority.com/2007/12/03/sql-server-grouping-join-clauses-in-sql/): I always enjoy writing and reading articles about JOIN Clauses. One of my friend and the best ColdFusion Expert Ben Nadel has written good article about SQL JOINs. There are few interesting comments as well at the end of article. “JOIN grouping is pretty powerful and can get you out of those sticky situations that involve mixed table relationship rules. ” Ben Nadel – Grouping JOIN Clauses In SQL Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Q and A with Database Administrators](https://blog.sqlauthority.com/2007/12/02/sql-server-qa-with-database-administrators/): I have been in India for more than a month now, as I am leading a very large outsourcing project. We have conducted few interviews since the project required more Database Administrators and Senior Developers. I am listing few of the questions discussed during all the interviews. The whole event of interviews was very interesting. I met some very good programmers from all over the country. Many interesting questions were discussed between interviewers and candidates. I am listing some of those questions here. Some are technical and some are just my personal opinions. I will appreciate your thought about this article.... - [SQL SERVER - Sharpen Your Skills: Brush up on FILLFACTOR, ISNULL, NULLIF, and % as wildcard and operator](https://blog.sqlauthority.com/2007/12/01/sql-server-sharpen-your-skills-brush-up-on-fillfactor-isnull-nullif-and-as-wildcard-and-operator/): Read my article in SQL Server Magazine December 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download SQL Server 2005 Books Online (September 2007)](https://blog.sqlauthority.com/2007/11/30/sqlauthority-news-download-sql-server-2005-books-online-september-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The September 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - Database Interview Questions and Answers Complete List](https://blog.sqlauthority.com/2007/11/29/sql-server-database-interview-questions-and-answers-complete-list/): Update: I have updated this article series and newly updated article series is over here. If you are subscribed to my blog you will know that I receive request to send Database or SQL Server very frequently. Following is list of articles of my questions and answers series. Download SQL Server Interview Questions and Answers Complete List Complete Series of SQL Server Interview Questions and Answers SQL Server Interview Questions and Answers – Introduction SQL Server Interview Questions and Answers – Part 1 SQL Server Interview Questions and Answers – Part 2 SQL Server Interview Questions and Answers – Part 3... - [SQL SERVER - Correct Syntax for Stored Procedure SP](https://blog.sqlauthority.com/2007/11/28/sql-server-correct-syntax-for-stored-procedure-sp/): Just a day ago, I received interesting question about correct syntax for Stored Procedure. Many readers of this blog will think that it is very simple question. The reason this is interesting is the question behavior of BEGIN … END statements and GO command in Stored Procedure. Let us first see what is correct syntax. Correct Syntax: CREATE PROCEDURE usp_SelectRecord AS BEGIN SELECT * FROM TABLE END GO I have seen many new developers write statements after END statement. This will not work but will probably execute first fine when stored procedure is created. Rule is anything between BEGIN and END... - [SQL SERVER - 2005 - List All Stored Procedure in Database](https://blog.sqlauthority.com/2007/11/27/sql-server-2005-list-all-stored-procedure-in-database/): Run following simple script on SQL Server 2005 to retrieve all stored procedure in database. SELECT * FROM sys.procedures; This will ONLY work with SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Rules of Third Normal Form and Normalization Advantage - 3NF](https://blog.sqlauthority.com/2007/11/26/sql-server-rules-of-third-normal-form-and-normalization-advantage-3nf/): I always ask question about Third Normal Form in interviews I take. Q. What is Third Normal Form and what is its advantage? A. Third Normal Form (3NF) is most preferable normal form in RDBMS. Normalization is the process of designing a data model to efficiently store data in a database. The rules of 3NF are mentioned here Make a separate table for each set of related attributes, and give each table a primary key. If an attribute depends on only part of a multi-valued key, remove it to a separate table If attributes do not contribute to a description of... - [SQLAuthority News - SQL Server Compact 3.5 Downloads and ReportViewer Visual Studio Download](https://blog.sqlauthority.com/2007/11/25/sqlauthority-news-sql-server-compact-35-downloads-and-reportviewer-visual-studio-download/): SQL Server Compact 3.5 Books Online and Samples SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the Books Online and Samples for SQL Server Compact 3.5 SQL Server Compact 3.5 for Windows Mobile SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the CAB files and DLL’s that are used to install SQL Server Compact 3.5 on the Windows Mobile Devices platform SQL Server... - [SQL SERVER - Upgrade Advise - From 2000 to 2005 or 2008](https://blog.sqlauthority.com/2007/11/24/sql-server-upgrade-advise-from-2000-to-2005-or-2008/): There has some good amount of discussion going on in SQL Server community about should we upgrade from SQL Server 2000 to SQL Server 2005 or wait for SQL Server 2008. I have received quite a few email and invitations to participate in forums on this topic. Instead of talking about this topic on different places, I have decided to write my opinion on my blog. I recommend to upgrade to SQL Server 2000 users to SQL Server 2005. SQL Server 2008 is due next year. The RTM may or may not be available till February 2008. After the release the... - [SQL SERVER - 2008 - November CPT5 New Improvement](https://blog.sqlauthority.com/2007/11/23/sql-server-2008-november-cpt5-new-improvement/): The progress map of SQL Server 2008 is diagrammatically listed here. I am listing the new improvements here as list. Data Collection and Performance Warehouse for Relational Engine Service Broker Enhancements Registered Servers Enhancements Synchronous net-changes change tracking for SQL Server T-SQL IntelliSense Declarative Management Framework (DMF) Enhancements Geo-spatial Support Analysis Services Query and Writeback Performance Robust Report Server Platform Integration Services – Lookup Enhancements Analysis Services MDX Query Optimizer – Block Computation Analysis Services Aggregation Design Analysis Services Cube Design Reporting Services Scale Engine Transparent Data Encryption Resource Governor – Limit Specification Backup Compression Plan Freezing Fully Parallel Plans Scale... - [SQL SERVER - Shrinking Truncate Log File - Log Full - Part 2](https://blog.sqlauthority.com/2007/11/22/sql-server-shrinking-truncate-log-file-log-full-part-2/): About a year ago, I wrote SQL SERVER - Shrinking Truncate Log File - Log Full. I was just going through some of the earlier posts and comments. - [SQL SERVER - Generate Incremented Linear Number Sequence](https://blog.sqlauthority.com/2007/11/21/sql-server-generate-incremented-linear-number-sequence/): Just a day ago, I received interesting question on this blog. Read original question here. This is very good question and after reading this question I quickly wrote small script as answer. Let us see the question and answer together. Q. How can we generate incremented linear number in sql server as in oracle we generate in via sequence? - [SQL SERVER - Sharpen Your Skills: Joins, Groupings, and Data Types](https://blog.sqlauthority.com/2007/11/20/sql-server-sharpen-your-skills-joins-groupings-and-data-types/): Read my article in SQL Server Magazine November 2007 Edition [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server 2008 Community Technology Preview (CTP) Download Now Available](https://blog.sqlauthority.com/2007/11/19/sqlauthority-news-sql-server-2008-community-technoloypreview-ctp-download-now-available/): Download the latest SQL Server 2008 Community Technology Preview (CTP) and try out the latest features of SQL Server 2008! The SQL Server development team uses your CTP feedback to help refine and enhance product features. Download it today and send your feedback. Microsoft SQL Server 2008, the next release of Microsoft SQL Server, provides a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with... - [SQLAuthority News - Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide - SQL Server, ColdFusion, ASP.NET](https://blog.sqlauthority.com/2007/11/18/sqlauthority-news-job-opportunity-in-ahmedabad-india-to-work-with-technology-leaders-worldwide-sql-server-coldfusion-aspnet/): If you have one or more years of experience in any web based programming language (.NET, ColdFusion, PHP) and interested in SQL Server as well willing to locate Ahmadabad, India. Please send me your resume, if selected you may get chance to work with one of the most progressing industry in world as well some smartest technology leaders worldwide. Salary depends on Experience. If selected for interview I suggest you go over SQL Server Interview Questions and Answers Complete List Download, as there is great chance I may be participating in interview. Please send your resume at pinaldave “at” yahoo.com and... - [SQL SERVER - 2005 - Best Practices for SQL Server Health Check](https://blog.sqlauthority.com/2007/11/17/sql-server-2005-best-practices-for-sql-server-health-check/): Here are few of the best practices one should follow for SQL Server Health Check. - [SQL SERVER - Generate Script with Data from Database - Database Publishing Wizard](https://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/): I really enjoyed writing about SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects. Since then the I have received question that how to copy data as well along with schema. The answer to this is Database Publishing Wizard. This wizard is very flexible and works with modes like schema only, data only or both. It generates a single SQL script file which can be used to recreate the contents of a database by manually executing the script on a target server. - [SQLAuthority News - Microsoft SQL Server 2005 Assessment Configuration Pack Download](https://blog.sqlauthority.com/2007/11/15/sqlauthority-news-microsoft-sql-server-2005-assessment-configuration-pack-download/): Microsoft SQL Server 2005 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Gramm-Leach Bliley Act compliance efforts Microsoft SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Database Dilbert](https://blog.sqlauthority.com/2007/11/14/sqlauthority-news-sql-joke-sql-humor-sql-laugh-database-dilbert/): This is my favorite Dilbert. Dilbert is an American comic strip written and illustrated by Scott Adams, first published in the year 1969. - [SQLAuthority News - Microsoft SQL Server 2005 MSIT Three Configuration Pack for Configuration Manager 2007](https://blog.sqlauthority.com/2007/11/14/sqlauthority-news-microsoft-sql-server-2005-msit-three-configuration-pack-for-configuration-manager-2007/): Microsoft SQL Server 2005 MSIT Basic Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2005 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2005 MSIT Intermediate Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2005 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2005 MSIT Comprehensive Configuration Pack for Configuration Manager 2007 This... - [SQL SERVER - DBCC CHECKDB Introduction and Explanation - DBCC CHECKDB Errors Solution](https://blog.sqlauthority.com/2007/11/13/sql-server-dbcc-checkdb-introduction-and-explanation-dbcc-checkdb-errors-solution/): DBCC CHECKDB checks the logical and physical integrity of all the objects in the specified database. If DBCC CHECKDB ran on database user should not run DBCC CHECKALLOC, DBCC CHECKTABLE, and DBCC CHECKCATALOG on database as DBCC CHECKDB includes all the three command. Usage of these included DBCC commands is listed below. - [SQL SERVER - FIX : ERROR Msg 1803 The CREATE DATABASE statement failed. The primary file must be at least 2 MB to accommodate a copy of the model database](https://blog.sqlauthority.com/2007/11/12/sql-server-fix-error-msg-1803-the-create-database-statement-failed-the-primary-file-must-be-at-least-2-mb-to-accommodate-a-copy-of-the-model-database/): Following error occurs when database which is attempted to be created is smaller than Model Database. It is must that all the databases are larger than Model database and 512KB. Following code will create the error discussed in this post. CREATE DATABASE Tests ON ( NAME = 'Tests', FILENAME = 'c:\tests.mdf', SIZE = 512KB ) GO Msg 1803, Level 16, State 1, Line 1 The CREATE DATABASE statement failed. The primary file must be at least 2 MB to accommodate a copy of the model database. Fix/WorkAround/Solution : Create database which is larger than Model database and 512KB. Size of the... - [SQLAuthority News - The Equations of Relativist](https://blog.sqlauthority.com/2007/11/12/sqlauthority-news-the-equations-of-relativist/): F = mg ….. Galileo F = ma ….. Newton E = mc²….. Einstein Reference : Pinal Dave (https://blog.sqlauthority.com) , Great Site – relationary) - [SQL SERVER - FIX : ERROR Msg 5174 Each file size must be greater than or equal to 512 KB](https://blog.sqlauthority.com/2007/11/12/sql-server-fix-error-msg-5174-each-file-size-must-be-greater-than-or-equal-to-512-kb/): Following error occurs when database which is attempted to be created is smaller than 512KB. It is must that all the databases are larger than 512KB. It will also follow with another error 1802, which is due to previous error 5174. Following code will create the error discussed in this post. CREATE DATABASE Tests ON ( NAME = 'Tests', FILENAME = 'c:\tests.mdf', SIZE = 12KB ) GO Msg 5174, Level 16, State 1, Line 1 Each file size must be greater than or equal to 512 KB. Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names... - [SQLAuthority News - SQL Server 2005 Powers Global Forensic Data Security Tool](https://blog.sqlauthority.com/2007/11/11/sqlauthority-news-sql-server-2005-powers-global-forensic-data-security-tool/): Note :  Download Whitepaper by Microsoft Find out how SQL Server 2005 powers a 27 TB data management system called ICE 3.0 that gathers forensic data from more than 85 Microsoft corporate proxy servers into a single database. The Information Security team at Microsoft uses an internal tool called Information Security Consolidated Event Management (ICE 3.0) to gather forensic data from more than 85 proxy servers around the world. Powered by SQL Server 2005, the 27 TB data management system collects different types of global evidence, such as inbound and outbound e-mail traffic, Login events, and Web browsing, into a single... - [SQL SERVER - 2005 2000 - Search String in Stored Procedure](https://blog.sqlauthority.com/2007/11/10/sql-server-2005-2000-search-string-in-stored-procedure/): SQL Server has released SQL Server 2000 edition before 7 years and SQL Server 2005 edition before 2 years now. There are still few users who have not upgraded to SQL Server 2005 and they are waiting for SQL Server 2008 in February 2008 to SQL Server 2008 to release. This blog has is heavily visited by users from both the SQL Server products. I have two previous posts which demonstrate the code which can be searched string in stored procedure. Many users get confused with the script version and try to execute SQL Server 2005 version on SQL Server 2000,... - [SQL SERVER - Versions, CodeNames, Year of Release](https://blog.sqlauthority.com/2007/11/09/sql-server-versions-codenames-year-of-release/): Just a day ago, while I was discussing one of the project with another outsourcing team lead in India (who is leading team of 100+ programmer and developer) he asked me if I know all the codenames of the SQL Server releases so far. I knew only two code names SQL Server 2005 – Yukon and SQL Server 2008 – Katmai. Once our meeting was over, I could not stop thinking about this question. I search online and very easily I found answer to this question on wikipedia. 1993 – SQL Server 4.21 for Windows NT 1995 – SQL Server 6.0,... - [SQLAuthority News - Book Review - SQL Server 2005 Management and Administration (Paperback)](https://blog.sqlauthority.com/2007/11/08/sqlauthority-news-book-review-sql-server-2005-management-and-administration-paperback/): SQL Server 2005 Management and Administration (Paperback) by Ross Mistry (Author), Chris Amaris (Author), Alec Minty (Author), Rand Morimoto (Author) Link to Amazon Short Summary: SQL SERVER 2005 is a trusted database platform that provides organizations a competitive advantage by allowing them to obtain faster results and make better business decisions. This book covers all the topics which can help Database Administrators to be successful and effective. Detail summary: This book is covers all the topics and modules of the SQL Server 2005, e.g. database engine, Analysis Services, Integration Services, replication, Reporting Services, Notification Services, services broker and full text search.... - [SQLAuthority News - 1 Million Visitors in last 1 year - [Update 2019]](https://blog.sqlauthority.com/2007/11/07/sqlauthority-news-1-million-visitors-in-last-1-year-update-2019/): It is indeed a bit day for me. I am very happy that I have 1 million visitors in just last 1 year. Read my story of 365 days. - [SQLAuthority News - Microsoft Synchronization Services for ADO.NET v2.0 CTP1](https://blog.sqlauthority.com/2007/11/06/sqlauthority-news-microsoft-synchronization-services-for-adonet-v20-ctp1/): Microsoft Synchronization Services for ADO.NET provides the ability to synchronize data from disparate sources over two-tier, N-tier, and service-based architectures. Rather than simply replicating a database and its schema, the Synchronization Services application programming interface (API) provides a set of components to synchronize data between data services and a local store. Applications are increasingly used on mobile clients, such as laptops and devices, that do not have a consistent or reliable network connection to a central server. It is crucial for these applications to work against a local copy of data on the client. Equally important is the need to synchronize... - [SQLAuthority News - Few Add-ons for SQLAuthority](https://blog.sqlauthority.com/2007/11/05/sqlauthority-news-few-add-ons-for-sqlauthority/): SQL Random Article Find Post SQL Jobs Search SQLAuthority Subscribe Email Update SQLAuthority Feed My Other Blog Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Best Articles on SQLAuthority.com](https://blog.sqlauthority.com/2007/11/04/sqlauthority-news-best-articles-on-sqlauthoritycom/): SQL SERVER – Cursor to Kill All Process in Database SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored procedure SQL SERVER – Shrinking Truncate Log File – Log Full SQL SERVER – Simple Example of Cursor SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case SQL SERVER – Restore Database Backup using SQL Script (T-SQL) SQL SERVER – T-SQL Script to find the CD key from Registry SQL SERVER – Delete Duplicate Records – Rows SQL SERVER – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation SQL SERVER... - [SQLAuthority News - Best SQLAuthority Articles on Other Popular Sites](https://blog.sqlauthority.com/2007/11/03/sqlauthority-news-best-sqlauthority-articles-on-other-popular-sites/): Best SQLAuthority Articles on Other Popular Sites SQL SERVER – UDF vs. Stored Procedures and Having vs. WHERE (SQL Server Magazine) SQL SERVER – Pre-Code Review Tips – Tips For Enforcing Coding Standards (dotnetslackers.com) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Best Downloads on SQLAuthority.com](https://blog.sqlauthority.com/2007/11/02/sqlauthority-news-best-downloads-on-sqlauthoritycom/): Best Downloads on SQLAuthority.com SQL SERVER – Query Analyzer Shortcuts SQL Server Interview Questions and Answers Complete List Download SQL SERVER – Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts) SQL SERVER Database Coding Standards and Guidelines Complete List Download SQL SERVER – Data Warehousing Interview Questions and Answers Complete List Download Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - First Birthday of Blog - 365 Post in One Year](https://blog.sqlauthority.com/2007/11/01/sqlauthority-news-first-birthday-of-blog-365-post-in-one-year/): Hello Everyone, Today is birthday of this blog. Exactly one year ago, I started this journey of SQL Server and today I have reached first mile stone. There are so many great experience I had during this year. One thing I enjoyed the most is My Extremely Knowledgeable and Friendly Readers. I have learned a lot from all my readers, their emails and comments on this blog. You have been wonderful part of this blog. I was very surprised when I counted how many articles I had posted last year. It was perfect 365! One article a day!! Once again, I... - [SQL SERVER - Importance of Master Database for SQL Server Startup](https://blog.sqlauthority.com/2007/10/31/sql-server-importance-of-master-database-for-sql-server-startup/): I have received following questions. I will list all the questions here and answer them together. What is the purpose of Master database? - [SQL SERVER - Business Intelligence (BI) Basic Terms Explanation](https://blog.sqlauthority.com/2007/10/30/sql-server-business-intelligence-bi-basic-terms-explanation/): Business Intelligence Business intelligence is a method of storing and presenting key enterprise data so that anyone in your company can quickly and easily ask questions of accurate and timely data. Effective BI allows end users to use data to understand why your business go the particular results that it did, to decide on courses of action based on past data, and to accurately forecast future results. Data Warehouse A single structure that usually, but not always, consists of one or more cubes. Data Mart A defined subset of a data warehouse, often a single cube from a group. It represents... - [SQL SERVER - Disable All Triggers on a Database - Disable All Triggers on All Servers](https://blog.sqlauthority.com/2007/10/29/sql-server-disable-all-triggers-on-a-database-disable-all-triggers-on-all-servers/): Just a day ago, I received question in email regarding my article SQL SERVER – 2005 Disable Triggers – Drop Triggers. Question : How to disable all the triggers for database? Additionally, how to disable all the triggers for all servers? Answer: Disable all the triggers for a single database: USE AdventureWorks; GO DISABLE TRIGGER Person.uAddress ON AdventureWorks; GO Disable all the triggers for all servers: USE AdventureWorks; GO DISABLE TRIGGER ALL ON ALL SERVER; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL-Triggers - [SQLAuthority News - USB Drive Fails to Copy Large File](https://blog.sqlauthority.com/2009/08/14/sqlauthority-news-usb-drive-fails-to-copy-large-file/): I am currently traveling on a month-long training assignment for Business Intelligence. For demonstration purposes, I use Virtual PC files and hands-on lab examples for attendees of the training. The size of my VPC file is about 15 GB. Initially, I copy this file to a USB Drive and then move it to other computers, as needed. Recently, while trying to copy my VPC file to my USB drive I received the following error: Error Copying File or Folder. Cannot Copy. There is not enough free disk space. I had never experienced this problem before. I tried copying it a few... - [SQL SERVER - Reason for SQL Server Agent Starting Before SQL Server Engine Service](https://blog.sqlauthority.com/2009/08/13/sql-server-reason-for-sql-server-agent-starting-before-sql-server-engine-service/): Nakul, a dedicated member of the Gandhinagar SQL Server User Group, recently emailed me with a very interesting, but quick question. He asked me why the SQL Server Agent starts before SQL Server Engine does? He made the very valid point that as the SQL Server Engine is the core service, it should start first, and there is little point to running the SQL Server Agent without it. Off the top of my head, I can offer the following quick reasons for this sequence: The SQL Server Engine does not only run jobs for SQL Server Engine itself. It also runs... - [SQL SERVER - Backup master Database Interval - master Database Best Practices](https://blog.sqlauthority.com/2009/08/12/sql-server-backup-master-database-interval-master-database-best-practices/): During a recent consultancy project, I was asked to review a Database Backup plan. While going through the plan, I noticed that there was no backup for the master database. When I questioned this, the DBA informed me that it was not necessary. I was startled and couldn’t resist explaining to him that the master database contains all the logon accounts details, as well as all the system-level database configuration. He was a little astounded and asked me to tell him at what intervals he should backup the master database. The discussion that followed was very thought provoking and I would... - [SQL SERVER - Discussion - Effect of Missing Identity on System - Real World Scenario](https://blog.sqlauthority.com/2009/08/11/sql-server-discussion-effect-of-missing-identity-on-system-real-world-scenario/): About a week ago, SQL Server Expert, Imran Mohammed, provided a script, which will list all the missing identity values of a table in a database. In this post, I asked my readers if any could write a similar or better script. The results were interesting. While no one provided a new script, my question sparked a very active discussion that is still ongoing. When providing the script, Imran asked me if I knew of any specific circumstances in which this kind of query could be useful, as he could not think of an instance where it would be necessary to... - [SQLAuthority News - A Quick Guide to Twitter](https://blog.sqlauthority.com/2009/08/10/sqlauthority-news-a-quick-guide-to-twitter/): I am a very big fan of Twitter. I have been using it for quite sometime now and I think it is a very convenient way to stay connected with friends, families, and even the world. You can share or connect with them in real-time and tell them what you are doing currently. The best part about it is micro-blogging; you are not required to type a whole blog but just a statement of not more than 140 characters. Another advantage is that if you want to put a link then Twitter truncates the url to a tinyurl.com link, thus you... - [SQLAuthority News - Interview with SQL Server MVP Glenn Berry](https://blog.sqlauthority.com/2009/08/09/sqlauthority-news-interview-with-sql-server-mvp-glenn-berry/): Glenn Berry works as a Database Architect at NewsGator Technologies in Denver, CO. He is a SQL Server MVP, and has a whole collection of Microsoft certifications, including MCITP, MCDBA, MCSE, MCSD, MCAD, and MCTS. He is also an Adjunct Faculty member at University College – University of Denver, where he has been teaching since 2000. He is one wonderful blogger and often blogs at here. 1) Please tell us something about yourself. I have been working as a Database Architect at NewsGator Technologies for about 3.5 years. Before that, I worked as a Performance Architect at a company called Mortgage... - [SQL Server - Multiple CTE in One SELECT Statement Query](https://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/): I have previously written many articles on CTE. One question I get often is how to use multiple CTE in one query or multiple CTE in SELECT statement. Let us see quickly two examples for the same. I had done my best to take simplest examples in this subject. Option 1 : /* Method 1 */ ;WITH CTE1 AS (SELECT 1 AS Col1), CTE2 AS (SELECT 2 AS Col2) SELECT CTE1.Col1,CTE2.Col2 FROM CTE1 CROSS JOIN CTE2 GO Option 2: /* Method 2 */ ;WITH CTE1 AS (SELECT 1 AS Col1), CTE2 AS (SELECT COL1+1 AS Col2 FROM CTE1) SELECT CTE1.Col1,CTE2.Col2 FROM CTE1 CROSS JOIN CTE2 GO Please... - [SQLAuthority News - Humorous SQL Cake - Funny SQL Cake](https://blog.sqlauthority.com/2009/08/07/sqlauthority-news-humorous-sql-cake-funny-sql-cake/): I  received the following interesting images in email during the past 2 months. I think they are superbly hilarious! I received them from various people at different times, so their is unknown. Let me know which of the following images you find the most interesting. Hope you enjoyed watching them! Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Get Time in Hour:Minute Format from a Datetime - Get Date Part Only from Datetime](https://blog.sqlauthority.com/2009/08/06/sql-server-get-time-in-hourminute-format-from-a-datetime-get-date-part-only-from-datetime/): I have seen scores of expert developers getting perplexed with SQL Server in finding time only from datetime datatype. Let us have a quick glance look at the solution. Let us learn about how to get Time in Hour:Minute Format from a Datetime as well as to get Date Part Only from Datetime. - [SQL SERVER - Get a List of Fixed Hard Drive and Free Space on Server](https://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/): When I am not blogging, I am typically working on SQL Server Optimization projects. Time and again, I only have access to SQL Server Management Studio that I can remotely connect to server but do not have access to Operating System, and it works just fine. At one point in optimization project, I have to decide on index filegroup placement as well TempDB files (.ldf and .mdf) placement. It is commonly known that system gives enhanced performance when index and tempdb are on separate drives than where the main database is placed. As I do not have access to OS I... - [SQL SERVER - Forgot the Password of Username SA](https://blog.sqlauthority.com/2009/08/04/sql-server-forgot-the-password-of-username-sa/): I just received a call from an old friend with whom I used to work in Las Vegas. He told me about a password-related issue he faced in his organization. They had changed the password of username SA and now they are not able to recall the new password. I am sure that he is not the first person who has faced this issue. There may be many more similar situations where employees who have sysamin password leaves the job or a hacker disables the SA account. Resetting the password of SA is a breeze! Option 1 : If there is... - [SQLAuthority News - Author Visit - Virtual Tech Days August 2009](https://blog.sqlauthority.com/2009/08/04/sqlauthority-news-author-visit-virtual-tech-days-august-2009/): Microsoft India has organized a premier online technical event Microsoft Virtual TechDays between August 19-21, 2009. I had presented two technical sessions and they were greatly received by audience. I had received 50+ request for providing PPT for all the attendees. It was great FREE event and I suggest that everybody should have attended the event. While I was at Bangalore, I had great time meeting fellow experts and top evangelist from Microsoft. Presenting online event is totally different experience than presenting in front of real people in User Groups. In user group meeting  it is very easy to get feedback... - [SQL SERVER - Introduction to SQL Server 2008 Profiler - Complete](https://blog.sqlauthority.com/2009/08/03/sql-server-introduction-sql-server-2008-profiler-complete/): Introduction SQL Server Profiler is a powerful tool that is available with SQL Server since a long time; however, it has mostly been underutilized by DBAs. SQL Server Profiler can perform various significant functions such as tracing what is running under the SQL Server Engine’s hood, and finding out how queries are resolved internally and what scripts are running to accomplish any T-SQL command. The major functions this tool can perform have been listed below: Creating trace Watching trace Storing trace Replaying trace Trace includes all the T-SQL scripts that run simultaneously on SQL Server. As trace contains all the T-SQL... - [SQLAuthority News - Proposed eGov Standards Policy - Benefit for All or Only A Chosen Few](https://blog.sqlauthority.com/2009/08/02/sqlauthority-news-proposed-egov-standards-policy-benefit-for-all-or-only-a-chosen-few/): Does the proposed eGov Standards Policy benefit all or only a chosen few? As a wider audience comes to accept new technology, so the technology itself grows. The recent debate in India on the eGov Standards policy has been a point of contention for some time. I would like to start our discussion on this topic by posing two questions: Question 1: Should government mandate single standards for a given technology domain? The obvious answer would appear to be “Yes”, but the considered answer is actually “No”. The stipulation of a “single standard” would unnecessarily restrict the technology choices for the... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2009/08/01/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-4/): Note : Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. The following list gives an overview of the features of the SQL Server management pack. Support for Enterprise, Standard and Express editions of SQL Server 2000, 2005 and 2008 and 32bit, 64bit and ia64 architectures.... - [SQL SERVER - Introduction to Cloud Computing](https://blog.sqlauthority.com/2009/07/31/sql-server-introduction-to-cloud-computing/): Introduction “Cloud Computing,” to put it simply, means “Internet Computing.” The Internet is commonly visualized as clouds; hence the term “cloud computing” for computation done through the Internet. With Cloud Computing users can access database resources via the Internet from anywhere, for as long as they need, without worrying about any maintenance or management of actual resources. Besides, databases in cloud are very dynamic and scalable. Cloud computing is unlike grid computing, utility computing, or autonomic computing. In fact, it is a very independent platform in terms of computing. The best example of cloud computing is Google Apps where any application... - [SQLAuthority News - Author's Birthday - Top 7 Commenters - Volunteers](https://blog.sqlauthority.com/2009/07/30/sqlauthority-news-authors-birthday-top-7-commenters-volunteers/): Today is July 30 and I am very happy; it’s my Birthday, celebration time!!! The most common question I receive on my every birthday is -what are my plans for birthday. Let me share my plans here today. Additionally, if you are interested to know when SQL Server was born read my post SQLAuthority News – Author BirthDay – SQL Server Birthday. My first plan is that I am going to take a break from blogging on anything technical today and spend more time with my family. Let me tell you about my second plan. I am very much pleased and... - [SQL SERVER - 2008 - Copy Database With Data - Generate T-SQL For Inserting Data From One Table to Another Table](https://blog.sqlauthority.com/2009/07/29/sql-server-2008-copy-database-with-data-generate-t-sql-for-inserting-data-from-one-table-to-another-table/): Just about a year ago, I had written on the subject of how to insert data from one table to another table without generating any script or using wizard in my article SQL SERVER – Insert Data From One Table to Another Table – INSERT INTO SELECT – SELECT INTO TABLE. Today, we will go over a similar question regarding how to generate script for data from database as well as table. SQL Server 2008 has simplified everything. Let us take a look at an example where we will generate script database. In our example, we will just take one table... - [SQL SERVER - 2008 - Design Process Decision Flow](https://blog.sqlauthority.com/2009/07/28/sql-server-2008-design-process-decision-flow/): I was recently invited by a company that is primarily using other RDBMS as their primary database for solutions. It was a different experience for me, as I am used to having pretty good SQL Server Smart crowd in my presentations, but this time there were smart people but no SQL Server experts in front of me. I was asked to elucidate the basics of SQL Server as well as how it works. Now, this was nothing short of a challenge for me; I had never done this kind of high level presentation. I used presentation from Infrastructure Planning and Design... - [SQL SERVER - List All Missing Identity Values of Table in Database](https://blog.sqlauthority.com/2009/07/27/sql-server-list-all-missing-identity-values-of-table-in-database/): The best part of any blog is when readers ask each other questions. Better still, is when a reader takes the time to provide a detailed response. A few days ago, one of my readers, Yasmin, asked a very interesting question: How we can find the list of tables whose identity was missed (not is sequential order) within the entire database? A big thank you to SQL Server Expert, Imran Mohammed, for his excellent response to this question. He also provided an extremely impressive script, which is well described and contains inline comments. We will now see the same example with... - [SQLAuthority News - Search SQL Server Solutions](https://blog.sqlauthority.com/2009/07/26/sqlauthority-news-search-sql-server-solutions/): So far, I have written over 1030 articles on my blog, and I have  received  an astounding  12,000+ comments. Undoubtedly, it has acquired the status of a  huge database now! I nearly receive 200+ emails  and lots of comments on this blog every day. I do maintain a log of all the comments and emails received. As per my observation, I have already answered 90% of the questions asked via email in this blog earlier. I do my best to respond to each email and comment of my readers. Quite often, the question asked in email is very urgent and  by... - [SQLAuthority News - Download - Cumulative Update Package for SQL Server 2008](https://blog.sqlauthority.com/2009/07/25/sqlauthority-news-download-cumulative-update-package-for-sql-server-2008/): SQL Server 2008 has been out for over two years and now a very significant Cumulative Update has been released. If you are using SQL Server 2008 then you must certainly install it to fix the various bugs. Cumulative Update 3 for SP1: http://support.microsoft.com/kb/971491 Cumulative Update 6 for RTM: I heavily recommend this update. Feel free to talk to me if you want more information on it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Maximizing View of SQL Server Management Studio - Full Screen - New Screen](https://blog.sqlauthority.com/2009/07/24/sql-server-maximizing-view-of-sql-server-management-studio-full-screen-new-screen/): I had a great, unforgettable time at Teched India 2009 in Hyderabad. I had delivered a successful session on SQL Server Management Studio Best Practices, which created a lot of interest in community. I was truly amazed at the tremendous response I got. I received countless different questions on this subject as soon as the event was over. One of the most frequently asked questions was about my demo on how to increase real estate of SSMS (SQL Server Management Studio). I had explained the following two different methods: 1) Open Results in Separate Tab This is a very interesting method... - [SQL SERVER - Puzzle - Write Script to Generate Primary Key and Foreign Key](https://blog.sqlauthority.com/2009/07/23/sql-server-puzzle-write-script-to-generate-primary-key-and-foreign-key/): In one of my recent projects, a large database migration project, I confronted a peculiar situation. SQL Server tables were already moved from Database_Old to Database_New. However, all the Primary Key and Foreign Keys were yet to be moved from the old server to the new server. Please note that this puzzle is to be solved for SQL Server 2005 or SQL Server 2008. As noted by Kuldip it is possible to do this in SQL Server 2000. In SQL Server Management Studio (SSMS), there is no option to script all the keys. If one is required to script keys they... - [SQLAuthority News - SQL Server Value Calculator](https://blog.sqlauthority.com/2009/07/22/sqlauthority-news-sql-server-value-calculator/): I have been using twitter for quite some time now (follow me at @pinaldave). In twitter world very often I find something interesting shared by my friends there. SQL Server Expert and Microsoft Evanglist Vinod Kumar has twitted very interesting detail linking to SQL Server Value Calculator. The web version of this tool is created in Silver Light and looks very cool and gives impression of PC Game Sims at first moment. This tool calculates Total Estimate Saving if SQL Server is used in any organization. It takes into consideration Total IT team members, Bandwidth, Servers, Security, Reports, Audits, Supports Calls... - [SQLAuthority News - SQL Azure - Microsoft SQL Data Services - Introduction and Pricing](https://blog.sqlauthority.com/2009/07/21/sqlauthority-news-sql-azure-microsoft-sql-data-services-introduction-and-pricing/): Microsoft has updated the branding for SQL Services and SQL Data Services. SQL Services will be called Microsoft SQL Azure, and SQL Data Services will be Microsoft SQL Azure Database. Changing the name does not change product but it demonstrates tight integration between the components of the service platforms. As a part of the Windows Azure platform, SQL Azure Database will deliver traditional relational database service in the cloud, supporting T-SQL over Tabular Data Stream (TDS) protocol. SQL Azure Database will be available in two editions: the Web Edition Database and the Business Edition Database. Web Edition – 2GB of T-SQL... - [SQLAuthority News - Authors Visit - DelhiBuzz TechEd on July 11, 2009](https://blog.sqlauthority.com/2009/07/20/sqlauthority-news-authors-visit-delhibuzz-teched-on-july-11-2009/): SQLBuzzDelhi organized TechEd Delhi on July 11, 2009. They even launched an official PASS Chapter in Delhi. The complete report of this event is here. This event like TechEd in Ahmedabad,  was a huge success and saw a huge number of attendees from all over India. Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. The event saw many wonderful speakers.I really appreciate the facility at DelhiBuzz and the amazing crowd brimming with enthusiasm. I really want to thank two people in particular for making the SQL PASS Delhi a grand success... - [SQL SERVER - Get Last Running Query Based on SPID](https://blog.sqlauthority.com/2009/07/19/sql-server-get-last-running-query-based-on-spid/): We often need to find the last running query or based on SPID need to know which query was executed. SPID is returns sessions ID of the current user process. The acronym SPID comes from the name of its earlier version, Server Process ID. To know which sessions are running currently, run the following command: SELECT @@SPID GO In our case, we got SPID 57, which means the session that is running this command has ID of 57. Now, let us open another session and run the same command. Here we get different IDs for different sessions. In our case, we... - [SQLAuthority News - Whitepaper - Using the Resource Governor](https://blog.sqlauthority.com/2009/07/18/sqlauthority-news-whitepaper-using-the-resource-governor/): Using the Resource Governor SQL Server Technical Article Writer: Aaron Bertrand, Boris Baryshnikov Technical Reviewers: Louis Davidson, Mark Pohto, Jay (In-Jerng) Choe Published: June 2009 SQL Server 2008 introduces a new feature, the Resource Governor, which provides enterprise customers the ability to both monitor and control the way different workloads use CPU and memory resources on their SQL Server instances. This paper explains several practical usage scenarios and gives guidance on best practices. The Resource Governor is a new feature in the Microsoft SQL Server 2008 Enterprise. It provides very powerful and flexible controls to dictate and monitor how a SQL... - [SQL SERVER - Two Methods to Retrieve List of Primary Keys and Foreign Keys of Database](https://blog.sqlauthority.com/2009/07/17/sql-server-two-methods-to-retrieve-list-of-primary-keys-and-foreign-keys-of-database/): There are two different methods to retrieve the list of Primary Keys and Foreign Keys from the database. - [SQL SERVER - Four Different Ways to Find Recovery Model for Database](https://blog.sqlauthority.com/2009/07/16/sql-server-four-different-ways-to-find-recovery-model-for-database/): Perhaps, the best thing about technical domain is that most of the things can be executed in more than one ways. It is always useful to know about the various methods of performing a single task. Today, we will observe four different ways to find out recovery model for any database. Method 1 Right Click on Database >> Go to Properties >> Go to Option. On the Right side you can find recovery model. Method 2 Click on the Database Node in Object Explorer. In Object Explorer Details, you can see the column Recovery Model. Method 3 This is a very... - [SQL SERVER - Restore Sequence and Understanding NORECOVERY and RECOVERY](https://blog.sqlauthority.com/2009/07/15/sql-server-restore-sequence-and-understanding-norecovery-and-recovery/): I maintain a spreadsheet of questions sent by users and from that I single out a topic to write and share my knowledge and opinion. Unless and until I find an issue appealing, I do not prefer to write about it, till the issue crosses the threshold. Today the question that crossed the threshold is - what is the difference between NORECOVERY and RECOVERY when restoring database and what is the restore sequence. - [SQL SERVER - Backup Timeline and Understanding of Database Restore Process in Full Recovery Model](https://blog.sqlauthority.com/2009/07/14/sql-server-backup-timeline-and-understanding-of-database-restore-process-in-full-recovery-model/): I assume you all know that there are three types of Database Backup Models, so we will not discuss on this commonly known topic today. In fact, we will just talk about how to restore database that is in full recovery model. Let us learn about backup timeline. - [SQL SERVER - BLOB - Pointer to Image, Image in Database, FILESTREAM Storage](https://blog.sqlauthority.com/2009/07/13/sql-server-blob-pointer-to-image-image-in-database-filestream-storage/): When it comes to storing images in database there are two common methods. I had previously blogged about the same subject on my visit to Toronto. With SQL Server 2008, we have a new method of FILESTREAM storage. However, the answer on when to use FILESTREAM and when to use other methods is still vague in community. Let us look into two traditional methods first along with their advantage and disadvantages. Method 1) Store image in filesystem and store pointer in database This is quite an old method and you can find this implemented in many places, even though SQL Server... - [SQLAuthority News - Big Thinkers - Robert Cain](https://blog.sqlauthority.com/2009/07/12/sqlauthority-news-big-thinkers-robert-cain/): I am exceedingly impressed and inspired by an on-going series of Big Thinkers by Robert Cain – A SQL Server MVP and a genial, whole-souled person. On meeting Robert Cain earlier this year at SQL Server MVP Summit in Seattle I asked him a question – Where do you get so many innovative ideas to write on blog and create presentations? He replied, “I do not try to get ideas, my experience inspires me.” Well, it is true that Robert has more than 10 years of experience as one of the TOP experts in SQL Server. Unlike most of the SQL... - [SQL SERVER - Standby Servers and Types of Standby Servers](https://blog.sqlauthority.com/2009/07/11/sql-server-standby-servers-and-types-of-standby-servers/): Standby servers – Standby Server is a type of server that can be brought online in a situation when Primary Server goes offline and application needs continuous (high) availability of the server. There is always a need to set up a mechanism where data and objects from primary server are moved to secondary (standby) server. This mechanism usually involves the process of moving backup from the primary server to the secondary server using T-SQL scripts. Often, database wizards are used to set up this process. We will now glance at the various types of standby servers. Hot Standby – Hot Standby... - [SQLAuthority News - Request SQLAuthority.com Stickers and SQL Server Cheat Sheet](https://blog.sqlauthority.com/2009/07/10/sqlauthority-news-request-sqlauthority-com-stickers-and-sql-server-cheat-sheet/): I have been overwhelmed with the request for SQL Server Cheat Sheet recently. I absolutely think it is tremendously useful; its hand written form is adorning my wall since a long time. Having realized its usefulness I got it done professionally and distributed it at TechEd in Hyderabad, TechEd in Ahmedabad, and TechEd on Road in Trivendrum. Now, they are very much in demand. - [SQLAuthority News - Authors Visit - K-MUG TechEd Trivandrum on June 27, 2009](https://blog.sqlauthority.com/2009/07/09/sqlauthority-news-authors-visit-k-mug-teched-trivandrum-on-june-27-2009-2/): K-MUG organized TechEd Trivandrum on 27th June, 2009. They even launched an official PASS Chapter in Trivandrum. The complete report of this event is here. This event like TechEd in Ahmedabad,  was a huge success and saw a huge number of attendees from all over India. Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. The event saw many wonderful speakers.I really appreciate the state-of-the-art facility at K-Mug and the amazing crowd brimming with enthusiasm. You can check out K-MUG event page for further information. I really want to thank two people... - [SQLAuthority News - Book Review - Murach's SQL Server 2008 for Developers](https://blog.sqlauthority.com/2009/07/08/sqlauthority-news-book-review-murachs-sql-server-2008-for-developers/): Murach’s SQL Server 2008 for Developers (Murach: Training & Reference) (Paperback) by Bryan Syverson, Joel Murach Link to Amazon Short Summary: Murach’s SQL Server 2008 for developers is an ideal book for all developers, and particularly, it is an excellent book for training and reference. If you are new to SQL, no problem! This book is the best reading material to start with. Long Summary: SQL Server has emerged as the leading database and nowadays there are a number of books available on this subject. However, it is important to select the right book to imbibe proper, thorough understanding. Murach’s SQL... - [SQLAuthority News - Authors Visit - DotNet Buzz Delhi TechEd Delhi on July 11, 2009](https://blog.sqlauthority.com/2009/07/07/sqlauthority-news-authors-visit-dotnet-buzz-delhi-teched-delhi-on-july-11-2009/): DotNet Buzz Delhi is organizing TechEd Delhi on July 11, 2009. Not just this, they are launching an official PASS Chapter in Delhi. The Agenda of the event is here and if you are around Delhi do not miss the opportunity to be a part of this upcoming great event. If you are keen to know what this event holds in store for you then read about TechEd in Ahmedabad, which saw a huge number of attendees and was a grand success.  Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. I... - [SQL SERVER - Languages for BI - MDX, DMX, XMLA](https://blog.sqlauthority.com/2009/07/06/sql-server-languages-for-bi-mdx-dmx-xmla/): Today, we have a very basic thing to go over. Few days back, I was discussing with one of my friends regarding BI. He told me that he knows that BI stands for Business Intelligence but he would like to know what languages BI uses to achieve the goal. The reason I found this question very interesting was because I was asked the same question two weeks back at TechEd on Road Ahmedabad. I had promised one of the attendees that I will reply to his question soon. This question, which my friend asked recently, reminded me of the same. Let us go over the languages of BI very quickly. Again, these are just definitions and there is much more to learn. Moreover, to master each language it may take years. - [SQLAuthority News - FIX : Error : HP OfficeJet Scanning and Printing Gray or Pink Shades](https://blog.sqlauthority.com/2009/07/05/sqlauthority-news-fix-error-hp-officejet-scanning-and-printing-gray-or-pink-shades/): Unlike my usual articles today’s article is not at all related to SQL Server but something drove me to include it on my blog. This issue snatched away my precious few hours. It took me over 2 hours to resolve it yesterday, which barred me from doing research on SQL Server. I am sure many people must have faced this issue and the sad part is no solution has been proposed so far. Let us understand the problem first. I got a brand new printer HP Officejet J4580 All-in-One printer. Support Engineer came along to install it. Fax, Printing, Photocopy –... - [SQL SERVER - Disk Partition Alignment Best Practices](https://blog.sqlauthority.com/2009/07/04/sql-server-disk-partition-alignment-best-practices/): Note :  Download Disk Partition Alignment Best Practices for SQL Serverby Microsoft Disk partition alignment is a powerful tool for improving SQL Server performance. Configuring optimal disk performance is often viewed as much art as science. A best practice that is essential yet often overlooked is disk partition alignment. Windows Server 2008 attempts to align new partitions out-of-the-box, yet disk partition alignment remains a relevant technology for partitions created on prior versions of Windows. This paper documents performance for aligned and nonaligned storage and why nonaligned partitions can negatively impact I/O performance; it explains disk partition alignment for storage configured on... - [SQLAuthority News - Book Review - The Rational Guide to Building Technical User Communities (Rational Guides)](https://blog.sqlauthority.com/2009/07/03/sqlauthority-news-book-review-the-rational-guide-to-building-technical-user-communities-rational-guides/): The Rational Guide to Building Technical User Communities (Rational Guides) (Paperback) by Greg Low Short Review : A Great, one-of-its-kind book for everybody who is interested in building technical user community. There is no other book written on this subject but after this comprehensive book no further reading will be required. Link to Amazon Detailed Review : This is for the first time in my book review, instead of talking about the book or author, I will introduce myself in a couple of lines to explain why and how this book is helpful to those interested in building community. I am... - [SQLAuthority News - MVP Award Renewed](https://blog.sqlauthority.com/2009/07/02/sqlauthority-news-mvp-award-renewed/): Year ago, it was a great, perhaps the proudest moment of my professional life. I was awarded Most Valuable Professional (MVP) for SQL Server by Microsoft. Today, I received an email informing me that I have been re-awarded SQL Server MVP status by Microsoft in recognition of my community contributions. It’s yet another proud moment for me. I’m very happy and excited that my hard work is being recognized.  I hope to work even harder and serve my community better! Microsoft Thank You! There’s a huge list of people I would like to thank for this award. However, instead of listing... - [SQL SERVER - Difference between Line Feed (\n) and Carriage Return (\r) - T-SQL New Line Char](https://blog.sqlauthority.com/2009/07/01/sql-server-difference-between-line-feed-n-and-carriage-return-r-t-sql-new-line-char/): Today, we will examine something very simple and very generic that can apply to hordes of programming languages. Let’s take a common question that is frequently discussed – What is difference between Line Feed (\n) and Carriage Return (\r)? Prior to continuing with this article let us first look into few synonyms for LF and CR. Line Feed – LF – \n – 0x0a – 10 (decimal) Carriage Return – CR – \r – 0x0D – 13 (decimal) Now that we have understood that we have two different options to get new line, the question that arises is – why is... - [SQL SERVER - 2008 - Policy-Based Management - Create, Evaluate and Fix Policies](https://blog.sqlauthority.com/2009/06/30/sql-server-2008-policy-based-management-create-evaluate-and-fix-policies/): This article will cover the most spectacular feature of SQL 2008 – Policy-based management and how the configuration of SQL Server with policy-based management architecture can make a powerful difference. Policy based management is loaded with several advantages. It can help you implement various policies for reliable configuration of the system. It also provides additional administration assistance to DBAs and helps them effortlessly manage various tasks of SQL Server across the enterprise. 1 Introduction 2 Basics of Policy Management 3 Policy Management Terms 4 Practical Example of Policy Management 4.1 Exploring of Facets 4.2 Create a Condition 4.3 Create a Policy... - [SQL SERVER - Maximum Number of Index per Table](https://blog.sqlauthority.com/2009/06/29/sql-server-maximum-number-of-index-per-table/): TechEd on Road Ahmedabad, June 20, 2009, was a huge success. This grand event saw over 200 attendees actively participating in the sessions. We had attendees traveling from far and wide, including Delhi, Mumbai, Jaipur, Kerala, Baroda, Himmatnagar, Rajkot, among other cities from India. This enthusiastic participation made the event truly grand. It was a moment of bliss for me as I had not anticipated such tremendous positive response! Although the Official time to commence the event was at 1:45 PM we were really excited to see the attendees entering the hall before the official time. We were more than happy... - [SQL SERVER - SQL Server Management Studio New Features](https://blog.sqlauthority.com/2009/06/28/sql-server-2008-management-studio-new-features-2/): This article describes the top 5 features of SQL Server Management Studio 2008. With the release of SQL Server 2008 Microsoft has upgraded SSMS with many new features as well as added tons of new functionalities requested by DBAs for long time. - [SQL SERVER - Fix : Error : 17892 Logon failed for login due to trigger execution. Changed database context to 'master'.](https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context-to-master/): I had previously written two articles about an intriguing observation of triggers online. SQL SERVER – Interesting Observation of Logon Trigger On All Servers SQL SERVER – Interesting Observation of Logon Trigger On All Servers – Solution If you are wondering what made me write yet another article on logon trigger then let me tell you the story behind it. One of my readers encountered a situation where he dropped the database created in the above two articles and he was unable to logon to the system after that. Let us recreate the scenario first and attempt to solve the problem.... - [SQL SERVER - Interesting Observation of Logon Trigger On All Servers - Solution](https://blog.sqlauthority.com/2009/06/26/sql-server-interesting-observation-of-logon-trigger-on-all-servers-solution/): Does the title of this post trigger your mind? If you all remember, a few days back I had written an article on my interesting observation regarding logon triggers. I would advise you to first read SQL SERVER – Interesting Observation of Logon Trigger On All Servers before continuing with this article further to have a complete idea of the subject. The question I put forth in my previous article was – In single login why the trigger fires multiple times; it should be fired only once. I received numerous answers in thread as well as in my MVP private news... - [SQLAuthority News - Authors Visit - K-MUG TechEd Trivandrum on June 27, 2009](https://blog.sqlauthority.com/2009/06/25/sqlauthority-news-authors-visit-k-mug-teched-trivandrum-on-june-27-2009/): K-MUG is organizing TechEd Trivandrum on 27th June, 2009. Not just this, they are launching an official PASS Chapter in Trivandrum. The Agenda of the event is here and if you are around Trivandrum do not miss the opportunity to be a part of this upcoming great event. If you are keen to know what this event holds in store for you then read about TechEd in Ahmedabad, which saw a huge number of attendees and was a grand success.  Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. Click here for... - [SQLAuthority News - Update on pinaldave.com and SQLAuthority.com](https://blog.sqlauthority.com/2009/06/24/sqlauthority-news-update-on-pinaldave-com-and-sqlauthority-com/): Problem: SQLAuthority.com site was not allowed in some browsers as pinaldave.com site was marked as malware or badware distributing third party site. Status: SQLAuthority.com and pinaldave.com both the sites are safe now and there is no threat to your computer. Feel free to click on the links. Since the last two mornings I have received over 200 emails querying about the error my sites were generating. I encountered countless questions and worst of all I was thrown verbal abuse for not getting my own site up right away and for being careless. I’m much relieved today as everything is back to... - [SQL SERVER - Delete Duplicate Rows](https://blog.sqlauthority.com/2009/06/23/sql-server-2005-2008-delete-duplicate-rows/): I had previously penned down two popular snippets regarding deleting duplicate rows and counting duplicate rows. Today, we will examine another very quick code snippet where we will delete duplicate rows using CTE and ROW_NUMBER() feature of SQL Server 2005 and SQL Server 2008. - [SQLAuthority News - TechEd on Road Ahmedabad June 20, 2009 - An Astounding Success](https://blog.sqlauthority.com/2009/06/22/sqlauthority-news-teched-on-road-ahmedabad-june-20-2009-an-astounding-success/): TechEd on Road Ahmedabad In India, TechEd was held in Hyderabad in the month of May. You can read myTechEd summary article here. A similar event will be organized in 10 major cities in India. Ahmedabad saw its first TechEd on Road and it was wholeheartedly welcomed by technology enthusiasts. The event was held at Rock regency, in the heart of Ahmedabad on June 20, 2009. We had attendees traveling over 500 miles to attend the event. We had attendees from Delhi, Mumbai, Jaipur, Kerala, Baroda, Himmatnagar, Rajkot, among other cities from India. It was a joyous and overwhelming experience for... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.1](https://blog.sqlauthority.com/2009/06/21/sqlauthority-news-risk-and-health-assessment-program-for-microsoft-sql-server-scoping-tool-v1-1/): Note :   Download Risk and Health Assessment Utility by Microsoft Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.1 is a practical download package intended exclusively for Microsoft Premier Customers. This package paraphernalia includes all the scoping tools required to prepare and qualify your environment to receive a Risk and Health Assessment Program for Microsoft SQL Server. Getting started with it is very easy. First, extract the Scoping Tool zip package to the tools server that will be used during the RAP engagement. Next, refer to Instructions.txt in the Scoping Tool folder for exhaustive instructions on executing... - [SQL Server - Understanding Table Hints with Examples](https://blog.sqlauthority.com/2009/06/20/sql-server-understanding-table-hints-with-examples-2/): Today we have a very interesting subject to look at. I tried to look for help online but have not found any other documentation besides what we have from the Book Online. Let us try to understand what are the different kinds of hints available in SQL Server and how they are helpful. What is a Hint? Hints are options and strong suggestions specified for enforcement by the SQL Server query processor on DML statements. The hints override any execution plan the query optimizer might select for a query. Before we continue to explore this subject, we need to consider one... - [SQL SERVER - Why You Should Attend PASS Summit Unite 2009- Seattle](https://blog.sqlauthority.com/2009/06/19/sql-server-why-you-should-attend-pass-summit-unite-2009-seattle/): PASS Summit Unite 2009 – the premier event for SQL Server professionals – will be held in Seattle from November 2 to November 5. It is the largest and the most intensive Microsoft SQL Server conference in the world organized by SQL Server users for SQL Server users. This year marks the 10th Anniversary of PASS Community Summit, making the event even more special. Every year, this event sees a huge number of attendees, as apart from high quality technical sessions it provides unparalleled access to the Microsoft SQL Server development, SQL CAT, and Customer Service and Support teams. PASS Summit... - [SQL SERVER - Clustered Index on Separate Drive From Table Location](https://blog.sqlauthority.com/2009/06/18/sql-server-clustered-index-on-separate-drive-from-table-location/): How to improve performance of SQL Server Queries is a common topic of discussion among many of us. Much has been said, much has been discussed. Few days back, I had an interesting discussion with one of the Junior developers regarding performance improvement of SQL Server Queries. We discussed on how by using a separate hard drive for several database objects can right away improve performance. I suggested him that non clustered index and tempdb can be created on a separate disk to improve performance. - [SQL SERVER - List Schema Name and Table Name for Database](https://blog.sqlauthority.com/2009/06/17/sql-server-list-schema-name-and-table-name-for-database/): Just a day ago, I was looking for script which generates all the tables in database along with its schema name. I tried to Search@SQLAuthority.com but got too many results. For the same reason, I am going to write down today’s quick and small blog post and I will remember that I had written I wrote it after my 1000th article. SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']' AS SchemaTable FROM sys.tables Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 1000th Article Milestone - 8 Millions Views - Solid Quality Mentors](https://blog.sqlauthority.com/2009/06/16/sqlauthority-news-1000th-article-milestone-8-millions-views-solid-quality-mentors/): Achieving a milestone gives a great sense of accomplishment! Today, I am writing my 1000th Article on this blog. I am extremely happy and gratified.  It is indeed a long journey since I started a few years back and at that time I had no idea that within a short period I would attain so much appreciation and popularity.  I intend to continue my journey further and attain more milestones. I have always enjoyed learning, sharing and helping my community. Through this blog, I have met many wonderful people, made great friends and interacted with diverse readers from across the globe.... - [SQL SERVER - Query Optimizer Hint ROBUST PLAN - Question to You](https://blog.sqlauthority.com/2009/06/15/sql-server-query-optimizer-hint-robust-plan-question-to-you/): While cleaning up my bookmarks this week, I stumbled upon a very small interesting thing. I can proudly call myself a pro at finding stuffs, but after continuously hunting online I could not gather comprehensive information about this topic. I was actually looking for a practical example for Query Optimizer Hint “ROBUST PLAN”. Before I seek help from you, let us first try to understand what query optimizer hints is and then we will move on to the concept of “ROBUST PLAN”. To put it simply, Query hints is a T-SQL clause which on running directs T-SQL query to run in... - [SQL SERVER - 2008 - SSMS Feature - Multi-server Queries](https://blog.sqlauthority.com/2009/06/14/sql-server-2008-ssms-feature-multi-server-queries/): In my recent visit to TechEd India 2009 at Hyderabad, I had taken a technical session on SQL Server Management Studio 2008 New Features, which was attended by a huge number of participants and was very successful. I got loads of requests from my readers for posting the session online. My presentation involved several videos and demos, so practically it is not possible for me to post my original session online. But as I do not want to disappoint my readers I have one solution; what I can do is that I can share some valuable tips from the session with... - [SQL SERVER - Effect of Normalization on Index and Performance](https://blog.sqlauthority.com/2009/06/13/sql-server-effect-of-normalization-on-index-and-performance/): Of late, I have been using Twitter quite frequently, and I am gradually discovering its usefulness. I received a Direct Message (or DM in terms of twitter) asking if I can comment on the effect of normalization on the Index and its performance in one twit! Now honestly speaking, this was new for me. I never expected to be quizzed like this. If you are using Twitter, then you must be aware that one twit contains only 140 characters. I was supposed to give answer on such a big subject in just 140 letters. An interesting fact is that normalization and the Index are not really closely related. The right question should have been – what is the effect of normalization on performance? - [SQL SERVER - 2008 - Customize Toolbar - Remove Debug Button from Toolbar](https://blog.sqlauthority.com/2009/06/12/sql-server-2008-customize-toolbar-remove-debug-button-from-toolbar/): In today’s article I have combined two different questions. I was fond of SQL Server Debugger feature in SQL Server 2000. To my utter disappointment, this feature was withdrawn from SQL Server 2005. However, because of loads of requests from developers it was re-introduced in SQL Server 2008. Let us learn about how to customize toolbars.  - [SQLAuthority News - Registration and Competition - TechEd on Road - Ahmedabad - June 20, 2009 Saturday](https://blog.sqlauthority.com/2009/06/11/sqlauthority-news-registration-and-competition-teched-on-road-ahmedabad-june-20-2009-saturday/): We have an upcoming grand event of TechEd on Road organized in Ahmedabad. This is a FREE event and ANYBODY who loves technology can attend it. This event will provide a precious opportunity to learn, interact and network with tech enthusiasts. I encourage you all to be a part of it and experience the joy of learning in a healthy and fun environment. - [SQL SERVER - Performance Counters from System Views - By Kevin Mckenna](https://blog.sqlauthority.com/2009/06/10/sql-server-performance-counters-from-system-views-by-kevin-mckenna/): I just love social media and all the new concepts of Web 2.0. There are bloggers who are overwhelmed by the new concepts of technology and are not able to keep pace with it. But I like taking such challenges. Twitter has acquired tremendous popularity nowadays and just like everybody else I am also fond of this latest vogue. You can follow me at Twitter here. Through twitter I am getting to meet people like me and it’s a great experience interacting with them. I met SQL and .NET expert Kevin Mckenna on twitter itself. Kevin is originally from Liverpool, England,... - [SQLAuthority News - TechEd On Road Ahmedabad, India is Announced - June 20, 2009 Saturday](https://blog.sqlauthority.com/2009/06/09/sqlauthority-news-teched-on-road-ahmedabad-india-is-announced-june-20-2009-saturday/): If you are regretting for missing TechEd India 2009 at Hyderabad here’s your chance of catching up with a similar kind of technology event in Ahmedabad, India on Saturday June 20, 2009. TechEd on Road will be held in Ahmedabad at Rock Regency, a prime location in the heart of the city. - [SQL SERVER - Fix: Error 15372 Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance - The connection will be closed](https://blog.sqlauthority.com/2009/06/08/sql-server-fix-error-15372-failed-to-generate-a-ser-instance-od-sql-server-due-to-a-failure-in-starting-the-process-for-the-user-instance-the-connection-will-be-closed/): Just a day ago, I was installing SQL Server Express on the backup computer. I found the solution for Error 15372. - [SQLAuthority News - Using SQL Server 2008 Extended Events - White paper By Jonathan Kehayias](https://blog.sqlauthority.com/2009/06/07/sqlauthority-news-using-sql-server-2008-extended-events-white-paper-by-jonathan-kehayias/): Strange it may sound but being a SQL Server pro has its downside too. Common information on SQL does not interest me, while a good document is hard to find. So the reader in me is mostly discontented and constantly keeps looking for interesting documents.  Recently, I chanced upon a really good white paper by Jonathan Keyhayias on SQL Serve r2008 extended events. I have known Jonathan through forums but have not met him in person yet. But I hope to meet him soon. The white paper starts with introduction to the extended event and then elaborates on its architecture, system... - [SQL SERVER - Order of Hotfix and Service Pack](https://blog.sqlauthority.com/2009/06/06/sql-server-order-of-hotfix-and-service-pack/): On an average once a week I receive a question from my readers regarding what should be the sequence of hotfix and service pack. Not long ago, one of my regular readers who is using SQL Server 2000 asked me how can he improve the installation speed as he has to install 4 Service Packs to upgrade his server to SQL Server SP4 version. All these questions from my readers have prompted me to write down this small note.  I hope this will clear some of the common doubts they have about this subject and they no longer would have to... - [SQLAuthority News - Rambling of Author and Technology Musing - Bing, Google, Windows 7, Books, Blogs, Twitter and Life](https://blog.sqlauthority.com/2009/06/05/sqlauthority-news-rambling-of-author-and-technology-musing-bing-google-windows-7-books-blogs-twitter-and-life/): I have been planning to write a general post on the latest technology for a long time but SQL keeps me so busy that I hardly get time. I know being busy is no excuse as everybody is busy with something. A manager is equally busy managing people as much as a peon busy doing errands. Now, coming back to my topic, I have lots of news to share with you all. Anyway, number one news is that Bing has been finally released a couple of days back. I am very much excited as something is finally challenging Google – The... - [SQL SERVER - What is Interim Table - Simple Definition of Interim Table](https://blog.sqlauthority.com/2009/06/04/sql-server-what-is-interim-table-simple-definition-of-interim-table/): Sometimes a simple question like “What is interim table?” can initiate a never-ending discussion between developers. I experienced this recently while I was on phone helping my friends working in Los Angeles. In a conference call, one of the developers kept on talking about “first interim table” and “second interim table” and so forth, while another developer was of the opinion that that there cannot be more than one interim table. Well, as this was not enough a third developer interrupted the debate and said that all the tables are interim tables. The heated discussion seemed never ending. To put the... - [SQL SERVER - Connect Item - Vote for Feature Request Function TRIM](https://blog.sqlauthority.com/2009/06/03/sql-server-connect-item-vote-for-feature-request-function-trim/): Till date, I have met the SQL Server Product Team twice: first time at SQL Server MVP Meet, Seattle, and second time at TechEd India 2009, Hyderabad. At both the times, I have put forth one request to the product team regarding implementing of function Trim(). As per my opinion, this is the most demanded feature of SQL Server. Almost all the programming languages have function TRIM() which removes space leading and any word that follows. However, SQL Server does not have TRIM() function. It has LTRIM() and RTRIM() functions, which when combined together LTRIM(RTRIM()) works like the expected TRIM() function... - [SQLAuthority News - Summary of TechEd India 2009 - A Grand Event](https://blog.sqlauthority.com/2009/06/02/sqlauthority-news-summary-of-teched-india-2009-a-grand-event/): TechEd India 2009 was undeniably a magnificent success! The 3-day grand event was adorned by delegates, sponsors, partners, customers, media as well as celebrities from cross the world. The event was marked by the CEO of Microsoft Steve Ballmer‘s keynote, Academy Award Winner Film Sound Designer of Slumdog Millioner Resool Pookutt‘s talk, not to forget the numerous technical sessions, Community Lounge, Partner Stalls, Demo Extravaganza, and the gaming zone. TechEd India 2009 was one event where community involvement was at its zenith. Organizations such as INETA APAC, Culminis, PASS and Microsoft India came together to bring all user group leaders together... - [SQL SERVER - List All Objects Created on All Filegroups in Database](https://blog.sqlauthority.com/2009/06/01/sql-server-list-all-objects-created-on-all-filegroups-in-database/): When I pen down any article I always keep my readers in my mind. With every topic of SQL server I cover, I try to bring readers closer to this technology. So, whenever I receive follow up questions from my readers I am exhilarated! Sometime back I had covered a topic – SQL SERVER – Create Multiple Filegroup For Single Database, for which I received a number of follow up questions. In this post I would like to discuss on a question from one of the readers Joginder “Jogi” Padiyala. “How can I find which object belongs to which filegroup. Is... - [SQL SERVER - Create Multiple Filegroup For Single Database](https://blog.sqlauthority.com/2009/05/31/sql-server-create-multiple-filegroup-for-single-database/): I am elated to receive hundreds of emails every day from my readers. My tight work schedule refrains me from answering all your questions, but I do try my best to entertain them whenever I can. Today’s post revolves around a question I received a number of times last year but never blogged on it. On positive side, you are reading about that interesting subject today. The question is – How to create multiple filegroup for any database? To find solution to this query, we will go through the following four cases. 1) Creating New Database a) Using T-SQL b) Using... - [SQL SERVER - Difference Between Candidate Keys and Primary Key](https://blog.sqlauthority.com/2009/05/30/sql-server-difference-between-candidate-keys-and-primary-key/): Let us first try to grasp the definition of the two keys. Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key. One needs to be very careful in selecting the Primary Key as an incorrect selection can adversely impact the database architect and... - [SQLAuthority News - Blog Makeover - New Banner - New Color](https://blog.sqlauthority.com/2009/05/29/sqlauthority-news-blog-makeover-new-banner-new-color/): Just a month back I had previously changed my personal homepage and had requested for feedback from my readers here SQLAuthority News – Authors Website Redesigned – https://www.pinaldave.com/ – Feedback Requested. To my astonishment, I received a huge number of emails. But I received only one comment. This time, I would like to request my readers to leave your comments on my blog instead of emailing it to me. This will allow everyone to know about others feedbacks and the actions I take towards incorporating the feedbacks on my blog and a new banner. - [SQL SERVER - Fix : Error : SQLDUMPER library failed initialization. Your installation is either corrupt or has been tampered with. Please uninstall then re-run setup to correct to correct this problem. in a modal dialog with the title SQL Writer](https://blog.sqlauthority.com/2009/05/28/sql-server-fix-error-sqldumper-library-failed-initialization-your-installation-is-either-corrupt-or-has-been-tampered-with-please-uninstall-then-re-run-setup-to-correct-to-correct-this-problem/): I often receive emails from reader requesting solution to following error: “SQLDUMPER library failed initialization. Your installation is either corrupt or has been tampered with. Please uninstall then re-run setup to correct to correct this problem.” in a modal dialog with the title “SQL Writer” While searching online there are so many different solution and many time the solution is to reinstall SQL Server. There is no need to reinstall SQL Server or do any complex process. It is very simple to fix this issue. Fix/Workaround/Solution: Go to Add/Remove Program in windows Control Panel Remove “microsoft SQL server vss writer” program... - [SQL SERVER - Interesting Observation of Logon Trigger On All Servers](https://blog.sqlauthority.com/2009/05/27/sql-server-interesting-observation-of-logon-trigger-on-all-servers/): I was recently working on security auditing for one of my clients. In this project, there was a requirement that all successful logins in the servers should be recorded. The solution for this requirement is a breeze! Just create logon triggers. I created logon trigger on server to catch all successful windows authentication as well SQL authenticated solutions. When I was done with this project, I made an interesting observation of executing a logon trigger multiple times. It was absolutely unexpected for me! As I was logging only once, naturally, I was expecting the entry only once. However, it did it multiple times on different threads – indeed an eccentric phenomenon at first sight! - [SQL SERVER - Find Hostname and Current Logged In User Name](https://blog.sqlauthority.com/2009/05/26/sql-server-find-hostname-and-current-logged-in-user-name/): I work in an environment wherein I connect to multiple servers across the world. Time and again, my SSMS is connected to a myriad of servers that kindles a lot of confusion. I frequently use the following trick to separate different connections, which I mentioned in my blog sometime back SQL SERVER – 2008 – Change Color of Status Bar of SSMS Query Editor. However, this trick does not help when a huge number of different connections are open. In such a case, I use the following handy script. Do not go by the length of the script; it might be... - [SQLAuthority News - Download Microsoft SQL Server 2008 Books Online (May 2009)](https://blog.sqlauthority.com/2009/05/25/sqlauthority-news-download-microsoft-sql-server-2008-books-online-may-2009/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - Introduction to Business Intelligence - Important Terms and Definitions](https://blog.sqlauthority.com/2009/05/24/sql-server-introduction-to-business-intelligence-important-terms-and-definitions/): What is Business Intelligence Business intelligence (BI) is a broad category of application programs and technologies for gathering, storing, analyzing, and providing access to data from various data sources, thus providing enterprise users with reliable and timely information and analysis for improved decision making. To put it simply, BI is an umbrella term that refers to an assortment of software applications for analyzing an organization’s raw data for intelligent decision making for business success. BI as a discipline includes a number of related activities, including decision support, data mining, online analytical processing (OLAP), querying and reporting, statistical analysis and forecasting. 1... - [SQLAuthority News - SQL Server Energy Event with Rushabh Mehta - May 20, 2009](https://blog.sqlauthority.com/2009/05/23/sqlauthority-news-sql-server-energy-event-with-rushabh-mehta-may-20-2009/): The much-awaited SQL Server Energy Event was successfully held on May 20, 2009 in Ahmedabad. It was jointly organized by Gandhinagar SQL Server User Group (President Pinal Dave – SQL MVP) and Ahmedabad SQL Server User Group (President Jacob Sebastian – SQL MVP). This vibrant event was one of the most interactive, remarkable and enriching events of this year in Ahmedabad. Several factors make this event unique. The main attraction of this outstanding event was Rushabh Mehta (SolidQ Mentor – SQL MVP), an eminent expert in the field of Business Intelligence. Technical session from a legend like Rushabh was an opportunity... - [SQLAuthority News - Download - SQL Server 2008 Developer Training Kit](https://blog.sqlauthority.com/2009/05/22/sqlauthority-news-download-sql-server-2008-developer-training-kit/): Note : Download SQL Server 2008 Developer Training Kit by Microsoft SQL Server 2008 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2005. The SQL Server 2008 Developer Training Kit will help you understand how to build web applications which deeply exploit the rich data types, programming models and new development paradigms in SQL Server 2008. The training kit is brought to you by Microsoft Developer and Platform Evangelism. - [SQL SERVER - FIX : ERROR : (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: )](https://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/): Regular readers of my blog are aware of the fact that I have written about this subject umpteen times earlier, and every time I have spoken about a new issue related to it. Few days ago, I had redone my local home network. I have LAN setup with wireless router connected with my four computers, two mobile devices, one printer and one VOIP solution. I had also formatted my primary computer and clean installed SQL Server 2008 into it. Yesterday, incidentally, I was sitting in my yard trying to connect SQL Server located in home office and suddenly I stumbled upon... - [SQL Server - Download PDF SQL Server Cheat Sheet](https://blog.sqlauthority.com/2009/05/20/sql-server-download-pdf-sql-server-cheat-sheet/): I had a gala time at TechEd India 2009 event! Meeting with great people is an experience of a lifetime. My session was well attended and well appreciated, which also gives me another reason to feel happy.  Moreover, my SQL Server Cheat Sheet gained unpredicted popularity at the event. Let me share with you all a little story behind this cheat sheet. For my personal use, I created one handy SQL Cheat Sheet, which I hang on my desk always. Even though I have a sound knowledge of SQL Syntax there are many occasions when I need to quickly refer to... - [SQLAuthority News - SQL Server Energy Event - Mark Your Calendar - May 20, 2009](https://blog.sqlauthority.com/2009/05/19/sqlauthority-news-sql-server-energy-event-mark-your-calender-may-20-2009/): I am very excited to share this news with all my readers. If you all remember I had already given a hint on my blog just two days back; I mentioned that we are going to host a grand event for Gandhinagar SQL Server User Group. In the past, Gandhinagar SQL Server User Group events have been more successful than we expected. Now, this event will grow even bigger as both Gandhinagar SQL Server User Group (President Pinal Dave – SQL MVP) and Ahmedabad SQL Server User Group (President Jacob Sebastian – SQL MVP) will come together for the event. This... - [SQL SERVER - Fix : Management Studio Error : Saving Changes in not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created](https://blog.sqlauthority.com/2009/05/18/sql-server-fix-management-studio-error-saving-changes-in-not-permitted-the-changes-you-have-made-require-the-following-tables-to-be-dropped-and-re-created-you-have-either-made-changes-to-a-tab/): Today, we will delve into a very simple issue that one of the Jr. Developers at my organization confronted. I have a preference for T-SQL. According to me, all the developers should always use T-SQL instead of Design feature of SQL Server Management Studio (SSMS). In fact, sound knowledge of T-SQL has the potential to make a huge difference in the development of the developer. One issue with using design mode of SSMS is that it sometimes adds too much overhead to the actual code and locks up the complete database. In the earlier version of SSMS, it was quite common... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting - International Speaker Visiting](https://blog.sqlauthority.com/2009/05/17/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-international-speaker-visiting/): It is my pleasure to announce Gandhinagar SQL Server User Group Meeting on May 20, 2009 Wednesday. Mark this date as we will be having international speaker Rushabh Mehta of SolidQ attending our session. Rushabh Mehta is a Mentor for Solid Quality Mentors’ global Business Intelligence division, based in USA, and is also the Managing Director for Solid Quality India Pvt. Ltd. I will have more information about his technical session, location and meeting time tomorrow. This will be once in a life time opportunity. If you are in Gujarat state, India and you do not attend this session, you will... - [SQL SERVER - How to Drop Temp Table - Check Existence of Temp Table](https://blog.sqlauthority.com/2009/05/17/sql-server-how-to-drop-temp-table-check-existence-of-temp-table/): I have received following questions numerous times: “How to check existence of Temp Table in SQL Server Database?” “How to drop Temp Table from TempDB?” “When I try to drop Temp Table I get following error. Msg 2714, Level 16, State 6, Line 4 There is already an object named ‘#temp’ in the database. How can I fix it?” “Can we have only one Temp Table or we can have multiple Temp Table?” “I have SP using Temp Table, when it will run simultaneously, will it overwrite data of temp table?” In fact I have already answer this question earlier in... - [SQLAuthority News - TechEd India 2009 - Day 3 - Product Group Meeting - Final Presentations - Meeting Friends](https://blog.sqlauthority.com/2009/05/16/sqlauthority-news-teched-india-2009-day-3-product-group-meeting-final-presentations-meeting-friends/): TechEd India 2009 has ended today and I’ve already started missing it! This three-day event was one of the best events of this year so far. I got the platform to meet best of the best people in the industry today. If I have to rate my days at TechEd I will assign the highest rating to day 3 as it was the most significant day. However, in today’s article I will not be writing in detail about the last day because most of the things that I want to discuss have been covered by NDA. Besides, I learnt some vital... - [SQLAuthority News - TechEd India 2009 - Day 2 - In-Person Meeting with Industry Leaders - Community Party](https://blog.sqlauthority.com/2009/05/15/sqlauthority-news-teched-india-2009-day-2-in-person-meeting-with-industry-leaders-community-party/): Action-packed day 2 of TechEd India is over, and I feel that today was even better day than day 1. So many things were going on simultaneously and keeping track of them is a hard task. Even today I got the chance to meet some renowned industry leaders. Apart from having real time conversation with Industry Leaders, I had a great time attending the various Tech Sessions. Highlight of the day was Vinod Kumar’s session on “Reducing the size of your database using Data Compression/Binary Compression in SQL Server 2008“. Vinod commenced this session by bringing forth some causal questions to... - [SQLAuthority News - TechEd India 2009 - Day 1 - Authors Tech Session - SQL Server Cheat Sheet - Meeting Great People](https://blog.sqlauthority.com/2009/05/14/sqlauthority-news-teched-india-2009-day-1-authors-tech-session-sql-server-cheat-sheet-meeting-great-people/): First day of TechEd India 2009 is over and when I recall the day I can say that it was truly a blast! This immensely huge and grand event was conducted successfully. I am having a tough time trying to recapitulate the first day as there were several different activities worth covering. Let me start with the three most important events of day. Steve Ballmer – Microsoft CEO – was the Keynote speaker at TechEd India. He is really an enthusiastic person. As soon as he showed up on stage, the entire auditorium was charged with energy. People were extremely keen... - [SQLAuthority News - TechEd India 2009 - Day 0 - Day 1 - Authors Tech Session - SQL Server Cheat Sheet - Catch Me Live](https://blog.sqlauthority.com/2009/05/13/sqlauthority-news-teched-india-2009-day-0-day-1-authors-tech-session-sql-server-cheat-sheet-catch-me-live/): Presently, I am at TechEd India 2009 in Hyderabad as one of the participants of this prestigious event. I will be heading a session on SQL Server Management Studio 2008 New Features. I had recently blogged about TechEd 2009 India here. Excerpt from the previous article “Tech.Ed-India is a great opportunity to gear yourself up to keep pace with the latest technology innovations and trends.  This event offers you the platform to get comprehensive hands-on-training and free certifications in some of the most sought after technologies of today. In fact, it is a must-attend event for all developers and IT Professionals.”... - [SQLAuthority News - Release of SQL Server 2008 R2 Announced](https://blog.sqlauthority.com/2009/05/12/sqlauthority-news-release-of-sql-server-2008-r2-announced/): SQL Server 2008 R2 expands on the value delivered in SQL Server 2008 by providinga wealth of new features and capabilities that can benefit your entire organization. This release will further improve IT Efficiency with new and enhanced management capabilities and empower business users to access, integrate, analyze and share information using business intelligence tools they already know. Capitalize on Hardware Innovation Optimize Hardware Resources Manage Efficiently at Scale Enhance Collaboration Across Development and IT Improve the Quality of Your Data Manage User-Generated Analytical Applications Report with Ease Get More Out of Your Data Build Robust Analytical Applications Consolidate Your Data... - [SQL SERVER - How to Drop Primary Key Contraint ](https://blog.sqlauthority.com/2009/05/12/sql-server-how-to-drop-primary-key-contraint/): One area that always, unfailingly pulls my interest is SQL Server Errors and their solution. I enjoy the challenging task of passing through the maze of error to find a way out with a perfect solution. However, when I received the following error from one of my regular readers, I was a little stumped at first! After some online probing, I figured out that it was actually syntax from MySql and not SQL Server. The reader encountered error when he ran the following query. ALTER TABLE Table1 DROP PRIMARY KEY GO Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword... - [SQL SERVER - Questions and Answers with Database Administrators](https://blog.sqlauthority.com/2009/05/11/sql-server-questions-and-answers-with-database-administrators/): I have been in India for long time now, and at present, I am managing a very large outsourcing project. Recently, we conducted few interviews since the project required more Database Administrators and Senior Developers, and I must say it was an enthralling experience for me! I got the opportunity to meet some very talented and competent programmers from all over the country. Scores of interesting questions were discussed between the interviewers and the candidates, which made the whole interview process nothing short of an enriching occasion! I am listing some of the interesting questions discussed during the interviews. Some are... - [SQL SERVER - 10 Reasons for Database Outsourcing](https://blog.sqlauthority.com/2009/05/10/sql-server-10-reasons-for-database-outsourcing/): 10 Reasons for Database Outsourcing While you may feel that your IT material is safe and handled effectively within your own company, these reasons may give you some perspective on why you may want to consider other options. Cost Reduction – Perhaps the most popular reason to outsource your database is the overall reduction in cost that would benefit your company.  No longer do you have to pay people to check up and maintain your servers, verify that they have uninterrupted power supplies, and ensure their security from hackers.  By going with an IT company that does this exclusively, you can... - [SQL SERVER - Find Table in Every Database of SQL Server - Part 2 Extension](https://blog.sqlauthority.com/2008/05/05/sql-server-find-table-every-database-sql-server-part-2-extension/): Long time blog reader and SQL Server Expert Simon Worth has suggested two additional method to achieve same results as described in article SQL SERVER – Find Table in Every Database of SQL Server. Method 1 sp_msforeachdb "SELECT '?' DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE '%address%'" Method 2 CREATE TABLE #TableNameResults (DatabaseName VARCHAR(100) NOT NULL, TableName VARCHAR(100) NOT NULL) INSERT INTO #TableNameResults EXEC sp_msforeachdb "SELECT '?' DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE '%address%'" SELECT * FROM #TableNameResults DROP TABLE #TableNameResults Reference : Pinal Dave (https://blog.sqlauthority.com), Simon Worth - [SQL SERVER - 2000 - SQL SERVER - Delete Duplicate Records - Rows - Readers Contribution](https://blog.sqlauthority.com/2008/05/04/sql-server-2000-sql-server-delete-duplicate-records-rows-readers-contribution/): I am proud on readers of this blog. One of the reader asked asked question on article SQL SERVER – Delete Duplicate Records – Rows and another reader followed up with nice quick answer. Let us read them both together. - [SQL SERVER 2005 - Vista Ultimate and SQL Server 2005 DEV Edition](https://blog.sqlauthority.com/2008/05/03/sql-server-2005-vista-ultimate-and-sql-server-2005-dev-edition/): I have been asked many times before “Does SQL Server Dev edition can be installed on Vista operating system?” I decided to find out the answer of this myself. I have just got new system which has Vista Ultimate Installed on it. I installed SQL Server 2005 dev edition on it. While installing it suggested that there are few component will not work with Vista and to make them work make sure to install SQL Server 2005 SP2. I was any way planning to install that. Once installation of SQL Server 2005 over, I installed SQL Server 2005 SP2. After restart... - [SQL SERVER - How to Rename Database Objects to Comply With Naming Conventions](https://blog.sqlauthority.com/2008/05/02/sql-server-how-to-rename-database-objects-to-comply-with-naming-conventions/): Christopher Miller read article of SQL SERVER Database Coding Standards and Guidelines Complete List Download and came up with wonderful SQL Server Script to rename all their database constraint with more organized constraint names, which helps to easily identify the constraint database exist on. Christopher Miller – “When we submit our schema updates internally, we usually catch any deviation from our naming conventions.  It’s not a perfect process and every now and then, something slips through the cracks.  We then correct the schema update to use the appropriate naming convention.  if we have been using the schema changes internally, we may... - [SQLAuthority News - Write for SQLAuthority](https://blog.sqlauthority.com/2008/05/01/sqlauthority-news-write-for-sqlauthority/): I always enjoy writing for my readers. Many times, I receive very good note, comments or article from my great experts of SQL Server. I really enjoy learning from my reader. If you are reader of SQLAuthority and you think you have knowledge, script or concept which benefit other readers of this blog, please feel free to send that to me. I love sharing good article and knowledge with my readers. You do not have to be well known to write article, just something which can interest other fellow readers like you, will be good article for this blog. It will... - [SQL SERVER - Find Table in Every Database of SQL Server - Part 2](https://blog.sqlauthority.com/2008/04/30/sql-server-find-table-in-every-database-of-sql-server-part-2/): Yesterday I wrote about SQL SERVER – Find Table in Every Database of SQL Server. Today we will see another method how we can achieve the same result using Information_Schema view. Refer my previous article here for additional information. CREATE PROCEDURE usp_FindTableNameInAllDatabase @TableName VARCHAR(256) AS DECLARE @DBName VARCHAR(256) DECLARE @varSQL VARCHAR(512) DECLARE @getDBName CURSOR SET @getDBName = CURSOR FOR SELECT name FROM sys.databases CREATE TABLE #TmpTable (TABLE_CATALOG VARCHAR(128), TABLE_SCHEMA VARCHAR(128), TABLE_NAME VARCHAR(256), TABLE_TYPE VARCHAR(10)) OPEN @getDBName FETCH NEXT FROM @getDBName INTO @DBName WHILE @@FETCH_STATUS = 0 BEGIN SET @varSQL = 'USE ' + @DBName + '; INSERT INTO #TmpTable SELECT *... - [SQL SERVER - Find Table in Every Database of SQL Server](https://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/): Just a day ago, one of the Jr. Developer requested that if I can help her with finding one particular table in every database on SQL Server. We have many Database Server and on some of the Database Server we have nearly 200 databases on it. The requirement was to find out one particular table from all the database. This was not possible by visual inspection as it might take lots of time and human error was possible. She was aware of the system view sys.tables. SELECT * FROM sys.Tables WHERE name LIKE '%Address%' The limitation of query mentioned above is... - [SQL SERVER - Download FAQ Sheet - SQL Server in One Page](https://blog.sqlauthority.com/2008/04/28/sql-server-download-faq-sheet-sql-server-in-one-page/): One of the most popular request I have received on this blog is to create one page which list all the SQL Server FAQs. SQL Server technology is very broad as well very deep. This is my humble attempt to list few of the daily used details in one page. Let me know your opinion and suggestion. Download SQL Server FAQ Sheet in PDF format Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query Analyzer Shortcuts - Part 2](https://blog.sqlauthority.com/2008/04/27/sql-server-query-analyzer-shortcuts-part-2/): I enjoy reader’s articles to read as much as I enjoy expert’s articles. One of blog reader Praveen Barath always have good ideas to share. Here is Praveen Barath’s comment on my previous article Query Analyzer Shortcuts. MSSQL server 2005 is a database platform , Platform because from one window you can connect to any of MSSQL services like SSMS, SSRS,SSIS,SSAS..etc. I am coming to your doubt why they shifted to SSMS as it s far slow. As the matter of fact MSSQL 2005 is more graphical more user friendly and handy tool, I hope once you will aware of all... - [SQL SERVER - Optimization Rules of Thumb - Best Practices - Reader's Article](https://blog.sqlauthority.com/2008/04/26/sql-server-optimization-rules-of-thumb-best-practices-readers-article/): This article has been written by blog reader and SQL Server Expert Praveen Barath in response to my previous article SQL SERVER – Optimization Rules of Thumb – Best Practices. Well Query Optimizations rules are not limited. It depends on business needs as well, For example we always suggest to have a relationship between tables but if they are heavily used for Update insert delete, I personally don’t recommended coz it will effect performance as I mentioned it all depends on Business needs; Here are few more tips I hope will help you to understand. One: only “tune” SQL after code... - [SQL SERVER - Optimization Rules of Thumb - Best Practices](https://blog.sqlauthority.com/2008/04/25/sql-server-optimization-rules-of-thumb-best-practices/): There are few rules for optimizing slow running query. Let us look at them one by one see how it can help. Rule # 1 : Always look at query plan first. I always start looking at query plan. There is always something which catches eyes. I pay special attention to part which has taken the most expensive part of whole execution plan. Rule # 2 : Table scan or clustered index scan needs to be optimized to table seek (if your table is small it does not matter and table scan gives you better result). Table scan happens when index... - [SQLAuthority News - Authors Personal Bookmarks](https://blog.sqlauthority.com/2008/04/25/sqlauthority-news-authors-personal-bookmarks/): Just like everybody else I also keep my personal bookmarks of websites. Recently I have reorganized my bookmarks in two categories. Please visit them and let me know your opinion. SQLAuthority BEST Articles SQLAuthority FAVORITE Articles Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Microsoft Office Visio 2007 Professional SQL Server Add-In](https://blog.sqlauthority.com/2008/04/24/sqlauthority-news-download-microsoft-office-visio-2007-professional-sql-server-add-in/): Note : Download Microsoft Office Visio 2007 Professional SQL Server Add-In by Microsoft Visio Infrastructure for SQL Servers is a tool which is meant for IT administrators who require constant interactions with the users for the installations of the SQL server in any IT infrastructure. Visio Infrastructure for SQL Servers is a tool which is meant for IT administrators who require constant interactions with the users for the installations of the SQL server in any IT infrastructure. This tool eases the constant communication between the end user and the administrator where administrators will have a ready to install visual representation of... - [SQL SERVER - Converting Subqueries to Joins](https://blog.sqlauthority.com/2008/04/23/sql-server-converting-subqueries-to-joins/): There is always more than one way to do one thing in any programming languages. In SQL Server there is always more than one way to achieve same result set. It is quite often I see that developers write subqueries in place of joins or joins in place subqueries. - [SQL SERVER - Join Better Performance - LEFT JOIN or NOT IN?](https://blog.sqlauthority.com/2008/04/22/sql-server-better-performance-left-join-or-not-in/): First of all answer this question : Which method of T-SQL is better for performance LEFT JOIN or NOT IN when writing a query? The answer is: It depends! It all depends on what kind of data is and what kind query it is etc. In that case just for fun guess one option LEFT JOIN or NOT IN. If you need to refer the query which demonstrates the mentioned clauses, review following two queries for Join Better Performance. - [SQL SERVER - 2008 - Update Resolving Conflict Between SQL Server 2005 and SQL Server 2008](https://blog.sqlauthority.com/2008/04/21/sql-server-2008-update-resolving-conflict-between-sql-server-2005-and-sql-server-2008/): I have been receiving many complains where user has installed SQL Server 2008 and when trying to install SQL Server 2005 after that installation never completed. Well, Microsoft has provided solution for this issue. Download the patch and install it first and then try to install SQL Server 2005 and it should install fine. Update for Windows Server 2008 for Itanium-based Systems (KB950636) Install this update to resolve an issue where SQL Server 2005 installation is not completed successfully on a system running Windows Server 2008. Update for Windows Server 2008 x64 Edition (KB950636) Install this update to resolve an issue... - [SQL SERVER - Identifiers As Valid Object Names](https://blog.sqlauthority.com/2008/04/20/sql-server-identifiers-as-valid-object-names/): Previous I wrote blog post about SQL SERVER – Explanation and Example Four Part Name. It was explaining the new feature of SQL Server 2005 of Schema. Few days ago I received email from Chi-Ho, Min of Taiwan, he suggested that he was successfully able to use column without completely specifying all the parts but just using servername…tablename. Please note the three dots (.) between servername and table. It was interesting what Chi-Ho observed so I decided to share with all of you. Please visit SQL SERVER – Explanation and Example Four Part Name for basic understanding of the four part... - [SQL SERVER - Is Cursor Database Object or Datatype?](https://blog.sqlauthority.com/2008/04/19/sql-server-is-cursor-database-object-or-datatype/): Whenever we want to loop something we always look for logic like WHILE LOOP or FOR LOOP. Trust me on my word that both of them are cursor when it is about SQL Server. - [SQL SERVER - Generate Foreign Key Scripts For Database](https://blog.sqlauthority.com/2008/04/18/sql-server-generate-foreign-key-scripts-for-database/): Regular reader of SQLAuthority.com blog Madhaiyan Seenivasan has send email with one very interesting script. This script generates all the foreign key addition script for your database. Many times there are situations where one need to drop all the foreign key and add them back. This SQL Script can be used for the same purpose. You can execute the SP by executing its name like EXEC DBO.SPGetForeignKeyInfo IF EXISTS ( SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[SPGetForeignKeyInfo]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) DROP PROCEDURE dbo.SPGetForeignKeyInfo GO CREATE PROCEDURE DBO.SPGetForeignKeyInfo AS /* Author : Seenivasan This procedure is used for Generating Foreign Key script. */ SET NOCOUNT ON DECLARE @FKName NVARCHAR(128) DECLARE @FKColumnName NVARCHAR(128)... - [SQLAuthority News - My Favorite Link of This Blog](https://blog.sqlauthority.com/2008/04/17/sqlauthority-news-my-favorite-link-of-this-blog/): I have written more than 500 article on this blog so far and the number is increasing. Many times I get this question, which one link do I click the most. It is very interesting for myself to read my previous articles, as I often like to read them and update it if I am missing anything or post a follow up articles or post a answer to any question in comment. There is no simple pattern for me to read my previous article. I like the random article of my blog. I use following link which send me to random... - [SQL SERVER - 2008 - Row Constructors - Load Temp Tables From Stored Procedures](https://blog.sqlauthority.com/2008/04/16/sql-server-2008-row-constructors-load-temp-tables-from-stored-procedures/): While playing with SQL Server 2008 I found new feature of “Row Constructors”, where I can load temp table from stored procedure directly. Look at the following SQL where I have to use OpenQuery from server to itself creating loopback server and execute stored procedure and insert into temp table. INSERT INTO #TempTable SELECT * FROM OPENQUERY(ServerName, 'exec StoredProc') Above mentioned same query can be now written with simpler statement as described here. INSERT INTO #TempTable EXEC StoredProc Note that this does not work with real tables or any other objects. This feature is only available to load temp tables. Reference... - [SQL SERVER - Surface Area Configuration Tools Reduce Exposure To Security Risks](https://blog.sqlauthority.com/2008/04/15/sql-server-surface-area-configuration-tools-reduce-exposure-to-security-risks/): Read my article published at SQL Server Magazine Surface Area Configuration Tools Reduce Exposure To Security Risks [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Slammer (Computer Worm)](https://blog.sqlauthority.com/2008/04/14/sql-server-sql-slammer-computer-worm/): Just a day ago, while talking with my outsourcing team one of the DBA asked me question. Is there any virus associated with SQL Server? I really find this question very interesting as I did not know if there are any viruses associated with SQL Server. I searched Google for this answer and I found link on wikipedia about SQL slammer, which is computer worm. Following excerpt is taken from wikipedia : The SQL slammer worm is a computer worm that caused a denial of service on some Internet hosts and dramatically slowed down general Internet traffic, starting at 05:30 UTC... - [SQL SERVER - 2008 - Important Resources](https://blog.sqlauthority.com/2008/04/13/sql-server-2008-important-resources/): In one of the recent public speaking event I was asked if I can list some important resources of SQL Server 2008. I promised that I will post the links on my blog. Here are Important Resources for SQL Server 2008. Learn more about data programmability http://www.microsoft.com/sql/2008/technologies/dataprogrammability.mspx Learn more about spatial data http://www.microsoft.com/sql/2008/technologies/spatial.mspx Learn more about SQL Server 2008 http://www.microsoft.com/sql/2008/default.mspx Discover SQL Server 2008: Webcasts, Virtual Labs, and White Papers http://www.microsoft.com/sql/2008/learning/default.mspx SQL Server 2008 training http://www.microsoft.com/learning/sql/2008/default.mspx Download latest SQL Server CTP http://www.microsoft.com/sql/2008/prodinfo/download.mspx Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Download Presentation and Whitepapers](https://blog.sqlauthority.com/2008/04/12/sql-server-2008-download-presentation-and-whitepapers/): SQL Server 2008 Manageability Learn about the new manageability improvements in SQL server 2008 that enables you to administer, monitor and maintain your data platform infrastructure while reducing the time and cost of management. This session provides an overview of the new manageability improvements that enables you to manage the infrastructure with policies, monitor and optimize your platform with insights and relevant information and scale your management across multiple servers. SQL Server 2008 Business Intelligence platform Learn how the new enhancements in SQL server 2008 provide a comprehensive and scalable Business Intelligence platform that enables you to integrate and manage your... - [SQL SERVER - 2005 - Find Database Collation Using T-SQL and SSMS - Part 2](https://blog.sqlauthority.com/2008/04/11/sql-server-2005-find-database-collation-using-t-sql-and-ssms-part-2/): Previously I have written two different ways to find database collation SQL SERVER – 2005 – Find Database Collation Using T-SQL and SSMS. One of blog reader jwwishart has posted another method for doing the same. SELECT collation_name FROM sys.databases WHERE name = 'AdventureWorks' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Restore Database Using Corrupt Datafiles (.mdf and .ldf) - Part 2](https://blog.sqlauthority.com/2008/04/10/sql-server-2005-restore-database-using-corrupt-datafiles-mdf-and-ldf-part-2/): Blog reader Donald Crowther has posted following comment. I have not tested this solution and when I tried to test it, it did not work for me. However, I have received email from two of my Jr. DBA who have done experiment about this and they are suggesting it works. If you have tried everything and you have given up to find solution. Try following suggestion. Make sure you have taken backup of your physical file and also this exercise you do at your own risk. ALTER DATABASE test SET emergency GO ALTER DATABASE test SET single_user GO DBCC checkdb (test,... - [SQL SERVER - 2005 - Connection Strings For .NET](https://blog.sqlauthority.com/2008/04/09/sql-server-2005-connection-strings-for-net/): SQL Native Client ODBC Driver Standard security Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Uid=myUsername;Pwd=myPassword; Trusted Connection Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes; Connecting to an SQL Server instance Driver={SQL Native Client};Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes; SQL Native Client OLE DB Provider Standard security Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase; Uid=myUsername;Pwd=myPassword; Trusted connection Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes; Connecting to an SQL Server instance Provider=SQLNCLI;Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes; SqlConnection (.NET) Standard Security Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; Trusted Connection Server=myServerAddress;Database=myDataBase;Trusted_Connection=True; Connecting to an SQL Server instance Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=True; Connecting to an SQL Server instance via an IP address Data Source=192.168.1.100,1433;Network Library=DBMSSOCN; Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword; Reference : Pinal Dave (https://blog.sqlauthority.com), ConnectionStrings - [SQL SERVER - Change Order of Column In Database Tables](https://blog.sqlauthority.com/2008/04/08/sql-server-change-order-of-column-in-database-tables/): One question I received quite often. How to change the order of the column in database table? It happens many times table with few columns is already created. After a while there is need to add new column to the previously existing table. Sometime it makes sense to add new column in middle of columns at specific places. There is no direct way to do this in SQL Server currently. Many users want to know if there is any workaround or solution to this situation. First of all, If there is any application which depends on the order of column it... - [SQL SERVER - 2005 - Restore Database Using Corrupt Datafiles (.mdf and .ldf)](https://blog.sqlauthority.com/2008/04/07/sql-server-2005-restore-database-using-corrupt-datafiles-mdf-and-ldf/): Just received question from one of the DBA Question: I do not have full backup of my database. My .mdf and .ldf are corrupted. Is there any way I can restore database now? Answer: Sorry. I do not think there is any way you can do it. Try attaching this files to database using db_attach but if that does not work, it will be very difficult make it work. If any of blog reader know fix for this, please post here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 15 Best Practices for Better Database Performance](https://blog.sqlauthority.com/2008/04/06/sql-server-15-best-practices-for-better-database-performance/): In this blog post we will see 15 best practices for better Database Performance. - [SQL SERVER - 2005 - Transferring Ownership of a Schema to a User](https://blog.sqlauthority.com/2008/04/05/sql-server-2005-transferring-ownership-of-a-schema-to-a-user/): One of the blog reader asked me how transfer of ownership of schema to another users. Follow the simple script and you will be able to transfer ownership of schema to another user. ALTER AUTHORIZATION ON SCHEMA::SchemaName TO UserName; GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL Server - Good Articles on Database Collation](https://blog.sqlauthority.com/2008/04/04/sql-server-good-articles-collation-databases/): I often get asked what is Database Collation in SQL Server and if there are some good articles related to Collation. Here are some articles. - [SQLAuthority News - Learn New Things - Self Criticism](https://blog.sqlauthority.com/2008/04/03/sqlauthority-news-learn-new-things-self-criticism/): I came across two interesting web pages and I really thought they had very good articles. I would like to share that with my blog readers today. I am just listing the abstract here. Please read the original articles they are much more interesting and enjoyable. Readers if you find any interesting site like this, let me know and I will write about it. 10 Ways to Learn New Things in Development 1. Read books. 2. Read Code 3. Write Code 4. Talk to other developers 5. Teach others 6. Listen to podcasts 7. Read blogs 8. Learn a new language... - [SQL SERVER - Find Nth Highest Salary of Employee - Query to Retrieve the Nth Maximum value](https://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/): This question is quite a popular question and it is interesting that I have been receiving this question every other day. I have already answer this question here. “How to find Nth Highest Salary of Employee”. Please read my article here to find Nth Highest Salary of Employee table : SQL SERVER – Query to Retrieve the Nth Maximum value I have re-wrote the same article here with example of SQL Server 2005 Database AdventureWorks : SQL SERVER – 2005 – Find Nth Highest Record from Database Table Just a day ago, I have received another script to get the same... - [SQL SERVER - Microsoft SQL Server 2000/2005 Management Pack Download](https://blog.sqlauthority.com/2008/04/01/sql-server-microsoft-sql-server-20002005-management-pack-download/): The SQL Server Management Pack monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems. Availability and performance monitoring is done using synthetic transactions. In addition, the Management Pack collects Event Log alerts and provides associated knowledge articles with additional user details, possible causes, and suggested resolutions. The Management Pack discovers Database Engines, Database Instances, and Databases and can optionally discover Database File and Database File Group objects. Feature Summary: • Active Directory Helper Service • SQL Server Agent • Backup • Databases and Tables • DBCC • Full Text Search • Log... - [SQL SERVER - Popular Articles of SQLAuthority Blog](https://blog.sqlauthority.com/2008/03/31/sql-server-popular-articles-of-sqlauthority-blog/): I receive this email quite often that which are most popular articles on my blog. There is already list on right navigation bar of my weekly popular article. If you are interested to know which are most popular articles as per readers and my opinion here are two listed. SQL SERVER Database Coding Standards and Guidelines Complete List Download SQL Server Interview Questions and Answers Complete List Download Let me know which articles is your favorite article on this blog. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Heap Structure - What is Heap?](https://blog.sqlauthority.com/2008/03/30/sql-server-introduction-to-heap-structure-what-is-heap/): Sometime simple questions are very interesting. A day ago, jr. developer asked me question : What is Heap? In SQL Server 2005 data is stored within tables. Data within a table is grouped together into allocation unites based on their column data types, what it means is one kind of data types are stored together in allocation unites. Data within this allocation unit is stored in pages. Each pages are of size 8KB. Group of 8 pages is stored together and they are referred as Extent. Pages within a table store the data rows with structure which helps to search/locate data... - [SQL SERVER - 2005 - List All Column With Identity Key In Specific Database](https://blog.sqlauthority.com/2008/03/29/sql-server-2005-list-all-column-with-indentity-key-in-specific-database/): Question I received in Email : How to list all the columns in the database which are used as identity key in my database? - [SQL SERVER - Introduction to sys.dm_exec_query_optimizer_info](https://blog.sqlauthority.com/2008/03/28/sql-server-2005-introduction-to-sysdm_exec_query_optimizer_info/): Many times when I am just bored I surf Book On Line for SQL Server 2005. Almost all the time I find something new which makes me believe that I have lot to learn and there are so many things I am not aware of. Today I found system catalog view sys.dm_exec_query_optimizer_info. I just enjoyed reading about it and now I will share this with you. - [SQL SERVER - 2005 - Find Index Fragmentation Details - Slow Index Performance](https://blog.sqlauthority.com/2008/03/27/sql-server-2005-find-index-fragmentation-details-slow-index-performance/): Just a day ago, while using one index I was not able to get the desired performance from the table where it was applied. I just looked for its fragmentation and found it was heavily fragmented. After I reorganized index it worked perfectly fine. Here is the quick script I wrote to find fragmentation of the database for all the indexes. SELECT ps.database_id, ps.OBJECT_ID, ps.index_id, b.name, ps.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps INNER JOIN sys.indexes AS b ON ps.OBJECT_ID = b.OBJECT_ID AND ps.index_id = b.index_id WHERE ps.database_id = DB_ID() ORDER BY ps.OBJECT_ID GO You can REBUILD or... - [SQLAuthority News - Few Links About SQLAuthority](https://blog.sqlauthority.com/2008/03/26/sqlauthority-news-few-links-about-sqlauthority/): I have listed few important links of SQLAuthority.com, I still receive some repeated questions. I do my best to respond to all of my readers, however, most of the time I am sending them link to one of my previously written article. Many times most of the answers can be found right away by searching in this blog. I have created special search engine, which exclusively searches in this blog. Search SQLAuthority.com – http://search.sqlauthority.com Finding good database developer job is very hard and finding good database developer is even harder. For the same reason I have attempted to created only SQL... - [SQL SERVER - Simple Puzzle Using Union and Union All - Answer](https://blog.sqlauthority.com/2008/03/25/sql-server-simple-puzzle-using-union-and-union-all-answer/): Yesterday I posted a puzzle SQL SERVER – Simple Puzzle Using Union and Union All, today we will see the answer of this. Following image explains the answer of puzzle. You can read the explanation of why this is answer read my previous article SQL SERVER – Union vs. Union All – Which is better for performance? Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Simple Puzzle Using Union and Union All](https://blog.sqlauthority.com/2008/03/24/sql-server-simple-puzzle-using-union-and-union-all/): I often get request to write puzzles using SQL Server. Today, I am presenting one very simple but very interesting puzzle. What will be the output of following two SQL Scripts. First try to answer without running this two script in Query Editor. Script 1 SELECT 1 UNION ALL (SELECT 1 UNION SELECT 2) GO Script 2 (SELECT 1 UNION ALL SELECT 1) UNION SELECT 2 GO Hint : This puzzle is based on my previous article SQL SERVER – Union vs. Union All – Which is better for performance? Answer : SQL SERVER – Simple Puzzle Using Union and Union... - [SQL SERVER - 2005 - Mechanisms to Ensure Integrity and Consistency of Databases - Locking and Row Versioning](https://blog.sqlauthority.com/2008/03/23/sql-server-2005-mechanisms-to-ensure-integrity-and-consistency-of-databases-locking-and-row-versioning/): Today I was going through Book On Line while researching something, I come across one interesting small article about two mechanisms to ensure integrity and consistency of databases – 1) Locking 2) Row Versioning Let us see their definition from Book Online Itself. Locking Each transaction requests locks of different types on the resources, such as rows, pages, or tables, on which the transaction is dependent. The locks block other transactions from modifying the resources in a way that would cause problems for the transaction requesting the lock. Each transaction frees its locks when it no longer has a dependency on... - [SQL SERVER - 2005 - Find Highest / Most Used Stored Procedure](https://blog.sqlauthority.com/2008/03/22/sql-server-2005-find-highest-most-used-stored-procedure/): How many times we all DBA’s might have wonder which stored procedure is executing most in the database? I have wondered it often and I have written following small script which gives me answer to my above questions. I am also retrieving few additional data along with the highest used SP names. You can change the name of the database from AdventureWorks to any database which you are curious about. If WHERE clause is completely removed it will give results for all the database. SELECT TOP 10 qt.TEXT AS 'SP Name', qs.execution_count AS 'Execution Count', qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime', qs.total_worker_time AS 'TotalWorkerTime',... - [SQL SERVER - Introduction to Live Lock - What is Live Lock?](https://blog.sqlauthority.com/2008/03/21/sql-server-introduction-to-live-lock-what-is-live-lock/): Some questions are very interesting to answer. I just received following question in Email. What is Live Lock? A Live lock is one, where a request for exclusive lock is denied continuously because a series of overlapping shared locks keeps on interfering each other and to adapt from each other they keep on changing the status which further prevents them to complete the task. In SQL Server Live Lock occurs when read transactions are applied on table which prevents write transaction to wait indefinitely. This is different then deadlock as in deadlock both the processes wait on each other. A human... - [SQLAuthority News - Book Review - Joe Celkos SQL Puzzles and Answers, Second Edition, Second Edition](https://blog.sqlauthority.com/2008/03/20/sqlauthority-news-book-review-joe-celkos-sql-puzzles-and-answers-second-edition-second-edition/): Joe Celko’s SQL Puzzles and Answers, Second Edition, Second Edition (The Morgan Kaufmann Series in Data Management Systems) (Paperback) by Joe Celko (Author) Link to Amazon Short Review: This book is for all of them who enjoy little puzzles or just something which gives them challenge. Some puzzles took hours to solve and some were straight forward. This book teaches you some basic principles and patterns as well satisfy your need for brain teasers. Detail Review: This book for all the SQL programmers regardless of database language you prefer. Book contains examples in different languages (SQL Server, Oracle, Sybase, Informix etc).... - [SQL SERVER - Add Column With Default Column Constraint to Table](https://blog.sqlauthority.com/2008/03/19/sql-server-add-column-with-default-column-constraint-to-table/): Just a day ago while working with database Jr. Developer asked me question how to add column along with column constraint. He also wanted to specify the name of the constraint. The newly added column should not allow NULL value. He requested my help as he thought he might have to write many lines to achieve what was requested. - [SQL SERVER - 2005 - Analysis Services Query Performance Top 10 Best Practices](https://blog.sqlauthority.com/2008/03/18/sql-server-2005-analysis-services-query-performance-top-10-best-practices/): Analysis Services Query Performance Top 10 Best Practices Optimize cube and measure group design Define effective aggregations Use partitions Write efficient MDX Use the query engine cache efficiently Ensure flexible aggregations are available to answer queries. Tune memory usage Tune processor usage Scale up where possible Scale out when you can no longer scale up Technet Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download White Papers - Migration from MySQL, Oracle, Sybase, or Microsoft Access to Microsoft SQL Server](https://blog.sqlauthority.com/2008/03/17/sqlauthority-news-download-white-papers-migration-from-mysql-oracle-sybase-or-microsoft-access-to-microsoft-sql-server/): Note : Download White Papers by Microsoft Guide to Migrating from MySQL to SQL Server 2005 This migration guide explains the differences between the MySQL and SQL Server 2005 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2005 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2005. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. Guide to Migrating from Sybase ASE to SQL Server 2005 This... - [SQL SERVER - 2005 - Retrieve Any User Defined Object Details Using sys objects Database](https://blog.sqlauthority.com/2008/03/16/sql-server-2005-retrieve-any-user-defined-object-details-using-sysobjects-database/): sys.objects object catalog view contains a row for each user-defined, schema-scoped object that is created within a database. You can retrieve any user defined object details by querying sys.objects database. Let us see one example of sys.objects database usage. You can run following query to retrieve all the information regarding name of foreign key, name of the table it FK belongs and the schema owner name of table. USE AdventureWorks; GO SELECT name AS ObjectName, OBJECT_NAME(schema_id) SchemaName, OBJECT_NAME(parent_object_id) ParentObjectName, name, * FROM sys.objects WHERE type = 'F' GO You can use any of the following in your WHERE clause and retrieve... - [SQL SERVER - 2005 - Retrieve Processes Using Specified Database](https://blog.sqlauthority.com/2008/03/15/sql-server-2005-retrieve-processes-using-specified-database/): Blog Reader Jim Sz posted quick but very interesting script. If user want to know how many processes are there in any particular database it can be retrieved querying sys.processes database. USE master GO DECLARE @dbid INT SELECT @dbid = dbid FROM sys.sysdatabases WHERE name = 'AdventureWorks' IF EXISTS (SELECT spid FROM sys.sysprocesses WHERE dbid = @dbid) BEGIN SELECT 'These processes are using current database' AS Note, spid, last_batch, status, hostname, loginame FROM sys.sysprocesses WHERE dbid = @dbid END GO Reference : Pinal Dave (https://blog.sqlauthority.com), Jim Sz - [SQL SERVER - 2005 - What is CLR?](https://blog.sqlauthority.com/2008/03/14/sql-server-2005-clr/): CLR is Common Language Runtime. Here is the diagram which explains the architecture of the CLR. - [SQL SERVER - FIX : Error : 3702 Cannot drop database because it is currently in use - Part 2](https://blog.sqlauthority.com/2008/03/13/sql-server-fix-error-3702-cannot-drop-database-because-it-is-currently-in-use-part-2/): Following error is very generic error and I have previously written SQL SERVER – FIX : Error : 3702 Cannot drop database because it is currently in use. Msg 3702, Level 16, State 3, Line 2 Cannot drop database “DataBaseName” because it is currently in use. One of the reader Dave have posted additional information in comments. I will list his advise here. First read the original post here. If you are still getting the error after you try using USE master GO DROP DATABASE (databaseName) GO Close SQL Server Management Studio completely. Open it again and connect as normal. Now... - [SQL SERVER - 2005 - Find Nth Highest Record from Database Table - Using Ranking Function ROW_NUMBER](https://blog.sqlauthority.com/2008/03/12/sql-server-2005-find-nth-highest-record-from-database-table-using-ranking-function-row_number/): I have previously written SQL SERVER – 2005 – Find Nth Highest Record from Database Table where I have shown query to find 4th highest record from database table. Everytime when I write blog I am always very eager to read comments of readers. Some of regular readers are industry leaders and and their comments always teach us all something new. One of them is Nicholas Paldino [.NET/C# MVP]. He has always provided valuable solution and comments to this blog. His recent comment about finding Nth Highest Record is quite an interesting. USE AdventureWorks GO SELECT t.* FROM ( SELECT e1.*,... - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - Part 3](https://blog.sqlauthority.com/2008/03/11/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql-part-3/): Please read SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL before continuing this article. I had asked users to come up with alternate solution of the same problem. Khadar Khan came up with good solution using CTE SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL – Part 2. Today we will see the solution suggested by Dave Arthur. This solution is quite good as it uses UNION ALL instead of OR clause. USE AdventureWorks GO SELECT A.* FROM ( SELECT TOP 1 * FROM Sales.SalesOrderDetail ORDER BY SalesOrderDetailID) A UNION ALL SELECT B.*... - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - Part 2 - CTE](https://blog.sqlauthority.com/2008/03/10/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql-part-2/): Please read SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL before continuing this article. I had asked users to come up with an alternate solution of the same problem. In this blog post we will see solution with the help of CTE.  - [SQLAuthority News - Authors Most Visited Article on Blog](https://blog.sqlauthority.com/2008/03/09/sqlauthority-news-authors-most-visited-article-on-blog/): I received many emails regarding SQLAuthority News – 500th Post – An Interesting Journey with SQL Server. One of the email asked interesting question regarding my most visited article on this blog. It was interesting to know that reader wants to know which article I visit the most. Following is the link to the article which I personal visit most of the time while working as Principal Database Administrator. SQL SERVER – 2005 – Search Stored Procedure Code – Search Stored Procedure Text Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Nth Highest Record from Database Table](https://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/): I had previously written SQL SERVER - Query to Retrieve the Nth Maximum value. I just received an email that if I can write this using AdventureWorks database as it is a default sample database for SQL Server 2005 and the user can run the query against it and understand it better. Let us see how we can find highest record from database. - [SQLAuthority News - 500th Post - An Interesting Journey with SQL Server](https://blog.sqlauthority.com/2008/03/07/sqlauthority-news-500th-post-an-interesting-journey-with-sql-server/): I am very pleased to write my 500th post. After 500 posts, I still have same feeling when I wrote first post on this blog. I would like to thank my family for their continuous support in writing this blog. Most of all I want to thank all of YOU for being wonderful readers of this blog, without your continuous participation and communication, this blog could not be what it is right now. THANK YOU. Some of the milestones in this wonderful Journey to SQL Authority. Search SQLAuthority Feature to search exclusively SQLAuthoritive.com. Readers can search the blog for immediate answers.... - [SQLAuthority News - SQL Server 2005 is The Data Platform Leader](https://blog.sqlauthority.com/2008/03/06/sqlauthority-news-sql-server-2005-is-the-data-platform-leader/): Questions I often get asked : How big is market for SQL Server? Is SQL Server industry leader? Does learning SQL Server technology will help future career? Why did you pick SQL Server as your expertise? I just love SQL Server. Let us read following article taken directly from Microsoft, which explains why SQL Server is Data Platform Leader. Microsoft is positioned in Leaders Quadrant for Magic Quadrant for Business Intelligence Platforms, 2008 Microsoft is positioned in Leaders Quadrant for Magic Quadrant for Data Warehouse Database Management Systems, 2007 SQL Server is the fastest growing Database and Business Intelligence vendor SQL... - [SQL SERVER - Simple Example of Cursor - Sample Cursor Part 2](https://blog.sqlauthority.com/2008/03/05/sql-server-simple-example-of-cursor-sample-cursor-part-2/): I have recently received email that I should update SQL SERVER – Simple Example of Cursor with example of AdventureWorks database. Simple Example of Cursor using AdventureWorks Database is listed here. USE AdventureWorks GO DECLARE @ProductID INT DECLARE @getProductID CURSOR SET @getProductID = CURSOR FOR SELECT ProductID FROM Production.Product OPEN @getProductID FETCH NEXT FROM @getProductID INTO @ProductID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @ProductID FETCH NEXT FROM @getProductID INTO @ProductID END CLOSE @getProductID DEALLOCATE @getProductID GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold](https://blog.sqlauthority.com/2008/03/04/sql-server-2005-a-simple-way-to-defragment-all-indexes-in-a-database-that-is-fragmented-above-a-declared-threshold/): Just a day ago, I received email from regular reader Rajiv Kayasthy about a script which demonstrates the A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold. He found this script on TechNet BOL and was attempting to run on SQL Server but was getting continuous error Msg 2501, Level 16, State 45, Line 1 Cannot find a table or object with the name “TableName”. Check the system catalog. After looking at the script provided on BOL I found that it has very small error. It was retrieving data without prefixing database schema.... - [SQL SERVER - Sharpen Your Basic SQL Server Skills - Learn the distinctions between unique constraint and primary key constraint and the easiest way to get random rows from a table](https://blog.sqlauthority.com/2008/03/03/sql-server-sharpen-your-basic-sql-server-skills-learn-the-distinctions-between-unique-constraint-and-primary-key-constraint-and-the-easiest-way-to-get-random-rows-from-a-table/): Read my article in SQL Server Magazine March 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL](https://blog.sqlauthority.com/2008/03/02/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql/): Just a day ago, while working with some inventory related projects, I faced one interesting situation. I had to find TOP 1 and BOTTOM 1 record together. I right away that I should just do UNION but then I realize that UNION will not work as it will only accept one ORDER BY clause. If you specify more than one ORDER BY clause. It will give an error. Let us see how we can retrieve top and bottom rows together. - [SQL SERVER - Transfer The Logins and The Passwords Between Instances of SQL Server 2005](https://blog.sqlauthority.com/2008/03/01/sql-server-transfer-the-logins-and-the-passwords-between-instances-of-sql-server-2005/): This question was asked to me by one of reader. “I just upgraded my server with better hardware and newer operating system. How can I transfer the logins and the passwords between two of my SQL Server?” I think Microsoft has wonderful documentation for this issue. kb 918992 I will briefly describe the solution here : Run the script in Query Editor. It will generate the script of username and password in the windows. USE master GO IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL DROP PROCEDURE sp_hexadecimal GO CREATE PROCEDURE sp_hexadecimal @binvalue varbinary(256), @hexvalue varchar(256) OUTPUT AS DECLARE @charvalue varchar(256) DECLARE @i... - [SQL SERVER - Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial](https://blog.sqlauthority.com/2008/02/29/sql-server-introduction-to-sql-server-encryption-and-symmetric-key-encryption-tutorial/): SQL Server 2005 provides encryption as a new feature to protect data against the attacks of hackers. Hackers may be able to get hold of the database or tables, but they wouldn’t understand the data or be able to use it. It is very important to encrypt crucial security related data when stored in the database, as well while transmitting across a network between the client and the server. Read my complete article here : Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Dynamic Case Statement - FIX : ERROR 156 : Incorrect syntax near the keyword](https://blog.sqlauthority.com/2008/02/28/sql-server-dynamic-case-statement-fix-error-156-incorrect-syntax-near-the-keyword/): One of my friend sent me query asking me how to generate dynamic case statements in SQL. Every time he tries to run following query he is getting Error 156 : Incorrect syntax near the keyword. He was frustrated with following two queries. There are two different ways to solve the problem when user want to Incorrect Query 1 : USE AdventureWorks GO DECLARE @OrderDirection VARCHAR(5) SET @OrderDirection = ‘DESC’ SELECT * FROM Production.WorkOrder WHERE ProductID = 722 ORDER BY OrderQty CASE WHEN @OrderDirection = ‘DESC’ THEN DESC ELSE ASC END GO ResultSet: Msg 156, Level 15, State 1, Line 8... - [SQLAuthority News - SQL Server 2008 R2 Support Ends on July 9, 2019](https://blog.sqlauthority.com/2008/02/27/sqlauthority-news-sql-server-2008-r2-support-ends-on-july-9-2019/): It is indeed true Microsoft will official support ends of the product on July 9, 2019. Comprehensive Database Performance Health Check.  - [SQL SERVER - SELECT 1 vs SELECT * - An Interesting Observation](https://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/): Many times I have seen issue of SELECT 1 vs SELECT * discussed in terms of performance or readability while checking for existence of rows in table. I ran quick 4 tests about this observed that I am getting same result when used SELECT 1 and SELECT *. I think smart readers of this blog will come up the situation when SELECT 1 and SELECT * have different execution plan when used to find existence of rows. - [SQLAuthority News - Latest SQL Server Management Studio Blogs](https://blog.sqlauthority.com/2008/02/25/sqlauthority-news-latest-sql-server-management-studio-blogs/): SQL Server Management Studio is an amazing product and I am personally a big fan of the same. Here are the few latest blog written on the same subject. - [SQL SERVER - 2005 - Licensing Model Compared to Other Database Products](https://blog.sqlauthority.com/2008/02/24/sql-server-2005-licensing-model-compared-to-other-database-products/): Yesterday on this blog I wrote about SQL SERVER – 2005 – Understanding Licensing Model. I have received many questions about pricing and comparing SQL Server with other RDBMS. One of the reason I like SQL Server because I am strong believer of licensed software usage and SQL Server is feature rich and dirt cheap compared to other comparable products. Let us review following chart and table which explains the difference. https://www.microsoft.com/en-us/sql-server/sql-server-2016 If you are interested to read about more about this you can review original article from where I have taken above information. Reference : Pinal Dave (https://blog.sqlauthority.com) , SQL... - [SQL SERVER - Understanding Licensing Models](https://blog.sqlauthority.com/2008/02/23/sql-server-understanding-licensing-models/): The licensing structure has evolved to reflect advances in technology and diverse use cases. Below are the primary licensing models available: - [SQL SERVER - Find All The User Defined Functions (UDF) - Part 2](https://blog.sqlauthority.com/2008/02/22/sql-server-find-all-the-user-defined-functions-udf-part-2/): Few days ago, I wrote about SQL SERVER – Find All The User Defined Functions (UDF) in a Database. Regular reader of this blog Madhivanan has suggested following alternate method to do the same task of finding all the user defined functions in database. USE AdventureWorks GO SELECT specific_name,specific_schema FROM information_schema.routines WHERE routine_type='function' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download SQL Server 2017](https://blog.sqlauthority.com/2008/02/21/sqlauthority-news-download-sql-server-2017/): This was a very old blog post and I have decided to re-write this as it was no longer useful. In this blog post, we will learn about SQL Server 2017. Here is how you can download SQL Server 2017 related material. - [SQLAuthority New - SQL Server 2008 Books Online CTP (February 2008)](https://blog.sqlauthority.com/2008/02/21/sqlauthority-new-sql-server-2008-books-online-ctp-february-2008/): Download a Community Technology Preview (CTP) version of the documentation and tutorials for Microsoft SQL Server 2008. SQL Server 2008 Books Online CTP (February 2008) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF to Return a Calendar for Any Date for Any Year](https://blog.sqlauthority.com/2008/02/20/sql-server-udf-to-return-a-calendar-for-any-date-for-any-year/): It gives me great pleasure to write articles like today’s one because I have received great comment from one of regular reader who has taken UDF written by me and created another UDF using that UDF which enhances functionality of it. I had written previous article about SQL SERVER – UDF – Function to Display Current Week Date and Day – Weekly Calendar. Reader of this blog and great SQL expert Dan Golden has wrote another UDF which uses UDF written by me. I thank Dan Golden for his contribution to this blog. I have modified his function a bit to... - [SQL SERVER - 2005 - FIX: Error message when you run a query against a table that does not have a clustered index in SQL Server 2005: "A severe error occurred on the current command"](https://blog.sqlauthority.com/2008/02/19/sql-server-2005-fix-error-message-when-you-run-a-query-against-a-table-that-does-not-have-a-clustered-index-in-sql-server-2005-a-severe-error-occurred-on-the-current-command/): In SQL Server 2005 while testing Indexes I had created a table with one non clustered index only. I did not create any clustered index on table. After that I ran SELECT statement, it gave me following error. I was very surprised when I looked at error. It says Msg 0, what it means is that this error is not known error to Microsoft and it might be bug. Msg 0, Level 11, State 0, Line 0 A severe error occurred on the current command. The results, if any, should be discarded. Msg 0, Level 20, State 0, Line 0 A... - [SQLAuthority News - Download SQL Server 2008 February CTP (CTP 6)](https://blog.sqlauthority.com/2008/02/18/sqlauthority-news-download-sql-server-2008-february-ctp-ctp-6/): SQL Server 2008 February CTP (CTP 6) has been released. Download from here. It will direct you to page which is dated November 2007. Continue with November 2007 which will take you to February 2008 CTP 6 Download page. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - How to Escape Single Quotes - Fix: Error: 105 Unclosed quotation mark after the character string](https://blog.sqlauthority.com/2008/02/17/sql-server-how-to-escape-single-quotes-fix-error-105-unclosed-quotation-mark-after-the-character-string/): Jr. Developer asked me other day how to escape single quote? User can escape single quote using two single quotes (NOT double quote). - [SQL SERVER - Msg: 2593 : There are ROWCOUNT rows in PAGECOUNT pages for object 'OBJECT'.](https://blog.sqlauthority.com/2008/02/16/sql-server-msg-2593-there-are-rowcount-rows-in-pagecount-pages-for-object-object/): There are ROWCOUNT rows in PAGECOUNT pages for object 'OBJECT'. This message is displayed when DBCC command is ran for any database. It is harmless and displayed for information purpose only. For each database DBCC commands displays number of rows and number of pages it is using. DBCC CHECKALLOC is exception for this messages. - [SQL SERVER - Index Reorganize or Index Rebuild](https://blog.sqlauthority.com/2008/02/15/sql-server-index-reorganize-or-index-rebuild/): Recently, I have received one question quite often about when to Index Reorganize and when to Index Rebuild. I have already written about this topic earlier but it seems that many are unable to search it. SQL SERVER – Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script If you have any question you can search exclusively SQLAuthority at http://search.SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Performance Monitor - How to Use Perfmon](https://blog.sqlauthority.com/2008/02/14/sql-server-introduction-to-performance-monitor-how-to-use-perfmon/): Yesterday I wrote about SQL SERVER – Introduction to Three Important Performance Counters. I received few questions about how to use Perfmon. Here is very brief introduction to Perfmon. There are three ways to launch Perfmon. 1) Type “start perfmon” at the command prompt. 2) Go to Start | Programs | Administrative Tools | Performance Monitor. 3) Go to Start | Run | Perfmon. Follow the images which explains how to use Perfmon and add different counters. Right click to bring up Add Counters Menu. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Three Important Performance Counters](https://blog.sqlauthority.com/2008/02/13/sql-server-introduction-to-three-important-performance-counters/): Performance Counters are very important to evaluate. There are more than thousands of Performance Counters. Today I will cover three basic but very important Performance Counters. Processor:% Processor Time It reports the total processor time with respect to the available capacity of the server. If counter is between 50 to 70 % consistently, investigate the process which is taking long time. PhysicalDisk:Avg.Disk Queue Length It indicates wait time for processes to use disk resources. As a disk is reading and writing data some requests cannot be immediately filled, those requests are queued. If many simultaneous requests are waiting, investigate the process... - [SQL SERVER - Get Current Database Name](https://blog.sqlauthority.com/2008/02/12/sql-server-get-current-database-name/): Yesterday while I was writing script for SQL SERVER – 2005 – Find Unused Indexes of Current Database . I realized that I needed SELECT statement where I get the name of the current Database. It was very simple script. SELECT DB_NAME() AS DataBaseName It will give you the name the database you are running using while running the query. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Find Unused Indexes of Current Database](https://blog.sqlauthority.com/2008/02/11/sql-server-2005-find-unused-indexes-of-current-database/): Simple but accurate following script will give you list of all the indexes in the database which are unused. If indexes are not used they should be dropped as Indexes reduces the performance for INSERT/UPDATE statement. Indexes are only useful when used with SELECT statement. Script to find unused Indexes. USE AdventureWorks GO DECLARE @dbid INT SELECT @dbid = DB_ID(DB_NAME()) SELECT OBJECTNAME = OBJECT_NAME(I.OBJECT_ID), INDEXNAME = I.NAME, I.INDEX_ID FROM SYS.INDEXES I JOIN SYS.OBJECTS O ON I.OBJECT_ID = O.OBJECT_ID WHERE OBJECTPROPERTY(O.OBJECT_ID,'IsUserTable') = 1 AND I.INDEX_ID NOT IN ( SELECT S.INDEX_ID FROM SYS.DM_DB_INDEX_USAGE_STATS S WHERE S.OBJECT_ID = I.OBJECT_ID AND I.INDEX_ID = S.INDEX_ID AND DATABASE_ID = @dbid)... - [SQLAuthority News - RIP: Ken Henderson, 1967 - 2008](https://blog.sqlauthority.com/2008/02/10/sqlauthority-news-rip-ken-henderson-1967-2008/): Ken Henderson, a nationally recognized consultant and leading DBMS practitioner, consults on high-end client/server projects away on Sunday, January 27, in Meeker, Oklahoma. Ken was an inspirational author of the SQL Server Guru’s Guide series of books. We will miss his forever. He was the author I respected the most. I have reviewed his book SQLAuthority News – Book Review – SQL Server 2005 Practical Troubleshooting: The Database Engine earlier on this blog. That was one great book. You can read sample chapter from that book here. Download Sample Chapter of SQL Server 2005 Practical Troubleshooting: The Database Engine. Let us... - [SQLAuthority News - 2008 - Download - SQL Server 2008 Brochure](https://blog.sqlauthority.com/2008/02/09/sqlauthority-news-2008-download-sql-server-2008-brochure/): SQL Server 2008 Brochure is available to download. It contains many information like available Server Editions, Top New Features, New Available Technologies and additional resources. - [SQL SERVER - Microsoft SQL Server Compact 3.5 SP1 Beta for ADO.Net Entity Framework Beta 3](https://blog.sqlauthority.com/2008/02/08/sql-server-microsoft-sql-server-compact-35-sp1-beta-for-adonet-entity-framework-beta-3/): SQL Server Compact 3.5 SP1 Beta release for the ADO.Net Entity Framework Beta 3 enables the following scenarios: Applications can work in terms of a more application-centric conceptual model, including types with inheritance, complex members, and relationships Applications are freed from hard-coded dependencies on a particular data engine or storage schema Mappings between the conceptual application model and the storage-specific schema can change without changing the application code Developers can work with a consistent application object model that can be mapped to various storage schemas, possibly implemented in different database management systems Multiple application models can be mapped to a single... - [SQL SERVER - Sharpen Your Basic SQL Server Skills - Database backup demystified](https://blog.sqlauthority.com/2008/02/07/sql-server-sharpen-your-basic-sql-server-skills-database-backup-demystified/): Read my article in SQL Server Magazine January 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Import CSV File Into SQL Server Using Bulk Insert - Load Comma Delimited File Into SQL Server](https://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/): This is a very common request recently – How to import CSV file into SQL Server? How to load CSV file into SQL Server Database Table? How to load comma delimited file into SQL Server? Let us see the solution in quick steps. CSV stands for Comma Separated Values, sometimes also called Comma Delimited Values. Create TestTable USE TestData GO CREATE TABLE CSVTest (ID INT, FirstName VARCHAR(40), LastName VARCHAR(40), BirthDate SMALLDATETIME) GO Create CSV file in drive C: with name sweetest. text with the following content. The location of the file is C:\csvtest.txt 1,James,Smith,19750101 2,Meggie,Smith,19790122 3,Robert,Smith,20071101 4,Alex,Smith,20040202 Now run following script to load... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Funny Microsoft Quotes](https://blog.sqlauthority.com/2008/02/05/sqlauthority-news-sql-joke-sql-humor-sql-laugh-funny-microsoft-quotes/): I have received many emails that I should write more post like SQLAuthority News – SQL Joke, SQL Humor, SQL Laugh – Funny Quotes. - [SQL SERVER - Simple Example of WHILE Loop with BREAK and CONTINUE](https://blog.sqlauthority.com/2008/02/04/sql-server-simple-example-of-while-loop-with-break-and-continue/): WHILE statement sets a condition for the repeated execution of an SQL statement or statement block. Following is very simple example of WHILE Loop with BREAK and CONTINUE. USE AdventureWorks; GO DECLARE @Flag INT SET @Flag = 1 WHILE (@Flag < 10) BEGIN BEGIN PRINT @Flag SET @Flag = @Flag + 1 END IF(@Flag > 5) BREAK ELSE CONTINUE END WHILE loop can use SELECT queries as well. You can find following example of BOL very useful. USE AdventureWorks; GO WHILE ( SELECT AVG(ListPrice) FROM Production.Product) < $300 BEGIN UPDATE Production.Product SET ListPrice = ListPrice * 2 SELECT MAX(ListPrice) FROM Production.Product... - [SQL SERVER - FIX : ERROR : Cannot find template file for new query (C:\Program Files\Microsoft SQL Server\90\Tools\ Binn\VSShell\Common7\ IDE\sqlworkbenchprojectitems\Sql\ SQLFile.sql)](https://blog.sqlauthority.com/2008/02/03/sql-server-fix-error-cannot-find-template-file-for-new-query-cprogram-filesmicrosoft-sql-server90toolsbinnvsshellcommon7idesqlworkbenchprojectitemssqlsqlfilesql/): Just a day ago while playing with SQL Server I suddenly faced a new kind of error, which I have never seen before. This error happens when clicked on New Query in SQL Server Management Studio. Let us learn in this blog post how we will fix the error - cannot find template file for a new query.  - [SQL SERVER - Find All The User Defined Functions (UDF) in a Database](https://blog.sqlauthority.com/2008/02/02/sql-server-find-all-the-user-defined-functions-udf-in-a-database/): Following script is very simple script which returns all the User Defined Functions for particular database. USE AdventureWorks; GO SELECT name AS function_name ,SCHEMA_NAME(schema_id) AS schema_name ,type_desc FROM sys.objects WHERE type_desc LIKE '%FUNCTION%'; GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Great Job with Great Pay](https://blog.sqlauthority.com/2008/02/01/sql-server-find-great-job-with-great-pay/): One question I have been asked consistently “Where can I find Great Job with Great Pay related to SQL Server?”. I have been aware of the fact that there are many jobs in market but finding one job which gives satisfaction in job as well has great salary are few. All the great places are usually taken by best employees and they do not change their job. Due to the same reason, I have created job board where companies can list their jobs as well all good candidate can find best job according to their requirement. Find Great Job with Great... - [SQL SERVER - Top 10 Best Practices for SQL Server Maintenance for SAP](https://blog.sqlauthority.com/2008/01/31/sql-server-top-10-best-practices-for-sql-server-maintenance-for-sap/): Top 10 Best Practices for SQL Server Maintenance for SAP By Takayuki Hoshino SQL Server provides an excellent database platform for SAP applications. The following recommendations provide an outline of best practices for maintaining SQL Server database for an SAP implementation. 1) Perform a full database backup daily 2) Perform transaction log backup Every 10 to 30 minutes 3) Back up system partition in case of configuration changes 4) Back up system databases in case of configuration changes 5) Run DBCC CHECKDB periodically (ideally before the full database backup) 6) Evaluate security patches monthly (and install them if they are necessary)... - [SQL SERVER - FIX : ERROR : The query processor could not start the necessary thread resources for parallel query execution](https://blog.sqlauthority.com/2008/01/30/sql-server-fix-error-the-query-processor-could-not-start-the-necessary-thread-resources-for-parallel-query-execution/): ERROR : The query processor could not start the necessary thread resources for parallel query execution. - [SQLAuthority New - O'relly Style Book Cover for SQLAuthority](https://blog.sqlauthority.com/2008/01/29/sqlauthority-new-orelly-style-book-cover-for-sqlauthority/): Yo Ming, Chin regular reader from Los Angeles, CA has sent me following image for SQLAuthority. Checkout O’reillymaker and create your own Book Cover. Reference : Pinal Dave (https://blog.sqlauthority.com) , O’reillymaker - [SQLAuthority News - SQL Server 2008 for Oracle DBA](https://blog.sqlauthority.com/2009/11/21/sqlauthority-news-sql-server-2008-for-oracle-dba/): This 15 modules, level 300 course provides students with the knowledge and skills to capitalize on their skills and experience as an Oracle DBA to manage a Microsoft SQL Server 2008 system. This workshop provides a quick start for the Oracle DBA to map, compare, and contrast the realm of Oracle database management to SQL Server database management. Module 1: Database and Instance Module 2: Database Architecture Module 3: Instance Architecture Module 4: Data Objects Module 5: Data Access Module 6: Data Protection Module 7: Basic Administration Module 8: Server Management Module 9: Managing Schema Objects Module 10: Database Security Module... - [SQLAuthority News - Book Review - Expert SQL Server 2008 Encryption by Michael Coles](https://blog.sqlauthority.com/2009/11/20/sqlauthority-news-book-review-expert-sql-server-2008-encryption-by-michael-coles/): Expert SQL Server 2008 Encryption (Paperback) Michael Coles (Author), Rodney Landrum (Author) Link to Amazon “What is your opinion on encryption? What I mean is: In a world filled with data, how do you see encryption?” This is the precise question Michael Coles posed to me on March 3rd of this year, while we were heading to Starbucks in Seattle. We were both attending the Microsoft MVP Summit there. In the information era, security has become one of the most vital aspects of life. Although the topic may seem a little mundane, its importance cannot be overemphasized. It is the pillar... - [SQL SERVER - Understanding Table Hints with Examples](https://blog.sqlauthority.com/2009/11/19/sql-server-understanding-table-hints-with-examples/): Introduction Today we have a very interesting subject to look at. I tried to look for help online but have not found any other documentation besides what we have from the Book Online. Let us try to understand what are the different kinds of hints available in SQL Server and how they are helpful. What is a Hint? Hints are options and strong suggestions specified for enforcement by the SQL Server query processor on DML statements. The hints override any execution plan the query optimizer might select for a query. Before we continue to explore this subject, we need to consider... - [SQL SERVER - Size of Index Table - A Puzzle to Find Index Size for Each Index on Table](https://blog.sqlauthority.com/2009/11/18/sql-server-size-of-index-table-a-puzzle-to-find-index-size-for-each-index-on-table/): It is very easy to find out some basic details of any table using the following Stored Procedure. USE AdventureWorks GO EXEC sp_spaceused [HumanResources.Shift] GO Above query will return following resultset The above SP provides basic details such as rows, data size in table, and Index size of all the indexes on the table. If we look at this carefully, a total of three indexes can be found on the table HumanResources.Shift. USE AdventureWorks GO SELECT * FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('HumanResources.Shift') GO The above query will give result with query listing all the index on the table. There is... - [SQL SERVER - 2005 2008 - Backup, Integrity Check and Index Optimization By Ola Hallengren](https://blog.sqlauthority.com/2009/11/17/sql-server-2005-2008-backup-integrity-check-and-index-optimization-by-ola-hallengren/): Script of Backup, Integrity Check and Index Optimization are the most important scripts for any developer. SQL Expert and true SQL enthusiast Ola Hallengren is known for his excellent scripts. Please try it out and let me know what you think. The documentation is available on http://ola.hallengren.com/Documentation.html and the script can be downloaded from http://ola.hallengren.com. Here is brief documentation sent by Ola himself for his script in his own words. Backup Maintenance I think that most of you have experienced the error messages “BACKUP LOG cannot be performed because there is no current database backup.” and “Cannot perform a differential backup... - [SQLAuthority News - Notes of Excellent Experience at SQL PASS 2009 Summit, Seattle](https://blog.sqlauthority.com/2009/11/16/sqlauthority-news-notes-of-excellent-experience-at-sql-pass-2009-summit-seattle/): Update: Do not forget to checkout last three photos and follow me on twitter (of course!) I have previously documented my four-day experience of SQL PASS 2009 Summit at Seattle. There were many reasons for SQL enthusiasts to attend the SQL PASS event; I am listing my own reasons here in order of importance to me. Networking with SQL fellows and experts Putting face to the name or avatar Learning and improving my SQL skills Understanding the structure of the largest SQL Server Professional Association Attending my favorite training sessions During these four days, there was so much happening that it... - [SQL SERVER - Whitepaper Consolidation Using SQL Server 2008](https://blog.sqlauthority.com/2009/11/15/sql-server-whitepaper-consolidation-using-sql-server-2008/): Consolidation Using SQL Server 2008 Writer: Allan Hirt, Megahirtz LLC (allan@sqlha.com) Technical Reviewers: Lindsey Allen, Madhan Arumugam, Ben DeBow, Sung Hsueh, Rebecca Laszlo, Claude Lorenson, Prem Mehra, Mark Pohto, Sambit Samal, and Buck Woody Published: October 2009 Many companies are considering or have already implemented consolidation of computing resources, including Microsoft SQL Server instances and databases, in their organization. A consolidation effort is a complex task that requires information, a detailed plan and timeline for success, and a strategy for administering the consolidated environment. This white paper walks through the journey of gathering and analyzing the information to base all planning... - [SQLAuthority News - Disk Partition Alignment Best Practices for SQL Server](https://blog.sqlauthority.com/2009/11/14/sqlauthority-news-disk-partition-alignment-best-practices-for-sql-server/): Disk Partition Alignment Best Practices for SQL Server Writers: Jimmy May, Denny Lee Contributors: Mike Ruthruff, Robert Smith, Bruce Worthington, Jeff Goldner, Mark Licata, Deborah Jones, Michael Thomassy, Michael Epprecht, Frank McBath, Joseph Sack, Matt Landers, Jason McKittrick, Linchi Shea, Juergen Thomas, Emily Wilson, John Otto, Brent Dowling Technical Reviewers: Mike Ruthruff, Robert Smith, Bruce Worthington, Emily Wilson, Lindsey Allen, Stuart Ozer, Thomas Kejser, Kun Cheng, Nicholas Dritsas, Paul Mestemaker, Alexei Khalyako, Mike Anderson, Bong Kang Published: May 2009 Disk partition alignment is a powerful tool for improving SQL Server performance. Configuring optimal disk performance is often viewed as much art... - [SQL SERVER - Policy Based Management - Create, Evaluate and Fix Policies](https://blog.sqlauthority.com/2009/11/13/sql-server-policy-based-management-create-evaluate-and-fix-policies/): Introduction This article will cover the most spectacular feature of SQL 2008 – Policy-based management and how the configuration of SQL Server with policy-based management architecture can make a powerful difference. Policy based management is loaded with several advantages. It can help you implement various policies for reliable configuration of the system. It also provides additional administration assistance to DBAs and helps them effortlessly manage various tasks of SQL Server across the enterprise. Basics of Policy Management SQL server 2008 has introduced policy management framework, which is the latest technique for SQL server database engine. SQL policy administrator uses SQL Server... - [SQL SERVER - Disable CHECK Constraint - Enable CHECK Constraint](https://blog.sqlauthority.com/2009/11/12/sql-server-disable-check-constraint-enable-check-constraint/): Foreign Key and Check Constraints are two types of constraints that can be disabled or enabled when required. This type of operation is needed when bulk loading operations are required or when there is no need to validate the constraint. The T-SQL Script that does the same is very simple. USE AdventureWorks GO -- Disable the constraint ALTER TABLE HumanResources.Employee NOCHECK CONSTRAINT CK_Employee_BirthDate GO -- Enable the constraint ALTER TABLE HumanResources.Employee WITH CHECK CHECK CONSTRAINT CK_Employee_BirthDate GO It is very interesting that when the constraint is enabled, the world CHECK is used twice – WITH CHECK CHECK CONSTRAINT. I often ask those to find the mistake in this script when they claim to... - [SQL SERVER - Sharepoint Resource Available for SQL Server](https://blog.sqlauthority.com/2009/11/11/sql-server-sharepoint-resource-available-for-sql-server/): Here is quick list of the tools which are available for SQL Server and Sharepoint. These are recently updated resources from Microsoft. External Collaboration Toolkit for SharePoint This solution allows users to create collaboration environments that use the familiar SharePoito deploy a SharePoint-based environment for collaboration with people outside your firewall. The accelerator allows users to create collaboration environments that use the familiar SharePoint interface. Because the solution is easy to use, end users are more likely to use it rather than revert to e-mail. SQL Server Reporting Services Add-in for SharePoint Technologies The Microsoft SQL Server 2005 Reporting Services Add-in... - [SQL Authority News - Training MS SQL Server 2005/2008 Query Optimization And Performance Tuning](https://blog.sqlauthority.com/2009/11/10/sql-authority-news-training-ms-sql-server-20052008-query-optimization-and-performance-tuning/): This is very short note announcing details about my course details for 'Training MS SQL Server 2005/2008 Query Optimization And Performance Tuning'. - [SQL SERVER - Removing Key Lookup - Seek Predicate - Predicate - An Interesting Observation Related to Datatypes](https://blog.sqlauthority.com/2009/11/09/sql-server-removing-key-lookup-seek-predicate-predicate-an-interesting-observation-related-to-datatypes/): Recently, I have been working on Query Optimization project. While working on it, I found the following interesting observation. This entire concept may appear very simple, but if you are working in the area of query optimization and server tuning, you will find such useful hints. Before we start, let us understand the difference between Seek Predicate and Predicate. Seek Predicate is the operation that describes the b-tree portion of the Seek. Predicate is the operation that describes the additional filter using non-key columns. Based on the description, it is very clear that Seek Predicate is better than Predicate as it... - [SQL SERVER - Stored Procedure are Compiled on First Run - SP taking Longer to Run First Time](https://blog.sqlauthority.com/2009/11/08/sql-server-stored-procedure-are-compiled-on-first-run-sp-taking-longer-to-run-first-time/): During the PASS summit, one of the attendees asked me the following question. Why the Stored Procedure takes long time to run for first time? The reason for the same is because Stored Procedures are compiled when it runs first time. When I answered the same, he replied that Stored Procedures are pre-compiled, and this should not be the case. In fact, Stored Procedures are not pre-compiled; they compile only during their first time execution. There is a misconception that stored procedures are pre-compiled. They are not pre-compiled, but compiled only during the first run. For every subsequent runs, it is... - [SQLAuthority News - Data Compression Strategy Capacity Planning and Best Practices](https://blog.sqlauthority.com/2009/11/07/sqlauthority-news-data-compression-strategy-capacity-planning-and-best-practices/): Data Compression: Strategy, Capacity Planning and Best Practices SQL Server Technical Article Writer: Sanjay Mishra Contributors: Marcel van der Holst, Peter Carlin, Sunil Agarwal Technical Reviewer: Stuart Ozer, Lindsey Allen, Juergen Thomas, Thomas Kejser, Burzin Patel, Prem Mehra, Joseph Sack, Jimmy May, Cameron Gardiner, Mike Ruthruff, Glenn Berry (SQL Server MVP), Paul S Randal (SQLskills.com), David P Smith (ServiceU Corporation) Published: May 2009 The data compression feature in SQL Server 2008 helps compress the data inside a database, and it can help reduce the size of the database. Apart from the space savings, data compression provides another benefit: Because compressed data... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 4](https://blog.sqlauthority.com/2009/11/06/sqlauthority-news-sql-pass-summit-seattle-2009-day-4/): Fourth day was awesome! I had scheduled nearly 8 meetings with different groups of people today. It was really great fun. Let us see the keypoints for the same. PASS President Wayne Snyder honored and thanked Kevin Kline for his 10 YEARS of service. Kevin then gets a well-deserved standing ovation from the entire audience. Next year’s PASS Summit will be in Seattle from November 8 to 11, 2010. Dell Key note was little flat in delivery. Dell was primary sponsor for the event. Dr. David DeWitt, Technical Fellow, Data & Storage Platform Division at Microsoft starts presentation entitled “From 1... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 3](https://blog.sqlauthority.com/2009/11/05/sqlauthority-news-sql-pass-summit-seattle-2009-day-3/): The third day at SQL PASS Summit was education + entertainment day for me. During the last 10 days, I woke up at 4:00 AM regularly. However, as I had way too much fun yesterday at various parties earlier, I did not get up till 7:30 AM. By the time I woke up, I realized that I was late for my early breakfast meeting with Solid Quality Global Mentors. I somehow managed to reach there at 8:00 AM and we talked for nearly an hour. After the meeting, I headed to Keynote. Keynote is the best time of the day and... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 2](https://blog.sqlauthority.com/2009/11/04/sqlauthority-news-sql-pass-summit-seattle-2009-day-2/): The second day of PASS started with very engaging and it started with an original game invented by Stuart Ainsworth. This game involves finding twitter people in real life. As I was not one of the square in bingo, I had decided to participate in game myself and try to win if I can. During this process, I felt guilty that I borrowed a pen from Stuart and did not return it back. In fact, after a while someone took the pen from me and never returned it. It is true that karma pays off! I should have returned it right... - [SQLAuthority News - SQLPASS Summit, Seattle 2009 - Day 1](https://blog.sqlauthority.com/2009/11/03/sqlauthority-news-sql-pass-summit-seattle-2009-day-1/): Day 1 at SQLPASS was awesome. I usually write everything in detail when I have to cover any project. This time, I have decided to cover this event little bit different and with lots of images. For day 1, I have more than 90 photos taken with many SQL celebrities and different sessions. I will be not able to cover all the photos taken today in this post. I will gradually post all the photos as I will do follow up posts. In this post, I will cover my activities on day 1 as well few of the photos that give you a visual tour of the spot that I have covered in one day. - [SQLAuthority News - 3 Year Old Blog - PASS Summit 2009 - 10.5 Million Views](https://blog.sqlauthority.com/2009/11/02/sqlauthority-news-3-year-old-blog-pass-summit-2009-10-5-million-views/): This blog has reached a remarkable milestone. It is 3 years old today. So far, there have been more than 10.5 million views on this blog and more than 1140 articles. It is really exciting that on this very important day, I am attending my very first SQL PASS in Seattle. The feeling and excitement to attend the very first summit cannot be put into words. I have been waiting to attend this summit for almost a year now, and today this dream is materializing with my blog’s “birthday.” You can read all of my articles written thus far here. I... - [SQL Authority News - Advanced T-SQL with Itzik Ben-Gan - Solid Quality Mentors](https://blog.sqlauthority.com/2009/11/01/sql-authority-news-advanced-t-sql-with-itzik-ben-gan-solid-quality-mentors/): As mentioned earlier in a blog post SQL SERVER – Advanced T-SQL with Itzik Ben-Gan – A Dream Coming True, I got the wonderful opportunity to attend the course of Itzik Ben-Gan. Itzik is one of the true masters of SQL Server, and his fame had set my expectations quite high. The most interesting aspect is that I have taught a similar course in India several times, and I was quite familiar with all the slides and examples. As I already knew a lot about this course, I was wondering if I would be able to enjoy the class or learn something... - [SQLAuthority News - New PASS President Rushabh Mehta](https://blog.sqlauthority.com/2009/10/31/sqlauthority-news-new-pass-president-rushabh-mehta/): The Professional Association for SQL Server (PASS) is an independent, not-for-profit association, dedicated to supporting, educating, and promoting the Microsoft SQL Server community. From local user groups and special interest groups (Virtual Chapters) to webcasts and the annual PASS Community Summit – the largest gathering of SQL Server professionals in the world – PASS is dedicated to helping its members Connect, Share, and Learn. Today was a big day as PASS announced the executive board members for the term starting on Jan 1, 2010. I would like to express my congratulations to all new executives of PASS. Please read official press... - [SQLAuthority News - India Market and Third Party SQL Server Tools](https://blog.sqlauthority.com/2009/10/30/sqlauthority-news-india-market-and-third-party-sql-server-tools/): Last week, I had wonderful time attending meeting of small ISV (Independent Software Vendors). Several topics were discussed, but the one topic that caught my attention was the adoption of the third party SQL Server tools. There were around 100+ top level managers who take decision regarding what resources are needed for projects. I had a great time talking to them. I have delivered a session on the subject “SQL Server – A Scalable Performance Database Platform“. Whenever I receive the right opportunity, it gives me great pleasure to talk about SQL Server. I have been working with SQL Server, and... - [SQLAuthority News - Birds-of-a-Feather (BOF) Lunch - SQL PASS Summit, Seattle, 2009](https://blog.sqlauthority.com/2009/10/29/sqlauthority-news-birds-of-a-feather-bof-lunch-sql-pass-summit-seattle-2009/): I received few emails regarding where can people meet me at SQL PASS event in Seattle. I am currently in Bellevue attending Itzik Ben-Gan’s class. I am immensely enjoying the class, and I shall post details about the class once it is over. If you are attending SQL PASS and interested to meet me, I will be present at Birds-of-a-Feather (BOF) Lunch. I will be talking on the subject Change Data Capture (CDC). Please note that this lunch is for all of us; moreover, it is not necessary that I will be talking on only subject of Change Data Capture. In... - [SQL SERVER - Tuning the Performance of Change Data Capture in SQL Server 2008](https://blog.sqlauthority.com/2009/10/28/sql-server-tuning-the-performance-of-change-data-capture-in-sql-server-2008/): Change data capture (CDC) is a new feature in SQL Server 2008 designed to capture insert, update, merge, and delete activities applied to SQL Server tables and to avail those changes in an easy-to-understand format. Conventionally, detecting changes in a source database to transfer these changes to a data warehouse required any of the following: Special columns in the source tables (time stamps, row versions). Triggers that capture changes. Comparison of the source and the destination systems. The above methods can have significant disadvantages: special columns require a change in the source database schema, and in many cases, a change in... - [SQL SERVER - How to Enable Index - How to Disable Index - Incorrect syntax near 'ENABLE'](https://blog.sqlauthority.com/2009/10/27/sql-server-how-to-enable-index-how-to-disable-index-incorrect-syntax-near-enable/): Many times I have seen that the index is disabled when there is large update operation on the table. Bulk insert of very large file updates in any table using SSIS is usually preceded by disabling the index and followed by enabling the index. I have seen many developers running the following query to disable the index. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO While enabling the same index, I have seen developers using the following INCORRECT syntax, which results in error. USE AdventureWorks GO ----INCORRECT Syntax Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact ENABLE GO Msg 102, Level 15, State... - [SQL SERVER - Advanced T-SQL with Itzik Ben-Gan - A Dream Coming True](https://blog.sqlauthority.com/2009/10/26/sql-server-advanced-t-sql-with-itzik-ben-gan-a-dream-coming-true/): As from my blog posts, all of you are probably aware that I am very much excited for attending SQL PASS at Seattle from Nov 1, 2009. As the days to the summit were nearing, I could already feel the rush of adrenalin in my veins. May be because of this, I could not wait any longer and so I headed towards Seattle a week earlier! As Robert Cain mentioned on twitter, I finally arrived at Seattle a week earlier than the start date of the summit. I landed in Seattle on the evening of Oct 24, 2009. As I was... - [SQLAuthority News - Best Practices for Integration Services Configurations](https://blog.sqlauthority.com/2009/10/25/sqlauthority-news-best-practices-for-integration-services-configurations/): Best Practices for Integration Services Configurations by Jamie Thomson This article explains what SQL Server Integration Services configurations are used for, why you should use Integration Services configurations, and what options you have for leveraging configurations. It will also make some simple recommendations that are based on my experiences of building Integration Services packages in a real-world environment. An understanding of the terms “package”, “Business Intelligence Development Studio”, and “dtexec.exe” in the context of Integration Services is assumed. There five basic types of Integration Services configurations. XML Configuration File Environment Variable Configuration Parent Package Configuration Registry Configuration SQL Server Configuration Read... - [SQL SERVER - Link to SQL Server Book Online - BOL](https://blog.sqlauthority.com/2009/10/24/sql-server-link-to-sql-server-book-online-bol/): Do you keep following Book Online Links handy? I do and I use them a lot. SQL Server 2008 R2 SQL Server 2008 SQL Server 2005 SQL Server 2000 I do and I use them a lot. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - PASS Sessions - I will be there!](https://blog.sqlauthority.com/2009/10/23/sqlauthority-news-pass-sessions-i-will-be-there/): As PASS is now one week away and I am all excited for the same. I am going to attend following two sessions for sure. I encourage all of you to also visit the same sessions. We can all talk about SQL , SQL Integration as well Beyond Relations. First sessions I will be attending of Rushabh Mehta, he is Managing Director of Solid Quality India. Overcoming SSIS Deployment and Configuration Challenges Presenter: Rushabh Mehta (Solid Quality Learning) Session Details It is no secret that a main deficiency of SSIS is deployment. Have you wanted to punch a wall before when... - [SQL SERVER - Difference Between Candidate Keys and Primary Key In Simple Words](https://blog.sqlauthority.com/2009/10/22/sql-server-difference-candidate-keys-primary-key-simple-words/): Introduction Not long ago, I had an interesting and extended debate with one of my friends regarding which column should be primary key in a table. The debate instigated an in-depth discussion about candidate keys and primary keys. My present article revolves around the two types of keys. Let us first try to grasp the definition of the two keys. Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. Primary... - [SQL SERVER - Introduction to Business Intelligence - Important Terms & Definitions](https://blog.sqlauthority.com/2009/10/21/sql-server-introduction-to-business-intelligence-important-terms-definitions/): What is Business Intelligence Business intelligence (BI) is a broad category of application programs and technologies for gathering, storing, analyzing, and providing access to data from various data sources, thus providing enterprise users with reliable and timely information and analysis for improved decision making. To put it simply, BI is an umbrella term that refers to an assortment of software applications for analyzing an organization’s raw data for intelligent decision making for business success. BI as a discipline includes a number of related activities, including decision support, data mining, online analytical processing (OLAP), querying and reporting, statistical analysis and forecasting. - [SQLAuthority News - PASS 2009 Sessions on Query Optimization and Performance Tuning](https://blog.sqlauthority.com/2009/10/20/sqlauthority-news-pass-2009-sessions-on-query-optimization-and-performance-tuning/): PASS Summit 2009 is now only 10 days away and I am very excited for the same. I can not wait to attend the summit as this is the most awaited conference of SQL Server in world. Everybody will be there and there will be something for everybody. My core expertise is in Query Optimization and Performance Tuning area, and when I see the list of PASS session on the subject, I am totally speechless. There are so many great speaker at PASS who are there to talk on the subject. It is absolutely not possible to attend all of them... - [SQL SERVER - Change Collation of Database Column - T-SQL Script - Consolidating Collations - Extention Script](https://blog.sqlauthority.com/2009/10/19/sql-server-change-collation-of-database-column-t-sql-script-consolidating-collations-extention-script/): This document is created by Brian Cidern, he has written this excellent extension to SQL Expert who SQL SERVER – Change Collation of Database Column – T-SQL Script. His scripts are not only extremely helpful to achieve the task of consolidating collations in quick script. His script not only works perfectly but excellent piece of code and logic. Hats off to you Brian! You can reach Brian at his email address (brians.sql.blog (at) gmail (dot) com) or leave comment here. Download all scripts and explanation here About Collation Consolidation At some time in your DBA career, you may find yourself in... - [SQLAuthority News - Whitepaper - Auditing in SQL Server 2008](https://blog.sqlauthority.com/2009/10/18/sqlauthority-news-whitepaper-auditing-in-sql-server-2008/): Auditing in SQL Server 2008 SQL Server Technical Article Writer: Il-Sung Lee, Art Rask Technical Reviewer: Jack Richins, Rick Byham, Sameer Tejani, Al Comeau, JC Cannon Published: February 2009 With SQL Server Audit, SQL Server 2008 introduces an important new feature that provides a true auditing solution for enterprise customers. While SQL Trace can be used to satisfy many auditing needs, SQL Server Audit offers a number of attractive advantages that may help DBAs more easily achieve their goals such as meeting regulatory compliance requirements. These include the ability to provide centralized storage of audit logs and integration with System Center,... - [SQLAuthority News - Happy Diwali and New Year](https://blog.sqlauthority.com/2009/10/17/sqlauthority-news-happy-diwali-and-new-year/): I wish all of you Happy Diwali and New Year. Dīwali is a significant festival an official holiday in India. While Divali is popularly known as the “festival of lights”, the most significant spiritual meaning is “the awareness of the inner light”. Database tip of the day : Test your backup strategy. Yesterday night I had received call from old client, who lost his live server. When I asked for his backup system, which I helped him to set up, he informed me that as server did not crashed for entire year that did not have it properly. Well, I helped... - [SQL SERVER - Recently Executed T-SQL Query](https://blog.sqlauthority.com/2009/10/16/sql-server-recently-executed-t-sql-query/): About a year ago, I wrote blog post about SQL SERVER – 2005 – Last Ran Query – Recently Ran Query.  Since, then I have received many question regarding how this is better than fn_get_sql() or DBCC INPUTBUFFER. The Short Answer in is both of them will be deprecated. Please refer to following update query to recently executed T-SQL query on database. SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest ORDER BY deqs.last_execution_time DESC Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Enable Automatic Statistic Update on Database](https://blog.sqlauthority.com/2009/10/15/sql-server-enable-automatic-statistic-update-on-database/): In one of the recent projects, I found out that despite putting good indexes and optimizing the query, I could not achieve an optimized performance and I still received an unoptimized response from the SQL Server. On examination, I figured out that the culprit was statistics. The database that I was trying to optimize had auto update of the statistics was disabled. Let us learn about how to Enable Automatic Statistic Update on Database. - [SQLAuthority News - First Editorial - T-SQL Challenges Beginners](https://blog.sqlauthority.com/2009/10/14/sqlauthority-news-first-editorial-t-sql-challenges-beginners/): I would like to welcome all of you to very first editorial for T-SQL Challenges for Beginners. T-SQL Challenges began with the aim to help community to come out of regular mind set of just reading articles online. There is plenty of reading material available online, but there are very few that can make us use our brain cells. T-SQL Challenges are very well received in community, and today, we are receiving more than 200 responses for every challenge in a very short time. The real challenge is how to keep everybody involved. T-SQL Challenges is focused and encourage experts to... - [SQL SERVER - Comic Slow Query - SQL Joke](https://blog.sqlauthority.com/2009/10/13/sql-server-comic-slow-query-sql-joke/): Community TechDays at Ahmedabad was a great successful event. In fact, this can be considered the biggest event held in Ahmedabad thus far along with the community. I have posted a detailed report of the same at Community TechDays in Ahmedabad – A Successful Event. After the event, I received many emails requesting the comic slow query I had shown in my presentation. - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup - Part 3](https://blog.sqlauthority.com/2009/10/12/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup-part-3/): Earlier I have written two different articles on the subject Remove Bookmark Lookup. This article is as part 3 of the original article. Please read the first two articles here before continuing reading this article. - [SQLAuthority News - Accessing SQL Server Databases with PHP](https://blog.sqlauthority.com/2009/10/11/sqlauthority-news-accessing-sql-server-databases-with-php/): Accessing SQL Server Databases with PHP SQL Server Technical Article Writer: Brian Swan Published: August 2008 The SQL Server 2005 Driver for PHP is a Microsoft-supported extension of PHP 5 that provides data access to SQL Server 2005 and SQL Server 2008. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2008. The SQL Server 2005 Driver for PHP API provides a comprehensive data access solution from PHP, and includes support for many features including Windows Authentication, transactions, parameter binding, streaming, metadata access, connection pooling, and error handling. This paper discusses... - [SQL SERVER - Download Logical Query Processing Poster](https://blog.sqlauthority.com/2009/10/10/sql-server-download-logical-query-processing-poster/): You can download the poster from Itzik Ben-Gan’s T-SQL Querying page over here. Earlier this year, I had written article on SQL SERVER – Logical Query Processing Phases – Order of Statement Execution and I had asked one question to readers. I got very good response for this question. Today, I am going to discuss about one of the errata I have made there. I had displayed the Logical Query Processing order, where I had incorrectly listed the last two operations. I have listed the operations as ORDER BY first and TOP afterwards. The fact is that TOP is always executed first and ORDER BY after that. - [SQL SERVER - Queries Waiting for Memory Allocation to Execute](https://blog.sqlauthority.com/2009/10/09/sql-server-queries-waiting-for-memory-allocation-to-execute/): In one of the recent projects, I was asked to create a report of queries that are waiting for memory allocation. The reason was that we were doubtful regarding whether the memory was sufficient for the application. The following query can be useful in similar case. Queries that do not have to wait on a memory grant will not appear in the resultset of following query. SELECT TEXT, query_plan, requested_memory_kb, granted_memory_kb,used_memory_kb, wait_order FROM sys.dm_exec_query_memory_grants MG CROSS APPLY sys.dm_exec_sql_text(sql_handle) CROSS APPLY sys.dm_exec_query_plan(MG.plan_handle) Please note that wait_order will give order of query waiting on memory to execute. This is a very important script, I suggest that you... - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup - Part 2](https://blog.sqlauthority.com/2009/10/08/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup-part-2/): This article is follow up of my previous article SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup. Please do read my previous article before continuing further. I have described there two different methods to reduce query execution cost. Let us compare the performance of the SELECT statement of the previous query. We have created two different indexes on the table. Method 1: Creating covering non-clustered index. In this method, we will create a non-clustered index that contains the columns used in the SELECT statement along with the column used in the WHERE... - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup](https://blog.sqlauthority.com/2009/10/07/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup/): Today, I would like to share one very quick tip about how to remove bookmark lookup or RID lookup. Let us first understand Bookmark lookup or RID lookup. Please note that from SQL Server 2005 SP1 onwards, Bookmark look up is known as Key look up. When a small number of rows are requested by a query, the SQL Server optimizer will try to use a non-clustered index on the column or columns contained in the WHERE clause to retrieve the data requested by the query. If the query requests data from columns not present in the non-clustered index, SQL Server... - [SQL SERVER - Interesting Observation - Query Hint - FORCE ORDER](https://blog.sqlauthority.com/2009/10/06/sql-server-interesting-observation-query-hint-force-order/): SQL Server never stops to amaze me. As regular readers of this blog already know that besides conducting corporate training, I work on large-scale projects on query optimizations and server tuning projects. In one of the recent projects, I have noticed that a Junior Database Developer used the query hint Force Order; when I asked for details, I found out that the basic concept was not properly understood by him. - [SQLAuthority News - Community TechDays in Ahmedabad - A Successful Event - Oct 3, 2009](https://blog.sqlauthority.com/2009/10/05/sqlauthority-news-community-techdays-in-ahmedabad-a-successful-event/): Community TechDays at Ahmedabad was a great successful event. In fact, this can be considered the biggest event held in Ahmedabad thus far along with community. This event was held by Microsoft and PASS (Professional Association of SQL Server). The goal of this event was to dive deep into the world of Microsoft technologies and get trained on the latest from Microsoft. Well, we could successfully achieve the same and build real connections with Microsoft experts and community members. - [SQL SERVER - Choose Right Edition of SQL Server Express for Your Application](https://blog.sqlauthority.com/2009/10/04/sql-server-choose-right-edition-of-sql-server-express-for-your-application/): SQL Server Express is better alternative of MySQL. I have recently helped quite a few organizations to move to SQL Server Express recently. However, one question keep on coming up quite often regarding which is the right edition for SQL Server Express. SQL Server Express have more than one edition available. Here is the quick guide to select right edition for SQL Server. After reading above guide if you are still not sure which edition you should select, leave a comment here or send me email and I will get back to you. SQL Server 2008 Express with Advanced Services –... - [SQLAuthority News - Database Encryption in SQL Server 2008 Enterprise Edition](https://blog.sqlauthority.com/2009/10/03/sqlauthority-news-database-encryption-in-sql-server-2008-enterprise-edition/): Database Encryption in SQL Server 2008 Enterprise Edition SQL Server Technical Article Writers: Sung Hsueh Technical Reviewers: Raul Garcia, Sameer Tejani, Chas Jeffries, Douglas MacIver, Byron Hynes, Ruslan Ovechkin, Laurentiu Cristofor, Rick Byham, Sethu Kalavakur Published: February 2008 TDE does not replace cell-level encryption, EFS, or BitLocker. This white paper compares TDE with these other encryption methods for application developers and database administrators. While this is not a technical, in-depth review of TDE, technical implementations are explored and a familiarity with concepts such as virtual log files and the buffer pool are assumed. The user is assumed to be familiar with... - [SQLAuthority News - SQL Server 2008 - The Other Side of Index - Community Tech Days](https://blog.sqlauthority.com/2009/10/02/sqlauthority-news-sql-server-2008-the-other-side-of-index-live-presentation-in-ahmedabad/): Community Tech Days are here Tomorrow in Ahmedabad on Oct 3, 2009. I will be presenting the session ‘SQL Server 2008 – The Other Side of Index’. I will be available there whole day if you want to meet and discuss SQL. I will be starting my session with following cartoon. You will have to attend the session in person to see what I am going to cover in the session. - [SQL SERVER - SQL Server Management Studio and Client Statistics](https://blog.sqlauthority.com/2009/10/01/sql-server-sql-server-management-studio-and-client-statistics/): Client Statistics is very important. Many a time, people relate queries execution plan with query cost. This is not a good comparison. Both are different parameters, and they are not always related. It is possible that the query cost of any statement is less, but the amount of the data returned is considerably large, which is causing any query to run slow. How do we know if any query is retrieving a large amount data or very little data? In one way, it is quite easy to figure this out by just looking at the result set; however, this method cannot... - [SQLAuthority News - Community Tech Days - Oct 3, 2009 - SQL Server 2008 - The Other Side of Index](https://blog.sqlauthority.com/2009/09/30/sqlauthority-news-community-tech-days-oct-3-2009-sql-server-2008-the-other-side-of-index/): Microsoft Community Tech Days are here! Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Community Tech Days are coming to Ahmedabad on Oct 3, 2009. I will be presenting the session ‘SQL Server 2008 – The Other Side of Index’. I will be talking about the other side of Index where we will be thinking out of the typical way of creating Indexes. Take a look at the following common conversation. Person 1: My Query is running slow. Person 2: How about create an index on it? Person 1:... - [SQL SERVER - Interesting Observation - Execution Plan and Results of Aggregate Concatenation Queries](https://blog.sqlauthority.com/2009/09/29/sql-server-interesting-observation-execution-plan-and-results-of-aggregate-concatenation-queries/): Working with SQL Server has never seems to be monotonous – no matter how long one has worked with it. Quite often, I come across some excellent comments that I feel like acknowledging them as blog posts. Recently, I wrote an article on SQL SERVER – Execution Plan and Results of Aggregate Concatenation Queries Depend Upon Expression Location, which is well received in community. Before you read this article further, I request you to read original article. I received very interesting comments from Bob on the blog, where he explained why this is happening. Further, he talked about a similar kind... - [SQLAuthority News - Download IIS Database Manager](https://blog.sqlauthority.com/2009/09/28/sqlauthority-news-download-iis-database-manager/): IIS Database Manager allows you to easily manage your local and remote databases from within IIS Manager. IIS Database Manager automatically discovers databases based on the Web server or application configuration and also provides the ability to connect to any database on the network. Once connected, IIS Database Manager provides a full array of management options including managing tables, views, stored procedures and data, as well as running ad hoc queries. Here are a few articles to get you started on using the IIS Database Manager: Basics of the IIS Database Manager Working with Tables Working with Views Working with Stored... - [SQLAuthority News - FILESTREAM Storage in SQL Server 2008](https://blog.sqlauthority.com/2009/09/27/sqlauthority-news-filestream-storage-in-sql-server-2008/): This white paper describes the FILESTREAM feature of SQL Server 2008, which allows storage of and efficient access to BLOB data using a combination of SQL Server 2008 and the NTFS file system. This white paper is Written By: Paul S. Randal (SQLskills.com) Read the white paper here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - FIX : An error occurred while executing this command. If this error persists, please contact your Live Meeting administrator.](https://blog.sqlauthority.com/2009/09/26/sqlauthority-news-fix-an-error-occurred-while-executing-this-command-if-this-error-persists-please-contact-your-live-meeting-administrator/): Recently, while I was scheduling a live meeting for one of my online training sessions, I kept receiving the following error message repeatedly. I had never encountered this type of error before, and despite searching online for a long time, I could not solve this problem. After several failed attempts, I finally managed to fix this error with the help of Solid Quality Mentors IT Support Mentor – Victor. He suggested that instead of just typing my name in the “To” field, I should clear the cache by pressing CTRL + DELETE or perform force lookup by selecting the contact person... - [SQL SERVER - Outer Join in Indexed View - Question to Readers](https://blog.sqlauthority.com/2009/09/25/sql-server-outer-join-in-indexed-view-question-to-readers/): Today I have question for you. Just a day ago I was reading whitepaper Improving Performance with SQL Server 2008 Indexed Views. Following is question and answer I read in the white paper. Q. Why can’t I use OUTER JOIN in an indexed view? A. Rows can logically disappear from an indexed view based on OUTER JOIN when you insert data into a base table. This makes incrementally updating OUTER JOIN views relatively complex to implement, and the performance of the implementation would be slower than for views based on standard (INNER) JOIN. Here I would like to ask you one... - [SQL SERVER - Interesting Observation - Index on Index View Used in Similar Query](https://blog.sqlauthority.com/2009/09/24/sql-server-interesting-observation-index-on-index-view-used-in-similar-query/): Recently, I was working on an optimization project for one of the large organizations. While working on one of the queries, we came across a very interesting observation. We found that there was a query on the base table and when the query was run, it used the index, which did not exist in the base table. On careful examination, we found that the query was using the index that was on another view. This was very interesting as I have personally never experienced a scenario like this. In simple words, “Query on the base table can use the index created... - [SQL SERVER - Insert Values of Stored Procedure in Table - Use Table Valued Function](https://blog.sqlauthority.com/2009/09/23/sql-server-insert-values-of-stored-procedure-in-table-use-table-valued-function/): I recently got many emails requesting to write a simple article. I also got a request to explain different ways to insert the values from a stored procedure into a table. Let us quickly look at the conventional way of doing the same with Table Valued Function. - [SQLAuthority News - Article 1100 and Community Service](https://blog.sqlauthority.com/2009/09/22/sqlauthority-news-article-1100-and-community-service/): This is 1100 the post of on my blog post on this blog. Just looking at the last 100 post of my blog, I have realized besides writing blog posts there are lots of other community events, I have been involved with. Let me quickly list few of the important community events and post, I have been involved with. There are three very important event in my life during last 100 posts. Three Very Important Event SQLAuthority News – 1000th Article Milestone – 8 Millions Views – Solid Quality Mentors SQLAuthority News – MVP Award Renewed SQLAuthority News – Shaivi Dave... - [SQL SERVER - Introduction to Service Broker and Sample Script](https://blog.sqlauthority.com/2009/09/21/sql-server-intorduction-to-service-broker-and-sample-script/): Service Broker in Microsoft SQL Server 2005 is a new technology that provides messaging and queuing functions between instances. The basic functions of sending and receiving messages forms a part of a “conversation.” Each conversation is considered to be a complete channel of communication. Each Service Broker conversation is considered to be a dialog where two participants are involved. Service broker find applications when single or multiple SQL server instances are used. This functionality helps in sending messages to remote databases on different servers and processing of the messages within a single database. In order to send messages between the instances,... - [SQL SERVER - Execution Plan and Results of Aggregate Concatenation Queries Depend Upon Expression Location](https://blog.sqlauthority.com/2009/09/20/sql-server-execution-plan-and-results-of-aggregate-concatenation-queries-depend-upon-expression-location/): I was reading the blog of Ward Pond, and I came across another note of Microsoft. I really found it very interesting. The given explanation was very simple; however, I would like to rewrite it again. Let us execute the following script. This script inserts two values ‘A’ and ‘B’ in the table and outputs a simple code to concatenate each other to produce the result ‘AB’. IF EXISTS( SELECT * FROM sysobjects WHERE name = 'T1' ) DROP TABLE T1 GO CREATE TABLE T1( C1 NCHAR(1)  ) INSERT T1 VALUES( 'A' ) INSERT T1 VALUES( 'B' ) DECLARE @Str0 VARCHAR(4) SET @Str0 =... - [SQLAuthority News - SQL Server Accelerator for Business Intelligence (BI) ](https://blog.sqlauthority.com/2009/09/19/sqlauthority-news-sql-server-accelerator-for-business-intelligence-bi/): I have wonderful experience at my recent Business Intelligence tour. I will write down in detail about my experience at different location. However, today I would like to talk about one particular question which was asked at all the locations. It was about SQL Server Accelerator for Business Intelligence (BI). Many attendee asked me how to use this tool. SQL Server Accelerator for Business Intelligence (BI) is no more supported by Microsoft. Microsoft does not provide any support for this solution accelerator and has no plans to release future versions. Microsoft SQL Server 2005 and later versions include most of the... - [SQLAuthority News - Community Tech Days Oct 3, 2009 - Ahmedabad](https://blog.sqlauthority.com/2009/09/18/sqlauthority-news-community-tech-days-oct-3-2009-ahmedabad/): Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Build real connections with Microsoft experts and community members, and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. What more... You can watch some of these sessions LIVE online, from the comfort of your workstation as well. - [SQL SERVER - Converting Stored Procedure into Table Valued Function](https://blog.sqlauthority.com/2009/09/17/sql-server-converting-stored-procedure-into-table-valued-function/): In one of my recent articles, I mentioned the use of Table Valued Function (TVF) instead of Stored Procedure (SP). I received a follow up email asking what type of SP can be converted into a TVF. This is indeed a very interesting question! In fact, not all the SPs qualify to be converted to a TVF. Please note that I am not encouraging to convert all the SPs to TVFs. Each SPs have their own usage and need. Here, I shall discuss about the type of SP that can be converted to a TVF. First of all, you need to... - [SQLAuthority News - Download Microsoft SQL Server StreamInsight CTP2](https://blog.sqlauthority.com/2009/09/16/sqlauthority-news-download-microsoft-sql-server-streaminsight-ctp2/): Note:   Download Microsoft SQL Server StreamInsight CTP2 by Microsoft Microsoft SQL Server StreamInsight is a platform for the continuous and incremental processing of unending sequences of events (event streams) from multiple sources with near-zero latency. These requirements, shared by vertical markets such as manufacturing, oil and gas, utilities, financial services, health care, web analytics, and IT and data center monitoring, make traditional store and query techniques impractical for timely and relevant processing of data. StreamInsight allows software developers to create innovative solutions in the domain of Complex Event Processing that satisfy these needs. It allows to monitor, mine, and develop insights... - [SQL SERVER - Cryptography in SQL Server 2008](https://blog.sqlauthority.com/2009/09/15/sql-server-cryptography-in-sql-server-2008/): SQL Server, particularly the 2005 and 2008 versions, offers the functionality of cryptography. In the following, this functionality is briefly explained. Introduction Any database professional will support the encryption of data. However, the encryption of data has to be carried out at the database engine level. This is quite tricky as there the database performance can be affected by the process of decryption, data manipulation, and then re-encryption when data is being updated. SQL Server offers robust data security. Further, it is important to have strong knowledge of cryptography in SQL Server in order to avoid many problems that are encountered... - [SQL SERVER - Plan Caching and Schema Change - An Interesting Observation](https://blog.sqlauthority.com/2009/09/14/sql-server-plan-caching-and-schema-change-an-interesting-observation/): Last week, I had published details regarding SQL SERVER – Plan Caching in SQL Server 2008 by Greg Low on this blog. Similar to any other white paper, I have read this paper very carefully and enjoyed reading it. One particular topic in the white paper that caught my attention is definition of schema change. I was well aware of this definition, but I have often found that users are not familiar with what exactly does a schema change mean. Many people assume that a change in the table structure is schema change. In fact, creating or dropping index on any... - [SQL SERVER - Introduction to Spatial Coordinate Systems: Flat Maps for a Round Planet](https://blog.sqlauthority.com/2009/09/13/sql-server-introduction-to-spatial-coordinate-systems-flat-maps-for-a-round-planet/): Introduction to Spatial Coordinate Systems: Flat Maps for a Round Planet SQL Server Technical Article Writers: Isaac Kunen Project Editor: Diana Steinmetz Published: July 2008 I recently read this very interesting white paper. I really found it very interesting as this one was one very easy to read and humourous white paper related to SQL Server. The white paper is starts with very interesting note regarding Columbus. Contrary to popular opinion, Columbus did not prove that the Earth is round. Pythagoras, Plato, and Aristotle claimed a round Earth based on philosophic and observational grounds. More impressively, Eratosthenes measured the Earth’s circumference... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2](https://blog.sqlauthority.com/2009/09/12/sqlauthority-news-risk-and-health-assessment-program-for-microsoft-sql-server-scoping-tool-v1-2/): This download package is intended for Microsoft Premier Customers Only. This package includes all of the scoping tools necessary to prepare and qualify your environment to receive a Risk and Health Assessment Program for Microsoft SQL Server. Download Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Why I am Going to Attend PASS Summit Unite 2009- Seattle](https://blog.sqlauthority.com/2009/09/11/sqlauthority-news-why-i-am-going-to-attend-pass-summit-unite-2009-seattle/): PASS Summit Unite2009 – the premier event for SQL Server professionals – will be held in Seattle from November 2 to 5. It is the largest and the most intensive Microsoft SQL Server conference in the world organized by SQL Server users for SQL Server users. This year marks the 10th Anniversary of PASS Community Summit, making the event even more special. Every year, this event sees a large number of attendees as apart from high quality technical sessions, it provides unparalleled access to the Microsoft SQL Server development, SQL CAT, and Customer Service and Support teams. PASS Summit is an... - [SQL SERVER - SQL Server Desktop Screen Background](https://blog.sqlauthority.com/2009/09/10/sql-server-sql-server-desktop-screen-background/): Buck Woody (MSFT) has published a blog post about SQL Server Desktop Screen Background. I really like the SQL Server Desktop background and I have replaced that background on my work laptop. I came across this particular post because I am a regular reader of his blog. Few of the other interesting posts written by him are following. - [SQL SERVER - Difference between SQL Server Express and MySQL](https://blog.sqlauthority.com/2009/09/09/sql-server-difference-between-sql-server-express-and-mysql/): Both SQL Server express and MySQL are two of the Relational Database Systems (RDBMS) available today. Both are freely available and meant for running smaller or embedded databases, yet there are also significant differences between them. - [SQLAuthority News - Shaivi Dave - Baby SQLAuthority](https://blog.sqlauthority.com/2009/09/08/sqlauthority-news-shaivi-dave-baby-sqlauthority/): Six days ago, on September 1st, 2009 07:03:40 AM, God blessed us with beautiful baby girl. As per Hindu Namkaran Sanskar (naming ritual), we have decided to name her as Shaivi Dave. Thank you all for all the wonderful suggestions for the baby name. Selecting the right name for the little one is really one of the most challenging tasks. According to Vedas, in Hindu religion, each occasion of a person’s life calls for elaborate rituals. After the birth of a child, naming ceremony or the Namkaran Samskar is considered one of the most important events. - [SQL SERVER - Importance of Database Schemas in SQL Server](https://blog.sqlauthority.com/2009/09/07/sql-server-importance-of-database-schemas-in-sql-server/): Beginning with SQL Server 2005, Microsoft introduced the concept of database schemas. A schema is now an independent entity- a container of objects distinct from the user who created those objects. Previously, the terms ‘user’ and ‘database object owner’ meant one and the same thing, but now the two are separate. This concept of separation of ‘user’ and ‘object owner’ may be a bit puzzling the first time one encounters it. Perhaps an example may better illustrate the concept: In SQL Server 2000, a schema was owned by, and was inextricably linked to, only one database principal (a principal is any... - [SQL SERVER - Find Gaps in The Sequence](https://blog.sqlauthority.com/2009/09/06/sql-server-find-gaps-in-the-sequence/): I have previously written two articles on the subject of missing identity and both are very well received by community. I had great fun to write article as many SQL Server expert participated in both the articles. Expert Imran Mohammed had provided excellent script to find missing identity. Please read both the articles for additional information before reading this article about finding gaps in the sequence. - [SQL SERVER - FIX - ERROR : Cannot drop the database because it is being used for replication. (Microsoft SQL Server, Error: 3724)](https://blog.sqlauthority.com/2009/09/05/sql-server-fix-error-cannot-drop-the-database-because-it-is-being-used-for-replication-microsoft-sql-server-error-3724/): I have set up replication at many different organization. One error I quite commonly face is after I have removed replication I can not remove database. When I try to remove the database it gives me following error. Cannot drop the database because it is being used for replication. (Microsoft SQL Server, Error: 3724) Fix/Workaround/Solution: The solution is very simple. Create the empty database with the same name on another server/instance first. Take full back of the same and forced restore over this database. Do let me know if you have any better idea or suggestion. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Designing SQL Server 2005 Analysis Services Cubes for Excel 2007 PivotTables](https://blog.sqlauthority.com/2009/09/04/sql-server-designing-sql-server-2005-analysis-services-cubes-for-excel-2007-pivottables/): In my recent Business Intelligence Training Roadshow August September 2009 I quite often get request to provide more details about Analysis Service Cubes for Excel 2007 PivotTable. Here is the white paper on the same subject. Microsoft Office Excel 2007 takes advantage of most of the features in Microsoft SQL Server 2005 Analysis Services. To take full advantage of these features, it is important to keep in mind the end-user experience in Office Excel 2007 when you are designing cubes. This document outlines how you can create a good end-user experience by optimizing the cube design for Office Excel 2007 PivotTable... - [SQL SERVER - What is Data Mining - A Simple Introductory Note](https://blog.sqlauthority.com/2009/09/03/sql-server-what-is-data-mining-a-simple-introductory-note/): According to MacLennan et al. (2009), data mining is defined as “the process of analyzing data to find hidden patterns using automatic methodologies.” Consider the following simple example that explains this concept. By analyzing the data on the items purchased from a supermarket or a chain of such stores, information on the products that are sold most can be obtained and accordingly supply of that particular products are increased and vice versa. Data mining, in short, is an analytical activity that studies the hidden patterns in a huge pile of data after appropriately classifying and sorting it. Who all are involved... - [SQL SERVER - Mirrored Backup and Restore and Split File Backup - Introduction](https://blog.sqlauthority.com/2009/09/02/sql-server-mirrored-backup-restore-split-file-backup-introduction/): Introduction - Mirrored Backup This article is based on a real life experience of the author while working with database backup and restore during his consultancy work for various organizations. We will go over the following important concepts of database backup and restore. Conventional Backup and Restore Spilt File Backup and Restore Mirror File Backup Understanding FORMAT Clause Miscellaneous details about Backup and Restore - [SQL SERVER - Download Script of Change Data Capture (CDC)](https://blog.sqlauthority.com/2009/09/01/sql-server-download-script-of-change-data-capture-cdc/): My article written on subject of Introduction to Change Data Capture (CDC) in SQL Server 2008 is quite a popular and I have received many request for uploading the script associated with this subject. - [SQLAuthority News - Baby SQLAuthority is here!](https://blog.sqlauthority.com/2009/09/01/sqlauthority-news-baby-sqlauthority-is-here/): September 1st, 2009 07:03:40 AM was one of the most beautiful moment of my life! God has graced us with baby girl. Nupur (my wife) and I am very happy today. We have no words to express our happiness. Baby girl and mother both are very healthy. We have yet to name our baby girl. Do you have any suggestions for Indian name? Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Effect of Oracle acquiring MySQL - A Delayed Analysis](https://blog.sqlauthority.com/2009/08/31/sqlauthority-news-effect-of-oracle-acquiring-mysql-a-delayed-analysis/): On 20 April 2009, Oracle Corporation announced its acquisition of Sun Microsystems in a deal worth about US$ 6 billion. This would have been just another one of corporate mega-deals that sound interesting in the news but really have no effect on your life. Except for the fact that with the purchase, Oracle acquired the world’s most widely used open-source database engine- MySQL. About 12 million small databases, mainly in websites and small businesses, run on the open-source MySQL platform, since it is stable, easily adaptable and most important of all for cash-strapped small companies, free. Note that ‘free’ here means... - [SQLAuthority News - Application and Multi-Server Management](https://blog.sqlauthority.com/2009/08/30/sqlauthority-news-application-and-multi-server-management/): SQL Server 2008 R2 – Application and Multi-Server Management SQL Server Technical Article Title: SQL Server 2008 R2Application and Multi-Server Management Introduction Writers: Geoff Allix Technical Reviewers: Joanne Hodgins, Omri Bahat, Morgan Oslake Published: February 2010 SQL Server 2008 R2 introduces new management tools to help improve IT efficiency and productivity. Investments in application and multi-server management will help organizations proactively manage database environments efficiently at scale through centralized visibility into resource utilization. Such investments can help streamline consolidation and upgrade initiatives across the application lifecycle—all with tools that make it fast and easy. This paper introduces the new extensions in... - [SQL SERVER - Plan Caching in SQL Server 2008](https://blog.sqlauthority.com/2009/08/29/sql-server-plan-caching-in-sql-server-2008-by-greg-low/): Plan Caching in SQL Server 2008 SQL Server Technical Article Writer:Greg Low, SolidQ Australia Technical Reviewers From Solid Quality Mentors: Andrew Kelly, Eladio Rincón, Itzik Ben-Gan Technical Reviewers From Microsoft: Adam Prout, Campbell Fraser, Xin Zhang Published: August 2009 - [SQL SERVER - Best Practices – Implementation of Database Object Schemas](https://blog.sqlauthority.com/2009/08/28/sql-server-best-practices-implementation-of-database-object-schemas/): SQL Server Best Practices – Implementation of Database Object Schemas SQL Server Technical Article Writer: Michael Redman Technical Reviewers: Sanjay Mishra, Juergen Thomas, Jimmy May, Burzin Patel, Glenn Berry (SQL Server MVP), Prem Mehra, Lindsey Allen, Thomas Kejser, Joseph Sack, Wanda He, Sharon Bjeletich Published: November 2008 - [SQL SERVER - Introduction to SQL Azure](https://blog.sqlauthority.com/2009/08/27/sql-server-introduction-to-sql-azure/): What is SQL Azure? In short, SQL Azure is simply a Microsoft branding change. SQL Services and SQL Data Services are now known as Microsoft SQL Azure and SQL Azure Database. There are a few changes, but fundamentally Microsoft’s plans to extend SQL server capabilities in cloud as web-based services remain intact. SQL Azure will continue to deliver an integrated set of services for relational databases. The reporting, analytics and data synchronization with end-users and partners also remains unchanged. This makes it most appealing to current users of SQL Server. SQL Azure is going to be the Next Big Thing from... - [SQL SERVER - SQL Server Express - A Complete Reference Guide](https://blog.sqlauthority.com/2009/08/26/sql-server-sql-server-express-a-complete-reference-guide/): SQL Server Express is one of the most valuable products of Microsoft. Very often, I face many questions with regard to SQL Server Express. Today, we will be covering some of the most commonly asked questions. - [SQLAuthority News - Business Intelligence Training Roadshow August September 2009](https://blog.sqlauthority.com/2009/08/25/sqlauthority-news-business-intelligence-training-roadshow-august-september-2009/): UPDATE : This is FREE training. I quite often receive request from readers and expert from all over the world if I do any training for SQL Server. Currently I am on Tour of 8 different stats of India and will be training on Business Intelligence Boot Camp. Here is quick image of the topics, which I am going to cover this boot camp. Currently, I am schedule to deliver the same course in many of the cities as described below. Let me know if you are interested in doing similar session at your city or organization and we can arrange... - [SQL SERVER - Index Seek vs. Index Scan - Diffefence and Usage - A Simple Note](https://blog.sqlauthority.com/2009/08/24/sql-server-index-seek-vs-index-scan-diffefence-and-usage-a-simple-note/): In this article we shall examine the two modes of data search and retrieval using indexes- index seek and index scan, and the differences between the two. - [SQLAuthority News - SQL Server 2008 Migration White Papers](https://blog.sqlauthority.com/2009/08/23/sqlauthority-news-sql-server-2008-migration-white-papers/): Quite often I get project when I am asked to migrate different database to SQL Server. Microsoft has excellent white papers written for this series. Guide to Migrating from MySQL to SQL Server 2008 In this migration guide you will learn the differences between the MySQL and SQL Server 2008 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2008 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2008. It describes the implementation differences of database... - [SQLAuthority News - Microsoft SQL Server 2008 Books Online](https://blog.sqlauthority.com/2009/08/22/sqlauthority-news-microsoft-sql-server-2008-books-online/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - Get Query Plan Along with Query Text and Execution Count](https://blog.sqlauthority.com/2009/08/21/sql-server-get-query-plan-along-with-query-text-and-execution-count/): Quite often, we need to know how many any particular objects have been executed on our server and what their execution plan is. I use the following handy script, which I use when I need to know the details regarding how many times any query has ran on my server along with its execution plan. You can add an additional WHERE condition if you want to learn about any specific object. - [SQL SERVER - FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.](https://blog.sqlauthority.com/2009/08/20/sql-server-fix-error-cannot-open-database-requested-by-the-login-the-login-failed-login-failed-for-user-nt-authoritynetwork-service/): This error is quite common and I have received it few times while I was working on a recent consultation project. Cannot open database requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’. This error occurs when you have configured your application with IIS, and IIS goes to SQL Server and tries to login with credentials that do not have proper permissions. This error can also occur when replication or mirroring is set up. If you search online, there are many different solutions provided to solve this error, and many of these solutions work fine. However,... - [SQLAuthority News - Two Virtual Tech Days Sessions - Watch it Online](https://blog.sqlauthority.com/2009/08/19/sqlauthority-news-two-virtual-tech-days-sessions-watch-it-online/): Indias premier online technical event is back again with the 6th Edition of Microsoft Virtual TechDays, scheduled to be held between August 19 -21, 2009. During these three days, you will have an opportunity to deep-dive into latest Microsoft Technologies and get a resolution to your most puzzling technical problems directly from the Technology Experts. I will be presenting two of the SQL Server Sessions on second day of the event on August 20th, 2009. SQL Server 2008: High Availability with SQL Server 2008 – “When, what where and how? Timing: 10:30am-11:45am Often in implementing High-Availability (HA) options with SQL Server... - [SQLAuthority News - Beyond Relational Interview on SQL Server 2008 Beyond Relational](https://blog.sqlauthority.com/2009/08/18/sqlauthority-news-beyond-relational-interview-on-sql-server-2008-beyond-relational/): SQL Server MVP and my personal friend Jacob Sebastian has published my interview on subject of Beyond Relational on his famous site Beyond Relational. Jacob is quite known for his T-SQL challenges as well. If you have not ever tried one, I suggest you give it a try and you will be addicted to it. Beyond Relational is interesting term. In simple terms, this means that it is beyond relations to traditional RDBMS. There are so many things to talk about when we stop thinking in terms of relationals. When we say “beyond relationals”, this does not mean that we move... - [SQL SERVER - Measure CPU Pressure - Detect CPU Pressure](https://blog.sqlauthority.com/2009/08/17/sql-server-measure-cpu-pressure-detect-cpu-pressure/): The CPU is responsible for not only SQL Server operations but also all the OS tasks related to the CPU. Let us learn about measuring CPU Pressure.  - [SQLAuthority News - Evaluate the Microsoft SQL Server 2008 R2 August Community Technology Preview (CTP)](https://blog.sqlauthority.com/2009/08/16/sqlauthority-news-evaluate-the-microsoft-sql-server-2008-r2-august-community-technology-preview-ctp/): SQL Server 2008 R2 expands on the value delivered in SQL Server 2008 to help your organization scale with confidence and improve IT and developer efficiency with new and enhanced tools for application and multi-server management, master data services and complex event processing. The new Self Service BI capabilities will empower end users to access, integrate, analyze and share information using business intelligence tools they already know – Microsoft Office. The August Customer Technology Preview (CTP) includes Application and Multi-server Management which will help organizations manage database environments efficiently at scale with increased visibility and control across the application lifecycle. The... - [SQL SERVER - Introduction to Change Data Capture (CDC) in SQL Server 2008](https://blog.sqlauthority.com/2009/08/15/sql-server-introduction-to-change-data-capture-cdc-in-sql-server-2008/): Simple-Talk.com has published my very first article on their site. This article is introducing Change Data Capture – the new concept introduced in SQL Server 2008. Change Data Capture records INSERTs, UPDATEs, and DELETEs applied to SQL Server tables, and makes a record available of what changed, where, and when, in simple relational ‘change tables’ rather than in an esoteric chopped salad of XML. These change tables contain columns that reflect the column structure of the source table you have chosen to track, along with the metadata needed to understand the changes that have been made. - [SQL SERVER - Fix : Error : 1326 Cannot connect to Database Server Error: 40 - Could not open a connection to SQL Server](https://blog.sqlauthority.com/2008/08/09/sql-server-fix-error-1326-cannot-connect-to-database-server-error-40-could-not-open-a-connection-to-sql-server/): If you are receiving the following error related to connection to SQL Server, this blog is for you.  - [SQLAuthority News - Security Update for SQL Server 2000 Service Pack 4 and MSDE 2000](https://blog.sqlauthority.com/2008/08/08/sqlauthority-news-security-update-for-sql-server-2000-service-pack-4-and-msde-2000/): If you are still using SQL Server 2000 (you should have upgraded to SQL Server 2005 by now), there is Security Upgrade for Service Pack 4 and MSDE. Download SQL Server 2000 Security Upgrade Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Released To Manufacturing Available](https://blog.sqlauthority.com/2008/08/08/sql-server-2008-released-to-manufacturing-available/): Microsoft has Released To Manufacturing available for SQL Server 2008. Released To Manufacturing (RTM) means that code of SQL Server 2008 has been approved by MS team and it is being send to manufacture. It will be while before it is available on distribute media on store shelves. Currently it is available for download by MSDN and TechNet subscribers. I want to congratulate MS SQL Server team for releasing the version of SQL Server on time. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - EXCEPT Clause in SQL Server is Similar to MINUS Clause in Oracle](https://blog.sqlauthority.com/2008/08/07/sql-server-except-clause-in-sql-server-is-similar-to-minus-clause-in-oracle/): One of the JR. Developer asked me a day ago, does SQL Server has similar operation like MINUS clause in Oracle. Absolutely, EXCEPT clause in SQL Server is exactly similar to MINUS operation in Oracle. The EXCEPT query and MINUS query returns all rows in the first query that are not returned in the second query. Each SQL statement within the EXCEPT query and MINUS query must have the same number of fields in the result sets with similar data types. Let us see that using example below. First create table in SQL Server and Oracle. CREATE TABLE EmployeeRecord (EmpNo INT... - [SQL SERVER - Query to Find Column From All Tables of Database](https://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/): One question came up just a day ago while I was writing SQL SERVER – 2005 – Difference Between INTERSECT and INNER JOIN – INTERSECT vs. INNER JOIN. How many tables in database AdventureWorks have column name like ‘EmployeeID’? It was quite an interesting question and I thought if there are scripts which can do this would be great. I quickly wrote down following script which will go return all the tables containing specific column along with their schema name. USE AdventureWorks GO SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name, c.name AS column_name FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID... - [SQL SERVER - 2005 - Get Field Name and Type of Database Table](https://blog.sqlauthority.com/2008/08/05/sql-server-2005-get-field-name-and-type-of-database-table/): In today’s article we will see question of one of reader Mohan and answer from expert Imran Mohammed. Imran thank you for answering question of Mohan. Question of Mohan: hi all, how can i get field name and type etc. in MS-SQL server 2005. is there any query available??? Answer from Imran Mohammed: @mohan use database_name Sp_help table_name This stored procedure gives all the details of column, their types, any indexes, any constraints, any identity columns and some good information for that particular table. Second method: select column_name ‘Column Name’, data_type ‘Data Type’, character_maximum_length ‘Maximum Length’ from information_schema.columns where table_name =... - [SQLAuthority News - SQLAuthority Site With New Banner](https://blog.sqlauthority.com/2008/08/04/sqlauthority-news-sqlauthority-site-with-new-banner/): I am glad to inform all the blog readers regarding new updated banner of this site. I would like to thank Ritesh, Sanjay and Rashmika who have spent their time to create the banner and gift to SQLAuthority. I really liked the new banner and I think it goes better with the theam of this site. Let me know what is your opinion about new banner. Old Banner : New Banner : (Click on banner) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Difference Between INTERSECT and INNER JOIN - INTERSECT vs. INNER JOIN](https://blog.sqlauthority.com/2008/08/03/sql-server-2005-difference-between-intersect-and-inner-join-intersect-vs-inner-join/): INTERSECT operator in SQL Server 2005 is used to retrieve the common records from both the left and the right query of the Intersect Operator. INTERSECT operator returns almost same results as INNER JOIN clause many times. When using INTERSECT operator the number and the order of the columns must be the same in all queries as well data type must be compatible. Let us see understand how INTERSECT and INNER JOIN are related.We will be using AdventureWorks database to demonstrate our example. Example 1: Simple Example of INTERSECT SELECT * FROM HumanResources.EmployeeDepartmentHistory WHERE EmployeeID IN (1,2,3) INTERSECT SELECT * FROM... - [SQL SERVER - Effect of Order of Join In Query](https://blog.sqlauthority.com/2008/08/02/sql-server-effect-of-order-of-join-in-query/): Let us try to understand this subject with example. We will use Adventurworks database for this purpose. Table which we will be using are HumanResources.Employee (290 rows), HumanResources.EmployeeDepartmentHistory (296 rows) and HumanResources.Department (16 rows). We will be running following two queries and observe the output. In the resultset the order of first column (EmployeeID) is different in both the cases when whole resultset is same. When compared both the results they are same but the order of rows is different in both the resultset. Query 1 : SELECT he.EmployeeID, he.Title, hd.Name, hd.GroupName, hdh.StartDate FROM HumanResources.Employee he LEFT JOIN HumanResources.EmployeeDepartmentHistory hdh ON... - [SQL SERVER - 2008 - Get Current System Date Time](https://blog.sqlauthority.com/2008/08/01/sql-server-2008-get-current-system-date-time/): How to get current system date time in SQL Server? - [SQL SERVER - 2008 - Find Current System Date Time and Time Offset](https://blog.sqlauthority.com/2008/07/31/sql-server-2008-find-current-system-date-time-and-time-offset/): If you want to find current datetime in SQL Server I suggest to read the following post : SQL SERVER – Retrieve Current Date Time in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()} This post is related to new feature available in SQL Server 2008. In SQL Server 2008 there is a function which provides current offset of the system from GMT time as well. Basically it shows the system datetime with offset. I think this can be useful in some of the instances where SQL Server are depending on the time offset. SELECT SYSDATETIMEOFFSET() AS 'Windows System Time' GO Reference : Pinal Dave... - [SQLAuthority News - Author BirthDay - SQL Server Birthday](https://blog.sqlauthority.com/2008/07/30/sqlauthority-news-author-birthday-sql-server-birthday/): It always suprise me how many people remember my birthday and take time from their busy life to call me, email me, wish me or send me their warm greetings. I would like to express my gratitude to them. Today is my birthday and I had decided to take a day off and does not talk about SQL Server. Due to urgent matter at my work, I am at office working just like usual. Well, when I decide not to talk about SQL Server today on blog, let us talk about birthdays. Let me ask all of you one question about... - [SQL SERVER - SQL SERVER - Simple Example of Recursive CTE - Part 2 - MAXRECURSION - Prevent CTE Infinite Loop](https://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/): Yesterday I wrote about SQL SERVER – SQL SERVER – Simple Example of Recursive CTE. I right away received email from regular reader John Mildred that if I can prevent infinite recursion of CTE. Sure! recursion can be limited. Use the option of MAXRECURSION. USE AdventureWorks GO WITH Emp_CTE AS ( SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate FROM HumanResources.Employee WHERE ManagerID IS NULL UNION ALL SELECT e.EmployeeID, e.ContactID, e.LoginID, e.ManagerID, e.Title, e.BirthDate FROM HumanResources.Employee e INNER JOIN Emp_CTE ecte ON ecte.EmployeeID = e.ManagerID ) SELECT * FROM Emp_CTE OPTION (MAXRECURSION 5) GO Now if your CTE goes beyond 5th recursion it will throw an... - [SQL SERVER - Simple Example of Recursive CTE](https://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/): Recursive is the process in which the query executes itself. It is used to get results based on the output of base query. We can use CTE as Recursive CTE (Common Table Expression). You can read my previous articles about CTE by searching at http://search.SQLAuthority.com . Here, the result of CTE is repeatedly used to get the final resultset. The following example will explain in detail where I am using AdventureWorks database and try to find hierarchy of Managers and Employees. USE AdventureWorks GO WITH Emp_CTE AS ( SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate FROM HumanResources.Employee WHERE ManagerID IS NULL... - [SQL SERVER - mssqlsystemresource - Resource Database](https://blog.sqlauthority.com/2008/07/27/sql-server-mssqlsystemresource-resource-database/): Just a day ago I received following email “Dear Pinal, While I was exploring my computer in directory C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data I have found database mssqlsystemresource. What is mssqlsystemresource? Thanks, Joseph Kazeka” Simple question like this are very interesting. mssqlsystemresource is Resource Database. It is read only database and contains system objects (i.e. sys.objects, sys.modules and other sys schema objects). Resource database does not contain any of user data. The purpose of resource database is to facilitates upgrading to new version of SQL Server without any hassle. In previous versions whenever version of SQL Server was upgraded all the previous... - [SQLAuthority News - Readers Selection - Readers Most Favorite Articles](https://blog.sqlauthority.com/2008/07/26/sqlauthority-news-readers-selection-readers-most-favorite-articles/): I have been receiving many emails from my readers about their favorite article. Few days ago, I asked in one of my post SQLAuthority News – Updated My Personal Book Mark Pages, which articles are most favorite articles of my readers. I have received tremendous response to my question and my mailbox overflowed. Based on readers response I have created list of readers most favorite articles. Let me know which one is your most favorite article. SQLAuthority News – Reader’s Selection Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQLAuthority T-Shirts, Mug, Hat and Other Product](https://blog.sqlauthority.com/2008/07/25/sqlauthority-news-sqlauthority-t-shirts-mug-hat-and-other-product/): I frequently get request for SQLAuthority T-Shirts. After continuous requests from many of loyal readers, I am posting link to SQLAuthoirty Products. SQLAuthority Products I have no intention to make money from this site or any product sale. All the product are sold from the site directly at no profit or profit sent to Child Rights and You directly. If this blog has been helpful to you and if you want to help me. Please stand up for the child rights. Donate money to Child Rights and You by visiting their site directly. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC SHRINKFILE Takes Long Time to Run](https://blog.sqlauthority.com/2008/07/25/sql-server-dbcc-shrinkfile-takes-long-time-to-run/): If you are DBA who are involved with Database Maintenance and file group maintenance, you must have experience that many times DBCC SHRINKFILE operations takes long time but any other operations with Database are relative quicker. Rebuilding index is quite resource intensive task but that happens faster than DBCC SHRINKFILE. Well, answer to this is very simple. DBCC SHRINKFILE is a single threaded operation. A single threaded operation does not take advantage of multiple CPUs and have no effect how many RAM are available. Hyperthreaded CPU even provides worst performance. If you rebuild indexes before you run DBCC SHRINKFILE operations, shrinking... - [SQL SERVER - 2005 -Track Down Active Transactions Using T-SQL](https://blog.sqlauthority.com/2008/07/24/sql-server-2005-track-down-active-transactions-using-t-sql/): Just a day ago, I was wondering how many active transaction are currently in my database. I found following DMV very useful – very simple and to the point. Following SQL will return currently active transaction. SELECT * FROM sys.dm_tran_session_transactions Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Log Viewer](https://blog.sqlauthority.com/2008/07/23/sql-server-introduction-to-log-viewer/): SQL Server log data is very important for any DBA to troubleshoot SQL Server related problems. In SQL Server 2000 there was no facility to check System and Application log, however in SQL Server 2005 there is facility of the log viewer. It is very useful tool and very easy to use as well. In SQL Server 2005 all the windows event logs can be seen along with SQL Server logs. Interface for all the logs is same and can be launched from the same place. This log can be exported and filtered as well. Following two images describes the how... - [SQL SERVER - Clear SQL Server Memory Caches](https://blog.sqlauthority.com/2008/07/22/sql-server-clear-sql-server-memory-caches/): If SQL Server is running slow and operations are throwing errors due to lack of memory, it is necessary to look into memory issue. If SQL Server is restarted all the cache memory is automatically cleaned up. In production server it is not possible to restart the server. In this scenario following three commands can be very useful. When executed following three commands will free up memory for SQL Server by cleaning up its cache. DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX - ERROR : 9004 An error occurred while processing the log for database. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log.](https://blog.sqlauthority.com/2008/07/21/sql-server-fix-error-9004-an-error-occurred-while-processing-the-log-for-database-if-possible-restore-from-backup-if-a-backup-is-not-available-it-might-be-necessary-to-rebuild-the-log/): ERROR : 9004 An error occurred while processing the log for database. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log. If you receive above error it means you are in great trouble. This error occurs when database is attempted to attach and it does not get attached. I have solved this error using following methods. Hope this will help anybody who is facing the same error. Microsoft suggest there are two solution to this problem. 1) Restore from a backup. Create Empty Database with same name and physical files (.ldf... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - July 19 2008](https://blog.sqlauthority.com/2008/07/21/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-july-19-2008/): Ahmedabad SQL Server User Group is just 2 months old chapter but it is getting extremely popular among enthusiastic IT professionals. I have joined this group and suggest all the developers of Ahmedabad and surrounding areas to join this group. It does not matter which application you are using but SQL Server is same everywhere. Ahmedabad SQL Server User Group is very fortunate to have Jacob Sebastian (SQL Server MVP) as President of the Usergroup. Jacob is co-founder and CTO of Excellence Infonet, Ahmedabad. You can read his articles at http://jacobsebastian.blogspot.com and www.sqlkatmai.com. In recent meeting I had presented learning session... - [SQL SERVER - Change the Port of Service Broker Configuration](https://blog.sqlauthority.com/2008/07/20/sql-server-change-the-port-of-service-broker-configuration/): Just two days ago, I wrote a small note about SQL SERVER - Introduction to Service Broker. - [SQL Server - Fix - Error : 9692 The _MSG protocol transport cannot listen on port because it is in use by another process.](https://blog.sqlauthority.com/2008/07/19/sql-server-fix-error-9692-the-_msg-protocol-transport-cannot-listen-on-port-because-it-is-in-use-by-another-process/): If you face following error the solution of this is very simple. Error : 9692 The _MSG protocol transport cannot listen on port because it is in use by another process. Above error comes up with Service Broker. Service Broker is used to send Database Emails. Read more about SQL SERVER – Introduction to Service Broker. Solution/Fix/WorkAround: Option 1: Run netstat -aon on command prompt and determine what program is using the port described in the error. Once figured out disable the application which is using that port. Option 2: Alternatively, the port on which Service Broker is running can be... - [SQL SERVER - Introduction to Service Broker](https://blog.sqlauthority.com/2008/07/18/sql-server-introduction-to-service-broker/): Service Broker is message queuing for SQL Server. It is used for sending emails and through Database Mails. You can read about SQL SERVER – Difference Between Database Mail and SQLMail here. Service Broker is feature which provides facility to SQL Server to send an asynchronous, transactional message. - [SQLAuthority News - Updated My Personal Book Mark Pages](https://blog.sqlauthority.com/2008/07/18/sqlauthority-news-updated-my-personal-book-mark-pages/): It has been long time since I have updated my personal book mark list. I have just refreshed it. You are all welcome to checkout my personally picked articles. SQLAuthority Best Articles SQLAuthority Favorite Articles I often visit above two links to read my selected articles. If you have any personal favorite from SQLAuthority.com and I have not included that to my list you can let me know and if I like it I will add to that list. I am also going to start new list very soon, which will be Readers Chosen Articles. So I suggest you start suggesting... - [SQLAuthority News - Ahmedabad SQL Server Usergroup Meeting](https://blog.sqlauthority.com/2008/07/17/sqlauthority-news-ahmedabad-sql-server-usergroup-meeting/): I will be attending Ahmedabad SQL Server Usergroup Meeting on July 19, 2008. I will be taking session about “SQL Server Best Practices“. I invite all of the SQL enthusiastic to stop by User Group Meeting and meet all the fellow developers, DBAs and members. Location : 401, TIME SQUARE, CG road, Op Bazar Calcutta, Ahmedabad, India Date and Time : July 19, 2008 6:30 PM onwards Hope to see all of you there. If you with to attend the meeting, please register your name by sending an email to jacob.reliancesp[at]gmail.com latest by Saturday 12 Noon. And for those of you... - [SQL SERVER - Readers Contribution to Site - Simple Example of Cursor](https://blog.sqlauthority.com/2008/07/16/sql-server-readers-contribution-to-site-simple-example-of-cursor/): eaders are very important to me. Without their active participation this site would not be the community helping web site. I encourage readers participation and request that you help other users with your knowledge. I recently come across very good communication between two of blog readers. I want to thank you Imran Mohammed for taking time to answer this question as well many other questions. Expert like Imran makes this world better. Let us read the question from Anthony from here. All, I am using Microsoft SQL 2005 and am trying to create a cursor that will take data from several... - [SQL SERVER - Deferred Name Resolution](https://blog.sqlauthority.com/2008/07/15/sql-server-deferred-name-resolution/): One of my Jr. Developer always wondered when she creates any Stored Procedure (SP) and if there is incorrect table name in the SP it creates the SP fine but while executing it gives run time error. However, if there is any valid table from database is referenced in SP with incorrect column name it will not let user create SP at all. Question : How come when table name is incorrect SP can be created successfully but when incorrect column is used SP can not be created? Answer : Deferred Name Resolution of database is the root cause for this... - [SQL SERVER - 2008 - Introduction to SPARSE Columns - Part 2](https://blog.sqlauthority.com/2008/07/14/sql-server-2008-introduction-to-sparse-columns-part-2/): Previously I wrote about SQL SERVER – 2008 – Introduction to SPARSE Columns. Let us understand the concept of SPARSE column in more detail. I suggest you read the first part before continuing reading this article. All SPARSE columns are stored as one XML column in database. Let us see some of the advantage and disadvantage of SPARSE column. Advantages of SPARSE column are: INSERT, UPDATE, and DELETE statements can reference the sparse columns by name. SPARSE column can work as one XML column as well. SPARSE column can take advantage of filtered Indexes, where data are filled in the row.... - [SQL SERVER - SP_CONFIGURE - Displays or Changes Global Configuration Settings](https://blog.sqlauthority.com/2008/07/13/sql-server-sp_configure-displays-or-changes-global-configuration-settings/): It is very good to know our server and its feature which are available for configurations. SQL Server always has many features which can be enabled or disabled. One should at least know what are the options SQL Server provides. This blog post we will learn how to display or change global configuration settings. - [SQL SERVER - 2008 - User Account - sa or sysadmin](https://blog.sqlauthority.com/2008/07/12/sql-server-2008-user-account-sa-or-sysadmin/): Just a day ago, I noticed ‘sysadmin’ user in SQL Server 2008. While looking more into it, I found that it has same account rights as ‘sa’ account. ‘sysadmin’ is actually replacement for legacy ‘sa’ account. ‘sa’ still exist in SQL Server 2008, however, it will be deprecated in future versions of SQL Server. It is recommended to all the users who switch to SQL Server 2008 to start migrating to ‘sysadmin’ from ‘sa’. - [SQL SERVER - 2005 - Two Important Security Update](https://blog.sqlauthority.com/2008/07/11/sql-server-2005-two-important-security-update/): If you are using SQL Server 2005, following two are very important security updates not to be missed. Security Update for SQL Server 2005 Service Pack 2 (KB948108) A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. Security Update for SQL Server 2005 Service Pack 2 (KB948109) A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Introduction to SPARSE Columns](https://blog.sqlauthority.com/2008/07/10/sql-server-2008-introduction-to-sparse-columns/): I have been writing recently about how SQL Server 2008 is better in terms of Data Stage and Backup Management. I have received very good replies from many users and have requested to write more about it. Today we will look into another interesting concept of SPARSE column. The reason I like this feature because it is way better in terms of how columns are managed in SQL Server. SPARSE column are better at managing NULL and ZERO values in SQL Server. It does not take any space in database at all. If column is created with SPARSE clause with it... - [SQL SERVER - 2008 - Two Convenient Features Inline Assignment - Inline Operations](https://blog.sqlauthority.com/2008/07/09/sql-server-2008-two-convenient-features-inline-assignment-inline-operations/): Sometimes things just go very convenient and we wish that how come it was not available in earlier versions. Let us see two features here. If it was SQL Server earlier versions we might have to write more lines to achieve what we can achieve in lesser lines. Following small example with only one variable demonstrates this feature. SQL Server 2005 version: DECLARE @idx INT SET @idx = 0 SET @idx = @idx + 1 SELECT @idx GO SQL Server 2008 version: This version demonstrates two important feature of Inline Assignment and Inline Operations DECLARE @idx INT = 0 SET @idx+=1 SELECT... - [SQL SERVER - Find Space Used For Any Particular Table](https://blog.sqlauthority.com/2008/07/08/sql-server-find-space-used-for-any-particular-table/): We often run out of the space in our drive and that is the number 1 cause of SQL Server engine stop running on various machines. Quite often we wonder how much space if any of the objects takes in the database. It is very simple to find out the space used by any table in the database. - [SQLAuthority News - Thank You to Awarding Author SQL MVP](https://blog.sqlauthority.com/2008/07/07/sqlauthority-news-thank-you-to-awarding-author-sql-mvp/): I received award from Microsoft for SQL Server Most Valuable Professional a week ago. I have received many many congratulations messages from many readers for getting this award. I thank all of you for sending me messages and your wishes. Honestly, I think this is all of yours award and I am just receiving this award for everybody who is reading and participating on this community forum. My goal is that more and more user participation occurs on this website and I publish few articles which are really contribution from readers. If you are reading this blog and have any idea... - [SQL SERVER - 2008 - Introduction to Row Compression](https://blog.sqlauthority.com/2008/07/06/sql-server-2008-introduction-to-row-compression/): In my previous article SQL SERVER – 2008 – Introduction to New Feature of Backup Compression I wrote about Row Compression and I have received many request to write in detail about Row Compression. I like when I get request about any subject to write about from my readers. Row Compression feature apply to zeros and null values and optimize their space in SQL Server. In fact, due to Row Compression feature SQL Server does not take any disk space for zero or null values. Any datatypes (decimal, datetime, money, int etc) if they are storing zero or null values in... - [SQL SERVER - Difference Between Database Mail and SQLMail](https://blog.sqlauthority.com/2008/07/05/sql-server-difference-between-database-mail-and-sqlmail/): In recent user group meeting in my city Ahmedabad, I have found that not every user knows difference between these two features of SQL Server. I do not blame any user for not knowing difference between Database Mail and SQLMail as this is very confusing sometime. I will try to explain this concept here. - [SQL SERVER - Deprecated DataType vardecimal](https://blog.sqlauthority.com/2008/07/04/sql-server-deprecated-datatype-vardecimal/): I received following email yesterday from Satnam Singh- Computer Programmer from Bangalore. “Dear Pinal, Congratulations for being MVP. You truely deserved it. I wonder why have you never written newly introduced feature of vardecimal. Keep up good work! Satnam Singh Developer – Bangalore.” In SQL Server 2005 SP2 they have introduced new concept of vardecimal, which reduces the size of zero and null values. Generically vardecimal values ranges upto 20 bytes in storage place, however when zero or null values are used it reduces the values to only 2 bytes, this way it saves valuable storage place. This feature is now... - [SQL SERVER - 2008 - Introduction to New Feature of Backup Compression](https://blog.sqlauthority.com/2008/07/03/sql-server-2008-introduction-to-new-feature-of-backup-compression/): Backup and Data Storage is my most favorite subject and I have not written about this for some time. I was experimenting with new feature of SQL Server 2008 and I come across very interesting feature of Backup compression. Let us see example of Database AdventureWorks with and without compression. After taking backup with compression enabled and without compression the file size can be compared to see the difference it makes with compressing the database. BACKUP DATABASE AdventureWorks TO DISK='C:\Backup\AW_NoCompression.bak' GO BACKUP DATABASE AdventureWorks TO DISK='C:\Backup\AW_WithCompression.bak' WITH COMPRESSION GO SQL Server 2008 supports backup data compression at database level. First of... - [SQL SERVER - 2008 - Insert Multiple Records Using One Insert Statement - Use of Row Constructor](https://blog.sqlauthority.com/2008/07/02/sql-server-2008-insert-multiple-records-using-one-insert-statement-use-of-row-constructor/): I previously wrote article about SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL. I am glad that in SQL Server 2008 we have new feature which will make our life much more easier. We will be able to insert multiple rows in SQL with using only one SELECT statement. Previous method 1: USE YourDB GO INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('First',1); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Second',2); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Third',3); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Fourth',4); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Fifth',5); GO Previous method 2:... - [SQLAuthority News - Microsoft Most Valuable Professional Award for SQL Server - MVP](https://blog.sqlauthority.com/2008/07/01/sqlauthority-news-microsoft-most-valuable-professional-award-for-sql-server-mvp/): I am very glad to announce that Microsoft has awarded me Most Valuable Professional Award for SQL Server. I would like to thank Microsoft and MVP Lead Abhishek for awarding this honor to me. MVP is most prestigious award and I am very pleased to receive it. I thank all of my readers for their continuous support in my journey. Please feel free to contact me if you need any help or assistance. Pinal Dave SQL – MVP, MCDBA, MCAD, MCP Bachelors of Engineering (Electronics and Communications), Masters of Science (Computer Networks) Founder – SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - High Availability - Hot Add Memory](https://blog.sqlauthority.com/2008/06/30/sql-server-2008-high-availability-hot-add-memory/): After reading my previous article about SQL SERVER – 2008 – High Availability – Hot Add CPU the same developer who suggested Hot Add CPU asked me if there are any restrictions in Hot Adding Memory. Yes, there are few restictions to Hot Add Memory as well. I am listing them here. 1) Underlying hardware is always key concern. Hardware should be capable to add memory when previous memories are operational. 2) Operating system should be either Windows Server 2003 or 2008 Enterprise or Datacenter Edition. 3) This feature is only available in 64-bit SQL Server Enterprise Edition, or the 32-bit... - [SQLAuthority News - Rise in SQL Injection Attacks Exploiting Unverified User Data Input](https://blog.sqlauthority.com/2008/06/29/sqlauthority-news-rise-in-sql-injection-attacks-exploiting-unverified-user-data-input/): Microsoft is aware of a recent escalation in a class of attacks targeting Web sites that use Microsoft ASP and ASP.NET technologies but do not follow best practices for secure Web application development. These SQL injection attacks do not exploit a specific software vulnerability, but instead target Web sites that do not follow secure coding practices for accessing and manipulating data stored in a relational database. When a SQL injection attack succeeds, an attacker can compromise data stored in these databases and possibly execute remote code. Clients browsing to a compromised server could be forwarded unknowingly to malicious sites that may... - [SQL SERVER - 2008 - High Availability - Hot Add CPU](https://blog.sqlauthority.com/2008/06/28/sql-server-2008-high-availability-hot-add-cpu/): One of team member suggested that we should upgrade to SQL Server 2008 because its new feature is very cool “Hot Add CPU”. Yes, I agree it is very cool feature. I am eagerly waiting for RTM of SQL Server 2008 so I can upgrade our servers to SQL Server 2008. However, to use the feature of High Availability of “Hot Add CPU” has many restrictions and I am not sure we will be in need of that right away or for atleast couple of year. Let us look at few of the restrictions for using Hot Add CPU 1) Hardware... - [SQL SERVER - Difference Between DBMS and RDBMS](https://blog.sqlauthority.com/2008/06/27/sql-server-difference-between-dbms-and-rdbms/): What is the difference between DBMS and RDBMS? DBMS – Data Base Management System RDBMS – Relational Data Base Management System or Relational DBMS A DBMS has to be persistent, that is it should be accessible when the program created the data ceases to exist or even the application that created the data restarted. A DBMS also has to provide some uniform methods independent of a specific application for accessing the information that is stored. RDBMS adds the additional condition that the system supports a tabular structure of the data, with enforced relationships between the tables. This excludes the databases that... - [SQLAuthority News - Famous Quotes From Bill Gates - Part 2](https://blog.sqlauthority.com/2008/06/26/sqlauthority-news-famous-quotes-from-bill-gates-part-2/): My previous article about Bill Gates SQLAuthority News – Famous Quotes From Bill Gates got really lots of readers and got lots of request in email that I should have follow up article about other famous quotes from Bill Gates which are missing from original article. This blog is not about Quotes but SQL Server, but little fun never hurts. SQL Server is product of Microsoft, which Bill Gates is Chairman of, so indirectly this article is about SQL Server. “The computer was born to solve problems that did not exist before.” – Bill Gates “Your most unhappy customers are your... - [SQLAuthority Download - SQL Server Cheatsheet](https://blog.sqlauthority.com/2008/06/25/sqlauthority-download-sql-server-cheatsheet/): I think this is most popular question I receive in email, if I have SQL Server cheat sheet. Well, SQL Server is very wide subject and covering all the main topics of SQL Server will take 100 pages book as cheat sheet. I have tried to create one page cheat sheet which I use for my daily use. I use this quite often and my teammates uses them as well. You can download and print this cheat sheet and use it for your personal reference. If you have any suggestions, please let me know and I will see if I can... - [SQLAuthority News - Microsoft Source Code Analyzer for SQL Injection](https://blog.sqlauthority.com/2008/06/24/sqlauthority-news-microsoft-source-code-analyzer-for-sql-injection/): Microsoft Source Code Analyzer for SQL Injection is a static code analysis tool for finding SQL Injection vulnerabilities in ASP code. Customers can run the tool on their ASP source code to help identify code paths that are vulnerable to SQL Injection attacks. Perform the following steps to download and install the Microsoft Source Code Analyzer for SQL Injection: 1. Download msscasi_asp_pkg.exe to a temporary directory. 2. Run msscasi_asp_pkg.exe. 3. Enter an installation directory when prompted. 4. After extracting the files, read the usage section of the Readme.htm file for next steps. Download Code Analyzer Abstract courtesy : Microsoft Reference :... - [SQLAuthority News - Release Notes for SQL Server 2008 Release Candidate 0](https://blog.sqlauthority.com/2008/06/23/sqlauthority-news-release-notes-for-sql-server-2008-release-candidate-0/): All product should be documented. Particularly when any release happens product must have release notes because release notes educates people about product and its usage. Microsoft has also release notes for SQL Server 2008. This Release Notes document contains information for Microsoft SQL Server 2008 Release Candidate 0 (RC0) that supplements the SQL Server 2008 RC0 Readme and Books Online documentation. Download Release Notes Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Create Check Constraint on Column](https://blog.sqlauthority.com/2008/06/22/sql-server-create-check-constraint-on-column/): I found one of the Jr. Developer writing trigger for the requirement where he wanted to make sure invalidate data does not enter in table column. I suggested him to write Check Constraint. Check Constraints are very handy to make sure all the data in the table is validated before it enters in the database. Let us check constraint on over one of the table on postalcode table in database AdventureWorks database. Constraint will suggest that value which is larger than 11 character can not be inserted into the column. Once constraint is created, it can be tested by tring to... - [SQLAuthority News - White Paper: Security Overview for Database Administrators](https://blog.sqlauthority.com/2008/06/21/sqlauthority-news-white-paper-security-overview-for-database-administrators/): Note:   Download White Paper by Microsoft SQL Server 2008 is secure by design, default, and deployment. Microsoft is committed to communicating information about threats, countermeasures, and security enhancements as necessary to keep your data as secure as possible. This paper covers some of the most important security features in SQL Server 2008. It tells you how, as an administrator, you can install SQL Server securely and keep it that way, even as applications and users make use of the data stored within. Included in This Document * Introduction * Secure Configuration o Windows Update o Surface Area Configuration * Authorization o... - [SQL SERVER - Find Current Identity of Table](https://blog.sqlauthority.com/2008/06/20/sql-server-find-current-identity-of-table/): Many times we need to know what is the current identity of the column. I have found one of my developer using aggregated function MAX() to find the current identity. USE AdventureWorks GO SELECT MAX(AddressID) FROM Person.Address GO However, I prefer following DBCC command to figure out current identity. USE AdventureWorks GO DBCC CHECKIDENT ('Person.Address') GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - White Paper: SQL Server 2008 Compared to Oracle Database 11g](https://blog.sqlauthority.com/2008/06/19/sqlauthority-news-white-paper-sql-server-2008-compared-to-oracle-database-11g/): Note: Download White Paper by Microsoft Microsoft SQL Server has steadily gained ground on other database systems and now surpasses the competition in terms of performance, scalability, security, developer productivity, business intelligence (BI), and compatibility with the 2007 Microsoft Office System. It achieves this at a considerably lower cost than does Oracle Database 11g. - [SQLAuthority News - Famous Quotes From Bill Gates](https://blog.sqlauthority.com/2008/06/18/sqlauthority-news-famous-quotes-from-bill-gates/): Bill Gates Quotes – “Success is a lousy teacher. It seduces smart people into thinking they can’t lose.” “Until we’re educating every kid in a fantastic way, until every inner city is cleaned up, there is no shortage of things to do.” “If I’d had some set idea of a finish line, don’t you think I would have crossed it years ago?” “If I had to say what is the thing that I feel best about, it’s being involved in this whole software revolution and what comes out of that.” “Whenever new technologies come along, parents have a legitimate concern about... - [SQL SERVER - 2008 - SQL Server Start Time](https://blog.sqlauthority.com/2008/06/17/sql-server-2008-sql-server-start-time/): I have been playing with SQL Server 2008 recently. There are many new features which SQL Server 2008 have. One of the interesting addition to SQL Server 2008 is system table field which records when SQL Server was started. This field has data type as datetime that is why it is precise to 3 milisecond. Note : This will not work with SQL Server 2005 or earlier version. This works with SQL Server 2008 only. SELECT sqlserver_start_time FROM sys.dm_os_sys_info ResultSet: sqlserver_start_time ———————– 2008-06-27 20:51:53.317 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to SERVERPROPERTY and example](https://blog.sqlauthority.com/2008/06/16/sql-server-introduction-to-serverproperty-and-example/): SERVERPROPERTY is very interesting system function. It returns many of the system values. I use it very frequently to get different server values like Server Collation, Server Name etc. Run following script to see all the properties of server. SELECT 'BuildClrVersion' ColumnName, SERVERPROPERTY('BuildClrVersion') ColumnValue UNION ALL SELECT 'Collation', SERVERPROPERTY('Collation') UNION ALL SELECT 'CollationID', SERVERPROPERTY('CollationID') UNION ALL SELECT 'ComparisonStyle', SERVERPROPERTY('ComparisonStyle') UNION ALL SELECT 'ComputerNamePhysicalNetBIOS', SERVERPROPERTY('ComputerNamePhysicalNetBIOS') UNION ALL SELECT 'Edition', SERVERPROPERTY('Edition') UNION ALL SELECT 'EditionID', SERVERPROPERTY('EditionID') UNION ALL SELECT 'EngineEdition', SERVERPROPERTY('EngineEdition') UNION ALL SELECT 'InstanceName', SERVERPROPERTY('InstanceName') UNION ALL SELECT 'IsClustered', SERVERPROPERTY('IsClustered') UNION ALL SELECT 'IsFullTextInstalled', SERVERPROPERTY('IsFullTextInstalled') UNION ALL SELECT 'IsIntegratedSecurityOnly', SERVERPROPERTY('IsIntegratedSecurityOnly') UNION ALL... - [SQL SERVER - 2008 - Inline Variable Assignment](https://blog.sqlauthority.com/2008/06/15/sql-server-2008-inline-variable-assignment/): I loved this feature. I have always wanted this feature to be present in SQL Server. Last time when I met developers from Microsoft SQL Server, I had talked about this feature. I think this feature saves some time but make the code more readable. ---- SQL Server 2005 Way DECLARE @MyVar INT SET @MyVar = 5 SELECT @MyVar AS TestVar GO ---- SQL Server 2008 Way DECLARE @MyVar INT&nbsp;= 5 SELECT @MyVar AS TestVar GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 600 Article and Over 3 Million Readers](https://blog.sqlauthority.com/2008/06/14/sqlauthority-news-600-article-and-over-3-million-readers/): Today is 600th article on this blog and so far over 3 Million readers have visited this blog. Popularity of this blog is increating everyday due to active participation from some good readers. When people share their ideas and their opinion whole world becomes better place. I encourage all of my readers to send me their thoughts, articles and ideas. I will be happy to share tips and tricks of readers with this blog. I have received many emails where people have asked me why I do not write about my favorite articles on this blog. Well, actually I do write... - [SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server](https://blog.sqlauthority.com/2008/06/13/sql-server-2008-introduction-to-policy-management-enforcing-rules-on-sql-server/): I have previous written article about SQL SERVER Database Coding Standards and Guidelines Complete List Download. I just received question from one of the blog reader is there any way we can just prevent violation of company policy. Well Policy Management can come into handy in this scenario. - [SQL SERVER - 2008 - Step By Step Installation Guide With Images](https://blog.sqlauthority.com/2008/06/12/sql-server-2008-step-by-step-installation-guide-with-images/): SQL SERVER 2008 Release Candidate 0 has been released for some time and I have got numerous request about how to install SQL Server 2008. I have created this step by step guide Installation Guide. Images are used to explain the process easier. - [SQL SERVER - 2008 - Four Key Pillars](https://blog.sqlauthority.com/2008/06/11/sql-server-2008-four-key-pillars/): As SQL Server 2008 is now ready to ship its final product in few months, I get many questions about what is new and attractive in SQL Server 2008. SQL SERVER 2008 has four key pillars. 1) Enterprise Data Platform It has heavily reliable database platform and can be expanded very quickly. IT also supports Hardware Security Module and Enterprise Key Management tools. Performance is key feature of SQL Server 2008. 2) Beyond Relational This edition supports spatial datatypes, which can be used for Global Positioning System and Geographic Information System. Additionally, arbitrary size of the files can be stored in... - [SQL SERVER - Microsoft SQL Server 2008 Reporting Services Add-in for Microsoft SharePoint Technologies](https://blog.sqlauthority.com/2008/06/10/sql-server-microsoft-sql-server-2008-reporting-services-add-in-for-microsoft-sharepoint-technologies/): Note: Download Here by Microsoft Microsoft SQL Server 2008 Reporting Services Add-in for SharePoint Technologies Release Candidate (RC0) (Reporting Services Add-in) enables you to take advantage of SQL Server 2008 Release Candidate (RC0) report processing and management capabilities within Windows SharePoint Services (WSS) 3.0 or Microsoft Office SharePoint Server 2007. The download provides the following functionality: A Report Viewer Web Part that provides report viewing capability, export to other rendering formats, page navigation, search, print, and zoom. Web application pages so that you can create subscriptions and schedules, and manage reports, models, and data sources. Support for using standard Windows SharePoint... - [SQLAuthority News - SQL Server 2008 Release Candidate 0](https://blog.sqlauthority.com/2008/06/09/sqlauthority-news-sql-server-2008-release-candidate-0/): Download Microsoft SQL Server 2008 Release Candidate 0 (RC0) and preview the latest features of SQL Server 2008! The SQL Server development team uses your feedback to help refine and enhance product features. Evaluate SQL Server 2008 RC0 today and send your feedback. SQL Server 2008 provides a comprehensive data platform that is secure, reliable, manageable, and scalable for your mission critical applications. With it, developers can create new applications that can store and consume any type of data on any device, enabling your users to make informed decisions with relevant insights. SQL Server 2008 RC0 will automatically expire after 180... - [SQL SERVER - Order of Conditions in WHERE Clause](https://blog.sqlauthority.com/2008/06/08/sql-server-order-of-conditions-in-where-clauses/): Sr. Developer in my organization asked me the following question about WHERE clause.  Question: Does the order of conditions matter in WHERE clause? - [SQL SERVER - PIVOT and UNPIVOT Table Examples](https://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/): I previously wrote two articles about PIVOT and UNPIVOT tables. I really enjoyed writing about them as it was interesting concept. One of the Jr. DBA at my organization asked me following question. “If we PIVOT any table and UNPIVOT that table do we get our original table?” I really think this is good question. Answers is Yes, you can but not always. When we pivot the table we use aggregated functions. If due to use of this function if data is aggregated, it will be not possible to get original data back. Let me explain this issue demonstrating simple example.... - [SQLAuthority News - Subscribe to the Newsletter for 3 Important Scripts](https://blog.sqlauthority.com/2008/06/06/sqlauthority-news-subscribe-to-the-newsletter-for-3-important-scripts/): Lots of people ask me how to stay in touch with SQLAuthority.com. Well, the answer is very simple, you can subscribe to the newsletter of SQLAuthority.com by going to URL here: https://go.sqlauthority.com.  - [SQL SERVER - Compound Assignment Operators - A Simple Example](https://blog.sqlauthority.com/2008/06/05/sql-server-2008-compound-assignment-operators/): SQL SERVER 2008 has introduced new concept of Compound Assignment Operators. Compound Assignment Operators are available in many other programming languages for quite some time. Compound Assignment Operators is operator where variables are operated upon and assigned on the same line. - [SQL SERVER - Create a Comma Delimited List Using SELECT Clause From Table Column](https://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/): I received following question in email : How to create a comma delimited list using SELECT clause from table column? - [SQL SERVER - Example of DISTINCT in Aggregate Functions](https://blog.sqlauthority.com/2008/06/03/sql-server-example-of-distinct-in-aggregate-functions/): Just a day ago, I was was asked this question in one of the teaching session to my team members. One of the member asked me if I can use DISTINCT in Aggregate Function and does it make any difference. Of course! It does make difference. DISTINCT can be used to return unique rows from a result set and it can be used to force unique column values within an aggregate function. USE AdventureWorks GO SELECT SUM(DISTINCT ReorderPoint) ResultDistinct FROM Production.Product GO SELECT SUM(ReorderPoint) ResultNoDistinct FROM Production.Product GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Order Of Column In Index](https://blog.sqlauthority.com/2008/06/02/sql-server-order-of-column-in-index/): I just found one of my Jr. DBA to create many indexes with lots of column in it. After talking with him I found out that he really does not understand how really Index works. He was under impression that if he has more columns in one index, that index has higher chance of getting selected during execution of query and speed up the query. It was very much incorrect. He did not understand important of the order of column in created index. Order really matters and the column which is at first order matters the most in Index. The selection... - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 4](https://blog.sqlauthority.com/2008/06/01/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-4/): I have been asked many times when there is DATENAME function available why do I go in exercise of writing UDF For the getting the day of the week. Answer is : I just like it! SELECT DATENAME(dw, GETDATE()) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Create Default Constraint Over Table Column](https://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/): Very frequently Jr. Developers request script for creating default constraint over table column. I have written following small script for creating default constraint. I think this will be useful to many other developers who want this script to keep handy. - [SQLAuthority News - 3 Million Readers and Continuing Journey](https://blog.sqlauthority.com/2008/05/30/sqlauthority-news-3-million-readers-and-continuing-journey/): I would like to express my deep gratitude towards your active participation on this blog. There are more than 3 Million of you have visited this site as well contributed to make it successful. You can read my personally selected articles here. SQLAuthority – Best Articles SQLAuthority – Favorite Articles Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UNPIVOT Table Example](https://blog.sqlauthority.com/2008/05/29/sql-server-unpivot-table-example/): My previous article SQL SERVER – PIVOT Table Example encouraged few of my readers to ask me question about UNPIVOT table. UNPIVOT table is reverse of PIVOT Table. USE AdventureWorks GO CREATE TABLE #Pvt ([CA] INT NOT NULL, [AZ] INT NOT NULL, [TX] INT NOT NULL); INSERT INTO #Pvt ([CA], [AZ], [TX]) SELECT [CA], [AZ], [TX] FROM ( SELECT sp.StateProvinceCode FROM Person.Address a INNER JOIN Person.StateProvince sp ON a.StateProvinceID = sp.StateProvinceID ) p PIVOT ( COUNT (StateProvinceCode) FOR StateProvinceCode IN ([CA], [AZ], [TX]) ) AS pvt; SELECT StateProvinceCode, Customer_Count FROM ( SELECT [CA], [AZ], [TX] FROM #Pvt ) t UNPIVOT (... - [SQLAuthority News - Download - Windows Server 2008 w/ SQL Server 2005](https://blog.sqlauthority.com/2008/05/28/sqlauthority-news-download-windows-server-2008-w-sql-server-2005/): Note: Download Here by Microsoft This download comes as a pre-configured VHD. This download enables testing of application designs on the Windows Server Platform. As design gets more closely integrated into the process of building websites and web applications it becomes more critical to have all the necessary software installed on your machine to enable you to preview and review the designs you are working on. Often this is the only way of ensuring your designs will remain intact and look as intended when the finished project goes live on the web. Working on a web based project today generally involves... - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 3](https://blog.sqlauthority.com/2008/05/27/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-3/): Datetime functions and stored procedures always interests me. Nanda Kumar has suggested modification to previous written article about SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 2. He has improved on UDF. CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) DECLARE @weekDay INT ----Here I have subtracted 7 For keeping Sunday as the First day like wise for Monday we need to subtract 2 and so on SET @weekDay=((DATEPART(dw,@dtDate)+@@DATEFIRST-7)%7) SELECT @rtDayofWeek = CASE @weekDay WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN... - [SQLAuthority News - SQL SERVER 2008 - New Logo](https://blog.sqlauthority.com/2008/05/26/sqlauthority-news-sql-server-2008-new-logo/): Microsoft SQL Server 2008 has new logo. I really liked the new design. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to Devide One Column into Two Column](https://blog.sqlauthority.com/2008/05/25/sql-server-t-sql-script-to-devide-one-column-into-two-column/): Just a day ago, we faced situation where one column in database contained two values which were separated by comma. We wanted to separate this two values in their own columns. It was interesting that value of the column was variable and something dynamic needed to be written. Following is quick script which separates one column into two columns. The separate between two values in comma. CREATE TABLE EMP_Demo (EMP_PAY VARCHAR(20), EMP_NAME VARCHAR(20), PAY_SCALE VARCHAR(20)); INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('ALPESH,7009') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('KRUTI,9909') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('TANMAY,16000.7') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('NESHA,6060.8') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('DEVANG,14000') UPDATE... - [SQL Authority News - SQL Server Interview Questions - SQL Related Jobs - DBA Job Description](https://blog.sqlauthority.com/2008/05/24/sql-authority-news-sql-server-interview-questions-sql-related-jobs-dba-job-description/): I like to help every candidate who are finding job. I have previously written article here which can help all the people who are looking for job or looking for candidates. SQL Server Interview Questions and Answers Complete List Download Find Job Related to SQL SERVER SQL Server DBA- Job Description Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 2](https://blog.sqlauthority.com/2008/05/23/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-2/): I have written article about SQL SERVER – UDF – Get the Day of the Week Function. I have received good modified script from reader Mihir Popat has suggested another code where Sunday does not have to be necessary the first day of the week. CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) DECLARE @weekDay INT -- Here I have subtracted 7 For keeping Sunday as the First day -- like wise for Monday we need to subtract 2 and so on SET @weekDay = ((DATEPART(dw,GETDATE())+@@DATEFIRST-7)%7) SELECT @rtDayofWeek = CASE @weekDay WHEN 1 THEN 'Sunday' WHEN 2 THEN... - [SQL SERVER - PIVOT Table Example](https://blog.sqlauthority.com/2008/05/22/sql-server-pivot-table-example/): This is quite a popular question and I have never wrote about this on my blog. A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table. - [SQL SERVER - 2005 - Twelve Tips For Optimizing Sql Server 2005 Query Performance](https://blog.sqlauthority.com/2008/05/21/sql-server-2005-twelve-tips-for-optimizing-sql-server-2005-query-performance/): I recently came across very nice article about optimization tips for SQL Server 2005. Here is the list of those 12 tips. Twelve Tips For Optimizing Sql Server 2005 Query Performance 1. Turn on the execution plan, and statistics 2. Use Clustered Indexes 3. Use Indexed Views 4. Use Covering Indexes 5. Keep your clustered index small. 6. Avoid cursors 7. Archive old data 8. Partition your data correctly 9. Remove user-defined inline scalar functions 10. Use APPLY 11. Use computed columns 12. Use the correct transaction isolation level Reference : Pinal Dave (https://blog.sqlauthority.com) , Original Article - [SQL SERVER - 2008 - Choosing the Right Edition for Your Needs](https://blog.sqlauthority.com/2008/05/20/sql-server-2008-choosing-the-right-edition-for-your-needs/): Enterprise SQL Server 2008 is a comprehensive data platform that meets the high demands of enterprise online transaction processing and data warehousing applications. Standard SQL Server 2008 Standard is a complete data management and business intelligence platform providing best-in-class ease of use and manageability for running departmental applications. Workgroup Run branch locations on this reliable data management and reporting platform that provides secure remote synchronization and management capabilities. Compact Available as a free download, build stand-alone and occasionally connected applications for mobile devices, desktops, and Web clients on all Microsoft Windows platforms. Express Available as a free download, Express is ideal... - [SQLAuthority Download - Providing Security for Web Applications and Infrastructure: Best Practices for Managing Security Risks](https://blog.sqlauthority.com/2008/05/19/sqlauthority-download-providing-security-for-web-applications-and-infrastructure-best-practices-for-managing-security-risks/): Note :  Download PPT by Microsoft Providing Security for Web Applications and Infrastructure: Best Practices for Managing Security Risks The Windows Live Security team shares best practices – from platform and network security to incident management – in providing security for web applications and infrastructure. Organizations across the globe face unique challenges in enhancing security for Web applications and their IT infrastructures. Issues such as improper Web server configuration, weak authentication policies, and invalidated Web requests can lead to unauthorized user access and potential attacks. The Microsoft Windows Live team provides services to millions of customers each month for e-mail, mobile... - [SQLAuthority News - SQL SERVER Database Administrator Job Description](https://blog.sqlauthority.com/2008/05/18/sqlauthority-news-sql-server-database-administrator-job-description/): I have previously written article about SQLAuthority News – Job Description of Database Administrator (DBA) or Database Developer. I have received quite a lot of request to update it or post something similar. Writing SQL Articles are easier then writing Job description for DBA. I have read many job description and job posting at Best SQL Jobs and found following job description. DBA Job Description The Data Base Administrator (DBA) is responsible for providing technical support for the database environment including overseeing the development and organization of the databases, assessment and implementation of new technologies, and providing Information Technology with a... - [SQL SERVER - Ideal TempDB FileGrowth Value](https://blog.sqlauthority.com/2008/05/17/sql-server-ideal-tempdb-filegrowth-value/): Just a day ago, while installing SQL Server on our development machine Jr. DBA asked me what should be kept file growth of the TempDB. I really have not thought about this till moment and I looked at MS site. - [SQL SERVER - Find Table in Every Database of SQL Server - Part 3](https://blog.sqlauthority.com/2008/05/16/sql-server-find-table-in-every-database-of-sql-server-part-3/): Previously I wrote two articles about SQL SERVER – Find Table in Every Database of SQL Server SQL SERVER – Find Table in Every Database of SQL Server – Part 2 I recently received email from SQL Expert and Blog Reader Greg Steinkuhler. People like Greg Steinkuhler makes this whole world better place. He wrote absolutely wonderful script which runs on network and have shared with community. Hats Off to you! His original email is listed here: Hi Pinal Dave, After reading the article on your website in reference to “Find Table in Every Database of SQL Server” I tried to... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Silly Mistake](https://blog.sqlauthority.com/2008/05/15/sql-server-sql-joke-sql-humor-sql-laugh-silly-mistake/): It is really very bad of person to laugh on others misfortune, however dark humor is based on the same concept. It has been long time since I wrote something funny on this blog. Recently, I have came across forum discussion regarding backup misery of one of the developer. I feel very sorry for the DBA who lost their backup but I found the suggestions of other “SQL Experts” really humorous and helpful as well. Read whole communication here Some of the witty lines are : OK, take a deep breath. Write a resignation letter. Go into your bosses office. Own... - [SQL SERVER - Orphaned MS DTC Transaction Information](https://blog.sqlauthority.com/2008/05/14/sql-server-orphaned-ms-dtc-transaction-information/): Few days ago, one of our application was crashing IIS application pool because of unhandled exception. After researched we figured out the case of it was orphaned MS DTC transaction. When multiple connections are operating over one MS DTC transaction, this problem sometime shows up. As many connection are working none of them try to roll back the MS DTC transaction, this creates orphaned connection, which crashes IIS application pool. You can figure out if there is orphaned connection or not in your application from following quick script. If there are orphaned connection it will show up in result otherwise script... - [SQL SERVER - Four Basic SQL Statements - SQL Operations](https://blog.sqlauthority.com/2008/05/13/sql-server-four-basic-sql-statements-sql-operations/): There are four basic SQL Operations or SQL Statements. SELECT – This statement selects data from database tables. UPDATE – This statement updates existing data into database tables. INSERT – This statement inserts new data into database tables. DELETE – This statement deletes existing data from database tables. If you want complete syntax for this four basic statement, please download FAQ (PDF) from SQL SERVER – Download FAQ Sheet – SQL Server in One Page Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable - Part 2](https://blog.sqlauthority.com/2008/05/12/sql-server-sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable-part-2/): Some questions never get old. One of them is temp table variable and temp table in SQL Server. I have previously wrote about this indepth here : SQL SERVER – Comparison : Similarity and Difference #TempTable vs @TempVariable Recently I received question: Can temporary table have indexes? If yes, are they really useful and efficient? When nonclustered index are created a separate table is created, what happens in the case of when temporary table? I really liked the question of user. Yes, temporary table can have indexes. If you have to use temporary table more than one time in your operation,... - [SQL SERVER 2005 - Microsoft Will Release SP3 Soon](https://blog.sqlauthority.com/2008/05/11/sql-server-2005-microsoft-will-release-sp3-soon/): I have received quite a few inquires if Microsoft is going to release SP3 for SQL Server or not? Yes! Microsoft is going to release SP3 very soon. The exact date is not announced yet. You can read the announcement of SP3 here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Function Property - Deterministic or Non-Deterministic](https://blog.sqlauthority.com/2008/05/10/sql-server-function-property-deterministic-or-non-deterministic/): I recently received question through email that how to determine if any user defined function is deterministic or non-deterministic? First go through two articles I have written about deterministic and non-deterministic function. SQL SERVER – Deterministic Functions and Nondeterministic Functions SQL SERVER – 2005 – Use of Non-deterministic Function in UDF – Find Day Difference Between Any Date and Today You can run following code to determine if function is deterministic or not. SELECT OBJECTPROPERTY(OBJECT_ID('dbo.ufnGetAccountingStartDate'), 'IsDeterministic') IsFunctionDeterministic Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 7311 - You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server](https://blog.sqlauthority.com/2008/05/09/sql-server-fix-error-7311-you-may-receive-an-error-message-when-you-try-to-run-distributed-queries-from-a-64-bit-sql-server-2005-client-to-a-linked-32-bit-sql-server-2000-server-or-to-a-linked-s/): Following email is received from SQL Server Expert Roy Cheung. He faced issue of creating and running distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server. He has found solution and would like to share with SQLAuthority Blog Readers. Hi Pinal, Recently, I’ve a problem on create and run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server. The solution below works perfect for us, I think it is good to share. http://blogs.msdn.com/sql_protocols/archive/2006/08/10/694657.aspx Thanks, Roy If you have tip or solution like this and would... - [SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database - Part 2](https://blog.sqlauthority.com/2008/05/08/sql-server-2005-find-tables-with-foreign-key-constraint-in-database-part-2/): What I love most about this blog is active readers participation. If readers are becoming contributor is the true success for any blog or online community. Recently many readers have contributed their suggestions and script to this blog. Joffery has provided nice script which is modification to previous article of SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database. Following note is from Joffery: Hi Pinal Very interesting article and of great help. I made a little addition to your code. As I wanted also to know what the FKs are doing in the Table (referential integrity... - [SQL SERVER - Create Database Error in Windows Vista](https://blog.sqlauthority.com/2008/05/07/sql-server-create-database-error-in-windows-vista/): I recently receive question from one of the blog reader that he is having problem creating database in Windows Vista. Read original comment here. I have installed vista ultimate and sql server 2005 developer edition in my computer.I also connect SQL 2005 in window authentication but when I CREATE any database in following query CREATE DATABASE MANEESH USE MANEESH Its give me everytime following error:- Msg 262, Level 14, State 1, Line 1 CREATE DATABASE permission denied in database ‘master’. & Msg 911, Level 16, State 1, Line 1 Could not locate entry in sysdatabases for database ‘maneesh’. No entry found with... - [SQL SERVER 2005 - FIX Error: 18456 : VISTA Windows Authentication](https://blog.sqlauthority.com/2008/05/06/sql-server-2005-fix-error-18456-vista-windows-authentication/): In previous post I have mentioned about SQL SERVER 2005 – Vista Ultimate and SQL Server 2005 DEV Edition. There was one simple issue with the installation. I was not able to login using windows authentication method. I was able to successful login using sa username and password. I kept on receiving following error. TITLE: Connect to Server —————————— Cannot connect to SQLAUTHORITY. —————————— ADDITIONAL INFORMATION: Login failed for user ‘SQLAUTHORITY\Pinal’. (Microsoft SQL Server, Error: 18456) For help, click: —————————— BUTTONS: OK —————————— After a while I realize that this may be due to one needs Administrator rights to do any... - [SQL SERVER - Script to Find SQL Server on Network](https://blog.sqlauthority.com/2007/04/13/sql-server-script-to-find-sql-server-on-network/): I manage lots of SQL Servers. Many times I forget how many server I have and what are their names. New servers are added frequently and old servers are replaced with powerful servers. I run following script to check if server is properly set up and announcing itself. This script requires execute permissions on XP_CMDShell. CREATE TABLE #servers(sname VARCHAR(255)) INSERT #servers (sname) EXEC master..xp_CMDShell 'ISQL -L' DELETE FROM #servers WHERE sname='Servers:' OR sname IS NULL SELECT LTRIM(sname) FROM #servers DROP TABLE #servers Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Disable Triggers - Drop Triggers](https://blog.sqlauthority.com/2007/04/13/sql-server-2005-disable-triggers-drop-triggers/): There are two ways to prevent trigger from firing. 1) Drop Trigger Example: DROP TRIGGER TriggerName GO 2) Disable Trigger DML trigger can be disabled two ways. Using ALETER TABLE statement or use DISABLE TRIGGER. I prefer DISABLE TRIGGER statement. Syntax: DISABLE TRIGGER { [ schema . ] trigger_name [ ,...n ] | ALL } ON { OBJECT_NAME | DATABASE | ALL SERVER } [ ; ] Example: DISABLE TRIGGER TriggerName ON TableName Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-1702-create-table-failed-because-column-in-table-exceeds-the-maximum-of-columns/): Error Received: Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns SQL Server 2000 supports table with maximum 1024 columns. This errors happens when we try to create table with 1024 columns or try to add columns to table which exceeds more than 1024. Fix/Solution/WorkAround: Reduce the number of columns in the table to 1,024 or less. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error: 3902, Severity: 16; State: 1 : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-3902-severity-16-state-1-the-commit-transaction-request-has-no-corresponding-begin-transaction/): SQL Server Integration Services Error : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. (Microsoft OLE DB Provider for SQL Server) Fix/Workaround/Solution: Option 1: To work around this problem, do not call the stored procedure by using ODBC Call syntax. You can call the stored procedure in may ways by using ADO. One of the methods is to call a stored procedure by using a command object. (View Example) Option 2: If the sql statements are like BEGIN TRAN SQL Statements END TRAN SET “RetainSameConnection” property on the connection manager to true. This will fix the problem. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Running 64 bit SQL SERVER 2005 on 32 bit Operating System](https://blog.sqlauthority.com/2007/04/12/sql-server-running-64-bit-sql-server-2005-on-32-bit-operating-system/): Few days ago, I have received email from users asking question :How to run 64 bit SQL SERVER 2005 on 32 bit operating system? - [SQL SERVER - UDF - User Defined Function to Extract Only Numbers From String](https://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/): Following SQL User Defined Function will extract/parse numbers from the string. CREATE FUNCTION ExtractInteger(@String VARCHAR(2000)) RETURNS VARCHAR(1000) AS BEGIN DECLARE @Count INT DECLARE @IntNumbers VARCHAR(1000) SET @Count = 0 SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1) END SET @Count = @Count + 1 END RETURN @IntNumbers END GO Run following script in query analyzer. SELECT dbo.ExtractInteger('My 3rd Phone Number is 323-111-CALL') GO It will return following values. 3323111 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Explanation of TRY...CATCH and ERROR Handling](https://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/): SQL Server 2005 offers a more robust set of tools for handling errors than in previous versions of SQL Server. Deadlocks, which are virtually impossible to handle at the database level in SQL Server 2000, can now be handled with ease. By taking advantage of these new features, you can focus more on IT business strategy development and less on what needs to happen when errors occur. In SQL Server 2005, @@ERROR variable is no longer needed after every statement executed, as was the case in SQL Server 2000. SQL Server 2005 provides the TRY…CATCH construct, which is already present in... - [SQL SERVER - 2005 - Silent Installation - Unattended Installation](https://blog.sqlauthority.com/2007/04/10/sql-server-2005-silent-installation-unattended-installation/): Silent SQL Server 2005 Installation is possible in two steps. 1) Creating an .ini file The SQL Server CD contains a template file called template.ini . Based on that create another required .ini file which includes a single [Options] section containing multiple parameters, each relating to a different feature or configuration setting. 2) Run Setup on command prompt On command prompt type following script setup.exe /settings <path TO .ini FILE> If location of sqlinstall.ini file is at C:\SQLSetup folder. The command to initiate silent installation is: setup.exe /settings C:SQLSetup sqlinstall.ini Specify the /qn switch to perform a silent installation (with no... - [SQL SERVER - SP Performance Improvement without changing T-SQL](https://blog.sqlauthority.com/2007/04/10/sql-server-sp-performance-improvement-without-changing-t-sql/): There are two ways, which can be used to improve the performance of Stored Procedure (SP) without making T-SQL changes in SP. Do not prefix your Stored Procedure with sp_. In SQL Server, all system SPs are prefixed with sp_. When any SP is called which begins sp_ it is looked into masters database first before it is looked into the database it is called in. Call your Stored Procedure prefixed with dbo.SPName – fully qualified name. When SP are called prefixed with dbo. or database.dbo. it will prevent SQL Server from placing a COMPILE lock on the procedure. While SP... - [SQL SERVER - 2005 Reserved Keywords](https://blog.sqlauthority.com/2007/04/09/sql-server-2005-reserved-keywords/): Microsoft SQL Server 2005 uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language that is used by SQL Server to parse and understand Transact-SQL statements and batches. It is not legal to include the reserved keywords in a Transact-SQL statement in any location except that defined by SQL Server. No objects in the database should be given a name that matches a reserved keyword. Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using... - [SQL SERVER - Search Text Field - CHARINDEX vs PATINDEX](https://blog.sqlauthority.com/2007/04/08/sql-server-search-text-field-charindex-vs-patindex/): We can use either CHARINDEX or PATINDEX to search in TEXT field in SQL SERVER. The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. Both functions take two arguments. With PATINDEX, you must include percent signs before and after the pattern, unless you are looking for the pattern as the first (omit the first %) or last (omit the last %) characters in a column. For CHARINDEX, the pattern cannot include wildcard characters. The second argument is a character expression, usually a column name, in which Adaptive Server searches for the specified pattern. Example of CHARINDEX:... - [SQL SERVER - DBCC Commands Introduced in SQL Server 2005](https://blog.sqlauthority.com/2007/04/07/sql-server-dbcc-commands-introduced-in-sql-server-2005/): SQL Server 2005 has introduced following two documented and five undocumented DBCC Commands. I was able to find documentation for only first one online. If you find any documentation of any other DBCC Commands please add comments. It will be helpful to all of us. Documented: freesessioncache () — no parameters Flushes the distributed query connection cache used by distributed queries against an instance of Microsoft SQL Server. View Details requeststats ({clear} | {setfastdecayrate, rate} | {setslowdecayrate, rate}) UnDocumented: mapallocunit (I8AllocUnitId | {I4part, I2part}) metadata ({‘print’ [, printopt = {0 |1}] | ‘drop’ | ‘clone’ [, ” | ….]}, {‘object’ [,... - [SQL SERVER - Fix: Server: Msg 7391, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/06/sql-server-fix-server-msg-7391-level-16-state-1-line-1/): I have received this error many times on different servers in my careers. There is no single fix for this Error. Server: Msg 7391, Level 16, State 1, Line 1 can happen due to many reasons. I have used various of this reasons with few of my servers. Please refer them and try them one by one. One of them should be applicable to your problem. You may receive a 7391 error message in SQLOLEDB when you run a distributed transaction against a linked server after you install Windows XP Service Pack 2 or Windows XP Tablet PC Edition 200. View... - [SQL SERVER - Performance Optimization of SQL Query and FileGroups](https://blog.sqlauthority.com/2007/04/05/sql-server-performance-optimization-of-sql-query-and-filegroups/): It is suggested to place transaction logs on separate physical hard drives. In this manner, data can be recovered up to the second in the event of a media failure. In SQL 2005 When database is created without specifying a transaction log size, the transaction log will be re-sized to 25 percent of the size of data files. Tables and their non-clustered indexes separated into separate file groups can improve performance, because modifications to the table can be written to both the table and the index at the same time. If tables and their corresponding indexes in a different file group,... - [SQL SERVER - Fix: HResult 0x274D, SQLCMD Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired](https://blog.sqlauthority.com/2007/04/04/sql-server-fix-hresult-0x274d-level-16-state-1-error-microsoft-sql-native-client-login-timeout-expired/): While Working with SQLCMD in SQL Server 2005 I encountered following error. Let us learn in this blog post how we can solve Fix: HResult 0x274D, Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired. - [SQL SERVER - T-SQL Paging Query Technique Comparison - SQL 2000 vs SQL 2005](https://blog.sqlauthority.com/2007/04/03/sql-server-t-sql-paging-query-technique-comparison-sql-2000-vs-sql-2005/): I was doing paging in SQL Server 2000 using Temp Table or Derived Tables. I decided to checkout new function ROW_NUMBER() in SQL Server 2005. ROW_NUMBER() returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. I have compared both the following query on SQL Server 2005. SQL 2005 Paging Method USE AdventureWorks GO DECLARE @StartRow INT DECLARE @EndRow INT SET @StartRow = 120 SET @EndRow = 140 SELECT FirstName, LastName, EmailAddress FROM ( SELECT PC.FirstName, PC.LastName, PC.EmailAddress, ROW_NUMBER() OVER( ORDER BY PC.FirstName, PC.LastName,PC.ContactID) AS RowNumber FROM... - [SQL SERVER - 2005 - Performance Dashboard Reports](https://blog.sqlauthority.com/2007/04/02/sql-server-2005-performance-dashboard-reports/): The Microsoft SQL Server 2005 Performance Dashboard Reports are used to monitor and resolve performance problems on your SQL Server 2005 database server. The SQL Server instance being monitored and the Management Studio client used to run the reports must both be running SP2 or later. Common performance problems that the dashboard reports may help to resolve include: – CPU bottlenecks (and what queries are consuming the most CPU) – IO bottlenecks (and what queries are performing the most IO). – Index recommendations generated by the query optimizer (missing indexes) – Blocking – Latch contention The SQL Server 2005 Performance Dashboard... - [SQL SERVER - TempDB is Full. Move TempDB from one drive to another drive.](https://blog.sqlauthority.com/2007/04/01/sql-server-tempdb-is-full-move-tempdb-from-one-drive-to-another-drive/): If you ever find your TEmpDB to be full and if you want to move TempDB, you will find this blog post very helpful. Here is the error message which may come across. Event ID: 17052 Description: The LOG FILE FOR DATABASE 'tempdb' IS FULL. Back up the TRANSACTION LOG FOR the DATABASE TO free Up SOME LOG SPACE - [SQL SERVER - 2005 Best Practices Analyzer (February 2007 CTP)](https://blog.sqlauthority.com/2007/03/31/sql-server-2005-best-practices-analyzer-february-2007-ctp/): Microsoft has released a tool called the Microsoft SQL Server Best Practices Analyzer. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. Download SQL Server 2005 Best Practices Analyzer (February 2007 Community Technology Preview) Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Index Seek Vs. Index Scan (Table Scan)](https://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/): Index Scan retrieves all the rows from the table. Index Seek retrieves selective rows from the table. - [SQL SERVER - Difference between DISTINCT and GROUP BY - Distinct vs Group By](https://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/): This question is asked many times to me. What is difference between DISTINCT and GROUP BY? A DISTINCT and GROUP BY usually generate the same query plan, so performance should be the same across both query constructs. GROUP BY should be used to apply aggregate operators to each group. If all you need is to remove duplicates then use DISTINCT. If you are using sub-queries execution plan for that query varies so in that case you need to check the execution plan before making decision of which is faster. Example of DISTINCT: SELECT DISTINCT Employee, Rank FROM Employees Example of GROUP... - [SQL SERVER - Fix : Error 8101 An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON](https://blog.sqlauthority.com/2007/03/28/sql-server-fix-error-8101-an-explicit-value-for-the-identity-column-in-table-can-only-be-specified-when-a-column-list-is-used-and-identity_insert-is-on/): This error occurs when the user has attempted to insert a row containing a specific identity value into a table that contains an identity column. Run following commands according to your SQL Statement. Let us learn about the IDENTITY_INSERT. - [SQL SERVER - Fix : Error 701 There is insufficient system memory to run this query](https://blog.sqlauthority.com/2007/03/27/sql-server-fix-error-701-there-is-insufficient-system-memory-to-run-this-query/): Generic Solution: Check the settings for both min server memory (MB) and max server memory (MB). If max server memory (MB) is a value close to the value of min server memory (MB), then increase the max server memory (MB) value. Check the size of the virtual memory paging file. If possible, increase the size of the file. For SQL Server 2005: Install following HotFix and Restart Server. Additionally following DBCC Commands can be ran to free memory: DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT - Retrieve Last Inserted Identity of Record](https://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/): SELECT @@IDENTITY It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value. @@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it. SELECT SCOPE_IDENTITY()... - [SQL SERVER - Stored Procedure - Clean Cache and Clean Buffer](https://blog.sqlauthority.com/2007/03/23/sql-server-stored-procedure-clean-cache-and-clean-buffer/): DBCC FREEPROCCACHE will invalidate all stored procedure plans that the optimizer has cached in memory. Let us learn how to clean cache.  - [SQL SERVER - Fix: Error Msg 128 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.](https://blog.sqlauthority.com/2007/03/22/sql-server-fix-error-msg-128-the-name-is-not-permitted-in-this-context-only-constants-expressions-or-variables-allowed-here-column-names-are-not-permitted/): Error Message: Server: Msg 128, Level 15, State 1, Line 3 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Causes: This error occurs when using a column as the DEFAULT value of another column when a table is created. CREATE TABLE [dbo].[Items] ( [OrderCount] INT, [ProductAmount] INT, [TotalAmount] DEFAULT ([OrderCount] + [ProductAmount]) ) Executing this CREATE TABLE statement will generate the following error message: Server: Msg 128, Level 15, State 1, Line 5 The name ‘TotalAmount’ is not permitted in this context. Only constants, expressions, or variables allowed here.... - [SQL SERVER - 2005 Security Best Practices - Operational and Administrative Tasks](https://blog.sqlauthority.com/2007/03/21/sql-server-2005-security-best-practices-operational-and-administrative-tasks/): This white paper covers some of the operational and administrative tasks associated with SQL Server 2005 security and enumerates best practices and operational and administrative tasks that will result in a more secure SQL Server system. - [SQL SERVER - SQL Commandments - Suggestions, Tips, Tricks](https://blog.sqlauthority.com/2007/03/20/sql-server-sql-commandments-suggestions-tips-tricks/): Few days ago, while searching for something on web site, I came across a very good article of 25 SQL Commandments. I really enjoyed reading it. It was for Oracle, I re-wrote it for SQL Server. First 18 points are taken from original article and last 2 I added to complete total of 20 Commandments. Many more rules and suggestions can be added to this list, this list is just a beginning. 1. Know your data and business application well. Familiarize yourself with these sources; you must be aware of the data volume and distribution in your database. 2. Test your... - [SQL SERVER - Fix: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17](https://blog.sqlauthority.com/2007/03/16/sql-server-fix-sqllib-error-oledb-error-encountered-calling-idbinitializeinitialize-hr-0x80004005-sqlstate-08001-native-error-17/): Error received: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17 Error state: 1, Severity: 16 Source: Microsoft OLE DB Provider for SQL Server Error message: [DBNETLIB]SQL Server does not exist or access denied The simple fix: Microsoft SQL Server 2005 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server 2005 Network Configuration >> Enable TCP-IP. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC command to RESEED Table Identity Value - Reset Table Identity](https://blog.sqlauthority.com/2007/03/15/sql-server-dbcc-reseed-table-identity-value-reset-table-identity/): DBCC CHECKIDENT can reseed (reset) the identity value of the table. For example, YourTable has 25 rows with 25 as last identity. If we want next record to have identity as 35 we need to run following T SQL script in Query Analyzer. DBCC CHECKIDENT (yourtable, reseed, 34) If table has to start with an identity of 1 with the next insert then the table should be reseeded with the identity to 0. If identity seed is set below values that currently are in table, it will violate the uniqueness constraint as soon as the values start to duplicate and will... - [SQL SERVER - Union vs. Union All - Which is better for performance?](https://blog.sqlauthority.com/2007/03/10/sql-server-union-vs-union-all-which-is-better-for-performance/): This article is completely re-written with better example SQL SERVER – Difference Between Union vs. Union All – Optimal Performance Comparison. I suggest all of my readers to go here for update article. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values. The difference between Union and Union all... - [SQL SERVER - Download 2005 SP2a](https://blog.sqlauthority.com/2007/03/07/sql-server-2005-sp2a/): Microsoft released an updated SQL Server 2005 SP2 on March 5th, 2007. The build number is 9.00.3042.01. The previous build number was 9.00.3042.00.Microsoft released a SP2a patch for the second service pack for SQL Server 2005 to fix the issues with the maintenance plans.If you have upgraded to SP2, use the download from here to patch the system. KB 933508 has more information on this patch. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Script to Determine Which Version of SQL Server 2000-2005 is Running](https://blog.sqlauthority.com/2007/03/07/sql-server-script-to-determine-which-version-of-sql-server-2000-2005-is-running/): To determine which version of SQL Server 2000/2005 is running, connect to SQL Server 2000/2005 by using Query Analyzer, and then run the following code: SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') The results are: The product version (for example, 8.00.534). The product level (for example, “RTM” or “SP2”). The edition (for example, “Standard Edition”). For example, the result looks similar to: 8.00.534 RTM Standard Edition Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation](https://blog.sqlauthority.com/2007/03/05/sql-server-quoted_identifier-onoff-and-ansi_null-onoff-explanation/): When create or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF? SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO--SQL PROCEDURE, SQL FUNCTIONS, SQL OBJECTGO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO ANSI NULL ON/OFF: This option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares a value with a null returns a 0. When off, any query that compares a value with a null returns a null value. QUOTED IDENTIFIER ON/OFF:... - [SQL SERVER - Delete Duplicate Records - Rows](https://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/): Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3. DELETE FROM MyTable WHERE ID NOT IN ( SELECT MAX(ID) FROM MyTable GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3) Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to find the CD key from Registry](https://blog.sqlauthority.com/2007/02/28/sql-server-t-sql-script-to-find-the-cd-key-from-registry/): Here is the way to find SQL Server CD key, which was used to install it on machine. If user do not have permission on the SP, please login using SA username. Expended stored procedure xp_regread can read any registry values. I have used this XP to read CD_KEY. This is undocumented Stroed Procedure and may not be supported in Future Version of SQL Server. USE master GO EXEC xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Microsoft SQL Server\80\Registration','CD_KEY' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - What is New in SQL Server Agent for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/02/26/sql-server-whats-new-in-sql-server-agent-for-microsoft-sql-server-2005/): I came across this interesting and detailed article ‘What’s New in SQL Server Agent for Microsoft SQL Server 2005’ on Microsoft TechNet. This article describes Security Improvements, New Roles in the msdb Database, Multiple Proxy Accounts, Performance Improvements, Performance Counters, New SQL Server Agent Subsystems, Shared Schedules, WMI Event Alerts, SQL Server Agent Sessions, Database Mail Support, Stored Procedure Changes in depth. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Restore Database Backup using SQL Script (T-SQL)](https://blog.sqlauthority.com/2007/02/25/sql-server-restore-database-backup-using-sql-script-t-sql/): In this blog post we are going to learn how to restore database backup using T-SQL script. We have already database which we will use to take a backup first and right after that we will use it to restore to the server. Taking backup is an easy thing, but I have seen many times when a user tries to restore the database, it throws an error. - [SQL SERVER - Download SQL Server 2005 Books Online (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-download-sql-server-2005-books-online-february-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The February 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - SQL Server 2005 Samples and Sample Databases (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-sql-server-2005-samples-and-sample-databases-february-2007/): The samples download provides over 100 samples for SQL Server 2005, demonstrating the following components: Database Engine, including administration, data access, Full-Text Search, Common Language Runtime (CLR) integration, Server Management Objects (SMO), Service Broker, and XML Analysis Services Integration Services Notification Services Reporting Services Replication The samples databases downloads include the AdventureWorks sample online transaction processing (OLTP) database, the AdventureWorksDW sample data warehouse, and the AdventureWorksAS sample projects which you can use to build the AdventureWorksAS BI database. These databases are used in the samples and in the code examples in the SQL Server 2005 Books Online. There is also a... - [SQL SERVER - Creating Comma Separate List From Table](https://blog.sqlauthority.com/2007/02/20/deprecate-dec-2007-creating-comma-separate-list-from-table/): Update : (5/5/2007) I have updated the script to support SQL SERVER 2005. Visit :SQL SERVER – Creating Comma Separate Values List from Table – UDF – SP Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 15023: User already exists in current database.](https://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/): Error 15023: User already exists in current database. 1) This is the best Solution. First of all run following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan. USE YourDB GO EXEC sp_change_users_login 'Report' GO Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist. In following example ‘ColdFusion’ is UserName, ‘cf’ is Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in... - [SQL SERVER - Function to Convert List to Table](https://blog.sqlauthority.com/2007/02/10/sql-server-function-to-convert-list-to-table/): Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005. Visit :SQL SERVER – UDF – Function to Convert List to Table Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Constraints and Unique Key Constraints](https://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/): Primary Key: Primary Key enforces uniqueness of the column on which they are defined. Primary Key creates a clustered index on the column. Primary Key does not allow Nulls. Create table with Primary Key: CREATE TABLE Authors ( AuthorID INT NOT NULL PRIMARY KEY, Name VARCHAR(100) NOT NULL ) GO Alter table with Primary Key: ALTER TABLE Authors ADD CONSTRAINT pk_authors PRIMARY KEY (AuthorID) GO Unique Key: Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value. Alter table to add unique constraint... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case](https://blog.sqlauthority.com/2007/02/01/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case/): Following function will convert any string to Title Case. I have this function for long time. I do not remember that if I wrote it myself or I modified from original source. Run Following T-SQL statement in query analyzer: SELECT dbo.udf_TitleCase('This function will convert this string to title case!') The output will be displayed in Results pan as follows: This Function Will Convert This String To Title Case! T-SQL code of the function is: CREATE FUNCTION udf_TitleCase (@InputString VARCHAR(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(1) DECLARE @OutputString VARCHAR(255) SET @OutputString = LOWER(@InputString) SET @Index = 2... - [SQL SERVER - ReIndexing Database Tables and Update Statistics on Tables](https://blog.sqlauthority.com/2007/01/31/sql-server-reindexing-database-tables-and-update-statistics-on-tables/): SQL SERVER 2005 uses ALTER INDEX syntax to reindex database. SQL SERVER 2005 supports DBREINDEX but it will be deprecated in future versions. Let us learn how to do ReIndexing Database Tables and Update Statistics on Tables. - [SQL SERVER - Query Analyzer Short Cut to display the text of Stored Procedure](https://blog.sqlauthority.com/2007/01/30/query-analyzer-short-cut-to-display-the-text-of-stored-procedure/): This is quick but interesting trick to display the text of Stored Procedure in the result window. Open SQL Query Analyzer >> Tools >> Customize >> Custom Tab type sp_helptext against Ctrl+3 (or shortcut key of your choice) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2007/01/26/sql-server-sql-joke-sql-humor-sql-laugh/): I have heard this joke from my friend. I always wanted to write it but I was not able to find the source of the joke. This joke I have located on DavidM’s Blog on SQLTeam. It is March 1st and the first day of DBMS school The teacher starts off with a role call.. Teacher: Oracle? “Present sir” Teacher: DB2? “Present sir” Teacher: SQL Server? “Present sir” Teacher: MySQL? [Silence] Teacher: MySQL? [Silence] Teacher: Where the hell is MySQL [In rushes MySQL, unshaven, hair a mess] Teacher: Where have you been MySQL “Sorry sir I thought it was February 31st”... - [SQL SERVER - Query Analyzer Shortcuts](https://blog.sqlauthority.com/2007/01/20/sql-server-query-analyzer-shortcuts/): Download Query Analyzer Shortcuts (PDF) Shortcut Function Shortcut Function ALT+BREAK Cancel a query CTRL+SHIFT+F2 Clear all bookmarks ALT+F1 Database object information CTRL+SHIFT+INSERT Insert a template ALT+F4 Exit CTRL+SHIFT+L Make selection lowercase CTRL+A Select all CTRL+SHIFT+M Replace template parameters CTRL+B Move the splitter CTRL+SHIFT+P Open CTRL+C Copy CTRL+SHIFT+R Remove comment CTRL+D Display results in grid format CTRL+SHIFT+S Show client statistics CTRL+Delete Delete through the end of the line CTRL+SHIFT+T Show server trace CTRL+E Execute query CTRL+SHIFT+U Make selection uppercase CTRL+F Find CTRL+T Display results in text format CTRL+F2 Insert/remove bookmark CTRL+U Change database CTRL+F4 Disconnect CTRL+V Paste CTRL+F5 Parse query and check... - [SQL SERVER - Query to find number Rows, Columns, ByteSize for each table in the current database - Find Biggest Table in Database](https://blog.sqlauthority.com/2007/01/10/sql-server-query-to-find-number-rows-columns-bytesize-for-each-table-in-the-current-database-find-biggest-table-in-database/): USE DatabaseName GO CREATE TABLE #temp ( table_name sysname , row_count INT, reserved_size VARCHAR(50), data_size VARCHAR(50), index_size VARCHAR(50), unused_size VARCHAR(50)) SET NOCOUNT ON INSERT #temp EXEC sp_msforeachtable 'sp_spaceused ''?''' SELECT a.table_name, a.row_count, COUNT(*) AS col_count, a.data_size FROM #temp a INNER JOIN information_schema.columns b ON a.table_name collate database_default = b.table_name collate database_default GROUP BY a.table_name, a.row_count, a.data_size ORDER BY CAST(REPLACE(a.data_size, ' KB', '') AS integer) DESC DROP TABLE #temp Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Simple Example of Cursor](https://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/): UPDATE: For working example using AdventureWorks visit : SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2 This is the simplest example of the SQL Server Cursor. I have used this all the time for any use of Cursor in my T-SQL. DECLARE @AccountID INT DECLARE @getAccountID CURSOR SET @getAccountID = CURSOR FOR SELECT Account_ID FROM Accounts OPEN @getAccountID FETCH NEXT FROM @getAccountID INTO @AccountID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @AccountID FETCH NEXT FROM @getAccountID INTO @AccountID END CLOSE @getAccountID DEALLOCATE @getAccountID Reference: Pinal Dave (http://www.SQLAuthority.com), BOL - [SQL SERVER - Shrinking Truncate Log File - Log Full](https://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/): UPDATE: Please follow link for SQL SERVER – SHRINKFILE and TRUNCATE Log File in SQL Server 2008. Sometime, it looks impossible to shrink the Truncated Log file. Following code always shrinks the Truncated Log File to minimum size possible. USE DatabaseName GO DBCC SHRINKFILE(<TransactionLogName>, 1) BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY DBCC SHRINKFILE(<TransactionLogName>, 1) GO [Update: Please note, there are much more to this subject, read my more recent blogs. This breaks the chain of the logs and in future you will not be able to restore point in time. If you have followed this advise, you are recommended to take full... - [SQL SERVER - Fix : Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved.](https://blog.sqlauthority.com/2006/12/20/sql-server-fix-error-14274-cannot-add-update-or-delete-a-job-or-its-steps-or-schedules-that-originated-from-an-msx-server-the-job-was-not-saved/): To fix the error which occurs after the Windows server name been changed, when trying to update or delete the jobs previously created in a SQL Server 2000 instance, or attaching msdb database. Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved. Reason: SQL Server 2000 supports multi-instances, the originating_server field contains the instance name in the format ‘server\instance’. Even for the default instance of the server, the actual server name is used instead of ‘(local)’. Therefore, after the Windows server is renamed, these jobs... - [SQL SERVER - Find Stored Procedure Related to Table in Database - Search in All Stored Procedure](https://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/): Following code will help to find all the Stored Procedures (SP) which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results. ----Option 1 SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so ON sc.id=so.id WHERE sc.TEXT LIKE '%tablename%' ----Option 2 SELECT DISTINCT o.name, o.xtype FROM syscomments c INNER JOIN sysobjects o ON c.id=o.id WHERE c.TEXT LIKE '%tablename%' Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Cursor to Kill All Process in Database](https://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/): When you run the script please make sure that you run it in different database then the one you want all the processes to be killed. CREATE TABLE #TmpWho (spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150), hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150)) INSERT INTO #TmpWho EXEC sp_who DECLARE @spid INT DECLARE @tString VARCHAR(15) DECLARE @getspid CURSOR SET @getspid =   CURSOR FOR SELECT spid FROM #TmpWho WHERE dbname = 'mydb'OPEN @getspid FETCH NEXT FROM @getspid INTO @spid WHILE @@FETCH_STATUS = 0 BEGIN SET @tString = 'KILL ' + CAST(@spid AS VARCHAR(5)) EXEC(@tString) FETCH NEXT FROM @getspid INTO @spid END CLOSE @getspid DEALLOCATE @getspid DROP TABLE #TmpWho... - [SQL SERVER - Simple Cursor to Select Tables in Database with Static Prefix and Date Created](https://blog.sqlauthority.com/2006/11/30/sql-server-cursor-to-process-tables-in-database-with-static-prefix-and-date-created/): Following cursor query runs through the database and find all the table with certain prefixed ('b_','delete_'). It also checks if the Table is more than certain days old or created before certain days, it will delete it. We can have any other operation on that table like to delete, print or index. - [SQL SERVER - Auto Generate Script to Delete Deprecated Fields in Current Database](https://blog.sqlauthority.com/2006/11/20/sql-server-auto-generate-script-to-delete-deprecated-fields-in-current-database/): I always mark fields to be deprecated with “dep_” as prefix. In this way, after few days, when I am sure that I do not need the field any more I run the query to auto generate the deprecation script. The script also checks for any constraint in the system and auto generate the script to drop it also. SELECT 'ALTER TABLE ['+po.name+'] DROP CONSTRAINT [' + so.name + ']' FROM sysobjects so INNER JOIN sysconstraints sc ON so.id = sc.constid INNER JOIN syscolumns col ON sc.colid = col.colid AND so.parent_obj = col.id AND col.name LIKE 'dep[_]%' INNER JOIN sysobjects po ON so.parent_obj = po.id WHERE so.xtype = 'D' ORDER BY po.name, col.name SELECT... - [SQL SERVER - Query to Find ByteSize of All the Tables in Database](https://blog.sqlauthority.com/2006/11/10/sql-server-query-to-find-byte-size/): SELECT CASE WHEN (GROUPING(sob.name)=1) THEN 'All_Tables'    ELSE ISNULL(sob.name, 'unknown') END AS Table_name,    SUM(sys.length) AS Byte_Length FROM sysobjects sob, syscolumns sys WHERE sob.xtype='u' AND sys.id=sob.id GROUP BY sob.name WITH CUBE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database](https://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/): UPDATE : SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database This is very long query. Optionally, we can limit the query to return results for one or more than one table. SELECT K_Table = FK.TABLE_NAME, FK_Column = CU.COLUMN_NAME, PK_Table = PK.TABLE_NAME, PK_Column = PT.COLUMN_NAME, Constraint_Name = C.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME INNER JOIN ( SELECT i1.TABLE_NAME, i2.COLUMN_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1 INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME WHERE i1.CONSTRAINT_TYPE = 'PRIMARY KEY' ) PT ON PT.TABLE_NAME = PK.TABLE_NAME ---- optional: ORDER BY 1,2,3,4 WHERE PK.TABLE_NAME='something'WHERE FK.TABLE_NAME='something'... - [SQL SERVER - INSERT TOP (N) INTO Table - Using Top with INSERT](https://blog.sqlauthority.com/2010/02/27/sql-server-insert-top-n-into-table-using-top-with-insert/): During my recent training at one of the clients, I was asked regarding the enhancement in TOP clause. When I demonstrated my script regarding how TOP works along with INSERT, one of the attendees suggested that I should also write about this script on my blog. Let me share this with all of you and do let me know what you think about this. Note that there are two different techniques to limit the insertion of rows into the table. Method 1: INSERT INTO TABLE … SELECT TOP (N) Cols… FROM Table1 Method 2: INSERT TOP(N) INTO TABLE … SELECT Cols…... - [SQLAuthority News - Keeping Your Ducks in a Row](https://blog.sqlauthority.com/2010/02/26/sqlauthority-news-keeping-your-ducks-in-a-row/): Last year during my visit to SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 2 I have received ducks from the event. Well during the same event I had learned from Jonathan Kehayias the saying of ‘Keeping Your Ducks in a Row‘. The most popular theory suggests that “ducks in a row” came from the world of sports, specifically bowling. Early bowling pins were often shorter and thicker than modern pins, which lead to the nickname ducks. Before the advent of automatic resetting machines, these “duck pins” would be manually put back into place between bowling rounds. Therefore, having... - [SQLAuthority News - MUGH - Microsoft User Group Hyderabad - Feb 2, 2010 Session Review](https://blog.sqlauthority.com/2010/02/25/sqlauthority-news-mugh-microsoft-user-group-hyderabad-feb-2-2010-session-review/): Earlier this month, I was very fortunate to visit Microsoft User Group Hyderabad lead by Hima Vindu Vejella. Hima is a very enthusiastic leader and kind person. I had a wonderful time meeting her as well her husband during my visit to Hyderabad. I had presented session on Index, which was well received. Brief information on this session is given below: The Other Side of SQL Server Index: Advanced Solutions to Ancient Problem SQL Server Index is very powerful tool and when in hand of the less skilled expert, the same tool can pose a danger to its performance and kill... - [SQL SERVER - Introduction to Rollup Clause](https://blog.sqlauthority.com/2010/02/24/sql-server-introduction-to-rollup-clause/): In this article we will go over basic understanding of Rollup clause in SQL Server. ROLLUP clause is used to do aggregate operation on multiple levels in hierarchy. Let us understand how it works by using an example. - [Data Mining Algorithms (Analysis Services - Data Mining)](https://blog.sqlauthority.com/2010/02/23/sqlauthority-news-links-to-book-on-line-data-mining-algorithms-analysis-services-data-mining/): I quite often receive requests for the Data Mining Algorithms details. Book Online has wonderful resources for the same. I suggest to read them here. - [SQLAuthority News - Blog Subscription and Comments RSS](https://blog.sqlauthority.com/2010/02/22/sqlauthority-news-blog-subscription-and-comments-rss/): Quite often I get email where many readers ask me how to get email from SQLAuthority.com blog. Today very quickly I will go over few standard practices of this blog using you can stay connected with SQLAuthority.com First the most important is search: I received hundreds of emails and hundreds of comments every day. I try to answer each of them but if you have any urgent question I strongly suggest to search in my custom SQLAuthority.com Search. It searches in all the blogs as well in the comments. Search @ SQLAuthority.com If you want to stay connected with SQLAuthority.com using... - [SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table)](https://blog.sqlauthority.com/2010/02/21/sql-server-if-existsselect-null-from-table-vs-if-existsselect-1-from-table/): Few days ago I wrote article about SQL SERVER – Stored Procedure Optimization Tips – Best Practices. I received lots of comments on particular blog article. In fact, almost all the comments are very interesting. If you have not read all the comments, I strongly suggest to read them. Click here to read the comments. The most interesting comment conversation is among Divya, Brian and Marko. Please read the comments of Marko for sure. It is the comment, which has triggered this post. Comments by Divya I have seen in one of the blogs to use EXISTS like IF EXISTS(Select null... - [SQL SERVER - Recompile Stored Procedure at Run Time](https://blog.sqlauthority.com/2010/02/20/sql-server-recompile-stored-procedure-at-run-time/): I recently received an email from reader after reading my previous article on SQL SERVER – Plan Recompilation and Reduce Recompilation – Performance Tuning regarding how to recompile any stored procedure at run time. There are multiple ways to do this. If you want your stored procedure to always recompile at run time, you can add the keyword RECOMPILE when you create the stored procedure. Additionally, if the stored procedure has to be recompiled at only one time, in that case, you can add RECOMPILE word one time only and run the SP as well. Let us go over these two options. - [SQLAuthority News - Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1](https://blog.sqlauthority.com/2010/02/19/sqlauthority-news-microsoft-sql-server-migration-assistant-2008-for-mysql-v1-0-ctp1-2/): Microsoft SQL Server Migration Assistant (SSMA) 2008 is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL to SQL Server 2008 and SQL Azure. SSMA 2008 for MySQL v1.0 CTP1 provides an assessment of migration efforts as well as automates schema and data migration. Download Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1 Download Microsoft SQL Server Migration Assistant 2005 for MySQL v1.0 CTP1 Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Plan Recompilation and Reduce Recompilation - Performance Tuning](https://blog.sqlauthority.com/2010/02/18/sql-server-plan-recompilation-and-reduce-recompilation-performance-tuning/): Recompilation process is same as compilation and degrades server performance. In SQL Server 2000 and earlier versions, this was a serious issue but in SQL server 2005, the severity of this issue has been significantly reduced by introducing a new feature called Statement-level recompilation. When SQL Server 2005 recompiles stored procedures, only the statement that causes recompilation is compiled, rather than the entire procedure. Recompilation occurs because of following reason: On schema change of objects. Adding or dropping column to/from a table or view Adding or dropping constraints, defaults, or rules to or from a table. Adding or dropping an index... - [SQLAuthority News - SQL Server Technical Article - The Data Loading Performance Guide](https://blog.sqlauthority.com/2010/02/17/sqlauthority-news-sql-server-technical-article-the-data-loading-performance-guide/): Note: SQL Server Technical Article – The Data Loading Performance Guide by Microsoft The white paper describes load strategies for achieving high-speed data modifications of a Microsoft SQL Server database. “Bulk Load Methods” and “Other Minimally Logged and Metadata Operations” provide an overview of two key and interrelated concepts for high-speed data loading: bulk loading and metadata operations. After this background knowledge, white paper describe how these methods can be used to solve customer scenarios. Script examples illustrating common design pattern are found in “Solving Typical Scenarios with Bulk Loading” Special consideration must be taken when you need to load and... - [SQL SERVER - Stored Procedure Optimization Tips - Best Practices](https://blog.sqlauthority.com/2010/02/16/sql-server-stored-procedure-optimization-tips-best-practices/): We will go over how to optimize Stored Procedure with making simple changes in the code. Please note there are many more other tips, which we will cover in future articles. - [SQL SERVER - Difference Between Update Lock and Exclusive Lock](https://blog.sqlauthority.com/2010/02/15/sql-server-difference-between-update-lock-and-exclusive-lock/): I have often got this question on this blog as well in different SQL Training. What is the difference between Update Lock and Exclusive Lock? When Exclusive Lock is on any processes no other lock can be placed on that row or table. Every other process have to wait till Exclusive Lock is complete its tasks. Update Lock is kind of Exclusive Lock except it can be placed on the row which already have Shared Lock on it. Update Lock reads the data of row which has Shared Lock, as soon as Update Lock is ready to change the data it... - [SQLAuthority News - SuperFlow for Creating SRS Report Models in Configuration Manager 2007](https://blog.sqlauthority.com/2010/02/14/sqlauthority-news-superflow-for-creating-srs-report-models-in-configuration-manager-2007/): Note : Download SuperFlow for Creating SRS Report Models in Configuration Manager 2007 by Microsoft The SuperFlow interactive content model provides a structured and interactive interface for viewing documentation. Each SuperFlow includes comprehensive information about a specific dataflow, workflow, or process. Depending on the focus of the SuperFlow, you will find overview information, steps that include detailed information, procedures, sample log entries, best practices, real-world scenarios, troubleshooting information, security information, animations, or other information. Each SuperFlow also includes links to relevant resources, such as Web sites or local files that are copied to your computer when you install the SuperFlow. The... - [SQLAuthority News - Download SQL Server 2008 Express Datasheet](https://blog.sqlauthority.com/2010/02/13/sqlauthority-news-download-sql-server-2008-express-datasheet/): Microsoft® SQL Server® 2008 Express is a free edition of SQL Server ideal for learning, developing and powering desktop and small server applications and for redistribution by ISVs. Download SQL Server 2008 Express Datasheet Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad Community Tech Days - Jan 30, 2010 - Huge Success](https://blog.sqlauthority.com/2010/02/12/sqlauthority-news-ahmedabad-community-tech-days-jan-30-2010-huge-success/): Ahmedabad Community Tech Days was held on Jan 30, 2010 at Bhaikaka Hall. This event was very received well and attended by a large number of technology enthusiasts and a number of TOP speakers from various technologies. During this event Pinal Dave (myself) and Jacob Sebastian had decided to do something different as the theme was innovation and efficiency. I presented session on SQL Azure, and Jacob presented session on SQL Server R2. This was a bit different than our usual relational SQL Server Presentation. This event was very well received, and we had received great feedback from the attendees. In... - [SQL SERVER - ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE](https://blog.sqlauthority.com/2010/02/11/sql-server-alter-database-dbname-set-single_user-with-rollback-immediate/): I have recently been conducting lots of training on SQL Server technology. During these trainings, I quite often create new databases and drop them as well. Many times, I am not able to drop the database as one of my instances might be using the database. As I am working on my laptop and very confident regarding dropping the database, I always take my database in single user and drop it immediately. ALTER DATABASE [YourDbName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; The above query will rollback any transaction which is running on that database and brings SQL Server database in a single... - [SQLAuthority News - Converting a Delimited String of Values into Columns](https://blog.sqlauthority.com/2010/02/10/sqlauthority-news-converting-a-delimited-string-of-values-into-columns/): This blog post is about two great bloggers and their excellent series of blog posts. It was quite unusual to see two bloggers posting articles that are supporting each other and constantly improving the articles to the next level. Two blogs which I am going to mention here are as follows: SELECT Blog FROM Brad.Schulz CROSS APPLY SQL.Server() – Brad Schulz and Demystifying SQL Server – Adam Haines. Before continuing this blog post, I suggest you all to bookmark these blogs for future reference. The whole thing started when Adam tried to answer the question “How to transform a delimited values... - [SQL SERVER - Brief Note about StreamInsight - What is StreamInsight](https://blog.sqlauthority.com/2010/02/09/sql-server-brief-note-about-streaminsight-what-is-streaminsight/): StreamInsight is a new event processing platform introduced in upcoming version SQL Server 2008 R2. Similar to other components such as SSIS, SSAS or Service Broker, it also needs to be installed along with the SQL Server. Up to SQL Server 2005, Microsoft’s main focus on SQL Server was to build a platform to efficiently store, manage, and retrieve data. However, now, Microsoft enhanced SQL Server to accept, monitor, and respond to complex and high number of events in near zero latency. For this, Microsoft introduced StreamInsight using the following approaches: Continuous and incremental processing of unending sequences of events. Lightweight... - [SQL SERVER - Find the Size of Database File - Find the Size of Log File](https://blog.sqlauthority.com/2010/02/08/sql-server-find-the-size-of-database-file-find-the-size-of-log-file/): I encountered the situation recently where I needed to find the size of the log file. When I tried to find the script by using Search@SQLAuthority.com I was not able to find the script at all. Here is the script, if you remove the WHERE condition you will find the result for all the databases. SELECT DB_NAME(database_id) AS DatabaseName, Name AS Logical_Name, Physical_Name, (size*8)/1024 SizeMB FROM sys.master_files WHERE DB_NAME(database_id) = 'AdventureWorks' GO Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Server 2008 R2 Update for Developers Training Kit](https://blog.sqlauthority.com/2010/02/07/sql-server-sql-server-2008-r2-update-for-developers-training-kit/): Note:   Download SQL Server 2008 R2 Update for Developers Training Kit by Microsoft SQL Server 2008 R2 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2008. The SQL Server 2008 R2 Update for Developers Training Kit is ideal for developers who want to understand how to take advantage of the key improvements introduced in SQL Server 2008 and SQL Server 2008 R2 in their applications, as well as for developers who are new to SQL Server. The training kit is brought to you by Microsoft Developer and Platform Evangelism. Download SQL Server... - [SQLAuthority News - Presenting Two Sessions at TechED Sri Lanka](https://blog.sqlauthority.com/2010/02/06/sqlauthority-news-presenting-two-sessions-at-teched-sri-lanka/): I will be presenting following two sessions at TechEd Sri Lanka this week. I am very excited as this is very first time I will be presenting in TechEd event. I have previously presented many sessions but I have never presented at this premier Microsoft Event. I will be presenting on following two subject. The history of the Log: Change Data Capture (CDC) Pinal Dave on 8-Feb-10 at 02.00 – 03.15 Learn to capture the history of data using CDC. An age old method of writing queries and triggers to capture change in database table is replaced with much powerful asynchronous... - [SQL SERVER - Stream Aggregate Showplan Operator - Reason of Compute Scalar before Stream Aggregate](https://blog.sqlauthority.com/2010/02/05/sql-server-stream-aggregate-showplan-operator-reason-of-compute-scalar-before-stream-aggregate/): I keep a check on the questions received from my readers; when any question crosses my threshold, I surely try to blog about it online. Stream Aggregate is a quite commonly encountered showplan operator. I have often found it in very simple COUNT(*) operation’s execution plan. If you like to read an official note on the subject, you can read the same on Book Online over here. The Stream Aggregate operator groups rows by one or more columns and then calculates one or more aggregate expressions returned by the query. Running the following query will give you Stream Aggregate Operator in... - [SQL SERVER - Get the List of Object Dependencies - sp_depends and information_schema.routines](https://blog.sqlauthority.com/2010/02/04/sql-server-get-the-list-of-object-dependencies-sp_depends-and-information_schema-routines-and-sys-dm_sql_referencing_entities/): Recently, I read a question on my friend‘s SQL site regarding the following: sp_depends does not give appropriate results whereas information_schema. routines do give proper answers. - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010 - Review Part Fun](https://blog.sqlauthority.com/2010/02/03/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010-review-part-fun/): MVP Open Day South Asia was held in Hyderabad from Jan 20, 2010 to Jan 23, 2010. This event was a fun-filled event as well as an educational one. The event was held at Microsoft IDC at Hyderabad, the largest Microsoft Development location after Redmond. I had great time meeting my friends and some of the renowned experts from all over the South Asia. The whole event started with networking with other MVPs as well as Product Group members. Besides lots of learning and meeting experts, this event was filled with fun too. The best thing for me was that I... - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010 - Review Part Business](https://blog.sqlauthority.com/2010/02/02/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010-review-part-business/): MVP Open Day South Asia was held in Hyderabad from Jan 20, 2010 to Jan 23, 2010. This event was a fun-filled as well as an educational event. This event was held at Microsoft IDC at Hyderabad – the largest Microsoft Development location after Redmond. I had a great time meeting my friends and some of the renowned experts from all over the South Asia. The whole event started with networking with other MVPs as well with Product Group members. - [SQL SERVER - Question - How to Convert Hex to Decimal](https://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/): In one of the recent projects, I realize the bottleneck of the query was an inline function which was converting Hex to Decimal. I optimized the inline function and reduced the query running time to one-tenth of the original running time. Later, I was eager to find out the script my blog readers might be using for hex to decimal conversion. Please leave your comments here and I will consider all the valid answers and publish with due credit to the author in one of the future posts. If the script you have posted here is not your original script, I... - [SQL SERVER - Location of Resource Database in SQL Server Editions](https://blog.sqlauthority.com/2010/01/31/sql-server-location-of-resource-database-in-sql-server-editions/): While working on a project of database backup and recovery, I found out that my client was not aware of the resource database at all. Location of Resource. - [SQL SERVER - Several Readers Questions and Readers Answers](https://blog.sqlauthority.com/2010/01/30/sql-server-several-readers-questions-and-readers-answers/): I often get questions on blog and many times I even get answers from readers as well. This article is collection of few of the questions and answers by readers of this blog. Q. How the records of a table can be scripted in INSERT INTO statements? A. In SQL Server 2008 : Right click Database > Tasks > Generate Scripts > In the wizard on Choose Script Option page, set Script Data option to True and complete the wizard.For SQL 2005 or earlier versions, use Database Publishing Wizard. For more details about Database Publishing wizard, please visit the blog https://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/... - [SQLAuthority News - Leadership Quotes and Inspiration](https://blog.sqlauthority.com/2010/01/29/sqlauthority-news-leadership-quotes-inspiration/): There is a big difference between leader and manager. There are plenty of interesting details written on this subject on the internet. In a recent presentation on leadership of one of the organizations I have presented a few of the quotes on the leadership subject to them. The leadership quotes were very much appreciated by the team so I am writing them over here. - [SQLAuthority News - Community Tech Days - Jan 30, 2010 - Must Attend](https://blog.sqlauthority.com/2010/01/28/sqlauthority-news-community-tech-days-jan-30-2010-must-attend/): Attend deep technology sessions for developers and IT professionals, as some of the best-known names come to your city to share their insights in topics ranging from .Net, Visual studio, Silverlight, to Windows and SQL Server. Build connections with Microsoft experts and community members and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. In Ahmedabad this event will happen on January 30, 2010. Just like last event we are expecting this time as well the event will have astonishing success and huge response. We will have five tech sessions back to back... - [SQLAuthority News - SQL Server 2008 R2 - Release Date in May 2010](https://blog.sqlauthority.com/2010/01/27/sqlauthority-news-sql-server-2008-r2-release-date-in-may-2010/): Microsoft has announced that SQL Server 2008 R2 will be available by May 2010. Its CTP (Community Technology Preview) version was already available from August 2009. It is still available for download. - [SQLAuthority News - Download White Paper - Troubleshooting Performance Problems in SQL Server 2008](https://blog.sqlauthority.com/2010/01/26/sqlauthority-news-download-white-paper-troubleshooting-performance-problems-in-sql-server-2008/): Troubleshooting Performance Problems in SQL Server 2008 SQL Server Technical Article Writers: Sunil Agarwal, Boris Baryshnikov, Keith Elmore, Juergen Thomas, Kun Cheng, Burzin Patel Technical Reviewers: Jerome Halmans, Fabricio Voznika, George Reynya Published: March 2009 It’s not uncommon to experience the occasional slowdown of a database running the Microsoft SQL Server database software. The reasons can range from a poorly designed database to a system that is improperly configured for the workload. As an administrator, you want to proactively prevent or minimize problems; if they occur, you want to diagnose the cause and take corrective actions to fix the problem whenever... - [SQL SERVER - Find Statistics Update Date - Update Statistics](https://blog.sqlauthority.com/2010/01/25/sql-server-find-statistics-update-date-update-statistics/): Statistics are one of the most important factors of a database as it contains information about how data is distributed in the database objects (tables, indexes etc). It is quite common to listen people talking about not optimal plan and expired statistics. Quite often I have heard the suggestion to update the statistics if query is not optimal. Please note that there are many other factors for query to not perform well; expired statistics are one of them for sure. If you want to know when your statistics was last updated, you can run the following query. USE AdventureWorks GO SELECT... - [SQLAuthority News - Download Sample Database for Microsoft SQL Server](https://blog.sqlauthority.com/2010/01/24/sqlauthority-news-download-sample-databases-for-microsoft-sql-server-2008-december-2009-samples-refresh-4/): This post is a response to one of the most asked questions where to get Sample Database for SQL Server 2008. The name of the new sample database is AdventureWorks.  - [SQLAuthority News - Remote BLOB Store Provider Library Implementation Specification](https://blog.sqlauthority.com/2010/01/23/sqlauthority-news-remote-blob-store-provider-library-implementation-specification/): Remote BLOB Store Provider Library Implementation Specification logo-sql08.gif SQL Server Technical Article Writers: Kevin Farlee, Pradeep Madhavarapu Technical Reviewer: Pradeep Madhavarapu, Michael Warmington Published: August 2008 Remote BLOB Store (RBS) is designed to move the storage of large binary data (BLOBs) from database servers to commodity storage solutions. With RBS, BLOB data is stored in storage solutions such as Content Addressable Stores (CAS), commodity hardware with data integrity and fault-tolerance systems, or mega service storage solutions like MSN Blue. A reference to the BLOB is stored in the database. An application stores and accesses BLOB data by calling into the RBS... - [SQL SERVER - Execution Plan - Estimated I/O Cost - Estimated CPU Cost - No Unit](https://blog.sqlauthority.com/2010/01/22/sql-server-execution-plan-estimated-io-cost-estimated-cpu-cost-no-unit/): During the SQL Server Optimization training, I enjoy teaching the Execution Plan. I am always sure that questions related to the estimated cost will be raised by attendees. Following are some common questions related to costs: - [SQLAuthority News - Community Tech Days - Jan 30, 2010 - Event Announcement](https://blog.sqlauthority.com/2010/01/21/sqlauthority-news-community-tech-days-jan-30-2010-event-announcement/): Attend deep technology sessions for developers and IT professionals, as some of the best-known names come to your city to share their insights in topics ranging from .Net, Visual studio, Silverlight, to Windows and SQL Server. Build connections with Microsoft experts and community members and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. In Ahmedabad this event will happen on January 30, 2010. Just like last event we are expecting this time as well the event will have astonishing success and huge response. We will have five tech sessions back to back... - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010](https://blog.sqlauthority.com/2010/01/20/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010/): Microsoft has organized an Open Day for all MVP the South Asia MVP.  The MVP Open Day is a three day invitation-only event that is hosted at MSIDC. The event will feature a roster of keynotes and deep dive technical sessions delivered by experts from the product group. Microsoft India Development Center (MSIDC) is one of Microsoft’s largest development centers outside the headquarters in Redmond. The MVP Open Day is an exclusive event for Asia Pacific & Greater China MVPs. MVP is exceptional technical community leader. Microsoft MVP site further explains MVP as “At Microsoft, we believe that by participating in technical... - [SQL SERVER - SSMS Query Command(s) completed successfully without ANY Results](https://blog.sqlauthority.com/2010/01/19/sql-server-ssms-query-commands-completed-successfully-without-any-results/): Yesterday night, I received a phone call from one of my friends with whom I used to work in USA. I was very pleased to receive this call from my old friend after 2 years, but the situation was not good on his side. He said that whatever query he runs, he just receives a message like Query Command(s) completed successfully without any result. However, when he opened a new window, it worked fine. He said he could not figure out the reason for the same and his manager who was standing nearby asked him to find out the reason and... - [SQL SERVER - DMV Error: FIX: Error: Msg 297, Level 16 The user does not have permission to perform this action](https://blog.sqlauthority.com/2010/01/18/sql-server-dmv-error-fix-error-msg-297-level-16-the-user-does-not-have-permission-to-perform-this-action/): I just received an email from one of the readers asking for help with error he encountered while attempting to run DMV. Msg 297, Level 16, State 1, Line 1 The user does not have permission to perform this action. Fix/Solution/Workaround: The above error is usually generated when the user who is trying to run the DMV does not have access to the run the DMV. I suggested him to contact his server admin to grant him VIEW SERVER STATE permissions so that he can run the DMV. Example: If user does not have VIEW SERVER STATE permissions when he runs... - [SQL SERVER - Get Server Version and Additional Info](https://blog.sqlauthority.com/2010/01/17/sql-server-get-server-version-and-additional-info/): It is quite common to get the SQL Server version details from following query. SELECT @@VERSION VersionInfo GO Recently I have been using following SP to get version details as it also provides me few more information about the server where the SQL Server is installed. EXEC xp_msver GO Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] I like to use the second one but again that is my preference. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Windows Azure Platform Training Kit - December Update](https://blog.sqlauthority.com/2010/01/16/sqlauthority-news-download-windows-azure-platform-training-kit-december-update/): Note :  Download Windows Azure Platform Training Kit – December Update by Microsoft I wanted to read some good SQL Azure related to documentation, I tried to do searching online. While searching I landed over Windows Azure Platform Training Kit. This contains lots of SQL Server related content.I downloaded it and started to explore, I suggest if you are interested in Azure Platform you download it as well. The Azure Services Training Kit includes a comprehensive set of technical content including hands-on labs, presentations, and demos that are designed to help you learn how to use the Windows Azure platform including:... - [SQL SERVER - Initializing a Merge Subscription Without a Snapshot](https://blog.sqlauthority.com/2010/01/15/sql-server-initializing-a-merge-subscription-without-a-snapshot/): During recent course of Disaster Recovery and Performance Tuning, I had very interesting conversation with students regarding Initializing a Merge Subscription Without a Snapshot and Initializing a Transactional Subscription Without a Snapshot. After the discussion when we were looking at MSDN pages one thing caught my notice was the note on the top of the MSDN page regarding future support of the feature for Initializing a Merge Subscription Without a Snapshot. In the book on line on the subject Initializing a Merge Subscription Without a Snapshot it suggests that this feature will be deprecated in future, whereas there is no such... - [SQLAuthority News - Vote for SQL Server 2005 Service Pack 4 - Vote for SQL Server 2008 Service Pack 2](https://blog.sqlauthority.com/2010/01/15/sqlauthority-news-vote-for-sql-server-2005-service-pack-4-vote-for-sql-server-2008-service-pack-2/): It has been long time since Microsoft has released SQL Server 2005 SP3 and SQL Server 2008 SP1. It is the time when the new SPs should be released. SQL Server 2005 Service Pack 4 SQL Server 2008 Service Pack 2 Many thanks to Steve Jones of SQLServerCentral.com for this excellent initiative. I voted there, have you voted? Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Busiest Database](https://blog.sqlauthority.com/2010/01/14/sql-server-find-busiest-database/): In my recent training I was asked to how to find which is the busiest database in any SQL Server Instance. What he really meant by this is which database was doing lots of read and write operation. To find the answer to this question I decided to look into the DMV which contains all the details of the executed query. From the DMV sys.dm_exec_query_stats I found three most important columns to determine busiest database. DMV sys.dm_exec_query_stats contained columns total_logical_reads, total_logical_writes, sql_handle. Column sql_handle can help to to determine the original query by CROSS JOINing DMF sys.dm_exec_sql_text. From DMF sys.dm_exec_sql_text Database... - [SQLAuthority News - SQL Server Migration QuickStart](https://blog.sqlauthority.com/2010/01/13/sqlauthority-news-sql-server-migration-quickstart/): The SQL Server Migration QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to help you get details about how to approach your customers who want to improve the return on investment from their data platforms by migrating to SQL Server from their existing Oracle or Sybase platforms. SQL Server Migration QuickStart Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fragmentation - Detect Fragmentation and Eliminate Fragmentation](https://blog.sqlauthority.com/2010/01/12/sql-server-fragmentation-detect-fragmentation-and-eliminate-fragmentation/): Q. What is Fragmentation? How to detect fragmentation and how to eliminate it? A. Storing data non-contiguously on disk is known as fragmentation. Before learning to eliminate fragmentation, you should have a clear understanding of the types of fragmentation. We can classify fragmentation into two types: Internal Fragmentation: When records are stored non-contiguously inside the page, then it is called internal fragmentation. In other words, internal fragmentation is said to occur if there is unused space between records in a page. This fragmentation occurs through the process of data modifications (INSERT, UPDATE, and DELETE statements) that are made against the table... - [SQL SERVER - The server network address "TCP://SQLServer:5023" can not be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418)](https://blog.sqlauthority.com/2010/01/11/the-server-network-address-tcpsqlserver5023-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-that-the-ports-for-the-local-and-remote-endpoints-are-operational-microso/): While doing SQL Mirroring, we receive the following as the most common error: The server network address “TCP://SQLServer:5023” cannot be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418) The solution to the above problem is very simple and as follows. Fix/WorkAround/Solution: Try all the suggestions one by one. Suggestion 1: Make sure that on Mirror Server the database is restored with NO RECOVERY option (This is the most common problem). Suggestion 2: Make sure that from Principal the latest LOG backup is... - [SQLAuthority News - Download - Microsoft Sync Framework Power Pack for SQL Azure November CTP (32-bit)](https://blog.sqlauthority.com/2010/01/10/sqlauthority-news-download-microsoft-sync-framework-power-pack-for-sql-azure-november-ctp-32-bit/): This release features the SQL Azure provider for Microsoft Sync Framework, a plug-in for Visual Studio 2008 Professional SP1 and the tool SQL Azure Data Sync Tool for SQL Server, all of which simplify using Sync Framework and SQL Azure together. Download Microsoft Sync Framework Power Pack for SQL Azure November CTP (32-bit) Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1](https://blog.sqlauthority.com/2010/01/09/sqlauthority-news-microsoft-sql-server-migration-assistant-2008-for-mysql-v1-0-ctp1/): Microsoft SQL Server Migration Assistant (SSMA) 2008 is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL to SQL Server 2008 and SQL Azure. Download Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1 Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad - Gandhinagar SQL Server User Group Meet - Dec 19, 2009](https://blog.sqlauthority.com/2010/01/08/sqlauthority-news-ahmedabad-gandhinagar-sql-server-user-group-meet-dec-19-2009/): Just like every month Ahmedabad and Gandhinagar SQL Server User Group meeting was held on Dec 19, 2009, at Ahmedabad. The interactive meeting was huge success as we had wonderful audience. We had three speakers this time. Tejas Shah talked about “Write CROSS TAB Query with PIVOT”. Tejas is an excellent SQL Expert and a very talented individual. It gives me great pleasure when I see any UG member who updates himself to next level. Tejas has earlier presented many sessions at UG, but this was one of the best sessions. He started with a very basic example and then took... - [SQLAuthority News - Webcasts - Resources for IT Managers and their Teams](https://blog.sqlauthority.com/2010/01/07/sqlauthority-news-webcasts-resources-for-it-managers-and-their-teams/): Pinal Dave and Jacob Sebastian are both SQL Server MVP are doing webcasts for IT Managers and their Teams. Join us for a 4 series webcast as follows: Part 1: Infrastructure and Resource Management for Business Intelligence – Jan 7 Part 2: BI on your desktop – End to end BI solution from MS – Jan 28 Part 3: IT Managers and Mission Critical Data – What, Why, When and How to manage – Feb 4 Part 4: Understanding security and compliance for Enterprise – Feb 11 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON - A Transactional Behavior](https://blog.sqlauthority.com/2010/01/06/sql-server-unique-nonclustered-index-creation-with-ignore_dup_key-on-a-transactional-behavior/): Earlier, I had written on SQL SERVER – Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON, and I received a comment regarding when this option can be useful. On the same day, I met Jacob Sebastian—my close friend and SQL Server MVP, I discussed this question with him. During our discussion, we came up with following example. When we have situation where we are dealing with INSERT and TRANSACTION, we can see this feature in action. Let us consider an example where we have two tables. One table has all the data and the second table has partial data. If you... - [SQL SERVER - SQL Server RDL Specification](https://blog.sqlauthority.com/2010/01/05/sql-server-sql-server-rdl-specification/): Report Definition Language (RDL) is an XML-based schema for defining reports. The goal of RDL is to promote the interoperability of commercial reporting products by defining a common schema that allows interchange of report definitions. To encourage interoperability, RDL includes the notion of compliance levels that products may choose to support. Download the RDL Specifications for SQL Server by clicking the links below. RDL Specification for SQL Server 2008 (.xps format) RDL Specification for SQL Server 2008 (.pdf format) RDL Specification for SQL Server 2005 (.pdf format) RDL Specification for SQL Server 2000 (.pdf format) Abstract courtesy : Microsoft Reference: Pinal... - [SQL SERVER - Fix: Error: 262 : SHOWPLAN permission denied in database](https://blog.sqlauthority.com/2010/01/05/sql-server-fix-error-262-showplan-permission-denied-in-database/): During one of my recent training class when I asked students to check the execution plan using (can be enabled using CTRL+M), they received error as following. Msg 262, Level 14, State 4, Line 1 SHOWPLAN permission denied in database ‘AdventureWorks’. - [SQL SERVER - Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON](https://blog.sqlauthority.com/2010/01/04/sql-server-unique-nonclustered-index-creation-with-ignore_dup_key-on/): In one of my recent training course, I was asked question regarding what is the importance of setting IGNORE_DUP_KEY = ON when creating unique nonclustered index. Here is the short answer: When nonclustered index is created without any option the default option is IGNORE_DUP_KEY = OFF, which means when duplicate values are inserted it throws an error regarding duplicate value. If option is set with syntaxIGNORE_DUP_KEY = ON when duplicate values are inserted it does not thrown an error but just displays warning. Let us try to understand this with example. Option 1: IGNORE_DUP_KEY = OFF Option 2: IGNORE_DUP_KEY = ON... - [SQLAuthority News - TechDays Session at Infosys Mysore 2009 - Change Data Capture and PowerPivot](https://blog.sqlauthority.com/2010/01/03/sqlauthority-news-techdays-session-at-infosys-mysore-2009-change-data-capture-and-powerpivot/): It has been a great pleasure to visit Infosys Mysore for an MSDN session. I had previously visited Infosys Bangalore for Technical session. Please read the details of earlier visit SQLAuthority News – Notes from TechDays 2009 at Infosys, Bangalore. This event was held on Dec 10, 2009. I have been recently presenting the subject of Change Data Capture; it has been great fun as it is a very interesting subject that really captures your attention. It was a well-received session that lasted for nearly 1.5 hours instead of regular 30 min. The smart crowd at Infosys received the subject very... - [SQL SERVER - Find Location of Data File Using T-SQL](https://blog.sqlauthority.com/2010/01/02/sql-server-find-location-of-data-file-using-t-sql/): While preparing for the training course of Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning, I needed to find out where my database files are stored on my hard drive. It is when following script came in handy to find the location of the data file using T-SQL.  - [SQL SERVER - FIX: Error: 1807 Could not obtain exclusive lock on database 'model'. Retry the operation later.](https://blog.sqlauthority.com/2010/01/01/sql-server-fix-error-1807-could-not-obtain-exclusive-lock-on-database-model-retry-the-operation-later/): While working on query optimization project, I encountered following error. Msg 1807, Level 16, State 3, Line 1 Could not obtain exclusive lock on database ‘model’. Retry the operation later. Msg 1802, Level 16, State 4, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors. The resolution of above problem is quick and easy. Fix/Workaround/Solution: Disconnect and Reconnect your SQL Server Management Studio’s session. Your error will go away. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 1200th Post - An Important Milestone](https://blog.sqlauthority.com/2009/12/31/sqlauthority-news-1200th-post-an-important-milestone/): Today is the last day of 2009 and this is my 1200th post! This year had been a wonderful year for me. I was actively involved with the community, and there were a lot of occasions where I could work along with IT professionals to resolve their issues in projects. Today, as this is my 1200th post and last day of 2009, we will go over few but very important milestones of this year (of course, in my life). Instead of longer list, I have decided to list only the most important events. Event listed event are in order of its... - [SQL SERVER - Fix Error 1949, Level 16: Cannot create index on view. The function yields nondeterministic results](https://blog.sqlauthority.com/2009/12/30/sql-server-fix-error-msg-1949-level-16-cannot-create-index-on-view-the-function-yields-nondeterministic-results-use-a-deterministic-system-function-or-modify-the-user-defined-function-to-r/): Recently, during my training session in Hyderabad, one of the attendees wanted to know the reason of the following error that he encountered every time he tried to create a view. He informed me that he is also creating the index using WITH SCHEMABINDING option. Let us see we can fix error 1949. Msg 1949, Level 16, State 1, Line 1 Cannot create index on view . The function yields nondeterministic results. Use a deterministic system function, or modify the user-defined function to return deterministic results. - [SQL SERVER - Get Date of All Weekdays or Weekends of the Year](https://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/): Today’s article is created based on wonderful contribution from Tejas Shah. Tejas is very prominent SQL Expert and .NET wizard. He has answered the query of a reader on this blog who raised the following question: how to generate the date for all the Sundays in the upcoming year. Tejas replied here with a script. What I really liked about the script is that it is very easy to understand, and also it can be customized very quickly. DECLARE @Year AS INT, @FirstDateOfYear DATETIME, @LastDateOfYear DATETIME -- You can change @year to any year you desire SELECT @year = 2010 SELECT... - [SQL SERVER - Difference Temp Table and Table Variable - Effect of Transaction](https://blog.sqlauthority.com/2009/12/28/sql-server-difference-temp-table-and-table-variable-effect-of-transaction/): Few days ago I wrote an article on the myth of table variable stored in the memory—it was very well received by the community. Read complete article here: SQL SERVER – Difference TempTable and Table Variable – TempTable in Memory a Myth. Today, I am going to write an article which follows the same series; in this, we will continue talking about the difference between TempTable and TableVariable. Both have the same structure and are stored in the database — in this article, we observe the effect of the transaction on the both the objects. DECLARE @intVar INT SET @intVar =... - [SQL SERVER - Download FREE SQL SERVER Express Edition and Service Pack 1](https://blog.sqlauthority.com/2009/12/27/sql-server-download-free-sql-server-express-edition-and-service-pack-1/): Here is the quick link from where SQL Server 2008 Express Edition can be downloaded. Download SQL Server 2008 Express Edition You can download it with many additional details as described in following image. Click on above link to go to page and select desired version. Additionally, please install SQL Server 2008 Express Service Pack 1. You can read one of my previous article where I have covered SQL Server 2008 Express in detail SQL SERVER – SQL Server Express – A Complete Reference Guide. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Whitepaper SQL Server 2008 Full-Text Search: Internals and Enhancements](https://blog.sqlauthority.com/2009/12/26/sql-server-whitepaper-sql-server-2008-full-text-search-internals-and-enhancements/): SQL Server 2008 Full-Text Search: Internals and Enhancements SQL Server Technical Article Writer: Fernando Azpeitia Lopez, Microsoft Corp. Published: July 2008 Database systems must go beyond the traditional realm of relational data by covering an increasing amount and variety of unstructured and semistructured information, be it speech, documents, XML, bioinformatics, chemical, or multimedia. Search is a key technology capable of working with vast amounts of data: it is scalable, low-latency, and very user-friendly. It is just what is needed to make a database the best place to store all types of data. SQL Server 2008 introduces a new Full-Text Engine that... - [SQL SERVER - CDC and TRUNCATE - Cannot truncate table because it is published for replication or enabled for Change Data Capture](https://blog.sqlauthority.com/2009/12/25/sql-server-cdc-and-truncate-cannot-truncate-table-because-it-is-published-for-replication-or-enabled-for-change-data-capture/): Few days ago, I got the great opportunity to visit Bangalore Infosys. Please read the complete details for the event here: SQLAuthority News – Notes from TechDays 2009 at Infosys, Bangalore. I mentioned during the session that CDC is asynchronous and it reads the log file to populate its data. I had received a very interesting question during the session. The question is as follows: does CDC feature capture the data during the truncate operation? Answer: It is not possible or not applicable. Truncate is operation that is not logged in the log file, and if one tries to truncate the... - [SQL Authority News - Training SQL Server Query Optimization And Performance Tuning](https://blog.sqlauthority.com/2009/12/24/sql-authority-news-training-ms-sql-server-2005-2008-query-optimization-performance-tuning/): Earlier this year we had offered Query Optimization course and it was sold out in minutes. Due to popular demand we are offering the same course in the very first week of next year. The title of the course is ‘MS SQL Server Query Optimization And Performance Tuning‘. This three day course is an intensive course designed to give attendees an in-depth look at the query optimization and performance tuning concepts and methods found in SQL Server. This course is designed to prepare the SQL Server developers and administrators for a transition to SQL Server while discussing best practices for a variety of topics. - [SQL SERVER - ORDER BY Clause and TOP WITH TIES](https://blog.sqlauthority.com/2009/12/23/sql-server-order-by-clause-and-top-with-ties/): Recently, on this blog, I published an article on SQL SERVER – Interesting Observation – TOP 100 PERCENT and ORDER BY; this article was very well received because of the observation made in it. One of the comments suggested the workaround was to use clause WITH TIES along with TOP and ORDER BY. That is not the correct solution; however, but the same comment brings up the question regarding how WITH TIES clause actually works. First of all, the clause WITH TIES can be used only with TOP and ORDER BY, both the clauses are required. Let us understand from one... - [SQLAuthority News - Meeting SQL Expert Imran at Hyderabad](https://blog.sqlauthority.com/2009/12/22/sqlauthority-news-meeting-sql-expert-imran-at-hyderabad/): I was very fortunate to meet the SQL Server Expert and one of the top participants of this blog Imran Mohammed. Imran has been very active on this blog and have previously contributed with few articles as well. I have been communicating with Imran for a long time; he is always very active and quick to reply. Many times, he has solved various difficult problems of readers which. He always goes an extra mile to resolve such problems – once I happened to see him spend more than 10 hours to solve a problem posed by a reader. When I met... - [SQL SERVER - Comma Separated Values (CSV) from Table Column - Part 2](https://blog.sqlauthority.com/2009/12/21/sql-server-comma-separated-values-csv-from-table-column-part-2/): In my earlier post, I wrote about how one can use XML to convert table to string SQL SERVER – Comma Separated Values (CSV) from Table Column. The same article is also published on channel 9 SQLAuthority News – Featured on Channel 9. One of the very interesting points that was discussed on show was about the usage of function SUBSTRING. I found the following point very valid: SUBSTRING usage limits the length of the XML to be used. I have re-written the same function with function STUFF, and it removes any limit imposed on the script. USE AdventureWorks GO --... - [SQLAuthority News - Migrating DTS Packages to Integration Services](https://blog.sqlauthority.com/2009/12/20/sqlauthority-news-migrating-dts-packages-to-integration-services/): Migrating DTS Packages to Integration Services Writer: Brian Knight Published: July 2008 SQL Server Integration Services (SSIS) brings a revolutionary concept of enterprise-class ETL to the masses. The engine is robust enough to handle hundreds of millions of rows with ease, but is simple enough to let both developers and DBAs engineer an ETL process. In this whitepaper, you will see the benefits of migrating your SQL Server 2000 Data Transformation Services (DTS) packages to Integration Services by using two proven methods. You will also see how you can run and manage your current DTS packages inside of the SQL Server... - [SQLAuthority News - Migrating to SQL Server from Other Database Products](https://blog.sqlauthority.com/2009/12/19/sqlauthority-news-migrating-to-sql-server-from-other-database-products/): Guide to Migrating from MySQL to SQL Server 2008 In this migration guide you will learn the differences between the MySQL and SQL Server 2008 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2008 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2008. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. The entire migration process using SQL Server Migration Assistant (SSMA) 2008 for Oracle is explained... - [SQL SERVER - Differences in Vulnerability between Oracle and SQL Server](https://blog.sqlauthority.com/2009/12/18/sql-server-differences-in-vulnerability-between-oracle-and-sql-server/): In the IT world, but not among experienced DBAs, there has been a long-standing myth that the Oracle database platform is more stable and more secure than SQL Server from Microsoft. This is due to a variety of reasons; but in my opinion, the main ones are listed below: A. Microsoft development platforms are generally more error-prone and full of bugs. This (unfairly) projects the weaknesses of earlier versions of Windows onto its other products such as SQL Server, which is a very stable and secure platform in its own right. B. Oracle has been around for longer than SQL Server... - [SQLAuthority News - Hub-And-Spoke: Building an EDW with SQL Server and Strategies of Implementation](https://blog.sqlauthority.com/2009/12/17/sqlauthority-news-hub-and-spoke-building-an-edw-with-sql-server-and-strategies-of-implementation/): Hub-And-Spoke: Building an EDW with SQL Server and Strategies of Implementation logo-sql08.gif SQL Server Technical Article Writers: Mark Theissen, Eric Kraemer Published: February 2009 To date, the implementation of a true hub-and-spoke architecture for a data warehouse environment has been an idealized and elusive goal. Although building a centralized “hub,” or enterprise data warehouse (EDW) that supports company-wide detail data is achievable, building and maintaining “spokes,” or dependent departmental data marts has proved to be the challenge. Most data warehouse environments have evolved to one of two architectures: a centralized EDW or a series of distributed and/or federated data marts. In... - [SQL SERVER - Fillfactor, Index and In-depth Look at Effect on Performance](https://blog.sqlauthority.com/2009/12/16/sql-server-fillfactor-index-and-in-depth-look-at-effect-on-performance/): I would like to start this post with an interesting question: Where in MS SQL Server is “100” equals to “0”?  And I am not talking about data types now.. Today I will be presenting the answer to this question and some topics related to it. Creating Indices in SQL Server is one of the most important tasks of any SQL DBA. Performance of your database is directly depends on your skills and proficiency in creating and maintaining the right number and quality of indices.. As a DBA, you can use “FILLFACTOR,” which is one of the important arguments that can... - [SQL SERVER - Difference TempTable and Table Variable - Table Variable in Memory a Myth](https://blog.sqlauthority.com/2009/12/15/sql-server-difference-temptable-and-table-variable-temptable-in-memory-a-myth/): Recently, I have been conducting many training sessions at a leading technology company in India. During the discussion of temp table and table variable, I quite commonly hear that Table Variables are stored in memory and Temp Tables are stored in TempDB. I would like to bust this misconception by suggesting following: Temp Table and Table Variable — both are created in TempDB and not in memory. Let us prove this concept by running the following T-SQL script. /* Check the difference between Temp Table and Memory Tables */ -- Get Current Session ID SELECT @@SPID AS Current_SessionID -- Check the space usage in page files SELECT user_objects_alloc_page_count FROM sys.dm_db_session_space_usage WHERE session_id = (SELECT @@SPID ) GO -- Create Temp Table and insert three thousand rows CREATE TABLE #TempTable (Col1... - [SQLAuthority News - An Year of Personal Events - A Life Outside SQL](https://blog.sqlauthority.com/2009/12/14/sqlauthority-news-an-year-of-personal-events-a-life-outside-sql/): Today I will keep the words very short and will convey story in three simple photographs. This post answers the question – “Do I have life outside SQL?” YES! I do and it is very beautiful. December 12, 2009 September 1, 2009 December 12, 2008 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - White Paper - Partitioned Table and Index Strategies Using SQL Server 2008](https://blog.sqlauthority.com/2009/12/13/sql-server-white-paper-partitioned-table-and-index-strategies-using-sql-server-2008/): Partitioned Table and Index Strategies Using SQL Server 2008 Writer: Ron Talmage, Solid Quality Mentors Technical Reviewer: Denny Lee, Wey Guy, Kevin Cox, Lubor Kollar, Susan Price – Microsoft Greg Low, Herbert Albert – Solid Quality Mentors When a database table grows in size to the hundreds of gigabytes or more, it can become more difficult to load new data, remove old data, and maintain indexes. Just the sheer size of the table causes such operations to take much longer. Even the data that must be loaded or removed can be very sizable, making INSERT and DELETE operations on the table... - [SQLAuthority News - Featured on Channel 9](https://blog.sqlauthority.com/2009/12/12/sqlauthority-news-featured-on-channel-9/): This blog was featured on Channel 9 MSDN over here : TWC9: Scott Hanselman, Jon Galloway, Bing, parallel unit tests, more. I was very proud that this blog was discussed for more than 5 mins (from min 18 to min 23) on my favorite online show. Scott Hanselman, Jon Galloway along with Dan Fernandez make this show very live and very very entertaining. The article which was featured in the show is SQL SERVER – Comma Separated Values (CSV) from Table Column. Here are few screenshot from the show. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ERROR: FIX: Cannot drop server because it is used as a Distributor in replication](https://blog.sqlauthority.com/2009/12/11/sql-server-error-fix-cannot-drop-server-because-it-is-used-as-a-distributor-in-replication/): Replication has been my favorite subject when it comes to resolving errors. I have found that many DBAs are stuck with the solving of the problem of replication for hours; however, the solution is very easy. One of the very common errors in replication occurs when replication is removed from any server. I have seen the following error as one attempts to remove replication from the same server when the publisher and distributor are on the same server. Cannot drop server ‘repl_distributor’ because it is used as a Distributor in replication. Cannot drop the distribution database ‘distribution’ because it is currently... - [SQL SERVER - Future of Business Intelligence](https://blog.sqlauthority.com/2009/12/10/sql-server-future-of-business-intelligence/): Business Intelligence (BI) is slated to play bigger roles in all kinds of businesses in the coming years. This is not surprising as data analysis and smarter decision making has made the use of BI inevitable in all sizes of businesses across all sectors, including Real estate, IT, mobile devices, governmental agencies, scientific and engineering communities and R&D labs, banking and insurance, to name a few. BI can effectively deal with industry-specific constraints, operations and objectives thereby helping organizations to better understand their customers, optimize their operations, minimize risk, manage revenue, and ultimately improve their results. Moreover, the changing economic environment,... - [SQL SERVER - Business Intelligence - Aligning Business Metrics](https://blog.sqlauthority.com/2009/12/09/sql-server-business-intelligence-aligning-business-metrics/): Today, executive management and managers need the latest information to drive intelligent decisions for business success. More informed decisions mean more revenue, less risk, decreased cost, and improved operational control for business agility and competitiveness. Besides, in today’s fast paced, technology-driven business world, organizations are continually struggling to deal with growing data volumes and complexity to use their own data efficiently. Constrained with competitive environments and data complexity are COO, IT Managers and Business Consultants who are asking for less information more easily for smarter, faster decision-making. They want information that is highly visual, up-to-date, personalized and secure. Also, they want... - [SQL SERVER - Fix : Error : Invalid object name 'sys.configurations'. (Microsoft SQL Server, Error: 208)](https://blog.sqlauthority.com/2009/12/08/sql-server-fix-error-invalid-object-name-sys-configurations-microsoft-sql-server-error-208/): As you all know that SQL Azure CTP has been released; here, I have included a step-by-step guide for how to configure the CTP: SQL SERVER – Azure Start Guide – Step by Step Installation Guide. For pricing and introduction, please read SQLAuthority News – SQL Azure – Microsoft SQL Data Services – Introduction and Pricing. I received many comments times when people are connected to the SQL Azure they receive following error. Invalid object name ‘sys.configurations’. (Microsoft SQL Server, Error: 208) Fix/Workaround/Solution: 1. Close out all the Connect to Server Dialogue 2. Click on the New Query button from the... - [SQL Server - White Paper - An Introduction to Fast Track Data Warehouse Architectures by Erik Veerman](https://blog.sqlauthority.com/2009/12/07/sql-server-white-paper-an-introduction-to-fast-track-data-warehouse-architectures-by-erik-veerman/): An Introduction to Fast Track Data Warehouse Architectures SQL Server Technical Article Writer: Erik Veerman, Solid Quality Mentors Technical Reviewer: Mark Theissen, Scotty Moran, Val Fontama Published: February 2009 The performance and stability of any application solution—whether line of business, transactional, or business intelligence (BI)—hinges on the integration between solution design and hardware platform. Choosing the appropriate solution architecture—especially for BI solutions—requires balancing the application’s intended purpose and expected use with the hardware platform’s components. Poor planning, bad design, and misconfigured or improperly sized hardware often lead to ongoing, unnecessary spending and, even worse, unsuccessful projects. The ultimate goal of the... - [SQL SERVER - White Papers - Consolidation Guidance for SQL Server - Consolidation Using SQL Server 2008](https://blog.sqlauthority.com/2009/12/06/sql-server-white-papers-consolidation-guidance-for-sql-server-consolidation-using-sql-server-2008/): Consolidation Using SQL Server 2008 Writer: Allan Hirt, Megahirtz LLC (allan@sqlha.com) Technical Reviewers: Lindsey Allen, Madhan Arumugam, Ben DeBow, Sung Hsueh, Rebecca Laszlo, Claude Lorenson, Prem Mehra, Mark Pohto, Sambit Samal, and Buck Woody Published: October 2009 What are the considerations when creating a consolidation plan for my environment? What are the key differentiators among the three consolidation options? How can I use these differentiators to choose the appropriate consolidation option for my environment? Read Consolidation Guidance for SQL Server Many companies are considering or have already implemented consolidation of computing resources, including Microsoft SQL Server instances and databases, in their... - [SQLAuthority News - Notes from TechDays 2009 at Infosys, Bangalore](https://blog.sqlauthority.com/2009/12/05/sqlauthority-news-notes-from-techdays-2009-at-infosys-bangalore/): I recently had opportunity to attend TechDays 2009 Infosys. The dates of the event was Nov 16-17, 2009. This event was the largest technology conference by Microsoft in Infosys. Microsoft Tech Days focused on positioning Microsoft as the company to bet on for future technology investments by businesses and consumers alike. The event was a showcase of Microsoft’s products and solutions to technologists, decision-makers, technology influencers, and analysts. The in-campus event in Infosys was attended by 2500 tech professionals and decision makers. The event was also broadcast live to all non-Bangalore Infosys locations by using Infosys’ internal infrastructure. 2.5K Attendees I... - [SQL SERVER - 2008 Star Join Query Optimization](https://blog.sqlauthority.com/2009/12/04/sql-server-2008-star-join-query-optimization/): Business Intelligence (BI) plays a significant role in businesses nowadays. Moreover, the databases that deal with the queries related to BI are presently facing an increase in workload. At present, when queries are sent to very large databases, millions of rows are returned. Also the users have to go through extended query response times when joining multiple tables are involved with such queries. ‘Star Join Query Optimization’ is a new feature of SQL Server 2008 Enterprise Edition. This mechanism uses bitmap filtering for improving the performance of some types of queries by the effective retrieval of rows from fact tables. Improved... - [SQLAuthority News - Airline Review - Paramount, Kingfisher, Go Air, Indigo, Jet Airways, Indian Airlines, Spicejet ](https://blog.sqlauthority.com/2009/12/03/sqlauthority-news-airline-review-paramount-kingfisher-go-air-indigo-jet-airways-indian-airlines-spicejet/): First of all, this is a totally different article that I have ever written on this site. As the regular readers of my blog are aware that I am always traveling due to my different assignments at work. In last two months, I have been on flight for 36 times; this makes me a regular air traveler, who travels almost every other day. For instance, considering a month of 24 days (excluding the weekends), for two months, there are 48 business days. In such case, I was almost on air always! There are many airlines in India, and I have traveled... - [SQL SERVER - Validate an XML Document in TSQL using XSD by Jacob Sebastian](https://blog.sqlauthority.com/2009/12/02/sql-server-validate-an-xml-document-in-tsql-using-xsd-by-jacob-sebastian/): Let us learn about XML Document in TSQL using XSD by Jacob Sebastian. - [SQLAuthority News - A Daily Doze of Technology - Alvin Ashcraft's Morning Dew](https://blog.sqlauthority.com/2009/12/01/sqlauthority-news-a-daily-doze-of-technology-alvin-ashcrafts-morning-dew/): A common question that I receive is regarding how I keep myself updated with latest information about technology and what is going on at present. I read lots of blogs and books. I am usually traveling 4 days in my any regular work week. I read physical books at the time. I prefer to read the books in hard copy and not on the computer screen. If you ever spot me reading books, quite often you can see me with a fiction book rather than a SQL Book. Ok… So the question is what do I read to keep myself updated... - [SQL SERVER - Size of Index Table for Each Index - Solution](https://blog.sqlauthority.com/2009/11/30/sql-server-size-of-index-table-for-each-index-solution/): Earlier I have posted small question on this blog and requested help from readers to participate here and provide solution. Please read the original Puzzle here. SQL SERVER – Size of Index Table – A Puzzle to Find Index Size for Each Index on Table The puzzle was to write a query that will return the size for each index that is on any particular table. We need a query that will return an additional column in the above listed query and it should contain the size of the index. So far I have found two potential solutions. I have done... - [SQL SERVER - Azure Start Guide - Step by Step Installation Guide](https://blog.sqlauthority.com/2009/11/29/sql-server-azure-start-guide-step-by-step-installation-guide/): As SQL Azure CTP is released I have included here step by step guide for how to configure the CTP. For pricing and introduction please read SQLAuthority News – SQL Azure – Microsoft SQL Data Services – Introduction and Pricing First it has to be configured online at Login using your Live ID Type in invitation code received from Microsoft for CTP. You can request one for your self here. Accept the TOU. Once logged it you will have to create server username and password. Click on my project and it will provide you details about your servername where your data... - [SQLAuthority News - SQL Server R2 Resources Downloads, Documentations](https://blog.sqlauthority.com/2009/11/28/sqlauthority-news-sql-server-r2-resources-downloads-documentations/): Microsoft SQL Server 2008 R2 November Community Technology Preview Building on SQL Server 2008, R2 provides an even more scalable data platform with comprehensive tools for managing your databases and applications, improving the quality of your data, and empowering your users to build rich analyses and reports using tools they are already familiar with. Microsoft SQL Server 2008 R2 November Community Technology Preview Feature Pack The Microsoft SQL Server 2008 R2 Feature Pack is a collection of stand-alone packages which provide additional value for SQL Server 2008 R2. SQL Server 2008 R2 Books Online Community Technology Preview November 2009 Download the... - [SQLAuthority News - Subscribe to Blog - Search a Blog](https://blog.sqlauthority.com/2009/11/27/sqlauthority-news-subscribe-to-blog-search-a-blog/): Quite often I get request if I send blog post in newsletter or through email. Here are few important links. You can for sure get email of my post, however, I strongly suggest to visit blog as if there are any updates in my post they are reflected on blog. Subscribe to blog post through email Subscribe SQLAuthority Feed Search SQLAuthority – This is very powerful search. Give it a try. Follow me on Twitter Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server 2008 Analysis Services Performance Guide](https://blog.sqlauthority.com/2009/11/26/sqlauthority-news-sql-server-2008-analysis-services-performance-guide/): Because Microsoft SQL Server Analysis Services query and processing performance tuning is a fairly broad subject, this white paper organizes performance tuning techniques into the following three segments. Enhancing Query Performance – Query performance directly impacts the quality of the end user experience. As such, it is the primary benchmark used to evaluate the success of an online analytical processing (OLAP) implementation. Analysis Services provides a variety of mechanisms to accelerate query performance, including aggregations, caching, and indexed data retrieval. In addition, you can improve query performance by optimizing the design of your dimension attributes, cubes, and Multidimensional Expressions (MDX) queries.... - [SQL SERVER - Comma Separated Values (CSV) from Table Column](https://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/): I use following script very often and I realized that I have never shared this script on this blog before. Creating Comma Separated Values (CSV) from Table Column is a very common task, and we all do this many times a day. Let us see the example that I use frequently and its output. - [SQL SERVER - Interesting Observation - TOP 100 PERCENT and ORDER BY](https://blog.sqlauthority.com/2009/11/24/sql-server-interesting-observation-top-100-percent-and-order-by/): Today we will go over a very simple, but interesting subject. The following error is quite common if you use ORDER BY while creating any view: Msg 1033, Level 15, State 1, Procedure something, Line 5 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. The error also explains the solution for the same – use of TOP. I have seen developers and DBAs using TOP very causally when they have to use the ORDER BY clause. Theoretically, there is no need of ORDER BY... - [SQL SERVER - A Common Design Problem - Should the Primary Key Always be a Clustered Index](https://blog.sqlauthority.com/2009/11/23/sql-server-a-common-design-problem-should-the-primary-key-always-be-a-clustered-index/): In SQL Server, whenever we create any key, a Primary Key automatically creates clustered index on the same. I like this feature and I use this feature every now and then. The question is does the change of any column as Primary Key should also create a Clustered Index? Moreover, is there any case, where one would not do the same? One of the recent conversations I had with one SQL Expert is with regard to the SSN number. The discussion was that SSN numbers are always unique and never repeated and hence are the best candidates for primary key. Additionally... - [SQL SERVER - Remove Bookmark Key Lookup - 4 Different Ideas](https://blog.sqlauthority.com/2009/11/22/sql-server-remove-bookmark-key-lookup-4-different-ideas/): I quite often get request to summarized my ideas about Removing bookmark lookup on this blog post. Bookmark lookup or key lookup are bad for any query as they force query engine to lookpup corresponding row in the table or index as it does not find required data from just reading the data. Here are list of my four post written on the same subject. SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup – Part... - [SQL SERVER - Clear Drop Down List of Recent Connection From SQL Server Management Studio](https://blog.sqlauthority.com/2008/11/05/sql-server-clear-drop-down-list-of-recent-connection-from-sql-server-management-studio/): Quite often it happens that SQL Server Management Studio’s Dropdown box is cluttered with many different SQL Server’s name. Sometime it contains the name of the server which does not exist or developer does not have access to it. It is very easy to clean the list and start over. Delete mru.dat file from following location. For SQL Server 2005: C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat If you can not find mru.dat at above location look for mru.dat in following folder. C:\Documents and Settings\[user]\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM\mru.dat For SQL Server 2008: C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\mru.dat If you can not... - [SQL SERVER - Fix : Error: 4064 - Cannot open user default database. Login failed. Login failed for user](https://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/): I have received following question nearly 10 times in last week though emails. Many users have received following error while connecting to the database. This error happens when database is dropped for which is default for some of the database user. When user try to login and their default database is dropped following error shows up. Cannot open user default database. Login failed. Login failed for user ‘UserName’. (Microsoft SQL Server, Error: 4064) The fix for this problem is very simple. Fix/Workaround/Solution: First click on Option>> Button of “Connect to Server” Prompt. Now change the connect to database to any existing... - [SQLAuthority News - SQL Server Security Whitepapers](https://blog.sqlauthority.com/2008/11/03/sqlauthority-news-sql-server-security-whitepapers/): Microsoft has published following three security related white papers. I suggest to all my readers to read them. Read the summary know what is covered in those  white papers. Engine Separation of Duties for the Application Developer – Separation of duties is an important consideration for databases and database applications. By properly defining schemas and roles, you can create a distinction between users who can manipulate data from those that administer the database. This paper discusses the topics of which application developers should be aware and provides a heuristic example to guide you in achieving separation of duties. Database Encryption in... - [SQL SERVER - Fix : Error : Login failed for user 'UserName'. The user is not associated with a trusted SQL Server connection](https://blog.sqlauthority.com/2008/11/02/sql-server-fix-error-login-failed-for-user-username-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Recently I have got two desktop computers at home and both of them are very powerful machine. Machine 1 : Windows Vista SP1 with SQL Server 2008 Machine 2 : Windows 2003 with SQL Server 2005 with SP2 When I was trying to connect from SQL Server 2008 to SQL Server 2005 using Windows Authentication I was getting following error. Login failed for user ‘UserName’. The user is not associated with a trusted SQL Server connection. To resolve this error follow the steps below on computer with SQL Server 2005. Create new user with Administrator privilege with same username and password... - [SQL SERVER - Stored Procedure WITH ENCRYPTION and Execution Plan](https://blog.sqlauthority.com/2008/11/01/sql-server-stored-procedure-with-encryption-and-execution-plan/): Stored Procedures are very important and most of the business logic of my applications are always coded in Stored Procedures. Sometime it is necessary to hide the business logic from end user due to security reasons or any other reason. Keyword WITH ENCRYPTION is used to encrypt the text of the Stored Procedure. One SP are encrypted it is not possible to get original text of the SP from SP itself. User who created SP will need to save the text to be used to create SP somewhere safe to reuse it again. Interesting observation: What prompted me to write this... - [SQL SERVER - DECLARE Multiple Variables in One Statement](https://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/): Just a day ago, while I was enjoying mini vacation during festival of Diwali I met one of the .NET developer who is big fan of Oracle. While discussing he suggested that he wished SQL Server should have feature where multiple variable can be declared in one statement. I requested him to not judge wonderful product like SQL Server with just one feature. SQL Server is great product and it has many feature which are very unique to SQL Server. Regarding feature of SQL Server where multiple variable can be declared in one statement, it is absolutely possible to do. Method... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2008/10/30/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007/): Note:   Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Feature Bullet Summary: The following list gives an overview of the features of the SQL Server management pack. Refer to the SQL Server management pack guide for more detail. Support for Enterprise, Standard and Express... - [SQLAuthority News - Download SQL Server 2005 Service Pack 3 - CTP](https://blog.sqlauthority.com/2008/10/29/sqlauthority-news-download-sql-server-2005-service-pack-3-ctp/): The CTP version of SQL Server 2005 Service Pack 3 (SP3) is now available. You can use these packages to upgrade any of the following SQL Server 2005 editions: Enterprise Enterprise Evaluation Developer Standard Workgroup For a summary list of What’s new in SQL Server 2005 SP3 CTP, review the What’s New document. These packages have been made available for general testing purposes only. Do not deploy the CTP software in production. Download SQL Server 2005 Service Pack 3 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Happy Diwali to All of You](https://blog.sqlauthority.com/2008/10/28/sqlauthority-news-happy-diwali-to-all-of-you/): SQLAuthority Wishes Happy Diwali to All of You. Diwali is one of the important Hindu festivals, which comprises of four consecutive days of celebrations. - [SQLAuthority News - Download Microsoft SQL Server 2008 Feature Pack, October 2008](https://blog.sqlauthority.com/2008/10/27/sqlauthority-news-download-microsoft-sql-server-2008-feature-pack-october-2008/): Note: Download Microsoft SQL Server 2008 Feature Pack, October 2008 by Microsoft - [SQLAuthority News - Definition - Outsourcing, Offshoring, Nearshoring, Offshore Outsourcing](https://blog.sqlauthority.com/2008/10/26/sqlauthority-news-definition-outsourcing-offshoring-nearshoring-offshore-outsourcing/): Outsourcing - Outsourcing is subcontracting a process, such as product design or manufacturing, to a third-party company. Outsourcing involves the transfer of the management and/or day-to-day execution of an entire business function to an external service provider. - [SQL SERVER - INNER JOIN using LEFT JOIN statement - Performance Analysis](https://blog.sqlauthority.com/2008/10/25/sql-server-inner-join-using-left-join-statement-performance-analysis/): Just a day ago, while I was working with JOINs I find one interesting observation, which has prompted me to create following example. Before we continue further let me make very clear that INNER JOIN should be used where it can not be used and simulating INNER JOIN using any other JOINs will degrade the performance. If there are scopes to convert any OUTER JOIN to INNER JOIN it should be done with priority. Run following two script and observe the resultset. Resultset will be identical. USE AdventureWorks GO / Example of INNER JOIN / SELECT p.ProductID, piy.ProductID FROM Production.Product p INNER JOIN Production.ProductInventory piy ON piy.ProductID = p.ProductID... - [SQLAuthority News - TOP Downloads - Bookmark](https://blog.sqlauthority.com/2008/10/24/sqlauthority-news-top-downloads-bookmark/): Recently I have gotten many, many requests for SQL Server Interview Questions and Answers as well as related articles. It seems many people are looking for Job or appearing for an interview at this time of the year. I have included lists of the my top downloads in the sidebar of the blog, still I receive many curious questions as side bar does not show up in the RSS feed. - [Author Visit - MVP Open Day 2008 - Goa - November 15-17](https://blog.sqlauthority.com/2008/10/23/author-visit-mvp-open-day-2008-goa-november-15-17/): I will be attending MVP Open Day 2008 in Goa from November 15 to November 17. I am eagerly waiting to attend the Open Day. If you are in Goa during that time we can meet sometime in evening after sessions are over. Following is the comics related to MVP Open Day 2008. - [SQLAuthority News - Running SQL Server 2008 in a Hyper-V Environment Best Practices and Performance Considerations](https://blog.sqlauthority.com/2008/10/22/sqlauthority-news-running-sql-server-2008-in-a-hyper-v-environment-best-practices-and-performance-considerations/): Hyper-V in Windows Server 2008 is a powerful virtualization technology that can be used by corporate IT to consolidate under-utilized servers, lowering TCO and maintaining or improving Quality of Service. Through a series of test scenarios that are representative of SQL Server application fundamentals, this document provides best practice recommendations on running SQL Server in Windows Hyper-V environment. White paper talks about many subjects and various topics. I enjoyed reading following sections. Setup and Configuration of Hyper-V Configurations Hyper-V Preinstall Checklist and Considerations Storage Configuration Recommendations Monitoring SQL Server on Hyper-V Configurations Test Methodology, Workloads Results, Observations, and Recommendations Different kind... - [SQL SERVER - Fix : Error : Incorrect syntax near. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel](https://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/): I have seen developers confused many times when they receive the following error message. Incorrect syntax near. Let us learn. - [SQL SERVER - Transaction and Local Variables - Swap Variables - Update All At Once Concept](https://blog.sqlauthority.com/2008/10/20/sql-server-transaction-and-local-variables-swap-variables-update-all-at-once-concept/): This article is inspired from two sources. Let us learn today about how to swap variables by updating everything at once concepts. 1) My year old article - SQL SERVER - Effect of TRANSACTION on Local Variable - After ROLLBACK and After COMMIT 2) Discussion with SQL Server MVP - Jacob Sebastian - SQLAuthority News - Author Visit - SQL Hour at Patni Computer Systems I usually summarize my article at the end, but this time let me summarize first and we will understand the article next. - [SQL SERVER - Introduction to CLR - Simple Example of CLR Stored Procedure](https://blog.sqlauthority.com/2008/10/19/sql-server-introduction-to-clr-simple-example-of-clr-stored-procedure/): CLR is abbreviation of Common Language Runtime. In SQL Server 2005 and later version of it database objects can be created which are created in CLR. Stored Procedures, Functions, Triggers can be coded in CLR. CLR is faster than T-SQL in many cases. CLR is mainly used to accomplish task which are not possible by T-SQL or can use lots of resources. CLR can be usually implemented where there is intense string operation, thread management or iteration methods which can be complicated for T-SQL. Implementing CLR provides more security to Extended Stored Procedure. Let us create one very simple CLR where... - [SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice - Part 2](https://blog.sqlauthority.com/2008/10/18/sql-server-retrieve-select-only-date-part-from-datetime-best-practice-part-2/): A year ago I wrote post about SQL SERVER – Retrieve – Select Only Date Part From DateTime – Best Practice where I have discussed two different methods of getting datepart from datetime. Method 1: SELECT DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())) Method 2: SELECT CONVERT(VARCHAR(10),GETDATE(),111) I have summarized my post suggesting that either method works fine and I prefer to use Method 2. However, with additional tests and looking at SQL Server internals very carefully, I want to suggest that Method 1 is better in terms of performance. While running on GETDATE() both of the above functions are equally fast and... - [SQL SERVER - Get Common Records From Two Tables Without Using Join](https://blog.sqlauthority.com/2008/10/17/sql-server-get-common-records-from-two-tables-without-using-join/): I really enjoy answering questions which I receive from either comments or Email. My passion is shared by SQL Server Expert Imran Mohammed. He frequently SQL community members by answering their questions frequently and promptly. Sachin Asked: Following is my scenario, Suppose Table 1 and Table 2 has same column e.g. Column1 Following is the query, 1. Select column1,column2 From Table1 2. Select column1 From Table2 I want to find common records from these tables, but i don’t want to use Join clause bcoz for that i need to specify the column name for Join condition. Will you help me to... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting - October 2008](https://blog.sqlauthority.com/2008/10/17/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-october-2008/): Tomorrow is third Saturday of the Month and every third Saturday we have Ahmedabad User Group Meeting. Our user group is growing and getting interesting. Everybody who attended last months User Group (UG) Meeting realized that how important it is to attend UG meetings. UG President Jacob Sebastian (SQL Server – MVP) presented excellent session on “Real World example of CTE”.I personally enjoyed the session very much. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my article here where... - [SQL SERVER - Downgrade Database to Previous Version](https://blog.sqlauthority.com/2008/10/16/sql-server-downgrade-database-to-previous-version/): Today I am writing on the topic which I do not like to write much. I enjoy writing usually positive or affirmative posts. Recently I got email from two different DBA where they upgraded to SQL Server 2005 trial version on their production server and now as their trial version was expire they wanted to downgrade their database to previous licensed version they had. The main questions is how they can downgrade the from SQL Server 2005 to SQL Server 2000? Answer is : Not Possible. There are no tools or native SQL Server facility which does this. I am also... - [SQL SERVER - Introduction and Example of UNION and UNION ALL](https://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/): It is very much interesting when I get request from blog reader to re-write my previous articles. I have received few request to rewrite my article SQL SERVER – Union vs. Union All – Which is better for performance? wi.th examples. I request you to read my previous article first to understand what is the concept and read this article to understand the same concept with example. xe=”color:green;”>/* Create First Table */ DECLARE @Table1 TABLE (Col INT) INSERT INTO @Table1 SELECT 1 INSERT INTO @Table1 SELECT 2 INSERT INTO @Table1 SELECT 3 INSERT INTO @Table1 SELECT 4 INSERT INTO @Table1 SELECT 5 /* Create Second Table */ DECLARE @Table2 TABLE (Col INT) INSERT INTO @Table2... - [SQL SERVER - Get Numeric Value From Alpha Numeric String - UDF for Get Numeric Numbers Only](https://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/): SQL is great with String operations. Many times, I use T-SQL to do my string operation. Let us see User Defined Function, which I wrote few days ago, which will return only Numeric values from AlphaNumeric values. CREATE FUNCTION dbo.udf_GetNumeric (@strAlphaNumeric VARCHAR(256)) RETURNS VARCHAR(256) AS BEGIN DECLARE @intAlpha INT SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric) BEGIN WHILE @intAlpha > 0 BEGIN SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' ) SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric ) END END RETURN ISNULL(@strAlphaNumeric,0) END GO /* Run the UDF with different test values */ SELECT dbo.udf_GetNumeric('') AS 'EmptyString'; SELECT dbo.udf_GetNumeric('asdf1234a1s2d3f4@@@') AS 'asdf1234a1s2d3f4@@@'; SELECT dbo.udf_GetNumeric('123456') AS '123456'; SELECT dbo.udf_GetNumeric('asdf') AS 'asdf'; SELECT dbo.udf_GetNumeric(NULL) AS 'NULL'; GO As... - [SQLAuthority News - Book Review - Pro SQL Server 2005 Replication (Definitive Guide)](https://blog.sqlauthority.com/2008/10/13/sqlauthority-news-book-review-pro-sql-server-2005-replication-definitive-guide/): Pro SQL Server 2005 Replication (Definitive Guide) (Hardcover) by Sujoy Paul (Author) Link to Amazon Quick Review: This is good book for any novice developer to start in the world of database replication implementation and maintenance. Replication is important part of highly availability and one book covers all the concept and methodology at one place. Detail Review: Replication is the process of sharing information so as to ensure consistency between redundant resources, such as software or hardware components, to improve reliability, fault-tolerance, or accessibility. Database replication can be used on many database management systems, usually with a master/slave relationship between the... - [SQLAuthority News - SQL Injection - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2008/10/12/sqlauthority-news-sql-injection-sql-joke-sql-humor-sql-laugh/): It has been a long time since I wrote about SQL Humor. Following is the cartoon sent to me by many (more than 10 times) so far by many users. I did not publish it till now as it has been quite popular and I believed many people had already seen it. However, recently by one of the quite big personality asked me why I have not included this in my blog, so I have finally decided to include that in my blog. Let us read humor about SQL Injection. - [SQLAuthority News - Download - Microsoft SQL Server 2008 Feature Pack, August 2008](https://blog.sqlauthority.com/2008/10/11/sqlauthority-news-download-microsoft-sql-server-2008-feature-pack-august-2008/): Download the 2008 Feature Pack for Microsoft SQL Server 2008, a collection of stand-alone install packages that provide additional value for SQL Server 2008. The Feature Pack is a collection of stand-alone install packages that provide additional value for SQL Server 2008. It includes the latest versions of: Redistributable components for SQL Server 2008. Add-on providers for SQL Server 2008. Backward compatibility components for SQL Server 2008. Download Feature Pack Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Enhenced TRIM() Function - Remove Trailing Spaces, Leading Spaces, White Space, Tabs, Carriage Returns, Line Feeds](https://blog.sqlauthority.com/2008/10/10/sql-server-2008-enhenced-trim-function-remove-trailing-spaces-leading-spaces-white-space-tabs-carriage-returns-line-feeds/): After reading my article SQL SERVER – 2008 – TRIM() Function – User Defined Function, I have received email and comments where user are asking if it is possible to remove trailing spaces, leading spaces, white space, tabs, carriage returns, line feeds etc. I found following script posted by Russ and Erik. It is modified a bit from original script. CREATE FUNCTION dbo.LTrimX(@str VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN DECLARE @trimchars VARCHAR(10) SET @trimchars = CHAR(9)+CHAR(10)+CHAR(13)+CHAR(32) IF @str LIKE '[' + @trimchars + ']%' SET @str = SUBSTRING(@str, PATINDEX('%[^' + @trimchars + ']%', @str), 8000) RETURN @str END GO CREATE FUNCTION dbo.RTrimX(@str VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN... - [SQL SERVER - 2008 - TRIM() Function - User Defined Function](https://blog.sqlauthority.com/2008/10/09/sql-server-2008-trim-function-user-defined-function/): I just received following question in email by James Louren. “How come SQL Server 2000, 2005 does not have function TRIM()? Is there any way to get similar results. What about SQL Server 2008?” James has asked very interesting question. I have previously wrote about SQL SERVER – TRIM() Function – UDF TRIM(). Today my answer is no different than what I answered in earlier post. SQL Server does not have function which can trim leading or trailing spaces of any string at the same time. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. SQL... - [SQLAuthority News - SQL Server 2008 - Microsoft Certifications for 70-432 70-433 70-450 70-452](https://blog.sqlauthority.com/2008/10/08/sqlauthority-news-sql-server-2008-microsoft-certifications-for-70-432-70-433-70-450-70-452/): I have received many emails requesting information about SQL Server certifications examples. Microsoft has released new set of exams for SQL Server 2008 certifications. I am listing them here for quick reference. Exam 70-432 – TS: Microsoft SQL Server 2008, Implementation and Maintenance Installing and Configuring SQL Server 2008 (10 percent) Maintaining SQL Server Instances (13 percent) Managing SQL Server Security (15 percent) Maintaining a SQL Server Database (16 percent) Performing Data Management Tasks (14 percent) Monitoring and Troubleshooting SQL Server (13 percent) Optimizing SQL Server Performance (10 percent) Implementing High Availability (9 percent) ————————————— Exam 70-433 – TS: Microsoft SQL... - [SQL SERVER - 2008 - High Resolution Wallpaper and Screen Saver](https://blog.sqlauthority.com/2008/10/07/sql-server-2008-high-resolution-wallpaper-and-screen-saver/): Recently I came across two very interesting ‘objects’ of SQL Server 2008. SQL Server 2008 High Resolution Wallpaper SQL Server 2008 Screen Saver Click Here to Download Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - SQL Hour at Patni Computer Systems](https://blog.sqlauthority.com/2008/10/07/sqlauthority-news-author-visit-sql-hour-at-patni-computer-systems/): Ahmedabad SQL Server User Group has started organizing a special event, “SQL Hour”, where we visit IT companies and interact with the SQL Server professionals. We had the first meeting this Saturday, 4th October 2008 at Patni Computer Systems, Gandhinangar. This meeting was lead by SQL Server User Group President Jacob Sebastian, who is known for his knowledge of “SQL Server – Behind the Scene”. He presented first session where he explained what is User Group and importance of “SQL Hour”. The meeting was very interesting and attendees were very responsive. We want to congratulate all the attendees as they really... - [SQLAuthority News - Upgrade SQL Server With SA Renamed - Rebuild System Databases - SQL Server 2008](https://blog.sqlauthority.com/2008/10/06/sqlauthority-news-upgrade-sql-server-with-sa-renamed-rebuild-system-databases-sql-server-2008/): I recently came across two interesting blog post by PSS SQL Server Engineers. They have written two interesting SQL Server 2008 related post and it can be very helpful to those who come across the issues mentioned in them. How to Rebuild System Databases in SQL Server 2008 Rarely but sometime there is need to rebuilding the System Databases. In SQL Server 2008 there is no facility to rebuild only msdb database. All the system database have to be rebuilt if any of the database has to be rebuild. System Databases like mssqlsystemresource can be rebuilt only by running Repair from... - [SQL SERVER - 2008 - Fix Connection Error with Visual Studio 2008 - Server Version is not supported - VS SP1 ISO Download](https://blog.sqlauthority.com/2008/10/05/sql-server-2008-fix-connection-error-with-visual-studio-2008-server-version-is-not-supported-vs-sp1-iso-download/): I previously wrote article SQL SERVER – 2008 – Fix Connection Error with Visual Studio 2008 – Server Version is not supported where I discussed how downloading Visual Studio SP1 will fix the error of Visual Studio 2008 connecting to SQL Server 2008. I have provided link to SP1 which was downloading only installer and after that it downloads SP1 component from internet. .NET Expert Vidya Vrat Agarwal has pointed out that Visual Studio SP1 can be downloaded as ISO. It is really good that now after downloading only one it can be used again to installed SP1 on multiple computers.... - [SQLAuthority News - Cumulative update package 1 for SQL Server 2008](https://blog.sqlauthority.com/2008/10/04/sqlauthority-news-cumulative-update-package-1-for-sql-server-2008/): Cumulative update package 1 for SQL Server 2008 is released. Click on link : http://support.microsoft.com/kb/956717/en-us Update : I have received few emails where developer did not find where to click on the support page to download the update package. Following image describes the link which is on very top of the page. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Find If Index is Being Used in Database](https://blog.sqlauthority.com/2008/10/03/sql-server-2008-find-if-index-is-being-used-in-database/): It is very often I get query that how to find if any index is being used in database or not. If any database has many indexes and not all indexes are used it can adversely affect performance. If number of index is higher it reduces the INSERT / UPDATE / DELETE operation but increase the SELECT operation. It is recommended to drop any unused indexes from table to improve the performance. Before dropping the index it is important to check if index is being used or not. I have wrote quick script which can find out quickly if index is... - [SQLAuthority News - Download - Visual Studio Team System 2008 Database Edition GDR September CTP](https://blog.sqlauthority.com/2008/10/03/sqlauthority-news-download-visual-studio-team-system-2008-database-edition-gdr-september-ctp/): In addition to providing support for SQL Server 2008 database projects, this release incorporates many previously released Power Tools as well as several new features. The new features include distinct Build and Deploy phases, Static Code Analysis and improved integration with SQL CLR projects. Database Edition no longer requires a Design Database. Therefore, it is no longer necessary to install an instance of SQL Express or SQL Server prior to using Database Edition. Let us learn about Visual Studio Team System. - [SQLAuthority News - Download - Microsoft SQL Server 2008 Books Online (August 2008)](https://blog.sqlauthority.com/2008/10/02/sqlauthority-news-download-microsoft-sql-server-2008-books-online-august-2008/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Descriptions of the... - [SQL Server - 2008 - Cheat Sheet - One Page PDF Download](https://blog.sqlauthority.com/2008/10/02/sql-server-2008-cheat-sheet-one-page-pdf-download/): Very frequently I have been asked to create a page, post or article where in one page all the important concepts of SQL Server are covered. SQL Server 2008 is very large subject and can not be even covered 1000 of pages. In daily life of DBA there are few commands very frequently used and for novice developers it is good to keep all the important SQL Script and SQL Statements handy. I have attempted to create cheat sheet for SQL Server 2008 most important commands. User can print this in one A4 size page and keep along with them. This can be used in interviews where T-SQL scripts are being asked. - [SQL SERVER - Example of PIVOT UNPIVOT Cross Tab Query in Different SQL Server Versions](https://blog.sqlauthority.com/2008/10/01/sql-server-example-of-pivot-unpivot-cross-tab-query-in-different-sql-server-versions/): Transforming rows to columns (PIVOT/CROSS TAB) and columns to rows (UNPIVOT) may be one of the common requirements that all of us must have seen several times in our programming life. SQL Server 2005 introduced two new operators: PIVOT and UNPIVOT that made writing cross-tab queries easier. My friend and SQL Server MVP Jacob Sebastian has posted an example that transform rows to columns using PIVOT operator. The reverse operation of PIVOT is UNPIVOT. PIVOT operator is available only in SQL Server 2005/2008. It does not exists in SQL Server 2000. Developers who are still using SQL Server 2000 should upgrade... - [SQLAuthority News - Security Update for SQL Server 2005 Service Pack 2](https://blog.sqlauthority.com/2008/09/30/sqlauthority-news-security-update-for-sql-server-2005-service-pack-2/): Developers who are using SQL Server Service Pack 2 must install this security patch for it. A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. You can help protect your computer by installing this update from Microsoft. After you install this item, you may have to restart your computer. Download Security Patch for SQL Server Service Pack 2 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Puzzle - Solution - Computed Columns Datatype Explanation](https://blog.sqlauthority.com/2008/09/29/sql-server-puzzle-solution-computed-columns-datatype-explanation/): Just a day before I wrote article SQL SERVER – Puzzle – Computed Columns Datatype Explanation which was inspired by SQL Server MVP Jacob Sebastian. I suggest that before continuing this article read original puzzle question SQL SERVER – Puzzle – Computed Columns Datatype Explanation. The question was if computed column was of datatype TINYINT how to create Computed Column of datatype INT? Before we continue with the answer let us run following script and understand how computed column is created. USE AdventureWorks GO CREATE TABLE MyTable ( ID TINYINT NOT NULL IDENTITY (1, 1), FirstCol TINYINT NOT NULL, SecondCol TINYINT NOT NULL, ThirdCol TINYINT NOT NULL, ComputedCol AS (FirstCol+SecondCol)*ThirdCol... - [SQL SERVER - Renaming SP is Not Good Idea - Renaming Stored Procedure Does Not Update sys.procedures](https://blog.sqlauthority.com/2008/09/28/sql-server-renaming-stored-procedure-does-not-update-sysprocedures/): I have written many articles about renaming a table, columns, and procedures SQL SERVER - How to Rename a Column Name or Table Name, here I found something interesting about renaming the stored procedures and felt like sharing it with you all. Let us learn about how renaming stored procedure does not update sys.procedures. - [SQL SERVER - Puzzle - Computed Columns Datatype Explanation](https://blog.sqlauthority.com/2008/09/27/sql-server-puzzle-computed-columns-datatype-explanation/): Yesterday I wrote post about SQL SERVER – Get Answer in Float When Dividing of Two Integer. I received excellent comment from SQL Server MVP Jacob Sebastian. Jacob has clarified the concept which I was trying to convey. He is famous for his “behind the scene insight“. When I read his comment, I realize another interesting concept which is related to same idea which is being discussed in this post. Let us read what Jacob says first. Jacob Sebastian: Nice post and something that is very much useful in the day-to-day programming life. Just wanted to add to what is already... - [SQL SERVER - Get Answer in Float When Dividing of Two Integer](https://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/): Many times we have requirements of some calculations amongst different fields in Tables. One of the software developers here was trying to calculate some fields having integer values and divide it which gave incorrect results in integer where accurate results including decimals was expected. Something as follows, Example, USE [AdventureWorks] GO CREATE TABLE [dbo].ConvertExample( [ID] [int] NULL, [Field1] [int] NULL, [Field2] [int] NULL, [Field3] [int] NULL, [Field4] [int] NULL ) GO INSERT INTO [dbo].ConvertExample VALUES (1,30,40,60,80) GO INSERT INTO [dbo].ConvertExample VALUES (2,20,10,50,80) GO INSERT INTO [dbo].ConvertExample VALUES (3,15,140,90,60) GO INSERT INTO [dbo].ConvertExample VALUES (1,60,0,5,2) GO SELECT * FROM [dbo].ConvertExample GO SELECT... - [SQL SERVER - Guidelines and Coding Standards Complete List Download](https://blog.sqlauthority.com/2008/09/25/sql-server-guidelines-and-coding-standards/): Coding standards and guidelines are very important for any developer on the path to a successful career. A coding standard is a set of guidelines, rules and regulations on how to write code. Coding standards should be flexible enough or should take care of the situation where they should not prevent best practices for coding. They are basically the guidelines that one should follow for better understanding. - [SQL SERVER - Guidelines and Coding Standards Part - 2](https://blog.sqlauthority.com/2008/09/24/sql-server-coding-standards-guidelines-part-2/): To express apostrophe within a string, nest single quotes (two single quotes). Example: SET @sExample = 'SQL''s Authority' When working with branch conditions or complicated expressions, use parenthesis to increase readability. IF ((SELECT 1 FROM TableName WHERE 1=2) ISNULL) To mark a single line as comment use (–) before the statement. To mark a section of code as comment use (/*…*/). If there is no need for resultset then use syntax that doesn’t return a resultset. IF EXISTS   (SELECT 1 FROM UserDetails WHERE UserID = 50) Rather than, IF EXISTS  (SELECT COUNT (UserID) FROM UserDetails WHERE UserID = 50) Use a graphical execution plan... - [SQL SERVER - Guidelines and Coding Standards Part - 1](https://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/): Use “Pascal” notation for SQL server Objects Like Tables, Views, Stored Procedures. Also tables and views should have ending “s”. Example: UserDetails Emails If you have big subset of table group than it makes sense to give prefix for this table group. Prefix should be separated by _. Example: Page_ UserDetails Page_ Emails Use following naming convention for Stored Procedure. sp<Application Name>_[<group name >_]<action type><table name or logical instance> Where action is: Get, Delete, Update, Write, Archive, Insert… i.e. verb Example: spApplicationName_GetUserDetails spApplicationName_UpdateEmails Use following Naming pattern for triggers: TR_<TableName>_<action><description> Example: TR_Emails_LogEmailChanges TR_UserDetails_UpdateUserName Indexes : IX_<tablename>_<columns separated by_> Example: IX_UserDetails_UserID Primary... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - September 2008](https://blog.sqlauthority.com/2008/09/22/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-september-2008/): On September 20, 2008 was one of the best day so far for Ahmedabad SQL Server User Group Meeting. We had two very interesting sessions by two SQL Server MVPs. SQL Server MVP Jacob Sebastian had began the meeting with very interesting introduction note. Along with many news Usergroup President Jacob Sebastian announced that SQL Server 2008 RTM (Release to Manufactor) is out. Jacob explained that difference between CTP ( Community Technology Preview) and RTM. RTM means MS SQL Server developer team has signed off on final version of product. Currently, SQL Server 2008 is available to MSDN Subscribers, TechNet Subscribers,... - [SQL SERVER - 2008 - Fix Connection Error with Visual Studio 2008 - Server Version is not supported](https://blog.sqlauthority.com/2008/09/21/sql-server-2008-fix-connection-error-with-visual-studio-2008-server-version-is-not-supported/): While attending conference SQLAuthority Author Visit – Microsoft Student Partner Conference, some developers informed me that SQL SERVER 2008 cannot be connected to Visual Studio 2008 and error displays as MS does not support SQL Server version. I was surprised initially as I could not believe that two MS products are not compatible. When trying myself I got the same error. SQL Server 2008 when connected to Visual Studio 2008 gives the error that “This server version is not supported.  Only servers up to Microsoft SQL Server 2005 are supported“. This error can be easily resolved by just installing Service pack. Download... - [SQLAuthority Author Visit - Ahmedabad User Group Meeting September 2008](https://blog.sqlauthority.com/2008/09/20/sqlauthority-author-visit-ahmedabad-user-group-meeting-september-2008/): Today is third Saturday of the Month and every third Saturday we have Ahmedabad User Group Meeting. Our user group is growing and getting interesting. Everybody who attended last months User Group (UG) Meeting realized that how important it is to attend UG meetings. UG President Jacob Sebastian (SQL Server – MVP) presented excellent session on “Transaction Isolation Levels and Locks in SQL Server”.I personally enjoyed the session very much. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my... - [Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/): The interview is a very important event for any person. A good interview questions leads to good career if the candidate is willing to learn. - [SQL SERVER - 2008 - Interview Questions and Answers - Part 8](https://blog.sqlauthority.com/2008/09/19/sql-server-2008-interview-questions-and-answers-part-8/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download What is Data Compression? In SQL SERVE 2008 Data Compression comes in two flavors: Row Compression Page Compression Row Compression Row compression changes the format of physical storage of data. It minimize the metadata (column information, length, offsets etc) associated with each record. Numeric data types and fixed length strings are stored in variable-length storage format, just like Varchar.  (Read More Here) Page Compression Page compression allows common data to be shared between rows for a given page. Its... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 7](https://blog.sqlauthority.com/2008/09/18/sql-server-2008-interview-questions-and-answers-part-7/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download How can we rewrite sub-queries into simple select statements or with joins? Yes we can write using Common Table Expression (CTE). A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. E.g. USE AdventureWorks... - [SQL SERVER - Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2008/09/17/sql-server-2008-interview-questions-and-answers-part-6/): Interview Questions and Answers - [SQL SERVER - 2008 - Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2008/09/16/sql-server-2008-interview-questions-and-answers-part-5/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download What command do we use to rename a db, a table and a column? To rename db sp_renamedb 'oldname' , 'newname' If someone is using db it will not accept sp_renmaedb. In that case first bring db to single user using sp_dboptions. Use sp_renamedb to rename database. Use sp_dboptions to bring database to multi user mode. E.g. USE master; GO EXEC sp_dboption AdventureWorks, 'Single User', True GO EXEC sp_renamedb 'AdventureWorks', 'AdventureWorks_New' GO EXEC sp_dboption AdventureWorks, 'Single User', False GO... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2008/09/15/sql-server-2008-interview-questions-and-answers-part-4/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER Which command using Query Analyzer will give you the version of SQL server and operating system? SELECT SERVERPROPERTY ('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') What is SQL Server Agent? SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose is to ease the implementation of tasks for the DBA, with its full-function... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2008/09/14/sql-server-2008-interview-questions-and-answers-part-3/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER 2) Common Questions Asked Which TCP/IP port does SQL Server run on? How can it be changed? SQL Server runs on port 1433. It can be changed from the Network Utility TCP/IP properties -> Port number, both on client and the server. What are the difference between clustered and a non-clustered index? (Read More Here) A clustered index is a special type of index that reorders the way records in the table are... - [SQL SERVER - Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2008/09/13/sql-server-2008-interview-questions-and-answers-part-2/): This is the second part of the blog post series Interview Questions and Answers.Click here to get free chapters (PDF) in the mailbox - [SQL SERVER - 2008 - Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2008/09/12/sql-server-2008-interview-questions-and-answers-part-1/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER What is RDBMS? Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the... - [SQLAuthority News - 700 Articles and Author Updates](https://blog.sqlauthority.com/2008/09/11/sqlauthority-news-700-articles-and-author-updates/): It is always interested to write article when reached at milestone. I start to receive many emails and suggestions just about when this blog is reaching any milestone. One question keep on coming to me is why do I write or what is in it for me? Satisfaction! I enjoy writing and helping community and by writing blog that is what I get. Lots of things have happened since last milestone of 600th article. 1) Microsoft presented most prestigious Microsoft SQL Server MVP Award. This award is given to Exceptional Technical Community Leader. 2) I am vice president of SQL Server... - [SQLAuthority News - SharePoint - Steps To Create A Custom WebPart - Deploy It SharePoint Site](https://blog.sqlauthority.com/2008/09/10/steps-to-create-a-custom-webpart-and-deploy-it-in-sharepoint-site/): SharePoint is one interesting software from Microsoft. My outsourcing location unit is working on one large project of SharePoint. Based on users feedback and overwhelming response to article SQL Server – Error : Fix : SharePoint Stop Working After Changing Server (Computer) Name I am posting one more article which is very important for SharePoint developers. SharePoint does not allow custom coding for any of the webpart. It is possible to create webpart in Visual Studio and integrate it with SharePoint. The process to create webpart in .NET framework and make it working in SharePoint often fails due to lack of... - [SQL Server - Error : Fix : SharePoint Stop Working After Changing Server (Computer) Name](https://blog.sqlauthority.com/2008/09/09/sql-server-error-fix-sharepoint-stop-working-after-changing-server-computer-name/): If Microsoft Office SharePoint Server (MOSS) and your database (MS SQL Server) are running together on same physical server, changing the name of the server (computer) using operating system may create non-functional SharePoint website. When you change the physical server name the SharePoint is already connected to the SQL instance of old computer name (OldServerName/SQLInstance) and on changing the name the SharePoint will not able to connect the SQL Server  as now the SQL Server instance will run on new computer name (NewServerName/SQLInstance). To solve this problem you need to reconfigure the entire Microsoft Office SharePoint Server with SQL Server Instance.... - [SQL SERVER - 2008 - Creating Primary Key, Foreign Key and Default Constraint](https://blog.sqlauthority.com/2008/09/08/sql-server-2008-creating-primary-key-foreign-key-and-default-constraint/): Primary key, Foreign Key and Default constraint are the 3 main constraints that need to be considered while creating tables or even after that. It seems very easy to apply these constraints but still we have some confusions and problems while implementing it. So I tried to write about these constraints that can be created or added at different levels and in different ways or methods. Primary Key Constraint: Primary Keys constraints prevents duplicate values for columns and provides unique identifier to each column, as well it creates clustered index on the columns. 1)      Create Table Statement  to create Primary Key... - [SQL SERVER - Explanation about Usage of Unique Index and Unique Constraint](https://blog.sqlauthority.com/2008/09/07/sql-server-explanation-about-usage-of-unique-index-and-unique-constraint/): I enjoy reading questions from blog readers and answering them. One of the another SQL enthusiastic is Imran who also regularly answer questions of users on this community blog. Recently he has answered in detail about when to use Unique Index and when to use Unique Constraint. Cristiano asked following questions : i need to know how work when there is a situation that there is a Unique Key and this field “alow null”, but when i am going to create a Unique Key the SQLSERVER saw that there were values duplicated and the values are “nulls”. How do i sove... - [SQL SERVER - Find Primary Key Using SQL Server Management Studio](https://blog.sqlauthority.com/2008/09/06/sql-server-find-primary-key-using-sql-server-management-studio/): Imran Mohammed is great SQL Expert and always eager to help community members. He enjoys answering question and solving problems of other community fellows. His answers are always detailed and trustworthy. Today we will see interesting question from Prasant and excellent answer from Imran Mohammed. Question from Prasant: Hi, I want to drop the primary key on one table but i cannot know which constraint is there. Is there a way to drop the primary key without specifying constraint. The basic idea of doing this is : I have one table with 4 columns e.g. 1. SrNo 2. NodeID 3. EnrollmentNo... - [SQL SERVER - 2008 - Creating Full Text Catalog and Full Text Search](https://blog.sqlauthority.com/2008/09/05/sql-server-creating-full-text-catalog-and-index/): Full Text Index helps to perform complex queries against character data. These queries can include words or phrase searching. We can create a full-text index on a table or indexed view in a database. Only one full-text index is allowed per table or indexed view. The index can contain up to 1024 columns. Software developer Monica Monica, who helped with screenshots also informed that this feature works with the RTM (Ready to Manufacture) version of SQL Server 2008 and does not work on CTP (Community Technology Preview) versions. Let us learn about Creating Full Text Catalog and Full Text Search in this blog post. - [SQLAuthority News - Download SQL Server Related Products](https://blog.sqlauthority.com/2008/09/05/sqlauthority-news-download-sql-server-related-products/): Configuration Manager 2007 R2 Evaluation Configuration Manager R2 now also supports Windows Vista SP1 and Windows Server 2008, integrates support for application virtualization, and provides an update to operating system deployment capability initially shipped in Configuration Manager. In addition, Client Status Reporting, SQL Reporting, and Forefront Client reporting are all now available. System Center Operations Manager 2007 SP1 Documentation This download contains documentation for System Center Operations Manager 2007 SP1. Microsoft® Visual Studio Team System 2008 Database Edition GDR August CTP Microsoft® Visual Studio Team System 2008 Database Edition GDR implements support for SQL Server 2008. Abstract courtesy : Microsoft Reference... - [SQLAuthirty Author Visit - SQL SERVER - User Group Meeting - Ahmedabad - August 30, 2008](https://blog.sqlauthority.com/2008/09/04/sqlauthirty-author-visit-sql-server-user-group-meeting-ahmedabad-august-30-2008/): I always enjoy participating in SQL Server User Group. We had recent meeting of Ahmedabad User Group on August 30. We had many things discussed in meeting. I enjoyed meeting fellows from different company who visited user group. The major discussion we had was quality of programmers and quality of work done by programmers. We all felt that looking at current market everybody is rushing for IT jobs. Finding right job is difficult and finding right candidate for job is even more difficult. User groups are the place for good developers to show up for good networking with industry leads and... - [SQLAuthority Author Visit - Microsoft Student Partner Conference](https://blog.sqlauthority.com/2008/09/03/sqlauthority-author-visit-microsoft-student-partner-conference/): The Microsoft Student Partner Program is a worldwide initiative to sponsor students who are interested in technology. The program mainly focuses on improving students skills for enjoyability, called Microsoft Student Partners (MSP). I was recently (August 30, 2008) invited to present technical session at conference held in my City. I really enjoyed presenting the session with very enthusiastic students. I see all the students as future strong members of developer community and Microsoft is doing great job encouraging them and giving them global platform. The program allows selected students to work along with professionals from Microsoft and to be a student... - [SQL SERVER - 2008 - Hardware and Software Requirements for Installing SQL Server 2008](https://blog.sqlauthority.com/2008/09/02/sql-server-hardware-and-software-requirements-for-installing-sql-server-2008/): The following sections list the minimum hardware and software requirements to install and run SQL Server 2008. The following requirements apply to all SQL Server 2008 installations: 1.Framework SQL Server Setup installs the following software components required by the product: – NET Framework 3.5 – SQL Server Native Client – SQL Server Setup support files 2. Software SQL Server Setup requires Microsoft Windows Installer 4.5 or a later version, and Microsoft Data Access Components (MDAC) 2.8 SP1 or a later version. You can download MDAC 2.8 SP1 from the MDAC downloads Web site. 3. Internet Software Microsoft Internet Explorer 6 SP1... - [SQL SERVER - Introduction to Filtered Index - Improve performance with Filtered Index](https://blog.sqlauthority.com/2008/09/01/sql-server-2008-introduction-to-filtered-index-improve-performance-with-filtered-index/): Filtered Index is a new feature in SQL SERVER 2008. Filtered Index is used to index a portion of rows in a table that means it applies filter on INDEX which improves query performance, reduce index maintenance costs, and reduce index storage costs compared with full-table indexes. - [SQL SERVER - 2008 - Introduction to Table-Valued Parameters with Example](https://blog.sqlauthority.com/2008/08/31/sql-server-table-valued-parameters-in-sql-server-2008/): Table-Valued Parameters is a new feature introduced in SQL SERVER 2008. In earlier versions of SQL SERVER it is not possible to pass a table variable in stored procedure as a parameter, but now in SQL SERVER 2008 we can use Table-Valued Parameter to send multiple rows of data to a stored procedure or a function without creating a temporary table or passing so many parameters. Table-valued parameters are declared using user-defined table types. To use a Table Valued Parameters we need follow steps shown below: Create a table type and define the table structure Declare a stored procedure that has... - [SQL SERVER - FIX : ERROR : Could Not Connect to SQL Server - TDSSNIClient initialization failed with error 0x7e, status code 0x60](https://blog.sqlauthority.com/2008/08/30/sql-server-fix-error-could-not-connect-to-sql-server-tdssniclient-initialization-failed-with-error-0x7e-status-code-0x60/): This is a very common error faced by so many people and I get lots of questions regarding this error. This error occurs due to many reasons and I have already posted few solutions on this error, see if you can find your solution here SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server SQL SERVER – Fix : Error : 1326 Cannot connect to Database Server Error: 40 – Could not open a connection to SQL Server or Recently when I was trying to create new user and connect to SQL SERVER... - [SQL SERVER - Few Useful DateTime Functions to Find Specific Dates](https://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/): Recently I have recieved email from Vivek Jamwal, which contains many useful SQL Server Date functions. ----Today SELECT GETDATE() 'Today' ----Yesterday SELECT DATEADD(d,-1,GETDATE()) 'Yesterday' ----First Day of Current Week SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) 'First Day of Current Week' ----Last Day of Current Week SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) 'Last Day of Current Week' ----First Day of Last Week SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0) 'First Day of Last Week' ----Last Day of Last Week SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6) 'Last Day of Last Week' ----First Day of Current Month SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) 'First Day of Current Month' ----Last Day of Current Month SELECT DATEADD(ms,- 3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0))) 'Last Day of Current Month' ----First Day of Last Month SELECT DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)) 'First Day of Last Month' ----Last Day of Last Month SELECT DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))) 'Last Day of Last Month' ----First Day of Current Year SELECT DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0) 'First Day of Current Year' ----Last Day of Current Year SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE())+1,0))) 'Last Day of Current Year' ----First Day of Last Year SELECT DATEADD(yy,-1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)) 'First Day of Last Year' ----Last Day of Last Year SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0))) 'Last Day of Last Year' ResultSet: Today ———————– 2008-08-29 21:54:58.967 Yesterday ———————– 2008-08-28 21:54:58.967 First Day of Current Week ————————- 2008-08-25 00:00:00.000 Last Day of Current Week ———————— 2008-08-31 00:00:00.000 First Day of... - [SQL SERVER - 2008 - Introduction to Merge Statement - One Statement for INSERT, UPDATE, DELETE](https://blog.sqlauthority.com/2008/08/28/sql-server-2008-introduction-to-merge-statement-one-statement-for-insert-update-delete/): MERGE is a new feature that provides an efficient way to perform multiple DML operations. In previous versions of SQL Server, we had to write separate statements to INSERT, UPDATE, or DELETE data based on certain conditions, but now, using MERGE statement we can include the logic of such data modifications in one statement that even checks when the data is matched then just update it and when unmatched then insert it. - [SQLAuthority News - Microsoft SQL Server 2008 R2 Report Builder 3.0](https://blog.sqlauthority.com/2008/08/27/sqlauthority-news-download-sql-server-2008-report-builder-20-rc1/): Microsoft SQL Server 2008 Reporting Services Report Builder 2.0 supports the full capabilities of SQL Server 2008 Reporting Services including flexible report layout, data visualizations and richly formatted text. The download includes the following functionality above the RC0 release of Report Builder: - [SQLAuthority News - SQL Server Express 2008 Downloads](https://blog.sqlauthority.com/2008/08/27/sqlauthority-news-sql-server-express-2008-downloads/): Microsoft SQL Server 2008 Express with Tools Microsoft SQL Server 2008 Express with Tools (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes graphical management tools. SQL Server 2008 Express provides powerful and reliable data management tools and rich features, data protection, and fast performance. It is ideal for small server applications and local data stores. Download Microsoft SQL Server 2008 Express with Tools Microsoft SQL Server 2008 Express with Advanced Services Microsoft SQL Server 2008 Express with Advanced Services (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes... - [SQL SERVER - How to Rename a Column Name or Table Name](https://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/): I often get requests from blog reader for T-SQL script to rename database table column name or rename table itself. Here is a video demonstrating the discussion [youtube=http://www.youtube.com/watch?v=5xviNDISwis] The script for renaming any column : sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN' The script for renaming any object (table, sp etc) : sp_RENAME '[OldTableName]' , '[NewTableName]' This article demonstrates two examples of renaming database object. Renaming database table column to new name. Renaming database table to new name. In both the cases we will first see existing table. Rename the object. Test object again with new name. 1. Renaming database table column to... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting - August 2008](https://blog.sqlauthority.com/2008/08/25/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-august-2008/): I will be attending Ahmedabad SQL Server Usergroup Meeting on August 30, 2008. I will be taking session about “SQL Server CTE and Recursive CTE“. The most important part of August Meeting is there will be presentation on “Transaction Isolation Levels and Locks in SQL Server” from user group President Jacob Sebastian. I invite all of the SQL enthusiastic to stop by User Group Meeting and meet all the fellow developers, DBAs and members. Location : 401, TIME SQUARE, CG road, Op Bazar Calcutta, Ahmedabad, India Date and Time : August 30, 2008 6:30 PM onwards Hope to see all of... - [SQLAuthority News - 4 Million Visits - over 675 SQL Server Articles](https://blog.sqlauthority.com/2008/08/25/sqlauthority-news-4-million-visits-over-675-sql-server-articles/): Thank you to all of my readers for supporting this blog. It has been wonderful journey all the way. I strongly encourage all my readers to actively contribute in discussion and writing article for blog. Today this blog has completed 4 Million visits and there are over 675 articles published on this blog. I have been awarded SQL MVP award from Microsoft during course of this “Journey of SQL Server”. I would like to thank Microsoft and all of my readers for their continuous support. If you have good idea about any SQL Server article please let me know and I... - [SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server - Fix Connection Problems of SQL Server](https://blog.sqlauthority.com/2008/08/24/sql-server-fix-error-40-could-not-open-a-connection-to-sql-server-fix-connection-problems-of-sql-server/): Everyday I get lots of question regarding error : An error has occurred while establishing a connection to the server when connecting to SQL server 2005, this failure may be caused by the fact that under default settings SQL server does not allow remote connection. ( provider: Named Pipes Provider, error: 40 – could not open a connection to SQL server. ) This error happens due to many reasons. There are few solutions already given on my original threads.I encourage to read following two articles first and see if you can find your solution. If you can not find any solution... - [SQL SERVER - 2008 - Configure Database Mail - Send Email From SQL Database](https://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/): Today in this article I would discuss about the Database Mail which is used to send the Email using SQL Server.  Previously I had discussed about SQL SERVER – Difference Between Database Mail and SQLMail. Database mail is the replacement of the SQLMail with many enhancements. So one should stop using the SQL Mail and upgrade to the Database Mail. Special thanks to Software Developer Monica, who helped with all the images and extensive testing of subject matter of this article. Here is the video of the same subject: [youtube=http://www.youtube.com/watch?v=ZGDBB2uwNp8] In order to send mail using Database Mail in SQL Server, there... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case - Part 2](https://blog.sqlauthority.com/2008/08/22/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case-part-2/): I had previously written SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case and I had really enjoyed writing it. Above script converts first letter of each word from sentence to upper case. For example this function will convert this string to title case! will be converted to This Function Will Convert This String To Title Case! However if you just want to convert first word of complete sentence you can use following quick script. USE AdventureWorks GO DECLARE @varString VARCHAR(100) SET @varString = 'this function will convert this string to title case!' SELECT... - [SQL SERVER - Behind the Scene of SQL Server Activity of - Transaction Log - Shrinking Log](https://blog.sqlauthority.com/2008/08/21/sql-server-behind-the-scene-of-sql-server-activity-of-transaction-log-shrinking-log/): Imran Mohammed continues to help community of SQL Server with his very enthusiastic writing and deep understanding of SQL Server architecture. Let us read what Imran has to say about how Transaction Log works and Shrinking of Log works. Question from lauraV Please help me understand. I am taking a full backup once a day, and transaction logs once every hour. Why is my LDF file not retaining a “normal” size? It continues to grow. I do not want to break the chain and use truncate only, though I have done this and it fixes the problem. I would very much... - [SQLAuthority News - Microsoft SQL Server Management Pack for Microsoft Operations Manager 2005](https://blog.sqlauthority.com/2008/08/21/sqlauthority-news-microsoft-sql-server-management-pack-for-microsoft-operations-manager-2005/): Note:  Download Microsoft Operations Manager 2005 by Microsoft The Microsoft SQL Server Management Pack provides both proactive and reactive monitoring of SQL Server 2008, 2005 and SQL Server 2000 in an enterprise environment. Availability and configuration monitoring, performance data collection, and default thresholds are built for enterprise-level monitoring. Both local and remote connectivity checks help ensure database availability. With the embedded expertise in the SQL Server Management Pack, you can proactively manage SQL Server, and identify issues before they become critical. This Management Pack increases the security, availability, and performance of your SQL Server infrastructure. The Microsoft SQL Server Management Pack... - [SQLAuthority News - Find Your IP Address - What Is My IP Address](https://blog.sqlauthority.com/2008/08/20/sqlauthority-news-find-your-ip-address-what-is-my-ip-address/): While developing often my developers need to know which IP address is of local network when looked from outside. I am working in large outsourcing company and we have local intranet setup. When connecting to remote servers from local system or from remote servers to local system we always want to know our Live IP address. Previously we have used many different methods to know our Live IP but nothing is reliable. External services often go down or provide incorrect information. I have added new feature to my site where any user can visit the page and find out their outgoing... - [SQL SERVER - Disable All the Trigger of Current Database](https://blog.sqlauthority.com/2008/08/19/sql-server-disable-all-the-trigger-of-current-database/): I have previously written article about SQL SERVER – Disable All Triggers on a Database – Disable All Triggers on All Servers. This is alternate method to achieve the same task. Following article is sent by Manish Kaushik. I recommend all of you to read original article along with this article for complete idea. CREATE PROCEDURE [dbo].[DisableAllTriggers] AS DECLARE @string VARCHAR(8000) DECLARE @tableName NVARCHAR(500) DECLARE cur CURSOR FOR SELECT name AS tbname FROM sysobjects WHERE id IN(SELECT parent_obj FROM sysobjects WHERE xtype='tr') OPEN cur FETCH next FROM cur INTO @tableName WHILE @@fetch_status = 0 BEGIN SET @string ='Alter table '+ @tableName + ' Disable trigger all' EXEC (@string)... - [SQL SERVER - Detailed Explanation of Transaction Lock, Lock Type, Avoid Locks](https://blog.sqlauthority.com/2008/08/18/sql-server-detailed-explanation-of-transaction-lock-lock-type-avoid-locks/): Loyal reader of this blog and “Great SQL Expert” Imran Mohammed always have good attitude towards any problem. Many times his answers very interesting to read and details are very accurate. I came across his two interesting comment on this blog and I would like to share this all of you. Priyank asked following question. Can u tell us something about how to find which sql table is having the lock and of what type. also please tell us how to remove a lock from a locked table thanks Priyank Imran Mohammed answered in great depth to this question. I personally... - [SQL SERVER - 2005 - Best Practices Analyzer (August 2008)](https://blog.sqlauthority.com/2008/08/17/sql-server-2005-best-practices-analyzer-august-2008/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. This download is the August 2008 release of SQL Server 2005 Best Practices Analyzer. Download Best Practices Analyzer Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - XML - Split a Delimited String - Generate a Delimited String](https://blog.sqlauthority.com/2008/08/17/sql-server-xml-split-a-delimited-string-generate-a-delimited-string/): SQL Server MVP and my very good friend Jacob Sebastian has written two wonderful articles about SQL Server and XML. I encourage to read this two articles to anybody who are interested in learning SQL and XML. Let us see how to Split a Delimited String. - [SQLAuthority News - Tip of the Minute](https://blog.sqlauthority.com/2008/08/16/sqlauthority-news-tip-of-the-minute/): Since my new personal website is launched I have received many comments and emails regarding new section of Tip of the Minute. Right navigation bar of the my personal website https://www.pinaldave.com/ contains section of the Tip of the Minute. Every time when page is refreshed it displays one new tip related to SQL Server. Few of the tips from the page I am listing here. Avoid unnecessary use of temporary tables. Try to use constraints instead of triggers, rules, and defaults whenever possible. SQL Server agent, allows you to schedule your own jobs and scripts. If any reader who will send... - [SQLAuthority News - Happy Indepedance Day to India](https://blog.sqlauthority.com/2008/08/15/sqlauthority-news-happy-indepedance-day-to-india/): India’s Independence Day is celebrated on August 15 to commemorate its independence on that day in 1947. The day is a national holiday in India. India will celebrate its 61st Independent day on August 15, 2008. Happy Independence Day to India Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Introduction to Online Indexing Operation](https://blog.sqlauthority.com/2008/08/15/sql-server-2008-introduction-to-online-indexing-operation/): When index is created or recreated it usually decreases performance of database. Either SQL takes long time for response or it does not response at all as transactions are blocked. When new table or database goes live it is not possible to find out exactly how many indexes are needed. After running queries on near to production data it is possible to find out which index can perform better. It is important in highly sensitive application to have data always available. SQL Server 2005 and later versions have provided feature called “Online Indexing”. Everytime index is updated it puts lock on... - [SQL SERVER - Get Date Time in Any Format - UDF - User Defined Functions](https://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/): One of the reader Nanda of SQLAuthority.com has posted very detailed script of converting any date time in desired format. I suggest every reader of this blog to save this script in your permanent code bookmark and use it when you need it. Let us learn about User Defined Functions. - [SQLAuthority News - Authors Personal Website Renovate - SQL Centric Website](https://blog.sqlauthority.com/2008/08/13/sqlauthority-news-authors-personal-website-renovate-sql-centric-website/): I am very pleased to announce my newly renovated website. I always liked my previous website as it was “Valid XHTML 1.1” and “Valid CSS 2.0”. Since I become MVP last month I have been receiving many emails where people were expecting more from my personal website. My blog http://www.SQLAuthority.com and my personal website https://www.pinaldave.com/ both are my heavily visited website but there was something missing when connecting them together. New website which went live today has all the missing elements to connect both my blog and website together. New website is also “Valid XHTML 1.1” and “Valid CSS 2.0”. One... - [SQLAuthority News - SQL Server 2008 Pricing and Licensing](https://blog.sqlauthority.com/2008/08/12/sqlauthority-news-sql-server-2008-pricing-and-licensing/): Note: SQL Server 2008 Pricing and Licensing by Microsoft SQL Server licensing and pricing are to intervined subjects and very important. I strongly suggest to use properly licensed SQL Server in any production environment. The concept of licensing can be confusing sometime to new administrators. If there is any confusion one should read following documentation from Microsoft for the purpose of clear idea and understanding. SQL Server 2008 is available under three licensing models: Server plus device client access license (CAL). Requires a license for the computer running the Microsoft server product, as well as CALs for each client device. Server... - [SQLAuthority News - Microsoft SQL Server 2008 Books Online - BOL - English](https://blog.sqlauthority.com/2008/08/12/sqlauthority-news-microsoft-sql-server-2008-books-online-bol-english/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. The Help viewer used by Books Online requires the Microsoft .NET Framework version 2.0. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and... - [SQLAuthority News - SQL Server 2008 Downloads Availables](https://blog.sqlauthority.com/2008/08/11/sqlauthority-news-sql-server-2008-downloads-availables/): SQL Server Compact 3.5 SP1 for Windows Mobile SQL Server Compact 3.5 SP1 for devices Windows Installer (MSI) file contains the CAB files and the DLLs for installing SQL Server Compact 3.5 SP1 on the Windows mobile devices. SQL Server Compact 3.5 SP1 and Synchronization Services for ADO.NET v1.0 SP1 for Windows Desktop SQL Server Compact 3.5 SP1 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP1 and Synchronization Services for ADO.NET version 1.0 SP1 on Windows desktop. SQL Server Compact... - [SQL SERVER - Download and Install Sample Database AdventureWorks 2005 - Detail Tutorial](https://blog.sqlauthority.com/2008/08/10/sql-server-2008-download-and-install-samples-database-adventureworks-2005-detail-tutorial/): Just a day ago I received a question from a reader who just installed SQL Server 2008. After the installation user did not find any sample database along with installation. The user wants to install the sample database which he is very much used to. Let us learn about Sample Database AdventureWorks. - [SQL SERVER - User Defined Functions (UDF) Limitations](https://blog.sqlauthority.com/2007/05/29/sql-server-user-defined-functions-udf-limitations/): UDF have its own advantage and usage but in this article we will see the limitation of UDF. Things UDF can not do and why Stored Procedure are considered as more flexible then UDFs. Stored Procedure are more flexibility then User Defined Functions(UDF). UDF has No Access to Structural and Permanent Tables. UDF can call Extended Stored Procedure, which can have access to structural and permanent tables. (No Access to Stored Procedure) UDF Accepts Lesser Numbers of Input Parameters. UDF can have upto 1023 input parameters, Stored Procedure can have upto 21000 input parameters. UDF Prohibit Usage of Non-Deterministic Built-in Functions... - [SQLAuthority News - Author Visit - Meeting with Readers - Top Three Features of SQL SERVER 2005](https://blog.sqlauthority.com/2007/05/28/sqlauthority-news-author-visit-meeting-with-readers-top-three-features-of-sql-server-2005/): Lots of travelers are visiting to Las Vegas due to long weekend of Memorial Day. I was invited to dinner meeting by two of my readers. It was wonderful discussion with them. We primarily discussed about scalability and upgrading issues about SQL Server. I received feedback about SQLAuthority.com site. There were two primarily request for them. I have been working on both of them already as I have received quite a few request for them from other readers as well. Beta testing has been completed, I will announce them on 1st June. While enjoying dinner I was asked interesting question and... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - SP](https://blog.sqlauthority.com/2007/05/28/sql-server-sql-joke-sql-humor-sql-laugh-sp/): One of my Friend send me(in email) following stored procedure. I laughed when I read it. Please enjoy it. It is here for amusement purpose only. Never use on development or production server. This is already dangerous you have been warned. CREATE PROCEDURE MyMarriage @ BrideGroom CHAR(NotBad), @ Bride CHAR(Good) AS BEGIN SELECT Bride FROM india_ Brides WHERE FatherInLaw = 'Millionaire' AND CarCount > 2 AND HouseStatus ='TwoStoreyed' AND BrideEduStatus='PG or Above' AND HavingBrothers='NO' AND HavingSisters ='No' AND AllowRelocate ='YES' SELECT Gold ,Cash,Car,BankBalance FROM FatherInLaw UPDATE MyBankAccout SET MyBal = MyBal + FatherinLawBal UPDATE MyLocker SET MyLockerContents = MyLockerContents + FatherinLawGold... - [SQL SERVER - Download Feature Pack for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/05/27/sql-server-download-feature-pack-for-microsoft-sql-server-2005/): Feature Pack for Microsoft SQL Server 2005 – February 2007 Download the February 2007 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. I have listed all the stand alone packages here. Even though title says February 2007, publication day of this package is 5/25/2007. All DBA should go through following list and see if their organization is using any of the application/feature and update is required for them. Microsoft ADOMD.NET Microsoft Core XML Services (MSXML) 6.0 Microsoft OLEDB Provider for DB2 Microsoft SQL Server Management Pack for MOM... - [SQL SERVER - 2005 Limiting Result Sets by Using TABLESAMPLE - Examples](https://blog.sqlauthority.com/2007/05/27/sql-server-2005-limiting-result-sets-by-using-tablesample-examples/): Introduced in SQL Server 2005, TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set. Example 1: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (10 PERCENT) Example 2: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (1000 ROWS) If you run above script many times you will notice that different numbers of... - [SQL SERVER - 2005 Replace TEXT with VARCHAR(MAX) - Stop using TEXT, NTEXT, IMAGE Data Types](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-replace-text-with-varcharmax-stop-using-text-ntext-image-data-types/): Yesterday, in Friday Afternoon team meeting. I was asked question by one of application developer “I am asked in new coding standards to use VARHCAR(MAX) instead of TEXT. Is VARCHAR(MAX) big enough to store TEXT field?” Well, I realize that I was not clear enough in my coding standard. It is extremely important for coding standards to be clear and have a enough explanation that developer have no doubt about them. I updated coding standards after the meeting. The answer is “Yes, VARCHAR(MAX) is big enough to accommodate TEXT field. TEXT, NTEXT and IMAGE data types of SQL Server 2000 will... - [SQL SERVER - 2005 Find Table without Clustered Index - Find Table with no Primary Key](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-find-table-without-clustered-index-find-table-with-no-primary-key/): One of the basic Database Rule I have is that all the table must Clustered Index. Clustered Index speeds up performance of the query ran on that table. Clustered Index are usually Primary Key but not necessarily. I frequently run following query to verify that all the Jr. DBAs are creating all the tables with no Clustered Index. USE AdventureWorks ----Replace AdventureWorks with your DBName GO SELECT DISTINCT [TABLE] = OBJECT_NAME(OBJECT_ID) FROM SYS.INDEXES WHERE INDEX_ID = 0 AND OBJECTPROPERTY(OBJECT_ID,'IsUserTable') = 1 ORDER BY [TABLE] GO Result set for AdventureWorks: TABLE ——————————————————- DatabaseLog ProductProductPhoto (2 row(s) affected) Related Post: SQL SERVER –... - [SQL SERVER - Change Default Fill Factor For Index](https://blog.sqlauthority.com/2007/05/25/sql-server-change-default-fill-factor-for-index/): SQL Server has default value for fill factor is Zero (0). The fill factor is implemented only when the index is created; it is not maintained after the index is created as data is added, deleted, or updated in the table. When creating an index, you can specify a fill factor to leave extra gaps and reserve a percentage of free space on each leaf level page of the index to accommodate future expansion in the storage of the table's data and reduce the potential for page splits. Let us learn about how to change default fill factor of index. - [SQL SERVER - Stored Procedure to display code (text) of Stored Procedure, Trigger, View or Object](https://blog.sqlauthority.com/2007/05/25/sql-server-stored-procedure-to-display-code-text-of-stored-procedure-trigger-view-or-object/): This is another popular question I receive. How to see text/content/code of Stored Procedure. System stored procedure that prints the text of a rule, a default, or an unencrypted stored procedure, user-defined function, trigger, or view. Syntax sp_helptext @objname = 'name' sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name Displaying the definition of a trigger or stored procedure sp_helptext 'dbo.nameofsp' Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Disadvantages (Problems) of Triggers](https://blog.sqlauthority.com/2007/05/24/sql-server-disadvantages-problems-of-triggers/): One of my team member asked me should I use triggers or stored procedure. Both of them has its usage and needs. I just basically told him few issues with triggers. This is small note about our discussion. Disadvantages(Problems) of Triggers It is easy to view table relationships , constraints, indexes, stored procedure in database but triggers are difficult to view. Triggers execute invisible to client-application application. They are not visible or can be traced in debugging code. It is hard to follow their logic as it they can be fired before or after the database insert/update happens. It is easy... - [SQL SERVER - 2005 Retrieve Configuration of Server](https://blog.sqlauthority.com/2007/05/24/sql-server-2005-retrieve-configuration-of-server/): Few days ago I was asked what is our SQL Server’s configuration. I provided way more information then they requested. Run following script and it will provide all the information about SQL Server . SQL Server provides in detailed information if Advanced Options are turned on. It is very clear from this that maximum number of object SQL Server can have is 2,147,483,647. It is considerably very big number. I am not worried yet about my database reaching its limit. EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure GO EXEC sp_configure 'show advanced options', 0 GO To change... - [SQL SERVER - NorthWind Database or AdventureWorks Database - Samples Databases](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases/): SQL Server 2005 does not install sample databases by default due to security reasons.I have received many questions regarding where is sample database in SQL Server 2005. One can install it afterward. AdventureWorks and AdvetureWorksDS are the new sample databases for SQL Server 2005, they can be download from here. Let us learn how to install NorthWind Database - samples databases.  - [SQL SERVER - 2005 Explanation Left Semi Join Showplan Operator and Other Operator](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-explanation-left-semi-join-showplan-operator-and-other-operator/): I come across very interesting documentation about Joins, while I was researching about article about EXCEPT yesterday. There are few interesting kind of join operations exists when execution plan is displayed in text format. Left Semi Join Showplan Operator The Left Semi Join operator returns each row from the first (top) input when there is a matching row in the second (bottom) input. If no join predicate exists in the Argument column, each row is a matching row. Left Anti Semi Join Showplan Operator The Left Anti Semi Join operator returns each row from the first (top) input when there is... - [SQLAuthority News - Funny One Liners - Humor](https://blog.sqlauthority.com/2007/05/23/sqlauthority-news-funny-one-liners-humor/): Once in a while we should laugh and relax. Here are few of my favorite funny one liners which I often use in my presentations. Let us start- Just read that 4,153,237 people got married last year, not to cause any trouble, but shouldn't that be an even number? - [SQLAuthority News - T-Shirts in Action](https://blog.sqlauthority.com/2007/05/22/sqlauthority-news-t-shirts-in-action/): Thank you All for great response to SQLAuthority T-Shirts. I have ran out of all of them. Please put your request here. I will go over all of them soon and see what I can do. They are made from high quality fiber and very comfortable. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Comparison EXCEPT operator vs. NOT IN](https://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/): The EXCEPT operator returns all of the distinct rows from the query to the left of the EXCEPT operator when there are no matching rows in the right query. The EXCEPT operator is equivalent of the Left Anti Semi Join. EXCEPT operator works the same way NOT IN. EXCEPTS returns any distinct values from the query to the left of the EXCEPT operand that do not also return from the right query. - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - T-Shirt](https://blog.sqlauthority.com/2007/05/21/sql-server-sql-joke-sql-humor-sql-laugh-t-shirt/): My friend sent me this in an email two days ago as he wanted me to have SQLAuthority T-Shirt with this image. I found it funny, I am not sure if I will have this on SQLAuthority T-Shirts. Please pay attention to the options available to select. I spend more than 3 hours to find the original source as my friend did not remember the source. Let's see some SQL Humor here: - [SQL SERVER - Top 15 free SQL Injection Scanners - Link to Security Hacks](https://blog.sqlauthority.com/2007/05/21/sql-server-top-15-free-sql-injection-scanners-link-to-security-hacks/): SQL injection is a technique for exploiting web applications that use client-supplied data in SQL queries, but without first stripping potentially harmful characters. Checking for SQL Injection vulnerabilities involves auditing your web applications and the best way to do it is by using automated SQL Injection Scanners. Security-Hacks.com compiled a list of free SQL Injection Scanners. I really enjoy reading the article. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Build List Link](https://blog.sqlauthority.com/2007/05/21/sql-server-2005-build-list-link/): What is Build List? All SQL Server has build list, this is incremental list of numbers which indicates which version SQL Server is running and what are its compatibility, patches etc. Regular Columnist Steve Jones of SQL Server Central has created build list. It is updated and informative. Microsoft Hot fixes are always cumulative. You can find your build number with: SELECT@@Version Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Code Formatting Tools](https://blog.sqlauthority.com/2007/05/20/sql-server-sql-code-formatter-tools/): SQL Code Formatting is very important. Every SQL Server DBA has its own preference about formatting. I like to format all keywords to uppercase. Following are two online tools, which formats SQL Code very good. I tested following script with those tools and I found two of the tools worth mentioning here. - [SQL SERVER - Script/Function to Find Last Day of Month](https://blog.sqlauthority.com/2007/05/20/sql-server-scriptfunction-to-find-last-day-of-month/): Following query will find the last day of the month. Query also take care of Leap Year. Script: DECLARE @date DATETIME SET @date='2008-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO DECLARE @date DATETIME SET @date='2007-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO ResultSet: LastDayOfMonth ----------------------- 2008-02-29 00:00:00.000 (1 row(s) affected) LastDayOfMonth ----------------------- 2007-02-28 00:00:00.000 (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ASCII to Decimal and Decimal to ASCII Conversion](https://blog.sqlauthority.com/2007/05/19/sql-server-ascii-to-decimal-and-decimal-to-ascii/): In this blog post we will see how we can convert ASCII to Decimal and Decimal to ASCII. In simple words, we will see the decimal and ASCII conversion. - [SQL SERVER - Math Functions Available in SQL Server](https://blog.sqlauthority.com/2007/05/19/sql-server-math-functions-for-2005/): The large majority of math functions is specific to applications using trigonometry, calculus, and geometry. This is very important and it is very difficult to have all of them together at place. - [SQL SERVER - 2005 Understanding Trigger Recursion and Nesting with examples](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-understanding-trigger-recursion-and-nesting-with-examples/): Trigger events can be fired within another trigger action. One Trigger execution can trigger even on another table or same table. This trigger is called NESTED TRIGGER or RECURSIVE TRIGGER. Nested triggers SQL Server supports the nesting of triggers up to a maximum of 32 levels. Nesting means that when a trigger is fired, it will also cause another trigger to be fired. If a trigger creates an infinitive loop, the nesting level of 32 will be exceeded and the trigger will cancel with an error message. Recursive triggers When a trigger fires and performs a statement that will cause the... - [SQL SERVER - 2005 - SSMS Change T-SQL Batch Separator](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-ssms-change-t-sql-batch-separator/): I recently received one big file with many T-SQL batches. It was a very big file and I was asked that this file was tested many times and it can run one transaction. I noticed the separator of the batches is not GO but it was EndBatch. I have followed two options to run the whole batch in one transaction. Let us learn how to change T-SQL Batch Separator. - [SQLAuthority News - Limited Edition T-Shirts Arrived](https://blog.sqlauthority.com/2007/05/17/sqlauthority-news-limited-edition-t-shirts-arrived/): I have received quite a few request for SQLAuthority.com T-shirts. Every day I receive lots of emails and suggestions. Many readers have great suggestions and have helped to improve content. First of all I express my gratitude to all of you. Few of my loyal and enthusiastic readers will receive the T-shirt by tomorrow. T-shirts are very limited. I have kept only two for me and have shipped all other. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Disable Index - Enable Index - ALTER Index](https://blog.sqlauthority.com/2007/05/17/sql-server-disable-index-enable-index-alter-index/): There are few requirements in real world when Index on table needs to be disabled and re-enabled afterwards. e.g. DTS, BCP, BULK INSERT etc. Index can be dropped and recreated. I prefer to disable the Index if I am going to re-enable it again. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO ----Enable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact REBUILD GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-1205-transaction-process-id-was-deadlocked-on-resources-with-another-process-and-has-been-chosen-as-the-deadlock-victim-rerun-the-transaction/): Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction. - [SQL SERVER - Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-130-cannot-perform-an-aggregate-function-on-an-expression-containing-an-aggregate-or-a-subquery/): Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery Following statement will give the following error: “Cannot perform an aggregate function on an expression containing an aggregate or a subquery.” MS SQL Server doesn’t support it. USE PUBS GO SELECT AVG(COUNT(royalty)) RoyaltyAvg FROM dbo.roysched GO You can get around this problem by breaking out the computation of the average in derived tables. USE PUBS GO SELECT AVG(t.RoyaltyCounts) FROM ( SELECT COUNT(royalty) AS RoyaltyCounts FROM dbo.roysched ) T GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL. - [SQL SERVER - Binary Sequence Generator - Truth Table Generator](https://blog.sqlauthority.com/2007/05/15/sql-server-binary-sequence-generator-truth-table-generator/): Run following script in query editor to generate truth table with its decimal value and binary sequence. The truth table is 512 rows long. This can be extended or reduced by adding or removing cross joins respectively. Script: USE AdventureWorks; DECLARE @Binary TABLE ( Digit bit) INSERT @Binary VALUES (0) INSERT @Binary VALUES (1) SELECT ((a.Digit*256) + (b.Digit*128) + (c.Digit*64) + (d.Digit*32) + (e.Digit*16) + (f.Digit*8) + (g.Digit*4) + (h.Digit*2) + (i.Digit*1)) DecimalValue, a.Digit '256', b.Digit '128' , c.Digit '64', d.Digit '32', e.Digit '16', f.Digit '8', g.Digit '4', h.Digit '2', i.Digit '1' FROM @Binary a CROSS JOIN @Binary b CROSS JOIN... - [SQL SERVER - DBCC commands List - documented and undocumented](https://blog.sqlauthority.com/2007/05/15/sql-server-dbcc-commands-list-documented-and-undocumented/): Database Consistency Checker (DBCC) commands can gives valuable insight into what’s going on inside SQL Server system. DBCC commands have powerful documented functions and many undocumented capabilities. Current DBCC commands are most useful for performance and troubleshooting exercises. To learn about all the DBCC commands run following script in query analyzer. DBCC TRACEON(2520) DBCC HELP (‘?’) GO To learn about syntax of an individual DBCC command run following script in query analyzer. DBCC HELP(<command>) GO Following is the list of all the DBCC commands and their syntax. List contains all documented and undocumented DBCC commands. DBCC activecursors [(spid)] DBCC addextendedproc (function_name,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Photo](https://blog.sqlauthority.com/2007/05/14/sql-server-sql-joke-sql-humor-sql-laugh-photo/): Pay attention to the last line of the ingredients. I found this entry at Worse Than Failure. I found it humorous. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - MS TechNet : Storage Top 10 Best Practices](https://blog.sqlauthority.com/2007/05/14/sql-server-ms-technet-storage-top-10-best-practices/): This one of the very interesting article I read regarding SQL Server 2005 Storage. Please refer original article at MS TechNet here. Understand the IO characteristics of SQL Server and the specific IO requirements / characteristics of your application. More / faster spindles are better for performance. Try not to “over” optimize the design of the storage; simpler designs generally offer good performance and more flexibility. Validate configurations prior to deployment. Always place log files on RAID 1+0 (or RAID 1) disks. Isolate log from data at the physical disk level. Consider configuration of TEMPDB database. Lining up the number of... - [SQL SERVER - Query to Find First and Last Day of Current Month - Date Function](https://blog.sqlauthority.com/2007/05/13/sql-server-query-to-find-first-and-last-day-of-current-month/): Following query will run respective on today's date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month. Let us see how we can do this with the help of Date Function in SQL Server. - [SQL SERVER - UDF - Function to Parse AlphaNumeric Characters from String](https://blog.sqlauthority.com/2007/05/13/sql-server-udf-function-to-parse-alphanumeric-characters-from-string/): Following function keeps only Alphanumeric characters in string and removes all the other character from the string. This is very handy function when working with Alphanumeric String only. I have used this many times. CREATE FUNCTION dbo.UDF_ParseAlphaChars ( @string VARCHAR(8000) ) RETURNS VARCHAR(8000) AS BEGIN DECLARE @IncorrectCharLoc SMALLINT SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) WHILE @IncorrectCharLoc > 0 BEGIN SET @string = STUFF(@string, @IncorrectCharLoc, 1, '') SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) END SET @string = @string RETURN @string END GO —-Test SELECT dbo.UDF_ParseAlphaChars('ABC”_I+{D[]}4|:e;””5,<.F>/?6') GO Result Set : ABCID4e5F6 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List all the database](https://blog.sqlauthority.com/2007/05/12/sql-server-2005-list-all-the-database/): List all the database on SQL Servers. All the following Stored Procedure list all the Databases on Server. I personally use EXEC sp_databases because it gives the same results as other but it is self explaining. ----SQL SERVER 2005 System Procedures EXEC sp_databases EXEC sp_helpdb ----SQL 2000 Method still works in SQL Server 2005 SELECT name FROM sys.databases SELECT name FROM sys.sysdatabases ----SQL SERVER Un-Documented Procedure EXEC sp_msForEachDB 'PRINT ''?''' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support](https://blog.sqlauthority.com/2007/05/12/sql-server-fix-error-msg-6263-level-16-state-1-line-2-enabling-sql-server-2005-for-clr-support/): Error: Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support 1) Enable Server for CLR Support. - [SQL SERVER - Explanation SQL Command GO](https://blog.sqlauthority.com/2007/05/11/sql-server-explanation-sql-command-go/): GO is not a Transact-SQL statement; it is often used in T-SQL code. Go causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches. SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is... - [SQL SERVER - Download Microsoft SQL Server 2005 System Views Map](https://blog.sqlauthority.com/2007/05/11/sql-server-download-microsoft-sql-server-2005-system-views-map/): The Microsoft SQL Server 2005 System Views Map shows the key system views included in SQL Server 2005, and the relationships between them. It is available to download from Microsoft Site. It can be printed and mounted at Office Depot or Kinko’s. Download SQL SERVER 2005 System Views Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 Katmai - Download Datasheet Final from Microsoft](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-download-datasheet-final-from-microsoft/): Few interesting thing about Katmai. SQL Server “Katmai” will provide a more secure, reliable and manageable enterprise data platform. SQL Server “Katmai” will enable developers and administrators to save time by allowing them to store and consume any type of data from XML to documents. SQL Server “Katmai” provides a more scalable infrastructure that enables IT to drive business intelligence throughout the organization. SQL Server “Katmai” along with .NET Framework 3.0 will accelerate the development of the next generation of applications. Reference : Pinal Dave (https://blog.sqlauthority.com) MS SQL Server (All the above text) Download Final Datasheet of Katmai from Microsoft - [SQL SERVER - Fix: Error: HResult 0x2, Named Pipes Provider: Could not open a connection](https://blog.sqlauthority.com/2007/05/10/sql-server-fix-error-hresult-0x2-level-16-state-1-named-pipes-provider-could-not-open-a-connection-to-sql-server/): In this blog post we are going to fix the error which is related to Named Pipes Provider. - [SQL SERVER - 2008 Katmai - Your Data, Any Place, Any Time](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-your-data-any-place-any-time/): I was following up on the news of first Microsoft Business Intelligence (BI) Conference held at Seattle. Good news is – SQL Server 2008 code name ‘Katmai’ is announced. I went to the official website I like the catchy line “Your Data, Any Place, Any Time“. As per my opinion the most important thing about Katmai is that it can be used to manage any type of data, including relational data, documents, geographic information and XML. The question I received many times since yesterday is : I am still using SQL Server 2000, I was planning to upgrade to SQL Server... - [SQL SERVER - Fix : Error 2501 : Cannot find a table or object with the name . Check the system catalog.](https://blog.sqlauthority.com/2007/05/09/sql-server-fix-error-2501-cannot-find-a-table-or-object-with-the-name-check-the-system-catalog/): Error 2501 : Cannot find a table or object with the name . Check the system catalog. This is very generic error beginner DBAs or Developers faces. The solution is very simple and easy. Follow the direction below in order. Fix/Workaround/Solution: Make sure that correct Database is selected. If not please run USE YourDatabase. Check the object or table name. They must be spelled correct. If database is case sensitive please use correct case. Use object belongs to other owner use two parts name as scheme_name.object_name. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - MIS2007 Part II - Database Raid Discussion](https://blog.sqlauthority.com/2007/05/09/sqlauthority-news-author-visit-mis2007-part-ii-database-raid-discussion/): MIS2007 is really going good. There are many things going on. As I mentioned in my previous article, It is really pleasure to meet industry leaders. There was discussion about what is good for database RAID 5 configuration or RAID 10. This subject is always very interesting. We were discussing from small databases (5GB) to larger databases(5 TB). The question was which RAID 5 or RAID 10. Surprisingly, everybody who participated in discussion said their experience says RAID 10 is better for this particular application as there are lots of reads and writes in database. One of the expert suggested that... - [SQL SERVER - Index Optimization CheckList](https://blog.sqlauthority.com/2007/05/08/sql-server-index-optimization-checklist/): Index optimization is always interesting subject to me. Every time I receive requests to help optimize query or query on any specific table. I always ask Jr.DBA to go over following list first before I take a look at it. Most of the time the Query Speed is optimized just following basic rules mentioned below. Once following checklist applied interesting optimization part begins which only experiment and experience can resolve. - [SQLAuthority News - Author Visit - The 2007 Marketing Innovation Summit, Las Vegas](https://blog.sqlauthority.com/2007/05/08/sqlauthority-news-author-visit-the-2007-marketing-innovation-summit-las-vegas/): I am attending The 2007 Marketing Innovation Summit“, Las Vegas. It started on 5/6/2007 and will continue till 5/9/2007. Unica Corporation has arranged this conference. The MIS 2007 Agenda includes: Case studies and best practices Sessions focused on Relationship Marketing, Internet Marketing and Marketing Operations Hands on “how to” sessions General sessions from distinguished industry experts A one-day Pre-Summit Affinium New User Workshop and Getting Prepared for Affinium Plan Post-Summit Hands-On Training Evening networking activities In two days so far, I have learned a lot and have met many industry leaders. Talking about cutting edge technology and SQL Server was perfect... - [SQL SERVER - Top 10 Hidden Gems in SQL Server 2005](https://blog.sqlauthority.com/2007/05/07/sql-server-top-10-hidden-gems-in-sql-server-2005/): Top 10 Hidden Gems in SQL Server 2005 By Cihan Biyikoglu SQL Server 2005 has hundreds of new and improved components. Some of these improvements get a lot of the spotlight. However there is another set that are the hidden gems that help us improve performance, availability or greatly simplify some challenging scenarios. This paper lists the top 10 such features in SQL Server 2005 that we have discovered through the implementation with some of our top customers and partners. TableDiff.exe Triggers for Logon Events (New in Service Pack 2) Boosting performance with persisted-computed-columns (pcc). DEFAULT_SCHEMA setting in sys.database_principles Forced Parameterization... - [SQL SERVER - 2005/2000 Examples and Explanation for GOTO](https://blog.sqlauthority.com/2007/05/07/sql-server-20052000-examples-and-explanation-for-goto/): The GOTO statement causes the execution of the T-SQL batch to stop processing the following commands to GOTO and processing continues from the label where GOTO points. GOTO statement can be used anywhere within a procedure, batch, or function. GOTO can be nested as well. GOTO can be executed by any valid user on SQL SERVER. GOTO can co-exists with other control of flow statements (IF…ELSE, WHILE). GOTO can only go(jump) to label in the same batch, it can not go to label out side of the batch. Syntax: Define the label: label: ALTER the execution: GOTO label Notes from MSDN... - [SQL SERVER - Creating Comma Separate Values List from Table - UDF - SP](https://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/): Following script will create common separate values (CSV) or common separate list from tables. convert list to table. Following script is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. There are three ways to do this. 1) Using COALESCE 2) Using SELECT Smartly 3) Using CURSOR. The table is example is: TableName: NumberTable NumberCols first second third fourth fifth Output : first,second,third,fourth,fifth Option 1: This is... - [SQL SERVER - UDF - Function to Convert List to Table](https://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/): Following Users Defined Functions will convert list to table. It also supports user defined delimiter. Following UDF is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. CREATE FUNCTION dbo.udf_List2Table ( @List VARCHAR(MAX), @Delim CHAR ) RETURNS @ParsedList TABLE ( item VARCHAR(MAX) ) AS BEGIN DECLARE @item VARCHAR(MAX), @Pos INT SET @List = LTRIM(RTRIM(@List))+ @Delim SET @Pos = CHARINDEX(@Delim, @List, 1) WHILE @Pos > 0 BEGIN SET... - [SQL SERVER - 2005 Enable CLR using T-SQL script](https://blog.sqlauthority.com/2007/05/05/sql-server-2005-enable-clr-using-t-sql-script/): Before doing any .Net coding in SQL Server you must enable the CLR. In SQL Server 2005, the CLR is OFF by default. This is done in an effort to limit security vulnerabilities. Following is the script which will enable CLR. EXEC sp_CONFIGURE 'show advanced options' , '1'; GO RECONFIGURE; GO EXEC sp_CONFIGURE 'clr enabled' , '1' GO RECONFIGURE; GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - UDF - User Defined Function to Find Weekdays Between Two Dates](https://blog.sqlauthority.com/2007/05/05/sql-server-udf-user-defined-function-to-find-weekdays-between-two-dates/): Following user defined function returns number of weekdays between two dates specified. This function excludes the dates which are passed as input params. It excludes Saturday and Sunday as they are weekends. I always had this function with for reference but after some research I found original source website of the function. This function has been written by Author Alexander Chigrik. CREATE FUNCTION dbo.spDBA_GetWeekDays ( @StartDate datetime, @EndDate datetime ) RETURNS INT AS BEGIN DECLARE @WorkDays INT, @FirstPart INT DECLARE @FirstNum INT, @TotalDays INT DECLARE @LastNum INT, @LastPart INT IF (DATEDIFF(DAY, @StartDate, @EndDate) 0) THEN @LastPart - 1 ELSE 0 END... - [SQL SERVER - Fix : Error : Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset DBSCHEMA_TABLES_INFO for OLE DB provider SQLNCLI for linked server LinkedServerName](https://blog.sqlauthority.com/2007/05/04/sql-server-fix-error-msg-7311-level-16-state-2-line-1-cannot-obtain-the-schema-rowset-dbschema_tables_info-for-ole-db-provider-sqlncli-for-linked-server-linkedservername/): You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server. Error: The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator. Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset “DBSCHEMA_TABLES_INFO” for OLE DB provider “SQLNCLI” for linked server “<LinkedServerName>”. The provider supports the interface, but returns a failure code when it is used. Fix/WorkAround/Solution: Use Windows Authentication mode For a... - [SQL SERVER - Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts)](https://blog.sqlauthority.com/2007/05/04/sql-server-download-sql-server-management-studio-keyboard-shortcuts-ssms-shortcuts/): Download SQL Server Management Studio Keyboard Shortcuts I have received many emails appreciating my article Query Analyzer Shortcuts and requesting same for SQL Server Management Studio Keyboard Shortcuts. I see frequent downloads of the PDF generated by SQLAuthority for the same on server. There is original article on MSDN site. I have combined complete article in one PDF again. It is easy to refer, print and manage. Download SQL Server Management Studio Keyboard Shortcuts Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC Commands to Free SQL Server Memory Caches](https://blog.sqlauthority.com/2007/05/03/sql-server-dbcc-commands-to-free-several-sql-server-memory-caches/): Lots of people do not know that following command can be very helpful to clear your memory caches of SQL Server. I have often seen people restarting their entire system to clear the memory caches. - [SQL SERVER - Enable Login - Disable Login using ALTER LOGIN - Change name of the 'SA'](https://blog.sqlauthority.com/2007/05/03/sql-server-enable-login-disable-login-using-alter-login-change-name-of-the-sa/): Enable Login – Disable Login using ALTER LOGIN – Change name of the ‘SA’ - [SQL SERVER - FIX : ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup](https://blog.sqlauthority.com/2007/05/02/sql-server-fix-error-1101-could-not-allocate-a-new-page-for-database-because-of-insufficient-disk-space-in-filegroup/): ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup . Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. Fix/Workaround/Solution: Make sure there is enough Hard Disk space where database files are stored on server. Turn on AUTOGROW for file groups. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 TOP Improvements/Enhancements](https://blog.sqlauthority.com/2007/05/02/sql-server-2005-top-improvementsenhancements/): SQL Server 2005 introduces two enhancements to the TOP clause. 1) User can specify an expression as an input to the TOP keyword. 2) User can use TOP in modification statements (INSERT, UPDATE, and DELETE). Explanation : User can specify an expression as an input to the TOP keyword. In SQL SERVER 2000 usage of TOP is implemented in following query. SELECT TOP 10 TableColumnID FROM TableName   For ages Developers and DBAs wants to pass parameters to TOP keyword. IN SQL SERVER 2005 it is possible. Example, @iNum is variables set before SELECT statement is ran. DECLARE @iNum INT SET... - [SQL SERVER - User Defined Functions (UDF) to Reverse String - UDF_ReverseString](https://blog.sqlauthority.com/2007/05/01/sql-server-user-defined-functions-udf-to-reverse-string-udf_reversestring/): UDF_ReverseString UDF_ReverseString User Defined Functions returns the Reversed String starting from certain position. First parameters takes the string to be reversed. Second parameters takes the position from where the string starts reversing. Script of UDF_ReverseString function to return Reverse String. CREATE FUNCTION UDF_ReverseString ( @StringToReverse VARCHAR(8000), @StartPosition INT ) RETURNS VARCHAR(8000) AS BEGIN IF (@StartPosition <= 0) OR (@StartPosition > LEN(@StringToReverse)) RETURN (REVERSE(@StringToReverse)) RETURN (STUFF (@StringToReverse, @StartPosition, LEN(@StringToReverse) - @StartPosition + 1, REVERSE(SUBSTRING (@StringToReverse, @StartPosition LEN(@StringToReverse) - @StartPosition + 1)))) END GO Usage of above UDF_ReverseString: Reversing the string from third position SELECT dbo.UDF_ReverseString('forward string',3) Results Set : forgnirts draw Reversing... - [SQL SERVER - Copy Column Headers in Query Analyzers in Result Set](https://blog.sqlauthority.com/2007/05/01/sql-server-copy-column-headers-in-query-analyzers-in-result-set/): Copy Column Headers in Query Analyzers in Result Set. In Query Analyzer go to Menu >> Tools >> Options >> Results Select Default results Target: Results to Text Results output format:(*): Tab Delimited Print column headers(*): Checkbox ON(check) [youtube=http://www.youtube.com/watch?v=BL5GO-jH3HA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com 100th Post - Gratitude Note to Readers](https://blog.sqlauthority.com/2007/05/01/sqlauthoritycom-101st-post-gratitude-note-to-readers/): Hello All, I would like to express my deep gratitude to all of my readers for their emails, comments, suggestions and continuous support on the occasion of 101st post on this blog. I would like to extend my gratitude to my parents. In good times or trying times my parents are there with me always. Mom and Dad thank you for your encouragement, warmth, advise and continuous love. Kind Regards and Best Wishes, Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Collate - Case Sensitive SQL Query Search](https://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/): In this blog post we are going to learn about how to do Case Sensitive SQL Query Search. If Column1 of Table1 has following values ‘CaseSearch, casesearch, CASESEARCH, CaSeSeArCh’, following statement will return you all the four records. - [SQL SERVER - FIX : ERROR : Msg 3159, Level 16, State 1, Line 1 - Msg 3013, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/30/sql-server-fix-error-msg-3159-level-16-state-1-line-1-msg-3013-level-16-state-1-line-1/): While moving some of the script from SQL SERVER 2000 to SQL SERVER 2005 our migration team faced following error. Msg 3159, Level 16, State 1, Line 1 The tail of the log for the database “AdventureWorks” has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. Following is the similar script using AdventureWorks... - [SQL SERVER - SET ROWCOUNT - Retrieving or Limiting the First N Records from a SQL Query](https://blog.sqlauthority.com/2007/04/30/sql-server-set-rowcount-retrieving-or-limiting-the-first-n-records-from-a-sql-query/): A SET ROWCOUNT statement simply limits the number of records returned to the client during a single connection. As soon as the number of rows specified is found, SQL Server stops processing the query. The syntax looks like this: - [SQL SERVER - 2005 Security DataSheet](https://blog.sqlauthority.com/2007/04/29/sql-server-2005-security-datasheet/): Microsoft has implemented strong security features into the Microsoft® SQL Server™ 2005, which provides a security-enabled platform for enterprise-class relational database and analysis solutions. SQL Server 2005 provides cutting edge security technology and addresses several security issues, including automatic secured updates and encryption of sensitive data. Download the SQL Server 2005 Security DataSheet from SQLAuthority.com Download the SQL Server 2005 Security DataSheet from Microsoft.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Random Number Generator Script - SQL Query](https://blog.sqlauthority.com/2007/04/29/sql-server-random-number-generator-script-sql-query/): Random Number Generator. There are many methods to generate random numbers in SQL Server. Method 1: Generate Random Numbers (Int) between Rang - [SQL SERVER - Replication Keywords Explanation and Basic Terms](https://blog.sqlauthority.com/2007/04/29/sql-server-replication-keywords-explanation-and-basic-terms/): While discussing replication with Jr. DBAs at work, I realize some of them have not experienced replication feature of SQL SERVER. Following is quick reference of replication keywords I created for easy conversation. - [SQL SERVER - Explanation SQL SERVER Merge Join](https://blog.sqlauthority.com/2007/04/28/sql-server-explanation-sql-server-merge-join/): The Merge Join transformation provides an output that is generated by joining two sorted data sets using a FULL, LEFT, or INNER join. The Merge Join transformation requires that both inputs be sorted and that the joined columns have matching meta-data. User cannot join a column that has a numeric data type with a column that has a character data type. If the data has a string data type, the length of the column in the second input must be less than or equal to the length of the column in the first input with which it is merged. USE pubs... - [SQL SERVER - Restrictions of Views - T SQL View Limitations](https://blog.sqlauthority.com/2007/04/28/sql-server-restrictions-of-views-t-sql-view-limitations/): UPDATE: (5/15/2007) Thank you Ben Taylor for correcting errors and incorrect information from this post. He is Database Architect and writes Database Articles at www.sswug.org. I have been coding as T-SQL for many years. I never have to use view ever in my career. I do not see in my near future I am using Views. I am able to achieve same database architecture goal using either using Third Normal tables, Replications or other database design work around.SQL Views have many many restrictions. There are few listed below. I love T-SQL but I do not like using Views. - [SQL SERVER - Good, Better and Best Programming Techniques](https://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/): A week ago, I was invited to meeting of programmers. Subject of meeting was “Good, Better and Best Programming Techniques”. I had made small note before I went to meeting, so if I have to talk about or discuss SQL Server it can come handy. Well, I did not get chance to talk on that as it was very causal and just meeting and greetings. Everybody just talked about what they think about their job. I talked very briefly about SQL Server, my current job and some funny incident at work. Everybody laughed big when I talked about funny bug ticket... - [SQL SERVER - Query to Retrieve the Nth Maximum Value](https://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/): Replace Employee with your table name, and Salary with your column name. Where N is the level of Salary to be determined. Let us see a query to retrieve the Nth Maximum Value. - [SQL SERVER - Locking Hints and Examples](https://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/): Locking Hints and Examples are as follows. The usage of them is the same but the effect is different. Let us learn it today together. - [SQL SERVER - SELECT vs. SET Performance Comparison](https://blog.sqlauthority.com/2007/04/27/sql-server-select-vs-set-performance-comparison/): Usage: SELECT : Designed to return data. SET : Designed to assign values to local variables. While testing the performance of the following two scripts in query analyzer, interesting results are discovered. SET @foo1 = 1; SET @foo2 = 2; SET @foo3 = 3; SELECT @foo1 = 1, @foo2 = 2, @foo3 = 3; While comparing their performance in loop SELECT statement gives better performance then SET. In other words, SET is slower than SELECT. The reason is that each SET statement runs individually and updates on values per execution, whereas the entire SELECT statement runs once and update all three... - [SQL SERVER - Difference Between Unique Index vs Unique Constraint](https://blog.sqlauthority.com/2007/04/26/sql-server-difference-between-unique-index-vs-unique-constraint/): Unique Index and Unique Constraint are the same. They achieve same goal. SQL Performance is same for both. Add Unique Constraint ALTER TABLE dbo.<tablename> ADD CONSTRAINT <namingconventionconstraint> UNIQUE NONCLUSTERED ( <columnname> ) ON [PRIMARY] Add Unique Index CREATE UNIQUE NONCLUSTERED INDEX <namingconventionconstraint> ON dbo.<tablename> ( <columnname> ) ON [PRIMARY] There is no difference between Unique Index and Unique Constraint. Even though syntax are different the effect is the same. Unique Constraint creates Unique Index to maintain the constraint to prevent duplicate keys. Unique Index or Primary Key Index are physical structure that maintain uniqueness over some combination of columns across all... - [SQL SERVER - Enable xp_cmdshell using sp_configure](https://blog.sqlauthority.com/2007/04/26/sql-server-enable-xp_cmdshell-using-sp_configure/): The xp_cmdshell option is a server configuration option that enables system administrators to control whether the xp_cmdshell extended stored procedure can be executed on a system. - [SQL SERVER - 2005 - DBCC ROWLOCK - Deprecated](https://blog.sqlauthority.com/2007/04/26/sql-server-2005-dbcc-rowlock-deprecated/): Title says all. My search engine log says many web users are looking for DBCC ROWLOCK in SQL SERVER 2005. It is deprecated feature for SQL SERVER 2005. It is Automatically on for SQL SERVER 2005. More Deprecated Features of SQL SERVER 2005 Refer MSDN Discontinued Database Engine Functionality in SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Alternate Fix : ERROR 1222 : Lock request time out period exceeded](https://blog.sqlauthority.com/2007/04/25/sql-server-alternate-fix-error-1222-lock-request-time-out-period-exceeded/): ERROR 1222 : Lock request time out period exceeded. - [SQL SERVER - ERROR Messages - sysmessages error severity level](https://blog.sqlauthority.com/2007/04/25/sql-server-error-messages-sysmessages-error-severity-level/): SQL ERROR Messages Each error message displayed by SQL Server has an associated error message number that uniquely identifies the type of error. The error severity levels provide a quick reference for you about the nature of the error. The error state number is an integer value between 1 and 127; it represents information about the source that issued the error. The error message is a description of the error that occurred. The error messages are stored in the sysmessages system table. - [SQL SERVER - 2005 Take Off Line or Detach Database](https://blog.sqlauthority.com/2007/04/25/sql-server-2005-take-off-line-or-detach-database/): EXEC sp_dboption N'mydb', N'offline', N'true' OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK AFTER 30 SECONDS OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK IMMEDIATE Using the alter database statement (SQL Server 2k and beyond) is the preferred method. The rollback after statement will force currently executing statements to rollback after N seconds. The default is to wait for all currently running transactions to complete and for the sessions to be terminated. Use the rollback immediate clause to rollback transactions immediately. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - TRIM() Function - UDF TRIM()](https://blog.sqlauthority.com/2007/04/24/sql-server-trim-function-udf-trim/): SQL Server does not have function which can trim leading or trailing spaces of any string. TRIM() is very popular function in many languages. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. I was expecting SQL Server 2005 to have TRIM() function. Unfortunately, SQL Server 2005 does not have that either. I have created very simple UDF which does the same work. FOR SQL SERVER 2000: CREATE FUNCTION dbo.TRIM(@string VARCHAR(8000)) RETURNS VARCHAR(8000) BEGIN RETURN LTRIM(RTRIM(@string)) END GO FOR SQL SERVER 2005: CREATE FUNCTION dbo.TRIM(@string VARCHAR(MAX)) RETURNS VARCHAR(MAX) BEGIN RETURN LTRIM(RTRIM(@string)) END GO Both the above... - [SQL SERVER - Six Properties of Relational Tables](https://blog.sqlauthority.com/2007/04/24/sql-server-six-properties-of-relational-tables/): Relational tables have six properties: Values Are Atomic This property implies that columns in a relational table are not repeating group or arrays. The key benefit of the one value property is that it simplifies data manipulation logic. Such tables are referred to as being in the “first normal form” (1NF). Column Values Are of the Same Kind In relational terms this means that all values in a column come from the same domain. A domain is a set of values which a column may have. This property simplifies data access because developers and users can be certain of the type... - [SQL SERVER - 2005 Collation Explanation and Translation](https://blog.sqlauthority.com/2007/04/24/sql-server-2005-collation-explanation-and-translation/): Just a day before one of our SQL SERVER 2005 needed Case-Sensitive Binary Collation. When we install SQL SERVER 2005 it gives options to select one of the many collation. I says in words like ‘Dictionary order, case-insensitive, uppercase preference’. I was confused for little while as I am used to read collation like ‘SQL_Latin1_General_Pref_Cp1_CI_AS_KI_WI’. I did some research and find following link which explains many of the SQL SERVER 2005 collation. Complete documentation MSDN – SQL SERVER Collation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Query Analyzer - Microsoft SQL SERVER Management Studio](https://blog.sqlauthority.com/2007/04/23/sql-server-2005-query-analyzer-microsoft-sql-server-management-studio/): Following may be very simple to some and helpful to other type of question. I have seen this in my server log as well as this has been always first question in my Developer Team. Where is SQL SERVER 2005 Query Analyzer? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). To see the familiour Query Analyzer Window follow the image below. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Find Seed Values, Increment Values and Current Identity Column value of the table](https://blog.sqlauthority.com/2007/04/23/sql-server-query-to-find-seed-values-increment-values-and-current-identity-column-value-of-the-table/): Following script will return all the tables which has identity column. It will also return the Seed Values, Increment Values and Current Identity Column value of the table. SELECT IDENT_SEED(TABLE_NAME) AS Seed, IDENT_INCR(TABLE_NAME) AS Increment, IDENT_CURRENT(TABLE_NAME) AS Current_Identity, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1 AND TABLE_TYPE = 'BASE TABLE' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Understanding new Index Type of SQL Server 2005 Included Column Index along with Clustered Index and Non-clustered Index](https://blog.sqlauthority.com/2007/04/23/sql-server-understanding-new-index-type-of-sql-server-2005-included-column-index-along-with-clustered-index-and-non-clustered-index/): Clustered Index Only 1 allowed per table Physically rearranges the data in the table to conform to the index constraints. - [SQL SERVER - Raid Configuration - RAID 10](https://blog.sqlauthority.com/2007/04/22/sql-server-raid-configuration-raid-10/): I get question about what configuration of redundant array of inexpensive disks (RAID) I use for my SQL Servers. The answer is short is: RAID 10. Why? Excellent performance with Read and Write. RAID 10 has advantage of both RAID 0 and RAID 1. RAID 10 uses all the drives in the array to gain higher I/O rates so more drives in the array higher performance. RAID 5 has penalty for write performance because of the parity in check. There are many article already written about them. If you are interested in reading more please refer book online. Reference : Pinal... - [SQL SERVER - @@DATEFIRST and SET DATEFIRST Relations and Usage](https://blog.sqlauthority.com/2007/04/22/sql-server-datefirst-and-set-datefirst-relations-and-usage/): The master database’s syslanguages table has a DateFirst column that defines the first day of the week for a particular language. SQL Server with US English as default language, SQL Server sets DATEFIRST to 7 (Sunday) by default. We can reset any day as first day of the week using SET DATEFIRST 5 This will set Friday as first day of week. @@DATEFIRST returns the current value, for the session, of SET DATEFIRST. SET LANGUAGE italian GO SELECT @@DATEFIRST GO ----This will return result as 1(Monday) SET LANGUAGE us_english GO SELECT @@DATEFIRST GO ----This will return result as 7(Sunday) In this... - [SQL SERVER - Fix : Error 1418 - Microsoft SQL Server - The server network address can not be reached](https://blog.sqlauthority.com/2007/04/22/sql-server-fix-error-1418-microsoft-sql-server-the-server-network-address-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-reissue-the-command/): Error: 1418 – Microsoft SQL Server – The server network address can not be reached or does not exist. Check the network address name and reissue the command The server network endpoint did not respond because the specified server network address cannot be reached or does not exist. - [SQL Server Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/04/21/sql-server-interview-questions-and-answers-complete-list-download/): This is summary blog post for SQL Server Interview Questions and Answers. Click here to get free chapters (PDF) in the mailbox. - [SQL Server Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2007/04/20/sql-server-interview-questions-part-6/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2007/04/19/sql-server-interview-questions-part-5/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2007/04/18/sql-server-interview-questions-part-4/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/04/17/sql-server-interview-questions-part-3/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/04/16/sql-server-interview-questions-part-2/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions-and-answers-introduction/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL SERVER - 64 bit Architecture and White Paper](https://blog.sqlauthority.com/2007/04/14/sql-server-64-bit-architecture-and-white-paper/): In supportability, manageability, scalability, performance, interoperability, and business intelligence, SQL Server 2005 provides far richer 64-bit support than its predecessor. This paper describes these enhancements. Read the original paper here. Following abstract is taken from the same paper. Another interesting article on 64-bit Computing with SQL Server 2005 is here. The primary differences between the 64-bit and 32-bit versions of SQL Server 2005 are derived from the benefits of the underlying 64-bit architecture. Some of these are: The 64-bit architecture offers a larger directly-addressable memory space. SQL Server 2005 (64-bit) is not bound by the memory limits of 32-bit systems. Therefore,... - [SQL SERVER - CASE Statement/Expression Examples and Explanation](https://blog.sqlauthority.com/2007/04/14/sql-server-case-statementexpression-examples-and-explanation/): CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in functions. Two basic formulations for CASE expression 1) Simple CASE expressions A simple CASE expression checks one expression against multiple values. Within a SELECT statement, a simple CASE expression allows only an equality check; no other comparisons are made. A simple CASE expression operates by comparing the first expression to the expression in each WHEN clause for equivalency. If these expressions... - [SQL SERVER - Fix : Error: 18452 Login failed for user '(null)'. The user is not associated with a trusted SQL Server connection.](https://blog.sqlauthority.com/2007/04/14/sql-server-fix-error-18452-login-failed-for-user-null-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Some errors never got old. I have seen many new DBA or Developers struggling with this errors. Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection. Fix/Solution/Workaround: Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)” to “Mixed Mode (Windows Authentication and SQL Server Authentication)”. Run following script in SQL Analyzer to change the authentication LOGIN sa ENABLE GO ALTER LOGIN sa WITH PASSWORD = '<password>' GO OR In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties. On the General page, you may have to create... - [SQL SERVER - Stored Procedures Advantages and Best Advantage](https://blog.sqlauthority.com/2007/04/13/sql-server-stored-procedures-advantages-and-best-advantage/): There are many advantages of Stored Procedures. I was once asked what do I think is the most important feature of Stored Procedure? I have to pick only ONE. It is tough question. I answered : Execution Plan Retention and Reuse (SP are compiled and their execution plan is cached and used again to when the same SP is executed again) Not to mentioned I received the second question following my answer : Why? Because all the other advantage known (they are mentioned below) of SP can be achieved without using SP. Though Execution Plan Retention and Reuse can only be... - [SQL SERVER – Precision of SMALLDATETIME – A 1 Minute Precision](https://blog.sqlauthority.com/2010/06/01/sql-server-precision-of-smalldatetime-a-1-minute-precision/): I am myself surprised that I am writing this post today. I am going to present one of the very known facts of SQL Server SMALLDATETIME datatype. Even though this is a very well-known datatype, many a time, I have seen developers getting confused with precision of the SMALLDATETIME datatype. The precision of the datatype SMALLDATETIME is 1 minute. It discards the seconds by rounding up or rounding down any seconds greater than zero. Let us see the following example DECLARE @varSDate AS SMALLDATETIME SET @varSDate = '1900-01-01&nbsp;12:12:01' SELECT @varSDate C_SDT SET @varSDate = '1900-01-01&nbsp;12:12:29' SELECT @varSDate C_SDT SET @varSDate =... - [SQLAuthority News - Monthly Roundup of Best SQL Posts](https://blog.sqlauthority.com/2010/05/31/sqlauthority-news-monthly-roundup-of-best-sql-posts/): After receiving lots of requests from different readers for long time I have decided to write first monthly round up. If all of you like it I will continue writing the same every month. In fact, I really like the idea as I was able to go back and read all of my posts written in this month. This month was started with answering one of the most common question asked me to about What is Adventureworks? Many of you know the answer but to the surprise more number of the reader did not know the answer. There were few extra... - [SQLAuthority News - Guest Post - Performance Counters Gathering using Powershell](https://blog.sqlauthority.com/2010/05/30/sqlauthority-news-guest-post-performance-counters-gathering-using-powershell/): Laerte Junior has previously helped me personally to resolve the issue with Powershell installation on my computer. He did an awesome job to help. He has sent this another wonderful article regarding performance counter for readers of this blog. I really liked it and I expect all of you who are Powershell geeks, you will like the same as well. - [SQLAuthority News - SQL Funny Quotes](https://blog.sqlauthority.com/2010/05/29/sqlauthority-news-guest-post-fault-contract-in-wcf-with-learning-video/): Here are few SQL Funny Quotes. Q. What if your Dad loses his car keys? A. 'Parent keys not found!' - [SQL SERVER - Disabled Index and Update Statistics](https://blog.sqlauthority.com/2010/05/28/sql-server-disabled-index-and-update-statistics/): When we try to update the statistics, it throws an error as if the clustered index is disabled. Now let us enable the clustered index only and attempt to update the statistics of the table right after that. Let us learn about Disabled Index and Update Statistics. - [SQL SERVER - DATE and TIME in SQL Server 2008](https://blog.sqlauthority.com/2010/05/27/sql-server-date-and-time-in-sql-server-2008/): I was thinking about DATE and TIME datatypes in SQL Server 2008. I earlier wrote about the about best practices of the same. Recently I had written one of the scripts written for SQL Server 2008 had to run on SQL Server 2005 (don’t ask me why!), I had to convert the DATE and TIME datatypes to DATETIME. Let me run a quick demo for the same. - [SQLAuthority News - SQL Server Technology Evangelists and Evangelism](https://blog.sqlauthority.com/2010/05/26/sqlauthority-news-sql-server-technology-evangelists-and-evangelism/): This is the exact conversation that I had with three people during the recent SQL Server Public Training. Person 1: “Are you an SQL Server Evangelist?” Pinal : “No, but Vinod Kumar is.” Person 1: “Who are you?” Person 2: “He is Pinal, haha!” Person 1: “I know that, but don’t you evangelize SQL Server Technology?” Pinal : “Hmm… I do that…” Person 1: “In that case, why don’t you call yourself an Evangelist?” Pinal : “…! …” Person 2: “Good Question! Who are you Pinal?” Pinal : “I think you are asking my title, is that correct?” Person 1: “Maybe.”... - [SQLAuthority News - Win MS Office License - Last 2 days](https://blog.sqlauthority.com/2010/05/26/sqlauthority-news-win-ms-office-license-last-2-days/): Just a note for everybody who is from India and want to win FREE Office License, participate in very easy contest here. SQLAuthority News – Virtual Launch Event for Office 2010 – Contest – Win MS Office License Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Whitepaper - SQL Azure vs. SQL Server](https://blog.sqlauthority.com/2010/05/25/sqlauthority-news-whitepaper-sql-azure-vs-sql-server/): SQL Server and SQL Azure are two Microsoft Products which goes almost together. There are plenty of misconceptions about SQL Azure. I have seen enough developers not planning for SQL Azure because they are not sure what exactly they are getting into. Some are confused thinking Azure is not powerful enough. I disagree and strongly urge all of you to read following white paper written and published by Microsoft. SQL Azure vs. SQL Server by Dinakar Nethi, Niraj Nagrani SQL Azure Database is a cloud-based relational database service from Microsoft. SQL Azure provides relational database functionality as a utility service. Cloud-based... - [SQLAuthority News – Microsoft SQL Server 2008 R2 – PowerPivot for Microsoft Excel 2010](https://blog.sqlauthority.com/2010/05/24/sqlauthority-news-microsoft-sql-server-2008-r2-powerpivot-for-microsoft-excel-2010/): Microsoft has really and truly created some buzz for PowerPivot. I have been asked to show the demo of Powerpivot in recent time even when I am doing relational database training. Attached is the few details where everyone can download PowerPivot and use the same. Microsoft SQL Server 2008 R2 – PowerPivot for Microsoft Excel 2010 – RTM Microsoft® PowerPivot for Microsoft® Excel 2010 provides ground-breaking technology, such as fast manipulation of large data sets (often millions of rows), streamlined integration of data, and the ability to effortlessly share your analysis through Microsoft® SharePoint 2010. Microsoft PowerPivot for Excel 2010 Samples... - [SQL SERVER – Check the Isolation Level with DBCC useroptions](https://blog.sqlauthority.com/2010/05/24/sql-server-check-the-isolation-level-with-dbcc-useroptions/): In recent consultancy project coordinator asked me – “can you tell me what is the isolation level for this database?” I have worked with different isolation levels but have not ever queried database for the same. I quickly looked up bookonline and found out the DBCC command which can give me the same details. You can run the DBCC UserOptions command on any database to get few details about dateformat, datefirst as well isolation level. DBCC useroptions Set Option                  Value --------------------------- -------------- textsize                    2147483647 language                    us_english dateformat                  mdy datefirst                   7 lock_timeout                -1 quoted_identifier           SET arithabort                  SET ansi_null_dflt_on           SET ansi_warnings               SET ansi_padding               ... - [SQLAuthority News - Virtual Launch Event for Office 2010 - Contest - Win MS Office License](https://blog.sqlauthority.com/2010/05/23/sqlauthority-news-virtual-launch-event-for-office-2010-contest-win-ms-office-license/): Office products are integral products of any PC. I accept that without Office Suites, I can not survive or make enough leaving. I am blogger and use word to create my blogs. I am SQL Server Trainer  and I use PowerPoint as my presentation tool. I am SQL Server consultant and I use Excel to keep my work log. I can not see my life with Office Tools. Just like any other Microsoft Product there is strong community following Office Tools. Please count me in. The same community is hosting a Virtual Launch Event for Office 2010 on May 25 and... - [SQLAuthority News - Downloads Available for Microsoft SQL Server Compact 3.5](https://blog.sqlauthority.com/2010/05/22/sqlauthority-news-downloads-available-for-microsoft-sql-server-compact-3-5/): There are few downloads released for Microsoft SQL Server Compact 3.5. Here is quick lists of the same. Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Desktop SQL Server Compact 3.5 SP2 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP2 and Synchronization Services for ADO.NET version 1.0 SP1 on Windows desktop. Microsoft SQL Server Compact 3.5 Service Pack 2 Server Tools SQL Server Compact 3.5 SP2 Server Tools Windows Installer (MSI) file installs replication components on the computer... - [SQL SERVER - Simple Example of Snapshot Isolation - Reduce the Blocking Transactions](https://blog.sqlauthority.com/2010/05/21/sql-server-simple-example-of-snapshot-isolation-reduce%c2%a0the%c2%a0blocking%c2%a0transactions/): To learn any technology and move to a more advanced level, it is very important to understand the fundamentals of the subject first. Today, we will be talking about something which has been quite introduced a long time ago but not properly explored when it comes to the isolation level. Snapshot Isolation was introduced in SQL Server in 2005. However, the reality is that there are still many software shops which are using the SQL Server 2000, and therefore cannot be able to maintain the Snapshot Isolation. Many software shops have upgraded to the later version of the SQL Server, but... - [SQLAuthority News – Professional Development and Community](https://blog.sqlauthority.com/2010/05/20/sqlauthority-news-professional-development-and-community/): I was recently invited by Hyderabad Techies to deliver a keynote for their 16-day online session called TECH THUNDERS. This event has been running from May 15 and will continue up to the end of the month May 30). There would be a total of 30 sessions. In every evening of those 16 day, there will be either one or two sessions from several noted industry experts. It is the same group which has received the Microsoft Community Impact Award as the Best User Group in India as for developers. This was my opportunity to talk about Professional Development. - [SQLAuthority News – Updated Favorite Scripts and Best Articles Page](https://blog.sqlauthority.com/2010/05/19/sqlauthority-news-updated-favorite-scripts-and-best-articles-page/): I have been writing on this blog for around 4 years now and have contributed with more than 1300 blog posts. Many times, I have been asked regarding what is my most favorite article or which is the most essential script for developers and DBA. This is very difficult to answer as I so much effort has been put on my blog and a large amount of content has been generated. However, I do keep a running list of my most favorite scripts and articles. This same are listed on the side bar of this blog as well; I am including... - [SQLAuthority Book Review - DBA Survivor: Become a Rock Star DBA](https://blog.sqlauthority.com/2010/05/18/sqlauthority-book-review-dba-survivor-become-a-rock-star-dba/): DBA Survivor: Become a Rock Star DBA – Thomas LaRock Link to Amazon Link to Flipkart First of all, I thank all my readers when I wrote that I could not get this book in any local book stores, because they offered me to send a copy of this good book. A very special mention goes to Sripada and Jayesh for they gave so much effort in finding my home address and sending me the hard copy. Before, I did not have the copy of the book, but now I have two of it already! It surprises me how my readers... - [SQLAuthority News - Bookmark - Deprecated Database Engine Features in SQL Server 2008](https://blog.sqlauthority.com/2010/05/17/sqlauthority-news-bookmark-deprecated-database-engine-features-in-sql-server-2008/): When anyone asked me if any specific feature is available in SQL Server 2008 or if any feature will be disabled in future versions of SQL Server, I always pointed to the following list where all the deprecated database engine features are listed. - [SQLAuthority News - Storage and SQL Server Capacity Planning and configuration - SharePoint Server 2010](https://blog.sqlauthority.com/2010/05/16/sqlauthority-news-storage-and-sql-server-capacity-planning-and-configuration-sharepoint-server-2010/): Just a day ago, I was asked how do you plan SQL Server Storage Capacity. Here is the excellent article published by Microsoft regarding SQL Server capacity planning for SharePoint 2010. This article touches all the vital areas of this subject. Here are the bullet points for the same. Gather storage and SQL Server space and I/O requirements Choose SQL Server version and edition Design storage architecture based on capacity and IO requirements Determine memory requirements Understand network topology requirements Configure SQL Server Validate storage performance and reliability Read the original article published by Microsoft here: Storage and SQL Server Capacity... - [SQL SERVER - List All the DMV and DMF on Server](https://blog.sqlauthority.com/2010/05/15/sql-server-list-all-the-dmv-and-dmf-on-server/): "How many DMV and DVF are there in SQL Server 2008?" - this question was asked to me in one of the recent SQL Server Training. - [SQL SERVER - Find Most Expensive Queries Using DMV](https://blog.sqlauthority.com/2010/05/14/sql-server-find-most-expensive-queries-using-dmv/): The title of this post is what I can express here for this quick blog post. I was asked in recent query tuning consultation project, if I can share my script which I use to figure out which is the most expensive queries are running on SQL Server. This script is very basic and very simple, there are many different versions are available online. This basic script does do the job which I expect to do - find out the most expensive queries in SQL Server Box. - [SQL SERVER - Four Posts on Removing the Bookmark Lookup - Key Lookup](https://blog.sqlauthority.com/2010/05/13/sql-server-four-posts-on-removing-the-bookmark-lookup-key-lookup/): Recently, I have observed that not many people have proper understanding of what is bookmark lookup or key lookup. Increasing numbers of the questions tells me that this is something that developers encounter every single day, but have no idea how to deal with. I have previously written three posts on this subject. All those who are looking for further information can check out the following three posts. SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key... - [SQL SERVER - Understanding ALTER INDEX ALL REBUILD with Disabled Clustered Index](https://blog.sqlauthority.com/2010/05/12/sql-server-understanding-alter-index-all-rebuild-with-disabled-clustered-index/): This blog is in response to the ongoing communication with the reader who had earlier asked the question of SQL SERVER – Disable Clustered Index and Data Insert. The same reader has asked me the difference between ALTER INDEX ALL REBUILD and ALTER INDEX REBUILD along with disabled clustered index. Instead of writing a big theory, we will go over the demo right away. Here are the steps that we intend to follow. 1) Create Clustered and Nonclustered Index 2) Disable Clustered and Nonclustered Index 3) Enable – a) All Indexes, b) Clustered Index USE tempdb GO -- Drop Table if Exists IF EXISTS (SELECT *... - [SQL SERVER - Spatial Database Queries - What About BLOB](https://blog.sqlauthority.com/2010/05/11/sql-server-spatial-database-queries-what-about-blob-t-sql-tuesday-006/): Michael Coles is one of the most interesting book authors I have ever met. He has a flair of writing complex stuff in a simple language. There are a very few people like that. I really enjoyed reading his recent book, Expert SQL Server 2008 Encryption. I strongly suggest taking a look at it. Let us learn about Spatial Database Queries. - [SQL SERVER - Size of Index Table for Each Index - Solution 3 - Powershell Index Size](https://blog.sqlauthority.com/2010/05/10/sql-server-size-of-index-table-for-each-index-solution-3-powershell/): If you are a Powershell user, the name of the Laerte Junior is not a new name. He is the one man with exceptional knowledge of Powershell. He is not only very knowledgeable, but also very kind and eager to those in need. I have been attempting to setup Powershell for many days, but constantly facing issues. I was not able to get going with this tool. Finally, yesterday I sent email to Laerte in response to his comment posted here. Within 5 minutes, Laerte came online and helped me with the solution. He spend nearly 15 minutes working along with me to solve my problem with installation. And yes, he did resolve it remotely without looking at my screen – What a skilled and exceptional person!! I will soon post a detail note about the issue I faced and resolved with the help of Laerte. Let us see how we can find Powershell Index Size. - [SQL SERVER - Size of Index Table for Each Index - Solution 2](https://blog.sqlauthority.com/2010/05/09/sql-server-size-of-index-table-for-each-index-solution-2/): Earlier I had ran puzzle where I asked question regarding size of index table for each index in database over here SQL SERVER – Size of Index Table – A Puzzle to Find Index Size for Each Index on Table. I had received good amount answers and I had blogged about that here SQL SERVER – Size of Index Table for Each Index – Solution. As a comment to that blog I have received another very interesting comment and that provides near accurate answers to original question. Many thanks to Rama Mathanmohan for providing wonderful solution. SELECT OBJECT_NAME(i.OBJECT_ID) AS TableName, i.name... - [SQLAuthority News - MSDN Flash Mentions - TechNet Flash Mention - Top Community Contributors (Annual) Winner](https://blog.sqlauthority.com/2010/05/08/sqlauthority-news-msdn-flash-mentions-technet-flash-mention-top-community-contributors-annual-winner/): I was going over my email to reach the famous Inbox (0), and I happened to come across TechNet Flash and MSDN Flash emails. I had kept them because those email editions had my names mentioned in them. Immediately, I took the screenshot of these. I am posting them here for later reference. It is always good idea to store important information for revisiting the memory lane. As a recent update, Microsoft has awarded me Top Community Contributors (Annual) Winners. I am thankful to you all as I would have not done this without your valuable contribution. I want to dedicate... - [SQLAuthority News - List of Master Data Services White Paper](https://blog.sqlauthority.com/2010/05/07/sqlauthority-news-list-of-master-data-services-white-paper/): Since my TechEd India 2010 presentation I am very excited with SQL Server 2010 Master Data Services. I just come across very interesting white paper on Microsoft site related to this subject. Here is the list of the same and location where you can download them. They are all written by Top Experts at Microsoft. - [SQLAuthority News - SQL Server 2008 R2 Hosted Trial](https://blog.sqlauthority.com/2010/05/06/sqlauthority-news-sql-server-2008-r2-hosted-trial/): This is a bit old news but for me but it will new for many of you know. SQLPASS, Dell, Microsoft and MaximumASP has come together and build hosted environment for free to all of us to use and experiment with. Register now to try out up to seven labs: SQL Server 2008 R2 – Multi Server Management SQL Server 2008 R2 – PowerPivot SQL Server 2008 R2 – Reporting Services SQL Server 2008 R2 – Master Data Services SQL Server 2008 R2 – StreamInsight SQL Server Integration Services – Introduction SQL Server Integration Services – Intermediate to Advanced Now this... - [SQLAuthority News - Wireless Router Security and Attached Devices - Complex Password](https://blog.sqlauthority.com/2010/05/06/sqlauthority-news-wireless-router-security-and-attached-devices-complex-password/): In the last week, I have received calls from friends who told me that they have got strange emails from me. To my surprise, I did not send them any emails. I was not worried until my wife complained that she was not able to find one of the very important folders containing our daughter’s photo that is located in our shared drive. This was alarming in my par, so I started a search around my computer’s folders. Again, please note that I am by no means a security expert. I checked my entire computer with virus and spyware, and strangely,... - [SQL SERVER - Get Latest SQL Query for Sessions - DMV](https://blog.sqlauthority.com/2010/05/05/sql-server-get-latest-sql-query-for-sessions-dmv/): In recent SQL Training I was asked, how can one figure out what was the last SQL Statement executed in sessions. The query for this is very simple. It uses two DMVs and created following quick script for the same. SELECT session_id, TEXT FROM sys.dm_exec_connections CROSS APPLY sys.dm_exec_sql_text(most_recent_sql_handle) AS ST While working with DMVs if you ever find any DMV has column with name sql_handle you can right away join that DMV with another DMV sys.dm_exec_sql_text and can get the text of the SQL statement. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Microsoft SQL Server 2005/2008 Query Optimization and Performance Tuning Training](https://blog.sqlauthority.com/2010/05/04/sqlauthority-news-microsoft-sql-server-20052008-query-optimization-performance-tuning-training/): Last 3 days to register for the courses. This is one time offer with big discount. The deadline for the course registration is 5th May, 2010. There are two different courses are offered by Solid Quality Mentors 1) Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning – Pinal Dave Date: May 12-14, 2010 Price: Rs. 14,000/person for 3 days Discount Code: ‘SQLAuthority.com’ Effective Price: Rs. 11,000/person for 3 days 2) SharePoint 2010 – Joy Rathnayake Date: May 10-11, 2010 Price: Rs. 11,000/person for 3 days Discount Code: ‘SQLAuthority.com’ Effective Price: Rs. 8,000/person for 2 days Download the complete PDF brochure.... - [SQL SERVER - SHRINKFILE and TRUNCATE Log File in SQL Server 2008](https://blog.sqlauthority.com/2010/05/03/sql-server-shrinkfile-and-truncate-log-file-in-sql-server-2008/): Note: Please read the complete post before taking any actions. This blog post would discuss SHRINKFILE and TRUNCATE Log File. The script mentioned in the email received from reader contains the following questionable code: “Hi Pinal, If you could remember, I and my manager met you at TechEd in Bangalore. We just upgraded to SQL Server 2008. One of our jobs failed as it was using the following code. The error was: Msg 155, Level 15, State 1, Line 1 ‘TRUNCATE_ONLY’ is not a recognized BACKUP option. The code was: DBCC SHRINKFILE(TestDBLog, 1) BACKUP LOG TestDB WITH TRUNCATE_ONLY DBCC SHRINKFILE(TestDBLog, 1)... - [SQL SERVER - The Difference between Dual Core vs. Core 2 Duo](https://blog.sqlauthority.com/2010/05/02/sql-server-the-difference-between-dual-core-vs-core-2-duo/): I have decided that I would not write on this subject until I have received a total of 25 questions on this subject about dual core.  - [SQL SERVER - What is AdventureWorks?](https://blog.sqlauthority.com/2010/05/01/sql-server-what-is-adventureworks/): A few days ago, I received DM asking What is an AdventureWorks database and why in all the examples I use that instead of any other database (e.g. Pubs or  Northwind)? As matter of fact, when I went back to my question list, which I have yet not answered, there were a few more variations of this same question. - [SQLAuthority News - TechEd India - April 12-14, 2010 Bangalore - An Unforgettable Experience](https://blog.sqlauthority.com/2010/04/30/sqlauthority-news-teched-india-april-12-14-2010-bangalore-an-unforgettable-experience-an-opportunity-of-a-lifetime/): TechEd India was one of the largest Technology events in India led by Microsoft. This event was attended by more than 3,000 technology enthusiasts, making it one of the most well-organized events of the year. Though I attempted to attend almost all the technology events here, I have not seen any bigger or better event in Indian subcontinents other than this. There are 21 Technical Tracks at Tech·Ed India 2010 that span more than 745 learning opportunities. I was fortunate enough to be a part of this whole event as a speaker and a delegate, as well. - [SQL SERVER - Disable Clustered Index and Data Insert](https://blog.sqlauthority.com/2010/04/29/sql-server-disable-clustered-index-and-data-insert/): Earlier today, I received following email. “Dear Pinal, We looked at your script and found out that in your script of disabling indexes, you have only included selected non-clustered index during the bulk insert and missed to disabled all the clustered index. Our DBA [name removed] has changed your script a bit and included all the clustered indexes. Since then our application is not working. When DBA [name removed] tried to enable clustered indexes again he is facing error Incorrect syntax error. We are in deep problem [word replaced] [Removed Identity of organization and few unrelated stuff ]” I have replied... - [SQL SERVER - GUID vs INT - Your Opinion](https://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/): I think the title is clear what I am going to write in your post. This is age old problem and I want to compile the list stating advantages and disadvantages of using GUID and INT as a Primary Key or Clustered Index or Both (the usual case). Let me start a list by suggesting one advantage and one disadvantage in each case. INT Advantage: Numeric values (and specifically integers) are better for performance when used in joins, indexes and conditions. Numeric values are easier to understand for application users if they are displayed. Disadvantage: If your table is large, it... - [SQLAuthority News - Public Training Classes In Hyderabad 12-14 May - SQL and 10-11 May SharePoint](https://blog.sqlauthority.com/2010/04/27/sqlauthority-news-public-training-classes-in-hyderabad-12-14-may-microsoft-sql-server-20052008-query-optimization-performance-tuning-2/): There were lots of request about providing more details for the blog post through email address specified in the article SQLAuthority News – Public Training Classes In Hyderabad 12-14 May – Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning. Here is the complete brochure of the course. There are two different courses are offered by Solid Quality Mentors 1) Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning – Pinal Dave Date: May 12-14, 2010 Price: Rs. 14,000/person for 3 days Discount Code: ‘SQLAuthority.com‘ Effective Price: Rs. 11,000/person for 3 days 2) SharePoint 2010 – Joy Rathnayake Date: May 10-11,... - [SQLAuthority News - Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning Training](https://blog.sqlauthority.com/2010/04/26/sqlauthority-news-public-training-classes-in-hyderabad-12-14-may-microsoft-sql-server-20052008-query-optimization-performance-tuning/): After successfully delivering many corporate training as well as the private training we are launching the Public Training in Hyderabad for SQL Server 2008. I will be leading the training on Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning Training. - [SQL SERVER – Attach mdf file without ldf file in Database](https://blog.sqlauthority.com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/): Background Story: One of my friends recently called up and asked me if I had spare time to look at his database and give him a performance tuning advice. Because I had some free time to help him out, I said yes. I asked him to send me the details of his database structure and sample data. He said that since his database is in a very early stage and is small as of the moment, so he told me that he would like me to have a complete database. My response to him was “Sure! In that case, take a... - [SQLAuthority News - Free Download - Microsoft SQL Server 2008 R2 RTM - Express with Management Tools - SQL Server 2008 R2 Books Online](https://blog.sqlauthority.com/2010/04/25/sqlauthority-news-free-download-microsoft-sql-server-2008-r2-rtm-express-with-management-tools/): This blog post is in response to several inquiry about Free Download of SQL Server 2008 R2 RTM. Microsoft has announced SQL Server 2008 R2 as RTM (Release To Manufacture). Microsoft® SQL Server® 2008 R2 Express is a powerful and reliable data management system that delivers a rich set of features, data protection, and performance for embedded applications, lightweight Web Sites and applications, and local data stores. Download Microsoft SQL Server 2008 R2 RTM – Express with Management Tools. Download Microsoft SQL Server 2008 R2 RTM – Management Studio Express. Download SQL Server 2008 R2 Books Online. Reference : Pinal Dave... - [SQL SERVER - T-SQL Script to Take Database Offline - Take Database Online](https://blog.sqlauthority.com/2010/04/24/sql-server-t-sql-script-to-take-database-offline-take-database-online/): Blog reader Joyesh Mitra recently left a comment to one of my very old posts about SQL SERVER – 2005 Take Off Line or Detach Database, which I have written focusing on taking the database offline. However, I did not include how to bring the offline database to online in that post. The reason I did not write it was that I was thinking it was a very simple script that almost everyone knows. However, it seems to me that there is something I found advanced and that is simple for other people sometime, in this case, I thought simple and... - [SQL SERVER - Update Statistics are Sampled By Default](https://blog.sqlauthority.com/2010/04/23/sql-server-update-statistics-are-sampled-by-default-2/): After reading my earlier post SQL SERVER – Create Primary Key with Specific Name when Creating Table on Statistics, I have received another question by a blog reader. The question is as follows: Question: Are the statistics sampled by default? Answer: Yes. The sampling rate can be specified by the user and it can be anywhere between a very low value to 100%. Let us do a small experiment to verify if the auto update on statistics is left on. Also, let’s examine a very large table that is created and statistics by default- whether the statistics are sampled or not.... - [SQL SERVER - Create Primary Key with Specific Name when Creating Table](https://blog.sqlauthority.com/2010/04/22/sql-server-create-primary-key-with-specific-name-when-creating-table/): It is interesting how sometimes the documentation of simple concepts is not available online. I had received email from one of the reader where he has asked how to create Primary key with a specific name when creating the table itself. He said, he knows the method where he can create the table and then apply the primary key with specific name. The attached code was as follows: CREATE TABLE [dbo].[TestTable]( [ID] [int] IDENTITY(1,1) NOT NULL, [FirstName] [varchar](100) NULL) GO ALTER TABLE [dbo].[TestTable] ADD  CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED ([ID] ASC) GO He wanted to know if we can create Primary Key as part of the table name as well, and... - [SQL SERVER - When Are Statistics Updated - What Triggers Statistics to Update](https://blog.sqlauthority.com/2010/04/21/sql-server-when-are-statistics-updated-what-triggers-statistics-to-update/): If you are an SQL Server Consultant/Trainer involved with Performance Tuning and Query Optimization, I am sure you have faced the following questions many times. When is statistics updated? What is the interval of Statistics update? What is the algorithm behind update statistics? These are the puzzling questions and more. - [SQL SERVER - Find Max Worker Count using DMV - 32 Bit and 64 Bit](https://blog.sqlauthority.com/2010/04/20/sql-server-find-max-worker-count-using-dmv-32-bit-and-64-bit/): During several recent training courses, I found it very interesting that Worker Thread is not quite known to everyone despite the fact that it is a very important feature. At some point in the discussion, one of the attendees mentioned that we can double the Worker Thread if we double the CPU (add the same number of CPU that we have on current system). The same discussion has triggered this quick article. Here is the DMV which can be used to find out Max Worker Count SELECT max_workers_count FROM sys.dm_os_sys_info Let us run the above query on my system and find... - [SQL SERVER - Find Most Active Database in SQL Server - DMV dm_io_virtual_file_stats](https://blog.sqlauthority.com/2010/04/19/sql-server-find-most-active-database-in-sql-server-dmv-dm_io_virtual_file_stats/): Few days ago, I wrote about SQL SERVER – Find Current Location of Data and Log File of All the Database. There was very interesting conversation in comments by blog readers. Blog reader and SQL Expert Sreedhar has very interesting DMV presented which lists the most active database in SQL Server. For quick reference he has included the size of the disk in KB, MB and GB as well. SELECT DB_NAME(mf.database_id) AS databaseName, name AS File_LogicalName, CASE WHEN type_desc = 'LOG' THEN 'Log File' WHEN type_desc = 'ROWS' THEN 'Data File' ELSE type_desc END AS File_type_desc ,mf.physical_name ,num_of_reads ,num_of_bytes_read ,io_stall_read_ms ,num_of_writes ,num_of_bytes_written ,io_stall_write_ms ,io_stall... - [SQLAuthority News - Free eBook Download - Introducing Microsoft SQL Server 2008 R2](https://blog.sqlauthority.com/2010/04/18/sqlauthority-news-free-ebook-download-introducing-microsoft-sql-server-2008-r2/): Microsoft Press has published a FREE eBook on the most awaiting releases of SQL Server 2008 R2. The book is written by Ross Mistry and Stacia Misner. Ross is my personal friend and one of the most active book writers in SQL Server Domain. When I see his name on any book, I am sure that it will be high quality and easy to read book. - [SQL SERVER - SELECT TOP Shortcut in SQL Server Management Studio (SSMS)](https://blog.sqlauthority.com/2010/04/17/sql-server-select-top-shortcut-in-sql-server-management-studio-ssms/): This is tool is pretty old, yet always comes as a handy tip. I had a great trip at TechEd in India. And, during one of my presentations, I was asked if there are any shortcuts to SELECT only TOP 100 records from SSMS. I immediately told him that if he explores the table in SSMS, he can just right click on it and SELECT TOP 1000 records. If he wanted only 100 records, then he could edit that 1000 to 100 by means of going to Options. Go to Options, then hover the mouse over the SQL Server Object Explorer,... - [SQLAuthority News - Best Compliment - DBA Survivor: Become a Rock Star DBA](https://blog.sqlauthority.com/2010/04/16/sqlauthority-news-best-compliment-dba-survivor-become-rock-star-dba/): Today's blog post is about the best compliment I have ever received. I am very, very happy and would like to share my feelings with you. Thomas Larock (Blog | Twitter) (known as SQLRockstar) keeps the excellent ranking of the blogger in the SQL Server Arena. I am a big fan of this list and have been referring lots of people. - [SQLAuthority News - Tips for Traveling to Nepal](https://blog.sqlauthority.com/2010/04/15/sqlauthority-news-tips-for-traveling-to-nepal/): If you are a regular reader of this blog, you might know that I travel nearly 20+ days out of 30 days in a month. There are cases when I don’t have a chance to go home for an entire month and my family has to travel to different cities just to meet me. During my recent visit, one of my acquaintances suggested that I should blog about my travel experiences as well. This can be helpful to others who are traveling to the country or city. This blog post is about Nepal. - [SQL SERVER - What is Spatial Database? - Developing with SQL Server Spatial and Deep Dive into Spatial Indexing](https://blog.sqlauthority.com/2010/04/14/sql-server-what-is-spatial-database-developing-with-sql-server-spatial-and-deep-dive-into-spatial-indexing/): What is Spatial Database? A spatial database is a database that is optimized to store and query data related to objects in space, including points, lines and polygons. While typical databases can understand various numeric and character types of data, additional functionality needs to be added for databases to process spatial data types. (Source: Wikipedia) Today I will be talking about the same subject at Microsoft TechEd India. If you want to learn about how to spatial aspect of data and how to integrate them with SQL Server this is the perfect session for you. Spatial is very special concept of... - [SQL SERVER - Configure Management Data Collection in Quick Steps - T-SQL Tuesday #005](https://blog.sqlauthority.com/2010/04/13/sql-server-configure-management-data-collection-in-quick-steps-t-sql-tuesday-005/): This article was written as a response to T-SQL Tuesday #005 – Reporting. The three most important components of any computer and server are the CPU, Memory, and Hard disk specification. This post talks about  how to get more details about these three most important components using the Management Data Collection. Management Data Collection generates the reports for the three said components by default. Configuring Data Collection is a very easy task and can be done very quickly. Please note: There are many different ways to get reports generated for CPU, Memory and IO. You can use DMVs, Extended Events as... - [SQLAuthority News - Three Posts on Reporting - T-SQL Tuesday #005](https://blog.sqlauthority.com/2010/04/13/sqlauthority-news-three-posts-on-reporting-t-sql-tuesday-005/): If you are following my blog, you already know that I am more of “T-SQL and Performance Tuning” type of person. I do have a good understanding of Business Intelligence suit and I also do certain training sessions on the same subject. When I was writing the blog post for T-SQL Tuesday #005 – Reporting, I realized that I have written a post that clearly explains how to generate reports using SQL Server Management Studio. Here is a quick recap on how one can use SSMS and out-of-the-box reports which can help many developers. Please note that they can be resource-intensive... - [SQL SERVER - What is MDS? - Master Data Services in Microsoft SQL Server](https://blog.sqlauthority.com/2010/04/12/sql-server-what-is-mds-master-data-services-in-microsoft-sql-server-2008-r2/): What is MDS? Master Data Services helps enterprises standardize the data people rely on to make critical business decisions. With Master Data Services, IT organizations can centrally manage critical data assets company wide and across diverse systems, enable more people to securely manage master data directly, and ensure the integrity of information over time. (Source: Replace with Microsoft) - [SQLAuthority News - SQL Server Cheat Sheet](https://blog.sqlauthority.com/2010/04/11/sqlauthority-news-spot-the-sqlauthority-baby-contest-sql-server-cheat-sheet/): I received many requests for the same. I have only 30 copies available at this moment. I will print more copies of the cheat sheet. - [SQLAuthority News - Speaking Sessions at TechEd India - 3 Sessions - 1 Panel Discussion](https://blog.sqlauthority.com/2010/04/10/sqlauthority-news-speaking-sessions-at-teched-india-3-sessions-1-panel-discussion/): Microsoft Tech-Ed India 2010 is considered as the major Technology event of the year for various IT professionals and developers. This event will feature a comprehensive forum in order   to learn, connect, explore, and evolve the current technologies we have today. I would recommend this event to you since here you will learn about today’s cutting-edge trends, thereby enhancing your work profile and getting ahead of the rest. But, the most important benefit of all might be the networking opportunity that that you can attain by attending the forum. You can build personal connections with various Microsoft experts and peers that... - [SQLAuthority News - Meeting with Allen Bailochan Tuladhar - An Unlimited Experience](https://blog.sqlauthority.com/2010/04/09/sqlauthority-news-meeting-with-allen-bailochan-tuladhar-an-unlimited-experience/): I recently came back from my 9-day trip in Nepal and I must say that this is one of the best trips I had in my lifetime. Allen Bailochan Tuladhar is a wonderful person and an extreme enthusiast for Microsoft Technology. Allen is the Chief Executive Officer of Unlimited Technologies Pvt Ltd., Country Manager of Microsoft MDP Nepal, the Member Secretary of Nepali Language in Information Technology, and member of the Steering Committee of the Government of Nepal. It an was unlimited experience for sure. - [SQLAuthority News - Author Visit Review - TechMela Nepal - March 29-30, 2010](https://blog.sqlauthority.com/2010/04/08/sqlauthority-news-author-visit-review-techmela-nepal-march-29-30-2010/): I was very fortunate to attend TechMela at Kathmandu, Nepal on 29th and 30th of March 2010. I would like to thank Allen Bailochan Tuladhar from Microsoft MDP Nepal for inviting me. Allen is a person with seemingly infinite energy and unlimited passion for Microsoft Technology. If you get an opportunity to spend just one hour with him, you will surely be more enthusiastic with regards to Microsoft Technology. And, I was lucky enough that I was able to spend about a total of 9 days with him in Kathmandu, working along with him in the Tech Community. TechMela is considered... - [SQLAuthority News - Milestone of 1300th Post and A Few Updates](https://blog.sqlauthority.com/2010/04/07/sqlauthority-news-milestone-of-1300th-post-and-few-updates/): Today is my 1300th blog post and I realize that my blog has been quite running such a long journey. I have been writing for a lengthy time on this tech blog. Today I would like to go back and briefly recall the posts that were part of my blog’s history. Read all list of all my blog posts here. This blog only started as a list of personal bookmarks. I used to just write down scripts on the blog for my personal use. I was the one who wrote many scripts here for the servers that I was maintaining to... - [SQL SERVER - Retrieve and Explore Database Backup without Restoring Database - Idera virtual database](https://blog.sqlauthority.com/2010/04/06/sql-server-retrieve-and-explore-database-backup-without-restoring-database-idera-virtual-database/): I recently downloaded Idera’s SQL virtual database, and tested it. There are a few things about this tool which caught my attention. Let us learn about Retrieve and Explore Database Backup without Restoring Database. - [SQL SERVER - 2008 - Introduction to Snapshot Database - Restore From Snapshot](https://blog.sqlauthority.com/2010/04/05/sql-server-2008-introduction-to-snapshot-database-restore-from-snapshot/): Snapshot database is one of the most interesting concepts that I have used at some places recently. Here is a quick definition of the subject from Book On Line: A Database Snapshot is a read-only, static view of a database (the source database). Multiple snapshots can exist on a source database and can always reside on the same server instance as the database. Each database snapshot is consistent, in terms of transactions, with the source database as of the moment of the snapshot’s creation. A snapshot persists until it is explicitly dropped by the database owner. If you do not know... - [SQL SERVER - Enable Identity Insert - Import Expert Wizard](https://blog.sqlauthority.com/2010/04/04/sql-server-enable-identity-insert-import-expert-wizard/): I recently got an email from an old friend who told me that when he tries to execute the SSIS package, it fails because of some identity error. After a few series of debugging and opening his package, we finally figured out that he has the following problem. Let's learn how to Enable Identity Insert – Import Expert Wizard. - [SQL SERVER - Difference Between GRANT and WITH GRANT](https://blog.sqlauthority.com/2010/04/03/sql-server-difference-between-grant-and-with-grant/): What is the difference between GRANT and WITH GRANT when giving permissions to the user? This is a very interesting question recently asked me to during my session at TechMela Nepal. Let us first see the syntax and analyze. GRANT: USE master; GRANT VIEW ANY DATABASE TO username; GO WITH GRANT: USE master; GRANT VIEW ANY DATABASE TO username WITH GRANT OPTION; GO The difference between these options is very simple. In case of only GRANT, the username cannot grant the same permission to other users. On the other hand, with the option WITH GRANT, the username will be able to give the permission after receiving requests... - [SQL SERVER - Simple Installation of Master Data Services (MDS) and Sample Packages - Very Easy](https://blog.sqlauthority.com/2010/04/02/sql-server-simple-installation-of-master-data-services-mds-and-sample-packages-very-easy/): I twitted recently about: ‘Installing #sql Server 2008 R2 – Master Data Services. Painless.’ After doing so, I got quite a few emails from other users as to why I thought it was painless. The reason was very simple- I was able to install it rather quickly on my laptop without any issues. There were a few requests along with these emails sent to me, which regards to how to install MDS, as well sample databases. Please note that I am the admin of my machine and I installed this MDS as the admin as well. Talk to your network administrator... - [SQLAuthority News - MS Access Database is the Way to Go - April 1st Humor](https://blog.sqlauthority.com/2010/04/01/sqlauthority-news-ms-access-database-is-the-way-to-go-april-1st-humor/): First of all, today is April 1- April Fool’s Day, so I have written this post for some light entertainment. My friend has just sent me an email about why a person should go for Access Database. For a short background, I used to be an MS Access user once (I will not call myself MS Access DBA), and I must say I had a good time with Database at that time. As time passed by, I moved from MS Access to SQL Server. Well, as for my friend’s email, his reasons considering MS Access usage really made me laugh. MS... - [SQLAuthority News - Fun Quotes about Technology](https://blog.sqlauthority.com/2010/03/31/sqlauthority-news-fun-quotes-technology/): SQL Server can be boring subject many times. In this blog post, let us see some of the fun quotes. - [SQL SERVER - World Shape files Download and Upload to Database - Spatial Database](https://blog.sqlauthority.com/2010/03/30/sql-server-world-shapefile-download-and-upload-to-database-spatial-database/): During my recent, training I was asked by a student if I know a place where he can download spatial files for all the countries around the world, as well as if there is a way to upload shape files to a database. Here is a quick tutorial for it. - [SQL SERVER - Introduction to Extended Events - Finding Long Running Queries](https://blog.sqlauthority.com/2010/03/29/sql-server-introduction-to-extended-events-finding-long-running-queries/): The job of an SQL Consultant is very interesting as always. The month before, I was busy doing query optimization and performance tuning projects for our clients, and this month, I am busy delivering my performance in Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning Course. I recently read white paper about Extended Event by SQL Server MVP Jonathan Kehayias. You can read the white paper here: Using SQL Server 2008 Extended Events. I also read another appealing chapter by Jonathan in the book, SQLAuthority Book Review – Professional SQL Server 2008 Internals and Troubleshooting. After reading these excellent notes by Jonathan, I decided to upgrade my course and include Extended Event as one of the modules. - [SQLAuthority News - Author Visit to Nepal TechMela - 2 Technical Sessions](https://blog.sqlauthority.com/2010/03/28/sqlauthority-news-author-visit-to-nepal-techmela-2-technical-sessions/): Microsoft MDP Nepal is going to organize a Tech Mela for the IT community of Nepal on March 29 & 30, 2010 (2066 Chaitra 16 & 17), Monday and Tuesday,  at the Russian Center for Science & Culture, Kamalpokhari, Kathmandu. The objective of the event is to enhance and exchange knowledge about Information Technology, as well as Microsoft products and technologies, with the IT community. I am very excited to attend this one-of-a-kind event in Nepal. - [SQL SERVER - FIX : ERROR : 4214 BACKUP LOG cannot be performed because there is no current database backup](https://blog.sqlauthority.com/2010/03/27/sql-server-fix-error-4214-backup-log-cannot-be-performed-because-there-is-no-current-database-backup/): I recently got following email from one of the readers. It is about Backup Log file. - [SQL SERVER - Generate Report for Index Physical Statistics - SSMS](https://blog.sqlauthority.com/2010/03/26/sql-server-generate-report-for-index-physical-statistics-ssms/): Few days ago, I wrote about SQL SERVER – Out of the Box – Activity and Performance Reports from SSSMS (Link). A user asked me a question regarding if we can use similar reports to get the detail about Indexes. Yes, it is possible to do the same. There are similar type of reports are available at Database level, just like those available at the Server Instance level. You can right click on Database name and click Reports. Under Standard Reports, you will find following reports. Disk Usage Disk Usage by Top Tables Disk Usage by Table Disk Usage by Partition... - [SQL SERVER - Out of the Box - Activity and Performance Reports from SSSMS](https://blog.sqlauthority.com/2010/03/25/sql-server-default-activty-and-performance-reports-from-sssms/): SQL Server management Studio 2008 is a wonderful tool and has many different features. Many times, an average user does not use them as they are not aware about these features. Today, we will learn one such feature. SSMS comes with many inbuilt performance reports and activity reports, but we do not use it to the full potential. - [SQL SERVER - Fix : Error : 8501 MSDTC on server is unavailable. Changed database context to publisherdatabase](https://blog.sqlauthority.com/2010/03/24/sql-server-fix-error-8501-msdtc-on-server-is-unavailable-changed-database-context-to-publisherdatabase/): During configuring replication on one of the server, I received following error. This is very common error and the solution of the same is even simpler. MSDTC on server is unavailable. Changed database context to publisherdatabase. (Microsoft SQL Server, Error: 8501) Solution: Enable “Distributed Transaction Coordinator” in SQL Server. Method 1: Click on Start–>Control Panel->Administrative Tools->Services Select the service “Distributed Transaction Coordinator” Right on the service and choose “Start” Method 2: Type services.msc in the run command box Select “Services” manager; Hit Enter Select the service “Distributed Transaction Coordinator” Right on the service and choose “Start” Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - We're sorry... ... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now. ](https://blog.sqlauthority.com/2010/03/23/sqlauthority-news-were-sorry-but-your-computer-or-network-may-be-sending-automated-queries-to-protect-our-users-we-cant-process-your-request-right-now/): I use multiple browser many times when I am working with multiple projects simultaneously. Often I use Google Reader to read few feeds. Recently, I faced the following error and this error will not go. I even restarted my computer and rebooted my network. I am confident that my computer does not have viruses or malware, I could not tackle this error. When I opened Google Reader on another browser, it worked fine. Finally, I found the solution and I want share it with all of you. Error We’re sorry… … but your computer or network may be sending automated queries.... - [SQL SERVER - Enumerations in Relational Database - Best Practice](https://blog.sqlauthority.com/2010/03/22/sql-server-enumerations-in-relational-database-best-practice/): This article has been submitted by Marko Parkkola, Data systems designer at Saarionen Oy, Finland. Marko is excellent developer and always thinking at next level. You can read his earlier comment which created very interesting discussion here: SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table). I must express my special thanks to Marko for sending this best practice for Enumerations in Relational Database. He has really wrote excellent piece here and welcome comments here. Enumerations in Relational Database This is a subject which is very basic thing in relational databases but often not very well understood... - [SQL SERVER - Fix : Error : 3117 : The log or differential backup cannot be restored because no files are ready to rollforward](https://blog.sqlauthority.com/2010/03/21/sql-server-fix-error-3117-the-log-or-differential-backup-cannot-be-restored-because-no-files-are-ready-to-rollforward/): I received the following email from one of my readers. Dear Pinal, I am new to SQL Server and our regular DBA is on vacation. Our production database had some problem and I have just restored full database backup to production server. When I try to apply log back I am getting following error. I am sure, this is valid log backup file. Screenshot is attached. [Few other details regarding server/ip address removed] Msg 3117, Level 16, State 1, Line 1 The log or differential backup cannot be restored because no files are ready to roll forward. Msg 3013, Level 16,... - [SQLAuthority News - Microsoft SQL Server Protocol Documentation Download](https://blog.sqlauthority.com/2010/03/20/sqlauthority-news-microsoft-sql-server-protocol-documentation-download/): Download Microsoft SQL Server Protocol Documentation Authored by Microsoft The Microsoft SQL Server protocol documentation provides detailed technical specifications for Microsoft proprietary protocols (including extensions to industry-standard or other published protocols) that are implemented and used in Microsoft SQL Server to interoperate or communicate with Microsoft products. The documentation includes a set of companion overview and reference documents that supplement the technical specifications with conceptual background, overviews of inter-protocol relationships and interactions, and technical reference information. Abstract courtesy Microsoft Microsoft SQL Server Protocol Documentation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interview Questions & Answers Needs Your Help](https://blog.sqlauthority.com/2010/03/19/sql-server-interview-questions-answers-needs-your-help/): Click here to get free chapters (PDF) in the mailbox About an year ago, I had posted SQL Server related Interview Questions and Answers. It was very well received in community. I have received many comments, suggestions and emails on this subject. I am planning to upgrade the Interview Questions and Answers and take it to next level. Here, I need your help. Please your comments, suggestions, expectation or potential interview Question (along with answer) here. Your input will be very valuable. As time goes by we all learn and get better. There were few things missing at that time when... - [SQL SERVER - Mirroring Configured Without Domain - The server network address TCP://SQLServerName:5023 can not be reached or does not exist](https://blog.sqlauthority.com/2010/03/18/sql-server-mirroring-configured-without-domain-the-server-network-address-tcpsqlservername5023-can-not-be-reached-or-does-not-exist/): Regular readers of my blog will be aware of my friend who called me few days ago with very a funny SQL Problem SQL SERVER – SSMS Query Command(s) completed successfully without ANY Results. This time, it did not take long before he called me up with another interesting problem, although the issue he was facing this time was not that interesting and also very specific to him, however, he insisted me to share with all of you. Let us understand his situation at first. My friend is preparing for DBA exam Exam 70-450: PRO: Designing, Optimizing and Maintaining a Database... - [SQL SERVER - Difference Between ROLLBACK IMMEDIATE and WITH NO_WAIT during ALTER DATABASE](https://blog.sqlauthority.com/2010/03/17/sql-server-difference-between-rollback-immediate-and-with-no_wait-during-alter-database/): We are going to discuss something very simple topic. Difference Between ROLLBACK IMMEDIATE and WITH NO_WAIT during ALTER DATABASE. - [SQL SERVER - Quick Note of Database Mirroring](https://blog.sqlauthority.com/2010/03/16/sql-server-quick-note-of-database-mirroring/): Just a day ago, I was invited at Round Table meeting at prestigious organization. They were planning to implement High Availability solution using Database Mirroring. During the meeting, I have made few notes of what was being discussed there. I just thought it would be interested for all of you know about it. Database Mirroring works on physical log records. SQL Server 2008 compresses the Transaction Log at Principal Server before it is transferred to mirror server. System databases can not be mirrored. Database which needs to be mirrored requires it to be in FULL recovery mode. High Safety Mode –... - [SQL SERVER - MAXDOP Settings to Limit Query to Run on Specific CPU](https://blog.sqlauthority.com/2010/03/15/sql-server-maxdop-settings-to-limit-query-to-run-on-specific-cpu/): This is very simple and known tip. Query Hint MAXDOP – Maximum Degree Of Parallelism can be set to restrict query to run on a certain CPU. Please note that this query cannot restrict or dictate which CPU to be used, but for sure, it restricts the usage of number of CPUs in a single batch. Let us consider the following example of this query. The following query usually runs on multicore on a dual core machine (please note it may not be the case with your machine). USE AdventureWorks GO SELECT * FROM Sales.SalesOrderDetail ORDER BY ProductID GO Now the same... - [SQLAuthority News - Interesting Whitepaper - We Loaded 1TB in 30 Minutes with SSIS, and So Can You](https://blog.sqlauthority.com/2010/03/14/sqlauthority-news-interesting-whitepaper-we-loaded-1tb-in-30-minutes-with-ssis-and-so-can-you/): We Loaded 1TB in 30 Minutes with SSIS, and So Can You SQL Server Technical Article Writers: Len Wyatt, Tim Shea, David Powell Published: March 2009 In February 2008, Microsoft announced a record-breaking data load using Microsoft SQL Server Integration Services (SSIS): 1 TB of data in less than 30 minutes. That data load, using SQL Server Integration Services, was 30% faster than the previous best time using a commercial ETL tool. This paper outlines what it took: the software, hardware, and configuration used. We will describe what we did to achieve that result, and offer suggestions for how to relate... - [SQLAuthority News - SQL Server 2008 R2 Update for Developers Training Kit (March 2010 Update)](https://blog.sqlauthority.com/2010/03/13/sqlauthority-news-sql-server-2008-r2-update-for-developers-training-kit-march-2010-update/): Note: Download SQL Server 2008 R2 Update for Developers Training Kit (March 2010 Update) Authored by Microsoft SQL Server 2008 R2 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2008. The SQL Server 2008 R2 Update for Developers Training Kit is ideal for developers who want to understand how to take advantage of the key improvements introduced in SQL Server 2008 and SQL Server 2008 R2 in their applications, as well as for developers who are new to SQL Server. The training kit is brought to you by Microsoft Developer and Platform... - [SQLAuthority News - Download Microsoft SQL Server JDBC Driver 3.0 CTP 1](https://blog.sqlauthority.com/2010/03/13/sqlauthority-news-download-microsoft-sql-server-jdbc-driver-3-0-ctp-1/): Note:  Download Microsoft SQL Server JDBC Driver 3.0 CTP 1 Authored by Microsoft Download the SQL Server JDBC Driver 3.0 CTP, a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform, Enterprise Edition 5. In its continued commitment to interoperability, Microsoft has released a preview of the upcoming Java Database Connectivity (JDBC) driver. The SQL Server JDBC Driver 3.0 CTP download is available to all SQL Server users at no additional charge, and provides access to SQL Server 2000, SQL Server 2005, and SQL Server 2008 from any Java application,... - [SQL SERVER - Checklist for Analyzing Slow-Running Queries](https://blog.sqlauthority.com/2010/03/12/sql-server-checklist-for-analyzing-slow-running-queries/): I am recently working on upgrading my class Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning with additional details and more interesting examples. While working on slide deck I realized that I need to have one solid slide which talks about checklist for analyzing slow running queries. A quick search on my saved book mark link come up with interesting book online link. This link very clearly suggests: To save time, consult this checklist before you contact your technical support provider. I strongly suggest you to do the same, first consult this checklist and if you still further need... - [SQL SERVER - Force Index Scan on Table - Use No Index to Retrieve the Data - Query Hint](https://blog.sqlauthority.com/2010/03/11/sql-server-force-index-scan-on-table-use-no-index-to-retrieve-the-data-query-hint/): Recently I received the following two questions from readers and both the questions have very similar answers. Question 1: I have a unique requirement where I do not want to use any index of the table; how can I achieve this? Question 2: Currently my table uses clustered index and does seek operation; how can I convert seek to scan? First of all, I am not going to analysis their need of why, in fact, they want to convert seek to scan or use no index here. The requirement is strange as using no index or scanning large table may reduce... - [SQLAuthority Book Review - Professional SQL Server 2008 Internals and Troubleshooting](https://blog.sqlauthority.com/2010/03/10/sqlauthority-book-review-professional-sql-server-2008-internals-and-troubleshooting/): Professional SQL Server 2008 Internals and Troubleshooting by Christian Bolton, Justin Langford, Brent Ozar, James Rowland-Jones, Steven Wort Link to Amazon (Worldwide) Link to Flipkart (India) Brief Review: Having a book on internal and associating that with real life is “almost” an impossible task. The reason for using the word “almost” is because this book has accomplished this very well. This internals book is written by keeping real life scenarios as top focus. The highlight of the book is that it teaches how to use internals to troubleshoot the real life issues of performance, storage, query processing and all the other... - [SQL SERVER - Improve Performance by Reducing IO - Creating Covered Index](https://blog.sqlauthority.com/2010/03/09/sql-server-improve-performance-by-reducing-io-creating-covered-index/): This blog post is in the response of the T-SQL Tuesday #004: IO by Mike Walsh. The subject of this month is IO. Here is my quick blog post on how Cover Index can Improve Performance by Reducing IO. Let us kick off this post with disclaimers about Index. Index is a very complex subject and should be exercised with experts. Too many indexes, and in particular, too many covering indexes can hamper the performance. Again, indexes are very important aspect of performance tuning. In this post, I am demonstrating very limited capacity of Index. We will create covering index for... - [SQLAuthority News - SQL SERVER 2008 R2 Pricing](https://blog.sqlauthority.com/2010/03/08/sql-server-2008-r2-pricing/): I was recently asked question about SQL Server 2008 pricing. I have bookmarked official site here which lists the pricing. Official site: What’s New in SQL Server 2008 R2 Editions Editions Per Processor PricingRetail Per Server Plus CAL PricingRetail Parallel Data Warehouse $57,498 Not offered via Server CAL Datacenter $57,498 Not offered via Server CAL Enterprise $28,749 $13,969 with 25 CALs Standard $7,499 $1,849 with 5 CALs However, I have bookmarked following site of Brent Ozar SQL Server 2008 R2 Pricing and Feature Changes. I think Brent has answered one very interesting question there that SQL Server R2 is FREE for... - [SQLAuthority News - Office 2010 Readiness Check - Are you ready for Office 2010?](https://blog.sqlauthority.com/2010/03/07/sqlauthority-news-office-2010-readiness-check-are-you-ready-for-office-2010/): PowerPivot for Excel is a data analysis tool that delivers unmatched computational power directly within the application users already know and love—Microsoft Excel. Office 2010 is the next version of Office 2010. We all know Office 2010 is on the verge of getting released and the reviews available online say that it’s a phenomenal product. My friend Vijay Raj has written excellent article on Office 2010 Readiness Check. Vijay is a Microsoft MVP, focusing on Application Setup and Deployment. He is also a Springboard Series Technical Expert Panel member for Windows 7.  He is one among the core team members at... - [SQLAuthority News - SQL Server Modeling CTP - Nov 2009 Release 2 (formerly Oslo)](https://blog.sqlauthority.com/2010/03/06/sqlauthority-news-sql-server-modeling-ctp-nov-2009-release-2-formerly-oslo/): Note : Download SQL Server Modeling CTP – Nov 2009 Release 2 (formerly Oslo)  by Microsoft SQL Server Modeling (formerly code name “Oslo”) is a set of future technologies that provide significant productivity gains across the lifecycle of .NET applications by enabling developers, architects, and IT professionals to work together more effectively with SQL Server at the center of the application lifecycle. The components of the SQL Server Modeling CTP are: “M” is a highly productive, developer friendly, textual language for defining schemas, queries, values, functions and DSLs for SQL Server databases “Quadrant” is a customizable tool for interacting with large... - [SQL SERVER - Order of Columns in Update Statement Does not Matter](https://blog.sqlauthority.com/2010/03/05/sql-server-order-of-columns-in-update-statement-does-not-matter/): I recently received few comments that I have not written on simple subjects recently. In fact, this blog is dedicated to all those who are really learning SQL Server and almost all the articles and posts are posted here keeping this goal in mind. One of the questions in the email which requested to write simple subjects was “Does the order of columns in UPDATE statements matter?” Let me try to answer this question today. The question in detail: Does the order of the columns in UPDATE statements matter? For example, is there any difference between option 1 and option 2... - [SQL SERVER - Rollback TRUNCATE Command in Transaction](https://blog.sqlauthority.com/2010/03/04/sql-server-rollback-truncate-command-in-transaction/): This is a very common concept that truncate cannot be rolled back. Let us learn in today's blog post that Rollback TRUNCATE is possible. - [SQL SERVER - Performance Comparison - INSERT TOP (N) INTO Table - Using Top with INSERT](https://blog.sqlauthority.com/2010/03/03/sql-server-performance-comparison-insert-top-n-into-table-using-top-with-insert/): Recently I wrote about SQL SERVER – INSERT TOP (N) INTO Table – Using Top with INSERT I mentioned about how TOP works with INSERT. I have mentioned that I will write about the performance in next article. Here is the performance comparison of the two options. - [SQLAuthority News - Excellent Event - TechEd Sri Lanka - Feb 8, 2010](https://blog.sqlauthority.com/2010/03/02/sqlauthority-news-excellent-event-teched-sri-lanka-feb-8-2010/): TechEd Sri Lanka was held at Waters Edge, Colombo between Feb 8 and Feb 10, 2010. It was one of the largest successful technical event in Sri Lanka. I was extremely surprised to how technically sound this event was and how excited the TechEd attendees were. I presented there on two different subject. They were very enthusiastic and had so many interesting questions during the session. One of my session received rating of 8.9. I must thank you to all the attendees for sending their feedback and appreciating my session. Both of my session have received feedback above average. The Other... - [SQL SERVER - Data and Page Compressions - Data Storage and IO Improvement](https://blog.sqlauthority.com/2010/03/01/sql-server-data-and-page-compressions-data-storage-and-io-improvement/): The performance of SQL Server is primarily decided by the disk I/O efficiency. Improving I/O definitely improves the performance. SQL Server 2008 introduced Data and Backup compression features to improve the disk I/O. Here, I will explain Data compression. Data compression implies the reduction in the disk space reserved by data. Therefore, data compression can be configured for a table, clustered index, non-clustered index, indexed view or a partition of table or index. Data compression is implemented at two levels: ROW and PAGE. Even page compression automatically implements row compression. Tables and indexes can be compressed when they are created by... - [SQLAuthority News - Hyderabad Techies February Fever Feb 11, 2010 - Indexing for Performance](https://blog.sqlauthority.com/2010/02/28/sqlauthority-news-hyderabad-techies-february-fever-feb-11-2010-indexing-for-performance/): I recently presented in Hyderabad User Group on the subject of The Other Side of SQL Server Index: Advanced Solutions to Ancient Problem , you can read more about this event here SQLAuthority News – MUGH – Microsoft User Group Hyderabad – Feb 2, 2010 Session Review. I really had great time talking about Index and Index Tuning. Index is very important part of database performance tuning and understanding it is a big thing. I have learned a lot of performance tuning tricks from Itzik Ben-Gan and Greg Low. After successful session at Hyderabad User Group, I have presented follow up... - [SQL SERVER - Introduction to Force Index Query Hints - Index Hint - Part2](https://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/): In my previous article SQL SERVER – Introduction to Force Index Query Hints – Index Hint I have discussed regarding how we can use Index Hints with any query. I just received email from one of my regular reader that are there any another methods for the same as it will be difficult to read the syntax of join.Yes, there is alternate way to do the same using OPTION clause however, as OPTION clause is specified at the end of the query we have to specify which table the index hint is put on. Example 1: Using Inline Query Hint USE... - [SQL SERVER - Introduction to Force Index Query Hints - Index Hint](https://blog.sqlauthority.com/2009/02/07/sql-server-introduction-to-force-index-query-hints-index-hint/): This article, I will start with disclaimer instead of having it at the end of article. “SQL Server query optimizer selects the best execution plan for a query, it is recommended to use query hints by experienced developers and database administrators in case of special circumstances.” When any query is ran SQL Server Engine determines which index has to be used. SQL Server makes uses Index which has lowest cost based on performance. Index which is the best for performance is automatically used. There are some instances when Database Developer is best judge of the index used. DBA can direct SQL... - [SQL SERVER - Quickest Way to - Kill All Threads - Kill All User Session - Kill All Processes](https://blog.sqlauthority.com/2009/02/06/sql-server-quickest-way-to-kill-all-threads-kill-all-user-session-kill-all-processes/): More than a year ago, I wrote how to kill all the processes running in SQL Server. Just a day ago, I found the quickest way to kill the processes of SQL Server. While searching online I found very similar methods to my previous method everywhere. Today in this article, I will write the quickest way to achieve the same goal. Read here for older method of using cursor – SQL SERVER – Cursor to Kill All Process in Database. USE master; GO ALTER DATABASE AdventureWorks SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE AdventureWorks SET MULTI_USER; GO Running above script will give following result.... - [SQLAuthority News - Two Promotion to Help Community](https://blog.sqlauthority.com/2009/02/05/sqlauthority-news-two-promotion-to-help-community/): In this difficult time of recession I have two promotion to share with SQL Server community. 1) Discount on Microsoft Exams and Free Second Retake Due to bad job market, the ratio to available jobs to available candidates is lower than usual. Microsoft exams are key to stand up in mass and prove your potential. Click Here to Get Discount Code and Read more about this subject 2) Post your Tech Job and Get 10% Discount Jobs @ SQLAuthority.com has come up as prominent job portal and have been getting very high traffic. I receive lots of email and comments from... - [SQL SERVER - Observation - Effect of Clustered Index over Nonclustered Index](https://blog.sqlauthority.com/2009/02/04/sql-server-observation-effect-of-clustered-index-over-nonclustered-index/): Today I came across very interesting observation while I was working on query optimization. Let us run the example first. Make sure to to enable Execution Plan (Using CTRL + M) before running comparison queries. USE [AdventureWorks] GO /* */ CREATE TABLE [dbo].[MyTable]( [ID] [int] NOT NULL, [First] [nchar](10) NULL, [Second] [nchar](10) NULL ) ON [PRIMARY] GO /* Create Sample Table */ INSERT INTO [AdventureWorks].[dbo].[MyTable] ([ID],[First],[Second]) SELECT 1,'First1','Second1' UNION ALL SELECT 2,'First2','Second2' UNION ALL SELECT 3,'First3','Second3' UNION ALL SELECT 4,'First4','Second4' UNION ALL SELECT 5,'First5','Second5' GO Now let us create nonclustered index over this table. /* Create Nonclustered Index over Table */... - [SQLAuthority News - Download SQL Server 2008 System Views Poster - PDF - A Wall Poster](https://blog.sqlauthority.com/2009/02/03/sqlauthority-news-download-sql-server-2008-system-views-poster-pdf-a-wall-poster/): Microsoft has published SQL Server 2008 System Views Poster. This poster should be must have poster for any SQL Server Developer. I have this poster on my wall. If you have extra copy of this postered in print. Do send it to me and I will forward it to developer who are very good but can not afford to get this poster printed in glossy pages. The Microsoft SQL Server 2008 System Views Map shows the key system views included in SQL Server 2008, and the relationships between them. The map is similar to the Microsoft SQL Server 2005 version and... - [SQL SERVER - T-SQL Script for FizzBuzz Logic](https://blog.sqlauthority.com/2009/02/02/sql-server-t-sql-script-for-fizzbuzz-logic/): Following is quite common Interview Question asked in many interview questions. FizzBuzz is popular but very simple puzzle and have been very popular to solve. FizzBuzz problem can be attempted in any programming language. Let us attempt it in T-SQL. Definition of FizzBuzz Puzzle : Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. DECLARE @counter INT DECLARE @output VARCHAR(8) SET @counter = 1 WHILE @counter < 101... - [SQLAuthority News - Download Microsoft SQL Server 2008 Books Online (January 2009)](https://blog.sqlauthority.com/2009/02/01/sqlauthority-news-download-microsoft-sql-server-2008-books-online-january-2009/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - FIX : ERROR : Msg 5834, Level 16, State 1, Line 1 The affinity mask specified conflicts with the IO affinity mask specified. Use the override option to force this configuration](https://blog.sqlauthority.com/2009/01/31/sql-server-fix-error-msg-5834-level-16-state-1-line-1-the-affinity-mask-specified-conflicts-with-the-io-affinity-mask-specified-use-the-override-option-to-force-this-configuration/): Yesterday I came across following error while enabling fill factor for my database server, when I was trying to write article SQL SERVER – 2008 – 2005 – Rebuild Every Index of All Tables of Database – Rebuild Index with FillFactor. I ran following T-SQL script and it gave me error. sp_configure 'show advanced options', 1 GO RECONFIGURE GO sp_configure 'fill factor', 90 GO RECONFIGURE GO In result pan following error showed up. Msg 5834, Level 16, State 1, Line 1 The affinity mask specified conflicts with the IO affinity mask specified. Use the override option to force this configuration. Fix/Solution/Workaround:... - [SQL SERVER - 2008 - 2005 - Rebuild Every Index of All Tables of Database - Rebuild Index with FillFactor](https://blog.sqlauthority.com/2009/01/30/sql-server-2008-2005-rebuild-every-index-of-all-tables-of-database-rebuild-index-with-fillfactor/): I just wrote down following script very quickly for one of the project which I am working on. The requirement of the project was that every index existed in database should be rebuilt with fillfactor of  80. One common question I receive why fillfactor 80, answer is I just think having it 80 will do the job.Fillfactor determines how much percentage of the space on each leaf-level page are filled with data. The space which is left empty on leaf-level page is not at end of the page but the empty space is reserved between rows of data. This ensures that... - [SQLAuthority News - Microsoft Certification Exam - Discount Code - Free Second Chance - MCTS, MCITP, MCPD](https://blog.sqlauthority.com/2009/01/29/sqlauthority-news-microsoft-certification-exam-discount-code-free-second-chance-mcts-mcitp-mcpd/): Please note down this important code or share with your colleagues who are keen to take Microsoft Certification Exam. This unique code is only available through Microsoft MVP’s and only published here to help community and no other intention. In this challenging economic climate, upgrading your IT skills becomes crucial to staying ahead. Invest in a Microsoft Certification to get the right IT skills. Register today with your MVP Certification Promotion Code:  and enjoy 2 chances to pass a Microsoft Certification Examination plus a 10% discount! If you fail on your first attempt, you will receive a free retake of the... - [SQL SERVER - Generate A Single Random Number for Range of Rows of Any Table - Very interesting Question from Reader](https://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/): Just a day ago I received email from reader how to get single random number for range of rows of any table. The question was not very clear to me so I had asked him to send me question in simpler words. He sent me question back in simple words. Let us understand this problem using database AdventureWorks. In AdventureWorks database we have table called Person.Address. How to get single random number generated for PostalCode ‘98011’ and another single random number for PostalCode ‘98033’. So far I have never received scenario like this. I had previously faced situation where I had... - [SQLAuthority News - Download Cumulative update package 3 for SQL Server 2008](https://blog.sqlauthority.com/2009/01/27/sqlauthority-news-download-cumulative-update-package-3-for-sql-server-2008/): For almost one year I have been using SQL Server 2008 and I keep watch on its update. Cumulative Update Package 3 has been made available now. Latest SQL Server 2008 version is 10.0.1787.0. Download Cumulative update package 3 for SQL Server 2008 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Microsoft SQL Server JDBC Driver 2.0 Community Technology Preview](https://blog.sqlauthority.com/2009/01/27/sqlauthority-news-download-microsoft-sql-server-jdbc-driver-20-community-technology-preview/): Note:  Download Microsoft SQL Server JDBC Driver 2.0 Community Technology Preview by Microsoft In its continued commitment to interoperability, Microsoft has released a new Java Database Connectivity (JDBC) driver. The SQL Server JDBC Driver 2.0 download is available to all SQL Server users at no additional charge, and provides access to SQL Server 2000, SQL Server 2005, and SQL Server 2008 from any Java application, application server, or Java-enabled applet. This is a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform, Enterprise Edition 5. This Community Technology Preview (CTP)... - [SQLAuthority News - Happy 60th Republic Day to India - Database Tip](https://blog.sqlauthority.com/2009/01/26/sqlauthority-news-happy-60th-republic-day-to-india-database-tip/): Kaleidoscopic images of India’s rich cultural diversity and the might of its military were on full display on the magnificent Rajpath Republic Day celebrations as the nation celebrated its 60th Republic Day amid an unprecedented security cover. An impressive and colourful parade, a traditional attraction of the national event, marched down the thoroughfare connecting the Rashtrapati Bhawan and the historic India Gate as President Pratibha Patil took the salute from marching contingents. (PTI) Database Tip of Today: Always check your execution plan first if your query is running slower and identify the part of query which is taking the highest execution... - [SQL SERVER - Shrinking NDF and MDF Files - A Safe Operation](https://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/): Just a day ago I have received following email from Siddhi and I found it interesting so I am sharing with all of you. Hello Pinal, I have seen many blogs from you on SQL server and i have always found them useful and easy to understand. Thanks for all the information you provide. I have one query about shrinking NDF and MDF files. Can we shrink NDF and MDF files?? If you do so is there any data loss? I have been shrinking the .LDF files every now and then but I am not too sure about NDF and MDF... - [SQLAuthority News - Download Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007](https://blog.sqlauthority.com/2009/01/24/sqlauthority-news-download-microsoft-sql-server-2005-data-mining-add-ins-for-microsoft-office-2007/): Note:  Download Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007 by Microsoft Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007 (Data Mining Add-ins) allow you take advantage of SQL Server 2005 predictive analytics in Office Excel 2007 and Office Visio 2007. The download includes the following components: Table Analysis Tools for Excel: This add-in provides easy-to-use tasks that leverage SQL Server 2005 Data Mining to perform powerful analytics on your spreadsheet data. Data Mining Client for Excel: This add-in allows you to go through the full data mining model development lifecycle within Excel 2007 using... - [SQL SERVER - 2008 - 2005 - Find Longest Running Query - TSQL - Part 2](https://blog.sqlauthority.com/2009/01/23/sql-server-2008-2005-find-longest-running-query-tsql-part-2/): Just another day I was playing with my query which I posted earlier SQL SERVER – 2008 – 2005 – Find Longest Running Query – TSQL and I found that I got error devide by zero. I have fixed this error in following query as well I have updated query to return time in millisecond instead of microsecond. Jerry Hung has also posted similar solution in comments of original article. I strongly suggest to read original article to now more about introduction and learn about DBCC command which clears cache. SELECT DISTINCT TOP 10 t.TEXT QueryName, s.execution_count AS ExecutionCount, s.max_elapsed_time AS MaxElapsedTime, ISNULL(s.total_elapsed_time... - [SQLAuthority News - Milestone of 6 Million Visits - 60 Lak Visits - Search and Job](https://blog.sqlauthority.com/2009/01/22/sqlauthority-news-milestone-of-6-million-visits-60-lak-visits-search-and-job/): Today SQLAuthority.com has completed 6 Million Visits. In 2 years 3 months miles stone of 6 million visits has been crossed. I want to thank all of my readers for their continuous support and help. On milestone of 6 million visits I want to announce small gratitude towards my readers who are continuously participating on this blog. I will be sending small surprise to all the readers who have been consistently participating on this blog. Those who have occasional participated with comments, suggestion or articles, I suggest them to participate more to get the surprise. Additionally, on this occasion I want... - [SQLAuthority News - SQLAuthority News - Ahmedabad User Group Meeting January 17 2009 - Review](https://blog.sqlauthority.com/2009/01/21/sqlauthority-news-sqlauthority-news-ahmedabad-user-group-meeting-january-17-2009-review/): User Group Meeting is the the event I always wait during whole month. User Group meetings are the place where we can meet various people from all around the city and expand our networking. Meeting new people and exchanging new tips and tricks is always interesting. For year 2009 we had our first User Group Meeting held on January 17, 2009. You can read the announcement here SQLAuthority News – Ahmedabad User Group Meeting January 17 2009. As this was first UG Meet of the year it was full of action with 3 back to back Performance Tuning related sessions. If... - [SQL SERVER - Rules for Optimizining Any Query - Best Practices for Query Optimization](https://blog.sqlauthority.com/2009/01/20/sql-server-rules-for-optimizining-any-query-best-practices-for-query-optimization/): This subject is very deep subject but today we will see it very quickly and most important points. May be following up on few of the points of this point will help users to right away improve the performance of query. In this article I am not focusing on in depth analysis of database but simple tricks which DBA can apply to gain immediate performance gain. Table should have primary key Table should have minimum of one clustered index Table should have appropriate amount of non-clustered index Non-clustered index should be created on columns of table based on query which is... - [SQLAuthority News - CWE/SANS TOP 25 Most Dangerous Programming Errors](https://blog.sqlauthority.com/2009/01/19/sqlauthority-news-cwesans-top-25-most-dangerous-programming-errors/): I just came across very interesting article from SANS Institute. Experts from more than 30 US and international cyber security organizations have released list of 25 most dangerous programming errors and their resolution. It may be possible that many of the programmers may not understand what this errors are and how to implement their solution. As said this are 25 most dangerous errors and all the developers should atleast know what they are so they do not are prevented from origin. Here are four major advantages listed by SANS. Software buyers will be able to buy much safer software. Programmers will... - [SQL SERVER - Difference Between Index Scan and Index Seek](https://blog.sqlauthority.com/2009/01/18/sql-server-difference-between-index-scan-and-index-seek/): I have explained the concept of Index Scan and Index Seek earlier but I keep on receiving the same question again and again. Let us today look into it with little more depth. Before we go over the concept of scan and seek we need to understand what SQL Server does before applying any kind of index on query. When any query is ran SQL Server has to determine that if any particular index can be applied on that particular query or not. SQL Server uses search predicates to make decision right before applying indexes to any given query. Let us... - [SQLAuthority News - Download Microsoft SQL Server Protocol Documentation](https://blog.sqlauthority.com/2009/01/17/sqlauthority-news-download-microsoft-sql-server-protocol-documentation/): he Microsoft SQL Server protocol documentation provides detailed technical specifications for Microsoft proprietary protocols (including extensions to industry-standard or other published protocols) that are implemented and used in Microsoft SQL Server to interoperate or communicate with Microsoft products. The documentation includes a set of companion overview and reference documents that supplement the technical specifications with conceptual background, overviews of inter-protocol relationships and interactions, and technical reference information. Download Microsoft SQL Server Protocol Documentation Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad User Group Meeting January 17 2009](https://blog.sqlauthority.com/2009/01/16/sqlauthority-news-ahmedabad-user-group-meeting-january-17-2009/): It is my pleasure to announce that SQL Server User Group Meeting is held on January 17, 2009. This is the first meeting of year 2009 and will be one interesting meeting as we will have back to back three presentation from SQL Experts. The agenda of meeting will be as following. Query Optimization Part 3 – Jacob Sebastian (SQL Server MVP) Understanding of Index Usage and Order By – Pinal Dave (SQL Server MVP) MERGE statement in SQL Server 2008 – Imran Bhadelia (MCTS) I encourage every SQL enthusiastic in city to attend this meeting as this will be one... - [SQL SERVER - Remove Duplicate Entry from Comma Delimited String - UDF](https://blog.sqlauthority.com/2009/01/15/sql-server-remove-duplicate-entry-from-comma-delimited-string-udf/): I love reader’s contribution this blog as that brings variety in articles. I encourage my readers to provide their contribution and I will publish then with their name. Blog Reader Ashish Jain has posted very simple script which will remove duplicate entry from comma delimited string. User Defined Function has very simple logic behind it. It takes comma delimited string and then converts it to table and runs DISTINCT operation on the table. DISTINCT operation removes duplicate value. After that it converts the table again into the string and it can be used. I have modified original contribution from Ashish so... - [SQL SERVER - Find Number of Rows and Disk Space Reserved - Using sp_spaceused Interesting Observation](https://blog.sqlauthority.com/2009/01/14/sql-server-find-number-of-rows-and-disk-space-reserved-using-sp_spaceused-interesting-observation/): Previously I posted SQL SERVER – Find Row Count in Table – Find Largest Table in Database – T-SQL. Today we will look into the same issue but with some additional interesting detail. We can find the row count using another system SP sp_spaceused. This SP gives additional information regarding disk space reserved on database as well. Well, when I ran the SP on AdventureWorks first time, I suspected that database SP is not providing me correct results. After a bit investigating I found that it may be possible that due to any reason may be the usage on AdventureWorks database... - [SQL SERVER - Find Row Count in Table - Find Largest Table in Database - T-SQL](https://blog.sqlauthority.com/2009/01/13/sql-server-find-row-count-in-table-find-largest-table-in-database-t-sql/): I have written following script every time when I am asked by our team leaders or managers that how many rows are there in any particular table or sometime I am even asked which table has highest number of rows. Being Sr. Project Manager, sometime I just write down following script myself rather than asking my developers. This script will gives row number for every table in database. USE AdventureWorks GO SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count FROM sys.dm_db_partition_stats st WHERE index_id < 2 ORDER BY st.row_count DESC GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Humor - Favorite Website - Funny Image](https://blog.sqlauthority.com/2009/01/12/sqlauthority-news-humor-favorite-website-funny-image/): I just received this image in email and I found it really funny. I do not know the source of the image or is it photoshopped. Thanks David Marsee for the image and email. If you have something really funny like this, please send them to me. Please do not leave comment regarding grammatical mistake in image as I am sure David (who send email) did not mean it. Reference : Pinal Dave https://blog.sqlauthority.com/ ) - [SQL SERVER - Top Five Articles of Year 2008](https://blog.sqlauthority.com/2009/01/11/sql-server-top-five-articles-of-year-2008/): Year 2008 was great year for me. I got plenty of request from readers asking for Top 10 or Top 5 articles of the year 2008. I am including Top 5 Articles of Year 2008 in two different categories. First is my blog SQLAuthority.com and another one is my home page pinaldave.com TOP 5 Articles at SQLAuthority.com This section has six links as very first link is repeated again in top 5 pages at pinaldave.com SQL SERVER – 2008 – Interview Questions and Answers Complete List Download Most popular and most visited page. Very first and compilation of SQL Server Interview... - [SQLAuthority News - Security White Papers](https://blog.sqlauthority.com/2009/01/10/sqlauthority-news-security-white-papers/): Microsoft Dynamics AX 2009 White Paper: Configuring Kerberos Authentication with Role Centers This document describes how to configure Kerberos authentication with Enterprise Portal and Role Centers. Kerberos authentication is required to display reports created using Microsoft SQL Server Reporting Services and Microsoft SQL Server Analysis Services on Role Center pages. Microsoft Dynamics AX 2009 White Paper: Configuring Enterprise Portal and Role Centers with SQL Reporting This document contains checklists and information to help administrators set up and configure Microsoft Dynamics AX 2009 Enterprise Portal and Role Centers with Microsoft SQL Server® Reporting Services® and Microsoft SQL Server Analysis Services. Reference :... - [SQL SERVER - sqlcmd - Using a Dedicated Administrator Connection to Kill Currently Running Query](https://blog.sqlauthority.com/2009/01/09/sql-server-sqlcmd-using-a-dedicated-administrator-connection-to-kill-currently-running-query/): People are judged from their questions and not their answers. I received wonderful question the other day. How sqlcmd can be used along with currently running query script posted on your blog? Please read following two posts before continuing this article as they cover background of this article. SQL SERVER – Interesting Observation – Using sqlcmd From SSMS Query Editor SQL SERVER – Find Currently Running Query – T-SQL If due to a long running query or any resource hogging query SQL Server is not responding sqlcmd can be used to connect to the server from another computer and kill the... - [SQLAuthority News - Author Visit - Mumbai, India - From January 8, 2008 to January 11, 2008](https://blog.sqlauthority.com/2009/01/08/sqlauthority-news-author-visit-mumbai-india-from-january-8-2008-to-january-11-2008/): I will be traveling to Mumbai from From January 8, 2008 to January 11, 2008. If any of readers wants to meet up for cup of coffee in evening leave a comment or send me email and we can arrange something. I will be visiting various places and my access to emails are limited. Regular readers, those who have my phone number can call me at any time. I will post review of my trip to Mumbai once I am back from trip. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Currently Running Query - T-SQL](https://blog.sqlauthority.com/2009/01/07/sql-server-find-currently-running-query-t-sql/): This is the script which I always had in my archive. Following script find out which are the queries running currently on your server. SELECT sqltext.TEXT, req.session_id, req.status, req.command, req.cpu_time, req.total_elapsed_time FROM sys.dm_exec_requests req CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext While running above query if you find any query which is running for long time it can be killed using following command. KILL [session_id] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interesting Observation - Using sqlcmd From SSMS Query Editor](https://blog.sqlauthority.com/2009/01/06/sql-server-interesting-observation-using-sqlcmd-from-ssms-query-editor/): A day before I wrote article SQL SERVER – sqlcmd vs osql – Basic Comparison. Today while I was displaying how sqlcmd can be used instead of osql to one of my companies team leader, I found another neat feature of SSMS Query Editor. sqlcmd can be used from Query Editor but it has to be enabled first. - [SQL SERVER - sqlcmd vs osql - Basic Comparison](https://blog.sqlauthority.com/2009/01/05/sql-server-sqlcmd-vs-osql-basic-comparison/): Today we will go over very simple but to the point comparison of two SQL Server utilities or SQL Server tools. This comes often to users which one to use sqlcmd or osql, when in need of running SQL Server queries from command prompt. Answer to this is very simple use “sqlcmd”. sqlcmd has all the feature which osql has to offer, additionally sqlcmd has many added feature than osql. isql was introduced in earlier versions of SQL Server. osql was introduced in SQL Server 2000 version. sqlcmd is newly added in SQL Server 2005 and offers additionally functionality which SQL... - [SQL SERVER - 2008 - Change Color of Status Bar of SSMS Query Editor](https://blog.sqlauthority.com/2009/01/04/sql-server-2008-change-color-of-status-bar-of-ssms-query-editor/): This is one very interesting issue which I have started to follow recently. Just like any other organization my company has many servers. Some are production and some are development. It is very much necessary that query which are written for developer environment does not run for production environment accidentally. In SQL Server 2008 there is special feature which can change the color of the task bar. This will alert developer to run query on server. Let us see quick tutorial with images which explains how the color of the status bar in SQL Server management studio can be changed. Another... - [SQL SERVER - Time Delay While Running T-SQL Query - WAITFOR Introduction](https://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/): Today we will look at one very small but interesting feature of SQL Server. Please note that this is not much known feature of SQL Server. In SQL Server sometime there are requirement when T-SQL script has to wait for some time before executing next statement. It is quite common that developers depends on application to take over this delay issue. However, SQL Server itself has very strong time management function of WAITFOR. Let us see two usage of WAITFOR clause. Official explanation of WAITFOR clause from Book Online is “Blocks the execution of a batch, stored procedure, or transaction until... - [SQL SERVER - 2008 - 2005 - Find Longest Running Query - TSQL](https://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/): UPDATE : Updated this query with bug fixed with one more enhancement SERVER – 2008 – 2005 – Find Longest Running Query – TSQL – Part 2. Recently my company owner asked me to find which query is running longest. It was very interesting that I was not able to find any T-SQL script online which can give me this data directly. Finally, I wrote down very quick script which gives me T-SQL which has ran on server along with average time and maximum time of that T-SQL execution. As I keep on writing I needed to know when exactly logging was started for the same T-SQL so I had added Logging start time in the query as well. - [SQLAuthority News - Happy New Year - 5 SQL New Year Resolutions](https://blog.sqlauthority.com/2009/01/01/sqlauthority-news-happy-new-year-5-sql-new-year-resolutions/): Happy New Year to All of YOU! Let us start year 2009 with word of wisdom from Albert Einstein. I feel that you are justified in looking into the future with true assurance, because you have a mode of living in which we find the joy of life and the joy of work harmoniously combined. Added to this is the spirit of ambition which pervades your very being, and seems to make the day’s work like a happy child at play. – Albert Einstein “May this new year all your dreams turn into reality and all your efforts into great achievements.”... - [SQLAuthority News - Recap Year 2008 - Two Most Important Event of My Life](https://blog.sqlauthority.com/2008/12/31/sqlauthority-news-recap-year-2008-two-most-important-event-of-my-life/): Year 2008 is about to complete in next few hours. It was one of the most interesting year for me in my life. There were so many things happened and fortunately all of them are good. If I have to list events special to me in year 2008 there can be many, I will list two most important events of my life in year 2008. I am awarded as SQL Server MVP by Microsoft I am very thankful to Microsoft to recognize my talent as SQL Server Expert and Community Leader. I had great fun this year when I visited MVP... - [SQLAuthority Author Visit Report - Tech Meetings - Recession - Job Market - Consolidation of Servers](https://blog.sqlauthority.com/2008/12/30/sqlauthority-author-visit-report-tech-meetings-recession-job-market-consolidation-of-servers/): In this blog post, I will discuss various topics which are related to various DBAs and Developers discussed in the recent market. - [SQL SERVER - 2008 - Certification Path Complete Download PDF](https://blog.sqlauthority.com/2008/12/29/sql-server-2008-certification-path-complete-download-pdf/): Microsoft Certification are very important for any developer’s career. I personally have acquired MS certification before and while practicing for MS Certification I learned a lot personally. Developers who are interesting in upgrading themselves with Microsoft Certification must download certification path PDF. - [SQL SERVER - Fix : Msg 15151, Level 16, State 1, Line 3 Cannot drop the login 'test', because it does not exist or you do not have permission](https://blog.sqlauthority.com/2008/12/28/sql-server-fix-msg-15151-level-16-state-1-line-3-cannot-drop-the-login-test-because-it-does-not-exist-or-you-do-not-have-permission/): I got following error when I was trying to delete user ‘test’ with ‘SA’ login. I was little surprised but then I tried to delete with the windows authenticated systemadmin account. Once again I got the same error. Msg 15151, Level 16, State 1, Line 3 Cannot drop the login ‘test’, because it does not exist or you do not have permission. The reason I was surprised that I was systemadmin and I should be allowed to delete the login. I am including the script which I used to delete the account here. IF EXISTS (SELECT * FROM sys.server_principals WHERE name =... - [SQL SERVER - Add Any User to SysAdmin Role - Add Users to System Roles](https://blog.sqlauthority.com/2008/12/27/sql-server-add-any-user-to-sysadmin-role-add-users-to-system-roles/): The reason I like blogging is follow up questions. I have wrote following two articles earlier this week. I just received question based on both of them. Before I go on questions, I recommend to read both of the article first. Both of them are very small article so they are quick to read. - [SQL SERVER - Fix : Error : Msg 15151, Level 16, State 1, Line 2 Cannot alter the login 'sa', because it does not exist or you do not have permission](https://blog.sqlauthority.com/2008/12/26/sql-server-fix-error-msg-15151-level-16-state-1-line-2-cannot-alter-the-login-sa-because-it-does-not-exist-or-you-do-not-have-permission/): Few days ago, I have wrote about SQL SERVER – DISABLE and ENABLE user SA I received following email from one of the user who received following error. Msg 15151, Level 16, State 1, Line 2 Cannot alter the login ‘sa’, because it does not exist or you do not have permission. Fix/Workaround/Solution: This error had occurred because of insufficient rights. Please read my previous post here before reading further article. SA is system admin user and it is the highest level of user in system. If any user have to modify the permissions of SA that user needs to have... - [SQLAuthority Author Visit - Valsad, Daman, Silvassa, Vapi - Tech Meetings](https://blog.sqlauthority.com/2008/12/25/sqlauthority-author-visit-valsad-daman-silvassa-vapi-tech-meetings/): I am currently traveling to South Gujarat doing Tech Meetings with leading organizations. Following is my tour schedule. Valsad – December 25, 2008 Daman – December 26, 2008 Silvassa – December 27, 2008 Vapi – December 28, 2008 I will be visiting some of the local IT industries and User Groups. If any of the readers who wants to meet me there can contact me by email. I will be bringing my new DELL XPS 1530 (wireless enabled) along with me so I will reply quickly. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Merry Christmas - Search SQLAuthority](https://blog.sqlauthority.com/2008/12/25/sqlauthority-news-merry-christmas-search-sqlauthority/): Merry Christmas and a prosperous New Year. Thanks for the love and support you give me. I pray to the god that recession will be over soon around the world and everybody is happy. I have been receiving increasing emails for asking question about where is the Search on SQLAuthority.com blog. I have created custom search engine using Google which exclusively searches into SQLAuthority and if needed in the web. If you have not tried SQLAuthority.com search before I suggest you give it a show as this surely improves the experience with this blog. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DISABLE and ENABLE user SA](https://blog.sqlauthority.com/2008/12/24/sql-server-disable-and-enable-user-sa/): Just a day ago, I received question from blog reader Mike McDonald. “How can I modify permissions for SA user? I tried to modify dbo users permission but now I am having problems.” First of all, there may be no relation between dbo user and SA user. They are different and should be left separate. Modifying the permission of SA user is not possible. However, SA can be disable or enabled using following script. Make sure that you are logged in using windows authentication account. /* Disable SA Login */ ALTER LOGIN [sa] DISABLE GO /* Enable SA Login */ ALTER LOGIN [sa] ENABLE GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Download Copy of Developer Edition for Free Is Myth](https://blog.sqlauthority.com/2008/12/23/sql-server-2008-download-copy-of-developer-edition-for-free-is-myth/): It is quite common myth that SQL Server 2008 Developer Edition is FREE. SQL Server 2008 developer edition has same code base and same features which are available in SQL Server 2008 enterprise edition. Only difference between them is licensing terms. Developer Edition can not be used in production environment and it can be used on development server only. I have received quite a lots of emails how this can be downloaded for free. First of this version is not free. It is available for $50 to download. However, those developer who are really looking for free edition of SQL Server... - [SQL SERVER - Find Next Running Time of Scheduled Job Using T-SQL](https://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/): I often receive a good question on the blog, however, I do not always receive a good answer for the questions. Recently someone asked on a blog about Finding next run time for Schedule Job using T-SQL. My friend came up with a nice script. I have modified it a bit to adjust needs. This blog post is about finding the next running time of scheduled job using T-SQL.  - [SQLAuthority News - SQL Server Related Downloads from Microsoft](https://blog.sqlauthority.com/2008/12/21/sqlauthority-news-sql-server-related-downloads-from-microsoft/): Feature Pack for SQL Server 2005 December 2008 Download the December 2008 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. Microsoft SQL Server Protocol Documentation The Microsoft SQL Server protocol documentation provides technical specifications for Microsoft proprietary protocols that are implemented and used in Microsoft SQL Server 2008. SQL Server 2005 Express Edition with Advanced Services SP3 Microsoft SQL Server 2005 Express Edition with Advanced Services is a free, easy-to use version of SQL Server Express that includes more features and makes it easier than ever to start... - [SQL SERVER - Change Collation of Database Column - T-SQL Script](https://blog.sqlauthority.com/2008/12/20/sql-server-change-collation-of-database-column-t-sql-script/): Just a day before I wrote about SQL SERVER – Find Collation of Database and Table Column Using T-SQL and I have received some good comments and one particular question was about how to change collation of database. It is quite simple do so. Let us see following example. USE AdventureWorks GO /* Create Test Table */ CREATE TABLE TestTable (FirstCol VARCHAR(10)) GO /* Check Database Column Collation */ SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN ( SELECT OBJECT_ID FROM sys.objects WHERE type = 'U' AND name = 'TestTable') GO /* Change the database collation */ ALTER TABLE TestTable ALTER COLUMN FirstCol VARCHAR(10) COLLATE SQL_Latin1_General_CP1_CS_AS NULL GO /* Check Database Column Collation */ SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN ( SELECT... - [SQLAuthority News - Download - SQL Server 2005 Books Online (December 2008)](https://blog.sqlauthority.com/2008/12/19/sqlauthority-news-download-sql-server-2005-books-online-december-2008/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The December 2008 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the December 2008 update, SQL Server 2005 Books Online includes documentation updates for... - [SQLAuthority News - Download Microsoft SQL Server 2005 Service Pack 3](https://blog.sqlauthority.com/2008/12/18/sqlauthority-news-download-microsoft-sql-server-2005-service-pack-3/): Service Pack 3 for Microsoft SQL Server 2005 is now available. SQL Server 2005 service packs are cumulative, and this service pack upgrades all service levels of SQL Server 2005 to SP3. You can use these packages to upgrade any of the following SQL Server 2005 editions: Enterprise Enterprise Evaluation Developer Standard Workgroup Download Service Pack 3 for Microsoft SQL Server 2005 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interesting Interview Questions - Revisited](https://blog.sqlauthority.com/2008/12/17/sql-server-interesting-interview-questions-revisited/): I really enjoyed users participation in my previous question. Read SQL SERVER – Interesting Interview Questions before continuing reading this article. This interview question was about user participation and about how good and how different you can come with your T-SQL script. What I really liked is that many users took this test seriously and did their best to answer. I really want to congratulate all the readers who have attempted to answer this question. As I have said earlier it did not matter what is the database structure, but it mattered what should be the good database architecture design. Here... - [SQL SERVER - Find Collation of Database and Table Column Using T-SQL](https://blog.sqlauthority.com/2008/12/16/sql-server-find-collation-of-database-and-table-column-using-t-sql/): Today we will go over very quick tip about finding out collation of database and table column. Collations specify the rules for how strings of character data are sorted and compared, based on the norms of particular languages and locales Today’s script are self explanatory so I will not explain it much. /* Find Collation of SQL Server Database */ SELECT DATABASEPROPERTYEX('AdventureWorks', 'Collation') GO /* Find Collation of SQL Server Database Table Column */ USE AdventureWorks GO SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN (SELECT OBJECT_ID FROM sys.objects WHERE type = 'U' AND name = 'Address') AND name = 'City' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Wedding Day of Author - Photographs - Mr. and Mrs. SQLAuthority](https://blog.sqlauthority.com/2008/12/15/sqlauthority-news-wedding-day-of-author-photographs/): On December 12, 2008 I had posted a note on blog when I completed 800th Article on this blog. The same day was also my wedding day. Read more about the same here SQLAuthority News – Wedding Day of Author. Thank you very much for your wishes and wonderful emails. I have received many emails and I have replied almost all of them with thank you note. Almost all of them have requested to send photographs of my wedding day. I have shared few of the photographs here. Those who were present at the occasion and want their own personal copy... - [SQL SERVER - Connect using Enterprise Manager to SQL Server 2005/2008](https://blog.sqlauthority.com/2008/12/14/sql-server-connect-using-enterprise-manager-to-sql-server-20052008/): I received the following email from Mike Bikinis. about enterprise manager. "How can I connect to SQL Server 2005 or SQL Server 2008 using SQL Server 2000's Enterprise Manager?" - [SQL SERVER - Email from Blog Reader - Not a Potential Bug in SQL - Puzzle](https://blog.sqlauthority.com/2008/12/13/sql-server-interesting-email-from-blog-reader-puzzle/): Few days ago, I received wonderful email from blog reader and it was like good puzzle. I enjoyed solving this puzzle. I did not write the name of the blog reader because I am not sure if he wants his name here or not. Please read this article and run the script described in email. You can download the SQL Script here. Also can any of you help this reader why SQL Server is behaving like this. I have already replied him with correct answer where I suggest that it is not bug and have explained him the reason for the... - [SQLAuthority News - Wedding Day of Author - 800th Article of Blog](https://blog.sqlauthority.com/2008/12/12/sqlauthority-news-wedding-day-of-author-800th-article-of-blog/): Today is big day for me. I am getting married today. Wedding is just one hour away and I am writing this article. I will post more information tomorrow about this event of my life. While assigning categories to this article, I laughed when I selected “SQLAuthority Author Visit” tag. The way I receive one question repetitively “What are the differences between SQL Server 2008 Standard and Enterprise Edition?”, I think Microsoft receives the same question again and again so they have created PDF answering the same question. Download SQL Server 2008 Enterprise and Standard Feature Compare. In November 2008 I... - [SQL SERVER - Interesting Interview Questions - Part 2 - Puzzle - Solution](https://blog.sqlauthority.com/2008/12/11/sql-server-interesting-interview-questions-part-2-puzzle-solution/): Yesterday we looked at Puzzle and I did got great response to this question. Very interestingly not many got it right. First go through the puzzle first and then come back here and read answer. Read Original Interview Question and Puzzle. Question: Select all the person from table PersonColor who have same color as ColorCode or have more colors than table ColorCode. UPDATE: Following solution is written with assumption that in SelectedColors table Name and ColorCode are Primary Key. This requirement was not specified in original question. /*Answer to Interview Question*/ SELECT Name FROM PersonColors pc INNER JOIN SelectedColors sc ON sc.ColorCode = pc.ColorCode GROUP BY pc.Name HAVING... - [SQLAuthority News - SQL SERVER 2008 Upgrade Technical Reference Guide Download](https://blog.sqlauthority.com/2008/12/11/sqlauthority-news-sql-server-2008-upgrade-technical-reference-guide-download/): Note:   SQL SERVER 2008 Upgrade Technical Reference Guide Download by Microsoft This 490-page document covers the essential phases and steps to upgrade existing instances of SQL Server 2000 and 2005 to SQL Server 2008 by using best practices. These include preparation tasks, upgrade tasks, and post-upgrade tasks. It is intended to be a supplement to SQL Server 2008 Books Online. A successful upgrade to SQL Server 2008 should be smooth and trouble-free. To achieve that smooth transition, you must devote plan sufficiently for the upgrade, and match the complexity of your database application. Otherwise, you risk costly and stressful errors and... - [SQL SERVER - Top 10 SQL Server 2008 Features for Independent Software Vendor Applications](https://blog.sqlauthority.com/2008/12/10/sql-server-2008-top-10-sql-server-2008-features-for-independent-software-vendor-applications/): Microsoft SQL Server 2008 has hundreds of new and improved features, many of which are specifically designed for large scale independent software vendor (ISV) applications, which need to leverage the power of the underlying database while keeping their code database agnostic. This article presents details of the top 10 features that we believe are most applicable to such applications based on our work with strategic ISV partners. Along with the description of each feature, the main pain-points the feature helps resolve and some of the important limitations that need to be considered are also presented. - [SQL SERVER - Interesting Interview Questions - Part 2 - Puzzle](https://blog.sqlauthority.com/2008/12/10/sql-server-interesting-interview-questions-part-2-puzzle/): In the recent time of recession my company is able to continue its progress and we are hiring. It is very surprising to me that many developers who have experience with SQL Server could not get following simple question right. There were nearly 40 candidates I interviewed but none of the candidate was able to solve this problem. When I displayed final answer they could not believe that it is that simple. When I asked some of the MCITP or Oracle certified candidate about why they can not get this simple question, they smiled and answered that I did not have... - [SQL SERVER - Find Table Row Count Without Using T-SQL and Without Opening Table](https://blog.sqlauthority.com/2008/12/09/sql-server-find-table-rowcount-without-using-t-sql-and-without-opening-table/): Recently I have been busy with interviewing many candidates for my organization. We are looking for some smart and experienced developers for some senior positions. I have wrote this previously SQL SERVER - Interesting Interview Questions. This blog post is about finding a table row count without using T-SQL. - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2008/12/08/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-2/): Note:   Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Note: Scripts in the SQL Server 2008 management pack rely on SQL Data Management Objects (SQL-DMO) to query information from the SQL Server. SQL-DMO is now deprecated and is not shipped as a part of... - [SQLAuthority News - Author Photographs Updated](https://blog.sqlauthority.com/2008/12/08/sqlauthority-news-author-photographs-updated/): I have received many emails about one of page in on personal site – Photos. I have updated all but one photo on my photo web page. There are new photos of my User Group Presentation and MVP activities. Visit my new photos page Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interview Questions - Difficult SQL Puzzle](https://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/): Today at my organization, we had nearly 30 interviews scheduled of DBA and .NET developers. Let us see a difficult SQL puzzle. - [SQLAuthority News - 10 Motivational Quotes from Technologiest of the Past](https://blog.sqlauthority.com/2008/12/06/sqlauthority-news-10-motivational-quotes-technologiest-past/): Once in a while it is a good idea to read what the greatest technologies of the past said about their time as well as the future. This is the running list of the motivational quotes which I have liked so far from various technologies. Please feel free to add yours as well. One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. – Elbert Hubbard - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/12/05/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008-2/): Ahmedabad SQL Server User Group Meeting was organized on November 29, 2008 at famous C.G. Road in Ahmedabad. We had great response and wonderful back to back technical sessions. The highlight of whole meeting was participation of UG President Jacob Sebastian – SQL MVP from New York. Meeting started with introduction and welcome to all the members from SQL Server MVP – Pinal Daveand followed by technical session of “SQL Server 2008 – Backup and Compression” by Pinal Dave. This session was very special because not every database user is aware of the special feature of SQL Server 2008 and how... - [SQL SERVER - Microsoft SQL Server 2008 Enterprise Evaluation: Trial Experience for IT Professionals / Developers](https://blog.sqlauthority.com/2008/12/04/sql-server-microsoft-sql-server-2008-enterprise-evaluation-trial-experience-for-it-professionals-developers/): Download SQL Server 2008 180-day Trial Software. Microsoft SQL Server 2008 is a database platform for large-scale online transaction processing (OLTP), data warehousing, and e-commerce applications; it is also a business intelligence platform for data analysis and reporting solutions. SQL Server 2008 is a trusted, productive, and intelligent data platform for all your data needs. SQL Server 2008 delivers on Microsoft’s Data Platform vision by helping your organization manage any data, any place, any time. It enables you to store structured, semi-structured, and unstructured data, such as documents, images and music, directly in the database. SQL Server 2008 delivers a rich... - [SQL SERVER - Default Collation of SQL Server 2008](https://blog.sqlauthority.com/2008/12/03/sql-server-default-collation-of-sql-server-2008/): Recently I wrote article about SQL SERVER – 2008 – Install SQL Server 2008 – How to Upgrade to SQL Server 2008 – Installation Tutorial, I received couple of comment suggesting that I did not talk about SQL Server default collation setting or how to change default collation when installing SQL Server 2008. While installing SQL Server 2008 on Server Configuration setting select “Collation” tab. It will bring up setting displayed in following image. You can check the default collation of SQL Server as well can change it from the same. SQL Server offers the SQL_Latin1_General_CP1_CI_AS collation as the default collation... - [SQL SERVER - 2008 - Install SQL Server 2008 - How to Upgrade to SQL Server 2008 - Installation Tutorial](https://blog.sqlauthority.com/2008/12/02/sql-server-2008-install-sql-server-2008-how-to-upgrade-to-sql-server-2008-installation-tutorial/): SQL SERVER 2008 RTM has been released for some time and I have got numerous request about how to install SQL Server 2008. I have created this step by step guide Installation Guide. Images are used to explain the process easier. I had previously written the same article earlier. It seemed necessary to re post it again as request of me posting Step by Step tutorial has increased for quite some time. - [SQL SERVER - Roadmap of Microsoft Certifications - SQL Server Certifications](https://blog.sqlauthority.com/2008/12/01/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications/): In these times of economical slowdown, more and more IT professionals are concerned about their jobs and their qualifications. It is a common trend for developers to start looking for ways to update their skills when jobs are not secure. Pure knowledge and real world work experience are always a good way to help secure your future. One way to demonstrate knowledge is by having a certification in the technology one claims to be expert in. Microsoft offers a series of certifications for IT professional and developers. In this article we will cover the following topics. Importance of Certificates Certification Structure... - [SQL SERVER - Interesting Observation - Use of Index and Execution Plan](https://blog.sqlauthority.com/2008/11/30/sql-server-interesting-observation-use-of-index-and-execution-plan/): Previously I wrote article about SQL SERVER – Interesting Observation about Order of Resultset without ORDER BY and I have received tremendous response from my readers by emails and comments. Readers demanded that I should have written little more for the same subject. As I really liked the subject myself very much, I have decided to write more about the same again. Those readers who have not read my previous article, I request them to go over my previous article one time before reading this article as that will give them history. Read my previous article here. Let us see three... - [SQLAuthority News - Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/11/29/sqlauthority-news-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008/): Today is special day for SQL Server enthusiastic as we will have SQL Server User Group Meeting today in Ahmedabad. Today in User Group we will have UG President Jacob Sebastian (MVP) participating from New York and UG Vice President Pinal Dave (MVP) will talk about “How to become MVP?” Agenda for today’s meeting is as following: Agenda: 1) Introduction by Pinal Dave 2) Direct from New York – Live Meeting by Jacob Sebastian– SQL Pass Roundup and Other News 3) Technical Session by Pinal Dave – Compressed Backup and Restore Techniques 4) Technical Session by Tejas Shah – What is... - [SQL Server - Switch Between Result Pan and Query Pan - SQL Shortcut](https://blog.sqlauthority.com/2008/11/28/sql-server-switch-between-result-pan-and-query-pan-sql-shortcut/): Many times when I am writing query I have to scroll the result displayed in the result set. Let us learn about the shortcut today. - [SQLAuthority News - Download Tools and Documentation for SQL SERVER](https://blog.sqlauthority.com/2008/11/27/sqlauthority-news-download-tools-and-documentation-for-sql-server/): SQL Server 2008 Report Definition Language Specification The goal of Report Definition Language (RDL) is to promote the interoperability of commercial reporting products by defining a common schema that allows interchange of report definitions. An important aspect to understand is that RDL is a schema definition, not a programmatic interface or protocol like HTTP or ODBC. RDL does not specify how report definitions are passed between applications or how reports are processed. Also, RDL is meant to be fully encapsulated; meaning that successfully interpreting an RDL document should not require any understanding of the source application. Microsoft Visual Studio Team System... - [SQLAuthority News - Help to Find Recession Proof Job](https://blog.sqlauthority.com/2008/11/26/sqlauthority-news-help-to-find-recession-proof-job/): Recently I have been receiving a lot of emails from employees asking where they can find good employee. I was under impression that due to global recession job market is down but from looking at recent increase in emails for looking for right candidate I have to say that there are good jobs still out there. There are few jobs in market which are recession proof. There are few decisions one has to make when their job is at risk. Use the website created by SQLAuthority.com for finding right job and right candidate. Click here to go to find right job... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/11/25/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008/): It is time again to announce SQL Hour – SQL Server User Group Meeting for November 2008. This time it is going to be one really interesting event. Our User Group is growing and getting more interesting. Lots of new SQL Server enthusiastic have contacted me recently for User Group meeting. It is the time for all the SQL Server developers to meet again for SQL Hour. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my article here where... - [SQL SERVER - Interesting Observation about Order of Resultset without ORDER BY](https://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/): Today I observed very interesting little thing about SQL Server and I felt that I should share this with my readers. I ran following two queries and found that I am getting different result-set. When I carefully observed I found that actually the result was same but order of the records returned is different. USE AdventureWorks GO SELECT ContactID FROM Person.Contact GO SELECT * FROM Person.Contact GO This particular thing interested me. I knew that when “ORDER BY” is not used order of the table is not guaranteed but I was not able to reproduce simple example for the same. Every... - [SQL SERVER - 2008 - Download and Install Sample Database AdventureWorks 2008](https://blog.sqlauthority.com/2008/11/23/sql-server-2008-download-and-install-samples-database-adventureworks-2008/): The following sample database is currently available for Microsoft SQL Server 2005 and Microsoft SQL Server 2008: - [SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database Including Schema](https://blog.sqlauthority.com/2008/11/22/sql-server-simple-use-of-cursor-to-print-all-stored-procedures-of-database-including-schema/): I love active participation from my readers. Just a day ago I wrote article about SQL SERVER – Simple Use of Cursor to Print All Stored Procedures of Database. I just received comment from Jerry Hung who have improved on previously written article of generating text of Stored Procedure. DECLARE @procName VARCHAR(100) DECLARE @getprocName CURSOR SET @getprocName = CURSOR FOR SELECT Name = '[' + SCHEMA_NAME(SCHEMA_ID) + '].[' + Name + ']' FROM sys.all_objects WHERE TYPE = 'P' AND is_ms_shipped 1 OPEN @getprocName FETCH NEXT FROM @getprocName INTO @procName WHILE @@FETCH_STATUS = 0 BEGIN PRINT 'sp_HelpText ' + @procName EXEC sp_HelpText @procName FETCH NEXT FROM @getprocName... - [SQLAuthority News - SQL Server White Paper: SQL Server 2008 Compliance Guide](https://blog.sqlauthority.com/2008/11/21/sqlauthority-news-sql-server-white-paper-sql-server-2008-compliance-guide/): Note: Download White Paper by Microsoft Organizations across the globe are being inundated with regulatory requirements. They also have a strong need to better manage their IT systems to ensure they are operating efficiently and staying secure. Microsoft is often asked to provide guidance and technology to assist organizations struggling with compliance. The SQL Server 2008 Compliance Guidance white paper was written to help organizations and individuals understand how to use the features of the Microsoft SQL Server 2008 database software to address their compliance needs. This paper serves as an accompaniment to the SQL Server 2008 compliance software development kit... - [SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database](https://blog.sqlauthority.com/2008/11/20/sql-server-simple-use-of-cursor-to-print-all-stored-procedures-of-database/): SQLAuthority Blog reader YordanGeorgiev has submitted very interesting SP, which uses cursor to generate text of all the Stored Procedure of current Database. This task can be done many ways, however, this is also interesting method. USE AdventureWorks GO DECLARE @procName VARCHAR(100) DECLARE @getprocName CURSOR SET @getprocName = CURSOR FOR SELECT s.name FROM sysobjects s WHERE type = 'P' OPEN @getprocName FETCH NEXT FROM @getprocName INTO @procName WHILE @@FETCH_STATUS = 0 BEGIN EXEC sp_HelpText @procName FETCH NEXT FROM @getprocName INTO @procName END CLOSE @getprocName DEALLOCATE @getprocName GO Just give this script a try and it will print text of all the SP in your... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Group Photo](https://blog.sqlauthority.com/2008/11/19/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-group-photo/): MVP Open day 2008 is one of the best event happened so far. I have previously written about this event in detail on this blog. - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 3](https://blog.sqlauthority.com/2008/11/18/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-3/): Yesterday was our last day at South Asia MVP Open Day. For three days continuously we are having great time along with fellow MVP. Every MVP was having great time because the way whole event was planned. We had plenty of time for networking as well lots of interesting sessions were going on. Most of the MVPs had slept late the day before because everybody was preparing their presentation for community buzz. The day before we had wonderful Open Space sessions at Midnight. The most avaited sessions was Nitin Paranjape – Do’s and Dont’s of being an entrepreneur (Monetizing your expertise).... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 2](https://blog.sqlauthority.com/2008/11/17/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-2/): At MVP Open Day we were promised that we will have 8 to 8 action packed day but we all observed much longer hours where we all MVP’s were busy with activity. I will say instead of 8 AM to 8 PM we actually had fun from 8 AM to 2 AM (next day). Day 2 at MVP Open day was filled with technical sessions followed by River Cruise and Dance party at Casino. On day 2 we had team photo, as I was part of team photo I could not take this photo myself. I will request Abhishek Kant to... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 1](https://blog.sqlauthority.com/2008/11/16/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-1/): It is great fun! Perfect Event and Great start. Yesterday I wrote about agenda of South Asia MVP Open Day 2008 which is at Hotel Kenilworth Resorts, Goa. November 15 – Day 1 of Open Day started with plain journey and ended with Goan Team Party at beach with fellow MVP. I have more than hundreds of the photos of this event. I will share few of the them with you. First of all let me thank three four people, without their support this event might have not possible. Howard Lo – Microsoft, Singapore – Regional Manager, Asia Pacific and Greater... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Link List](https://blog.sqlauthority.com/2008/11/15/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-link-list/): Today is very exciting day as I will start my trip to South Asia MVP Open Day 2008 – Goa. Yesterday I wrote about my visit. I will be attending South Asia MVP Open Day 2008 on November 15 – 17, 2008 at Hotel Kenilworth Resorts, Goa. Those who have asked how can they meet me in Goa is that you will have to send me email and I will respond to them. At this moment I have reached goa and writing using my new USB Data Card internet. I will post more photos and event details as I receive them.... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa](https://blog.sqlauthority.com/2008/11/14/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa/): I will be attending South Asia MVP Open Day 2008 on November 15 – 17, 2008 at Hotel Kenilworth Resorts, Goa. I am very excited as this will be my first Open Day event after being MVP. Microsoft Most Valuable Professionals (MVPs) are exceptional technical community leaders from around the world who are awarded for voluntarily sharing their high quality, real world expertise in offline and online technical communities. Microsoft MVPs are a highly select group of experts that represents the technical community’s best and brightest, and they share a deep commitment to community and a willingness to help others. There... - [SQLAuthority News - RML Utilities - Usage and Additional Help](https://blog.sqlauthority.com/2008/11/13/sqlauthority-news-rml-utilities-usage-and-additional-help/): Yesterday I wrote about SQLAuthority News – Download RML Utilities for SQL Server. I received many emails where different developers requested how to find additional help regarding RML Utilities. Few users reported that they are not able to install RML Utilities because of some reporting service pre-requisite. If RML Utilities are not being installed due to pre-requisite, install Microsoft Report Viewer 2008 SP1 Redistributable and then try to install RML Utilities. If there is need of additional help once RML Utilities are installed click on Start >> All Programs >> RML Utilities for SQL Server >> Help >> RML Help. Once... - [SQLAuthority News - Download RML Utilities for SQL Server](https://blog.sqlauthority.com/2008/11/12/sqlauthority-news-download-rml-utilities-for-sql-server/): Note:   Download RML Utilities for SQL Server by Microsoft The RML utilities allow you to process SQL Server trace files and view reports showing how SQL Server is performing. For example, you can quickly see: Which application, database or login is using the most resources, and which queries are responsible for that Whether there were any plan changes for a batch during the time when the trace was captured and how each of those plans performed What queries are running slower in today’s data compared to a previous set of data You can also test how the system will behave with... - [SQL SERVER - Delete Backup History - Cleanup Backup History](https://blog.sqlauthority.com/2008/11/11/sql-server-delete-backup-history-cleanup-backup-history/): SQL Server stores history of all the taken backup forever. History of all the backup is stored in msdb database. Many times older history is no more required. Following Stored Procedure can be executed with parameter which takes days of history to keep. In following example 30 is passed to keep history of month. USE msdb GO DECLARE @DaysToKeepHistory DATETIME SET @DaysToKeepHistory = CONVERT(VARCHAR(10), DATEADD(dd, -30, GETDATE()), 101) EXEC sp_delete_backuphistory @DaysToKeepHistory GO Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Check Database Integrity for All Databases of Server - DBCC CHECKDB](https://blog.sqlauthority.com/2008/11/10/sql-server-check-database-integrity-for-all-databases-of-server/): Today we will see quick script which will check integrity of all the databases of SQL Server. We will learn about DBCC CHECKDB in this blog post.  - [SQLAuthority News - SQL Server 2008 Book Online Updated in October 2008](https://blog.sqlauthority.com/2008/11/09/sqlauthority-news-sql-server-2008-book-online-updated-in-october-2008/): SQL Server 2008 Books Online is updated on 31 October 2008. I always bookmark latest BOL for my easy reference. Getting Started: New and Updated Topics (31 October 2008) Analysis Services – Multidimensional Data: New and Updated Topics (31 October 2008) Database Engine: New and Updated Topics (31 October 2008) Integration Services: New and Updated Topics (31 October 2008) Analysis Services – Data Mining: New and Updated Topics (31 October 2008) Reporting Services: New and Updated Topics (31 October 2008) Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER 2008 - Connect Visual Studio 2005 Patch Download](https://blog.sqlauthority.com/2008/11/08/sql-server-2008-connect-visual-studio-2005-patch-download/): It was not possible to connect SQL Server 2008 to Visual Studio 2005 so far. Microsoft has released Service Pack once it is installed SQL Server 2008. - [SQL SERVER - Refresh Database Using T-SQL](https://blog.sqlauthority.com/2008/11/07/sql-server-refresh-database-using-t-sql/): Yesterday I received following questions on blog. Ashish Agarwal asked following question. Hi Pinal, Can we refresh a database (like we do by right clicking database node in object explorer and clicking on refresh) thru SQL Query? If yes, can you please tell me the query? Thanks, Ashish Agarwal Answer to above question is NO. It is not possible to do the same task using SQL Query. However, if you have changed some SP or any other object and if they are cached in the database, database can be refreshed using DBCC commands. Read my previous article about SQL SERVER –... - [SQLAuthority News - 5 Millions Visitors - 2 Anniversary - Authors Note on Economy Slow Down and Job Opportunity - SQL Server](https://blog.sqlauthority.com/2008/11/06/sqlauthority-news-5-millions-visitors-2-anniversary-authors-note-on-economy-slow-down-and-job-opportunity-sql-server/): I just received the following screen shot from one of the regular readers of the SQLAuthority.com blog. He pointed out important milestone for our blog. We have crossed 5 million visitors. In less than 2 years SQLAuthority.com blog has been visited by 5 million visitors. I even missed the anniversary our blog. On November 1st, 2008 SQLAuthority.com has completed 2 years of its existence and now continuing in 3rd year. - [SQLAuthority News - Microsoft SQL Server Compact 3.5 Server Tools Beta 2 Released](https://blog.sqlauthority.com/2007/08/03/sqlauthority-news-microsoft-sql-server-compact-35-server-tools-beta-2-released/): SQL Server Compact 3.5 Server Tools installs replication components on the IIS server enabling merge replication and remote data access (RDA) between SQL Server Compact 3.5 database on a Windows Desktop & Mobile devices and database servers running SQL Server 2005 and later versions of SQL Server 2005. Download SQL Server Compact 3.5 For more information please see the SQL Server Compact 3.5 Books Online Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Two Different Ways to Comment Code - Explanation and Example](https://blog.sqlauthority.com/2007/08/03/sql-server-two-different-ways-to-comment-code-explanation-and-example/): SQL Server has two different ways to comment code. Let us learn all of them here in this blog post. Various the options in the blog posts. - [SQLAuthority News - Book Review - SQL Server 2005 Practical Troubleshooting: The Database Engine](https://blog.sqlauthority.com/2007/08/02/sqlauthority-news-book-review-sql-server-2005-practical-troubleshooting-the-database-engine/): SQLAuthority.com Book Review : SQL Server 2005 Practical Troubleshooting: The Database Engine (SQL Server Series) (Paperback) by Ken Henderson Link to book on Amazon Short Review : Database Administrators can use this book on a daily basis in SQL Server 2005 troubleshooting and problem solving. Answers to SQL issues can be swiftly located using the index of this book.This book covers the topics and subjects which any other books, blogs or websites (including MSDN, BOL) do not cover. This book provides DBAs with solutions which can be used by user in highly dynamic environments to resolve common and specialized problems. This... - [SQL SERVER - FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details](https://blog.sqlauthority.com/2007/08/02/sql-server-fix-error-945-database-cannot-be-opened-due-to-inaccessible-files-or-insufficient-memory-or-disk-space-see-the-sql-server-error-log-for-details/): SQL SERVER – FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details This error is very common and many times, I have seen affect of this error as Suspected Database, Database Operation Ceased, Database Stopped transactions. Solution to this error is simple but very important. Fix/Solution/WorkAround: 1) If possible add more hard drive space either by removing of unnecessary files from hard drive or add new hard drive with larger size. 2) Check if the database is set to Autogrow on. 3) Check if... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Search SQL](https://blog.sqlauthority.com/2007/08/01/sql-server-sql-joke-sql-humor-sql-laugh-search-sql/): In meeting with DBA friends one of my friend suggested while searching for “MSSQL Client” Microsoft returns you suggestion as “MySQL Client“. I did not believe it so I tested it myself. He was correct. Here is the screen shot. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - July CTP Released](https://blog.sqlauthority.com/2007/08/01/sql-server-2008-july-ctp-released/): SQL Server 2008 July Community Technology Preview has been released. With SQL Server 2008 July CTP release, customers can immediately utilize new capabilities that support their mission-critical platform and enable pervasive insight across the enterprise. SQL Server 2008 lays the groundwork for innovative policy-based management that enables administrators to reduce their time spent on maintenance tasks. SQL Server 2008 provides enhancements in the SQL Server BI platform by enabling customers to provide up-to-date information with Change Data Capture and MERGE features, and develop highly scalable analysis services cubes with new development environments. - [SQLAuthority News - My Favorite Articles of This Blog](https://blog.sqlauthority.com/2007/07/31/sqlauthority-news-my-favorite-articles-of-this-blog/): The question I receive very often is I have more than 250 articles so far on this blog, which are my most favorite articles so far? Yesterday while talking with my parents on occasion of my birthday, they asked the same question to me. Answer is I keep running list of the my personal favorite articles on my personal website. I update it very frequently. Visit Author’s Personal Favorite Best Articles List Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Birthday of SQL Authority Author](https://blog.sqlauthority.com/2007/07/30/sqlauthority-news-birthday-of-sql-authority-author/): Today is Birthday of SQL Authority Author. Thought of the day : Family is everything. https://www.pinaldave.com/ http://www.SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Data Warehousing Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/07/29/sql-server-data-warehousing-interview-questions-and-answers-complete-list-download/): Click here to get free chapters (PDF) in the mailbox It was a great pleasure to write latest series about Data Warehousing Interview Questions and Answers. Just like always again, I received lots of suggestion and follow up questions. I have tried to accommodate all of them in the last post in the series. I hope this series is helpful to all candidates who are seeking a job as well interviewers. I have combined all the questions and answers in the one PDF which is available to download and refer at convenience. Complete Series of SQL Server Interview Questions and Answers... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/07/28/sql-server-data-warehousing-interview-questions-and-answers-part-3/): Click here to get free chapters (PDF) in the mailbox What are slowly changing dimensions (SCD)? SCD is abbreviation of Slowly changing dimensions. SCD applies to cases where the attribute for a record varies over time. There are three different types of SCD. 1) SCD1 : The new record replaces the original record. Only one record exist in database – current data. 2) SCD2 : A new record is added into the customer dimension table. Two records exist in database – current data and previous history data. 3) SCD3 : The original data is modified to include new data. One record... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/07/27/sql-server-data-warehousing-interview-questions-and-answers-part-2/): Click here to get free chapters (PDF) in the mailbox What are normalization forms? Please visit this article. Describes the foreign key columns in fact table and dimension table? Foreign keys of dimension tables are primary keys of entity tables. Foreign keys of facts tables are primary keys of Dimension tables. What is Data Mining? Data Mining is the process of analyzing data from different perspectives and summarizing it into useful information. What is the difference between view and materialized view? A view takes the output of a query and makes it appear like a virtual table and it can be... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/07/26/sql-server-data-warehousing-interview-questions-and-answers-part-1/): Let us learn about Data Warehousing Interview Questions and Answers. - [SQLAuthority News - Interesting Read - Programming Concepts, Structured Thinking Language (STL) and Relationary](https://blog.sqlauthority.com/2007/07/25/sqlauthority-news-interesting-read-programming-concepts-structured-thinking-language-stl-and-relationary/): I have always enjoyed reading articles and blogs which are different then others. There many be thousands of technology and programming blogs, only few makes difference in the tech world. One of the high quality blog, I enjoy reading is relationary by Grant Czerepak. Grant Czerepak is an IT professional with over 20 years experience in relational database technology specifically in the areas of design, development and administration. As per Grant Czerepak “In this blog I will be mixing, matching, shifting and sifting paradigms that have come up in my work with relational databases and other concepts I’ve picked up while... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/07/25/sql-server-data-warehousing-interview-questions-and-answers-introduction/): Click here to get free chapters (PDF) in the mailbox This series is in response to many of my reader’s continuous request to start Data Warehousing Interview Questions and Answers series. This series is written in the same spirit as previous two series which has received good response. Samples Question from Interview Questions and Answer Series What is Data Warehousing? A data warehouse is the main repository of an organization’s historical data, its corporate memory. It contains the raw material for management’s decision support system. The critical factor leading to the use of a data warehouse is that a data analyst... - [SQL SERVER - 2005 - Server and Database Level DDL Triggers Examples and Explanation](https://blog.sqlauthority.com/2007/07/24/sql-server-2005-server-and-database-level-ddl-triggers-examples-and-explanation/): Let's learn about Server and Database Level DDL Triggers Examples and Explanation here. Let us learn more about this topic. - [SQL SERVER - UDF - Function to Get Previous And Next Work Day - Exclude Saturday and Sunday](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-function-to-get-previous-and-next-work-day-exclude-saturday-and-sunday/): While reading ColdFusion blog of Ben Nadel Getting the Previous Day In ColdFusion, Excluding Saturday And Sunday, I realize that I use similar function on my SQL Server Database. This function excludes the Weekends (Saturday and Sunday), and it gets previous as well as next work day. - [SQL SERVER - UDF - Get the Day of the Week Function](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-get-the-day-of-the-week-function/): The day of the week can be retrieved in SQL Server by using the DatePart function. The value returned by function is between 1 (Sunday) and 7 (Saturday). To convert this to a string representing the day of the week, use a CASE statement. Method 1: Create function running following script: CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) SELECT @rtDayofWeek = CASE DATEPART(weekday,@dtDate) WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN 'Wednesday' WHEN 5 THEN 'Thursday' WHEN 6 THEN 'Friday' WHEN 7 THEN 'Saturday' END RETURN (@rtDayofWeek) END GO Call... - [SQLAuthority News - FQL - Facebook Query Language](https://blog.sqlauthority.com/2007/07/22/sqlauthority-news-fql-facebook-query-language/): I was exploring the new hype today, I found Facebook Developers Documentation very interesting. Facebook API can be queries using FQL - Facebook Query Language, which is similar to SQL. - [SQL SERVER - Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database 'yourdatabasename'. CREATE DATABASE is aborted.](https://blog.sqlauthority.com/2007/07/21/sql-server-fix-error-msg-1813-level-16-state-2-line-1-could-not-open-new-database-yourdatabasename-create-database-is-aborted/): Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database ‘yourdatabasename’. CREATE DATABASE is aborted. This errors happens when corrupt database log are attempted to attach to new server. Solution of this error is little long and it involves restart of the server. I recommend following all the steps below in order without skipping any of them. Fix/Solution/Workaround: SQL Server logs are corrupted and they need to be rebuilt to make the database operational. Follow all the steps in order. Replace the yourdatabasename name with real name of your database. 1. Create a new database... - [SQL SERVER - Fix : Error Msg 4214 - Error Msg 3013 - BACKUP LOG cannot be performed because there is no current database backup](https://blog.sqlauthority.com/2007/07/20/sql-server-fix-error-msg-4214-error-msg-3013-backup-log-cannot-be-performed-because-there-is-no-current-database-backup/): This is very interesting error as I could not found any documentation on-line. It took me nearly 1 hour to figure out what was creating error. - [SQL SERVER - 2005 - SSMS - View/Send Query Results to Text/Grid/Files](https://blog.sqlauthority.com/2007/07/19/sql-server-2005-ssms-viewsend-query-results-to-textgridfiles/): Many times I have been asked how to change the result window from Text to Grid and vice versa. There are three different ways to do it. Method 1 : Key-Board Short Cut Results to Text – CTRL + T Results to Grid – CTRL + D Results to File – CTRL + SHIFT + F Method 2 : Using Toolbar Method 3 : Using Menubar Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SPACE Function Example](https://blog.sqlauthority.com/2007/07/19/sql-server-space-function-example/): A month ago, I wrote about SQL SERVER – TRIM() Function – UDF TRIM() . I was asked in comment if SQL Server has space function? Yes. SELECT SPACE(100) will generate 100 space characters. The use of SPACE() function is demonstrated in BOL very fine. Example from BOL: USE AdventureWorks; GO SELECT RTRIM(LastName) + ',' + SPACE(2) + LTRIM(FirstName) FROM Person.Contact ORDER BY LastName, FirstName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Restore Database Without or With Backup - Everything About Restore and Backup](https://blog.sqlauthority.com/2007/07/18/sql-server-restore-database-without-or-with-backup-everything-about-restore-and-backup/): The questions I received in last two weeks: “I do not have backup, is it possible to restore database to previous state?” “How can restore the database without using backup file?” “I accidentally deleted tables in my database, how can I revert back?” “How to revert the changes, I have only logs but no complete backup?” “How to rollback the database changes, my backup file is corrupted?” Answer: You need complete backup to rollback your changes. If you do not have complete backup you can not revert back. Sorry. To restore the database to previous stage if you have full backup:... - [SQL SERVER - CASE Statement in ORDER BY Clause - ORDER BY using Variable](https://blog.sqlauthority.com/2007/07/17/sql-server-case-statement-in-order-by-clause-order-by-using-variable/): This article is as per request from Application Development Team Leader of my company. His team encountered code where application was preparing string for ORDER BY clause of SELECT statement. Application was passing this string as variable to Stored Procedure (SP) and SP was using EXEC to execute the SQL string. This is not good for performance as Stored Procedure has to recompile every time due to EXEC. sp_executesql can do the same task but still not the best performance. Previously: Application: Nesting logic to prepare variable OrderBy. Database: Stored Procedure takes variable OrderBy as input parameter. SP uses EXEC (or... - [SQL SERVER - Microsoft White Papers - Analysis Services Query Best Practices - Partial Database Availability](https://blog.sqlauthority.com/2007/07/16/sql-server-microsoft-white-papers-analysis-services-query-best-practices-partial-database-availability/): Microsoft TechNet frequently releases White Papers on SQL Server Technology. I have read the following two white papers recently. The summary of its content is here. Analysis Services Query Performance Top 10 Best Practices Optimize cube and measure group design Define effective aggregations Use partitions Write efficient MDX Use the query engine cache efficiently Ensure flexible aggregations are available to answer queries. Tune memory usage Tune processor usage Scale up where possible Scale out when you can no longer scale up Partial Database Availability Writer: Danny Tambs Download Word Document As databases become larger and larger, the infrastructure assets and technology... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - 15 Signs to Identify Bad DBA](https://blog.sqlauthority.com/2007/07/15/sql-server-sql-joke-sql-humor-sql-laugh-15-signs-to-identify-bad-dba/): 15 Signs to Identify Bad DBA They think it is bug in SQL Server when two NULL values compared with each other but SQL Server does not say they equal to each other. They do not rename the trigger name thinking it will not work after it is rename. They are looking for difference between Index Scan or Table Scan on Google. They reinstall the SQL Server if they forget the password of SA login. They use model database for testing their script. They believe compiled stored procedure is production ready. They prefix all stored procedures with ‘sp_’ to be consistent... - [SQL SERVER - 2005 Collation Explanation and Translation - Part 2](https://blog.sqlauthority.com/2007/07/14/sql-server-2005-collation-explanation-and-translation-part-2/): Following function return all the available collation of SQL Server 2005. My previous article about the SQL SERVER – 2005 Collation Explanation and Translation. SELECT * FROM sys.fn_HelpCollations() Result Set: (only few of 1011 records) Name Description Latin1_General_BIN Latin1-General, binary sort Latin1_General_BIN2 Latin1-General, binary code point comparison sort Latin1_General_CI_AI Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AI_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AI_KS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AI_KS_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-sensitive Latin1_General_CI_AS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AS_KS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AS_KS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-sensitive Latin1_General_CS_AI Latin1-General, case-sensitive, accent-insensitive, kanatype-insensitive,... - [SQL SERVER - 2005 - Use ALTER DATABASE MODIFY NAME Instead of sp_renameDB to rename](https://blog.sqlauthority.com/2007/07/13/sql-server-2005-use-alter-database-modify-name-instead-of-sp_renamedb-to-rename/): To rename database it is very common to use for SQL Server 2000 user : EXEC sp_renameDB 'oldDB','newDB' sp_renameDB syntax will be deprecated in the future version of SQL Server. It is supported in SQL Server 2005 for backwards compatibility only. It is recommended to use ALTER DATABASE MODIFY NAME instead. New syntax of ALTER DATABASE MODIFY NAME is simple as well. /* Create Test Database */ CREATE DATABASE Test GO /* Rename the Database Test to NewTest */ ALTER DATABASE Test MODIFY NAME = NewTest GO /* Cleanup NewTest Database Do not run following command if you want to use the database. It is dropped here for sample database clean up. */ DROP DATABASE NewTest GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Validate Field For DATE datatype using function ISDATE()](https://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/): This article is based on the a question from Jr. Developer at my company. He works with the system, where we import CSV file in our database. One of the fields in the database is DATETIME field. Due to architecture requirement, we insert all the CSV fields in the temp table which has all the fields VARCHAR. We validate all the data first in temp table (check for inconsistency, malicious code, incorrect data type) and if passed validation we insert them in the final table in the database. Let us learn about ISDate function in this blog post. - [SQLAuthority News - SQL Blog SQLAuthority.com Comment by Mr. Ben Forta](https://blog.sqlauthority.com/2007/07/11/sqlauthority-news-sql-blog-sqlauthoritycom-comment-by-mr-ben-forta/): Today is one of the most glorious day for SQLAuthority.com in history. Famous author of Sams Teach Yourself Microsoft SQL Server T-SQL In 10 Minutes, ColdFusion Guru, and well known evangelists Mr. Ben Forta has made comment on his blog about SQLAuthority.com. I encourage all my readers to visit comment link here. I am very thankful to Mr. Forta for finding time to visit my blog from his busy schedule. I am attaching screen shot of the original post along with this post for reference. Mr. Forta said, “Pinalkumar Dave is a DBA with extensive SQL Server (and ColdFusion) experience. I... - [SQL SERVER - 2005 - Features Comparison Chart](https://blog.sqlauthority.com/2007/07/11/sql-server-2005-features-comparison-chart/): This post in the response to all the readers who have asked what are the differences between SQL Server 2005 editions. The reason I have never posted article about this as Microsoft has wonderful comparison chart on Microsoft SQL Server web site. This chart explains the difference between features of Express, Workgroup, Standard, and Enterprise editions. Visit Microsoft SQL Server 2005 Editions Features Comparison Chart Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Scheduled Launch at an Event in Los Angeles on Feb. 27, 2008](https://blog.sqlauthority.com/2007/07/11/sql-server-2008-scheduled-launch-at-an-event-in-los-angeles-on-feb-27-2008/): SQL SERVER 2008 will be launched at an Event in Los Angeles on Feb. 27, 2008. “In anticipation for the most significant Microsoft enterprise event in the next year, Turner announced that Windows Server® 2008, Visual Studio® 2008 and Microsoft SQL Server™ 2008 will launch together at an event in Los Angeles on Feb. 27, 2008, kicking off hundreds of launch events around the world.” Read original article here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Count Duplicate Records - Rows](https://blog.sqlauthority.com/2007/07/11/sql-server-count-duplicate-records-rows/): In my previous article SQL SERVER – Delete Duplicate Records – Rows, we have seen how we can delete all the duplicate records in one simple query. In this article we will see how to find count of all the duplicate records in the table. Following query demonstrates usage of GROUP BY, HAVING, ORDER BY in one query and returns the results with duplicate column and its count in descending order. SELECT YourColumn, COUNT(*) TotalCount FROM YourTable GROUP BY YourColumn HAVING COUNT(*) > 1 ORDER BY COUNT(*) DESC Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com)... - [SQL SERVER - 2005 - List All Stored Procedure Modified in Last N Days](https://blog.sqlauthority.com/2007/07/10/sql-server-2005-list-all-stored-procedure-modified-in-last-n-days/): I usually run following script to check if any stored procedure was deployed on live server without proper authorization in last 7 days. If SQL Server suddenly start behaving in un-expectable behavior and if stored procedure were changed recently, following script can be used to check recently modified stored procedure. If stored procedure was created but never modified afterwards modified date and create date for that stored procedure are same. SELECT name FROM sys.objects WHERE type = 'P' AND DATEDIFF(D,modify_date, GETDATE()) < 7 ----Change 7 to any other day value Following script will provide name of all the stored procedure which... - [SQL SERVER - Result of EXP (Exponential) to the POWER of PI - Functions Explained](https://blog.sqlauthority.com/2007/07/09/sql-server-result-of-exp-exponential-to-the-power-of-pi-functions-explained/): SQL Server can do some intense Mathematical calculations. Following are three very basic and very necessary functions. All the three function does not need explanation. I will not introduce their definition but will demonstrate the usage of function. SELECT PI() GO SELECT POWER(2,5) GO SELECT POWER(8,-2) GO SELECT EXP(99) GO SELECT EXP(1) GO Results Set : PI ———————- 3.14159265358979 PowerEg1 ———– 32 PowerEg2 ———– 0 ExpEg1 ———————- 9.88903031934695E+42 ExpEg2 ———————- 2.71828182845905 Now the Questions asked in the Title of the Article – What is the result of EXP to the POWER of PI SELECT POWER(EXP(1), PI()) GO Results ———————- 23.1406926327793 Reference... - [SQL SERVER - FIX : ERROR Msg 244, Level 16, State 1 - FIX : ERROR Msg 245, Level 16, State 1](https://blog.sqlauthority.com/2007/07/08/sql-server-fix-error-msg-244-level-16-state-1-fix-error-msg-245-level-16-state-1/): FIX : ERROR Msg 244, Level 16, State 1, Line 1 FIX : ERROR Msg 245, Level 16, State 1, Line 1 This error can happen due to conversion of one data type to incompatible datatype. Few examples are: VARCHAR to INT, INT to TINYINT etc. I have spotted this error happening with CAST or ISNULL, please add comments if you have come across this error in other examples. Following scripts will create this error. SELECT CAST('111111' AS SMALLINT); SELECT CAST('This is not smallint' AS SMALLINT); The errors received from above two scripts are : Msg 244, Level 16, State 2,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Generic Quotes](https://blog.sqlauthority.com/2007/07/08/sql-server-sql-joke-sql-humor-sql-laugh-generic-quotes/): Few days ago, in meeting I was forced to answer one of the question from non-programmer was considered as funny quotes for long time. “Yes it is latest year 2005 version of SQL Server – still it will not play your flash movie” — Pinal Dave (SQLAuthority.com) Many of following quotes are well apply to SQL Server or any database and I find them humorous. Software is Too Important to be Left to Programmers — Meilir Page-Jones. A clever person solves a problem. A wise person avoids it. — Einstein If you think good architecture is expensive, try bad architecture. —... - [SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT](https://blog.sqlauthority.com/2007/07/07/sql-server-convert-text-to-numbers-integer-cast-and-convert/): Few of the questions I receive very frequently. I have collect them in spreadsheet and try to answer them frequently. How to convert text to integer in SQL? If table column is VARCHAR and has all the numeric values in it, it can be retrieved as Integer using CAST or CONVERT function. How to use CAST or CONVERT? SELECT CAST(YourVarcharCol AS INT) FROM Table SELECT CONVERT(INT, YourVarcharCol) FROM Table Will CAST or CONVERT thrown an error when column values converted from alpha-numeric characters to numeric? YES. Will CAST or CONVERT retrieve only numbers when column values converted from alpha-numeric characters to... - [SQL SERVER - FIX : Error : msg 8115, Level 16, State 2, Line 2 - Arithmetic overflow error converting expression to data type](https://blog.sqlauthority.com/2007/07/06/sql-server-fix-error-msg-8115-level-16-state-2-line-2-arithmetic-overflow-error-converting-expression-to-data-type/): Following errors can happen when any field in the database is attempted to insert or update larger data of the same type or other data type. Msg 8115, LEVEL 16, State 2, Line 2 Arithmetic overflow error converting expression TO data type <ANY DataType> Example is if integer 111111 is attempted to insert in TINYINT data type it will throw above error, as well as if integer 11111 is attempted to insert in VARCHAR(2) data type it will throw above error. Fix/Solution/Workaround: 1) Verify the inserted/updated value that it is of correct length and data type. 2) If inserted/updated value are... - [SQL SERVER - 2005 - Microsoft Document Explorer cannot be shown because the specified help collection 'ms-help://MS.SQLCC.v9](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-microsoft-document-explorer-cannot-be-shown-because-the-specified-help-collection-ms-helpmssqlccv9/): I have received six emails in last four days asking for the resolution of error when tried to open newly installed SQL Server Book On-Line. Microsoft Document Explorer cannot be shown because the specified help collection ‘ms-help://MS.SQLCC.v9 1) Uninstall the versions of Book On-line (different languages, different releases etc) using Add-Remove programs tools. 2) Re-install SQL Server Book On-line. Above solution is confirmed by MSDN site here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Best Practices Analyzer Tutorial - Sample Example](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-best-practices-analyzer-tutorial-sample-example/): Yesterday I posted small note about SQL SERVER – 2005 Best Practices Analyzer (July BPA). I received many request about how BPA is used. Some of readers has asked me to provide sample tutorial which can help start using BPA. This utility has many uses for best practice. I have created very simple and initial tutorial. I encourage to follow that and once used it create your own reports in your desired format. Do not hesitate to install this add-on as I have use this previously to tune our production servers. Following tutorial about BPA is ran on one of my... - [SQL SERVER - 2005 Best Practices Analyzer (July BPA)](https://blog.sqlauthority.com/2007/07/04/sql-server-2005-best-practices-analyzer-july-bpa/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD HERE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Definition, Comparison and Difference between HAVING and WHERE Clause](https://blog.sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/): In recent interview sessions in hiring process I asked this question to every prospect who said they know basic SQL. Surprisingly, none answered me correct. They knew lots of things in details but not this simple one. One prospect said he does not know cause it is not on this Blog. Well, here we are with same topic online. Answer in one line is : HAVING specifies a search condition for a group or an aggregate function used in SELECT statement. HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP... - [SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable](https://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/): #TempTable and @TempVariable are different things with different scope. Their purpose is different but highly overlapping. TempTables are originated for the storage and & storage & manipulation of temporal data. TempVariables are originated (SQL Server 2000 and onwards only) for returning date-sets from table-valued functions. Common properties of #TempTable and @TempVariable They are instantiated in tempdb. They are backed by physical disk. Changes to them are logged in the transaction log1. However, since tempdb always uses the simple recovery model, those transaction log records only last until the next tempdb checkpoint, at which time the tempdb log is truncated. Discussion of... - [SQL SERVER - 2005 Comparison SP_EXECUTESQL vs EXECUTE/EXEC](https://blog.sqlauthority.com/2007/07/02/sql-server-2005-comparison-sp_executesql-vs-executeexec/): Common Properties of SP_EXECUTESQL and EXECUTE/EXEC The Transact-SQL statements in the sp_executesql or EXECUTE string are not compiled into an execution plan until sp_executesql or the EXECUTE statement are executed. The strings are not parsed or checked for errors until they are executed. The names referenced in the strings are not resolved until they are executed. The Transact-SQL statements in the executed string do not have access to any of the variables declared in the batch that contains thesp_executesql or EXECUTE statement. The batch containing the sp_executesql or EXECUTE statement does not have access to variables or local cursors defined in... - [SQL SERVER - Explanation of WITH ENCRYPTION clause for Stored Procedure and User Defined Functions](https://blog.sqlauthority.com/2007/07/01/sql-server-explanation-of-with-encryption-clause-for-stored-procedure-and-user-defined-functions/): This article is written to answer following two questions I have received in last one week. Questions 1) How to hide code of my Stored Procedure that no one can see it? 2) Our DBA has left the job and one of the function which retrieves important information is encrypted, how can we decrypt it and find original code? Answers 1) Use WITH ENCRYPTION while creating Stored Procedure or User Defined Function. 2) Sorry, unfortunately there is no simple way to decrypt the code. Hard way is too hard to even attempt. Explanations of WITH ENCRYPTION clause If SP or UDF... - [SQL SERVER - Fix : Error : Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type 'varchar' exceeds the maximum allowed for any data type (8000)](https://blog.sqlauthority.com/2007/06/30/sql-server-fix-error-server-msg-131-level-15-state-3-line-1-the-size-given-to-the-type-varchar-exceeds-the-maximum-allowed-for-any-data-type-8000/): Error: Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type ‘varchar’ exceeds the maximum allowed for any data type (8000) When the the length is specified in declaring a VARCHAR variable or column, the maximum length allowed is still 8000. Fix/WorkAround/Solution: Use either VARCHAR(8000) or VARCHAR(MAX) . VARCHAR(MAX) of SQL Server 2005 is replacement of TEXT of SQL Server 2000. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recompile All The Stored Procedure on Specific Table](https://blog.sqlauthority.com/2007/06/29/sql-server-recompile-all-the-stored-procedure-on-specific-table/): I have noticed that after inserting many rows in one table many times the stored procedure on that table executes slower or degrades. This happens quite often after BCP or DTS. I prefer to recompile all the stored procedure on the table, which has faced mass insert or update. sp_recompiles marks stored procedures to recompile when they execute next time. Example: ----Following script will recompile all the stored procedure on table Sales.Customer in AdventureWorks database. USE AdventureWorks; GO EXEC sp_recompile N'Sales.Customer'; GO ----Following script will recompile specific stored procedure uspGetBillOfMaterials only. USE AdventureWorks; GO EXEC sp_recompile 'uspGetBillOfMaterials'; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - 2005 Improvements in TempDB](https://blog.sqlauthority.com/2007/06/28/sql-server-2005-improvements-in-tempdb/): Following are some important improvements in tempdb in SQL Server 2005 over SQL Server 2000 Input/Output traffic to TempDB is reduced as logging is improved. In SQL Server 2005 TempDB does not log “after value” everytime. E.g. For INSERT it does not log after value on log as that will be any way logged in the TempTable. Similar for DELETE as It does not have to log After value as it is not there. This is big improvement in performance in SQL Server 2005 for TempDB. Some other improvement in File System of operating system. (I am not listing them as... - [SQL SERVER - Running Batch File Using T-SQL - xp_cmdshell bat file](https://blog.sqlauthority.com/2007/06/27/sql-server-running-batch-file-using-t-sql/): In last month I received few emails emails regarding SQL SERVER – Enable xp_cmdshell using sp_configure. The questions are 1) What is the usage of xp_cmdshell and 2) How to execute BAT file using T-SQL? I really like the follow up questions of my posts/articles. Answer is xp_cmdshell can execute shell/system command, which includes batch file. 1) Example of running system command using xp_cmdshell is SQL SERVER – Script to find SQL Server on Network EXEC master..xp_CMDShell 'ISQL -L' 2) Example of running batch file using T-SQL i) Running standalone batch file (without passed parameters) EXEC master..xp_CMDShell 'c:findword.bat' ii) Running parameterized batch... - [SQL SERVER - 2005 List All Tables of Database](https://blog.sqlauthority.com/2007/06/26/sql-server-2005-list-all-tables-of-database/): This is very simple and can be achieved using system table sys.tables. USE YourDBName GO SELECT * FROM sys.Tables GO This will return all the tables in the database which user have created. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Explanation and Example Four Part Name](https://blog.sqlauthority.com/2007/06/26/sql-server-explanation-and-example-four-part-name/): What is four part name? Explanation : ServerName.DatabaseName.DatabaseOwner.TableName Example : localhost.AdventureWorks.Person.Contact Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Repeate String N Times Using String Function REPLICATE](https://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/): I came across this SQL String Function few days ago while searching for Database Replication. This is T-SQL Function and it repeats the string/character expression N number of times specified in the function. SELECT REPLICATE( ' https://blog.sqlauthority.com/ ' , 9 ) This repeats the string https://blog.sqlauthority.com/ to 9 times in result window. I think it is fun utility to generate repeated text if ever required. Result Set: https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com/) , BOL - [SQLAuthority News - Book Review - Microsoft(R) SQL Server 2005 Unleashed (Paperback)](https://blog.sqlauthority.com/2007/06/24/sqlauthority-news-book-review-microsoftr-sql-server-2005-unleashed-paperback/): SQLAuthority.com Book Review : Microsoft(R) SQL Server 2005 Unleashed (Paperback) by Ray Rankins, Paul Bertucci, Chris Gallelli, Alex T. Silverstein Link to book on Amazon Short Review : SQL Server 2005 Unleashed is focused on Database Administration and day-to-day administrative management aspects of SQL Server. All the chapters of this book are heavily based on Book On-line (BOL) and it continue discussing the topics, where BOL leaves off. This makes this book a good reference for those who are looking for additional information, tricks & tips, and behind the scene details. I recommend this book as a wonderful read and hands-on... - [SQL SERVER - Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild - SQL SERVER 2000 and SQL SERVER 2005](https://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/): Index Fragmentation: When a page of data fills to 100 percent and more data must be added to it, a page split occurs. To make room for the new data, SQL Server must move half of the data from the full page to a new page. The new page that is created is created after all the pages in database. Therefore, instead of going right from one page to the next when looking for data, SQL Server has to go one page to another page around the database looking for the next page it needs. This is Index Fragmentation. Severity of... - [SQL SERVER - 2005 Row Overflow Data Explanation](https://blog.sqlauthority.com/2007/06/23/sql-server-2005-row-overflow-data-explanation/): In SQL Server 2000 and SQL Server 2005 a table can have a maximum of 8060 bytes per row. One of my fellow DBA said that he believed that SQL Server 2000 had that restriction but SQL Server 2005 does not have that restriction and it can have a row of 2GB. I totally agreed with him but after we discussed this problem in depth, we realized that there are more into it than only 8060 bytes limit. It is still true for SQL Server 2005 that a table can have maximum of 8060 bytes per row however the restriction has... - [SQL SERVER - Explanation and Comparison of NULLIF and ISNULL](https://blog.sqlauthority.com/2007/06/22/sql-server-explanation-and-comparison-of-nullif-and-isnull/): Explanation of NULLIF Syntax: NULLIF ( expression , expression ) Returns a null value if the two specified expressions are equal. NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression. NULLIF is equivalent to a searched CASE function in which the two expressions are equal and the resulting expression is NULL. - [SQLAuthority.com News - iGoogle Gadget Published](https://blog.sqlauthority.com/2007/06/21/sqlauthoritycom-news-igoogle-gadget-published/): I have recently received many requests to add an iGoogle Gadget so it can be integrated on iGoogle home page so I’ve gone ahead and done so: Add iGoogle Gadget Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Retrieve Current DateTime in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}](https://blog.sqlauthority.com/2007/06/21/sql-server-retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/): There are three ways to retrieve the current datetime in SQL SERVER. CURRENT_TIMESTAMP, GETDATE(), {fn NOW()} - [SQL SERVER - Find Length of Text Field](https://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/): To measure the length of VARCHAR fields the function LEN(varcharfield) is useful. To measure the length of TEXT fields the function is DATALENGTH(textfield). Len will not work for text field. Example: SELECT DATALENGTH(yourtextfield) AS TEXTFieldSize Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com News - Journey to SQL Authority Milestone of SQL Server](https://blog.sqlauthority.com/2007/06/19/sqlauthoritycom-news-journey-to-sql-authority-milestone-of-sql-server/): SQLAuthority.com News – Journey to SQL Authority Milestone of SQL Server I am very glad to write this 200th post of this blog. I would like to express my gratitude to all of YOU – my readers for continuously reading this blog. I receive many comments and emails with feedback, questions and suggestion everyday. I enjoy meeting few of you during this journey as well. Please do send me feedback and your request to make this blog better. Following is milestone of Journey to SQL Authority. SQL Server Interview Questions and Answers Complete List Download (PDF) SQL Server Database Coding Standards... - [SQL SERVER - Delay Function - WAITFOR clause - Delay Execution of Commands](https://blog.sqlauthority.com/2007/06/18/sql-server-delay-function-waitfor-clause-delay-execution-of-commands/): Blocks the execution of a batch, stored procedure, or transaction until a specified time or time interval is reached, or a specified statement modifies or returns at least one row. This is very useful. Every day when I restore the database to backup server for reports post processing, I use WAITFOR clause. While executing the WAITFOR statement, the transaction is running and no other requests can run under the same transaction. If the server is busy, the thread may not be immediately scheduled; therefore, the time delay may be longer than the specified time. WAITFOR can be used with query but... - [SQL SERVER - De-fragmentation of Database at Operating System to Improve Performance](https://blog.sqlauthority.com/2007/06/17/sql-server-de-fragmentation-of-database-at-operating-system-to-improve-performance/): This issues was brought to me by our Sr. Network Engineer. While running operating system level de-fragmentation using either windows de-fragmentation or third party tool it always skip all the MDF file and never de-fragment them. He was wondering why this happens all the time. The reason MDF file are skipped all the time in de-fragmentation because they are in use when SQL Server is running. Windows operating system de-fragmentation skips all the file in are currently in use. After discovering this the real question was how to de-fragment when files are in use. Steps are Stop the Server, Re-start, keep... - [SQL SERVER - 2005 - UDF - User Defined Function to Strip HTML - Parse HTML - No Regular Expression](https://blog.sqlauthority.com/2007/06/16/sql-server-udf-user-defined-function-to-strip-html-parse-html-no-regular-expression/): One of the developers at my company asked is it possible to parse HTML and retrieve only TEXT from it without using regular expression. He wanted to remove everything between < and > and keep only Text. I found the question very interesting and quickly wrote UDF which does not use regular expression. Let us see how to parse HTML without regular expression. - [SQL SERVER - sp_HelpText for sp_HelpText - Puzzle](https://blog.sqlauthority.com/2007/06/15/sql-server-sp_helptext-for-sp_helptext-puzzle/): It was interesting to me. I was using sp_HelpText to see the text of the stored procedure. Stored Procedure were different so I had copied sp_HelpText on my clipboard and was pasting it in Query Editor of Management Studio. In rush I typed twice sp_HelpText and hit F5. Result was interesting. What are your guesses? My team mates and few of my readers suggested : SQL Server will be in recursive loop, SQL Server will be not responde, SQL Server will throw an error. Try this: sp_HelpText sp_HelpText Result was as expected. SQL Server did its job and displayed the text... - [SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases - Part 2](https://blog.sqlauthority.com/2007/06/15/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases-part-2/): I have mentioned the history of NorthWind, Pubs and AdventureWorks in my previous post SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases. I have been receiving very frequent request for NorthWind Database for SQL Server 2005 and installation method. - [SQL SERVER - Easy Sequence of SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY](https://blog.sqlauthority.com/2007/06/14/sql-server-easy-sequence-of-select-from-join-where-group-by-having-order-by/): I was called many times by Jr. Programmers in team to debug their SQL. I keep log of most of the problems and review them afterwards. This helps me to evaluate my team and identify most important next thing which I can do to improve the performance and productivity of it. Recently we have many new hires and they had almost similar questions. Since, I have send them following sequence of the SELECT clause I am not interrupted often, which helps me to focus on larger project architectural design. SELECT yourcolumns FROM tablenames JOIN tablenames WHERE condition GROUP BY yourcolumns HAVING... - [SQL SERVER - Explanation SQL SERVER Hash Join](https://blog.sqlauthority.com/2007/06/14/sql-server-explanation-sql-server-hash-join/): Hash Join works with large data set. I have seen this join used many times in data warehouses applications as well as data mining algorithms. While its characteristics are similar to merge join it does not required ordered result set to join. Hash join requiresequijoin predicate to join tables. Equijoin predicate is comparing values between one table to other table using “equals to” (“=”) operator. Hash join gives best performance when two more join tables are joined and at-least one of them have no index or is not sorted. It is also expected that smaller of the either of table can... - [SQL SERVER - Fix : Error 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time.](https://blog.sqlauthority.com/2007/06/13/sql-server-fix-error-8629-the-query-processor-could-not-produce-a-query-plan-from-the-optimizer-because-a-query-cannot-update-a-text-ntext-or-image-column-and-a-clustering-key-at-the-same-time/): Error : 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time. - [SQL SERVER - Download 2005 Books Online (May 2007)](https://blog.sqlauthority.com/2007/06/13/sql-server-download-2005-books-online-may-2007/): Microsoft has merged SQL Server 2005 Expressed to SQL Server 2005 Books Online. New Version of SQL Server 2005 Books Online is released on June 12, 2007. Download SQL Server Books Online (BOL) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recovery Models and Selection](https://blog.sqlauthority.com/2007/06/13/sql-server-recovery-models-and-selection/): SQL Server offers three recovery models: full recovery, simple recovery and bulk-logged recovery. The recovery models determine how much data loss is acceptable and determines whether and how transaction logs can be backed up. Select Simple Recovery Model if: * Your data is not critical. * Losing all transactions since the last full or differential backup is not an issue. * Data is derived from other data sources and is easily recreated. * Data is static and does not change often. Select Bulk-Logged Recovery Model if: * Data is critical, but logging large data loads bogs down the system. * Most... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2007/06/12/sql-server-sql-joke-sql-humor-sql-laugh-funny-quotes/): While searching WIKI I came across this oracle WIKI. I found this very funny. I have taken few quotes from this site. There are lot more stuff there. The degree of normality in a database is inversely proportional to that of its DBA. Program complexity grows until it exceeds the capability of the programmer who must maintain it. “Walking on water and developing software from a specification are easy if both are frozen.” — Edward V. Berard, “Life-Cycle Approaches” “Technology is dominated by two types of people: those who understand what they do not manage, and those who manage what they... - [SQL SERVER - LEN and DATALENGTH of NULL Simple Example](https://blog.sqlauthority.com/2007/06/12/sql-server-len-and-datalength-of-null-simple-example/): Simple but interesting – In recent survey I found that many developers making this generic mistake. I have seen following code in periodic code review. (The code below is not actual code, it is simple sample code) DECLARE @MyVar VARCHAR(10) SET @MyVar = NULL IF (LEN(@MyVar) = 0) … I decided to send following code to them. After running the following sample code it was clear that LEN of NULL values is not 0 (Zero) but it is NULL. Similarly, the result for DATALENGTH function is the same. DATALENGTH of NULL is NULL. Sample Test Version: DECLARE @MyVar VARCHAR(10) SET @MyVar... - [SQL SERVER - Cannot Resolve Collation Conflict For Equal to Operation](https://blog.sqlauthority.com/2007/06/11/sql-server-cannot-resolve-collation-conflict-for-equal-to-operation/): Cannot resolve collation conflict for equal to operation. In MS SQL SERVER, the collation can be set at the column level. - [SQL SERVER - 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) - CTE vs. Derived Table](https://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/): I have received few emails and comments about my post SQL SERVER – T-SQL Paging Query Technique Comparison – SQL 2000 vs SQL 2005. The main question was is this can be done using CTE? Absolutely! What about Performance? It is same! Please refer above mentioned article for history of paging. - [SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice](https://blog.sqlauthority.com/2007/06/10/sql-server-retrieve-select-only-date-part-from-datetime-best-practice/): Just a week ago, my Database Team member asked me what is the best way to only select date part from datetime. When ran following command it also provide the time along with the date. - [SQL SERVER - Fix : Error : An error has occurred while establishing a connect to the server. Solution with Images.](https://blog.sqlauthority.com/2007/06/10/sql-server-fix-error-an-error-has-occurred-while-establishing-a-connect-to-the-server-solution-with-images/): While reviewing my my blog search engine terms I find Error 40 is the most common error searched. I have previously wrote blog about how to fix this error here : SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server. Today I have added few screen shot of that error and their solution to help readers who need additional help to understand my post. Error Screen: Solution Part 1: Enable SQL Server Service Solution Part 2: Enable TCP/IP Protocol Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 9514 Xml data type is not supported in distributed queries. Remote object 'OPENROWSET' has xml column(s)](https://blog.sqlauthority.com/2007/06/09/sql-server-fix-error-msg-9514-level-16-state-1-line-1-xml-data-type-is-not-supported-in-distributed-queries-remote-object-openrowset-has-xml-columns/): In this blog post we are going to learn how to fix XML Data Type related error. - [SQL SERVER - Spatial Database Definition and Research Documents](https://blog.sqlauthority.com/2007/06/09/sql-server-spatial-database-definition-and-research-documents/): Recently I was asked in meeting of SQL SERVER user group, what my opinion about spatial database. I answered from my basic knowledge. Spatial database is like database of space (not the star wars or star trek kind space). SQL Server database can understand the numeric and string values. If we ask to SQL Server what is multiplication of 6 and 3 it will provide answer as 18. If we ask to SQL Server what is distance between two points in polygon, it will be not able to answer using native functions. Custom SQL code written by user can do similar... - [SQL SERVER - UDF - Function to Display Current Week Date and Day - Weekly Calendar](https://blog.sqlauthority.com/2007/06/08/sql-server-udf-function-to-display-current-week-date-and-day-weekly-calendar/): In analytics section of our product I frequently have to display the current week dates with days. Week starts from Sunday. We display the data considering days as column and date and other values in column. If today is Friday June 8, 2007. We need script which can provides days and dates for current week. Following script will generate the required script. DECLARE @day INT DECLARE @today SMALLDATETIME SET @today = CAST(CONVERT(VARCHAR(10), GETDATE(), 101) AS SMALLDATETIME) SET @day = DATEPART(dw, @today) SELECT DATEADD(dd, 1 - @day, @today) Sunday, DATEADD(dd, 2 - @day, @today) Monday, DATEADD(dd, 3 - @day, @today) Tuesday, DATEADD(dd,... - [SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL](https://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/): Update: For SQL Server 2008 there is even better method of Row Construction, please read it here : SQL SERVER – 2008 – Insert Multiple Records Using One Insert Statement – Use of Row Constructor This is very interesting question I have received from new developer. How can I insert multiple values in table using only one insert? Now this is interesting question. When there are multiple records are to be inserted in the table following is the common way using T-SQL. - [SQL SERVER - 2005 Download New Updated Book On Line (BOL)](https://blog.sqlauthority.com/2007/06/07/sql-server-2005-download-new-updated-book-on-line-bol/): Book On Line the primary source for help for many developers has been updated. It now includes the updates till SP2 release. I use book on line for accuracy for my definition and information on this blog. Download Book On Line (Update June 4th, 2007) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 (Katmai) June CTP Released - Improvement Pillars - Diagram](https://blog.sqlauthority.com/2007/06/07/sql-server-2008-katmai-june-ctp-released-improvement-pillars-diagram/): I received quite a few emails in last three days for not mentioning on my blog about SQL Server 2008 (Katmai) CPT June is released. The reason I did not mentioned because I was busy with my mini series SQL SERVER – Database Coding Standards and Guidelines Complete List Download. SQL Server 2008 (Katmai) June CTP (Community Technology Preview) is announced in TechNet 2007 and is available to download. SQL Server 2008 June CTP enables customers to immediately utilize new capabilities that support their mission-critical platform. The chart below explains important improvements coming online with each CTP. Please visit SQL Server... - [SQL SERVER - Fix : Error : Error 15401: Windows NT user or group 'username' not found. Check the name again.](https://blog.sqlauthority.com/2007/06/07/sql-server-fix-error-error-15401-windows-nt-user-or-group-username-not-found-check-the-name-again/): Fix : Error : Error 15401: Windows NT user or group ‘username’ not found. Check the name again. This is quite a famous error and I was asked to write about it by couple of readers. The reason I was not writing about this as the solution of this error is very well explained in Book On Line. All the potential causes and their solutions are explained well here. This post/article should be considered as book mark to solution. Fix/WorkAround/Solution: Refere Microsoft Help and Support : How to troubleshoot error 15401 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Database Coding Standards and Guidelines Complete List Download](https://blog.sqlauthority.com/2007/06/06/sql-server-database-coding-standards-and-guidelines-complete-list-download/): Download SQL SERVER Database Coding Standards and Guidelines Complete List - [SQL SERVER - Database Coding Standards and Guidelines - Part 2](https://blog.sqlauthority.com/2007/06/05/sql-server-database-coding-standards-and-guidelines-part-2/): SQL Server Database Coding Standards and Guidelines - Part 2 - [SQL SERVER - Database Coding Standards and Guidelines - Part 1](https://blog.sqlauthority.com/2007/06/04/sql-server-database-coding-standards-and-guidelines-part-1/): SQL Server Database Coding Standards and Guidelines - Part 1 - [SQL SERVER - Database Coding Standards and Guidelines - Introduction](https://blog.sqlauthority.com/2007/06/03/sql-server-database-coding-standards-and-guidelines-introduction/): I have received many many request to do another series since my series SQL Server Interview Questions and Answers Complete List Download. I have created small series of Coding Standards and Guidelines, as this is the second most request I have received from readers. This document can be extremely long but I have limited to very few pages as it is difficult to follow thousands of the rules. My experience says it is more productive developer and better code if coding standard has important fewer rules than lots of micro rules. - [SQL SERVER - 2005 Explanation and Example - SELF JOIN](https://blog.sqlauthority.com/2007/06/03/sql-server-2005-explanation-and-example-self-join/): A self-join is simply a normal SQL join that joins one table to itself. This is accomplished by using table name aliases to give each instance of the table a separate name. Joining a table to itself can be useful when you want to compare values in a column to other values in the same column. A join in which records from a table are combined with other records from the same table when there are matching values in the joined fields. A self-join can be an inner join or an outer join. A table is joined to itself based upon... - [SQL SERVER - 2005 - Microsoft SQL Server Management Pack for Microsoft Operations Manager 2005 - Download SQL Server MOM 2005](https://blog.sqlauthority.com/2007/06/02/sql-server-2005-microsoft-sql-server-management-pack-for-microsoft-operations-manager-2005-download-sql-server-mom-2005/): The Microsoft SQL Server Management Pack provides both proactive and reactive monitoring of SQL Server 2005 and SQL Server 2000 in an enterprise environment. Availability and configuration monitoring, performance data collection, and default thresholds are built for enterprise-level monitoring. Both local and remote connectivity checks help ensure database availability. Features description are available online. Download SQL Server MOM 2005 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Subscribe to Feed in Email](https://blog.sqlauthority.com/2007/06/02/sqlauthority-news-subscribe-to-feed-in-email/): You can subscribe to SQLAuthority.com Feed using Email. Email will be delivered to your preferred email address when new post appears on SQLAuthority.com Subscribe to SQLAuthority Feed Through Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Dedicated Search Engine for SQLAuthority - Search SQL Solutions](https://blog.sqlauthority.com/2007/06/01/sqlauthority-news-dedicated-search-engine-for-sqlauthority-search-sql-solutions/): Visit search.SQLAuthority.com I have been receiving many questions asking for tutorials, suggestions or questions about topics I already have wrote before but readers are have not found it or having difficulty to find them. I have almost around 200 articles on this blog so far and it is growing. One of the team member in my company keep on asking about search engine specific to SQLAuthority.com. He suggest that he always search in this blog first before he search on web. One of the loyal reader suggests that I should have search facilities in my SQL Interview Questions. I have created... - [SQL SERVER - 2005 Constraint on VARCHAR(MAX) Field To Limit It Certain Length](https://blog.sqlauthority.com/2007/06/01/sql-server-2005-constraint-on-varcharmax-field-to-limit-it-certain-length/): One of the Jr. DBA at in my Team Member asked me question the other day when he was replacing TEXT field with VARCHAR(MAX) : How can I limit the VARCHAR(MAX) field with maximum length of 12500 characters only. His Question was valid as our application was allowing 12500 characters. Traditionally thinking we only create the field as long as we need. SQL Server 2005 does support VARCHAR(MAX) but does not support VARCHAR(12500). If we try to create database field with VARCHAR(12500) it gives following error. Server: Msg 131, Level 15, State 3, Line 1 The size (12500) given to the... - [SQL SERVER - Retrieve Information of SQL Server Agent Jobs](https://blog.sqlauthority.com/2007/05/31/sql-server-retrieve-information-of-sql-server-agent-jobs/): sp_help_job returns information about jobs that are used by SQL Server Agent service to perform automated activities in SQL Server. When executed sp_help_job procedure with no parameters to return the information for all of the jobs currently defined in the msdb database. - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility - Part 2 - Management Studio](https://blog.sqlauthority.com/2007/05/31/sql-server-2005-change-database-compatible-level-backward-compatibility-part-2-management-studio/): I have received quite a few request about post I have two days ago SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility, if this can be done using SQL Server Management Studio. It is very simple to do this using Management Studio as well but I still prefer T-SQL way. Following steps will display the method to change the compatible levels. Write click on database. Click on Properties. Click on Options. Change the Compatibility level to desired compatibility. (See Attached image below) Click OK. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Must Not Contain NULL - Primary Key are NOT NULL](https://blog.sqlauthority.com/2007/05/31/sql-server-primary-key-must-not-contain-null-primary-key-are-not-null/): While reviewing the search engine log for this blog I found lots of search regarding Nullable Primary Key. It is not possible. This post is especially to clear the Not Nullable Primary Key Property. The Allow Nulls property can’t be set on a column that is part of the primary key. All columns that are part of a table’s a primary key must contain aggregate unique values other than NULL. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQLAuthority.com News - Best SQL Job Search - Best SQL Job List - Find SQL Jobs](https://blog.sqlauthority.com/2007/05/30/sqlauthoritycom-news-best-sql-job-search-best-sql-job-list-find-sql-jobs/): SQLAuthority.com News – Best SQL Job Search – Best SQL Job List – Find SQL Jobs Visit : I have been receiving two kind of requests almost every day. 1) Recruiters and Employers asking where can they find good candidates who are truly dedicated to SQL Server? 2) Job seeker asking where can they find only SQL related jobs? There are hundreds of web site which have great resources for all kind of jobs. Monster and Dice are examples of them. Many sites are bit ocean of the jobs and it is hard to find only SQL Jobs from there, many... - [SQL SERVER - Trace Flags - DBCC TRACEON](https://blog.sqlauthority.com/2007/05/30/sql-server-trace-flags-dbcc-traceon/): Trace flags are valuable tools as they allow DBA to enable or disable a database function temporarily. Once a trace flag is turned on, it remains on until either manually turned off or SQL Server restarted. Only users in the sysadmin fixed server role can turn on trace flags. If you want to enable/disable Detailed Deadlock Information (1205), use Query Analyzer and DBCC TRACEON to turn it on. 1205 trace flag sends detailed information about the deadlock to the error log. Enable Trace at current connection level: DBCC TRACEON(1205) Disable Trace: DBCC TRACEOFF(1205) Enable Multiple Trace at same time separating each... - [SQL SERVER - Fix : Error : Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table](https://blog.sqlauthority.com/2007/05/30/sql-server-fix-error-server-msg-544-level-16-state-1-line-1-cannot-insert-explicit-value-for-identity-column-in-table/): Error Message: Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF. This error message appears when you try to insert a value into a column for which the IDENTITY property was declared, but without having set the IDENTITY_INSERT setting for the table to ON. Fix/WorkAround/Solution: /* Turn Identity Insert ON so records can be inserted in the Identity Column  */ SET IDENTITY_INSERT [dbo].[TableName] ON GO INSERT INTO [dbo].[TableName] ( [ID], [Name] ) VALUES ( 2, 'InsertName') GO /* Turn Identity Insert OFF  */ SET IDENTITY_INSERT [dbo].[TableName] OFF GO Setting the IDENTITY_INSERT to ON allows explicit values to be inserted into the identity column of a table. Execute permissions... - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility](https://blog.sqlauthority.com/2007/05/29/sql-server-2005-change-database-compatible-level-backward-compatibility/): sp_dbcmptlevel Sets certain database behaviors to be compatible with the specified version of SQL Server. Example: ----SQL Server 2005 database compatible level to SQL Server 2000 EXEC sp_dbcmptlevel AdventureWorks, 80; GO ----SQL Server 2000 database compatible level to SQL Server 2005 EXEC sp_dbcmptlevel AdventureWorks, 90; GO Version of SQL Server database can be one of the following: 60 = SQL Server 6.0 65 = SQL Server 6.5 70 = SQL Server 7.0 80 = SQL Server 2000 90 = SQL Server 2005 The sp_dbcmptlevel stored procedure affects behaviors only for the specified database, not for the entire server. sp_dbcmptlevel provides only... - [SQL SERVER - Few Notes on Fast Track Data Warehouse](https://blog.sqlauthority.com/2010/09/05/sql-server-few-notes-on-fast-track-data-warehouse/): I recently delivered fast track data warehouse training. This training was very challenging as this training requires very specific hardware and extremely different way of looking at data warehousing. While training I have made few notes and I will now share the same notes with you. Please note that this are just notes and not learning material. Fast Track Data Warehouse has a primary emphasis on eliminating potential performance bottlenecks. It supports maximum of 48 TB data at this moment. Currently HP, Dell, Bull, IBM and EMC2 provides necessary hardware for Fast Track Data Warehouse. All the Software and Hardware comes... - [SQLAuthority News - Social Media Confusion - Twitter, FaceBook, LinkedIn and Me](https://blog.sqlauthority.com/2010/09/04/sqlauthority-news-social-media-confusion-twitter-facebook-linkedin-and-me/): No story today – I am sure all of you know what I want to talk today. I am indeed not happy with how social media is evolving. There was a time when every social media has its own style and concept. Today wherever I go, I see the same thing. Same news, same update and same old thing. I see now a days not much difference between Twitter, FaceBook and LinkedIn. They all have lost their meaning. Here is what I see the use of social media. Twitter: For short update of what exactly you are doing right now. Not... - [SQL SERVER - Soft Delete - IsDelete Column - Your Opinion](https://blog.sqlauthority.com/2010/09/03/sql-server-soft-delete-isdelete-column-your-opinion/): Just a day ago, I was reading the blog post of Michale J Swart. If you are a regular reader of this blog, I am sure you will be familiar with him. He is a very interesting blogger for sure. He recently wrote an article about Ten Things I hate to See in T-SQL; it was really fun, but the thing which caught my eyes was the subject of isDeleted Column. First of all, let me say that I totally agree with his view point. Let me re-produce what Michale exactly suggests. “Deleted records aren’t deleted. Look, they’re right there!” You... - [SQLAuthority News – SQL Server Health Check Service – Speed UP SQL Server](https://blog.sqlauthority.com/2010/09/02/sqlauthority-news-sql-server-health-check-service-speed-up-sql-server/): In my earlier article SQLAuthority News – Training and Consultancy and Travel – Story of Last 30 Days I had mentioned that I prefer to do 50% consultation and 50% training. Since then I often receive what do I do consultation for and what is my expertise. I am basically man of the performance tuning. I love to tune servers and I love to speed up queries. I often get queries what do I do when I go to performance tuning. Here I am listing my complete service descriptions. This whole exercise can be done remotely as well on site. The... - [SQLAuthority News - Fathers and Daughters](https://blog.sqlauthority.com/2010/09/01/sqlauthority-news-fathers-and-daughters/): Today I am very happy as my daughter is one year old. I have no words to explain how lucky I am to be father of daughter. She is everything to me and my wife have (sweet) complain that I stopped paying attention to her since our daughter has arrived. Check out here one year old photographs. There is special bond between fathers and daughters. An year ago here is the comment I have received from Solid Quality Mentors Global CEO Fernando G. Guerrero wrote to me in email. “What a wonderful gift. Someone told me once that if I had... - [SQLAuthority News - A Monthly Roundups of SQLAuthority Blog Posts - Updated 2019](https://blog.sqlauthority.com/2010/08/31/sqlauthority-news-a-monthly-roundups-of-sqlauthority-blog-posts-updated-2019/): Monthly roundups are very refreshing as it gives me a chance to go back and see what did I do last month. Let us learn in this blog post. - [SQLAuthority News - SQL Server Performance Optimization - Seminar Series](https://blog.sqlauthority.com/2010/08/30/sqlauthority-news-sql-server-performance-optimization-seminar-series/): I am very glad that I will be presenting my very first seminar training series worldwide. This event is called the Solid Quality DIRECTIONS Seminar Series. I am very fortunate that I am given this opportunity to work under prestigious organizations. I have been with Solid Quality Mentors for more than a year now. I have learned a lot and I have grown a lot through this group. While working for Solid Quality, I have conducted many training events and various consultations projects. I can say that I have collected and kept with me all the wisdom and knowledge related to... - [SQLAuthority News - Download - SQL Server Monitoring Management Pack](https://blog.sqlauthority.com/2010/08/29/sqlauthority-news-download-sql-server-monitoring-management-pack/): The SQL Server Management Pack provides the capabilities for Operations Manager 2007 SP1 and R2 to discover SQL Server 2005, 2008, and 2008 R2. It monitors SQL Server components such as database engine instances, databases, and SQL Server agents. The monitoring provided by this management pack includes performance, availability, and configuration monitoring, performance data collection, and default thresholds. You can integrate the monitoring of SQL Server components into your service-oriented monitoring scenarios. In addition to health monitoring capabilities, this management pack includes dashboard views, extensive knowledge with embedded inline tasks, and views that enable near real-time diagnosis and resolution of detected... - [SQL SERVER - Plan Cache - Retrieve and Remove - A Simple Script](https://blog.sqlauthority.com/2010/08/28/sql-server-plan-cache-retrieve-and-remove-a-simple-script/): I had a very interesting situation at my recent performance tuning project. I realize that the developers there were running very large dataset queries on their production server randomly. I got alarmed so I suggested their developer not to do that on the production server; instead, they could create some alternate scenarios where they could synchronize database and query on the same server. The production server should not be used for development work. It should be queried with proper methods (queries, Stored Procedures, etc.), supporting production application. - [SQL SERVER - Getting Started with Execution Plans](https://blog.sqlauthority.com/2010/08/27/sql-server-getting-started-with-execution-plans/): Execution Plans is one of the most interesting subjects and I often get a question about it. Many people want to know how to get started. - [SQL SERVER – Adding Column is Expensive by Joining Table Outside View – Limitation of the Views Part 2](https://blog.sqlauthority.com/2010/08/26/sql-server-adding-column-is-expensive-limitation-of-the-views-part-2/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Note: I have updated the title based on feedback of Davide Mauri (Solid Quality Mentors). Thank you for your help. Let’s see another reason why I do not like Views. Regular queries or Stored Procedures give us flexibility when we need another column; we can add a column to regular queries right away. If we want to do the same with Views, we will have to modify them first. This means any query that does... - [SQL SERVER - Does Order of Column in WHERE Clause Matter?](https://blog.sqlauthority.com/2010/08/25/sql-server-deos-order-of-column-in-where-clause-matter/): Today is a quick puzzle time. Let us learn about - Does the order of column used in WHERE clause matter for performance? Let us learn today. - [SQLAuthority News - Download Microsoft SQL Server Migration Assistant](https://blog.sqlauthority.com/2010/08/24/sqlauthority-news-download-microsoft-sql-server-migration-assistant/): SSMA for Oracle v4.2 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from Oracle to SQL Server 2005, SQL Server 2008 or SQL Server 2008 R2. SSMA for Access v4.2 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from Access to SQL Server 2005, SQL Server 2008, SQL Server 2008 R2 and SQL Azure. SSMA for MySQL v1.0 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL... - [SQLAuthority News - Feedback Received for Virtual Tech Days Sessions on Spatial Database](https://blog.sqlauthority.com/2010/08/24/sqlauthority-news-feedback-received-for-virtual-tech-days-sessions-on-spatial-database/): I recently got opportunity to speak at Virtual Tech Days on August 18, 2010 on the subject Spatial Database. The event was heavily attended by enthusiasts world wide. I delivered session the on the subject of Spatial Database and it was great fun to deliver the session. I have delivered similar session many times before but delivering online is always wonderful experience and it is indeed fun. I got the feedback right away from the organizers and it is above the average of data track. Session Name: Developing with SQL Server Spatial and Deep Dive into Spatial Indexing Adj. LM Attendance:... - [SQL SERVER – ORDER BY Does Not Work – Limitation of the Views Part 1](https://blog.sqlauthority.com/2010/08/23/sql-server-order-by-does-not-work-limitation-of-the-views-part-1/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Recently, I was about the limitations of views. I started to make a list and realized that there are many limitations of the views. Let us start with the first well-known limitation. Order By clause does not work in View. I agree with all of you  who say that there is no need of using ORDER BY in the View. ORDER BY should be used outside the View and not in the View. This example is... - [SQL SERVER - Computed Columns - Index and Performance](https://blog.sqlauthority.com/2010/08/22/sql-server-computed-columns-index-and-performance/): This is the last article in the series of the computed columns I have been writing. Here are previous articles. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER – Computed Column – PERSISTED and Performance – Part 2 This article talks about how non-persisted columns give better performance than PERSISTED columns. SQL SERVER – Computed Column and Performance... - [SQL SERVER – Computed Column – PERSISTED and Storage – Part 2](https://blog.sqlauthority.com/2010/08/21/sql-server-computed-column-persisted-and-storage-part-2/): I am really enjoying writing about computed column and its effect in terms of storage. Before I go on with this topic, I suggest you read the earlier articles about computed column to get the complete context. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns.... - [SQL SERVER – Function to Retrieve First Word of Sentence – String Operation](https://blog.sqlauthority.com/2010/08/20/sql-server-function-to-retrieve-first-word-of-sentence-string-operation/): I have sent of function library where I store all the UDF I have ever written. Recently I received email from my friend requesting if I have UDF which manipulate string and returns only very first word of the statement. Well, I realize that I do not have such a script at all. I found myself writing down this similar script after long time. Let me know if you know any other better script to do the same task. DECLARE @StringVar VARCHAR(100) SET @StringVar = ' anything ' SELECT CASE CHARINDEX(' ', LTRIM(@StringVar), 1) WHEN 0 THEN LTRIM(@StringVar) ELSE SUBSTRING(LTRIM(@StringVar), 1,... - [SQL SERVER - Negative Identity Seed Value and Negative Increment Interval](https://blog.sqlauthority.com/2010/08/19/sql-server-negative-identity-seed-value-and-negative-increment-interval/): Let us learn today about Negative Identity Seed Value and Negative Increment Interval. I have also included a video in this blog post. - [SQL SERVER - Download SQL Server 2008 Interview Questions and Answers Complete List](https://blog.sqlauthority.com/2010/08/18/sql-server-download-sql-server-2008-interview-questions-and-answers-complete-list/): I was getting many request to update SQL Server Interview Questions and Answers I had written couple of years ago. I have modified the original document a bit and corrected few of the typos and errors. I have really enjoyed going over all the Interview Questions and Answers. It has been the most popular subject always on this blog. I am in process of updating that with few new questions and answers I have received from industry experts. Please provide your feedback on how we can further improve them or what kind of questions and answers would like to include in... - [SQLAuthority News - Speaking Online at Virtual Techdays - Aug 18, 2010 - Spatial Datatypes](https://blog.sqlauthority.com/2010/08/17/sqlauthority-news-speaking-online-at-virtual-techdays-aug-18-2010-spatial-datatypes/): I am honored that I have been invited to speak at Virtual TechDays on Aug 18, 2010 by Microsoft. I will be speaking on my favorite subject of Spatial Datatypes. This exclusive Online event will have 30 deep technical sessions per day – and, attendance is completely FREE. There are dedicated tracks for Architects, Software  Developers / Project Managers, Infrastructure Managers / Professionals and Enterprise Developers. Register for the event over here. Date and Time : August 18, 2010, 4:15pm – 5:15pm Developing with SQL Server Spatial and Deep Dive into Spatial Indexing Microsoft SQL Server 2008 delivers new spatial data... - [SQL SERVER - Finding the Occurrence of Character in String](https://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/): This article is written in response to provide hint to TSQL Beginners Challenge 14. The challenge is about counting the number of occurrences of characters in the string. Here is quick method how you can count occurrence of character in any string. Here is quick example which provides you two different details. How many times the character/word exists in string? How many total characters exists in Occurrence? Let us see following example and it will clearly explain it to you. DECLARE @LongSentence VARCHAR(MAX) DECLARE @FindSubString VARCHAR(MAX) SET @LongSentence = 'My Super Long String With Long Words' SET @FindSubString = 'long' SELECT... - [SQLAuthority News - Bookmark Link for Sync Framework for SQL Azure](https://blog.sqlauthority.com/2010/08/15/sqlauthority-news-bookmark-link-for-sync-framework-for-sql-azure/): I have been looking for good tutorial for Sync Framework for SQL Server. There was quite a bit demand of the product. I have received quite a few request as well. I finally found good list of the link of Sync Framework. The links are listed below. Introduction to Sync Framework Introduction to Sync Framework Database Synchronization Understanding Scopes Microsoft Sync Framework Power Pack for SQL Azure Walkthrough Microsoft Sync Framework Power Pack for SQL Azure Synchronizing Databases I have found above links from the document Sync Framework for SQL Azure. The document talks about sync framework and also included supplemented... - [SQLAuthority News - Why SQL Server is better than any other RDBMS Applications?](https://blog.sqlauthority.com/2010/08/14/sqlauthority-news-why-sql-server-is-better-than-any-other-rdbms-applications/): Earlier I had announced contest on blog where I gave away two MSDN Subscriptions to person who has provided best comment on the subject of “Why SQL Server is better than any other RDBMS Applications?” I have received tremendous response to the contest. I got many responses, it was extremely difficult to announce the winner and I requested help of two SQL Server MVPs to help me out with the results. Here is the winner of the contest. They really spend good time and wrote about their feeling for SQL Server product. Here is their answers. I strongly suggest that you... - [SQL SERVER – Computed Column and Performance – Part 3](https://blog.sqlauthority.com/2010/08/13/sql-server-computed-column-and-performance-part-3/): I am really enjoying writing about computed column and its effect in terms of performance. Before continuing this article, I suggest you read the earlier articles on the same subject to get the complete context. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER... - [SQL SERVER – SHRINKDATABASE For Every Database in the SQL Server](https://blog.sqlauthority.com/2010/08/12/sql-server-shrinkdatabase-for-every-database-in-the-sql-server/): I was recently called to attend the Query Tuning Project. I had a very interesting experience in this event. I would like to share to you what actually happened. Note: If you are just going to say that shrinking database is bad, I agree with you and that is the main point of this blog post. Please read the whole blog post first. The problem definition of the consultation was to improve the performance of the database server. I usually fly to the client’s location a day before, so the next day I am all fresh upon reaching the client’s office... - [SQLAuthority News - MSDN Subscription Giveaway Announced](https://blog.sqlauthority.com/2010/08/11/sqlauthority-news-msdn-subscription-giveaway-announced/): Last Month received following “NOT FOR SALE” subscription of Microsoft Visual Studio 2010 Ultimate with MSDN. As a MVP, MCT I already have free subscription to MSDN and TechNet. I plan to give away this free subscription to someone who is need of the same or can use it the best. I have already given away two of the subscription to someone who can really use them. In fact, they have reported me where and how they are using the subscription. This gives me great satisfaction. I have announced one subscription for all of you my reader to win. Top SQL... - [SQL SERVER - Best Practices for DBA Before Taking Vacation](https://blog.sqlauthority.com/2010/08/10/sql-server-best-practices-for-dba-before-taking-vacation/): This blog post is written in response to T-SQL Tuesday hosted by Jason Brimhall. Everybody wants to take a vacation. Who does not love vacation, anyway? However, it seems that it has been getting more and more difficult to take vacation recently. There are two reasons why a person is not able to enjoy his vacation. First is due to company policies (bad boss!), and second is your responsibilities. Well, I cannot guide you much about company policy issues simply because I cannot do something about it. I have a wonderful boss and I have been taking many vacations, doing a... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool New v1.2](https://blog.sqlauthority.com/2010/08/09/sqlauthority-news-risk-health-assessment-program-microsoft-sql-server-scoping-tool-new-v1-2/): Risk and Health Assessment Program for Microsoft SQL Server helps reduce business risks associated with downtime, performance bottlenecks, and the complexities of deploying and managing an enterprise-level, data management solution. You can read more about Risk and Health Assessment Program for Microsoft SQL Server in the datasheet over  here. Microsoft has released recently the tool for its Premier Customers. This tool provides all the necessary details to prepare and qualify any environment to receive a risk and health assessment Program for Microsoft SQL Server. You can download Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2 from... - [SQLAuthority News - SQL Server Monitoring Management Pack Download](https://blog.sqlauthority.com/2010/08/09/sqlauthority-news-sql-server-monitoring-management-pack-download/): Microsoft has SQL Server Health monitoring tool, which I have noticed that many of us do not give it a try. Microsoft has released Monitoring management pack download recently and it does plenty of the task, which normally one would like to do. Instead of going for third party tool, I suggest you give it a try. Following text is produced directly from original MSDN page from here. The SQL Server Management Pack provides the capabilities for Operations Manager 2007 SP1 and R2 to discover SQL Server 2005, 2008, and 2008 R2. It monitors SQL Server components such as database engine... - [SQLAuthority News - Microsoft SQL Server 2008 R2 Report Builder 3.0](https://blog.sqlauthority.com/2010/08/08/sqlauthority-news-microsoft-sql-server-2008-r2-report-builder-3-0/): Microsoft has recently released Microsoft SQL Server 2008 R2 Report Builder 3.0. This version is enhancement to earlier versions by adding many new features. It provides an intuitive report authoring environment for business and power users. It supports the full capabilities of SQL Server 2008 R2 Reporting Services. The download provides a stand-alone installer for Report Builder 3.0. Report Builder 3.0 introduces additional visualizations including maps, sparklines and databars which can help produce new insights well beyond what can be achieved with standard tables and charts. The Report Part Gallery is also included in this release – taking self-service reporting to... - [SQLAuthority News – Community Tech Days, Ahmedabad – July 24, 2010](https://blog.sqlauthority.com/2010/08/07/sqlauthority-news-community-tech-days-ahmedabad-july-24-2010/): Community Tech Days are a series of events in my city. Ahmedabad Community is one of the best communities I have ever come across in this world. People are genius, very kind and very patient. They are not shy to ask any questions and I could see their keen desire to learn and absorb new technology. My special thanks to the Community because without them, this event series would not be possible. - [SQL SERVER - Parallelism Query in Database](https://blog.sqlauthority.com/2010/08/06/sql-server-parallelism-query-in-database/): I recently came across two interesting questions asked by Feodor over here. He has asked very interesting questions. Please check them as follows: If I have a dual core computer and I would like to get a query executed with parallelism in order to test it, how would I do that? You can use the AdventureWorks database and let me know if you can get a query to execute in parallel. I am running machine which has 2 different cores. I was able to reproduce the parallel query using following T-SQL Script. USE AdventureWorks GO SELECT * FROM Sales.SalesOrderDetail sod INNER... - [SQLAuthority News – SQL Data Camp, Chennai, July 17, 2010 – A Huge Success](https://blog.sqlauthority.com/2010/08/05/sqlauthority-news-sql-data-camp-chennai-july-17-2010-a-huge-success/): I had great pleasure to attend very first SQL Data Camp at Chennai on July 17, 2010. This event was very unique as this was very first one-day SQL Event in whole Indian Subcontinent. The event was blast as there were so many back–to-back SQL Sessions with SQL Server MVPs. I was fortunate to present two different sessions at the SQL Data Camp in Chennai. I must express my special thanks to event organizers Sugesh, Deepak and Vidyasagar for organizing such a wonderful event. Every participant who was attending the event had a great time and expressed their passion for SQL... - [SQL SERVER - Computed Column - PERSISTED and Performance - Part 2](https://blog.sqlauthority.com/2010/08/04/sql-server-computed-column-persisted-and-performance-part-2/): This is the third article in the series which I am writing on Persisted Columns. I suggest you read following two article first before continuing on this article. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER – Computed Column – PERSISTED and Performance... - [SQL SERVER - Computed Column - PERSISTED and Performance](https://blog.sqlauthority.com/2010/08/03/sql-server-computed-column-persisted-and-performance/): This is the list of the all the articles in the series of computed column. - [SQLAuthority News - T-SQL Challenges and Hints and Suggestions](https://blog.sqlauthority.com/2010/08/02/sqlauthority-news-t-sql-challenges-and-hints-and-suggestions/): Those who read my blog are for sure know my very good friend Jacob Sebastian. He is SQL Server MVP and founder of wonderful site T-SQL Challenges. No matter how expert we are, challenges are made to make us think and try to go to next level. There are certain people who writes always challenging code, however there are many who are yet not expert but the passion of T-SQL is on them. Jacob has many wonderful ideas and T-SQL challenge is his contribution to community, where he helps community to think, help them to mentor and help them to become one better coder. - [SQL SERVER – Introduction to BINARY_CHECKSUM and Working Example](https://blog.sqlauthority.com/2010/08/01/sql-server-introduction-to-binary_checksum-and-working-example/): In one of the recent consultancy, I was asked if I can give working example of BINARY_CHECKSUM. This is usually used to detect changes in a row. If any row has any value changed, this function can be used to figure out if the values are changed in the rows. However, if the row is changed from A to B and once again changed back to A, the BINARY_CHECKSUM cannot be used to detect the changes. Let us see quick example of the of same. Following example is modified from the original example taken from BOL. USE AdventureWorks; GO -- Create... - [SQLAuthority News - A Monthly Round Up of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/07/31/sqlauthority-news-a-monthly-round-up-of-sqlauthority-blog-posts-2/): This month was very interesting month for me. I visited 2 different countries – Malaysia and Sri Lanka. I had great time attending 3 community sessions – Chennai, Kuala Lumpur and Ahmedabad. Though, I was at home only 5 nights, I was fortunate enough to spend good amount of the time with family as well. My family traveled along with me to different countries as well few of my business trips.I also have few good news in this week. SQLAuthority News – I am a MVP and I Love SQL Server SQLAuthority News – I am Microsoft Certified Trainer (MCT) SQLAuthority... - [SQL Tips - 5 SQL Server Best Practices](https://blog.sqlauthority.com/2010/07/30/sqlauthority-news-authors-birthday-5-sql-server-best-practices/): In this blog post we will see 5 SQL Server Best Practices. Backup Master. I am going to have a backup of the database using script; however, the backup script has not been updated for a long time now. - [SQL SERVER - Check Advanced Server Configuration](https://blog.sqlauthority.com/2010/07/29/sql-server-check-advanced-server-configuration/): I was recently asked following question about how to Check Advanced Server Configuration. - [SQLAuthority News - 2 Sessions at TechInsight 2010 - June 29 - July 1, 2010](https://blog.sqlauthority.com/2010/07/28/sqlauthority-news-2-sessions-at-techinsight-2010-june-29-july-1-2010/): Earlier this month, I got the opportunity to visit Malaysia for community sessions on June 29 – July 1, 2010 at Kuala Lumpur, Malaysia, which I would consider as valuable experience. I presented two different sessions at the event. The event was extremely popular in local community, and I had great time meeting people in Malaysia. I must say that the best thing about Kuala Lumpur is the people and their response. Techinsights is a major technology conference to network with like-minded peers and also up-skill your knowledge on latest technologies. An event that offers opportunity to dabble in hardcore technologies... - [SQL SERVER - Computed Column - PERSISTED and Storage](https://blog.sqlauthority.com/2010/07/27/sql-server-computed-column-persisted-and-storage/): This is the list of the all the articles in the series of computed column. - [SQL SERVER – FIX: ERROR: 8170 Insufficient result space to convert uniqueidentifier value to char](https://blog.sqlauthority.com/2010/07/26/sql-server-fix-error-8170-insufficient-result-space-to-convert-uniqueidentifier-value-to-char/): I just came across very simple error and the solution was even simpler. While concatenating NEWID to another varchar string, I had to CONVERT/CAST it to VARCHAR and I accidentally put length of VARCHAR to 10 instead of 36. It displayed following error. Msg 8170, Level 16, State 2, Line 1 Insufficient result space to convert uniqueidentifier value to char. - [SQLAuthority News - Last 2 Day to Win MSDN Subscription - Total 2 to Win](https://blog.sqlauthority.com/2010/07/25/sqlauthority-news-last-2-day-to-win-msdn-subscription-total-2-to-win/): Today is the last day to win MSDN subscription on this blog. SQL Server MVP Madhivanan is known name. As there are more than 150 comments, I had requested him to help me out with deciding the winner. After looking at the quality responses, he has for sure accepted to hep me out with the deciding the winner but also added one more subscription from his side. This leads to total 2 of the subscription to win. Today is the last day to participate in the content. However, as we have added one more subscription on very last day, we have... - [SQLAuthority News - The story of the world - Spatial Data types - July 24, 2010](https://blog.sqlauthority.com/2010/07/24/sqlauthority-news-the-story-of-the-world-spatial-data-types-july-24-2010/): Today I will be speaking on the subject of Spatial Database at Community Tech Days at Ahmedabad. The event is absolutely FREE. We have so far received 500+ RSVP but there are only limited 250 seats are available. We are doing our best to inform everybody about their registration status. If you have received confirmation email, I suggest that you come in early enough to reserve the place. - [SQL SERVER - Find Queries using Parallelism from Cached Plan](https://blog.sqlauthority.com/2010/07/24/sql-server-find-queries-using-parallelism-from-cached-plan/): I recently came across wonderful blog post of Feodor Georgiev. He is one fine developer and like to dwell in the subject of performance tuning and query optimizations. He is one real genius and original blogger. Recently I came across his wonderful script, which I was in fact writing myself and I found out that he has already posted the same query over here. After getting his permission I am reproducing the same query on this blog. Note to not run the following script on busy transactional production environment as well, it does not get all historical results as it only... - [SQLAuthority News - Funny Technology Quotes - Humor](https://blog.sqlauthority.com/2010/07/23/sqlauthority-news-guest-post-walkthrough-on-creating-wcf-data-service-odata-and-consuming-in-windows-7-mobile-application/): I am including a few of the interesting quotes today. Let us see Funny Technology Quotes. Here are few interesting new lessons. - [SQLAuthority News - SolidQ Journal Released - A Must Read for All](https://blog.sqlauthority.com/2010/07/22/sqlauthority-news-solidq-journal-released-a-must-read-for-all/): SQL Server is one of the most popular products of Microsoft and a large amount of quality content is available online. Solid Quality Mentors have together built a superior quality journal, which contains the best of the best authentic articles from renowned experts of SQL Server. When I downloaded SolidQ Journal, the very first feeling I got was like that of old days of reading technology magazines online. Very soon, I was busy reading the articles one by one and did not realize that I spend nearly 3 hours on single sitting reading the entire journal. After reading it completely, I... - [SQL SERVER - Win USD 11,899 worth MSDN Subscription 5 Days to go](https://blog.sqlauthority.com/2010/07/21/sql-server-win-usd-11899-worth-msdn-subscription-5-days-to-go/): Few days ago, I had posted content SQLAuthority News – FREE Microsoft Visual Studio 2010 Ultimate with MSDN. It has received tremendous response to them. This competition is still open for 5 more days. I am sure you can win the subscription if you leave the best comment. Win $ 11,899 worth Price You need to answer one simple question: You need to answer one simple question: Why SQL Server is better than any other RDBMS applications? Please do not leave comments in this thread, leave at original thread over here. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SELECT * FROM dual - Dual Equivalent](https://blog.sqlauthority.com/2010/07/20/sql-server-select-from-dual-dual-equivalent/): This blog post is for all the Oracle developers who keep on asking for the lack of “dual” table in SQL Server. Here is a quick note about DUAL table, in an easy question-and-answer format. What is DUAL in Oracle? Dual is a table that is created by Oracle together with data dictionary. It consists of exactly one column named “dummy”, and one record. The value of that record is X. You can check the content of the DUAL table using the following syntax. SELECT * FROM dual It will return only one record with the value ‘X’. What is the... - [SQL SERVER - Identifying Statistics Used by Query](https://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/): “Can I know which statistics were used by my query?” Recently, someone asked this question in my training class of query optimization and performance tuning. I really liked the question. The answer for me is very simple. “No.” Well, if I stop here suggesting only “No,” it will be an incomplete answer. Let us continue a bit more. There is no direct method or DVM or any tool which can tell us which statistics were used by any query. In fact, it looks like there is no way one can know if the any created statistics was ever used or not.... - [SQLAuthority News - SQL Server Quickstart Downloads from Microsoft](https://blog.sqlauthority.com/2010/07/18/sqlauthority-news-sql-server-quickstart-downloads-from-microsoft/): Here are few recent published by Microsoft. Application Platform Optimization SQL Server Migration QuickStart The SQL Server Migration QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to help you get details about how to approach your customers who want to improve the return on investment from their data platforms by migrating to SQL Server from their existing Oracle or Sybase platforms. Application Platform Optimization SQL Server Consolidation QuickStart The SQL Server Consolidation QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to present to customers who... - [SQLAuthority News - Community TechDays, Ahmedabad - July 24, 2010](https://blog.sqlauthority.com/2010/07/17/sqlauthority-news-community-techdays-ahmedabad-july-24-2010/): Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Build real connections with Microsoft experts and community members, and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. What more… you can watch some of these sessions LIVE online from the comfort of your workstation as well. The event registration site is here. I will be speaking on the subject. SQL Server – The story of the world – Spatial Data types Speaker: Pinal Dave Event Date: 24th July 2010 Session Time:... - [SQL SERVER - Datetime Function TODATETIMEOFFSET Example](https://blog.sqlauthority.com/2010/07/16/sql-server-datetime-function-todatetimeoffset-example/): Earlier I wrote about SQL SERVER – Datetime Function SWITCHOFFSET Example. After reading this blog post, I got another quick reply that if I can explain the usage of TODATETIMEOFFSET as well. - [SQL SERVER - Datetime Function SWITCHOFFSET Example](https://blog.sqlauthority.com/2010/07/15/sql-server-datetime-function-switchoffset-example/): I was recently asked if I know how SWITCHOFFSET works. This feature only works in SQL Server 2008. Here is quick definition of the same from BOL: Returns a datetimeoffset value that is changed from the stored time zone offset to a specified new time zone offset. What essentially it does is that changes the current offset of the time to any other offset which we defined. Let us see the example of the same. SELECT SYSDATETIMEOFFSET() GetCurrentOffSet; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '-04:00') 'GetCurrentOffSet-4'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '-02:00') 'GetCurrentOffSet-2'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+00:00') 'GetCurrentOffSet+0'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+02:00') 'GetCurrentOffSet+2'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+04:00') 'GetCurrentOffSet+4'; Now let us... - [SQLAuthority News - Two SQL Sessions at SQL Data Camp at Chennai - July 17, 2010](https://blog.sqlauthority.com/2010/07/14/sqlauthority-news-two-sql-sessions-at-sql-data-camp-at-chennai-july-17-2010/): I will be presenting two SQL Server advance level sessions at SQL Data Camp @ Chennai. I am very excited for this event as I am going to meet my friends Sugesh, Deepak, Vidhya and Madhivanan at this event. All of them are SQL Server MVPs. I have come to know that there are two other SQL Server MVPs – Madhu andVenkatesh are also joining the event as speaker. This is going to be one mega fest as so many of SQL Server MVPs are going to be present at same place. The event is going to be world-class event and... - [SQL SERVER - How do I Learn and How do I Teach](https://blog.sqlauthority.com/2010/07/13/sql-server-how-do-i-learn-and-how-do-i-teach/): This blog post is written in response to T-SQL Tuesday hosted by Robert L Davis (aka SQLSoldier). The blog post has raised three very interesting questions. How do you learn? How do you teach? What are you learning or teaching? Let me try to answer the same. How do I learn? This question is very interesting. I have written a blog post on the very same subject few days ago when I completed my 1400th blog post. Learning is a continuous process and it never ends. There are many different ways through which one can learn. Looking back, when I was... - [SQLAuthority News - FREE Microsoft Visual Studio 2010 Ultimate with MSDN](https://blog.sqlauthority.com/2010/07/12/sqlauthority-news-free-microsoft-visual-studio-2010-ultimate-with-msdn/): I just received following “NOT FOR SALE” subscription of Microsoft Visual Studio 2010 Ultimate with MSDN. As a MVP, MCT I already have free subscription to MSDN and TechNet. I plan to give away this free subscription to someone who is need of the same or can use it the best. You can win the subscription. I will pick the winner of the subscription on 25th of the July. Which means you have 10 days to take part. I will decide the winner with the help of fellow MVPs and subject matter experts. You need to answer one simple question: Why... - [SQL SERVER - Parallelism - Row per Processor - Row per Thread - Thread 0](https://blog.sqlauthority.com/2010/07/11/sql-server-parallelism-row-per-processor-row-per-thread-thread-0/): Earlier I had posted article answering question. “When SQL Server executes any query on multiple processors, do all processors process equal numbers of rows?” Read the answer over SQL SERVER – Parallelism – Row per Processor – Row per Thread. In the same article, I had asked back to readers as well. “If you look carefully in the Properties window or XML Plan, there is “Thread 0″. What does this “Thread 0” indicate?” Here is the answer of the question, many thanks to all of you and special mention to Marko Parkkola, who has answered first and the answer is very detailed.... - [SQLAuthority News - Milestone - 1400th Post and Why do I blog](https://blog.sqlauthority.com/2010/07/10/sqlauthority-news-milestone-1400th-post-and-why-do-i-blog/): I am very glad today that I have reached milestone of 1400th post. I was looking back to my journey which I started on Nov 1, 2006 and I feel that it has been long way. I have noticed a lot of changes in myself too. Earlier, I used to write a milestone post every time I reach either 1 million views or when I am writing the 100th post. I noticed that such “milestones” started happening quite often; so I decided to write about such milestones on every 100th post. Well, this limited the number of such milestone posts to... - [SQLAuthority News - I am a MVP and I Love SQL Server](https://blog.sqlauthority.com/2010/07/09/sqlauthority-news-i-am-a-mvp-and-i-love-sql-server/): I am very glad that I received this prestigious award for the third time in a row. I am very thankful to Microsoft for introducing this wonderful technology of SQL Server. I enjoy getting involved with the community, which also helps in my self-improvement as well. I would like to take this moment to thank all my friends, readers, session attendees, MS Product Teams, MVP Program and my Organization for the constant support and encouragement. There are few questions that I often receive about the MVP program. Today, I will answer them in brief. Microsoft MVP Logo Question: How can I become a... - [SQL SERVER - The Self Join - Inner Join and Outer Join ](https://blog.sqlauthority.com/2010/07/08/sql-server-the-self-join-inner-join-and-outer-join/): Self Join has always been an note-worthy case. It is interesting to ask questions on self join in a room full of developers. I often ask – if there are three kind of joins, i.e.- Inner Join, Outer Join and Cross Join; what type of join is Self Join? The usual answer is that it is an Inner Join. In fact, it can be classified under any type of join. I have previously written about this in my interview questions and answers series. I have also mentioned this subject when I explained the joins in detail over SQL SERVER – Introduction... - [SQL SERVER - Upper Case Shortcut SQL Server Management Studio](https://blog.sqlauthority.com/2010/07/07/sql-server-upper-case-shortcut-sql-server-management-studio/): Few days ago, I received code which is very similar to code shown below. select * from Sales.SalesOrderDetail where ProductID > 777 I am not the guy who go crazy for formatting but I do appreciate proper coding. I like if the code was formatted like below. SELECT * FROM Sales.SalesOrderDetail WHERE ProductID > 777 The fastest way one can do this in SSMS is either search and replace or using SSMS short cut to covert keywords to upper case. What I do is I select the word and hit CTRL+SHIFT+U and it SSMS immediately changes the case of the selected... - [SQLAuthority News - I am Microsoft Certified Trainer (MCT) ](https://blog.sqlauthority.com/2010/07/06/sqlauthority-news-i-am-microsoft-certified-trainer-mct/): I am a Microsoft Certified Trainer and I am very much proud of it. Because I am a MCT, I have the support of great community leaders and trainers who help me constantly to improve in what I do. I have many Microsoft Certifications and I constantly try to take more of these. Every time, a new certification is announced, I make sure to add it to my list of existing ones. This post is written to make the community aware that how sometimes strict bureaucracy guidelines can create issues and a very well-confirmed project can crash. Those who know me... - [SQL SERVER – PowerShell Version Info](https://blog.sqlauthority.com/2010/07/05/sql-server-powershell-version-info/): I have multiple computer systems at home. I have previously taken a picture of my home office and published it here. Also, I recently had a scenario where I was listing a PowerShell version installed in my computer systems. While searching online, I found two different commands that can determine the version of PowerShell. One of them worked fine in Version 1, while both worked on Version 2. The commands are: $PSVersionTable and $host I have run both the commands on different PowerShell versions and found the following output. This is a call to all PowerShell experts to help me out... - [SQL SERVER - Index Levels, Page Count, Record Count and DMV - sys.dm_db_index_physical_stats](https://blog.sqlauthority.com/2010/07/04/sql-server-index-levels-page-count-record-count-and-dmv-%c2%a0sys-dm_db_index_physical_stats/): In the recent Query Tuning project, one of the developers who were helping me out in the project asked me if there is any way that he could know how many pages are used by any Index,  and if there is any way I could demonstrate the different levels of B-Tree. The following is the diagram on Clustered Index that I have quickly drawn using MS Word for the said developer. Clustered Index B-Tree Let us quickly see the diagram of B-Tree and how the levels are set up. The leaf level is always considered as Level 0. There can be... - [SQL SERVER - View XML Query Plans in SSMS as Graphical Execution Plan](https://blog.sqlauthority.com/2010/07/03/sql-server-view-xml-query-plans-in-ssms-as-graphical-execution-plan/): Earlier I wrote a blog post on SQL SERVER – Parallelism – Row per Processor – Row per Thread, where I mentioned the XML Plan. As a follow up on the blog post, I received the request to send the same execution plan so that the blog readers can also use the same and reproduce it on their machine. I realized that I have actually never written on how one can send a graphical execution plan to another user so that they can reproduce the same exact details without all the actual tables, indexes and objects. Here is very simple method... - [SQL SERVER - Parallelism - Row per Processor - Row per Thread](https://blog.sqlauthority.com/2010/07/02/sql-server-parallelism-row-per-processor-row-per-thread/): Here is a question I received via email: “When SQL Server executes any query on multiple processors, do all processors process equal numbers of rows?” I find this one very interesting. I quickly wrote down a query which can run on multiple CPU in my machine. My laptop has a Core 2 Duo processor and has two CPUs. When I ran the query, I found out from the execution plan that there is a parallelism operator, which runs my query in both CPUs. I pressed F4 to see the Properties of the execution plan. You can open the Properties window by... - [SQL SERVER - Introduction to Best Practices Analyzer - Quick Tutorial](https://blog.sqlauthority.com/2010/07/01/sql-server-introduction-to-best-practices-analyzer-quick-tutorial/): I previously wrote about SQLAuthority News – Download – Microsoft SQL Server 2008 R2 Best Practices Analyzer earlier and since then I have received many emails requesting to explain how it works. I assume that you can download and install the tool successfully. Once done just follow the steps listed below. You will be successfully able to test multiple instances of SQL Server using this tool. Once the tool is launched, select the product you wish to analysis. Click on Start Scan will take few minutes to analysis the server. Select the appropriate features to include the analysis in report. I... - [SQLAuthority News - A Monthly Round Up of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/06/30/sqlauthority-news-a-monthly-round-up-of-sqlauthority-blog-posts/): Last month I wrote monthly round up and I was very well received. For the same here it goes this months wrote up for all the SQLAuthority.com blogs. The month started very interesting subject of SQL SERVER – Precision of SMALLDATETIME – A 1 Minute Precision which lead to few datetime related blog posts. I find them very interesting and hopefully you will too. SQL SERVER – Difference Between GETDATE and SYSDATETIME SQL SERVER – Difference Between DATETIME and DATETIME2 SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE Another interesting blog post series was on the subject how SQL... - [SQL SERVER - Outer Join Not Allowed in Indexed Views](https://blog.sqlauthority.com/2010/06/29/sql-server-outer-join-not-allowed-in-indexed-views/): I recently received an email that contains a question from one of my readers. I have already replied the answer to his email, but I would still like to bring it to your attention and ask if you think I could have done any better with the example I gave. The question was raised when the email sender read the white paper, Improving Performance with SQL Server 2008 Indexed Views. If you scroll all the way down through the said white paper, there are several questions and answers. Q: Why can’t I use OUTER JOIN in an Indexed view? A: Rows... - [SQLAuthority News - Exam 70-433 - MCTS - Microsoft SQL Server 2008, Database Development](https://blog.sqlauthority.com/2010/06/29/sqlauthority-news-exam-70-433-mcts-microsoft-sql-server-2008-database-development/): I often receive lots of questions regarding how to pass SQL Server Certification exams. I have previously written about the road map over SQL SERVER – Roadmap of Microsoft Certifications – SQL Server Certifications. I have tremendous respect for Microsoft Certification and I enjoy the preparation phase as well as attending the real exam. The real value is after passing the exams as I am always sure that during the whole process, I have learned something new and my knowledge has been updated. Prometric Testing Center Experience: I had a Prometric voucher for one free exam, which was expiring on June... - [SQL SERVER - Default Statistics on Column - Automatic Statistics on Column](https://blog.sqlauthority.com/2010/06/28/sql-server-default-statistics-on-column-automatic-statistics-on-column/): During the SQL Server Training, I frequently noticed confusion in people in terms of Statistics. Many people have no idea on how Statistics works. There are so many misconceptions with respect to Statistics. I recently had an interesting conversation with one attendee who believed that Statistics only exists on Column if there is an Index on the Column, or if we explicitly create Statistics on it. - [SQLAuthority News – Announcing Winners of the Office 2010 Giveaway](https://blog.sqlauthority.com/2010/06/27/sqlauthority-news-announcing-winners-of-the-office-2010-giveaway/): Thank you all for participating in Office 2010 giveaway. After carefully evaluation following user is announced as the winner. The question was as following. Choose best option: With which Microsoft Office Product Powerpivot is associated? Options: 1) PowerPoint 2) Excel 3) Word The answer was suppose to be most creative and informative. Many congratulations to the winner of the Office Giveaway. Winning comment by Sagar. PowerPivot refers to a collection of applications and services that provide an end-to-end solution for creating and sharing business intelligence using Excel and SharePoint. As SharePoint is not the option answer is ‘EXCEL’. PowerPivot for Excel... - [SQL SERVER - Fast Track Data Warehouse for SQL Server 2008](https://blog.sqlauthority.com/2010/06/26/sql-server-fast-track-data-warehouse-for-sql-server-2008/): I recently attended a wonderful training session organized by Microsoft on Fast Track Data Warehouse Reference Architectures. If you are regular reader of my blog, you will be well aware of the fact that I am more of the Relational guy than a Business Intelligence professional. I was initially a bit skeptic about this training. However, once I start learning about it, to my surprise, I thought that I am the perfect guy to learn this. In fact, I realized that few of the tricks which this course is suggesting have already been implemented in my earlier consulting assignments. Fast Track... - [SQLAuthority News – Download – Microsoft SQL Server 2008 R2 Best Practices Analyzer](https://blog.sqlauthority.com/2010/06/25/sqlauthority-news-download-microsoft-sql-server-2008-r2-best-practices-analyzer/): Microsoft has released wonderful tool SQL Server 2008 R2 Best Practices Analyzer. I have previously used this tool and found it quite helpful. Here is the latest version which you can download from MS site. Microsoft SQL Server 2008 R2 Best Practices Analyzer However, I received quite a few emails that users are not able to install it after downloading this tool. There is nothing wrong with this tool but there are two prerequisites which are needed. I am additionally listing the download link to all of them here with. Microsoft Baseline Configuration Analyzer 2.0 Microsoft PowerShell 2.0 Reference: Pinal Dave... - [SQLAuthority News – Meeting Bryan Oliver and Learning Wisdom of Life](https://blog.sqlauthority.com/2010/06/24/sqlauthority-news-meeting-bryan-oliver-and-learning-wisdom-of-life/): During my most recent travel outside India, I was fortunate enough to meet Bryan Oliver. I have heard a lot about him but never had chance to meet him in person. Just like we all do for someone we never met before, I had already some preconceived notions about him. I assumed that he might be someone who will be quite proud about his knowledge with 20+ years of experience in the industry. I was also not expecting a very friendly approach as he was quite older than me. I am sure by now that all of you might have guessed... - [SQLAuthority News - Guest Post - SELECT * FROM XML - Jacob Sebastian](https://blog.sqlauthority.com/2010/06/23/sqlauthority-news-guest-post-select-from-xml-jacob-sebastian/): One of the most common problem SQL Server developers face while dealing with XML is related to writing the correct XPath expression to read a specific value from an XML document. I usually get a lot of questions by email, on my blog or in the forums which looks like the following: - [SQLAuthority News - Price List - Oracle vs SQL Server](https://blog.sqlauthority.com/2010/06/22/sqlauthority-news-price-list-oracle-vs-sql-server/): During one of the consulting project, I was asked to prove that the SQL Server is a more economical choice than Oracle. Well, I do not want to start again the battle, which has been clearly won by SQL Server. Summary: SQL Server is a feature-rich and economical choice compared to Oracle. The base product of Oracle is expensive and to add all the features that are offered by the SQL Server, it requires many more different add-ons. These extra add-ons further increase the price to make SQL Server much more affordable than Oracle, which is ridiculously expensive. I suggest that... - [SQL SERVER - TRANSACTION, DML and Schema Locks](https://blog.sqlauthority.com/2010/06/21/sql-server-transaction-dml-and%c2%a0schema%c2%a0locks/): Today we will be going over a simple but interesting concept. Many a time, I have come across the lack of understanding on how the transactions work in SQL Server. Today we will go over a small but interesting observation. One of my clients had recently invited me to help them out with an interview for their senior developers. I had interviewed nearly 50+ candidates in a single day. There were many different questions, but the following question was incorrectly answered most of the time. The question was to create a scenario where you can see the SCHEMA LOCK. The interview... - [SQL SERVER - Free Download - SQL Server 2008 R2 Update for Developers Training Kit](https://blog.sqlauthority.com/2010/06/20/sql-server-free-download-sql-server-2008-r2-update-for-developers-training-kit/): SQL Server 2008 R2 is released and have been a stable product since the day it is released. I have not received any complains or rants from any of my customers who has upgraded to this version. The number one request is how one can learn about the new features of SQL Server or how one can get going in using SQL Server 2008. Microsoft has released SQL Server 2008 R2 Developers Training Kit. This is awesome kit and I just suggest to have a look at the content one time. Here is what MS say for this kit: SQL Server... - [SQLAuthority News - Delivering Two SQL Sessions at SQL Data Camp at Chennai - July 17, 2010](https://blog.sqlauthority.com/2010/06/19/sqlauthority-news-delivering-two-sql-sessions-at-sql-data-camp-at-chennai-july-17-2010/): SQL Server Community is very strong community world-wide. In India SQL is considered as one of the most popular technology. Chennai is the only city in India where there are more than 3 SQL Server MVPs are from. My MVP friends has arranged one of the very first whole day SQL event in India at Chennai. At this event all the speakers are MVPs as well there will be more than 6 SQL Server MVP present at this single event. You can register for this event by going to the site and clicking on link Register. I am very much looking... - [SQLAuthority News - Interview with SQL Server MVP Madhivanan - A Real Problem Solver](https://blog.sqlauthority.com/2010/06/18/sqlauthority-news-interview-with-sql-server-mvp-madhivanan-a-real-problem-solver/): Madhivanan (SQL Server MVP) is a real community hero. He is known for his two skills – 1) Help Community and 2) Help Community. I have met him many times and every time I feel if anybody in online world needs help Madhivanan does his best to reach them out and solve problem. His name is not new if you are reading this blog or have ever asked a question in any online SQL forum. He is always there to help. When Madhivanan has time he even helps people on this blog as well. He spends his valuable time to help... - [SQL SERVER - Data Pages in Buffer Pool - Data Stored in Memory Cache](https://blog.sqlauthority.com/2010/06/17/sql-server-data-pages-in-buffer-pool-data-stored-in-memory-cache/): This will drop all the clean buffers so we will be able to start again from there. Now, run the following script and check the execution plan of the query. Have you ever wondered what types of data are there in your cache? During SQL Server Trainings, I am usually asked if there is any way one can know how much data in a table is stored in the memory cache? The more detailed question I usually get is if there are multiple indexes on table (and used in a query), were the data of the single table stored multiple times... - [SQL SERVER - Find Largest Supported DML Operation - Question to You](https://blog.sqlauthority.com/2010/06/16/sql-server-find-largest-supported-dml-operation-question-to-you/): SQL Server is very big and it is not possible to know everything in SQL Server but we all keep learning. Recently I was going over the best practices of transactions log and I come across following statement. The log size must be at least twice the size of largest supported DML operation (using uncompressed data volumes). First of all I totally agree with this statement. However, here is my question – How do we measure the size of the largest supported DML operation? I welcome all the opinion and suggestions. I will combine the list and will share that with... - [SQL SERVER - Shrinking Database NDF and MDF Files](https://blog.sqlauthority.com/2010/06/15/sql-server-shrinking-ndf-and-mdf-files-readers-opinion/): Previously, I had written a blog post about SQL SERVER. I am posting this blog post here about Shrinking Database. - [SQLAuthority News - Author Visit - SQL Server 2008 R2 Launch](https://blog.sqlauthority.com/2010/06/14/sqlauthority-news-author-visit-sql-server-2008-r2-launch/): June 11, 2010 was a wonderful day because I attended the very first SQL Server 2008 R2 Launch event held by Microsoft at Mumbai. I traveled to Mumbai from my home town, Ahmedabad. The event was located at one of the best hotels in Mumbai,”The Leela”. SQL Server R2 Launch was an evening event that had a few interesting talks. SQL PASS is associated with this event as one of the partners and its goal is to increase the awareness of the Community about SQL Server. I met many interesting people and had a great networking opportunity at the event. This... - [SQL SERVER - What is Denali?](https://blog.sqlauthority.com/2010/06/13/sql-server-what-is-denali/): I see following question quite common on Twitter or in my email box. “What is Denali?” Denali is code name of SQL Server 2011. Here is the list of the code name of other versions of SQL Server. In 1988, Microsoft released its first version of SQL Server. It was developed jointly by Microsoft and Sybase for the OS/2 platform. 1993 – SQL Server 4.21 for Windows NT 1995 – SQL Server 6.0, codenamed SQL95 1996 – SQL Server 6.5, codenamed Hydra 1999 – SQL Server 7.0, codenamed Sphinx 1999 – SQL Server 7.0 OLAP, codenamed Plato 2000 – SQL Server... - [SQL SERVER - Difference Between DATETIME and DATETIME2 - WITH GETDATE](https://blog.sqlauthority.com/2010/06/12/sql-server-difference-between-datetime-and-datetime2-with-getdate/): Earlier I wrote blog post SQL SERVER – Difference Between GETDATE and SYSDATETIME which inspired me to write SQL SERVER – Difference Between DATETIME and DATETIME2. Now earlier two blog post inspired me to write this blog post (and 4 emails and 3 reads from readers). I previously populated DATETIME and DATETIME2 field with SYSDATETIME, which gave me very different behavior as SYSDATETIME was rounded up/down for the DATETIME datatype. I just ran the same experiment but instead of populating SYSDATETIME in this script I will be using GETDATE function. DECLARE @Intveral INT SET @Intveral = 10000 CREATE TABLE #TimeTable (FirstDate DATETIME, LastDate DATETIME2)... - [SQL SERVER - Difference Between DATETIME and DATETIME2](https://blog.sqlauthority.com/2010/06/11/sql-server-difference-between-datetime-and-datetime2/): Yesterday I have written a very quick blog post on SQL SERVER – Difference Between GETDATE and SYSDATETIME and I got tremendous response for the same. I suggest you read that blog post before continuing with this blog post today. I had asked people to honestly take part and share their view about the above two system functions. There are few emails as well as few comments on the blog post asking a question on how did I come to know the difference between the same. The answer is from real world issues. I was called in for performance tuning consultancy,... - [SQL SERVER - Difference Between GETDATE and SYSDATETIME](https://blog.sqlauthority.com/2010/06/10/sql-server-difference-between-getdate-and-sysdatetime/): Sometime something so simple skips our mind. I never knew the difference between GETDATE and SYSDATETIME. I just ran simple query as following and realized the difference. SELECT GETDATE() fn_GetDate, SYSDATETIME() fn_SysDateTime In case of GETDATE the precision is till miliseconds and in case of SYSDATETIME the precision is till nanoseconds. Now the questions is to you – did you know this? Be honest and please share your views. I already accepted that I did not know this in very first line. This applies to SQL Server 2008 only. Reference: Pinal Dave (http://www.SQLAuthority.com), - [SQL SERVER - Fastest Way to Restore Database](https://blog.sqlauthority.com/2010/06/09/sql-server-fastest-way-to-restore-the-database/): A few days ago, I received following email from blog reader where the question was about the fastest way to restore database. - [SQL SERVER - Merge Operations - Insert, Update, Delete in Single Execution](https://blog.sqlauthority.com/2010/06/08/sql-server-merge-operations-insert-update-delete-in-single-execution/): This blog post is written in response to T-SQL Tuesday hosted by Jorge Segarra. I have been very active using these Merge operations in my development. However, I have found out from my consulting work and friends that these amazing operations are not utilized by them most of the time. Here is my attempt to bring the necessity of using the Merge Operation to surface one more time. - [SQL SERVER - Subquery or Join - Various Options - SQL Server Engine Knows the Best - Part 2](https://blog.sqlauthority.com/2010/06/07/sql-server-subquery-or-join-various-options-sql-server-engine-knows-the-best-part-2/): This blog post is part 2 of the earlier written article SQL SERVER – Subquery or Join – Various Options – SQL Server Engine knows the Best by Paulo R. Pereira. Paulo has left excellent comment to earlier article once again proving the point that SQL Server Engine is smart enough to figure out the best plan itself and uses the same for the query. Let us go over his comment as he has posted. “I think IN or EXISTS is the best choice, because there is a little difference between ‘Merge Join’ of query with JOIN (Inner Join) and the... - [SQL SERVER - Subquery or Join - Various Options - SQL Server Engine knows the Best](https://blog.sqlauthority.com/2010/06/06/sql-server-subquery-or-join-various-options-sql-server-engine-knows-the-best/): This is followup post of my earlier article SQL SERVER – Convert IN to EXISTS – Performance Talk, after reading all the comments I have received I felt that I could write more on the same subject to clear few things out. First let us run following four queries, all of them are giving exactly same resultset. USE AdventureWorks GO -- use of = SELECT * FROM HumanResources.Employee E WHERE E.EmployeeID = ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- use of in SELECT * FROM HumanResources.Employee E WHERE E.EmployeeID IN ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- use of exists SELECT * FROM HumanResources.Employee E... - [SQL SERVER - Convert IN to EXISTS - Performance Talk](https://blog.sqlauthority.com/2010/06/05/sql-server-convert-in-to-exists-performance-talk/): In recent training one of the attendee asked if I can show a simple method to convert IN clause to EXISTS clause so it impacts performance. Here is the simple example. - [SQL SERVER - Generate Database Script for SQL Azure](https://blog.sqlauthority.com/2010/06/04/sql-server-generate-database-script-for-sql-azure/): When talking about SQL Azure the common complaint I hear is that the script generated from stand-along SQL Server database is not compatible with SQL Azure. This was true for some time for sure, but not any more. If you have SQL Server 2008 R2 installed you can follow the guideline below to generate a script which is compatible with SQL Azure. - [SQLAuthority News - Training and Consultancy and Travel - Story of Last 30 Days](https://blog.sqlauthority.com/2010/06/03/sqlauthority-news-training-and-consultancy-and-travel-story-of-30-last-30-days/): Today’s blog post is not technical as usual. Here, I present a real story, and I also invite you all to share your thoughts or opinions on this post. I am a professional SQL Server Trainer; I also do consultation in the area of the Performance Tuning and Query Optimizations. In any month, I like the mix of both in my schedule. I prefer to do training for one week, and then commit the next week for some consultation work. Due to the advancement in technology, for most of the consultation works, there is no client location visit or first time... - [SQL SERVER - Stored Procedure and Transactions](https://blog.sqlauthority.com/2010/06/02/sql-server-stored-procedure-and-transactions/): I just overheard the following statement – “I do not use Transactions in SQL as I use Stored Procedure“. I just realized that there are so many misconceptions about this subject. Transactions has nothing to do with Stored Procedures. Let me demonstrate that with a simple example. USE tempdb GO -- Create 3 Test Tables CREATE TABLE TABLE1 (ID INT); CREATE TABLE TABLE2 (ID INT); CREATE TABLE TABLE3 (ID INT); GO -- Create SP CREATE PROCEDURE TestSP AS INSERT INTO TABLE1 (ID) VALUES (1) INSERT INTO TABLE2 (ID) VALUES ('a') INSERT INTO TABLE3 (ID) VALUES (3) GO -- Execute SP --... - [SQL SERVER - Find Last Date Time Updated for Any Table](https://blog.sqlauthority.com/2009/05/09/sql-server-find-last-date-time-updated-for-any-table/): I just received an email from one of my regular readers who is curious to know if there is any way to find out when a table is recently updated (or last date time updated). I was ready with my answer! I promptly suggested him that if a table contains UpdatedDate or ModifiedDate date column with default together with value GETDATE(), he should make use of it. On close observation, the table is not required to keep history when any row is inserted. However, the sole prerequisite is to be aware of when any table has been updated. That’s it! - [SQLAuthority News - Future of Business Intelligence and Databases - Article by Nupur Dave](https://blog.sqlauthority.com/2009/05/08/sqlauthority-news-future-of-business-intelligence-and-databases-article-by-nupur-dave/): This article is submitted by Nupur Dave Future of Business Intelligence and Databases The term business intelligence (BI) was coined by Howard Dresner in the early 1990s. He defined Business Intelligence as “a set of concepts and methodologies to improve decision making in business through use of facts and fact-based systems.” In a time when data warehousing was considered leading-edge he created the vision that led to the development of business intelligence, as it is known today.  The once visionary BI is now commonplace and in near future a momentous transformation is about to take place. BI is all set to... - [SQL SERVER - FIX : Error : Windows Update; Error Code 8000FFFF ](https://blog.sqlauthority.com/2009/05/07/sql-server-fix-error-windows-update-error-code-8000ffff/): At present, I am running Windows Vista Ultimate as OS in my computer. I have installed SQL Server 2008 developer’s version in my computer. A couple of months back, I learnt that SQL Server Book On-Line (BOL) update has been released. I usually depend on my Windows Update of SQL Server to install all updates in my OS, so I do not have to  bother myself with installing updates manually. However, this time I was quite taken aback to find that my computer was not updated with the latest updates released by Microsoft. Further, I noticed that my SQL Server Book... - [SQLAuthority News - Book Review - SQL Server 2008 Management and Administration by Ross Mistry](https://blog.sqlauthority.com/2009/05/06/sqlauthority-news-book-review-sql-server-2008-management-and-administration-by-ross-mistry/): SQL Server 2008 Management and Administration (Paperback) - [SQLAuthority News - Author Visit - TechEd India 2009 - Hyderabad](https://blog.sqlauthority.com/2009/05/05/sqlauthority-news-author-visit-teched-india-2009-hyderabad/): I am sure most of you have already heard the good news -Microsoft TechEd India 2009 finally arrives! Tech.Ed-India is a great opportunity to gear yourself up to keep pace with the latest technology innovations and trends.  This event offers you the platform to get comprehensive hands-on-training and free certifications in some of the most sought after technologies of today. In fact, it is a must-attend event for all developers and IT Professionals. Tech.Ed-India will see Steve Balmer, CEO of Microsoft, giving the Keynote and the presence of some renowned speakers. The event will offer you the opportunity to interact with... - [SQL SERVER - Roadmap of Microsoft Certifications - SQL Server Certifications](https://blog.sqlauthority.com/2009/05/04/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications-2/): Introduction In these times of economic slowdown and uncertainties, more and more IT professionals are concerned about their job security and their qualifications. With job insecurity looming on their minds, it is a common trend for developers to start hunting for ways to update their skills. Sound knowledge and real world work experience are always a good way to help secure your future. However, a great way to demonstrate knowledge and competence is by having a certification in the technology one claims to be proficient in. Download Roadmap of Microsoft Certifications – SQL Server Certifications Microsoft offers a series of certifications... - [SQL SERVER - Add or Remove Identity Property on Column](https://blog.sqlauthority.com/2009/05/03/sql-server-add-or-remove-identity-property-on-column/): This article contribution from one of my favorite SQL Expert Imran Mohammed. He is one man who has lots of ideas and helps people from all over the world with passion using this community as platform. His constant zeal to learn more about SQL Server keeps him engaging him to do new SQL Server related activity every time. 1. Adding Identity Property to an existing column in a table. How difficult is it to add an Identity property to an existing column in a table? Is there any T-SQL that can perform this action? For most, the answer to the above... - [SQL SERVER - Example of DDL, DML, DCL and TCL Commands](https://blog.sqlauthority.com/2009/05/02/sql-server-example-of-ddl-dml-dcl-and-tcl-commands/): DML DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. SELECT – Retrieves data from a table INSERT –  Inserts data into a table UPDATE – Updates existing data into a table DELETE – Deletes all records from a table DDL DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. CREATE – Creates objects in the database ALTER – Alters objects of the database DROP – Deletes objects of the database TRUNCATE – Deletes all records from... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting April 24, 2009](https://blog.sqlauthority.com/2009/05/01/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-april-24-2009-2/): We had another successful Gandhinagar SQL Server User Group Meeting on April 24, 2009. In spite of our User Group being just two months old, it received overwhelming warm response from the audience! The meeting once again saw around 50 SQL Server enthusiasts eagerly looking forward to brush up their knowledge and gain some vital tips. The agenda of the meeting was as follows: 6:30 PM – 6:45 PM – Query Optimization Tricks – Jacob Sebastian 6:45 PM – 7:10 PM – Back to Basics – Pinal Dave 7:10 PM – 7:20 PM – Questions and Answers 7:20 PM – 7:30... - [SQL SERVER - FIX : ERROR : is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)](https://blog.sqlauthority.com/2009/04/30/sql-server-fix-error-is-not-a-valid-win32-application-exception-from-hresult-0x800700c1/): Just a day ago, one of my friend sent me email requesting help with following error: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) In fact this is not SQL Server error but it is of .NET application. The solution of this error is just changing configuration of IIS7. Fix/Solution/Workaround: Go to IIS. Click on Application Pool. Look for your web application in application pool. Go to Advanced Settings by right clicking on previously selected application pool. Enable 32-Bit Applications by checking it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Solution to Puzzle - Shortest Code to Perform SSN Validation](https://blog.sqlauthority.com/2009/04/29/sql-server-solution-to-puzzle-shortest-code-to-perform-ssn-validation/): One of my friends – a SQL Server MVP- Jacob Sebastian has a knack for coming up with interesting ideas and stuffs, the latest example being SQL Server Puzzles on his blog. Jacob is a regular blogger and a talented writer. I enjoy reading his blogs and books. He has recently published his new book – The Art of XSD – SQL Server XML Schema Collections. I have based my present article on his most recent brainteaser – Write the shortest T-SQL Code that removes invalid SSN values and returns a result set with only valid SSN values. There are few... - [SQL SERVER - Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial with Script](https://blog.sqlauthority.com/2009/04/28/sql-server-introduction-to-sql-server-encryption-and-symmetric-key-encryption-tutorial-with-script/): SQL Server 2005 and SQL Server 2008 provide encryption as a new feature to protect data against hackers’ attacks. Hackers might be able to penetrate the database or tables, but owing to encryption they would not be able to understand the data or make use of it. Nowadays, it has become imperative to encrypt crucial security-related data while storing in the database as well as during transmission across a network between the client and the server. - [SQLAuthority News - Starting the SQL Journey - How Did I Get Started With SQL?](https://blog.sqlauthority.com/2009/04/27/sqlauthority-news-starting-the-sql-journey-how-did-i-get-started-with-sql/): This is the very first time I am answering any online tag. SQL Expert Jorge Segarra (a.k.a @SQLChicken) recently tagged me with a very simple yet significant question related to my journey on the path of SQL Server. Let me introduce you all to Jorge first before moving on to his question. Jorge lives in Tampa, Florida, with his beautiful wife, an adorable dog and two naughty cats. He is currently working as a SQL DBA and system administrator for the University Community Hospital. His in-depth knowledge of SQL Server and comprehensive understanding of the subject has gained him incredible popularity... - [SQL SERVER - List All the Tables for All Databases Using System Tables](https://blog.sqlauthority.com/2009/04/26/sql-server-list-all-the-tables-for-all-databases-using-system-tables/): Today we will go over very simple script which will list all the tables for all the database. sp_msforeachdb 'select "?" AS db, * from [?].sys.tables' Update: Based on comments received below I have updated this article. Thank you to all the readers. This is good example where something small like this have good participation from readers. Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQLAuthority News - Interview of Author on 60 Seconds with Pinal Dave](https://blog.sqlauthority.com/2009/04/25/sqlauthority-news-interview-of-author-on-60-seconds-with-pinal-dave/): Vijaya Kadiyala is my fellow .NET and SQL Expert and very respected member of the technology community in India. He is known for his easy but to the point attitude for technology. He regularly writes on his blog : DotNetVJ. I happen to meet him at MVP Summit in Seattle and have learned a lot about him. In my recent travel to South India, I have learned a great deal about his community services and enthusiasm about cutting edge technology. Vijaya has started interview series on his blog where he takes very quick interviews of community leaders. He asked following five... - [SQL SERVER - Leading Zero to Number ](https://blog.sqlauthority.com/2009/04/24/sql-server-leading-zero-to-number/): I have received few emails asking how to prefix any number with zero. I have previously written two articles for the same subject. Please refer to my previous articles. SQL SERVER – Pad Ride Side of Number with 0 – Fixed Width Number Display SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display Let me know if you are aware of any other method. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to SQL Server 2008 Profiler - Summary](https://blog.sqlauthority.com/2009/04/24/sql-server-introduction-to-sql-server-2008-profiler/): Introduction SQL Server Profiler is a powerful tool that is available with SQL Server since a long time; however, it has mostly been underutilized by DBAs. SQL Server Profiler can perform various significant functions such as tracing what is running under the SQL Server Engine’s hood, and finding out how queries are resolved internally and what scripts are running to accomplish any T-SQL command. The major functions this tool can perform have been listed below: Creating trace Watching trace Storing trace Replaying trace Trace includes all the T-SQL scripts that run simultaneously on SQL Server. As trace contains all the T-SQL... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting April 24, 2009](https://blog.sqlauthority.com/2009/04/23/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-april-24-2009/): Gandhinagar SQL Server User Group launch event was held on March 27, 2009. This successful, well-attended event received very positive and warm community response. Visit Gandhinagar SQL Server User Group Portal and register yourself now! We are going to meet again this month on April 24, 2009 Friday from 6:30PM to 7:30 PM. We will be very fortunate that we will have outside guest and another SQL Server MVP visiting us. Jacob Sebastian is president of Ahmedabad SQL Server User Group and fellow MVP. He has taken many technical sessions in meetings and famous speaker in SQL Server arena. The agenda... - [SQL SERVER - FIX : Error: 18486 Login failed for user 'sa' because the account is currently locked out. The system administrator can unlock it. - Unlock SA Login](https://blog.sqlauthority.com/2009/04/23/sql-server-fix-error-18486-login-failed-for-user-sa-because-the-account-is-currently-locked-out-the-system-administrator-can-unlock-it-unlock-sa-login/): Today, we will riffle through a very simple, yet common issue – How to unlock a locked “sa” login? It is quite a common practice that SQL Server is hosted on a separate server than application server. In most cases, SQL Server ports or IP are exposed to the web, which makes them risk prone. For hackers, System Admin login “sa” is the preferred account which they use for hacking. In fact, a majority of hackers try to hack into SQL Server by attempting to login using “sa” account. Once hackers gain access to server using “sa” login, they get a... - [SQL SERVER - Difference Between SQL Server Compact Edition (CE) and SQL Server Express Edition](https://blog.sqlauthority.com/2009/04/22/sql-server-difference-between-sql-server-compact-edition-ce-and-sql-server-express-edition/): I often received question regarding what are difference between SQL Server Compact Edition (CE) and SQL Server Express Edition. In one line – SQL Server CE is for mobile application and embaded systems where as SQL Server Express Edition is limited feature light version of SQL Server Standard. SQL Server Compact Edition SQL Server Express Edition ClickOnce Deployment ClickOnce Deployment Installed centrally with an MSI Installed centrally with an MSI XML storage XML storage Transact-SQL Transact-SQL Subscriber for merge replication Subscriber for merge replication Simple transactions Simple transactions Database size support – 4GB Database size support – 4GB Number of concurrent... - [SQL SERVER - What is Cloud Computing - Introduction to Cloud Computing](https://blog.sqlauthority.com/2009/04/21/sql-server-what-is-cloud-computing-introduction-to-cloud-computing/): “Cloud Computing,” to put it simply, means “Internet Computing.” The Internet is commonly visualized as clouds; hence the term “cloud computing” for computation done through the Internet. With Cloud Computing users can access database resources via the Internet from anywhere, for as long as they need, without worrying about any maintenance or management of actual resources. Besides, databases in cloud are very dynamic and scalable. Cloud computing is unlike grid computing, utility computing, or autonomic computing. In fact, it is a very independent platform in terms of computing. The best example of cloud computing is Google Apps where any application can... - [SQLAuthority Book Review - Pro T-SQL 2008 Programmer’s Guide by Michael Coles](https://blog.sqlauthority.com/2009/04/20/sqlauthority-book-review-pro-t-sql-2008-programmers-guide-by-michael-coles/): Pro T-SQL 2008 Programmer’s Guide by Michael Coles Link to Amazon Short Summary: Pro T-SQL 2008 Programmer’s Guide examines SQL Server 2008 T-SQL from a developer’s perspective. This information-rich book covers a wide array of developer-specific topics in SQL Server 2008. In addition, it provides in-depth knowledge of various newly introduced topics. This book is written as a practical guide to help database developers who mainly deal with T-SQL. It has really hit the spot with appropriate .NET code at a few places where required. The book assumes a basic knowledge of SQL, but it is very easy to understand for... - [SQL SERVER - Fix : SQL Server 2008 Developer Edition Install fail due to .NET Framework 3.5 missing](https://blog.sqlauthority.com/2009/04/19/sql-server-fix-sql-server-2008-developer-edition-install-fail-due-to-net-framework-35-missing/): It goes without saying that computer running slow is a common problem we all face, a pestering one indeed! Last week, I had to format my computer as it was running at an annoyingly tortoise pace. After formatting it, I installed Visual Studio 2008. When tested Visual Studio 2008 worked all fine. However, when I attempted to install SQL Server 2008, I was confronted with an error about NET Framework 3.5 missing. - [SQLAuthority News - Troubleshooting Performance Problems in SQL Server 2008](https://blog.sqlauthority.com/2009/04/18/sqlauthority-news-troubleshooting-performance-problems-in-sql-server-2008/): Troubleshooting Performance Problems in SQL Server 2008 SQL Server Technical Article Writers: Sunil Agarwal, Boris Baryshnikov, Keith Elmore, Juergen Thomas, Kun Cheng, Burzin Patel Technical Reviewers: Jerome Halmans, Fabricio Voznika, George Reynya Published: March 2009 - [SQLAuthority News - Authors Website Redesigned - http://www.pinaldave.com - Feedback Requested](https://blog.sqlauthority.com/2009/04/17/sqlauthority-news-authors-website-redesigned-httpwwwpinaldavecom-feedback-requested/): I’m pleased to inform you all that I’ve recently launched my personal website. It’s been a long time since I’ve been writing on my blog https://blog.sqlauthority.com, but I’ve been keeping my personal notes at my homepage http://www.pinaldave.com. I’ve completely rehauled the website to give it the much-needed makeover, right from redesigning the layout to writing fresh content. But, I would be extremely happy to have your feedback so that I can enhance my website further. I’ve always been a people’s person who believes in sharing his knowledge. Also, I want to see myself growing as an individual and as a professional.... - [SQLAuthority News - Microsoft Certification Exam - Discount Code](https://blog.sqlauthority.com/2009/04/16/sqlauthority-news-microsoft-certification-exam-discount-code/): Note: I am republishing this blog post as the offer of this code is extended to April 30, 2009. Please note down this important code or share with your colleagues who are keen to take Microsoft Certification Exam. This unique code is only available through Microsoft MVP’s and only published here to help community and no other intention. In this challenging economic climate, upgrading your IT skills becomes crucial to staying ahead. Invest in a Microsoft Certification to get the right IT skills. Register today with your MVP Certification Promotion Code:  and enjoy 2 chances to pass a Microsoft Certification Examination... - [SQL SERVER - Poll Result - What is Your Favorite Database?](https://blog.sqlauthority.com/2009/04/15/sql-server-poll-result-what-is-your-favorite-database/): I previously posted a Poll about What is Your Favorite Database? I got great response from users. In fact, I received some of the best poll-related comments on this blog  and they are worth reading. Let us check the result first. Here are the votes I received on different database. Total votes received are 1,697. SQL Server – 1,121 – 64% Oracle – 432 – 25% MySQL – 144 – 8% Other – 64 – 4% SQL Server is a clear winner with  1,121 votes, which is an astounding 64% of the total votes. As a matter of fact, it is... - [SQL SERVER - Check if Current Login is Part of Server Role Member](https://blog.sqlauthority.com/2009/04/14/sql-server-check-if-current-login-is-part-of-server-role-member/): I often work on consulting projects with umpteen clients from across the globe. The nature of the works I usually receive necessitates me to take on the role of a system admin. Now, this role is trailed by come common issues. This article revolves around one such concern. Let us learn about Server Role Member. - [SQL SERVER - Introduction to JOINs - Basic of JOINs](https://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/): The launch of Gandhinagar SQL Server User Group was a tremendous, astonishing success! It was overwhelming to see a large gathering of enthusiasts looking up to me (I was the Key Speaker) eager to enhance their knowledge and participate in some brainstorming discussions. Some members of User Group had requested me to write a simple article on JOINS elucidating its different types. INNER JOIN This join returns rows when there is at least one match in both the tables. OUTER JOIN There are three different Outer Join methods. LEFT OUTER JOIN This join returns all the rows from the left table... - [SQL SERVER - FIX : ERROR : The SQL Server System Configuration Checker cannot be executed due to WMI configuration on the machine Error:2147749896 (0×80041008)](https://blog.sqlauthority.com/2009/04/12/sql-server-fix-error-the-sql-server-system-configuration-checker-cannot-be-executed-due-to-wmi-configuration-on-the-machine-error2147749896-0%c3%9780041008/): A couple of days back I  had my computer formatted. I reinstalled it with Vista SP1 32bit. Subsequent to installing other indispensable software  I tried to install SQL Server 2005 .  However, it instantly displayed the following error message. The SQL Server System Configuration Checker cannot be executed due to WMI configuration on the machine Error:2147749896 (0×80041008). It was a bit frustrating for me as it was pretty late and I ardently wanted to install SQL Server 2008 right after I was done  with installing SQL Server 2005. I pinged my friend James Locazicoski with the above error message. James came... - [SQL SERVER - Interesting Observation of DMV of Active Transactions and DMV of Current Transactions](https://blog.sqlauthority.com/2009/04/11/sql-server-interesting-observation-of-dmv-of-active-transactions-and-dmv-of-current-transactions/): This post is about a riveting observation I made a few days back. While playing with transactions I came across two DMVs  that are associated with Transactions. 1) sys.dm_tran_active_transactions – Returns information about transactions for the instance of SQL Server. 2) sys.dm_tran_current_transaction – Returns a single row that displays the state information of the transaction in the current session. Now, what really interests me is the following observation. These two DMVs , in actual fact, display the distinction between active transactions and current transactions. Current transaction can be active transaction at the time of execution, but not all active transactions are... - [SQL SERVER - Restore or Attach Database Without .NDF or .MDF is Not Possible](https://blog.sqlauthority.com/2009/04/10/sql-server-restore-or-attach-database-without-ndf-or-mdf-is-not-possible/): This article revolves around a trivial yet common issue. There might be a set of people for whom the current topic might appear to be insignificant. But I have been asked this question innumerable times, particularly from   people who are frequenting using forums or have blog related to storage and highly availability, which instigated me to write this article. Here goes this frequently asked question. Question: Is it possible to restore database if one of the files of .mdf (primary data file) or .ndf (secondary data file) is missing? Answer: In one word the answer is NO. All the .mdf and... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2009/04/10/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-3/): Note: Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Scripts in the SQL Server 2008 management pack rely on SQL Data Management Objects (SQL-DMO) to query information from the SQL Server. SQL-DMO is now deprecated and is not shipped as a part of SQL Server... - [SQLAuthority News - Download SQL Server 2005 Report Packs - SQL Server Sample Reports - Report Templates](https://blog.sqlauthority.com/2009/04/10/sqlauthority-news-download-sql-server-2005-report-packs-sql-server-sample-reports-report-templates/): Note:   Download SQL Server 2005 Report Packs by Microsoft SQL Server 2005 Reporting Services is a comprehensive, server-based reporting solution designed to help you author, manage, and deliver both paper-based, ad hoc, and interactive Web-based reports. Each report pack consists of a set of predefined reports, a sample database, a readme file, and an End User License Agreement (EULA). You can use these sample reports as templates to quickly author and distribute new interactive reports. Report Pack contains following sample reports SQL Server 2005 Integration Services Log Reports SQL Server 2005 Report Pack for Microsoft Dynamics Axapta 3.0 SQL Server 2005... - [SQL SERVER - Fix Error 9803. Invalid data for type "numeric" - Data Type Mapping](https://blog.sqlauthority.com/2009/04/09/sql-server-fix-error-msg-9803-level-16-invalid-data-for-type-numeric-data-type-mapping-for-oracle-publishers/): My present article talks about an error that you will encounter when connecting to Oracle database using OPENQUERY. Let us learn about how to fix error 9803. - [SQL SERVER - Maximum Columns per Primary Key - Fix : Error : Msg 1904, Level 16, The index on table has column names in index key list. The maximum limit for index or statistics key column list is 16](https://blog.sqlauthority.com/2009/04/08/sql-server-maximum-columns-per-primary-key-fix-error-msg-1904-level-16-the-index-on-table-has-column-names-in-index-key-list-the-maximum-limit-for-index-or-statistics-key-column-list-is-16/): My present article covers two fundamental questions. 1) What is the maximum number of columns included in Primary Key Index/Constraint? 2) What is fix/solution for the following error: Msg 1904, Level 16, State 1, Line 1 The index ” on table ‘dbo.Table_2’ has 17 column names in index key list. The maximum limit for index or statistics key column list is 16. The same error surfaces when example is created using SSMS. Fix/Solution/Workaround: Maximum columns per Primary Key Index is 16. In fact, 16 is the limit for columns per Foreign Key and Index Key. You cannot have more than 16... - [SQLAuthority News - SQL Server 2008 Service Pack 1 Released - Available for Download](https://blog.sqlauthority.com/2009/04/08/sqlauthority-news-sql-server-2008-service-pack-1-released-available-for-download/): SQL Server 2008 Service Pack 1 (SP1) is now available. You can use these packages to upgrade any SQL Server 2008 edition. Download SQL Server 2008 Service Pack 1 Build of SP1 is SP1 is build 10.00.2531.00. Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Server Type and File Extention](https://blog.sqlauthority.com/2009/04/07/sql-server-server-type-and-file-extention/): Owing to my personal experience so far, I can undeniably say that Microsoft Windows products are outstanding. One of the reasons that make them exceptional is their little nifty tricks. For instance, every time I double click myfilename.sql it opens Microsoft SQL Server Management Studio (SSMS). The reason how Windows discerns that it has to open SSMS is because the extension of file I had clicked is .sql. I explored and found that SQL Server has few more filetypes associated with it, which are as follows. SQL Server – .sql SQL Server Compact 3.5 SP1 – .sqlce SQL Server Analysis Service... - [SQL SERVER - Logical Query Processing Phases - Order of Statement Execution](https://blog.sqlauthority.com/2009/04/06/sql-server-logical-query-processing-phases-order-of-statement-execution/): Of late, I penned down an article – SQL SERVER – Interesting Observation of ON Clause on LEFT JOIN – How ON Clause Effects Resultset in LEFT JOIN – which received a very intriguing comment from one of my regular blog readers Craig. According to him this phenomenon happens due to Logical Query Processing. His comment instigated a question in my mind. I have put forth this question to all my readers at the end of the article. Let me first give you an introduction to Logical Query Processing Phase. What actually sets SQL Server apart from other programming languages is... - [SQL SERVER - 2008 - Management Studio New Features](https://blog.sqlauthority.com/2009/04/05/sql-server-2008-management-studio-new-features/): Pinalkumar Dave describes the top 5 features of SQL Server Management Studio 2008. This article describes the top 5 features of SQL Server Management Studio 2008. With the release of SQL Server 2008 Microsoft has upgraded SSMS with many new features as well as added tons of new functionalities requested by DBAs for long time. SQL Server 2008 has been released for a year now. In SQL Server 2000, DBA had to use two different tools to maintain the database as well as the query database, specifically SQL Server Enterprise Manager and SQL Server Query Analyzer. With the release of SQL... - [SQL SERVER - Mirrored Backup and Restore and Split File Backup](https://blog.sqlauthority.com/2009/04/05/sql-server-mirrored-backup-and-restore-and-split-file-backup/): Introduction This article is based on a real life experience of the author while working with database backup and restore during his consultancy work for various organizations. We will go over the following important concepts of database backup and restore. Conventional Backup and Restore Spilt File Backup and Restore Mirror File Backup Understanding FORMAT Clause Miscellaneous details about Backup and Restore Conventional and Split File Backup and Restore Just a day before working on one of the projects, I had to take a backup of one database of 14 GB. My hard drive lacked sufficient space at that moment. Fortunately, I... - [SQL SERVER - Automated Index Defragmentation Script](https://blog.sqlauthority.com/2009/04/04/sql-server-automated-index-defragmentation-script/): Index Defragmentation is one of the key processes to significantly improve performance of any database. Index fragments occur when any transaction takes place in database table.  Fragmentation typically happens owing to insert, update and delete transactions. Having said that, fragmented data can produce unnecessary reads thereby reducing performance of heavy fragmented tables. I have often been asked to share my personal Index Defragmentation Script. Well, I use Automated Index Defragmentation Script created by my friend – a SQL Expert – Michelle Ufford (a.k.a SQLFool). Michelle is a SQL Server Developer, DBA, a humble blogger, and an absolute geek! She is also... - [SQLAuthority News - Launch of Gandhinagar SQL Server User Group](https://blog.sqlauthority.com/2009/04/03/sqlauthority-news-launch-of-gandhinagar-sql-server-user-group/): Gandhinagar SQL Server User Group launch event was held on March 27, 2009. This successful, well-attended event received very positive and warm community response. This launch event, unexpectedly, saw over 50 database enthusiasts participating. It was really a moment of pleasant surprise when we ran out of chairs. The otherwise spacious room started getting smaller as more and more people joined in, and unquestionably, we felt ecstatic about it! Visit Gandhinagar SQL Server User Group Portal and register yourself now! We commenced Gandhinagar SQL Server User Group launch event sharp at 6:30 and completed it precisely at 7:30. During these 60... - [SQL SERVER - Very Powerful and Feature-Rich Backup, Zip and FTP Utility SQLBackupAndFTP](https://blog.sqlauthority.com/2009/04/02/sql-server-very-powerful-and-feature-rich-backup-zip-and-ftp-utility-sqlbackupandftp/): It goes without saying that Database Backup is the most important task for any Database Administrator (DBA). Naturally, large organizations always have a team of DBAs who execute Database Backup tasks. No matter how big or small an organization is, the importance of database backup remains the same across the board. It’s a common practice in several organizations to upload the backup to their remote location for additional safety. I totally vouch for this safety measure of having their additional backup on remote/satellite location. This redundancy comes in handy whenever a catastrophe of not having proper backup surfaces abruptly. While I... - [SQL SERVER - Reseed Identity of Table - Table Missing Identity Values - Gap in Identity Column](https://blog.sqlauthority.com/2009/04/01/sql-server-reseed-identity-of-table-table-missing-identity-values-gap-in-identity-column/): Some time ago I was helping one of my Junior Developers who presented me with an interesting situation. He had a table with Identity Column. Because of some reasons he was compelled to delete few rows from the table. On inserting new rows in the table he noticed that the rows started from the next identity value which created gap in the identity value. His application required all the identities to be in sequence, so this was certainly not a small issue for him. The solution to this issue regarding gap in identity column is very simple. Let us first take... - [SQL SERVER - IntelliSense Does Not Work - Enable IntelliSense](https://blog.sqlauthority.com/2009/03/31/sql-server-2008-intellisense-does-not-work-enable-intellisense/): While I was working with SQL Server 2008 IntelliSense, I realized that it was not functioning as I expected. Even after I had enabled IntelliSense it was still not opening any suggestions at all. After a while, I figured out some vital information regarding how to make sure IntelliSense smoothly works all the time without you giving any trouble. Let us learn how we can Enable IntelliSense. - [SQLAuthority News - Top 10 Strategic Technologies for 2009](https://blog.sqlauthority.com/2009/03/30/sqlauthority-news-top-10-strategic-technologies-for-2009/): Gartner, Inc. analysts highlighted the top 10 technologies and trends that will be strategic for most organizations. Factors that denote significant impact include a high potential for disruption to IT or the business, the need for a major dollar investment, or the risk of being late to adopt. The top 10 strategic technologies for 2009 include: Virtualization. Much of the current buzz is focused on server virtualization, but virtualization in storage and client devices is also moving rapidly. Cloud Computing. Cloud computing is a style of computing that characterizes a model in which providers deliver a variety of IT-enabled capabilities to... - [SQL SERVER - Fix : Error : Msg 2714, Level 16, State 6 - There is already an object named '#temp' in the database](https://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/): Recently, one of my regular blog readers emailed me with a question concerning the following error: Msg 2714, Level 16, State 6, Line 4 There is already an object named ‘#temp’ in the database. This reader has been encountering the above-mentioned error, and he is curious to know the reason behind this. Here’s Rakesh’s email. Hi Pinal, I’m a  regular visitor to your blog and I thoroughly enjoy your articles and especially the way you solve your readers’ queries. I work as a junior SQL developer in Austin. Today, when I started to create a TSQL application, I detected an interesting... - [SQLAuthority News - SQL SERVER 2008 - Updated Brochure Available for Download](https://blog.sqlauthority.com/2009/03/28/sqlauthority-news-sql-server-2008-updated-brochure-available-for-download/): SQL Server 2008 new brochure is available for download. Microsoft® SQL Server® 2008 provides a trusted, productive, and intelligent data platform that enables you to: Run your most demanding mission-critical applications. Reduce time and cost of development and management of applications. Deliver actionable insight to your entire organization. Your Data, Any Place, Any Time. Download SQL Server 2008 Brochure Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Database Poll and Gandhinagar SQL Server User Group Launch Today](https://blog.sqlauthority.com/2009/03/27/sqlauthority-news-database-poll-and-gandhinagar-sql-server-user-group-launch-today/): I have published a poll on website few days ago for favorite database of SQLAuthority.com readers. The best comment will win USB drive. The poll will close on April 1, 2009. Looking at the poll result, it seems that Oracle has gained a lot over SQL Server from last time when I checked. Please share this poll with your friends, your UG and community to get better sample. If you are not interested in poll there are many interesting comments, please read them. Additionally, Gandhinagar SQL Server User Group has launch event today. I suggest all of you from surrounding area... - [SQLAuthority News - Author Video Interview Published Online - Microsoft MVP Summit 2009](https://blog.sqlauthority.com/2009/03/27/sqlauthority-news-author-video-interview-published-online-microsoft-mvp-summit-2009/): Microsoft MVP Award Blog and Microsoft South Asian MVP Blog has published my video interview online. My interview was conducted by Abhishek Kant – Microsoft MVP Lead and Technology Blogger. I am thankful to Abhishek Kant for conducting my interview, Abhishek Baxi for publishing on South Asian Blog and Jas Dhaliwal for producing the video. Above All I am very thankful to Microsoft for awarding me MVP Award. This video was shot at Microsoft MVP Summit 2009 at Seattle. Watch my Video on Microsoft MVP Award Blog Watch my Video on Microsoft South Asian MVP Blog Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error: Msg 15123, Level 16 - The configuration option 'advance option' does not exist, or it may be an advanced option.](https://blog.sqlauthority.com/2009/03/26/sql-server-fix-error-msg-15123-level-16-the-configuration-option-advance-option-does-not-exist-or-it-may-be-an-advanced-option/): I received another email describing error received due to my executing script from my previous article . Error : Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51 The configuration option ‘optimize for ad hoc workloads’ does not exist, or it may be an advanced option. Let us quickly see the reproduction of this error in following image. Fix/Workaround/Solution: The reason this error is happening because of not enabling advance option. Run complete following script and it should fix the problem. sp_CONFIGURE 'show advanced options',1 RECONFIGURE GO sp_CONFIGURE ‘optimize for ad hoc workloads’,1 RECONFIGURE GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 4621, Level 16, State 10 : Permissions at the server scope can only be granted when the current database is master](https://blog.sqlauthority.com/2009/03/26/sql-server-fix-error-msg-4621-level-16-state-10-permissions-at-the-server-scope-can-only-be-granted-when-the-current-database-is-master/): I have received comment from Radha Goswami on my previous blog article SQL SERVER – 2008 – Activity Monitor is Empty – Fix Activity Monitor for All Users. Radha is facing following error when she is tring to grant permission to login. Error: Msg 4621, Level 16, State 10, Line 1 Permissions at the server scope can only be granted when the current database is master Following image is I have recreated based on the above error message. Fix/Workaround/Solution: If you look at the database in use is AdventureWorks and when any server level persmission has to be granted the database... - [SQLAuthority News - Announcement - Gandhinagar SQL Server User Group - March 27, 2009](https://blog.sqlauthority.com/2009/03/25/sqlauthority-news-announcement-gandhinagar-sql-server-user-group-march-27-2009/): It is my pleasure to announce new SQL Server User Group – Gandhinagar SQL Server User Group. We will be meeting every 2nd and 4th Friday of the month. Here is the detail for this months meeting. We will be having one gift for best participant in the meeting. I request all the SQL enthusiast to attend this meeting and do not miss it. You can be member at sqlpass @ . Meeting Date Time: March 27, 2009 6:30 PM -7:30 PM Friday Meeting Agenda: 6:30 PM – 7:00 PM – Introduction to Joins and Real Life Scenario 7:00 PM –... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting Review - March 21, 2009](https://blog.sqlauthority.com/2009/03/25/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-review-march-21-2009/): We had fun session with Ahmedabad SQL Server Usre Group last week on March 21, 2009. It was short session but one interesting one. We discussed about how query profiler works and how to find most popular query from SQL Server instance. We had also prepared Trace Template as well query which can ran to identify longest running query along with popular query. I received nearly 10 questions after my session and lots of time was spent answering them. The whole session was very interactive. I want to congratulate everybody who attended it, if you need my Profiler Template and Query... - [SQL SERVER - 2008 - SCOPE_IDENTITY Bug with Multi Processor Parallel Plan and Solution](https://blog.sqlauthority.com/2009/03/24/sql-server-2008-scope_identity-bug-with-multi-processor-parallel-plan-and-solution/): This article is very serious and I would like to explain this as simple as I can. SCOPE_IDENTITY() which is commonly used in place of @@Identity has bug when run in Parallel Plan. You can read my explanation of @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT in earlier article. The bug is listed here in connect site SCOPE_IDENTITY() sometimes returns incorrect value. Additionally, the bug is also listed in Book Online on last line of the SCOPE_IDENTITY() documentation. When parallel plan is executed SCOPE_IDENTITY or IDENTITY may produce inconsistent results. The bug will be fixed in future versions of SQL Server. For SQL... - [SQL SERVER - 2008 - Location of Activity Monitor - Where is SQL Serve Activity Monitor Located](https://blog.sqlauthority.com/2009/03/23/sql-server-2008-location-of-activity-monitor-where-is-sql-serve-activity-monitor-located/): I received question from Aloke Sinha after reading my article SQL SERVER – 2008 – Activity Monitor is Empty – Fix Activity Monitor for All Users. Hello Pinalbhai, Thank you for your post about activity monitor, but I can not find activity monitor under Menu — Tools. How to activate it? [Other unrelated information removed] Take care, Aloke Sinha The reason I decided to write about this subject is because I totally understand why Aloke is confused here. Activity Monitor can not be activated from any menu from top menu bar. There are two different methods to activate Activity Monitors. From... - [SQL SERVER - 2008 - Activity Monitor is Empty - Fix Activity Monitor for All Users](https://blog.sqlauthority.com/2009/03/22/sql-server-2008-activity-monitor-is-empty-fix-activity-monitor-for-all-users/): This article is an outcome of the technical discussion of activity monitor and its behavior with my friend and SQL Expert Tejas Shah. Tejas told me that he does not like to re-write content from MSDN, but rather prefer to write real life scenarios, as that prepares him to become a better SQL Expert. While discussing about Activity Monitor he informed that it throws an error when there is a permissions issue. He has even blogged about how to give permissions to user to launch activity monitor on his blog . Tejas asked me to write on the same subject for SQL Server 2008. Here is the article covering the discussion I had with Tejas. - [SQL SERVER - 2008 - Optimize for Ad hoc Workloads - Advance Performance Optimization](https://blog.sqlauthority.com/2009/03/21/sql-server-2008-optimize-for-ad-hoc-workloads-advance-performance-optimization/): Every batch (T-SQL, SP etc) when ran creates execution plan which is stored in system for re-use. Due to this reason large number of query plans are stored in system. However, there are plenty of plans which are only used once and have never re-used again. One time ran batch plans wastes memory and resources. SQL Server 2008 has feature of optimizing ad hoc workloads. Before we move to it, let us understand the behavior of SQL Server without optimizing ad hoc workload. Please run following script for testing. Make sure to not to run whole batch together. Just run each... - [SQL SERVER - AWE (Address Windowing Extensions) Explained in Simple Words](https://blog.sqlauthority.com/2009/03/20/sql-server-awe-address-windowing-extensions-explained-in-simple-words/): I was asked question by Jr. DBA that “What is AWE?”. For those who do know what is AWE or where is it located, it can be found at SQL Server Level properties. AWE is properly explained in BOL so we will just have our simple explanation. Address Windowing Extensions API is commonly known as AWE.  AWE is used by SQL Server when it has to support very large amounts of physical memory. AWE feature is only available in SQL Server Enterprise, Standard, and Developer editions with of SQL Server 32 bit version. Microsoft Windows 2000/2003 server supports maximum of 64GB... - [SQLAuthority News - 900th Article - 9 Best Practices - Important Milestones](https://blog.sqlauthority.com/2009/03/19/sqlauthority-news-900th-article-9-best-practices-important-milestones/): Today is my 900th article on this blog. You can see list of all the 900 articles here. I suggest you go over the list and read any article you like. - [SQL SERVER - Find All Servers From Local Network - Using sqlcmd - Detect Installed SQL Server on Network](https://blog.sqlauthority.com/2009/03/18/sql-server-find-all-servers-from-local-network-using-sqlcmd/): I recently had requirement to create list of all the SQL Server on local network. I remembered that I had written similar script a year ago SQL SERVER – Script to Find SQL Server on Network. When I looked at it, I realize that I had written it for SQL Server 2000 and used “isql” utility, which is deprecated now. I quickly wrote down updated script using “sqlcmd”. Command “osql” still works in SQL Server 2008. Go to command prompt and type in “osql -L” or “sqlcmd -L”. Note one change between osql and sqlcmd is that osql has additional server... - [SQL SERVER - Practical SQL Server XML: Part One - Query Plan Cache and Cost of Operations in the Cache](https://blog.sqlauthority.com/2009/03/17/sql-server-practical-sql-server-xml-part-one-query-plan-cache-and-cost-of-operations-in-the-cache/): I am very fortunate that I have friends like Michael Coles. Michael Coles is SQL Server and XML expert and have written many books on SQL Server as well XML. He has previously written book which I have reviewed on this blog SQLAuthority News – Book Review – Pro T-SQL 2005 Programmer’s Guide (Paperback). I am currently reading his latest book Pro SQL Server 2008 XML (Hardcover) which can be found on amazon. I will be writing review of the book once I am done reading it. Michael Coles and I met last at Microsoft MVP Summit 2009 at Seattle and... - [SQL SERVER - UDF - Pad Ride Side of Number with 0 - Fixed Width Number Display](https://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/): SQL SERVER - UDF - Pad Ride Side of Number with 0 - Fixed Width Number Display. Let us learn more about this blog. - [SQL SERVER - Interesting Observation of ON Clause on LEFT JOIN - How ON Clause affects Resultset in LEFT JOIN ](https://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/): Today I received email from Yoel from Israel. He is one smart man always bringing up interesting questions. Let us see his latest email first. Hi Pinal, I am subscribed to your blog and enjoy reading it. I have a question which has been bothering me for some time now. When I want to filter records in a query, I usually put the condition in the WHERE clause. When I make an inner join, I can put the condition in the ON clause instead, giving the same result. But with left joins this is not the case. Here is a quote... - [SQLAuthority News - Lots of SQL Server News - Tip of the Article](https://blog.sqlauthority.com/2009/03/14/sqlauthority-news-lots-of-sql-server-news/): I have been reeving lots of feedback from blog readers and what I have learned that they all wanted me to write about SQL Server Community news at least once a week. I am not sure if I can write every week what are happening in SQL Server world but I promise to write about news when I have collected few important news. Let me try this time how it goes and we will see in future how do you like it based on on your feedback. IPD Guide: Let me start with what has been keeping me busy recently. I... - [SQL SERVER - Profiler - Adding Filters - Observation on CPU Load](https://blog.sqlauthority.com/2009/03/13/sql-server-profiler-adding-filters-observation-on-cpu-load/): Today I am blog about something which I found recently while working with SQL Server Profiler. Profiler can be invoked just typing profiler in command prompt. I am using Windows Vista Ultimate 32 bit (License Version) and SQL Server 2008 Development (License Version). The reason I have put “License Version” because I encourage everybody to use only licensed software. SQL Server Profiler gives feature where we can specify which column filter. Column filter can have value which can be validated with atucal data and based on it, it will store information in profiler stress. I was always under impression that adding... - [SQL SERVER - What is Your Favorite Database? - Poll Continuous](https://blog.sqlauthority.com/2009/03/12/sql-server-what-is-your-favorite-database-poll-continuous/): I have published SQL Server Poll about What is Your Favorite Database? to get feedback from readers of this blog about what is their favorite database. I have received so far tremendous response. This poll will continue through out this month and will close on 1st of April. I will post all the statistic once the poll is over. I encourage all of you to spread the word about it to different channels, blogs, linked list and emails. It is not only important to vote for your favorite database but it is equally important to leave comment justifying why and which... - [SQL SERVER - Difference Between Union vs. Union All - Optimal Performance Comparison](https://blog.sqlauthority.com/2009/03/11/sql-server-difference-between-union-vs-union-all-optimal-performance-comparison/): More than a year ago I had written article SQL SERVER – Union vs. Union All – Which is better for performance? I have got many request to update this article. It is not fair to update already written article so I am rewriting it again with additional information. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the... - [SQL SERVER - Pad Ride Side of Number with 0 - Fixed Width Number Display](https://blog.sqlauthority.com/2009/03/10/sql-server-pad-ride-side-of-number-with-0-fixed-width-number-display/): Today we will look something which is very quick and but quite frequently useful string operation over numeric datatype. This article is written based on a question asked by one of the users (name not disclosed as per request). Let us see how to show a fixed width number display.  - [SQLAuthority News - Author Visit - Complete Wrapup of Microsoft MVP Summit 2009 Trip](https://blog.sqlauthority.com/2009/03/09/sqlauthority-news-author-visit-complete-wrapup-of-microsoft-mvp-summit-2009-trip/): Today I have arrived in India and back to Ahmedabad. I have left my home on 27th February and arrived back at my home on 9th March. I was traveling for total of 10 days out of 2 days were just technically included as they were very little occupied. I was traveling for 3 days out of remaining 8 days. This leaves me with total of 5 business day. This five days I worked for nearly 16 hours everyday attending Microsoft MVP summit technical sessions, having meetings with industry leaders and learning new things. I have posted my complete tour details... - [SQLAuthority News - Author Visit - South Asian MVPs at Global MVP Summit 2009](https://blog.sqlauthority.com/2009/03/08/sqlauthority-news-author-visit-south-asian-mvps-at-global-mvp-summit-2009/): I am currently at Mumbai Airport and waiting for my flight to Ahmedabad. I am little exhausted but had great time at Global MVP Summit 2009. There were lots of South Asian MVPs present at global event as well. We all had great time to network with each other and few of the MVPs who had arrived day before summit had great time touring Seattle together. We all MVPs had learned so many things about each other and shared some internal tips with each other. One thing we all decided is guest blogging, where we will write blog article for each... - [SQLAuthority News - Author Visit - Tech User Group Meeting, Markham, Canada and Toronto CA Solutions](https://blog.sqlauthority.com/2009/03/07/sqlauthority-news-author-visit-tech-user-group-meeting-markham-canada-and-toronto-ca-solutions/): I can talk about database almost all the day. Yesterday I had two technical meetings. One with Tech User Group of Markham and another with TorontoCASolutions. Let us go over my summary of both the meetings. Tech User Group of Markham, Canada Steve Jagadishan is very enthusiastic leader of the Tech User Group. This user group is very new UG and learning all the tricks and treads. UG is still very small and it has only 6 members so far. There are lots of challenges they are facing and we had interesting discussion at Timothy’s Coffee (a famous Canadian coffee chain).... - [SQLAuthority News - Author Visit - Toronto, Canada - Insert Image in Database](https://blog.sqlauthority.com/2009/03/06/sqlauthority-news-author-visit-toronto-canada-insert-image-in-database/): I am traveling to Toronto from Microsoft MVP Sumeet. I will be very tired as I am continuously working very hard from last 27th Feb. I am still Jet Legged from my trip from India to USA and now I am again changing time zones by visiting Canada. I get all my energy from feeling that what I am doing is helping community and I am working hard to help people who are looking for help. Interestingly Steven Biggins, a reader of this blog was with me in same flight to Canada. He recognized me and asked me following question. As... - [SQLAuthority News - MVP Summit 2009 - Day 4 - Keynote of Steve Ballmer](https://blog.sqlauthority.com/2009/03/05/sqlauthority-news-mvp-summit-2009-day-4-keynote-of-steve-ballmer/): An action pack day with lots of tech session and 4 back to back Keynote sessions is over. Steve Ballmer presented one of the keynote where all attendees really felt energetic. Steve is the person who has so much energy that may be 16 year old kid feel older in front of him. Just like his style, he came in and took over complete session under his charm. I really wish, I could have shared more information but due to NDA I can not share it. It was explicitly expressed that photographs are allowed to take and publish so I am... - [SQLAuthority News - MVP Summit 2009 - Day 3 - Party Day and SQL Celebrity Photos](https://blog.sqlauthority.com/2009/03/04/sqlauthority-news-mvp-summit-2009-day-3-party-day-and-sql-celebrity-photos/): Today was the third day of MVP Summit 2009 and it was wonderful. I had my dream come true as I was able to meet Kalen Delaney – a legendary author of SQL Server and truly living SQL God. If I had not met her today, my trip to USA would have not been complete. I am awaiting for famous book Microsoft SQL Server 2008 Internals (Pro – Developer) to release and I will be the first one to purchase for sure. I really wish if I can get early copy of the book as I just can not wait for... - [SQLAuthority News - MVP Summit 2009 - Day 2 - Most Contributing MVP of Year](https://blog.sqlauthority.com/2009/03/03/sqlauthority-news-mvp-summit-2009-day-2-most-contributing-mvp-of-year/): Day 2 of MVP Summit 2009 was filled with Back to Back Technical session. However, due to NDA I will be not able to share the details about the session. I even verified that I can not even post the title of the session which I have attended. I can only talk general details about the event. In one line – “It is one GREAT event!” Interested readers can read about MVP event schedule here : Agenda of Microsoft MVP Summit 2009. It was the best day for me as I was chosen to have honor by fellow MVP for one... - [SQLAuthority News - MVP Summit 2009 - Day 1 - Summit Welcome and Keynotes](https://blog.sqlauthority.com/2009/03/02/sqlauthority-news-mvp-summit-2009-day-1-summit-welcome-and-keynotes/): My regular blog readers must be aware of my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today was day 1 of MVP Summit and we had started it with big gala event. In morning few of Indian MVP visited Seattle Space Needle and had too much fun there. The Space Needle is a tower in Seattle, Washington, but similar to the one in tokyo, Japan, and is a major landmark of the Pacific Northwest region of the United States and a symbol of Seattle. Located at the Seattle Center, it was built for... - [SQLAuthority News - MVP Summit 2009 - Day 0 - About Pinal Dave](https://blog.sqlauthority.com/2009/03/01/sqlauthority-news-mvp-summit-2009-day-0-about-pinal-dave/): Today is first day of MVP Summit 2009 in Seattle and I am very excited to attend it. This is first time I am in Seattle and I am really liking it. I am planning to visit Seattle Needle and Starbucks coffee shops. One question I have received many times so far is Where am I am from? and once I answer that question I get follow up question about Why I did so? Let me answer this question on my blog today so my readers know about it. I am currently located in Ahmedabad, Gujarat, India and working as SQL... - [SQLAuthority News - MVP Summit 2009 - Database Industry Discussion - Live From London Airport and Sheraton Seattle](https://blog.sqlauthority.com/2009/02/28/sqlauthority-news-mvp-summit-2009-database-industry-discussion-live-from-london-airport-and-sheraton-seattle/): My regular blog readers must be aware of my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today I have very interesting day and my tour has converted to technical discussion from the airport itself. I accidentally met my friend and fellow MVP as well SQL Server Expert Suprotim Agarwal at Mumbai Airport. We will be traveling all the way to Seattle together in same flights. Suprotim is wonderful person to meet as a top notch tech geek of India. We both have same interest and love for technologies. We discussed many tech related... - [SQLAuthority News - MVP Summit 2009 - Journey Begins](https://blog.sqlauthority.com/2009/02/27/sqlauthority-news-mvp-summit-2009-journey-begins/): I will be blogging actively about my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today I will be leaving for Mumbai. I will be at Mumbai International Airport between 10 PM to 2 AM. If you are traveling and in Mumbai during this four hours, let us meet and talk about Microsoft and SQL Server. I already have received couple of email from SQL Enthusiastics who will be coming to Airport to meet me, so look for 3-4 people sitting gather looking at Dell XPS and having fun. While I am traveling to... - [SQL SERVER - 2008 - Find Relationship of Foreign Key and Primary Key using T-SQL - Find Tables With Foreign Key Constraint in Database](https://blog.sqlauthority.com/2009/02/26/sql-server-2008-find-relationship-of-foreign-key-and-primary-key-using-t-sql-find-tables-with-foreign-key-constraint-in-database/): While searching for how to find Primary Key and Foreign Key relationship using T-SQL, I came across my own blog article written earlier SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database. It is really handy script and not found written on line anywhere. This is one really unique script and must be bookmarked. There may be situations when there is need to find out on relationship between Primary Key and Foreign Key. I have modified my previous script to add schema name along with table name. It would be really great if any of you can... - [The Poll - What is Your Favorite Database?](https://blog.sqlauthority.com/2009/02/25/the-poll-what-is-your-favorite-database/): What is Your Favorite Database? - [SQLAuthority News - Author Visit - MVP Global Summit 2009 - Seattle and Redmond](https://blog.sqlauthority.com/2009/02/24/sqlauthority-news-author-visit-mvp-global-summit-2009-seattle-and-redmond/): MVP Global Summit 2009 is just a less than a week away and I am very all ready for attending my first MVP Global Summit. Microsoft Most Valuable Professionals (MVPs) are invited to attend the MVP Global Summit at the Washington State Convention & Trade Center in Seattle and at Microsoft headquarters in Redmond, Washington, from March 1 through 4. This year’s event promises to provide opportunities for MVPs to network and socialize with their technical peers, build stronger relationships with Microsoft product teams, and represent their communities by sharing real world insight and feedback. Following is my travel itinerary: Feb... - [SQL SERVER - Disable Windows Authentication - Remove Windows Authentication Login Account](https://blog.sqlauthority.com/2009/02/24/sql-server-disable-windows-authentication-remove-windows-authentication-login-account/): I just received following email from one of the blog reader. Question : “How to disable Windows Authentication?” Answer : It can not be disabled. Windows Authentication is the most secure way to login in system. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad User Group Meeting February 21 2009](https://blog.sqlauthority.com/2009/02/23/sqlauthority-news-ahmedabad-user-group-meeting-february-21-2009-2/): We had Ahmedabad SQL Server User Group meeting on February 21, 2009 and it was wonderful to see so many people showing up for meeting. Gradually our group is growing and more and more developers and DBA are showing up. We had two session in this meeting. From the feedback which we have received I can say that it went excellent and developer loved it. In fact there was request to repeat similar kind of sessions to continue. We had started the session little earlier based on attendee’s feedback at 6:15. The agenda of our meeting today was as following. Interesting... - [SQL SERVER - Download - Microsoft SQL Server 2008 Management Studio Express](https://blog.sqlauthority.com/2009/02/22/sql-server-download-microsoft-sql-server-2008-management-studio-express/): Microsoft SQL Server 2008 Management Studio Express is a free, integrated environment for accessing, configuring, managing, administering, and developing all components of SQL Server. SQL Server 2008 Management Studio Express combines a broad group of graphical tools with a number of rich script editors to provide access to SQL Server to developers and administrators of all skill levels. Download – Microsoft SQL Server 2008 Management Studio Express Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - My Observation - Effect of Clustered Index over Nonclustered Index](https://blog.sqlauthority.com/2009/02/21/sql-server-observation-effect-clustered-index-nonclustered-index/): Note: This article is re-write of my previous article SQL SERVER – Observation – Effect of Clustered Index over Nonclustered Index. I have received so many request that re-write it as it is little confusing. I am going to re-write this with simpler words. Query optimization is one art which is difficult to master. Just like any other art this requires creativity and imagination as well understanding of subject matter. Let us look at interesting observation which I came across. First of all download the script from here and run it in SSMS. Now enable Execution Plan (Using CTRL + M)... - [SQLAuthority News - Ahmedabad User Group Meeting February 21 2009](https://blog.sqlauthority.com/2009/02/20/sqlauthority-news-ahmedabad-user-group-meeting-february-21-2009/): It is my pleasure to announce that SQL Server User Group Meeting is held on February 21, 2009. This is the second meeting of year 2009 and will be one interesting meeting as we will have back to back two presentation from SQL Experts. The agenda of meeting will be as following. Working with IDENTITY values in SQL Server – Jacob Sebastian (SQL Server MVP) Interesting Observation – SQL Server Index Usage – Pinal Dave (SQL Server MVP) I encourage every SQL enthusiastic in city to attend this meeting as this will be one memorable event. From this month onwards we... - [SQL SERVER - Disabling Indexes - Non Clustered Indexes](https://blog.sqlauthority.com/2009/02/19/sql-server-disabling-indexes-non-clustered-indexes/): I came across a fantastic T-SQL script that offers an additional feature for changing the recovery mode while enabling and disabling indexes. - [SQLAuthority Author Visit - A True Outsourcing Giant and Technology Leader DigiCorp in Ahmedabad India](https://blog.sqlauthority.com/2009/02/18/sqlauthority-author-visit-a-true-outsourcing-giant-and-technology-leader-digicorp-in-ahmedabad-india/): Last week, I happen to visit one of the tech company in Ahmedabad, India. I visit different IT organization for two purpose – learn more about technology advancement in different organization and help them with any issues if they are facing with Microsoft technology and in particular SQL Server. I visited DigiCorp Information Systems Pvt. Ltd. and I was impressed by its technological advancement and exposure to cutting edge technology. DigiCorp was founded in Jan 2004 and now maintains between 60 and 70 employees in bustling Ahmedabad, India. The company specializes in customized application development in .NET, PHP, Windows Mobile, iPhone... - [SQL SERVER - Find Current Location of Data and Log File of All the Database](https://blog.sqlauthority.com/2009/02/17/sql-server-find-current-location-of-data-and-log-file-of-all-the-database/): As I am doing lots of experiments on my SQL Server test box, I sometime gets too many files in SQL Server data installation folder – the place where I have all the .mdf and .ldf files are stored. I often go to that folder and clean up all unnecessary files I have left there taking up my hard drive space. I run following query to find out which .mdf and .ldf files are used and delete all other files. If your SQL Server is up and running OS will not let you delete .mdf and .ldf files any way giving... - [SQL SERVER - List All Server Wide Configurations Values](https://blog.sqlauthority.com/2009/02/16/sql-server-list-all-server-wide-configurations-values/): Just a day ago, while working on one of the project, I needed to see what is the two digit year cutoff of my current SQL Server. I did not remember what was the exact syntax to search for the same so I ran following query to list all server wide configurations. While looking at quickly I found out value of two digit year cutoff on line 19th. A small but very important script to save for getting server information. - [SQL SERVER - Reasons to Backup Master Database - Why Should Master Database Backedup](https://blog.sqlauthority.com/2009/02/15/sql-server-reasons-to-backup-master-database-why-should-master-database-backedup/): The most interesting thing about writing blog at SQLAuthority.com is follow up question. Just a day before I wrote article about SQL SERVER – Restore Master Database – An Easy Solution, right following it, I received email from user requesting reason for importance of backing up master database. Master database contains all the system level information of server. Information about all the login account, system configurations and information required to access all the other database are stored in master database. If master database is damaged, it will be difficult to use any other database in SQL Server and that makes it... - [SQL SERVER - Restore Master Database - An Easy Solution](https://blog.sqlauthority.com/2009/02/14/sql-server-restore-master-database-an-easy-solution/): Today we will go over two step easy method to restore ‘master’ database. It is really unusal to have need of restoring the master database. In very rare situation this need should arises. It is important to have full backup of master database, without full backup file of master database it can not be restored. It is necessary to start SQL Server in single user mode before master database can be restored. It is very easy to start SQL Server server in single user mode. Follow the tutorial SQL SERVER – Start SQL Server Instance in Single User Mode. Once SQL... - [SQL SERVER - Simple Example of Reading XML File Using T-SQL](https://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/): In one of the previous article we have seen how we can create XML file using SELECT statement SQL SERVER – Simple Example of Creating XML File Using T-SQL. Today we will see how we can read the XML file using the SELECT statement. Following is the XML which we will read using T-SQL: Following is the T-SQL script which we will be used to read the XML: DECLARE @MyXML XML SET @MyXML = '<SampleXML> <Colors> <Color1>White</Color1> <Color2>Blue</Color2> <Color3>Black</Color3> <Color4 Special="Light">Green</Color4> <Color5>Red</Color5> </Colors> <Fruits> <Fruits1>Apple</Fruits1> <Fruits2>Pineapple</Fruits2> <Fruits3>Grapes</Fruits3> <Fruits4>Melon</Fruits4> </Fruits> </SampleXML>' SELECT a.b.value(‘Colors[1]/Color1[1]’,‘varchar(10)’) AS Color1, a.b.value(‘Colors[1]/Color2[1]’,‘varchar(10)’) AS Color2, a.b.value(‘Colors[1]/Color3[1]’,‘varchar(10)’) AS Color3, a.b.value(‘Colors[1]/Color4[1]/@Special’,‘varchar(10)’)+‘ ‘+ +a.b.value(‘Colors[1]/Color4[1]’,‘varchar(10)’)... - [SQL SERVER - Simple Example of Creating XML File Using T-SQL](https://blog.sqlauthority.com/2009/02/12/sql-server-simple-example-of-creating-xml-file-using-t-sql/): I always want to learn SQL Server and XML file. Let us go over a very simple example, today about how to create XML using SQL Server. - [SQL SERVER - Technical Articles - Performance Optimizations for the XML Data Type in SQL Server 2005](https://blog.sqlauthority.com/2009/02/11/sql-server-technical-articles-performance-optimizations-for-the-xml-data-type-in-sql-server-2005/): I always wanted to learn XML and its usage. My friend and fellow MVP Jacob Sebastian is expert in XML, so if you are interested in XML please visit his blog here. If you are interested in performance optimization for XML Data type in SQL Server following article is must read for you. Performance Optimizations for the XML Data Type in SQL Server 2005 by  Shankar Pal, Babu Krishnaswamy, Vasili Zolotov, and Leo Giakoumakis – Microsoft Corporation Articles covers following subjects. Introduction Data Modeling with the XML Data Type Bulk Loading XML Data Indexing XML Data Query and Data Modification Conclusion... - [SQL SERVER - Start SQL Server Instance in Single User Mode](https://blog.sqlauthority.com/2009/02/10/sql-server-start-sql-server-instance-in-single-user-mode/): There are certain situation when user wants to start SQL Server Engine in “single user” mode from the start up. To start SQL Server in single user mode is very simple procedure as displayed below. Go to SQL Server Configuration Manager and click on  SQL Server 2005 Services. Click on desired SQL Server instance and right click go to properties. On the Advance table enter param ‘-m;‘ before existing params in Startup Parameters box. Make sure that you entered semi-comma after -m. Once that is completed, restart SQL Server services to take this in effect. Once this is done, now you... - [SQL SERVER - 2008 - Download Microsoft SQL Server 2008 Express with Tools Free](https://blog.sqlauthority.com/2009/02/09/sql-server-2008-download-microsoft-sql-server-2008-express-with-tools-free/): Note: Download Microsoft SQL Server 2008 Express with Tools Free by Microsoft SQL Server 2008 Express Edition was much awaited version of SQL Server 2008. It is FREE and available to download from web. Microsoft SQL Server 2008 Express with Tools (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes graphical management tools. SQL Server 2008 Express provides powerful and reliable data management tools and rich features, data protection, and fast performance. It is ideal for small server applications and local data stores. SQL Server 2008 Express with Tools has all of the features in... - [SQL SERVER - 2008 - Server Consolidation WhitePaper Download](https://blog.sqlauthority.com/2007/10/28/sql-server-2008-server-consolidation-whitepaper-download/): Server Consolidation with SQL Server 2008 Writer: Martin Ellis Reviewer: Prem Mehra,Lindsey Allen, Tiffany Wissner, Sambit Samal Published: March 2009 Microsoft SQL Server 2008 supports multiple options for server consolidation, which provides organizations with the flexibility to choose the consolidation approach that best meets their requirements to centralize data services management and reduce hardware and maintenance costs. By providing centralized management, auditing, and monitoring capabilities, SQL Server 2008 makes it easy to manage multiple databases and data services, which significantly reduces administrative overheads in large enterprises. Finally, SQL Server 2008 provides the reassurance of industry-leading performance and scalability, and unprecedented control... - [SQL SERVER - 2005 - Get Current User - Get Logged In User](https://blog.sqlauthority.com/2007/10/27/sql-server-2005-get-current-user-get-logged-in-user/): Interesting enough Jr. DBA asked me how he can get current user for any particular query is ran. He said he wants it for debugging purpose as well for security purpose. I totally understand the need of this request. Knowing the current user can be extremely helpful in terms of security. To get current user run following script in Query Editor SELECT SYSTEM_USER SYSTEM_USER will return current user. From Book On-Line – SYSTEM_USER returns the name of the currently executing context. If the EXECUTE AS statement has been used to switch context, SYSTEM_USER returns the name of the impersonated context. Reference... - [SQL SERVER - Deterministic Functions and Nondeterministic Functions](https://blog.sqlauthority.com/2007/10/26/sql-server-deterministic-functions-and-nondeterministic-functions/): Deterministic functions always returns the same output result all the time it is executed for same input values. i.e. ABS, DATEDIFF, ISNULL etc. Nondeterministic functions may return different results each time they are executed. i.e. NEWID, RAND, @@CPU_BUSY etc. Functions that call extended stored procedures are nondeterministic. User-defined functions that create side effects on the database are not recommended. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Forced Parameterization and Simple Parameterization - T-SQL and SSMS](https://blog.sqlauthority.com/2007/10/25/sql-server-2005-forced-parameterization-and-simple-parameterization-t-sql-and-ssms/): SQL Server compiles query and saves the procedures cache plans in the database. When the same query is called it uses compiled execution plan which improves the performance by saving compilation time. Queries which are parametrized requires less recompilation and dynamically built queries needs compilations and recompilation very frequently. Forced parameterization may improve the performance of certain databases by reducing the frequency of query compilations and recompilations. Database which has high volumes of the queries can be most benefited from this feature. When the PARAMETERIZATION option is set to FORCED, any literal value that appears in a SELECT, INSERT, UPDATE or... - [SQL SERVER - Simple Example of WHILE Loop With CONTINUE and BREAK Keywords](https://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/): I have tried to explain the usage of simple WHILE loop in the first example. BREAK keywords will exit the stop the while loop and control is moved. - [SQL SERVER - Get Permissions of My Username / Userlogin on Server / Database](https://blog.sqlauthority.com/2007/10/23/sql-server-get-permissions-of-my-username-userlogin-on-server-database/): A few days ago, I was invited to one of the largest database company. I was asked to review database schema and propose changes to it. There was special username or user logic was created for me, so I can review their database. I was very much interested to know what kind of permissions I was assigned per server level and database level. I did not feel like asking their Sr. DBA the question about permissions. - [SQL SERVER - Difference Between @@Version and xp_msver - Retrieve SQL Server Information](https://blog.sqlauthority.com/2007/10/22/sql-server-difference-between-version-and-xp_msver-retrieve-sql-server-information/): Just a day ago, I was asked which SQL Server version I am using. I said SQL Server 2005. However, the person I was talking was looking for more information then that. He requested more detail about the version. I responded with SQL Server 2005 Service Pack 2. After the discussion was over I thought there must be some global variable which brings back this information. I took guess and typed following command in SQL Query Editor SELECT @@Version 'SQL Version' I was really glad when it worked and returned following result. Resultset: Microsoft SQL Server 2005 – 9.00.3054.00 (Intel X86)... - [SQL SERVER - 2005 - Limitation of Online Index Rebuld Operation](https://blog.sqlauthority.com/2007/10/21/sql-server-2005-limitation-of-online-index-rebuld-operation/): Just a day ago, during one interview question of Online Indexing come up. I really enjoy discussing this issue as I was talking with candidate who was very smart. Following two questions were discussed. 1) What is Online Index Rebuild Operation? Online operation means when online operations are happening the database are in normal operational condition, the processes which are participating in online operations does not require exclusive access to database. Read about this in-depth in my previous article SQL SERVER – 2005 – Explanation and Script for Online Index Operations – Create, Rebuild, Drop 2) What are the limitation of... - [SQL SERVER - Set Server Level FILLFACTOR Using T-SQL Script](https://blog.sqlauthority.com/2007/10/20/sql-server-set-server-level-fillfactor-using-t-sql-script/): As the title is very clear what this post is about I will not write long description. I have listed definition of FILLFACTOR from BOL here. - [SQL SERVER - Types of DBCC Commands When Used as Database Console Commands](https://blog.sqlauthority.com/2007/10/19/sql-server-types-of-dbcc-commands-when-used-as-database-console-commands/): Just a day ago, while discussing some SQL issues with one of the Sr. Database Administrator in India, we end up discussing DBCC as Database Console Commands when used as T-SQL. We both tried to remember what are the types of DBCC as Database Console Commands and could not come up with more than two types, however we both knew there are four. When the conversation was over, I looked up MSDN for the types of the DBCC. I found following documentation here. There are four types of the Database Console Commands. Maintenance Maintenance tasks on a database, index, or filegroup.... - [SQL SERVER - 2005 - Fix : Error : Msg 7411, Level 16, State 1 Server is not configured for RPC](https://blog.sqlauthority.com/2007/10/18/sql-server-2005-fix-error-msg-7411-level-16-state-1-server-is-not-configured-for-rpc/): Error : Msg 7411, Level 16, State 1 Server is not configured for RPC This was annoying error which was fixed by Jr. DBA, whom I am personally training at my organization. I think he is going to be great programmer. He worked in my organization for more than 8 months. I finally have decided to coach him myself. When I encountered this error, I gave him task to figure this out himself. I absolutely gave him no direction and very few min to fix this problem. As you might have guessed without using internet help (as there is no help... - [SQLAuthority News - Book Review - Backup & Recovery (Paperback)](https://blog.sqlauthority.com/2007/10/17/sqlauthority-news-book-review-backup-recovery-paperback/): Backup & Recovery [ILLUSTRATED] (Paperback) by W. Curtis Preston (Author) Link to Amazon Short Summary: This book’s does not only teaches you have to create safe backup but it takes you to the next level where a large organization can save tons of dollars a year by making their backup and restore faster and more reliable process. Detail Summary: Backup and Recovery is the most interesting subject to me. I have always enjoyed reading and writing about this subject. I personally believe that without proper backup and ability to restore the backup to recover the system to original state, any organization... - [SQL SERVER - Three T-SQL Script to Create Primary Keys on Table](https://blog.sqlauthority.com/2007/10/16/sql-server-three-t-sql-script-to-create-primary-keys-on-table/): I have always enjoyed writing about three topics Constraint and Keys, Backup and Restore and Datetime Functions. Primary Keys constraints prevents duplicate values for columns and provides unique identifier to each column, as well it creates clustered index on the columns. -- Primary Key Constraint upon Table Created Method 1 USE AdventureWorks GO CREATE TABLE ConstraintTable (ID INT CONSTRAINT Ct_ID PRIMARY KEY, ColSecond INT) GO --Clean Up DROP TABLE ConstraintTable GO -- Primary Key Constraint upon Table Created Method 2 USE AdventureWorks GO CREATE TABLE ConstraintTable (ID INT, ColSecond INT, CONSTRAINT Ct_ID PRIMARY KEY (ID)) GO --Clean Up DROP TABLE ConstraintTable... - [SQL SERVER - 2005 - Driver for PHP Community Technology Preview (October 2007)](https://blog.sqlauthority.com/2007/10/16/sql-server-2005-driver-for-php-community-technology-preview-october-2007/): In its continued commitment to interoperability, Microsoft has released a new SQL Server 2005 Driver for PHP. The SQL Server 2005 Driver for PHP Community Technology Preview (CTP) download is available to all SQL Server users at no additional charge. The SQL Server 2005 Driver for PHP is a PHP 5 extension that allows for the reading and writing of SQL Server data from within PHP scripts. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2000. How to install driver 1. Download sqlsrv-for-php_version_language.exe to a temporary directory. 2. Run sqlsrv-for-php_version_language.exe.... - [SQL SERVER - Explanation and Understanding NOT NULL Constraint](https://blog.sqlauthority.com/2007/10/15/sql-server-explanation-and-understanding-not-null-constraint/): NOT NULL is integrity CONSTRAINT. It does not allow creating of the row where column contains NULL value. Most discussed question about NULL is what is NULL? I will not go in depth analysis it. Simply put NULL is unknown or missing data. When NULL is present in database columns, it can affect the integrity of the database. I really do not prefer NULL in database unless they are absolutely necessary. (Please make sure it is just my preference, and I use NULL it is absolutely needed). To prevent nulls to be inserted in the database, table should have NOT NULL... - [SQL SERVER - Three Rules to Use UNION](https://blog.sqlauthority.com/2007/10/14/sql-server-three-rules-to-use-union/): I have previously written two articles on UNION and they are quite popular. I was reading SQL book Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes By Ben Forta and I came across three rules of UNION and I felt like mentioning them here. UNION RULES A UNION must be composed of two or more SELECT statements, each separated by the keyword UNION. Each query in a UNION must contain the same columns, expressions, or aggregate functions, and they must be listed in the same order. Column datatypes must be compatible: They need not be the same exact same... - [SQL SERVER - 2005 - SQL Server Surface Area Configuration Tool Examples and Explanation](https://blog.sqlauthority.com/2007/10/13/sql-server-2005-sql-server-surface-area-configuration-tool-examples-and-explanation/): Microsoft has turned off all the potential features of SQL Server 2005 that could be susceptible to security risks and hacker attacks. Many features of SQL Server 2005 i.e. xp_cmdshell, DAC etc comes disabled by default, this makes the vulnerable surface area less visible to potential attacks. The Surface Area Configuration tool provides DBAs with a single, easy-to-use method of configuring external security of SQL Server. Use SQL Server Surface Area Configuration to enable, disable, start, or stop the features, services, and remote connectivity of your SQL Server 2005 installations. You can use SQL Server Surface Area Configuration on local and... - [SQL SERVER - Pre-Code Review Tips - Tips For Enforcing Coding Standards](https://blog.sqlauthority.com/2007/10/12/sql-server-pre-code-review-tips-tips-for-enforcing-coding-standards/): Each organization has its own coding standards and enforcement rules. It is sometime difficult for DBAs to change the code following code review, as it may affect many different layers of the application. In large organizations, many stored procedures are written and modified every day. It is smart to keep watch on all stored procedures, at frequent intervals, before code comes to final code review. Pre-code reviewing in this manner will save lots of time. I run a few scripts every day to check the status of all the stored procedures on our development server. Doing so gives me a good... - [SQL SERVER - T-SQL Script to Add Clustered Primary Key](https://blog.sqlauthority.com/2007/10/11/sql-server-t-sql-script-to-add-clustered-primary-key/): Jr. DBA asked me three times in a day, how to create Clustered Primary Key. I gave him following sample example. That was the last time he asked “How to create Clustered Primary Key to table?” USE [AdventureWorks] GO ALTER TABLE [Sales].[Individual] ADD CONSTRAINT [PK_Individual_CustomerID] PRIMARY KEY CLUSTERED ( [CustomerID] ASC ) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF vs. Stored Procedures and Having vs. WHERE](https://blog.sqlauthority.com/2007/10/10/sql-server-udf-vs-stored-procedures-and-having-vs-where/): Read my First Article in SQL Server Magazine – Oct 2007 [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Sample Example of RANKING Functions - ROW_NUMBER, RANK, DENSE_RANK, NTILE](https://blog.sqlauthority.com/2007/10/09/sql-server-2005-sample-example-of-ranking-functions-row_number-rank-dense_rank-ntile/): I have not written about this subject for long time, as I strongly believe that Book On Line explains this concept very well. SQL Server 2005 has total of 4 ranking function. Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. ROW_NUMBER () OVER ([<partition_by_clause>] <order_by_clause>) Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. RANK () OVER ([<partition_by_clause>] <order_by_clause>) Returns the rank of each row within the partition of a result set. DENSE_RANK () OVER ([<partition_by_clause>]... - [SQL SERVER - 2005 - Connection Property of SQL Server Management Studio SSMS](https://blog.sqlauthority.com/2007/10/08/sql-server-2005-connection-property-of-sql-server-management-studio-ssms/): Following images quickly explain how to connect to SQL Server with different connection property. It can be useful when connection properties need to be changed for SQL Server when connected. I use this in my company when I connect to one of our servers using named pipes instead of TCP/IP. Let us learn about Connection Property of SQL Server Management Studio SSMS. - [SQLAuthority News - Latest Interesting Downloads and Articles](https://blog.sqlauthority.com/2007/10/07/sqlauthority-news-latest-interesting-downloads-and-articles/): White Paper: Precision Considerations for Analysis Services Users This white paper covers accuracy and precision considerations in SQL Server 2005 Analysis Services. For example, it is possible to query Analysis Services with similar queries and obtain two different answers. While this appears to be a bug, it actually is due to the fact that Analysis Services caches query results and the imprecision that is associated with approximate data types. This white paper discusses how these issues manifest themselves, why they occur, and best practices to minimize their effect. Microsoft SQL Server 2005 JDBC Driver 1.1 In its continued commitment to interoperability,... - [SQL SERVER - Executing Remote Stored Procedure - Calling Stored Procedure on Linked Server](https://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure-calling-stored-procedure-on-linked-server/): I was going through comments on various posts to see if I have missed to answer any comments. I realized that there are quite a few times I have answered question which discuss about how to call stored procedure or query on linked server or another server. This is very detailed topic, I will keep it very simple. I am making assumptions that remote server is already set up as linked server with proper permissions in application and network is arranged. Method 1 : Remote Stored Procedure can be called as four part name: Syntax: EXEC [RemoteServer] .DatabaseName.DatabaseOwner.StoredProcedureName ‘Params’ Example: EXEC... - [SQL SERVER - 2005 - Open SSMS From Command Prompt - sqlwb.exe Example](https://blog.sqlauthority.com/2007/10/05/sql-server-2005-open-ssms-from-command-prompt-sqlwbexe-example/): This article is written by request and suggestion of Sr. Web Developer at my organization. Due to nature of this article most of the content are referred from Book On-Line. sqlwb command prompt utility which opens SQL Server Management Studio. sqlwb command does not run queries from command prompt. sqlcmd utility runs queries from command prompt, read for more information. The syntax of this sqlwb is very simple. I will copy complete syntax from BOL here : sqlwb [scriptfile] [projectfile] [solutionfile] [-S servername] [-d databasename] [-U username] [-P password] [-E] [-nosplash] [-?] I use following script very frequently. 1) Open SQL... - [SQL SERVER - 2005 - Different Types of Cache Objects](https://blog.sqlauthority.com/2007/10/04/sql-server-2005-different-types-of-cache-objects/): About two months ago I reviewed book SQL Server 2005 Practical Troubleshooting: The Database Engine. Yesterday I received a request from reader, if I can write something from this book, which is not common knowledge in DBA community. I really like the idea, however I must respect the Authors copyright about this book. This book is unorthodox SQL book, it talks about things which can get you to fix your problem faster, if problem is discussed in book. There are few places it teaches behind the scene SQL stories. - [SQL SERVER - 2005 - Explanation of TRY…CATCH and ERROR Handling With RAISEERROR Function](https://blog.sqlauthority.com/2007/10/03/sql-server-2005-explanation-of-trycatch-and-error-handling-with-raiseerror-function/): One of the developer at my company thought that we can not use RAISEERROR function in new feature of SQL Server 2005 TRY…CATCH. When asked for explanation he suggested SQL SERVER – 2005 Explanation of TRY…CATCH and ERROR Handling article as excuse suggesting that I did not give example of RAISEERROR with TRY…CATCH. We all thought it was funny. Just to keep record straight, TRY…CATCH can sure use RAISEERROR function. First read original article for additional information about how TRY…CATCH works with ERROR codes. SQL SERVER – 2005 Explanation of TRY…CATCH and ERROR Handling Example 1 : Simple TRY…CATCH without RAISEERROR... - [SQL SERVER - Find Name of The SQL Server Instance](https://blog.sqlauthority.com/2007/10/02/sql-server-find-name-of-the-sql-server-instance/): Few days ago, there was complex condition when we had one database on two different server. We were migrating database from one server to another server using nightly backup and restore. Based on database server stored procedures has to run different logic. We came up with two different solutions. 1) When database schema is very much changed, we wrote completely new stored procedure and deprecated older version once it was not needed. 2) When logic depended on Server Name we used global variable @@SERVERNAME. It was very convenient while writing migrating script which depended on server name for the same database.... - [SQL SERVER - 2005 - OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE](https://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/): SQL Server 2005 has new OUTPUT clause, which is quite useful. OUTPUT clause has accesses to inserted and deleted tables (virtual tables) just like triggers. OUTPUT clause can be used to return values to client clause. OUTPUT clause can be used with INSERT, UPDATE, or DELETE to identify the actual rows affected by these statements. OUTPUT clause can generate table variable, a permanent table, or temporary table. Even though, @@Identity will still work in SQL Server 2005, however I find OUTPUT clause very easy and powerful to use. Let us understand OUTPUT clause using example. ———————————————————————————————————————— —-Example 1 : OUTPUT clause... - [SQL SERVER - 2005 Query Editor - Microsoft SQL Server Management Studio](https://blog.sqlauthority.com/2007/09/30/sql-server-2005-query-editor-microsoft-sql-server-management-studio/): This post may be very simple for most of the users of SQL Server 2005. Earlier this year, I have received one question many times – Where is Query Analyzer in SQL Server 2005? I wrote small post about it and pointed many users to that post – SQL SERVER – 2005 Query Analyzer – Microsoft SQL SERVER Management Studio. Recently I have been receiving similar question. Where is Query Editor in SQL Server 2005? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). I have been pointing my users to my... - [SQL SERVER - Two Connections Related Global Variables Explained - @@CONNECTIONS and @@MAX_CONNECTIONS](https://blog.sqlauthority.com/2007/09/29/sql-server-two-connections-related-global-variables-explained-connections-and-max_connections/): Few days ago, I was searching MSDN and I stumbled upon following two global variables. Following variables are very briefly explained in the BOL. I have taken their definition from BOL and modified BOL example to displayed both the global variable together. @@CONNECTIONS Returns the number of attempted connections, either successful or unsuccessful since SQL Server was last started. @@MAX_CONNECTIONS Returns the maximum number of simultaneous user connections allowed on an instance of SQL Server. The number returned is not necessarily the number currently configured. @@MAX_CONNECTIONS is the maximum number of connections allowed simultaneously to the server. @@CONNECTIONS is incremented with... - [SQL SERVER - Introduction and Example for DATEFORMAT Command](https://blog.sqlauthority.com/2007/09/28/sql-server-introduction-and-example-for-dateformat-command/): While doing surprise code review of Jr. DBA I found interesting syntax DATEFORMAT. This keywords is very less used as CONVERT and CAST can do much more than this command. It is still interesting to learn about learn about this new syntax. Sets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data. This command allows you to input strings that would normally not be recognized by SQL server as dates. The SET DATEFORMAT command lets you specify order of data parts. The options for DATEFORMAT are mdy, dmy, ymd, ydm, myd, or dym. The default DATEFORMAT is mdy.... - [SQL SERVER - FIX : Error 3154: The backup set holds a backup of a database other than the existing database](https://blog.sqlauthority.com/2007/09/27/sql-server-fix-error-3154-the-backup-set-holds-a-backup-of-a-database-other-than-the-existing-database/): Our Jr. DBA ran to me with this error just a few days ago while restoring the database. Error 3154: The backup set holds a backup of a database other than the existing database. Solution is very simple and not as difficult as he was thinking. He was trying to restore the database on another existing active database. Fix/WorkAround/Solution: 1) Use WITH REPLACE while using the RESTORE command. View Example 2) Delete the older database which is conflicting and restore again using RESTORE command. I understand my solution is little different than BOL but I use it to fix my database... - [SQLAuthority News - Book Review - Programming SQL Server 2005 [ILLUSTRATED]](https://blog.sqlauthority.com/2007/09/26/sqlauthority-news-book-review-programming-sql-server-2005-illustrated/): Programming SQL Server 2005 [ILLUSTRATED] (Paperback) by Bill Hamilton (Author) Link to Amazon User does not have to be experience SQL Server 2005 programmer to use this book; as it is designed for users of all levels. This book also suggests that user does not have to be experienced with SQL Server 2000. However, I disagree with that. This book only covers new features of SQL Server 2005. Understanding of fundamental relational database concepts is helpful to digest and accept the concepts introduced in this book. This book covers following perspective of SQL Server 2005 new features. Tools and utilities Data... - [SQL SERVER - Effect of TRANSACTION on Local Variable - After ROLLBACK and After COMMIT](https://blog.sqlauthority.com/2007/09/25/sql-server-effect-of-transaction-on-local-variable-after-rollback-and-after-commit/): Few days ago, one of the Jr. Developer asked me this question (What will be the Effect of TRANSACTION on Local Variable – After ROLLBACK and After COMMIT?) while I was rushing to an important meeting. I was getting late so I asked him to talk with his Application Tech Lead. When I came back from meeting both of them were looking for me. They said they are confused. I quickly wrote down following example for them. Example: PRINT 'After ROLLBACK example' DECLARE @FlagINT INT SET @FlagInt = 1 PRINT @FlagInt ---- @FlagInt Value will be 1 BEGIN TRANSACTION SET @FlagInt... - [SQL SERVER - Order of Result Set of SELECT Statement on Clustered Indexed Table When ORDER BY is Not Used](https://blog.sqlauthority.com/2007/09/24/sql-server-order-of-result-set-of-select-statement-on-clustered-indexed-table-when-order-by-is-not-used/): "What will be the order of the result set of a SELECT statement on clustered indexed table when the ORDER BY clause is not used?" - [SQL SERVER - Stored Procedure to Know Database Access Permission to Current User](https://blog.sqlauthority.com/2007/09/23/sql-server-stored-procedure-to-know-database-access-permission-to-current-user/): Jr. DBA in my company only have access to the database which they need to use. Often they try to access database and if they do not have permission they face error. Jr. DBAs always check which database they have access using following system stored procedure. It is very reliable and provides accurate information. Sytanx: EXEC sp_MShasdbaccess GO ResultSet: ( I have listed only one column) AdventureWorks AdventureWorksDW master model msdb MyDB ReportServer ReportServerTempDB tempdb Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Version Information and Additional Information - Extended Stored Procedure xp_msver](https://blog.sqlauthority.com/2007/09/22/sql-server-2005-version-information-and-additional-information-extended-stored-procedure-xp_msver/): I was glad when I discovered this Extended Stored Procedure myself. I always used different syntax to retrieve server information. Many of information I was looking up using system information of the windows operating system. Syntax: EXEC xp_msver ResultSet: Index Name Internal_Value Character_Value —— ——————————– ————– ————————————- 1 ProductName NULL Microsoft SQL Server 2 ProductVersion 589824 9.00.3042.00 3 Language 1033 English (United States) 4 Platform NULL NT INTEL X86 5 Comments NULL NT INTEL X86 6 CompanyName NULL Microsoft Corporation 7 FileDescription NULL SQL Server Windows NT 8 FileVersion NULL 2005.090.3042.00 9 InternalName NULL SQLSERVR 10 LegalCopyright NULL © Microsoft Corp.... - [SQL SERVER - 2005 - Multiple Language Support](https://blog.sqlauthority.com/2007/09/21/sql-server-2005-multiple-language-support/): SQL Server supports multiple languages. Information about all the languages are stored in sys.syslanguages system view. You can run following script in Query Editor and see all the information about each language. Information about Months and Days varies for each language. Syntax: SELECT Alias, * FROM sys.syslanguages ResultSet: (* results not included) Alias ————– English German French Japanese Danish Spanish Italian Dutch Norwegian Portuguese Finnish Swedish Czech Hungarian Polish Romanian Croatian Slovak Slovenian Greek Bulgarian Russian Turkish British English Estonian Latvian Lithuanian Brazilian Traditional Chinese Korean Simplified Chinese Arabic Thai Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : ERROR : 3260 An internal buffer has become full](https://blog.sqlauthority.com/2007/09/20/sql-server-fix-error-3260-an-internal-buffer-has-become-full/): ERROR : 3260 An internal buffer has become full The reason I have picked to write about this error is because we have encountered this error many times in one of our older server. Fix/WorkAround/Solution: We were not able to absolutely reduce this error but following changes helped. 1) Rebooted server if error is happening frequently. 2) Increased RAM to Server. 3) Increased RAM allocation to SQL Server application. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Rename Database to New Name Using Stored Procedure by Changing to Single User Mode](https://blog.sqlauthority.com/2007/09/19/sql-server-rename-database-to-new-name-using-stored-procedure-by-changing-to-single-user-mode/): In my organization we rename the database on development server when are refreshing the development server with live data. We save the old database with new name and restore the database from live with same name. If developer/Jr. DBA have not saved the SQL Script from development server, he/she can go back to old Server and retrieve the script. There are few interesting facts to note when the database is renamed. When renamed the database, filegroup name or filename (.mdf,.ldf) are not changed. User with SA privilege can rename the database with following script when the context of the database is... - [SQLAuthority News - Scale-Out Querying with Analysis Services Using SAN Snapshots](https://blog.sqlauthority.com/2007/09/18/sqlauthority-news-scale-out-querying-with-analysis-services-using-san-snapshots/): White paper describes the use of virtual copy Storage Area Network (SAN) snapshots in a load-balanced scalable querying environment for SQL Server 2005 Analysis Services. This architecture provides the following improvements Improves the utilization of disk resources Optimizes cube processing operations Supports dedicated snapshots for specific users at different points in time In selecting a snapshot implementation for use with for Analysis Services, users may wish to consider the following snapshot attributes: Provisioning of snapshots Writeability of snapshots Scalability of snapshots Performance of snapshots Efficiency of snapshots I have created this article here only to promote the original White Paper, which... - [SQL SERVER - UDF - Validate Positive Integer Function - Validate Natural Integer Function](https://blog.sqlauthority.com/2007/09/18/sql-server-udf-validate-positive-integer-function-validate-natural-integer-function/): Few days ago I wrote SQL SERVER – UDF – Validate Integer Function. It was very interesting to write this and developers at my company started to use it. One Jr. DBA modified this function to validate only positive integers. I will share this with everybody who are interested in similar functionality. Code: CREATE FUNCTION [dbo].[udf_IsNatural] ( @Number VARCHAR(100) ) RETURNS BIT BEGIN DECLARE @Ret BIT IF (PATINDEX('%[^0-9-]%', @Number) = 0 AND CHARINDEX('-', @Number) <= 1 AND @Number NOT IN ('.', '-', '+', '^') AND LEN(@Number)>0 AND @Number NOT LIKE '%-%') SET @Ret = 1 ELSE SET @Ret = 0 RETURN @Ret END GO... - [SQLAuthority News - NASDAQ Uses SQL Server 2005 - Reducing Costs through Better Data Management](https://blog.sqlauthority.com/2007/09/17/sqlauthority-news-nasdaq-uses-sql-server-2005-reducing-costs-through-better-data-management/): I just came across PDF published by Microsoft to promote SQL Server 2005. I find few things very interesting. I will list them here. NASDAQ - [SQL SERVER - Difference Between UPDATE and UPDATE()](https://blog.sqlauthority.com/2007/09/17/sql-server-difference-between-update-and-update/): What is the difference between UPDATE and UPDATE()? UPDATE is syntax used to update the database tables or database views. USE AdventureWorks ; GO UPDATE Production.Product SET ListPrice = ListPrice * 2; GO UPDATE() is used in triggers to check update/insert to the database tables or database views. Returns a Boolean value that indicates whether an INSERT or UPDATE attempt was made on a specified column of a table or view. UPDATE() is used anywhere inside the body of a Transact-SQL INSERT or UPDATE trigger to test whether the trigger should execute certain actions. USE AdventureWorks ; GO CREATE TRIGGER reminder... - [SQLAuthority News - Active Directory Integration Sample Script](https://blog.sqlauthority.com/2007/09/16/sqlauthority-news-active-directory-integration-sample-script/): A sample script that enables you to extract a list of computer names from your custom SQL Server database and add them to an Active Directory security group. The security group can then be referenced in the Agent Assignment and Failover Wizard to automate agent assignments to Management Servers. 1. Queries customer SQL asset database. 2. Populates custom security group with computer accounts of computers returned by the SQL query. Download from MSDN Abstract courtesy : Microsoft Reference :Pinal Dave (https://blog.sqlauthority.com), Text from MSDN - [SQL SERVER - 2005 - List All The Constraint of Database - Find Primary Key and Foreign Key Constraint in Database](https://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/): Following script are very useful to know all the constraint in the database. I use this many times to check the foreign key and primary key constraint in database. This is simple but useful script from my personal archive. USE AdventureWorks; GO SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint, SCHEMA_NAME(schema_id) AS SchemaName, OBJECT_NAME(parent_object_id) AS TableName, type_desc AS ConstraintType FROM sys.objects WHERE type_desc LIKE '%CONSTRAINT' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Pro T-SQL 2005 Programmer's Guide (Paperback)](https://blog.sqlauthority.com/2007/09/15/sqlauthority-news-book-review-pro-t-sql-2005-programmers-guide-paperback/): Pro T-SQL 2005 Programmer’s Guide (Paperback) Book Review - [SQLAuthority News - Random Article from SQLAuthority Blog](https://blog.sqlauthority.com/2007/09/14/sqlauthority-news-random-article-from-sqlauthority-blog/): It has been wonderful writing on this blog. Many times I visit my older articles and read them. One of my favorite feature on WordPress.com (where I host my blog) is Random Article Feature. I use it quite often to land on random page on my blog. It is really good to read articles written previously because there are so many new things to learn as well keep previously learned knowledge refreshed. I have added link to random article in the side bar of this blog. User can click on it to visit random article as well click in the link... - [SQL SERVER - Difference Between EXEC and EXECUTE vs EXEC() - Use EXEC/EXECUTE for SP always](https://blog.sqlauthority.com/2007/09/13/sql-server-difference-between-exec-and-execute-vs-exec-use-execexecute-for-sp-always/): What is the difference between EXEC and EXECUTE? They are the same. Both of them executes stored procedure when called as EXEC sp_help GO EXECUTE sp_help GO I have seen enough times developer getting confused between EXEC and EXEC(). EXEC command executes stored procedure where as EXEC() function takes dynamic string as input and executes them. EXEC('EXEC sp_help') GO Another common mistakes I have seen is not using EXEC before stored procedure. It is always good practice to use EXEC before stored procedure name even though SQL Server assumes any command as stored procedure when it does not recognize the first... - [SQLAuthority News - Scrum: Agile Software Development for Project Management](https://blog.sqlauthority.com/2007/09/12/sqlauthority-news-scrum-agile-software-development-for-project-management/): This is something I have learned while working for so many years as Project Manager. It is not as important to know how things are done but it is important to know how to get things done. Scrum is an Agile Software Development system which helps developers to get project done in reasonable time and with superior quality. Scrum is organized around the following roles: Product Owner – Determines what functionality is needed ScrumMaster – Leads the Scrum and is primarily responsible for making sure the Scrum process is followed and removing impediments that keep the Team from working The Team... - [SQL SERVER - Frequency of SQL Server Reboot and Restart](https://blog.sqlauthority.com/2007/09/11/sql-server-frequency-of-sql-server-reboot-and-restart/): This is very interesting question. I will keep the answer of this question very simple. First of all there is no scientific research or white paper I can backup my results with. Answer contains part simple observation and part experience. There is no need to reboot SQL Server. Once it is on it is ON! However, I have heard that frequent reboot improves performance. In my company our network administration department has policy to reboot all the servers every 15 days. We reboot all the servers at every 15 days. Regarding performance improvement, our servers are always up and running as... - [SQLAuthority News - Book Review - SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills](https://blog.sqlauthority.com/2007/09/11/sqlauthority-news-book-review-sql-server-2005-dba-street-smarts-a-real-world-guide-to-sql-server-2005-certification-skills/): SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills (Paperback) by Joseph L. Jorden Link to Amazon Short Review: Microsoft’s new generation of certifications is design not only to emphasize your proficiency with a specific technology but also to prove you have the skills needed to perform a specific role. This book is developed based on the exam objective of the 70-431, although its purpose is to server more as a reference than just an exam preparation book. Detail Review: This book is designed to give DBAs some insight into the world of typical... - [SQL SERVER - 2005 - White Paper - Integrating Visio 2007 and Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/09/10/sql-server-2005-white-paper-integrating-visio-2007-and-microsoft-sql-server-2005/): This article focuses on integration techniques specific to Microsoft Office Visio 2007 and Microsoft SQL Server 2005. Using Visio 2007, you can connect Visio shapes to data that was generated outside Visio. A large amount of data can be captured in a SQL Analysis Services database. Being able to analyze that data in a visual way enhances the value of the data. In the following example, sales data stored in an Analysis Services cube is used to generate a Visio PivotDiagram so that the data can be explored and graphically enhanced. View Integrating Visio 2007 and Microsoft SQL Server 2005 Reference... - [SQLAuthority News - Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide](https://blog.sqlauthority.com/2007/09/10/sqlauthority-news-job-opportunity-in-ahmedabad-india-to-work-with-technology-leaders-worldwide/): If you have one or more years of experience in any web based programming language (.NET, ColdFusion, PHP) and interested in SQL Server as well willing to locate Ahmadabad, India. Please send me your resume, if selected you may get chance to work with one of the most progressing industry in world as well some smartest technology leaders worldwide. Salary depends on Experience. If selected for interview I suggest you go over SQL Server Interview Questions and Answers Complete List Download, as there is great chance I may be participating in interview. Please send your resume at pinaldave “at” yahoo.com and... - [SQL SERVER - 2005 - Start Stop Restart SQL Server From Command Prompt](https://blog.sqlauthority.com/2007/09/09/sql-server-2005-start-stop-restart-sql-server-from-command-prompt/): Very frequently I use following command prompt script to start and stop default instance of SQL Server. Our network admin loves this commands as this is very easy. Click Start >> Run >> type cmd to start command prompt. Start default instance of SQL Server net start mssqlserver Stop default instance of SQL Server net stop mssqlserver Start and Stop default instance of SQL Server. You can create batch file to execute both the commands together. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF - User Defined Function - Get Number of Days in Month](https://blog.sqlauthority.com/2007/09/08/sql-server-udf-user-defined-function-get-number-of-days-in-month/): Following User Defined Function (UDF) returns the numbers of days in month. It is very simple yet very powerful and full proof UDF. CREATE FUNCTION [dbo].[udf_GetNumDaysInMonth] ( @myDateTime DATETIME ) RETURNS INT AS BEGIN DECLARE @rtDate INT SET @rtDate = CASE WHEN MONTH(@myDateTime) IN (1, 3, 5, 7, 8, 10, 12) THEN 31 WHEN MONTH(@myDateTime) IN (4, 6, 9, 11) THEN 30 ELSE CASE WHEN (YEAR(@myDateTime) % 4 = 0 AND YEAR(@myDateTime) % 100 != 0) OR (YEAR(@myDateTime) % 400 = 0) THEN 29 ELSE 28 END END RETURN @rtDate END GO Run following script in Query Editor: SELECT dbo.udf_GetNumDaysInMonth(GETDATE()) NumDaysInMonth... - [SQL SERVER - Correlated and Noncorrelated - SubQuery Introduction, Explanation and Example](https://blog.sqlauthority.com/2007/09/07/sql-server-correlated-and-noncorrelated-subquery-introduction-explanation-and-example/): A correlated subquery is an inner subquery which is referenced by the main outer query such that the inner query is considered as being executed repeatedly. Example: ----Example of Correlated Subqueries USE AdventureWorks; GO SELECT e.EmployeeID FROM HumanResources.Employee e WHERE e.ContactID IN ( SELECT c.ContactID FROM Person.Contact c WHERE MONTH(c.ModifiedDate) = MONTH(e.ModifiedDate) ) GO A noncorrelated subquery is subquery that is independent of the outer query and it can executed on its own without relying on main outer query. Example: ----Example of Noncorrelated Subqueries USE AdventureWorks; GO SELECT e.EmployeeID FROM HumanResources.Employee e WHERE e.ContactID IN ( SELECT c.ContactID FROM Person.Contact c... - [SQL SERVER - 2005 - Introduction and Explanation to sqlcmd](https://blog.sqlauthority.com/2007/09/06/sql-server-2005-introduction-and-explanation-to-sqlcmd/): I decided to write this article to respond to request of one of usergroup, which requested that they would like to learn sqlcmd 101. SQL Server 2005 has introduced new utility sqlcmd to run ad hoc Transact-SQL statements and scripts from command prompt. T-SQL commands are entered in command prompt window and result is displayed in the same window, unless result set are sent to output files. sqlcmd can execute single T-SQL statement as well as batch file. sqlcmd utility can connect to earlier versions of SQL Server as well. The sqlcmd utility uses the OLE DB provider to execute T-SQL... - [SQLAuthority News - SQL SERVER 2008 CTP 4 Released](https://blog.sqlauthority.com/2007/09/06/sqlauthority-news-sql-server-2008-ctp-4-released/): SQL Server 2008 CTP 4 is released as a pre-configured VHD. This allows you to trial SQL Server 2008 CTP 4 in a virtual environment. Download SQL Server 2008 CTP 4 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Valid SQL Error](https://blog.sqlauthority.com/2007/09/05/sql-server-sql-joke-sql-humor-sql-laugh-valid-sql-error/): Yesterday I had posted my 300th post and I missed the announcement. One of my reader sent me following Image in email congratulating SQLAuthority blog for completing 300th post and also informing me that it has been long time I have posted something funny. I have written few articles about frequent SQL Server Errors on this blog. He suggested that this humorous images goes along with it. If you know source of this image please let me know I would like to include that. Visit more SQL Server Humors. Reference : Pinal Dave (https://blog.sqlauthority.com) , Need original reference for image. - [SQLAuthority News - Interesting Read - Using A SQL JOIN In A SQL UPDATE/Delete Statement - Ben Nadel](https://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/): As everybody know SQL is what I like most. Before I was into SQL Server, I was very much into ColdFusion. ColdFusion is still my most favorite programming language. I still program in ColdFusion, infect my personal website https://www.pinaldave.com/ is in ColdFusion. I regularly read ColdFusion blog and latest updates in ColdFusion. Recently at company where I work, we upgraded to ColdFusion 8 and .NET 2.0 (C# is our preferred language in .NET technology). Both of this languags work with SQL Server 2005 very well in my company. My favorite blog for ColdFusion technology is blog of BEN NADEL . Ben... - [SQL SERVER - 2005 - Find Tables With Primary Key Constraint in Database](https://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/): My article SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key has received following question many times. I have deleted similar questions and kept only latest comment there. In SQL Server 2005 How to Find Tables With Primary Key Constraint in Database? Script to find all the primary key constraint in database: USE AdventureWorks; GO SELECT i.name AS IndexName, OBJECT_NAME(ic.OBJECT_ID) AS TableName, COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName FROM sys.indexes AS i INNER JOIN sys.index_columns AS ic ON i.OBJECT_ID = ic.OBJECT_ID AND i.index_id = ic.index_id WHERE i.is_primary_key = 1 In SQL Server 2005 How to Find Tables... - [SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database](https://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/): While writing article based on my SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key I got an idea about writing this article. I was thinking if you can find primary key for any table in the database, you can sure find foreign key for any table in the database as well. - [SQL SERVER - 2005 - Search Stored Procedure Code - Search Stored Procedure Text](https://blog.sqlauthority.com/2007/09/03/sql-server-2005-search-stored-procedure-code-search-stored-procedure-text/): I receive following question many times by my team members. How can I find if particular table is being used in the stored procedure? How to search in stored procedures? How can I do dependency check for objects in stored procedure without using sp_depends? I have previously wrote article about this SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored procedure. The same feature can be implemented using following script in SQL Server 2005. USE AdventureWorks GO --Searching for Empoloyee table SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Employee%' GO --Searching for Empoloyee table... - [SQL SERVER - Fix : Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward](https://blog.sqlauthority.com/2007/09/02/sql-server-fix-error-msg-3117-level-16-state-4-the-log-or-differential-backup-cannot-be-restored-because-no-files-are-ready-to-rollforward/): Following error occurs when tried to restored the differential backup. Fix : Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward Fix/WorkAround/Solution: This error happens when Full back up is not restored before attempting to restore differential backup or full backup is restored with WITH RECOVERY option. Make sure database is not in operational conditional when differential backup is attempted to be restored. Example of restoring differential backup successfully after restoring full backup. RESTORE DATABASE AdventureWorks FROM DISK = 'C:\AdventureWorksFull.bak' WITH NORECOVERY; RESTORE DATABASE AdventureWorks FROM DISK... - [SQL SERVER - 2005 - Find Database Status Using sys.databases or DATABASEPROPERTYEX](https://blog.sqlauthority.com/2007/08/31/sql-server-2005-find-database-status-using-sysdatabases-or-databasepropertyex/): While writing article about database collation, I came across sys.databases and DATABASEPROPERTYEX. It was very interesting to me that this two can tell user so much about database properties. Following are main database status: (Reference: BOL Database Status) ONLINE Database is available for access. OFFLINE Database is unavailable. RESTORING One or more files of the primary filegroup are being restored, or one or more secondary files are being restored offline. RECOVERING Database is being recovered. RECOVERY PENDING SQL Server has encountered a resource-related error during recovery. SUSPECT At least the primary filegroup is suspect and may be damaged. EMERGENCY User has... - [SQL SERVER - 2005 - Find Database Collation Using T-SQL and SSMS](https://blog.sqlauthority.com/2007/08/30/sql-server-2005-find-database-collation-using-t-sql-and-ssms/): This article is written based on feedback I have received on SQL SERVER – Cannot resolve collation conflict for equal to operation. Many reader asked me how to find collation of current database. There are two different ways to find out SQL Server database collation. 1) Using T-SQL (My Recommendation) Run following Script in Query Editor SELECT DATABASEPROPERTYEX('AdventureWorks', 'Collation') SQLCollation; ResultSet: SQLCollation ———————————— SQL_Latin1_General_CP1_CI_AS 2) Using SQL Server Management Studio Refer the following two diagram to find out the SQL Collation. Write Click on Database Click on Properties Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Difference and Explanation among DECIMAL, FLOAT and NUMERIC](https://blog.sqlauthority.com/2007/08/29/sql-server-difference-and-explanation-among-decimal-float-and-numeric/): The basic difference between Decimal and Numeric : They are the exactly same. Same thing different name. The basic difference between Decimal/Numeric and Float : Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly. Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type reane can be represented exactly with precision and scale. Converting from Decimal or Numeric to float can cause some loss of precision. For the Decimal or Numeric data types, SQL Server considers each specific combination of precision and scale as a... - [SQL SERVER - Actual Execution Plan vs. Estimated Execution Plan](https://blog.sqlauthority.com/2007/08/28/sql-server-actual-execution-plan-vs-estimated-execution-plan/): I was recently invited to participate in big discussion on one of the online forum, the topic was Actual Execution Plan vs. Estimated Execution Plan. I refused to participate in that particular discussion as I have very simple but strong opinion about this topic. I always use Actual Execution Plan as it is accurate. Why not Estimated Execution Plan? It is not accurate. Sometime it is easier or useful to to know the plan without running query. I just run query and have correct and accurate Execution Plan. Shortcut for Display Estimated Execution Plan : CTRL + L Shortcut for Include... - [SQL SERVER - 2005 - Use Always Outer Join Clause instead of (*= and =*)](https://blog.sqlauthority.com/2007/08/27/sql-server-2005-use-always-outer-join-clause-instead-of-and/): Yesterday I wrote about how SQL Server 2005 does not support named pipes. Today, my friend called me asking some of his query does not work. I asked him to send me the queries. I asked him to send me query. I noticed in his queries something, I have never practiced before and I never had any issue therefore. Instead of using LEFT OUTER JOIN clause he was using *= and similarly instead of using RIGHT OUTER JOIN clause he was using =*. Once I replaced did necessary modification, queries run just fine. I wish I can give you example of... - [SQL SERVER - 2005 - No Backup Support For Named Pipes](https://blog.sqlauthority.com/2007/08/26/sql-server-2005-no-backup-support-for-named-pipes/): While helping one of my DBA friend (who works in big company in LA) to upgrade SQL Server 2000 to SQL Server 2005 I just found one thing, which I have not paid attention before. SQL Server 2000 supported named pipe backup device. SQL Server 2005 does not support named pipe backup device, however SQL Server 2005 supports disk and tape devices. I receive following question many times, I have answered this question earlier on this blog. I will still answer it again. What is my preferred method of backup? We use SAN with RAID 10 configuration. Some industry experts suggested... - [SQL SERVER - FIX : Error : msg 2540 - The system cannot self repair this error](https://blog.sqlauthority.com/2007/08/25/sql-server-fix-error-msg-2540-the-system-cannot-self-repair-this-error/): SQL SERVER – FIX : Error : msg 2540 – The system cannot self repair this error This is most annoying error. I have only faced this error twice so far. I solved this error restoring the database back up. Read here for additional help on SQL Backup And Restore. This error is occurs when database is in state when it can not be heal itself, i.e. corrupted metadata or corrupted important system database files. Fix/WorkAround/Solution: My prefered order to fix the problem. 1) Restored database from backup. 2) Run DBCC with repair option, which will not bring much favorable answer.... - [SQL SERVER - T-SQL Script to Attach and Detach Database](https://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/): Following script can be used to detach or attach the database. If the database is to be from one database to another database following script can be used to detach from old server and attach to a new server. Let us learn about how to Attach and Detach Database. - [SQL SERVER - 2005 - Use of Non-deterministic Function in UDF - Find Day Difference Between Any Date and Today](https://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/): While writing few articles about SQL Server DataTime I accidentally wrote User Defined Function (UDF), which I would have not wrote usually. Once I wrote this function, I did not find it very interesting and decided to discard it. However, I suddenly noticed use of Non-Deterministic function in the UDF. I always thought that use of Non-Deterministic function is prohibited in UDF. I even wrote about it earlier SQL SERVER – User Defined Functions (UDF) Limitations. It seems like SQL Server 2005 either have removed this restriction or it is bug. I think I will not say this is bug but... - [SQL SERVER - T-SQL Script to Insert Carriage Return and New Line Feed in Code](https://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/): Very simple and very effective. We use all the time for many reasons - formatting, while creating dynamically generated SQL to separate GO command from other T-SQL, saving some user input text to database etc. Let us learn about T-SQL Script to Insert Carriage Return and New Line Feed in Code. - [SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects](https://blog.sqlauthority.com/2007/08/21/sql-server-2005-create-script-to-copy-database-schema-and-all-the-objects-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/): Update: This article is re-written with SQL Server 2008 R2 instance over here: SQL SERVER – 2008 – 2008 R2 – Create Script to Copy Database Schema and All The Objects – Data, Schema, Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects Following quick tutorial demonstrates how to create T-SQL script to copy complete database schema and all of its objects such as Stored Procedure, Functions, Triggers, Tables, Views, Constraints etc. You can review your schema, backup for reference or use it to compare with previous backup. Step 1 : Start Step 2 : Welcome Screen Step... - [SQLAuthority News - Principles of Simplicity](https://blog.sqlauthority.com/2007/08/20/sqlauthority-news-principles-of-simplicity/): Yesterday I came across Principles of Simplicity by Mads Kristensen. I think this is good write up and I enjoyed reading it. This are very generic and applies to all programming language and databases applications. Principles of Simplicity by Mads Kristensen 1. Simplicity or not at all Some developers tend to over-complicate a task and ends up writing too many classes to solve a simple problem. 2. Don’t build submarines It’s a common fact that IT projects take longer than scheduled even if you schedule for delays. 3. Test when appropriate Testing is one very important factor of the development cycle... - [SQL SERVER - Find Monday of the Current Week](https://blog.sqlauthority.com/2007/08/20/sql-server-find-monday-of-the-current-week/): Very Simple Script which find Monday of the Current Week SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0) MondayOfCurrentWeek Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes](https://blog.sqlauthority.com/2007/08/19/sqlauthority-news-book-review-sams-teach-yourself-microsoft-sql-server-t-sql-in-10-minutes/): Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes (Sams Teach Yourself) by Ben Forta Link to Amazon Short Review: If T-SQL (Transact-Structured Query Language) is foreign tongue to you, after reading this book, you will speak T-SQL. This book is SQL Server version of best-selling book Sams Teach Yourself SQL in 10 Minutes. This book teaches what a SQL developer must know methodically, systematically, and exactly. Anybody who are new to SQL Server and wants to learn most of T-SQL which can be implemented in short time in their application – BUY this book immediately. Detail Review: This is... - [SQL SERVER - Find Last Day of Any Month - Current Previous Next](https://blog.sqlauthority.com/2007/08/18/sql-server-find-last-day-of-any-month-current-previous-next/): Few questions are always popular. They keep on coming up through email, comments or from co-workers. Finding Last Day of Any Month is similar question. I have received it many times and I enjoy answering it as well. I have answered this question twice before here: SQL SERVER – Script/Function to Find Last Day of Month SQL SERVER – Query to Find First and Last Day of Current Month Today, we will see the same solution again. Please use the method you find appropriate to your requirement. Following script demonstrates the script to find last day of previous, current and next... - [SQL SERVER - 2005 - Explanation and Script for Online Index Operations - Create, Rebuild, Drop](https://blog.sqlauthority.com/2007/08/17/sql-server-2005-explanation-and-script-for-online-index-operations-create-rebuild-drop/): SQL Server 2005 Enterprise Edition supports online index operations. Index operations are creating, rebuilding and dropping indexes. The question which I receive quite often – what is online operation? Is online operation is related to web, internet or local network? Online operation means when online operations are happening the database are in normal operational condition, the processes which are participating in online operations does not require exclusive access to database. In case of Online Indexing Operations, when Index operations (create, rebuild, dropping) are occuring they do not require exclusive access to database, they do not lock any database tables. This is... - [SQLAuthority News - Subscribed to SQLAuthority Emails](https://blog.sqlauthority.com/2007/08/16/sqlauthority-news-subscribed-to-sqlauthority-emails/): I have got many request about alert system when new post is published on this blog. I use feedburner email service, which sends email whenever new post is published on my blog. Many times, I update my post based on feedback from comments or news. If you want updated information, visit the blog. Subscribe to SQLAuthority.com Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Book On-Line Link - BOL](https://blog.sqlauthority.com/2007/08/16/sql-server-2008-book-on-line-link/): I am researching SQL Server. Those who are asking me questions about SQL Server 2008, please refer following link. I will post my tutorials and articles very soon. Books Online is commonly known as BOL. - [SQL SERVER - 2005 - Difference and Similarity Between NEWSEQUENTIALID() and NEWID()](https://blog.sqlauthority.com/2007/08/16/sql-server-2005-difference-and-similarity-between-newsequentialid-and-newid/): NEWSEQUENTIALID() and NEWID() both generates the GUID of datatype of uniqueidentifier. NEWID() generates the GUID in random order whereas NEWSEQUENTIALID() generates the GUID in sequential order. Let us see example first demonstrating both of the function. USE AdventureWorks; GO ----Create Test Table for with default columns values CREATE TABLE TestTable (NewIDCol uniqueidentifier DEFAULT NEWID(), NewSeqCol uniqueidentifier DEFAULT NewSequentialID()) ----Inserting five default values in table INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES ----Test Table to see NewID() is random ----Test Table to see NewSequentialID()... - [SQL SERVER - Insert Data From One Table to Another Table - INSERT INTO SELECT - SELECT INTO TABLE](https://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table/): Following three questions are many times asked on this blog. How to insert data from one table to another table efficiently? How to insert data from one table using where condition to another table? How can I stop using cursor to move data from one table to another table? There are two different ways to implement inserting data from one table to another table. I strongly suggest to use either of the methods over the cursor. Performance of following two methods is far superior over the cursor. I prefer to use Method 1 always as I works in all the cases.... - [SQLAuthority News - Book Review - Learning SQL on SQL Server 2005 (Learning)](https://blog.sqlauthority.com/2007/08/14/sqlauthority-news-book-review-learning-sql-on-sql-server-2005-learning/): SQLAuthority.com Book Review : Learning SQL on SQL Server 2005 (Learning) [ILLUSTRATED] (Paperback) by Sikha Bagui, Richard Earp Link to book on Amazon Short Review: This books covers simple and complex concept in very easy language with lots of examples. Every beginner can learn a great amount of tips from experienced authors. Whether you are a self-learner, new to databases or in need of SQL refresher, this is good read. Detail Review: This book is written by two conceptual strong SQL Server Gurus. SQL Server is growing extremely popular in the area of high-performance data applications. It is very important to... - [SQL SERVER - What is SQL? How to pronounce SQL?](https://blog.sqlauthority.com/2007/08/14/sql-server-what-is-sql-how-to-pronounce-sql/): SQL is abbreviation of Structured Query Language. SQL is pronounced as S.Q.L. (ess-que-ell or ess-cue-ell) not sequel. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - Database Architecture and Implementation Discussion - New York, New Jersey Details](https://blog.sqlauthority.com/2007/08/13/sqlauthority-news-author-visit-database-architecture-and-implementation-discussion-new-york-new-jersey-details/): Last weekend I visited New York City (NY) and Edison (NJ) to attend database architecture meeting with a big environmental technology firm. It was very interesting to meet CEO and few of the lead database administrators. Lots of database related things were discussed. I will list few of the points discussed in the meeting here, due to privacy policy I will be not able to write many of the interesting details I have learned there. Please let me know if you are interested in any of the particular topic. I can elaborate more on the topic which interests everybody. 1) Database... - [SQL SERVER - Fix : ERROR : Msg 1033, Level 15, State 1 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.](https://blog.sqlauthority.com/2007/08/12/sql-server-fix-error-msg-1033-level-15-state-1-the-order-by-clause-is-invalid-in-views-inline-functions-derived-tables-subqueries-and-common-table-expressions-unless-top-or-for-xml-is-als/): Following error is encountered when view is attempted to created with ORDER BY clause in it. ORDER BY clause is not allowed in views in SQL Server 2005. This solution also displays the workaround to use ORDER BY in VIEW. I really do not prefer to use views. My views on SQL Views read it SQL SERVER – Restrictions of Views – T SQL View Limitations. Msg 1033, Level 15, State 1 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. This is error interested... - [SQL SERVER - UDF - Validate Integer Function](https://blog.sqlauthority.com/2007/08/11/sql-server-udf-validate-integer-function/): I received quite a good feedback about my post about SQL SERVER – Validate Field For DATE datatype using function ISDATE() One of the most interesting comment I received from my reader from Canada. I was suggested just like ISDATE() to write about ISNUMERIC() which can be used to validate numeric values. As per BOL: ISNUMERIC returns 1 when the input expression evaluates to a valid numeric data type; otherwise it returns 0. ISNUMERIC returns 1 for some characters that are not numbers, such as plus (+), minus (-), and valid currency symbols such as the dollar sign ($). Now this... - [SQL SERVER - 2005 - Find Stored Procedure Create Date and Modified Date](https://blog.sqlauthority.com/2007/08/10/sql-server-2005-find-stored-procedure-create-date-and-modified-date/): This post is second part of my previous post about SQL SERVER – 2005 – List All Stored Procedure Modified in Last N Days - [SQL SERVER - 2005 - List All The Column With Specific Data Types](https://blog.sqlauthority.com/2007/08/09/sql-server-2005-list-all-the-column-with-specific-data-types/): Since we upgraded to SQL Server 2005 from SQL Server 2000, we have used following script to find out columns with specific datatypes many times. It is very handy small script. SQL Server 2005 has new datatype of VARCHAR(MAX), we decided to change all our TEXT datatype columns to VARCHAR(MAX). The reason to do that as TEXT datatype will be deprecated in future version of SQL Server and VARCHAR(MAX) is superior to TEXT datatype in features. We run following script to identify all the columns which are TEXT datatype and developer converts them to VARCHAR(MAX) Script 1 : Simple script to... - [SQL SERVER - 2005 - SSMS - Enable Autogrowth Database Property](https://blog.sqlauthority.com/2007/08/08/sql-server-2005-ssms-enable-autogrowth-database-property/): We can use SSMS to Enable Autogrowth property of the Database. Right-click on Database click on Properties and click on Files. There will be column of Autogrowth, click on small box with three (…) dots. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List Tables in Database Without Primary Key](https://blog.sqlauthority.com/2007/08/07/sql-server-2005-list-tables-in-database-without-primary-key/): This is very simple but effective script. It list all the table without primary keys. USE DatabaseName; GO SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableName FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0 ORDER BY SchemaName, TableName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Fix: Error 2596 The repair statement was not processed. The database cannot be in read-only mode](https://blog.sqlauthority.com/2007/08/06/sql-server-fix-error-2596-the-repair-statement-was-not-processed-the-database-cannot-be-in-read-only-mode/): ERROR 2596 : The repair statement was not processed. The database cannot be in read-only mode. - [SQL SERVER - Stop SQL Server Immediately Using T-SQL](https://blog.sqlauthority.com/2007/08/05/sql-server-stop-sql-server-immediately-using-t-sql/): This question has came up many quite a few times with our development team as well as emails I have received about how to stop SQL Server immediately (due to accidentally ran t-sql, business logic or just need of to stop SQL Server using T-SQL). Answer is very simple, run following command in SQL Editor. SHUTDOWN If you want to shutdown the system without performing checkpoints in every database and without attempting to terminate all user processes use following command. SHUTDOWN WITH NOWAIT Server can be turned off using windows services as well. SHUTDOWN permissions are assigned to members of the... - [SQL SERVER - One Thing All DBA Must Know](https://blog.sqlauthority.com/2007/08/04/sql-server-one-thing-all-dba-must-know/): FULLY BACKUP DATABASE. Update : I posted this post with only line. However I received many comments and questions asking different questions related to it. I have compiled all of them and modified this post. Most asked Question : What is the best time when database should be backed up? Answer : When everything is running perfect. This is the time when backup should be taken because in troubled time this is the backup required to be restored. The best backup is when system was running PERFECT. Question : I am experienced DBA, what should be the frequency of backup when... - [SQLAuthority News - Download SQL Server 2005 Samples and Sample Databases](https://blog.sqlauthority.com/2007/08/04/sqlauthority-news-download-sql-server-2005-samples-and-sample-databases/): Microsoft has purchased GitHub, the world’s leading software development platform where more than 28 million developers learn, share and collaborate to create the future for 7.5 Billion dollars.  - [SQLAuthority News - Author Visit - Database Architecture and Implementation Discussion - New York, New Jersey](https://blog.sqlauthority.com/2007/08/04/sqlauthority-news-author-visit-database-architecture-and-implementation-discussion-new-york-new-jersey/): I will be traveling for next two days to New York and New Jersey for Database Architecture and Implementation Discussion with one of the largest software technology company. The major focus of this firm is environmental product analysis. I will be not able to answer any questions, comments and emails during next two days 8/5 Saturday and 8/6 Sunday. I will post all the interesting details (which I can disclose safely without violating privacy policy) once I am come back to my city – Las Vegas. I am looking forward to meet industry giants and prominent personalities for next two days.... - [SQL SERVER - What is Page Life Expectancy (PLE) Counter](https://blog.sqlauthority.com/2010/12/13/sql-server-what-is-page-life-expectancy-ple-counter/): During performance tuning consultationconsultation, there are plenty of counters and values, I often come across. Today we will quickly talk about Page Life Expectancy counter, which is commonly known as PLE as well. You can find the value of the PLE by running the following query. SELECT [object_name], [counter_name], [cntr_value] FROM sys.dm_os_performance_counters WHERE [object_name] LIKE '%Manager%' AND [counter_name] = 'Page life expectancy' The recommended value of the PLE counter is (updated: minimum of) 300 seconds. I have seen on busy system this value to be as low as even 45 seconds and on unused system as high as 1250 seconds. Page... - [SQL SERVER - Activity Monitor and Performance Issue](https://blog.sqlauthority.com/2010/12/12/sql-server-activity-monitor-and-performance-issue/): We had a wonderful SQLAuthority News – Community Tech Days – December 11, 2010 event yesterday. During this event SQL Expert Jacob shared a very interesting story related to activity monitor. - [SQLAuthority News - SQL Server 2008 R2 System Views Map](https://blog.sqlauthority.com/2010/12/11/sqlauthority-news-sql-server-2008-r2-system-views-map/): SQL Server 2008 R2 System Views Map is released. I am very proud that my organization (Solid Quality Mentors) is part of making this possible. This map shows the key system views included in SQL Server 2008 and 2008 R2, and the relationships between them. SQL Server 2008 R2 System Views Map Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SEVER - Finding Memory Pressure - External and Internal](https://blog.sqlauthority.com/2010/12/10/sql-sever-finding-memory-pressure-external-and-internal/): The following query will provide details of external and internal memory pressure. It will return the data how much portion in the existing memory is assigned to what kind of memory type. - [SQLAuthority News - Community Tech Days - SharePoint Server](https://blog.sqlauthority.com/2010/12/09/sqlauthority-news-community-tech-days-sharepoint-server/): Community Tech Days are very close on December 11. I will be speaking in the following session. Best Database Practice for SharePoint Server. - [SQL SERVER - Installing AdventureWorks for SQL Server](https://blog.sqlauthority.com/2010/12/08/sql-server-installing-adventureworks-for-sql-server-2011/): I just began with SQL Server 2012. The very first thing, I realized that there is no AdventureWorks Sample Database available for Denali. I quickly searched online and reached to Microsoft documentation where it provides information on the how to install (restore) AdventureWorks for SQL Server . - [SQLAuthority News - A Successful Performance Tuning Seminar at Pune - Dec 4-5, 2010](https://blog.sqlauthority.com/2010/12/07/sqlauthority-news-a-successful-performance-tuning-seminar-at-pune-dec-4-5-2010/): This is report to my third of very successful seminar event on SQL Server Performance Tuning. SQL Server Performance Tuning Seminar in Colombo was oversubscribed with total of 35 attendees. You can read the details over hereSQLAuthority News – SQL Server Performance Optimizations Seminar – Grand Success – Colombo, Sri Lanka – Oct 4 – 5, 2010. SQL Server Performance Tuning Seminar in Hyderabad was oversubscribed with total of 25 attendees. You can read the details over here SQL SERVER – A Successful Performance Tuning Seminar – Hyderabad – Nov 27-28, 2010. The same Seminar was offered in Pune on December... - [SQL SERVER - Solution - Challenge - Puzzle - Usage of FAST Hint](https://blog.sqlauthority.com/2010/12/06/sql-server-solution-challenge-puzzle-usage-of-fast-hint/): Earlier I had posted quick puzzle and I had received wonderful response to the same from Brad Schulz. Today we will go over the solution. The puzzle was posted here: SQL SERVER – Challenge – Puzzle – Usage of FAST Hint The question was in what condition the hint FAST will be useful. In the response to this puzzle blog post here is what SQL Server Expert Brad Schulz has pointed me to his blog post where he explain how FAST hint can be useful. I strongly recommend to read his blog post over here. With the permission of the Brad,... - [SQL SERVER - Puzzle - Error While Converting Money to Decimal](https://blog.sqlauthority.com/2010/12/05/sql-server-solution-puzzle-challenge-error-while-converting-money-to-decimal/): Earlier I had posted quick puzzle about Converting Money and I had received a wonderful response to the same. Let us go over the solution. The puzzle was posted here: SQL SERVER – Puzzle – Challenge – Error While Converting Money to Decimal - [SQLAuthority News - Statistics Used by the Query Optimizer in Microsoft SQL Server 2008 - Microsoft Whitepaper](https://blog.sqlauthority.com/2010/12/04/sqlauthority-news-statistics-used-by-the-query-optimizer-in-microsoft-sql-server-2008-microsoft-whitepaper/): I recently presented session on Statistics and Best Practices in Virtual Tech Days on Nov 22, 2010. The sessions was very popular and I got many questions right after the sessions. The number question I had received was where everybody can get the further information. I am very much happy that my sessions created some curiosity for one of the most important feature of the SQL Server. Statistics are the heart of the SQL Server. Let us read about Statistics Used by the Query Optimizer in Microsoft SQL Server 2008. - [SQL SERVER - A Successful Performance Tuning Seminar - Hyderabad - Nov 27-28, 2010 - Next Pune](https://blog.sqlauthority.com/2010/12/03/sql-server-a-successful-performance-tuning-seminar-hyderabad-nov-27-28-2010-next-pune/): My recent SQL Server Performance Tuning Seminar in Colombo was oversubscribed with total of 35 attendees. You can read the details over here SQLAuthority News – SQL Server Performance Optimizations Seminar – Grand Success – Colombo, Sri Lanka – Oct 4 – 5, 2010. I had recently completed another seminar in Hyderabad which was again blazing success. We had 25 attendees to the seminar and had wonderful time together. There is one thing very different between usual class room training and this seminar series. In this seminar series we go 100% demo oriented and real world scenario deep down. We do not... - [SQLAuthority News - Community Tech Days - A SQL Legends in Ahmedabad - December 11, 2010](https://blog.sqlauthority.com/2010/12/02/sqlauthority-news-community-tech-days-a-sql-legends-in-ahmedabad-december-11-2010/): Ahmedabad is going to be fortunate city again on December 11. We are going to have SQL Server Legends present at the prestigious event of Community Tech Days in Ahmedabad. The venue details are as following: H K Hall, H K College Campus, Near Handloom House, Opp. Natraj Cinema, Ashram Road, Ahmedabad – 380009 Click here to Registration for the event. Agenda of the event is as following. 10:15am – 10:30am     Welcome – Pinal Dave 10:30am – 11:15am     SQL Tips and Tricks for .NET Developers by Jacob Sebastian 11:15am – 11:30am     Tea Break 11:30am – 12:15pm     Best... - [SQL SERVER - 3 Simple Puzzles - Need Your Suggestions](https://blog.sqlauthority.com/2010/12/01/sql-server-3-simple-puzzles-need-your-suggestions/): Last Month, I have posted three Simple Puzzles and I got very good response. I think there can be many interesting answers there. I would like to request all of you to take part the puzzles and provide your answer. I plant to consolidate answers and publish all the valid answers on this blog with due credit. SQL SERVER – Challenge – Puzzle – Usage of FAST Hint SQL SERVER – Puzzle – Challenge – Error While Converting Money to Decimal SQL SERVER – Challenge – Puzzle – Why does RIGHT JOIN Exists I am also thinking that after such a... - [SQL SERVER - Automated Type Conversion using Expressor Studio](https://blog.sqlauthority.com/2010/11/30/sql-server-automated-type-conversion-using-expressor-studio/): Recently I had an interesting situation during my consultation project. Let me share to you how I solved the problem using Expressor Studio. Consider a situation in which you need to read a field, such as customer_identifier, from a text file and pass that field into a database table. In the source file’s metadata structure, customer_identifier is described as a string; however, in the target database table, customer_identifier is described as an integer. Legitimately, all the source values for customer_identifier are valid numbers, such as “109380”. To implement this in an ETL application, you probably would have hard-coded a type conversion... - [SQL SERVER - DBA or DBD? - Database Administrator or Database Developer](https://blog.sqlauthority.com/2010/11/29/sql-server-dba-or-dbd-database-administrator-or-database-developer/): Earlier this month, I had poll on this blog where I asked question – Are you a Database Administrator or Database Developer? The word DBA (Database Administrator) is very common but DBD (Database Developer) is not common at all. This made me think – what is the ratio of the same. Here the result of the poll: Database Administrator 36.6% (254 votes) Database Developer 63.4% (440 votes) Total Votes: 694 This is open poll, if you want you can still participate here. Vote your Voice – DBD or DBA? I think it is the time when DBD word for Database Developer... - [SQL SERVER - Challenge - Puzzle - Why does RIGHT JOIN Exists](https://blog.sqlauthority.com/2010/11/28/sql-server-challenge-puzzle-why-does-right-join-exists/): I had interesting conversation with the attendees of the my SQL Server Performance Tuning course. I was asked if LEFT JOIN can do the same task as RIGHT JOIN by reserving the order of the tables in join, why does RIGHT JOIN exists? The definitions are as following: Left Join – select all the records from the LEFT table and then pick up any matching records from the RIGHT table   Right Join – select all the records from the RIGHT table and then pick up any matching records from the LEFT table Most of us read from LEFT to RIGHT... - [SQL SERVER - Puzzle - Challenge - Error While Converting Money to Decimal](https://blog.sqlauthority.com/2010/11/27/sql-server-puzzle-challenge-error-while-converting-money-to-decimal/): Earlier I wrote SQL SERVER – Challenge – Puzzle – Usage of FAST Hint and I did receive some good comments. Here is another question to tease your mind. Run following script and you will see that it will thrown an error. DECLARE @mymoney MONEY; SET @mymoney = 12345.67; SELECT CAST(@mymoney AS DECIMAL(5,2)) MoneyInt; GO The datatype of money is also visually look similar to the decimal, why it would throw following error: Msg 8115, Level 16, State 8, Line 3 Arithmetic overflow error converting money to data type numeric. Please leave a comment with explanation and I will post a your... - [SQL SERVER - Challenge - Puzzle - Usage of FAST Hint](https://blog.sqlauthority.com/2010/11/26/sql-server-challenge-puzzle-usage-of-fast-hint/): I was recently working with various SQL Server Hints. After working for a day on various hints, I realize that for one hint, I am not able to come up with good example. The hint is FAST. Let us look at the definition of the FAST hint from the Book On-Line. FAST number_rows Specifies that the query is optimized for fast retrieval of the first number_rows. This is a nonnegative integer. After the first number_rows are returned, the query continues execution and produces its full result set. Now the question is in what condition this hint can be useful. I have... - [SQL SERVER - Concat Function in SQL Server - SQL Concatenation](https://blog.sqlauthority.com/2010/11/25/sql-server-concat-function-in-sql-server-sql-concatenation/): Earlier this week, I was delivering Advanced BI training on the subject of “SQL Server 2008 R2”. I had a great time delivering the session. During the session, we talked about SQL Server 2012 Denali. Suddenly one of the attendees suggested his displeasure for the product. He said, even though, SQL Server is now in moving very fast and have proved many times a better enterprise solution, it does not have some basic functions. I naturally asked him for an example and he suggested CONCAT() which exists in MySQL and Oracle. The answer is very simple – the equivalent function in... - [SQLAuthority News - What's New in SQL Server "Denali"](https://blog.sqlauthority.com/2010/11/24/sqlauthority-news-whats-new-in-sql-server-denali/): I was today doing SQL Server Advanced Training at Bangalore and I had few attendees asked me if I can give them review of the SQL Server Denali. I had not downloaded Denali on my work computer so I could not do demonstration of the same. However, I promised to blog about with additional details very next day. Denali is also known as SQL 11 and the compatibility mode number is 110. Here are few details about it. What is new in SQL Server “Denali” Download CTP1 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQLPASS Nov 8-11, 2010-Seattle - An Alternative Look at Experience](https://blog.sqlauthority.com/2010/11/23/sqlauthority-news-sqlpass-nov-8-11-2010-seattle-an-alternative-look-at-experience/): I recently attended most prestigious SQL Server event SQLPASS between Nov 8-11, 2010 at Seattle. I have only one expression for the event – Best Summit Ever This year the summit was at its best. Instead of writing about my usual routine or the event, I am going to write about the interesting things I did and how I felt about it! Trip to Seattle! This was my second trip to Seattle this year and the journey is always long. Here is the travel stats on how long it takes to get to Seattle: 24 hours official air time 36 hours... - [SQLAuthority News - Statistics and Best Practices - Virtual Tech Days - Nov 22, 2010](https://blog.sqlauthority.com/2010/11/22/sqlauthority-news-statistics-and-best-practices-virtual-tech-days-nov-22-2010/): I am honored that I have been invited to speak at Virtual TechDays on Nov 22, 2010 by Microsoft. I will be speaking on my favorite subject of Statistics and Best Practices. This exclusive online event will have 80 deep technical sessions across 3 days – and, attendance is completely FREE. There are dedicated tracks for Architects, Software Developers/Project Managers, Infrastructure Managers/Professionals and Enterprise Developers. So, REGISTER for this exclusive online event TODAY. Statistics and Best Practices Timing: 11:45am-12:45pm Statistics are a key part of getting solid performance. In this session we will go over the basics of the statistics and... - [SQL SERVER - Change Database Access to Single User Mode Using SSMS](https://blog.sqlauthority.com/2010/11/21/sql-server-change-database-access-to-single-user-mode-using-ssms/): I have previously written about how using T-SQL Script we can convert the database access to single user mode before backup. I was recently asked if the same can be done using SQL Server Management Studio. Yes! You can do it from database property (Write click on database and select database property) and follow image. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Beginning T-SQL 2008 by Kathi Kellenberger](https://blog.sqlauthority.com/2010/11/20/sqlauthority-news-book-review-beginning-t-sql-2008-by-kathi-kellenberger/): Beginning T-SQL 2008 by Kathi Kellenberger Amazon Link Detail Review: Beginning T-SQL 2008 is one of the best books on the market if you are just beginning to work with Microsoft SQL, or have a little bit of experience and need to learn more quickly. Each chapter of the book introduces a new subject, and builds upon topics covered in previous chapters.  The author of the book, Kathi Kellenberger understands that you need to form a solid foundation of knowledge before moving on to new topics, and sets up each subject nicely.  Because the chapters move in an orderly progression, you... - [SQLAuthority News - Blog Stats Revealed ](https://blog.sqlauthority.com/2010/11/19/sqlauthority-news-blog-stats-revealed/): I often receive praises, questions, suggestions and skeptical emails regarding my blog stats. Let me put everything aside and open up my stats page for all. I use wordpress.com and stats are maintained by them. Every month, I will put the blog stats on the following page for every one’s consumption. View SQLAuthority Stats If you still have question – do ask me :) Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server Performance Series Hyderabad / Pune - Nov/Dec 2010](https://blog.sqlauthority.com/2010/11/18/sqlauthority-news-sql-server-performance-series-hyderabad-pune-novdec-2010/): Just a quick note that SQL Server Performance Tuning and Optimizations Seminar series which I am offering at Hyderabad and Pune are almost all sold out. Read the details of the earlier successful seminar conducted at Colombo, Sri Lanka over here. Hyderabad Nov 27-28, 2010 (Last 3 Seats Left) Best Western Amrutha Castle 5-9-16, Opp. Secretriat, Saifabad, Khairatabad Hyderabad, Andhra Pradesh Pune Dec 04-05, 2010 (Last 6 Seats Left) Location TBA as we are looking for larger capacity room. I promise that this is going to be great fun as this sessions are very different then any usual sessions you have... - [SQL SERVER - History of SQL Server Database Encryption](https://blog.sqlauthority.com/2010/11/17/sql-server-history-of-sql-server-database-encryption/): I recently met Michael Coles and Rodeney Landrum the author of one of the kind book Expert SQL Server 2008 Encryption at SQLPASS in Seattle. During the conversation we ended up how Microsoft is evolving encryption technology. The same discussion lead to talking about history of encryption tools in SQL Server. Michale pointed me to page 18 of his book of encryption. He explicitly give me permission to re-produce relevant part of history from his book. Encryption in SQL Server 2000 Built-in cryptographic encryption functionality was nonexistent in SQL Server 2000 and prior versions. In order to get server-side encryption in... - [SQLAuthority News - Download Whitepaper - Understanding and Controlling Parallel Query Processing in SQL Server](https://blog.sqlauthority.com/2010/11/16/sqlauthority-news-download-whitepaper-understanding-and-controlling-parallel-query-processing-in-sql-server/): My recently article SQL SERVER – Reducing CXPACKET Wait Stats for High Transactional Database has received many good comments regarding MAXDOP 1 and MAXDOP 0. I really enjoyed reading the comments as the comments are received from industry leaders and gurus. I was further researching on the subject and I end up on following white paper written by Microsoft. Understanding and Controlling Parallel Query Processing in SQL Server Data warehousing and general reporting applications tend to be CPU intensive because they need to read and process a large number of rows. To facilitate quick data processing for queries that touch a large... - [SQL SERVER - Information Related to DATETIME and DATETIME2](https://blog.sqlauthority.com/2010/11/15/sql-server-information-related-to-datetime-and-datetime2/): I recently received interesting comment on the blog regarding workaround to overcome the precision issue while dealing with DATETIME and DATETIME2. I have written over this subject earlier over here. SQL SERVER – Difference Between GETDATE and SYSDATETIME SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE SQL SERVER – Difference Between DATETIME and DATETIME2 SQL Expert Jing Sheng Zhong has left following comment: The issue you found in SQL server new datetime type is related time source function precision. Folks have found the root reason of the problem – when data time values are converted (implicit or explicit)... - [SQL SERVER – FIX ERROR 3702 Cannot drop database “MyDBName” because it is currently in use](https://blog.sqlauthority.com/2010/11/14/sql-server-error-fix-msg-3702-level-16-state-3-line-1-cannot-drop-database-mydbname-because-it-is-currently-in-use/): I often go to do various seminars and presentations at various organizations. During presentations I often create and drop various databases for the demonstration's purpose. Recently in one of the presentations, I tried to remove my recently created database, I got following error 3702 which is related to user cannot drop database. - [SQL SERVER - Reducing CXPACKET Wait Stats for High Transactional Database](https://blog.sqlauthority.com/2010/11/13/sql-server-reducing-cxpacket-wait-stats-for-high-transactional-database/): While engaging in a performance tuning consultation for a client, a situation occurred where they were facing a lot of CXPACKET Waits Stats. The client asked me if I could help them reduce this huge number of wait stats. I usually receive this kind of request from other client as well, but the important thing to understand is whether this question has any merits or benefits, or not. Before we continue the resolution, let us understand what CXPACKET Wait Stats are. The official definition suggests that CXPACKET Wait Stats occurs when trying to synchronize the query processor exchange iterator. You may... - [SQL SERVER - Get All the Information of Database using sys.databases](https://blog.sqlauthority.com/2010/11/12/sql-server-get-all-the-information-of-database-using-sys-databases/): Earlier I wrote blog article SQL SERVER – Finding Last Backup Time for All Database. In the response of this article I have received very interesting script from SQL Server Expert Matteo as a comment in the blog. He has written script using sys.databases which provides plenty of the information about database. I suggest you can run this on your database and know unknown of your databases as well. SELECT database_id, CONVERT(VARCHAR(25), DB.name) AS dbName, CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, 'status')) AS [Status], state_desc, (SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'rows') AS DataFiles, (SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id)... - [SQLAuthority News - SQL Server Denali CTP1 - Release Date November 9, 2010](https://blog.sqlauthority.com/2010/11/11/sqlauthority-news-sql-server-2011-release-date-november-9-2010/): I am very excited as I was about to witness SQL Server 2011 – Code Named “Denali” is released on November 11, 2010 at SQLPASS. I will write a detail report for the same in future. You can download CTP1 right away right now and install on your machine. The major features of the new products are as following: Enhanced Mission-Critical Platform: an enhanced highly available and scalable platform. Developer and IT Productivity: new innovative productivity tools and features. Pervasive Insight: expanding the reach of BI to business users and end-to-end data integration and management. I am going to download the... - [SQL SERVER - Get Database Backup History for a Single Database](https://blog.sqlauthority.com/2010/11/10/sql-server-get-database-backup-history-for-a-single-database/): I recently wrote article SQL SERVER – Finding Last Backup Time for All Database and requested blog readers to respond with their own script which they use it Database Backup. Here is the script suggested by SQL Expert aasim abdullah, who has written excellent script which goes back and retrieves the history of any single database. USE AdventureWorks GO -- Get Backup History for required database SELECT TOP 100 s.database_name, m.physical_device_name, CAST(CAST(s.backup_size / 1000000 AS INT) AS VARCHAR(14)) + ' ' + 'MB' AS bkSize, CAST(DATEDIFF(second, s.backup_start_date, s.backup_finish_date) AS VARCHAR(4)) + ' ' + 'Seconds' TimeTaken, s.backup_start_date, CAST(s.first_lsn AS VARCHAR(50)) AS... - [SQL SERVER - Recycle Error Log - Create New Log file without Server Restart](https://blog.sqlauthority.com/2010/11/09/sql-server-recycle-error-log-create-new-log-file-without-server-restart/): The job of a consultant is always interesting – sometimes one becomes very busy and at times, over busy. I have been overwhelmed with recent performance tuning engagements. In one of the recent engagements, a large number of errors were found in the server. I noticed that their error log filled up very quickly. I also noticed a very interesting action by their DBA. I observed that after we make some changes in the server to avoid the errors, the DBA restarted the server. I asked him the reason for doing so. He explained every time that when he restarts the server, a new error log file is created. The current log file is renamed as errorlog.1; errorlog.1 becomes errorlog.2, and in a similar way, it continues. This way, after making some change, we can watch the error file from the beginning. - [SQLAuthority News – Why I am Going to Attend PASS Summit Unite 2010 – Seattle](https://blog.sqlauthority.com/2010/11/08/sqlauthority-news-why-i-am-going-to-attend-pass-summit-unite-2010-seattle/): I am once again attending SQLPASS this year.When I told this to my friend that I am going to SQL PASS again, he has the same question, which quite often many people ask. WHY? I had earlier wrote article on this subject. I am writing it again the same. The reason is simple – I love it! Why should I attend PASS Summit There is not one or two but a number of reasons regarding why I should be a part of PASS Summit. First, it is a good platform to learn the latest skills and strategies through over 160 expert-led... - [SQLAuthority News – Presenting at South East Asia SharePoint Conference – Oct 26, 27, 2010 – Singapore](https://blog.sqlauthority.com/2010/11/07/sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference/): Every SharePoint site runs on SQL Server and most of the SharePoint sites face issues with performance due to suboptimal configuration of underlying SQL Server. Recently, I presented a session on SharePoint and SQL Server Performance at Singapore on Oct 26-27, 2010. It was South East Asia SharePoint Conference, and I must say, the event was a blast! Pinal Dave presenting at SharePoint Conference at Singapore This was very a unique event in Asian Sub-Continent and also one of the best managed conferences that I have attended thus far. The location of the event was very good, and the rooms were... - [SQLAuthority News - Last Day to Participate in my Questions at SQL Quiz](https://blog.sqlauthority.com/2010/11/06/sqlauthority-news-last-day-to-participate-in-my-questions-at-sql-quiz/): My very good friend, Jacob Sebastian, is running a month-long SQL Quiz Series where the best-of-the-best experts from around the globe would be the quiz masters. They will ask one question every day, and users are expected to answer them correctly. The winning prizes include cool gadgets like iPAD, Kindle and many more. I am one of the quiz masters, and my question is published here: The View, The Table and The Clustered Index Confusion. I have asked there three questions. Q1. Does the table use an index created on itself? Q2. Does the view use an index created on itself?... - [SQLAuthority News - Happy Deepavali and Happy News Year](https://blog.sqlauthority.com/2010/11/05/sqlauthority-news-happy-deepavali-and-happy-news-year/): Diwali (also spelled Divali in other countries) or Deepavali is popularly known as the festival of lights. It literally means “array of light”. Diwali is the most important festival of the year and is celebrated with families performing traditional activities together in their homes. Deepavali is an official holiday in India. I pretty much work every day except today. I dedicate this day to my family. This is their day. Every year on Deepavali I share a database tips with all of my blog readers. I quite often get ask if I can help people with their systems performance. I am... - [SQL SERVER - Finding Last Backup Time for All Database](https://blog.sqlauthority.com/2010/11/04/sql-server-finding-last-backup-time-for-all-database/): Here is the quick script I use find last backup time for all the database in my server instance. - [SQL SERVER - Fix: Error: MS Jet OLEDB 4.0 cannot be used for distributed queries because the provider is used to run in apartment mode.](https://blog.sqlauthority.com/2010/11/03/sql-server-fix-error-ms-jet-oledb-4-0-cannot-be-used-for-distributed-queries-because-the-provider-is-used-to-run-in-apartment-mode/): I recently got email from blog reader with following error. MS Jet OLEDB 4.0 cannot be used for distributed queries because the provider is used to run in apartment mode. The fix of the same is very easy. Fix/Workaround/Resolution: sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ad Hoc Distributed Queries', 1; GO RECONFIGURE; GO If you are still facing the error after running above statement please leave a comment here and I will do my best to help you out. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Are you a Database Administrator or a Database Developer?](https://blog.sqlauthority.com/2010/11/02/sql-server-are-you-a-database-administrator-or-a-database-developer/): This blog post is written in response to T-SQL Tuesday hosted by Paul Randal. I think following questions has been always very interesting question for everybody who is working with SQL Server. Are you a Database Administrator or Database Developer? The answer of this question varies from organizations to organizations and to countries to countries. Quite often I see people call them developer and doing tasks of backup and restore of the database. Often I see Administrator writing efficient code in application development. I totally understand that it is almost impossible to draw a line and quite often we are comfortable... - [SQLAuthority News - 4th Birthday of Blog - 20 Million Views - Blog Anniversary - A Milestone](https://blog.sqlauthority.com/2010/11/01/sqlauthority-news-4th-birthday-of-blog-blog-anniversary-a-milestone/): Today is Nov 1, 2010. Four years ago, on the same day of the year 2006,  I wrote my first blog without thinking or even understanding where this blog was going to. The reason I started blogging was very simple- I just wanted to keep a note of what I learn every day. It was really that simple. This blog also have completed 20 Million Views! I will post a detail statistics very soon in separate post. Today is this blog’s 4th birthday. It has completed the long journey of 4 years. I previously explained the reason of the origin of... - [SQLAuthority News – New Banner of Blog](https://blog.sqlauthority.com/2010/10/31/sqlauthority-news-new-banner-of-blog/): As this blog is approaching 4th anniversary, I have decided to change few things in this blog. I have finally decided to change the blog banner and I have created internal poll for the blog banner. I have uploaded the winning banner as the title of the blog and I liked it a lot. I would like to know your opinion about the same. The changes I have done from the previous banners are Bigger Images Bigger Logo A cleaning up edges Please visit the site https://blog.sqlauthority.com/ and give me your opinion about banner. Reference: Pinal Dave (https://blog.sqlauthority.com)   - [SQL SERVER - Minimum Maximum Memory - Server Memory Options](https://blog.sqlauthority.com/2010/10/30/sql-server-minimum-maximum-memory-server-memory-options/): I was recently reading about SQL Server Memory Options over here. While reading this one line really caught my attention is minimum value allowed for maximum memory options. The default setting for min server memory is 0, and the default setting for max server memory is 2147483647. The minimum amount of memory you can specify for max server memory is 16 megabytes (MB). This was very interesting to me as I was not familiar with this details. This was one interesting detail for me. In reality I will never set up my max server memory to 16 MB, it will be right... - [SQL SERVER - List of all the Views from Database](https://blog.sqlauthority.com/2010/10/29/sql-server-list-of-all-the-views-from-database/): My earlier article SQL SERVER – The Limitations of the Views – Eleven and more… has lots of popularity and I have been asked many questions on the view. Many emails I received suggesting that they have hundreds of the view and now have no clue what is going on and how many of them have indexes and how many does not have an index. Some even asked me if there is any way they can get a list of the views with the property of Index along with it. - [SQLAuthority News – Blog of Nupur Dave on Windows Live](https://blog.sqlauthority.com/2010/10/28/sqlauthority-news-blog-of-nupur-dave-on-windows-live/): Blog are way to express ourselves; Blogs are bookmarks of my learning process and blogs reflects us. My Wife Nupur, an avid user of Windows Live, has decided to start blogging on the subject. There was lots of discussion between us regarding if she really wants to blog or keep her learning offline. One of the discussions we had was regarding what new she can add to the world which is already populated and overloaded with information. Her answer was very simple: “My perspective“. I respect her for the same and that is why she is blogging now. The blog is just... - [SQL SERVER - SQL Challenge - SQL Puzzle - Query Creating Most TempDB IO Usage](https://blog.sqlauthority.com/2010/10/27/sql-server-sql-challenge-sql-puzzle-query-creating-most-tempdb-io-usage/): Recently, there have been a lot of interesting concepts in various challenges. My friend Jacob Sebastian is running the SQLQuiz for the entire month, and it has been very popular and going just great. So here I thought I would put something very similar to the quiz bee. The award here is simple, all valid answers will be published on this blog with due credit to you, plus the credit would link back to your desired profile. Now the question is: What are the queries which are creating lots of IO operations in TempDB? You can use any DMV to answer... - [SQLAuthority News - Database Performance for SharePoint Sites - Session Tomorrow in Singapore](https://blog.sqlauthority.com/2010/10/26/sqlauthority-news-database-performance-for-sharepoint-sites-session-tomorrow-in-singapore/): I am all excited to present my very first session on Database Performance for SharePoint Sites. Here is the details for my session which is planned for tomorrow. Grand Copthorne Waterfront Hotel Singapore 392 Havelock Road Singapore 169663 My Sessions details: Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site! Date: Oct 27, 2010 Time: 1:30 PM Venue: Grand Copthorne Waterfront Hotel (Waterfront Conference Centre) During the session I will be presenting three demos. I have worked hard to come up with this demos. Here is the details for the same. SQLAuthority News – SQLAuthority News – Presenting at... - [SQL SERVER – A Brief Introduction to DW 2.0](https://blog.sqlauthority.com/2010/10/25/sql-server-a-brief-introduction-to-dw-2-0/): The traditional form of storing digital data has been disk storage.  However, the huge advances in technology means that there has been a huge need for data storage to evolve to keep up with the fast-changing times.  Microsoft SQL Server has gone through a huge overhaul in order to keep up with the amount of data storage that is necessary, and that is where data warehousing comes into play. For many online applications, there is a need to not only access small amount of information from disk storage, but large amounts in the forms of sets.  SQL Server allows access to... - [SQL SERVER - Corrupted Backup File and Unsuccessful Restore](https://blog.sqlauthority.com/2010/10/24/sql-server-corrupted-backup-file-and-unsuccessful-restore/): If you are an SQL Server Consultant, there is never a single dull moment in your life. Quite often you are called in for fixing something, but then you always end up fixing something else! I was recently working on an offshore project where I was called in to tune high transaction OLTP server. During work, I demanded that I should have a server which is very similar to live database so I could inspect all the settings and data. I may end up running a few queries which may or may not change the server settings. The Sr. DBA agreed... - [SQL SERVER - Taking Multiple Backup of Database in Single Command - Mirrored Database Backup](https://blog.sqlauthority.com/2010/10/23/sql-server-taking-multiple-backup-of-database-in-single-command-mirrored-database-backup/): I recently had a very interesting experience. In one of my recent consultancy works, I was told by our client that they are going to take the backup of the database and will also a copy of it at the same time. I expressed that it was surely possible if they were going to use a mirror command. In addition, they told me that whenever they take two copies of the database, the size of the database, is always reduced. Now this was something not clear to me, I said it was not possible and so I asked them to show... - [SQLAuthority News – SQLAuthority News – Presenting at South East Asia SharePoint Conference – Demo Details](https://blog.sqlauthority.com/2010/10/22/sqlauthority-news-sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference-demo-details/): I will be Presenting at South East Asia SharePoint Conference – Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site. I am very excited beuse this is going to be my very first series of presentations at SharePoint Conference. Since I posted details about the event, I have been asked many times about the kind of demo I will be having in the session. If you are a regular reader of this blog, you know that my core area is performance tuning. I am going to focus on the same subject when I present at the SharePoint Conference. I... - [SQLAuthority News - Book Review - Beginning SQL Joes 2 Pros: The SQL Hands-On Guide for Beginners](https://blog.sqlauthority.com/2010/10/21/sqlauthority-news-book-review-beginning-sql-joes-2-pros-the-sql-hands-on-guide-for-beginners/): Beginning SQL Joes 2 Pros: The SQL Hands-On Guide for Beginners Rick A Morelan, Doug Fritz Link to Amazon Short Review: This is one book that provides a solid fundamental to the reader along with hands-on experience  and in-depth learning. Right now, an error-free book that is closer to real world scenarios is very much in need. This one fundamental book can take the reader for a wonderful ride, where he/she can learn the advanced aspects of the subject very quickly. Instead of pure theory, this book focuses on real diagrams, examples or just a pure old–school-style exercise, which appeals the... - [SQL SERVER – Could not connect to TCP error code 10061: No connection could be made because the target machine actively refused it](https://blog.sqlauthority.com/2010/10/20/sql-server-could-not-connect-to-tcp-error-code-10061-no-connection-could-be-made-because-the-target-machine-actively-refused-it/): I was recently getting following error in my StreamInsight Application. Could not connect to  TCP error code 10061: No connection could be made because the target machine actively refused it. The solution was very simple, I had to enable exception of the my port in my windows firewall. The way I figured it out  was by quickly disabling the firewall (it was not a production server). Once I disabled it, the application just worked fine; this was a sign that the firewall was the cause of the issue, I right away enabled firewall and added my port as exception. So many... - [SQLAuthority News - SQL Server Performance Optimizations Seminar - Grand Success - Colombo, Sri Lanka - Oct 4 - 5, 2010](https://blog.sqlauthority.com/2010/10/19/sqlauthority-news-sql-server-performance-optimizations-seminar-grand-success-colombo-sri-lanka-oct-4-5-2010/): I have been on world tour on SQL Server Performance Optimizations Seminar. The latest seminar was conducted in Colombo, Sri Lanka on Oct 4 – Oct 5. I had previously written about this event over SQLAuthority News – SQL Server Seminar at Colombo Full. This event was oversubscribed and we could not accommodate the last few nominations due to the restrictions of the place. We had total of 35 attendees and the event offered lots of fun. The attendees were a perfect combination – all had few years of experience and many of them were responsible for performance for their server.... - [SQL SERVER - Change Column DataTypes](https://blog.sqlauthority.com/2010/10/18/sql-server-change-column-datatypes/): There are times when I feel like writing that I am a day older in SQL Server. In fact, there are many who are looking for a solution that is simple enough. Have you ever searched online for something very simple. I often do and enjoy doing things which are straight forward and easy for change. In this blog post, we will see to Change Column DataTypes - [SQL SERVER - System Stored Procedure sys.sp_tables](https://blog.sqlauthority.com/2010/10/17/sql-server-system-stored-procedure-sys-sp_tables/): I have seen people running the following script quite often, to know the list of the tables from the database: SELECT * FROM sys.tables GO The script above provides various information from create date to file stream, and many other important information. If you need all those information, that script is the one for you. However, if you do not need all those information, I suggest that you run the following script: EXEC sys.sp_tables GO The script above will give all the tables in the table with schema name and qualifiers. Additionally, this will return all the system catalog views together... - [SQL SERVER - StreamInsight and SQL Server 2008 R2](https://blog.sqlauthority.com/2010/10/16/sql-server-streaminsight-and-sql-server-2008-r2/): I was recently called into create POC (Proof of Concept) for a project which was being planned for use StreamInsight. When I was there, I was also asked to give overview of the this feature to their CTO (who had only 15 minutes to spare). Usually I do not like sudden change of plans but the dynamic nature of consultation always gives me motivation to work more. I quickly talked few things in the session. In the evening, I had received the minutes of the meeting and had brief note regarding my discussion on StreamInsight. I am copy pasting the same brief note over here. - [SQLAuthority News – Microsoft WhitePaper on PowerPivot Data Refresh](https://blog.sqlauthority.com/2010/10/15/sqlauthority-news-microsoft-whitepaper-on-powerpivot-data-refresh/): I was recently working at customer location on PowerPivot project. It was quite complected as this is relatively new technology and we all are exploring what this technology can do and what it can bring to us on table in real life experience. During this implementation the project design document needed specification regarding Data Refresh rates. It was a bit complected as there were various components and modules to the project and selecting the refresh rates means understand all of the requirement as well understanding our implementation in and out. I referred following white paper from Microsoft before I move further... - [SQL SERVER - 1500 Posts - A MileStone - Origin of Blog Name Revealed](https://blog.sqlauthority.com/2010/10/14/sql-server-1500-posts-a-milestone-original-of-blog-name-revealed/): This is my 1500th blog post. I am very happy. In my earlier 1400th blog post mile stone, I made a promise that I would explain why I have chosen SQLAuthority.com as my blog’s name. Let me share with you the story about how I came up with the name. In my earlier career days, I was used to code in ColdFusion programming language, and there was a site called Fusion Authority. I was always referring to it whenever I had to get any latest details of the subject. The name inspired me so I started checking out if there were... - [SQL SERVER - Visiting Alma Mater - Delivering Session on Database Performance and Career - Nirma Institute of Technology](https://blog.sqlauthority.com/2010/10/13/sql-server-visiting-alma-mater-delivering-session-on-database-performance-and-career-nirma-institute-of-technology/): Everyone always dream of visiting their school and college, where they have had studied once. It is a great feeling to see the college once again – where you have spent the wonderful golden years of your time. College time is filled with studies, education, emotions and several plans to build future. I consider myself fortunate as I got the opportunity to study at some of the best places in the world. I have earned my Bachelors in Engineering in Electronics and Communication from Nirma Institute of the Technology (NIT), Ahmedabad, India. I must say that this is one of the... - [SQL SERVER - Indexed View always Use Index on Table](https://blog.sqlauthority.com/2010/10/12/sql-server-indexed-view-always-use-index-on-index/): This blog post is written in response to T-SQL Tuesday hosted by Shankar Reddy. I have been recently writing about Views and their Limitations. While writing this article series, I got inspired to write about SQL Server Quiz Questions. You can view the Quiz Question posted over here. In SQL Server 2005, a single table can have maximum 249 non clustered indexes and 1 clustered index. In SQL Server 2008, a single table can have maximum 999 non clustered indexes and 1 clustered index. It is widely believed that a table can have only 1 clustered index, and this belief is... - [SQLAuthority News - Presenting at South East Asia SharePoint Conference - Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site](https://blog.sqlauthority.com/2010/10/11/sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference-maintaining-sql-server-at-optimal-performance-for-blazing-fast-sharepoint-site/): I am delighted and very excited as I am going to attend very first time SharePoint Conference. Even though I will be attending SP conference, I will be presenting on my favorite subject – SQL Server Performance. Every SharePoint site runs on SQL Server and most of the SharePoint sites face issues with performance due to suboptimal configuration of underlying SQL Server. This session will be very unique. I will be starting with a bit pessimistic talk about how one cannot many things in SQL Server when SharePoint Server is installed. I will go over in the details for the reasons... - [SQL SERVER - Encrypted Stored Procedure and Activity Monitor](https://blog.sqlauthority.com/2010/10/10/sql-server-encrypted-stored-procedure-and-activity-monitor/): I recently had received question if any stored procedure is encrypted can we see its definition in Activity Monitor. - [SQLAuthority News - SQL Server 2008 Add-ins and Feature Pack Downloads](https://blog.sqlauthority.com/2010/10/09/sqlauthority-news-sql-server-2008-add-ins-and-feature-pack-downloads/): Here are few of the latest Microsoft Add-ins and downloads recently announced. SQL Server Reporting Services Add-in for SharePoint Technologies The Microsoft SQL Server 2008 SP2 Reporting Services Add-in for Microsoft SharePoint Technologies is a Web download that provides features for running a report server within a larger deployment of Windows SharePoint Services 3.0 or Microsoft Office SharePoint Server 2007. SQL Server Data Mining Add-ins for Office 2007 Download SQL Server 2008 Data Mining Add-ins for Office 2007. This package includes two add-ins for Microsoft Office Excel 2007 (Table Analysis Tools and Data Mining Client) and one add-in for Microsoft Office... - [SQL SERVER - Simple Explanation of Data Type Precedence](https://blog.sqlauthority.com/2010/10/08/sql-server-simple-explanation-of-data-type-precedence/): While I was working on creating a question for SQL SERVER – SQL Quiz – The View, The Table and The Clustered Index Confusion, I had actually created yet another question along with this question. However, I felt that the one which is posted on the SQL Quiz is much better than this one because what makes that question more challenging is that it has a multiple answer. Here is the question regarding Simple Explanation of Data Type Precedence: Run the following example first and then observe the query execution plan. USE tempdb GO CREATE TABLE FirstTable (ID INT, Col VARCHAR(100))... - [SQL SERVER - SQL Quiz - The View, The Table and The Clustered Index Confusion](https://blog.sqlauthority.com/2010/10/07/sql-server-sql-quiz-the-view-the-table-and-the-clustered-index-confusion/): My very good friend, Jacob Sebastian, is running a month-long SQL Quiz Series where the best-of-the-best experts from around the globe would be the quiz masters. They will ask one question every day, and users are expected to answer them correctly. The winning prizes include cool gadgets like iPAD, Kindle and many more. I am one of the quiz masters, and my question is published here: The View, The Table and The Clustered Index Confusion. I have asked there three questions. However, the real important question is: Bonus Question: Does this mean that my table has two effective clustered indexes now?... - [SQL SERVER – Quickest Way to Identify Blocking Query and Resolution – Dirty Solution](https://blog.sqlauthority.com/2010/10/06/sql-server-quickest-way-to-identify-blocking-query-and-resolution-dirty-solution/): As the title suggests, this is quite a dirty solution; it’s not as elegant as you expect. The Story: I got a phone call at night (11 PM) from one of my old friends, requesting a hand. He asked me if I could help him with a very strange situation. He was facing a condition where he was not able to delete data from a table. He already tried to TRUNCATE, DELETE and DROP on the table, but still no luck. I demanded him to let me access it; however, he had to say “No” due to security reasons. Even though... - [SQL SERVER - Error : Fix : Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file failed with the operating system error 2(The system cannot find the file specified.)](https://blog.sqlauthority.com/2010/10/05/sql-server-error-fix-msg-5133-level-16-state-1-line-2-directory-lookup-for-the-file-failed-with-the-operating-system-error-2the-system-cannot-find-the-file-specified/): I recently got email from friend who had suffered from following error. Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.). Msg 1802, Level 16, State 1, Line 2 CREATE DATABASE failed. Some file names listed could not be created. Check related errors. Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.). Msg 1802, Level 16, State 1, Line 2 CREATE DATABASE failed. Some file... - [SQL SERVER - Find Total Number of Transactions on Interval](https://blog.sqlauthority.com/2010/10/04/sql-server-find-total-number-of-transaction-on-interval/): In one of my recent Performance Tuning assignment I was asked how do someone know how many transactions are happening on server during certain interval. I had handy script for the same. Following script displays transactions happened on server at the interval of one minute. You can change the WAITFOR DELAY to any other interval and it should work. - [SQL SERVER - The Limitations of the Views - Eleven and more...](https://blog.sqlauthority.com/2010/10/03/sql-server-the-limitations-of-the-views-eleven-and-more/): I had earlier written, interesting article series on the limitations of the views. I had a great time writing this series. I got many many requests. - [SQLAuthority News - SQL Server Seminar at Colombo Full - Hyderabad Few Seats Available](https://blog.sqlauthority.com/2010/10/02/sqlauthority-news-sql-server-seminar-at-colombo-full-hyderabad-few-seats-available/): If you are familiar with my blog, you might be aware of that I am doing world-wide seminar on SQL Server Seminars. I have lots of request to do the event in various cities, now our plan is very simple and to do this in very few cities. Our current seminar at Colombo is sold out and we have 40 confirmed registrations over 35 available spaces. We have also waiting list of the 10 students and we will see if we can accommodate the same. I have received many request from India for the same seminar, here is the quick update... - [SQL SERVER – Get Query Running in Session](https://blog.sqlauthority.com/2010/10/01/sql-server-get-query-running-in-session/): I was recently looking for syntax where I needed a query running in any particular session. I always remembered the syntax and ha d actually written it down before, but somehow it was not coming to mind quickly this time. I searched online and I ended up on my own article written last year SQL SERVER – Get Last Running Query Based on SPID. I felt that I am getting old because I forgot this really simple syntax. This post is a refresher to me. I knew it was something so familiar since I have used this syntax so many times... - [SQL SERVER - Microsoft SQL Server 2008 Service Pack 2 Download](https://blog.sqlauthority.com/2010/09/30/sql-server-microsoft-sql-server-2008-service-pack-2-download/): Microsoft SQL Server 2008 Service Pack 2 (SP2) is now available for download. You can download your preferred version from link here. The major enhancements are as following: 15K partitioning Improvement. Reporting Services in SharePoint Integrated Mode. SQL Server 2008 R2 Application and Multi-Server Management Compatibility with SQL Server 2008. SQL Server 2008 Instance Management. Data-tier Application (DAC) Support. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Monthly Roundup of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/09/30/sqlauthority-news-monthly-roundup-of-sqlauthority-blog-posts/): Since I started the monthly round up of the blog post, I have received many positive feedback. I plan to continue doing this month refresher every month now. This rounds ups are my mirror and informs me what I have been doing whole month. Here is quick look at the last month. The month started very interesting with my daughter’s birthday SQLAuthority News – Fathers and Daughters. As this was very first birthday it was very special for me. I had great time enjoying with her quality time and it was all fun. I am an MVP and I am one... - [SQL SERVER - View Over the View Not Possible with Index View - Limitations of the View 11](https://blog.sqlauthority.com/2010/09/29/sql-server-view-over-the-view-not-possible-with-index-view-limitations-of-the-view-11/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… When I wrote the article about SQL SERVER – Adding Column is Expensive by Joining Table Outside View – Limitation of the Views Part 2, I had received a comment that said: “If joining column is expensive to the view, why can’t I create a view over the view and create an index on it?” The answer is simple: It’s actually another limitation of the View. You cannot create an Index on a nested View situation. The following example where... - [SQLAuthority News - SQL Health Check and SQL Seminars](https://blog.sqlauthority.com/2010/09/28/sqlauthority-news-sql-health-check-and-sql-seminars/): After announcing the SQL Seminar series and SQL Health Check series, there has been a great response from them. I already have signed up assignments until December 2010 Mid Week for doing various health checks for different organizations. One thing that I noticed is that there’s something common and popular in many  health check services– the Wait Stats. SQL Server Resource Wait Stats Analysis Wait Stat Analysis is very crucial for optimizing databases, but it is often overlooked due to lack of understanding. We perform advanced resource Wait Statistics Analysis and provide you with suggestions to optimize your database server. We... - [SQL SERVER - Keywords View Definition Must Not Contain for Indexed View - Limitation of the View 10](https://blog.sqlauthority.com/2010/09/27/sql-server-keywords-view-definition-must-not-contain-for-indexed-view-limitation-of-the-view-10/): I have recently written many articles on the limitation of the views. I have tried to sum up all the keywords which are not allowed in the indexed view. - [SQL SERVER – SELF JOIN Not Allowed in Indexed View – Limitation of the View 9](https://blog.sqlauthority.com/2010/09/26/sql-server-self-join-not-allowed-in-indexed-view-limitation-of-the-view-9/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Previously, I wrote an article about SQL SERVER – The Self Join – Inner Join and Outer Join, and that blog post seems very popular because of its interesting points. It is quite common to think that Self Join is also only Inner Join, but the reality is that it can be anything. The concept of Self Join is very useful that we use it quite often in our coding. However, this is not allowed... - [SQL SERVER – Get Numeric Value From Alpha Numeric String – Get Numbers Only](https://blog.sqlauthority.com/2010/09/25/sql-server-get-numeric-value-from-alpha-numeric-string-get-numbers-only/): I have earlier wrote article about SQL SERVER – Get Numeric Value From Alpha Numeric String – UDF for Get Numeric Numbers Only and it was very handy tool for me. Recently blog reader and SQL Expert Christofer has left excellent improvement to this logic. Here is his contribution. He has provided Stored Procedure and the same can be easily converted to Function. CREATE PROCEDURE [dbo].[CleanDataFromAlpha] @alpha VARCHAR(50), @decimal DECIMAL(14, 5) OUTPUT AS BEGIN SET NOCOUNT ON; DECLARE @ErrorMsg VARCHAR(50) DECLARE @Pos INT DECLARE @CommaPos INT DECLARE @ZeroExists INT DECLARE @alphaReverse VARCHAR(50) DECLARE @NumPos INT DECLARE @Len INT -- 1 Reverse... - [SQL SERVER - Outer Join Not Allowed in Indexed Views - Limitation of the View 8](https://blog.sqlauthority.com/2010/09/24/sql-server-outer-join-not-allowed-in-indexed-views-limitation-of-the-view-8/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… This blog post was previously published over here. I am republishing it in the series Limitation of the Views with a few modifications. While reading the white paper Improving Performance with SQL Server 2008 Indexed Views, I noticed that it says outer joins are NOT allowed in the indexed views. Here, I have created an example to demonstrate why this is so. Rows can logically disappear from an Indexed View based on OUTER JOIN when... - [SQL SERVER - Cross Database Queries Not Allowed in Indexed View - Limitation of the View 7](https://blog.sqlauthority.com/2010/09/23/sql-server-cross-database-queries-not-allowed-in-indexed-view-limitation-of-the-view-7/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… One of the requirements of Indexed View is that it has to be created ‘WITH SCHEMABINDING’. If the View is not created with that clause, it would not let you create an index on that View. Moreover, if you try to create a View with schemabinding, it would not allow you to create the database. -- Create DB USE MASTER GO CREATE DATABASE TEST1 CREATE DATABASE TEST2 GO -- Table1 USE Test1 GO CREATE TABLE... - [SQL SERVER - UNION Not Allowed but OR Allowed in Index View - Limitation of the View 6](https://blog.sqlauthority.com/2010/09/22/sql-server-union-not-allowed-but-or-allowed-in-index-view-limitation-of-the-view-6/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… If you want to create an Indexed View, you ought to know that UNION Operation is not allowed in Indexed View. It is quite surprising at times when the UNION operation looks very innocent and seems that it cannot be used in the View. Before an in-depth understanding this subject, let me show you a script where UNION is not allowed in Indexed View: USE tempdb GO IF EXISTS (SELECT * FROM sys.views WHERE OBJECT_ID =... - [SQL SERVER - COUNT(*) Not Allowed but COUNT_BIG(*) Allowed - Limitation of the View 5](https://blog.sqlauthority.com/2010/09/21/sql-server-count-not-allowed-but-count_big-allowed-limitation-of-the-view-5/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… One of the most prominent limitations of the View it is that it does not support COUNT(*); however, it can support COUNT_BIG(*) operator. In the following case, you see that if View has COUNT (*) in it already, it cannot have a clustered index on it. On the other hand, a similar index would be created if we change the COUNT (*) to COUNT_BIG (*).For an easier understanding of this topic, let us see the... - [SQL SERVER - How to Stop Growing Log File Too Big](https://blog.sqlauthority.com/2010/09/20/sql-server-how-to-stop-growing-log-file-too-big/): I was recently engaged in Performance Tuning Engagement in Singapore. The organization had a huge database and had more than a million transactions every hour. During the assignment, I noticed that they were truncating the transactions log. This really alarmed me so I informed them this should not be continued anymore because there’s really no need of truncating or shortening the database log. The reason why they were truncating the database log was that it was growing too big and they wanted to manage its large size. I provided two different solutions for them. Now let’s venture more on these solutions.... - [SQL SERVER - SSRS 2008 R2 - MapGallery - World Map](https://blog.sqlauthority.com/2010/09/19/sql-server/): SQL Server 2008 R2 has negatively integrated ability to work with maps. There are few ways how one can select map and use them in their projects. The one I recently came across was MapGallery. By default SQL Server 2008 R2 is enabled for USA maps. This is quite a common request from developers around the globe that they want the same feature available in their own country. - [SQL SERVER - 2008 R2 - PowerPivot for Microsoft Excel 2010 - RTM](https://blog.sqlauthority.com/2010/09/18/sql-server-2008-r2-powerpivot-for-microsoft-excel-2010-rtm/): Microsoft PowerPivot for Microsoft Excel 2010 provides ground-breaking technology, such as fast manipulation of large data sets (often millions of rows), streamlined integration of data, and the ability to effortlessly share your analysis through Microsoft SharePoint 2010. I have recently started to work with SQL Server 2008 R2 and find the product extremely stable and feature complete. I have installed PowerPivot and I am finding it to be also integrating very well with the product. I recently did one presentations using this two technology and worked very well. Let me know if you are using PowerPivot for your power BI users.... - [SQLAuthority News - How to Subscribe to this Blog?](https://blog.sqlauthority.com/2010/09/17/sqlauthority-news-how-to-subscribe-to-this-blog/): How do I subscribe to this blog? I have received this question quite a few times, and have answered them accordingly. As we all know, blogs are part of a social network, and the whole social networking thing is very interesting as everything in it is interwoven together. Let us see in how many different ways you can stay connected with this blog. 1. Email Subscription. If you go to the home page of this blog and scroll down a bit, you will see the following image. Simply enter your email address where you wish to receive notifications of new blog... - [SQLAuthority News - What is an MVP? - How to become an MVP?](https://blog.sqlauthority.com/2010/09/16/sqlauthority-news-what-is-an-mvp-how-to-become-an-mvp/): There are a lot of basic questions I get that inquires about being an MVP. - [SQL SERVER – SELECT * and Adding Column Issue in View – Limitation of the View 4](https://blog.sqlauthority.com/2010/09/15/sql-server-select-and-adding-column-issue-in-view-limitation-of-the-view%c2%a04/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… - [SQL SERVER - Disabled Index and Index Levels and B-Tree](https://blog.sqlauthority.com/2010/09/14/sql-server-disabled-index-and-index-levels-and-b-tree/): This blog post is written in response to T-SQL Tuesday hosted by Michael J. Swart. Recently, I presented a session at the Microsoft Bangalore office. Everybody eagerly wanted to learn more, to the extent that they wanted a mentor to train each of them in order to move on to the next level. I have many mentors worldwide as I keep on traveling, in addition to being already a part of Solid Quality Mentors. However, if I have to take one name in India, I will take the name of Vinod Kumar, who has given me many insights and helped me... - [SQL SERVER - What are Wait Types, Wait Stats and its Importance](https://blog.sqlauthority.com/2010/09/13/sql-server-what-are-wait-types-wait-stats-and-its-importance/): Earlier last month Solid Quality India announced SQL Server Health Check Service and since then, it has got very good response from the industry. However, the only question we are be asked all the time is: “What is “SQL Server Resource Wait Stats Analysis” and how can it be useful?”What caught my attention is that it seems everyone understood what the other details on the page mean, but most of them have a query regarding Wait Stats and their importance. For such a long time, even I wasn’t sure what Wait Stats are. Later on, I learned Wait Stats from Andrew... - [SQL SERVER - Soft Delete Conversation - Your Opinion Needed](https://blog.sqlauthority.com/2010/09/12/sql-server-soft-delete-conversation-your-opinion-needed/): Last Week I wrote article about SQL SERVER – Soft Delete – IsDelete Column – Your Opinion and this article has got excellent community response. There have been some very interesting feedback on both the side. There are few opinions where expert have explained the conversation very balanced way. I am listing today here few of the conversations. You are welcome to provide further input on the same subject. I am listening here only abstract of the comment, click on the name to read the complete comment. jonmcrawford – She has very first very good explanation and votes for no, suggesting... - [SQLAuthority News - Download - Microsoft SQL Server 2008 R2 Best Practices Analyzer Whitepaper](https://blog.sqlauthority.com/2010/09/11/sqlauthority-news-download-microsoft-sql-server-2008-r2-best-practices-analyzer-whitepaper/): I had previously written article on SQL SERVER – Introduction to Best Practices Analyzer – Quick Tutorial. Microsoft has come up with white paper regarding same Best Practice Analyzer. In the new R2 version the SQL BPA introduces advanced capabilities in conjunction with the PowerShell architecture and also raises the bar for prerequisites and cross dependencies. Microsoft has just released white paper which discuses the best practices to use Best Practices Analyzer. This white paper covers very important aspects of the tools. They talk about Installations, Usage and Troubleshooting. Additionally this white paper covers Engine Rules and Powershell methodology. I suggest... - [SQL SERVER - Find Automatically Created Statistics - T-SQL](https://blog.sqlauthority.com/2010/09/10/sql-server-find-automatically-created-statistics-t-sql/): Earlier, I wrote about my experience at an organization here: SQL SERVER – Plan Cache – Retrieve and Remove – A Simple Script. This blog post briefly narrates another experience I had at the same organization. When I was there, I also looked at the statistics and found something that I would like to bring into the limelight. As the developers ran many non-production queries on the production server, many statistics were automatically created on the table. These stats were not useful as they were created by several queries which ran one-time or ad-hoc. Because of this, we really had to... - [SQL SERVER - Quickly Upgrade Your SQL Server](https://blog.sqlauthority.com/2010/09/09/sql-server-quickly-upgrade-your-sql-server/): In this blog post, I will talk about how you can use Docker to quickly upgrade your SQL Server. I discuss docker in this blog post. - [SQL SERVER – Find Row Count in Table – Find Largest Table in Database – Part 2](https://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/): Last Year I wrote article on the subject SQL SERVER – Find Row Count in Table – Find Largest Table in Database – T-SQL. It is very good to see excellent participation there. In my script I had not taken care of table schema. SQL Server Expert Ameena has modified the same script to include the schema. Here is the new modified script. SELECT sc.name +'.'+ ta.name TableName ,SUM(pa.rows) RowCnt FROM sys.tables ta INNER JOIN sys.partitions pa ON pa.OBJECT_ID = ta.OBJECT_ID INNER JOIN sys.schemas sc ON ta.schema_id = sc.schema_id WHERE ta.is_ms_shipped = 0 AND pa.index_id IN (1,0) GROUP BY sc.name,ta.name ORDER... - [SQL SERVER - Index Levels and Delete Operations - Page Level Observation](https://blog.sqlauthority.com/2010/09/07/sql-server-index-levels-and-delete-operations-page-level-observation/): I wrote an article before on SQL SERVER – Index Levels, Page Count, Record Count and DMV – sys.dm_db_index_physical_stats. In that article, I promised that I would give a follow up post with a few more interesting details. I suggest that you go over the earlier article first to understand the details on B-Tree and Index Level. Today we will see one of the fascinating aspects of Delete Operations. Update: This blog post contained few factual errors and they were clearly pointed out by Hrvoje Piasevoli over here. Based on his comment, I have modified this blog post. I will include... - [SQL SERVER - Index Created on View not Used Often - Limitation of the View 3](https://blog.sqlauthority.com/2010/09/06/sql-server-index-created-on-view-not-used-often-limitation-of-the-view-3/): Update: Please read the summary post of all the 11 Limitation of the view SQL SERVER – The Limitations of the Views – Eleven and more… Let us learn about Index Created on View not Used Often. - [SQLAuthority News - USB Drive Fails to Copy Large File](https://blog.sqlauthority.com/2009/08/14/sqlauthority-news-usb-drive-fails-to-copy-large-file/): I am currently traveling on a month-long training assignment for Business Intelligence. For demonstration purposes, I use Virtual PC files and hands-on lab examples for attendees of the training. The size of my VPC file is about 15 GB. Initially, I copy this file to a USB Drive and then move it to other computers, as needed. Recently, while trying to copy my VPC file to my USB drive I received the following error: Error Copying File or Folder. Cannot Copy. There is not enough free disk space. I had never experienced this problem before. I tried copying it a few... - [SQL SERVER - Reason for SQL Server Agent Starting Before SQL Server Engine Service](https://blog.sqlauthority.com/2009/08/13/sql-server-reason-for-sql-server-agent-starting-before-sql-server-engine-service/): Nakul, a dedicated member of the Gandhinagar SQL Server User Group, recently emailed me with a very interesting, but quick question. He asked me why the SQL Server Agent starts before SQL Server Engine does? He made the very valid point that as the SQL Server Engine is the core service, it should start first, and there is little point to running the SQL Server Agent without it. Off the top of my head, I can offer the following quick reasons for this sequence: The SQL Server Engine does not only run jobs for SQL Server Engine itself. It also runs... - [SQL SERVER - Backup master Database Interval - master Database Best Practices](https://blog.sqlauthority.com/2009/08/12/sql-server-backup-master-database-interval-master-database-best-practices/): During a recent consultancy project, I was asked to review a Database Backup plan. While going through the plan, I noticed that there was no backup for the master database. When I questioned this, the DBA informed me that it was not necessary. I was startled and couldn’t resist explaining to him that the master database contains all the logon accounts details, as well as all the system-level database configuration. He was a little astounded and asked me to tell him at what intervals he should backup the master database. The discussion that followed was very thought provoking and I would... - [SQL SERVER - Discussion - Effect of Missing Identity on System - Real World Scenario](https://blog.sqlauthority.com/2009/08/11/sql-server-discussion-effect-of-missing-identity-on-system-real-world-scenario/): About a week ago, SQL Server Expert, Imran Mohammed, provided a script, which will list all the missing identity values of a table in a database. In this post, I asked my readers if any could write a similar or better script. The results were interesting. While no one provided a new script, my question sparked a very active discussion that is still ongoing. When providing the script, Imran asked me if I knew of any specific circumstances in which this kind of query could be useful, as he could not think of an instance where it would be necessary to... - [SQLAuthority News - A Quick Guide to Twitter](https://blog.sqlauthority.com/2009/08/10/sqlauthority-news-a-quick-guide-to-twitter/): I am a very big fan of Twitter. I have been using it for quite sometime now and I think it is a very convenient way to stay connected with friends, families, and even the world. You can share or connect with them in real-time and tell them what you are doing currently. The best part about it is micro-blogging; you are not required to type a whole blog but just a statement of not more than 140 characters. Another advantage is that if you want to put a link then Twitter truncates the url to a tinyurl.com link, thus you... - [SQLAuthority News - Interview with SQL Server MVP Glenn Berry](https://blog.sqlauthority.com/2009/08/09/sqlauthority-news-interview-with-sql-server-mvp-glenn-berry/): Glenn Berry works as a Database Architect at NewsGator Technologies in Denver, CO. He is a SQL Server MVP, and has a whole collection of Microsoft certifications, including MCITP, MCDBA, MCSE, MCSD, MCAD, and MCTS. He is also an Adjunct Faculty member at University College – University of Denver, where he has been teaching since 2000. He is one wonderful blogger and often blogs at here. 1) Please tell us something about yourself. I have been working as a Database Architect at NewsGator Technologies for about 3.5 years. Before that, I worked as a Performance Architect at a company called Mortgage... - [SQL Server - Multiple CTE in One SELECT Statement Query](https://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/): I have previously written many articles on CTE. One question I get often is how to use multiple CTE in one query or multiple CTE in SELECT statement. Let us see quickly two examples for the same. I had done my best to take simplest examples in this subject. Option 1 : /* Method 1 */ ;WITH CTE1 AS (SELECT 1 AS Col1), CTE2 AS (SELECT 2 AS Col2) SELECT CTE1.Col1,CTE2.Col2 FROM CTE1 CROSS JOIN CTE2 GO Option 2: /* Method 2 */ ;WITH CTE1 AS (SELECT 1 AS Col1), CTE2 AS (SELECT COL1+1 AS Col2 FROM CTE1) SELECT CTE1.Col1,CTE2.Col2 FROM CTE1 CROSS JOIN CTE2 GO Please... - [SQLAuthority News - Humorous SQL Cake - Funny SQL Cake](https://blog.sqlauthority.com/2009/08/07/sqlauthority-news-humorous-sql-cake-funny-sql-cake/): I  received the following interesting images in email during the past 2 months. I think they are superbly hilarious! I received them from various people at different times, so their is unknown. Let me know which of the following images you find the most interesting. Hope you enjoyed watching them! Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Get Time in Hour:Minute Format from a Datetime - Get Date Part Only from Datetime](https://blog.sqlauthority.com/2009/08/06/sql-server-get-time-in-hourminute-format-from-a-datetime-get-date-part-only-from-datetime/): I have seen scores of expert developers getting perplexed with SQL Server in finding time only from datetime datatype. Let us have a quick glance look at the solution. Let us learn about how to get Time in Hour:Minute Format from a Datetime as well as to get Date Part Only from Datetime. - [SQL SERVER - Get a List of Fixed Hard Drive and Free Space on Server](https://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/): When I am not blogging, I am typically working on SQL Server Optimization projects. Time and again, I only have access to SQL Server Management Studio that I can remotely connect to server but do not have access to Operating System, and it works just fine. At one point in optimization project, I have to decide on index filegroup placement as well TempDB files (.ldf and .mdf) placement. It is commonly known that system gives enhanced performance when index and tempdb are on separate drives than where the main database is placed. As I do not have access to OS I... - [SQL SERVER - Forgot the Password of Username SA](https://blog.sqlauthority.com/2009/08/04/sql-server-forgot-the-password-of-username-sa/): I just received a call from an old friend with whom I used to work in Las Vegas. He told me about a password-related issue he faced in his organization. They had changed the password of username SA and now they are not able to recall the new password. I am sure that he is not the first person who has faced this issue. There may be many more similar situations where employees who have sysamin password leaves the job or a hacker disables the SA account. Resetting the password of SA is a breeze! Option 1 : If there is... - [SQLAuthority News - Author Visit - Virtual Tech Days August 2009](https://blog.sqlauthority.com/2009/08/04/sqlauthority-news-author-visit-virtual-tech-days-august-2009/): Microsoft India has organized a premier online technical event Microsoft Virtual TechDays between August 19-21, 2009. I had presented two technical sessions and they were greatly received by audience. I had received 50+ request for providing PPT for all the attendees. It was great FREE event and I suggest that everybody should have attended the event. While I was at Bangalore, I had great time meeting fellow experts and top evangelist from Microsoft. Presenting online event is totally different experience than presenting in front of real people in User Groups. In user group meeting  it is very easy to get feedback... - [SQL SERVER - Introduction to SQL Server 2008 Profiler - Complete](https://blog.sqlauthority.com/2009/08/03/sql-server-introduction-sql-server-2008-profiler-complete/): Introduction SQL Server Profiler is a powerful tool that is available with SQL Server since a long time; however, it has mostly been underutilized by DBAs. SQL Server Profiler can perform various significant functions such as tracing what is running under the SQL Server Engine’s hood, and finding out how queries are resolved internally and what scripts are running to accomplish any T-SQL command. The major functions this tool can perform have been listed below: Creating trace Watching trace Storing trace Replaying trace Trace includes all the T-SQL scripts that run simultaneously on SQL Server. As trace contains all the T-SQL... - [SQLAuthority News - Proposed eGov Standards Policy - Benefit for All or Only A Chosen Few](https://blog.sqlauthority.com/2009/08/02/sqlauthority-news-proposed-egov-standards-policy-benefit-for-all-or-only-a-chosen-few/): Does the proposed eGov Standards Policy benefit all or only a chosen few? As a wider audience comes to accept new technology, so the technology itself grows. The recent debate in India on the eGov Standards policy has been a point of contention for some time. I would like to start our discussion on this topic by posing two questions: Question 1: Should government mandate single standards for a given technology domain? The obvious answer would appear to be “Yes”, but the considered answer is actually “No”. The stipulation of a “single standard” would unnecessarily restrict the technology choices for the... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2009/08/01/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-4/): Note : Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. The following list gives an overview of the features of the SQL Server management pack. Support for Enterprise, Standard and Express editions of SQL Server 2000, 2005 and 2008 and 32bit, 64bit and ia64 architectures.... - [SQL SERVER - Introduction to Cloud Computing](https://blog.sqlauthority.com/2009/07/31/sql-server-introduction-to-cloud-computing/): Introduction “Cloud Computing,” to put it simply, means “Internet Computing.” The Internet is commonly visualized as clouds; hence the term “cloud computing” for computation done through the Internet. With Cloud Computing users can access database resources via the Internet from anywhere, for as long as they need, without worrying about any maintenance or management of actual resources. Besides, databases in cloud are very dynamic and scalable. Cloud computing is unlike grid computing, utility computing, or autonomic computing. In fact, it is a very independent platform in terms of computing. The best example of cloud computing is Google Apps where any application... - [SQLAuthority News - Author's Birthday - Top 7 Commenters - Volunteers](https://blog.sqlauthority.com/2009/07/30/sqlauthority-news-authors-birthday-top-7-commenters-volunteers/): Today is July 30 and I am very happy; it’s my Birthday, celebration time!!! The most common question I receive on my every birthday is -what are my plans for birthday. Let me share my plans here today. Additionally, if you are interested to know when SQL Server was born read my post SQLAuthority News – Author BirthDay – SQL Server Birthday. My first plan is that I am going to take a break from blogging on anything technical today and spend more time with my family. Let me tell you about my second plan. I am very much pleased and... - [SQL SERVER - 2008 - Copy Database With Data - Generate T-SQL For Inserting Data From One Table to Another Table](https://blog.sqlauthority.com/2009/07/29/sql-server-2008-copy-database-with-data-generate-t-sql-for-inserting-data-from-one-table-to-another-table/): Just about a year ago, I had written on the subject of how to insert data from one table to another table without generating any script or using wizard in my article SQL SERVER – Insert Data From One Table to Another Table – INSERT INTO SELECT – SELECT INTO TABLE. Today, we will go over a similar question regarding how to generate script for data from database as well as table. SQL Server 2008 has simplified everything. Let us take a look at an example where we will generate script database. In our example, we will just take one table... - [SQL SERVER - 2008 - Design Process Decision Flow](https://blog.sqlauthority.com/2009/07/28/sql-server-2008-design-process-decision-flow/): I was recently invited by a company that is primarily using other RDBMS as their primary database for solutions. It was a different experience for me, as I am used to having pretty good SQL Server Smart crowd in my presentations, but this time there were smart people but no SQL Server experts in front of me. I was asked to elucidate the basics of SQL Server as well as how it works. Now, this was nothing short of a challenge for me; I had never done this kind of high level presentation. I used presentation from Infrastructure Planning and Design... - [SQL SERVER - List All Missing Identity Values of Table in Database](https://blog.sqlauthority.com/2009/07/27/sql-server-list-all-missing-identity-values-of-table-in-database/): The best part of any blog is when readers ask each other questions. Better still, is when a reader takes the time to provide a detailed response. A few days ago, one of my readers, Yasmin, asked a very interesting question: How we can find the list of tables whose identity was missed (not is sequential order) within the entire database? A big thank you to SQL Server Expert, Imran Mohammed, for his excellent response to this question. He also provided an extremely impressive script, which is well described and contains inline comments. We will now see the same example with... - [SQLAuthority News - Search SQL Server Solutions](https://blog.sqlauthority.com/2009/07/26/sqlauthority-news-search-sql-server-solutions/): So far, I have written over 1030 articles on my blog, and I have  received  an astounding  12,000+ comments. Undoubtedly, it has acquired the status of a  huge database now! I nearly receive 200+ emails  and lots of comments on this blog every day. I do maintain a log of all the comments and emails received. As per my observation, I have already answered 90% of the questions asked via email in this blog earlier. I do my best to respond to each email and comment of my readers. Quite often, the question asked in email is very urgent and  by... - [SQLAuthority News - Download - Cumulative Update Package for SQL Server 2008](https://blog.sqlauthority.com/2009/07/25/sqlauthority-news-download-cumulative-update-package-for-sql-server-2008/): SQL Server 2008 has been out for over two years and now a very significant Cumulative Update has been released. If you are using SQL Server 2008 then you must certainly install it to fix the various bugs. Cumulative Update 3 for SP1: http://support.microsoft.com/kb/971491 Cumulative Update 6 for RTM: I heavily recommend this update. Feel free to talk to me if you want more information on it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Maximizing View of SQL Server Management Studio - Full Screen - New Screen](https://blog.sqlauthority.com/2009/07/24/sql-server-maximizing-view-of-sql-server-management-studio-full-screen-new-screen/): I had a great, unforgettable time at Teched India 2009 in Hyderabad. I had delivered a successful session on SQL Server Management Studio Best Practices, which created a lot of interest in community. I was truly amazed at the tremendous response I got. I received countless different questions on this subject as soon as the event was over. One of the most frequently asked questions was about my demo on how to increase real estate of SSMS (SQL Server Management Studio). I had explained the following two different methods: 1) Open Results in Separate Tab This is a very interesting method... - [SQL SERVER - Puzzle - Write Script to Generate Primary Key and Foreign Key](https://blog.sqlauthority.com/2009/07/23/sql-server-puzzle-write-script-to-generate-primary-key-and-foreign-key/): In one of my recent projects, a large database migration project, I confronted a peculiar situation. SQL Server tables were already moved from Database_Old to Database_New. However, all the Primary Key and Foreign Keys were yet to be moved from the old server to the new server. Please note that this puzzle is to be solved for SQL Server 2005 or SQL Server 2008. As noted by Kuldip it is possible to do this in SQL Server 2000. In SQL Server Management Studio (SSMS), there is no option to script all the keys. If one is required to script keys they... - [SQLAuthority News - SQL Server Value Calculator](https://blog.sqlauthority.com/2009/07/22/sqlauthority-news-sql-server-value-calculator/): I have been using twitter for quite some time now (follow me at @pinaldave). In twitter world very often I find something interesting shared by my friends there. SQL Server Expert and Microsoft Evanglist Vinod Kumar has twitted very interesting detail linking to SQL Server Value Calculator. The web version of this tool is created in Silver Light and looks very cool and gives impression of PC Game Sims at first moment. This tool calculates Total Estimate Saving if SQL Server is used in any organization. It takes into consideration Total IT team members, Bandwidth, Servers, Security, Reports, Audits, Supports Calls... - [SQLAuthority News - SQL Azure - Microsoft SQL Data Services - Introduction and Pricing](https://blog.sqlauthority.com/2009/07/21/sqlauthority-news-sql-azure-microsoft-sql-data-services-introduction-and-pricing/): Microsoft has updated the branding for SQL Services and SQL Data Services. SQL Services will be called Microsoft SQL Azure, and SQL Data Services will be Microsoft SQL Azure Database. Changing the name does not change product but it demonstrates tight integration between the components of the service platforms. As a part of the Windows Azure platform, SQL Azure Database will deliver traditional relational database service in the cloud, supporting T-SQL over Tabular Data Stream (TDS) protocol. SQL Azure Database will be available in two editions: the Web Edition Database and the Business Edition Database. Web Edition – 2GB of T-SQL... - [SQLAuthority News - Authors Visit - DelhiBuzz TechEd on July 11, 2009](https://blog.sqlauthority.com/2009/07/20/sqlauthority-news-authors-visit-delhibuzz-teched-on-july-11-2009/): SQLBuzzDelhi organized TechEd Delhi on July 11, 2009. They even launched an official PASS Chapter in Delhi. The complete report of this event is here. This event like TechEd in Ahmedabad,  was a huge success and saw a huge number of attendees from all over India. Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. The event saw many wonderful speakers.I really appreciate the facility at DelhiBuzz and the amazing crowd brimming with enthusiasm. I really want to thank two people in particular for making the SQL PASS Delhi a grand success... - [SQL SERVER - Get Last Running Query Based on SPID](https://blog.sqlauthority.com/2009/07/19/sql-server-get-last-running-query-based-on-spid/): We often need to find the last running query or based on SPID need to know which query was executed. SPID is returns sessions ID of the current user process. The acronym SPID comes from the name of its earlier version, Server Process ID. To know which sessions are running currently, run the following command: SELECT @@SPID GO In our case, we got SPID 57, which means the session that is running this command has ID of 57. Now, let us open another session and run the same command. Here we get different IDs for different sessions. In our case, we... - [SQLAuthority News - Whitepaper - Using the Resource Governor](https://blog.sqlauthority.com/2009/07/18/sqlauthority-news-whitepaper-using-the-resource-governor/): Using the Resource Governor SQL Server Technical Article Writer: Aaron Bertrand, Boris Baryshnikov Technical Reviewers: Louis Davidson, Mark Pohto, Jay (In-Jerng) Choe Published: June 2009 SQL Server 2008 introduces a new feature, the Resource Governor, which provides enterprise customers the ability to both monitor and control the way different workloads use CPU and memory resources on their SQL Server instances. This paper explains several practical usage scenarios and gives guidance on best practices. The Resource Governor is a new feature in the Microsoft SQL Server 2008 Enterprise. It provides very powerful and flexible controls to dictate and monitor how a SQL... - [SQL SERVER - Two Methods to Retrieve List of Primary Keys and Foreign Keys of Database](https://blog.sqlauthority.com/2009/07/17/sql-server-two-methods-to-retrieve-list-of-primary-keys-and-foreign-keys-of-database/): There are two different methods to retrieve the list of Primary Keys and Foreign Keys from the database. - [SQL SERVER - Four Different Ways to Find Recovery Model for Database](https://blog.sqlauthority.com/2009/07/16/sql-server-four-different-ways-to-find-recovery-model-for-database/): Perhaps, the best thing about technical domain is that most of the things can be executed in more than one ways. It is always useful to know about the various methods of performing a single task. Today, we will observe four different ways to find out recovery model for any database. Method 1 Right Click on Database >> Go to Properties >> Go to Option. On the Right side you can find recovery model. Method 2 Click on the Database Node in Object Explorer. In Object Explorer Details, you can see the column Recovery Model. Method 3 This is a very... - [SQL SERVER - Restore Sequence and Understanding NORECOVERY and RECOVERY](https://blog.sqlauthority.com/2009/07/15/sql-server-restore-sequence-and-understanding-norecovery-and-recovery/): I maintain a spreadsheet of questions sent by users and from that I single out a topic to write and share my knowledge and opinion. Unless and until I find an issue appealing, I do not prefer to write about it, till the issue crosses the threshold. Today the question that crossed the threshold is - what is the difference between NORECOVERY and RECOVERY when restoring database and what is the restore sequence. - [SQL SERVER - Backup Timeline and Understanding of Database Restore Process in Full Recovery Model](https://blog.sqlauthority.com/2009/07/14/sql-server-backup-timeline-and-understanding-of-database-restore-process-in-full-recovery-model/): I assume you all know that there are three types of Database Backup Models, so we will not discuss on this commonly known topic today. In fact, we will just talk about how to restore database that is in full recovery model. Let us learn about backup timeline. - [SQL SERVER - BLOB - Pointer to Image, Image in Database, FILESTREAM Storage](https://blog.sqlauthority.com/2009/07/13/sql-server-blob-pointer-to-image-image-in-database-filestream-storage/): When it comes to storing images in database there are two common methods. I had previously blogged about the same subject on my visit to Toronto. With SQL Server 2008, we have a new method of FILESTREAM storage. However, the answer on when to use FILESTREAM and when to use other methods is still vague in community. Let us look into two traditional methods first along with their advantage and disadvantages. Method 1) Store image in filesystem and store pointer in database This is quite an old method and you can find this implemented in many places, even though SQL Server... - [SQLAuthority News - Big Thinkers - Robert Cain](https://blog.sqlauthority.com/2009/07/12/sqlauthority-news-big-thinkers-robert-cain/): I am exceedingly impressed and inspired by an on-going series of Big Thinkers by Robert Cain – A SQL Server MVP and a genial, whole-souled person. On meeting Robert Cain earlier this year at SQL Server MVP Summit in Seattle I asked him a question – Where do you get so many innovative ideas to write on blog and create presentations? He replied, “I do not try to get ideas, my experience inspires me.” Well, it is true that Robert has more than 10 years of experience as one of the TOP experts in SQL Server. Unlike most of the SQL... - [SQL SERVER - Standby Servers and Types of Standby Servers](https://blog.sqlauthority.com/2009/07/11/sql-server-standby-servers-and-types-of-standby-servers/): Standby servers – Standby Server is a type of server that can be brought online in a situation when Primary Server goes offline and application needs continuous (high) availability of the server. There is always a need to set up a mechanism where data and objects from primary server are moved to secondary (standby) server. This mechanism usually involves the process of moving backup from the primary server to the secondary server using T-SQL scripts. Often, database wizards are used to set up this process. We will now glance at the various types of standby servers. Hot Standby – Hot Standby... - [SQLAuthority News - Request SQLAuthority.com Stickers and SQL Server Cheat Sheet](https://blog.sqlauthority.com/2009/07/10/sqlauthority-news-request-sqlauthority-com-stickers-and-sql-server-cheat-sheet/): I have been overwhelmed with the request for SQL Server Cheat Sheet recently. I absolutely think it is tremendously useful; its hand written form is adorning my wall since a long time. Having realized its usefulness I got it done professionally and distributed it at TechEd in Hyderabad, TechEd in Ahmedabad, and TechEd on Road in Trivendrum. Now, they are very much in demand. - [SQLAuthority News - Authors Visit - K-MUG TechEd Trivandrum on June 27, 2009](https://blog.sqlauthority.com/2009/07/09/sqlauthority-news-authors-visit-k-mug-teched-trivandrum-on-june-27-2009-2/): K-MUG organized TechEd Trivandrum on 27th June, 2009. They even launched an official PASS Chapter in Trivandrum. The complete report of this event is here. This event like TechEd in Ahmedabad,  was a huge success and saw a huge number of attendees from all over India. Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. The event saw many wonderful speakers.I really appreciate the state-of-the-art facility at K-Mug and the amazing crowd brimming with enthusiasm. You can check out K-MUG event page for further information. I really want to thank two people... - [SQLAuthority News - Book Review - Murach's SQL Server 2008 for Developers](https://blog.sqlauthority.com/2009/07/08/sqlauthority-news-book-review-murachs-sql-server-2008-for-developers/): Murach’s SQL Server 2008 for Developers (Murach: Training & Reference) (Paperback) by Bryan Syverson, Joel Murach Link to Amazon Short Summary: Murach’s SQL Server 2008 for developers is an ideal book for all developers, and particularly, it is an excellent book for training and reference. If you are new to SQL, no problem! This book is the best reading material to start with. Long Summary: SQL Server has emerged as the leading database and nowadays there are a number of books available on this subject. However, it is important to select the right book to imbibe proper, thorough understanding. Murach’s SQL... - [SQLAuthority News - Authors Visit - DotNet Buzz Delhi TechEd Delhi on July 11, 2009](https://blog.sqlauthority.com/2009/07/07/sqlauthority-news-authors-visit-dotnet-buzz-delhi-teched-delhi-on-july-11-2009/): DotNet Buzz Delhi is organizing TechEd Delhi on July 11, 2009. Not just this, they are launching an official PASS Chapter in Delhi. The Agenda of the event is here and if you are around Delhi do not miss the opportunity to be a part of this upcoming great event. If you are keen to know what this event holds in store for you then read about TechEd in Ahmedabad, which saw a huge number of attendees and was a grand success.  Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. I... - [SQL SERVER - Languages for BI - MDX, DMX, XMLA](https://blog.sqlauthority.com/2009/07/06/sql-server-languages-for-bi-mdx-dmx-xmla/): Today, we have a very basic thing to go over. Few days back, I was discussing with one of my friends regarding BI. He told me that he knows that BI stands for Business Intelligence but he would like to know what languages BI uses to achieve the goal. The reason I found this question very interesting was because I was asked the same question two weeks back at TechEd on Road Ahmedabad. I had promised one of the attendees that I will reply to his question soon. This question, which my friend asked recently, reminded me of the same. Let us go over the languages of BI very quickly. Again, these are just definitions and there is much more to learn. Moreover, to master each language it may take years. - [SQLAuthority News - FIX : Error : HP OfficeJet Scanning and Printing Gray or Pink Shades](https://blog.sqlauthority.com/2009/07/05/sqlauthority-news-fix-error-hp-officejet-scanning-and-printing-gray-or-pink-shades/): Unlike my usual articles today’s article is not at all related to SQL Server but something drove me to include it on my blog. This issue snatched away my precious few hours. It took me over 2 hours to resolve it yesterday, which barred me from doing research on SQL Server. I am sure many people must have faced this issue and the sad part is no solution has been proposed so far. Let us understand the problem first. I got a brand new printer HP Officejet J4580 All-in-One printer. Support Engineer came along to install it. Fax, Printing, Photocopy –... - [SQL SERVER - Disk Partition Alignment Best Practices](https://blog.sqlauthority.com/2009/07/04/sql-server-disk-partition-alignment-best-practices/): Note :  Download Disk Partition Alignment Best Practices for SQL Serverby Microsoft Disk partition alignment is a powerful tool for improving SQL Server performance. Configuring optimal disk performance is often viewed as much art as science. A best practice that is essential yet often overlooked is disk partition alignment. Windows Server 2008 attempts to align new partitions out-of-the-box, yet disk partition alignment remains a relevant technology for partitions created on prior versions of Windows. This paper documents performance for aligned and nonaligned storage and why nonaligned partitions can negatively impact I/O performance; it explains disk partition alignment for storage configured on... - [SQLAuthority News - Book Review - The Rational Guide to Building Technical User Communities (Rational Guides)](https://blog.sqlauthority.com/2009/07/03/sqlauthority-news-book-review-the-rational-guide-to-building-technical-user-communities-rational-guides/): The Rational Guide to Building Technical User Communities (Rational Guides) (Paperback) by Greg Low Short Review : A Great, one-of-its-kind book for everybody who is interested in building technical user community. There is no other book written on this subject but after this comprehensive book no further reading will be required. Link to Amazon Detailed Review : This is for the first time in my book review, instead of talking about the book or author, I will introduce myself in a couple of lines to explain why and how this book is helpful to those interested in building community. I am... - [SQLAuthority News - MVP Award Renewed](https://blog.sqlauthority.com/2009/07/02/sqlauthority-news-mvp-award-renewed/): Year ago, it was a great, perhaps the proudest moment of my professional life. I was awarded Most Valuable Professional (MVP) for SQL Server by Microsoft. Today, I received an email informing me that I have been re-awarded SQL Server MVP status by Microsoft in recognition of my community contributions. It’s yet another proud moment for me. I’m very happy and excited that my hard work is being recognized.  I hope to work even harder and serve my community better! Microsoft Thank You! There’s a huge list of people I would like to thank for this award. However, instead of listing... - [SQL SERVER - Difference between Line Feed (\n) and Carriage Return (\r) - T-SQL New Line Char](https://blog.sqlauthority.com/2009/07/01/sql-server-difference-between-line-feed-n-and-carriage-return-r-t-sql-new-line-char/): Today, we will examine something very simple and very generic that can apply to hordes of programming languages. Let’s take a common question that is frequently discussed – What is difference between Line Feed (\n) and Carriage Return (\r)? Prior to continuing with this article let us first look into few synonyms for LF and CR. Line Feed – LF – \n – 0x0a – 10 (decimal) Carriage Return – CR – \r – 0x0D – 13 (decimal) Now that we have understood that we have two different options to get new line, the question that arises is – why is... - [SQL SERVER - 2008 - Policy-Based Management - Create, Evaluate and Fix Policies](https://blog.sqlauthority.com/2009/06/30/sql-server-2008-policy-based-management-create-evaluate-and-fix-policies/): This article will cover the most spectacular feature of SQL 2008 – Policy-based management and how the configuration of SQL Server with policy-based management architecture can make a powerful difference. Policy based management is loaded with several advantages. It can help you implement various policies for reliable configuration of the system. It also provides additional administration assistance to DBAs and helps them effortlessly manage various tasks of SQL Server across the enterprise. 1 Introduction 2 Basics of Policy Management 3 Policy Management Terms 4 Practical Example of Policy Management 4.1 Exploring of Facets 4.2 Create a Condition 4.3 Create a Policy... - [SQL SERVER - Maximum Number of Index per Table](https://blog.sqlauthority.com/2009/06/29/sql-server-maximum-number-of-index-per-table/): TechEd on Road Ahmedabad, June 20, 2009, was a huge success. This grand event saw over 200 attendees actively participating in the sessions. We had attendees traveling from far and wide, including Delhi, Mumbai, Jaipur, Kerala, Baroda, Himmatnagar, Rajkot, among other cities from India. This enthusiastic participation made the event truly grand. It was a moment of bliss for me as I had not anticipated such tremendous positive response! Although the Official time to commence the event was at 1:45 PM we were really excited to see the attendees entering the hall before the official time. We were more than happy... - [SQL SERVER - SQL Server Management Studio New Features](https://blog.sqlauthority.com/2009/06/28/sql-server-2008-management-studio-new-features-2/): This article describes the top 5 features of SQL Server Management Studio 2008. With the release of SQL Server 2008 Microsoft has upgraded SSMS with many new features as well as added tons of new functionalities requested by DBAs for long time. - [SQL SERVER - Fix : Error : 17892 Logon failed for login due to trigger execution. Changed database context to 'master'.](https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context-to-master/): I had previously written two articles about an intriguing observation of triggers online. SQL SERVER – Interesting Observation of Logon Trigger On All Servers SQL SERVER – Interesting Observation of Logon Trigger On All Servers – Solution If you are wondering what made me write yet another article on logon trigger then let me tell you the story behind it. One of my readers encountered a situation where he dropped the database created in the above two articles and he was unable to logon to the system after that. Let us recreate the scenario first and attempt to solve the problem.... - [SQL SERVER - Interesting Observation of Logon Trigger On All Servers - Solution](https://blog.sqlauthority.com/2009/06/26/sql-server-interesting-observation-of-logon-trigger-on-all-servers-solution/): Does the title of this post trigger your mind? If you all remember, a few days back I had written an article on my interesting observation regarding logon triggers. I would advise you to first read SQL SERVER – Interesting Observation of Logon Trigger On All Servers before continuing with this article further to have a complete idea of the subject. The question I put forth in my previous article was – In single login why the trigger fires multiple times; it should be fired only once. I received numerous answers in thread as well as in my MVP private news... - [SQLAuthority News - Authors Visit - K-MUG TechEd Trivandrum on June 27, 2009](https://blog.sqlauthority.com/2009/06/25/sqlauthority-news-authors-visit-k-mug-teched-trivandrum-on-june-27-2009/): K-MUG is organizing TechEd Trivandrum on 27th June, 2009. Not just this, they are launching an official PASS Chapter in Trivandrum. The Agenda of the event is here and if you are around Trivandrum do not miss the opportunity to be a part of this upcoming great event. If you are keen to know what this event holds in store for you then read about TechEd in Ahmedabad, which saw a huge number of attendees and was a grand success.  Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. Click here for... - [SQLAuthority News - Update on pinaldave.com and SQLAuthority.com](https://blog.sqlauthority.com/2009/06/24/sqlauthority-news-update-on-pinaldave-com-and-sqlauthority-com/): Problem: SQLAuthority.com site was not allowed in some browsers as pinaldave.com site was marked as malware or badware distributing third party site. Status: SQLAuthority.com and pinaldave.com both the sites are safe now and there is no threat to your computer. Feel free to click on the links. Since the last two mornings I have received over 200 emails querying about the error my sites were generating. I encountered countless questions and worst of all I was thrown verbal abuse for not getting my own site up right away and for being careless. I’m much relieved today as everything is back to... - [SQL SERVER - Delete Duplicate Rows](https://blog.sqlauthority.com/2009/06/23/sql-server-2005-2008-delete-duplicate-rows/): I had previously penned down two popular snippets regarding deleting duplicate rows and counting duplicate rows. Today, we will examine another very quick code snippet where we will delete duplicate rows using CTE and ROW_NUMBER() feature of SQL Server 2005 and SQL Server 2008. - [SQLAuthority News - TechEd on Road Ahmedabad June 20, 2009 - An Astounding Success](https://blog.sqlauthority.com/2009/06/22/sqlauthority-news-teched-on-road-ahmedabad-june-20-2009-an-astounding-success/): TechEd on Road Ahmedabad In India, TechEd was held in Hyderabad in the month of May. You can read myTechEd summary article here. A similar event will be organized in 10 major cities in India. Ahmedabad saw its first TechEd on Road and it was wholeheartedly welcomed by technology enthusiasts. The event was held at Rock regency, in the heart of Ahmedabad on June 20, 2009. We had attendees traveling over 500 miles to attend the event. We had attendees from Delhi, Mumbai, Jaipur, Kerala, Baroda, Himmatnagar, Rajkot, among other cities from India. It was a joyous and overwhelming experience for... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.1](https://blog.sqlauthority.com/2009/06/21/sqlauthority-news-risk-and-health-assessment-program-for-microsoft-sql-server-scoping-tool-v1-1/): Note :   Download Risk and Health Assessment Utility by Microsoft Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.1 is a practical download package intended exclusively for Microsoft Premier Customers. This package paraphernalia includes all the scoping tools required to prepare and qualify your environment to receive a Risk and Health Assessment Program for Microsoft SQL Server. Getting started with it is very easy. First, extract the Scoping Tool zip package to the tools server that will be used during the RAP engagement. Next, refer to Instructions.txt in the Scoping Tool folder for exhaustive instructions on executing... - [SQL Server - Understanding Table Hints with Examples](https://blog.sqlauthority.com/2009/06/20/sql-server-understanding-table-hints-with-examples-2/): Today we have a very interesting subject to look at. I tried to look for help online but have not found any other documentation besides what we have from the Book Online. Let us try to understand what are the different kinds of hints available in SQL Server and how they are helpful. What is a Hint? Hints are options and strong suggestions specified for enforcement by the SQL Server query processor on DML statements. The hints override any execution plan the query optimizer might select for a query. Before we continue to explore this subject, we need to consider one... - [SQL SERVER - Why You Should Attend PASS Summit Unite 2009- Seattle](https://blog.sqlauthority.com/2009/06/19/sql-server-why-you-should-attend-pass-summit-unite-2009-seattle/): PASS Summit Unite 2009 – the premier event for SQL Server professionals – will be held in Seattle from November 2 to November 5. It is the largest and the most intensive Microsoft SQL Server conference in the world organized by SQL Server users for SQL Server users. This year marks the 10th Anniversary of PASS Community Summit, making the event even more special. Every year, this event sees a huge number of attendees, as apart from high quality technical sessions it provides unparalleled access to the Microsoft SQL Server development, SQL CAT, and Customer Service and Support teams. PASS Summit... - [SQL SERVER - Clustered Index on Separate Drive From Table Location](https://blog.sqlauthority.com/2009/06/18/sql-server-clustered-index-on-separate-drive-from-table-location/): How to improve performance of SQL Server Queries is a common topic of discussion among many of us. Much has been said, much has been discussed. Few days back, I had an interesting discussion with one of the Junior developers regarding performance improvement of SQL Server Queries. We discussed on how by using a separate hard drive for several database objects can right away improve performance. I suggested him that non clustered index and tempdb can be created on a separate disk to improve performance. - [SQL SERVER - List Schema Name and Table Name for Database](https://blog.sqlauthority.com/2009/06/17/sql-server-list-schema-name-and-table-name-for-database/): Just a day ago, I was looking for script which generates all the tables in database along with its schema name. I tried to Search@SQLAuthority.com but got too many results. For the same reason, I am going to write down today’s quick and small blog post and I will remember that I had written I wrote it after my 1000th article. SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']' AS SchemaTable FROM sys.tables Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 1000th Article Milestone - 8 Millions Views - Solid Quality Mentors](https://blog.sqlauthority.com/2009/06/16/sqlauthority-news-1000th-article-milestone-8-millions-views-solid-quality-mentors/): Achieving a milestone gives a great sense of accomplishment! Today, I am writing my 1000th Article on this blog. I am extremely happy and gratified.  It is indeed a long journey since I started a few years back and at that time I had no idea that within a short period I would attain so much appreciation and popularity.  I intend to continue my journey further and attain more milestones. I have always enjoyed learning, sharing and helping my community. Through this blog, I have met many wonderful people, made great friends and interacted with diverse readers from across the globe.... - [SQL SERVER - Query Optimizer Hint ROBUST PLAN - Question to You](https://blog.sqlauthority.com/2009/06/15/sql-server-query-optimizer-hint-robust-plan-question-to-you/): While cleaning up my bookmarks this week, I stumbled upon a very small interesting thing. I can proudly call myself a pro at finding stuffs, but after continuously hunting online I could not gather comprehensive information about this topic. I was actually looking for a practical example for Query Optimizer Hint “ROBUST PLAN”. Before I seek help from you, let us first try to understand what query optimizer hints is and then we will move on to the concept of “ROBUST PLAN”. To put it simply, Query hints is a T-SQL clause which on running directs T-SQL query to run in... - [SQL SERVER - 2008 - SSMS Feature - Multi-server Queries](https://blog.sqlauthority.com/2009/06/14/sql-server-2008-ssms-feature-multi-server-queries/): In my recent visit to TechEd India 2009 at Hyderabad, I had taken a technical session on SQL Server Management Studio 2008 New Features, which was attended by a huge number of participants and was very successful. I got loads of requests from my readers for posting the session online. My presentation involved several videos and demos, so practically it is not possible for me to post my original session online. But as I do not want to disappoint my readers I have one solution; what I can do is that I can share some valuable tips from the session with... - [SQL SERVER - Effect of Normalization on Index and Performance](https://blog.sqlauthority.com/2009/06/13/sql-server-effect-of-normalization-on-index-and-performance/): Of late, I have been using Twitter quite frequently, and I am gradually discovering its usefulness. I received a Direct Message (or DM in terms of twitter) asking if I can comment on the effect of normalization on the Index and its performance in one twit! Now honestly speaking, this was new for me. I never expected to be quizzed like this. If you are using Twitter, then you must be aware that one twit contains only 140 characters. I was supposed to give answer on such a big subject in just 140 letters. An interesting fact is that normalization and the Index are not really closely related. The right question should have been – what is the effect of normalization on performance? - [SQL SERVER - 2008 - Customize Toolbar - Remove Debug Button from Toolbar](https://blog.sqlauthority.com/2009/06/12/sql-server-2008-customize-toolbar-remove-debug-button-from-toolbar/): In today’s article I have combined two different questions. I was fond of SQL Server Debugger feature in SQL Server 2000. To my utter disappointment, this feature was withdrawn from SQL Server 2005. However, because of loads of requests from developers it was re-introduced in SQL Server 2008. Let us learn about how to customize toolbars.  - [SQLAuthority News - Registration and Competition - TechEd on Road - Ahmedabad - June 20, 2009 Saturday](https://blog.sqlauthority.com/2009/06/11/sqlauthority-news-registration-and-competition-teched-on-road-ahmedabad-june-20-2009-saturday/): We have an upcoming grand event of TechEd on Road organized in Ahmedabad. This is a FREE event and ANYBODY who loves technology can attend it. This event will provide a precious opportunity to learn, interact and network with tech enthusiasts. I encourage you all to be a part of it and experience the joy of learning in a healthy and fun environment. - [SQL SERVER - Performance Counters from System Views - By Kevin Mckenna](https://blog.sqlauthority.com/2009/06/10/sql-server-performance-counters-from-system-views-by-kevin-mckenna/): I just love social media and all the new concepts of Web 2.0. There are bloggers who are overwhelmed by the new concepts of technology and are not able to keep pace with it. But I like taking such challenges. Twitter has acquired tremendous popularity nowadays and just like everybody else I am also fond of this latest vogue. You can follow me at Twitter here. Through twitter I am getting to meet people like me and it’s a great experience interacting with them. I met SQL and .NET expert Kevin Mckenna on twitter itself. Kevin is originally from Liverpool, England,... - [SQLAuthority News - TechEd On Road Ahmedabad, India is Announced - June 20, 2009 Saturday](https://blog.sqlauthority.com/2009/06/09/sqlauthority-news-teched-on-road-ahmedabad-india-is-announced-june-20-2009-saturday/): If you are regretting for missing TechEd India 2009 at Hyderabad here’s your chance of catching up with a similar kind of technology event in Ahmedabad, India on Saturday June 20, 2009. TechEd on Road will be held in Ahmedabad at Rock Regency, a prime location in the heart of the city. - [SQL SERVER - Fix: Error 15372 Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance - The connection will be closed](https://blog.sqlauthority.com/2009/06/08/sql-server-fix-error-15372-failed-to-generate-a-ser-instance-od-sql-server-due-to-a-failure-in-starting-the-process-for-the-user-instance-the-connection-will-be-closed/): Just a day ago, I was installing SQL Server Express on the backup computer. I found the solution for Error 15372. - [SQLAuthority News - Using SQL Server 2008 Extended Events - White paper By Jonathan Kehayias](https://blog.sqlauthority.com/2009/06/07/sqlauthority-news-using-sql-server-2008-extended-events-white-paper-by-jonathan-kehayias/): Strange it may sound but being a SQL Server pro has its downside too. Common information on SQL does not interest me, while a good document is hard to find. So the reader in me is mostly discontented and constantly keeps looking for interesting documents.  Recently, I chanced upon a really good white paper by Jonathan Keyhayias on SQL Serve r2008 extended events. I have known Jonathan through forums but have not met him in person yet. But I hope to meet him soon. The white paper starts with introduction to the extended event and then elaborates on its architecture, system... - [SQL SERVER - Order of Hotfix and Service Pack](https://blog.sqlauthority.com/2009/06/06/sql-server-order-of-hotfix-and-service-pack/): On an average once a week I receive a question from my readers regarding what should be the sequence of hotfix and service pack. Not long ago, one of my regular readers who is using SQL Server 2000 asked me how can he improve the installation speed as he has to install 4 Service Packs to upgrade his server to SQL Server SP4 version. All these questions from my readers have prompted me to write down this small note.  I hope this will clear some of the common doubts they have about this subject and they no longer would have to... - [SQLAuthority News - Rambling of Author and Technology Musing - Bing, Google, Windows 7, Books, Blogs, Twitter and Life](https://blog.sqlauthority.com/2009/06/05/sqlauthority-news-rambling-of-author-and-technology-musing-bing-google-windows-7-books-blogs-twitter-and-life/): I have been planning to write a general post on the latest technology for a long time but SQL keeps me so busy that I hardly get time. I know being busy is no excuse as everybody is busy with something. A manager is equally busy managing people as much as a peon busy doing errands. Now, coming back to my topic, I have lots of news to share with you all. Anyway, number one news is that Bing has been finally released a couple of days back. I am very much excited as something is finally challenging Google – The... - [SQL SERVER - What is Interim Table - Simple Definition of Interim Table](https://blog.sqlauthority.com/2009/06/04/sql-server-what-is-interim-table-simple-definition-of-interim-table/): Sometimes a simple question like “What is interim table?” can initiate a never-ending discussion between developers. I experienced this recently while I was on phone helping my friends working in Los Angeles. In a conference call, one of the developers kept on talking about “first interim table” and “second interim table” and so forth, while another developer was of the opinion that that there cannot be more than one interim table. Well, as this was not enough a third developer interrupted the debate and said that all the tables are interim tables. The heated discussion seemed never ending. To put the... - [SQL SERVER - Connect Item - Vote for Feature Request Function TRIM](https://blog.sqlauthority.com/2009/06/03/sql-server-connect-item-vote-for-feature-request-function-trim/): Till date, I have met the SQL Server Product Team twice: first time at SQL Server MVP Meet, Seattle, and second time at TechEd India 2009, Hyderabad. At both the times, I have put forth one request to the product team regarding implementing of function Trim(). As per my opinion, this is the most demanded feature of SQL Server. Almost all the programming languages have function TRIM() which removes space leading and any word that follows. However, SQL Server does not have TRIM() function. It has LTRIM() and RTRIM() functions, which when combined together LTRIM(RTRIM()) works like the expected TRIM() function... - [SQLAuthority News - Summary of TechEd India 2009 - A Grand Event](https://blog.sqlauthority.com/2009/06/02/sqlauthority-news-summary-of-teched-india-2009-a-grand-event/): TechEd India 2009 was undeniably a magnificent success! The 3-day grand event was adorned by delegates, sponsors, partners, customers, media as well as celebrities from cross the world. The event was marked by the CEO of Microsoft Steve Ballmer‘s keynote, Academy Award Winner Film Sound Designer of Slumdog Millioner Resool Pookutt‘s talk, not to forget the numerous technical sessions, Community Lounge, Partner Stalls, Demo Extravaganza, and the gaming zone. TechEd India 2009 was one event where community involvement was at its zenith. Organizations such as INETA APAC, Culminis, PASS and Microsoft India came together to bring all user group leaders together... - [SQL SERVER - List All Objects Created on All Filegroups in Database](https://blog.sqlauthority.com/2009/06/01/sql-server-list-all-objects-created-on-all-filegroups-in-database/): When I pen down any article I always keep my readers in my mind. With every topic of SQL server I cover, I try to bring readers closer to this technology. So, whenever I receive follow up questions from my readers I am exhilarated! Sometime back I had covered a topic – SQL SERVER – Create Multiple Filegroup For Single Database, for which I received a number of follow up questions. In this post I would like to discuss on a question from one of the readers Joginder “Jogi” Padiyala. “How can I find which object belongs to which filegroup. Is... - [SQL SERVER - Create Multiple Filegroup For Single Database](https://blog.sqlauthority.com/2009/05/31/sql-server-create-multiple-filegroup-for-single-database/): I am elated to receive hundreds of emails every day from my readers. My tight work schedule refrains me from answering all your questions, but I do try my best to entertain them whenever I can. Today’s post revolves around a question I received a number of times last year but never blogged on it. On positive side, you are reading about that interesting subject today. The question is – How to create multiple filegroup for any database? To find solution to this query, we will go through the following four cases. 1) Creating New Database a) Using T-SQL b) Using... - [SQL SERVER - Difference Between Candidate Keys and Primary Key](https://blog.sqlauthority.com/2009/05/30/sql-server-difference-between-candidate-keys-and-primary-key/): Let us first try to grasp the definition of the two keys. Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key. One needs to be very careful in selecting the Primary Key as an incorrect selection can adversely impact the database architect and... - [SQLAuthority News - Blog Makeover - New Banner - New Color](https://blog.sqlauthority.com/2009/05/29/sqlauthority-news-blog-makeover-new-banner-new-color/): Just a month back I had previously changed my personal homepage and had requested for feedback from my readers here SQLAuthority News – Authors Website Redesigned – https://www.pinaldave.com/ – Feedback Requested. To my astonishment, I received a huge number of emails. But I received only one comment. This time, I would like to request my readers to leave your comments on my blog instead of emailing it to me. This will allow everyone to know about others feedbacks and the actions I take towards incorporating the feedbacks on my blog and a new banner. - [SQL SERVER - Fix : Error : SQLDUMPER library failed initialization. Your installation is either corrupt or has been tampered with. Please uninstall then re-run setup to correct to correct this problem. in a modal dialog with the title SQL Writer](https://blog.sqlauthority.com/2009/05/28/sql-server-fix-error-sqldumper-library-failed-initialization-your-installation-is-either-corrupt-or-has-been-tampered-with-please-uninstall-then-re-run-setup-to-correct-to-correct-this-problem/): I often receive emails from reader requesting solution to following error: “SQLDUMPER library failed initialization. Your installation is either corrupt or has been tampered with. Please uninstall then re-run setup to correct to correct this problem.” in a modal dialog with the title “SQL Writer” While searching online there are so many different solution and many time the solution is to reinstall SQL Server. There is no need to reinstall SQL Server or do any complex process. It is very simple to fix this issue. Fix/Workaround/Solution: Go to Add/Remove Program in windows Control Panel Remove “microsoft SQL server vss writer” program... - [SQL SERVER - Interesting Observation of Logon Trigger On All Servers](https://blog.sqlauthority.com/2009/05/27/sql-server-interesting-observation-of-logon-trigger-on-all-servers/): I was recently working on security auditing for one of my clients. In this project, there was a requirement that all successful logins in the servers should be recorded. The solution for this requirement is a breeze! Just create logon triggers. I created logon trigger on server to catch all successful windows authentication as well SQL authenticated solutions. When I was done with this project, I made an interesting observation of executing a logon trigger multiple times. It was absolutely unexpected for me! As I was logging only once, naturally, I was expecting the entry only once. However, it did it multiple times on different threads – indeed an eccentric phenomenon at first sight! - [SQL SERVER - Find Hostname and Current Logged In User Name](https://blog.sqlauthority.com/2009/05/26/sql-server-find-hostname-and-current-logged-in-user-name/): I work in an environment wherein I connect to multiple servers across the world. Time and again, my SSMS is connected to a myriad of servers that kindles a lot of confusion. I frequently use the following trick to separate different connections, which I mentioned in my blog sometime back SQL SERVER – 2008 – Change Color of Status Bar of SSMS Query Editor. However, this trick does not help when a huge number of different connections are open. In such a case, I use the following handy script. Do not go by the length of the script; it might be... - [SQLAuthority News - Download Microsoft SQL Server 2008 Books Online (May 2009)](https://blog.sqlauthority.com/2009/05/25/sqlauthority-news-download-microsoft-sql-server-2008-books-online-may-2009/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - Introduction to Business Intelligence - Important Terms and Definitions](https://blog.sqlauthority.com/2009/05/24/sql-server-introduction-to-business-intelligence-important-terms-and-definitions/): What is Business Intelligence Business intelligence (BI) is a broad category of application programs and technologies for gathering, storing, analyzing, and providing access to data from various data sources, thus providing enterprise users with reliable and timely information and analysis for improved decision making. To put it simply, BI is an umbrella term that refers to an assortment of software applications for analyzing an organization’s raw data for intelligent decision making for business success. BI as a discipline includes a number of related activities, including decision support, data mining, online analytical processing (OLAP), querying and reporting, statistical analysis and forecasting. 1... - [SQLAuthority News - SQL Server Energy Event with Rushabh Mehta - May 20, 2009](https://blog.sqlauthority.com/2009/05/23/sqlauthority-news-sql-server-energy-event-with-rushabh-mehta-may-20-2009/): The much-awaited SQL Server Energy Event was successfully held on May 20, 2009 in Ahmedabad. It was jointly organized by Gandhinagar SQL Server User Group (President Pinal Dave – SQL MVP) and Ahmedabad SQL Server User Group (President Jacob Sebastian – SQL MVP). This vibrant event was one of the most interactive, remarkable and enriching events of this year in Ahmedabad. Several factors make this event unique. The main attraction of this outstanding event was Rushabh Mehta (SolidQ Mentor – SQL MVP), an eminent expert in the field of Business Intelligence. Technical session from a legend like Rushabh was an opportunity... - [SQLAuthority News - Download - SQL Server 2008 Developer Training Kit](https://blog.sqlauthority.com/2009/05/22/sqlauthority-news-download-sql-server-2008-developer-training-kit/): Note : Download SQL Server 2008 Developer Training Kit by Microsoft SQL Server 2008 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2005. The SQL Server 2008 Developer Training Kit will help you understand how to build web applications which deeply exploit the rich data types, programming models and new development paradigms in SQL Server 2008. The training kit is brought to you by Microsoft Developer and Platform Evangelism. - [SQL SERVER - FIX : ERROR : (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: )](https://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/): Regular readers of my blog are aware of the fact that I have written about this subject umpteen times earlier, and every time I have spoken about a new issue related to it. Few days ago, I had redone my local home network. I have LAN setup with wireless router connected with my four computers, two mobile devices, one printer and one VOIP solution. I had also formatted my primary computer and clean installed SQL Server 2008 into it. Yesterday, incidentally, I was sitting in my yard trying to connect SQL Server located in home office and suddenly I stumbled upon... - [SQL Server - Download PDF SQL Server Cheat Sheet](https://blog.sqlauthority.com/2009/05/20/sql-server-download-pdf-sql-server-cheat-sheet/): I had a gala time at TechEd India 2009 event! Meeting with great people is an experience of a lifetime. My session was well attended and well appreciated, which also gives me another reason to feel happy.  Moreover, my SQL Server Cheat Sheet gained unpredicted popularity at the event. Let me share with you all a little story behind this cheat sheet. For my personal use, I created one handy SQL Cheat Sheet, which I hang on my desk always. Even though I have a sound knowledge of SQL Syntax there are many occasions when I need to quickly refer to... - [SQLAuthority News - SQL Server Energy Event - Mark Your Calendar - May 20, 2009](https://blog.sqlauthority.com/2009/05/19/sqlauthority-news-sql-server-energy-event-mark-your-calender-may-20-2009/): I am very excited to share this news with all my readers. If you all remember I had already given a hint on my blog just two days back; I mentioned that we are going to host a grand event for Gandhinagar SQL Server User Group. In the past, Gandhinagar SQL Server User Group events have been more successful than we expected. Now, this event will grow even bigger as both Gandhinagar SQL Server User Group (President Pinal Dave – SQL MVP) and Ahmedabad SQL Server User Group (President Jacob Sebastian – SQL MVP) will come together for the event. This... - [SQL SERVER - Fix : Management Studio Error : Saving Changes in not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created](https://blog.sqlauthority.com/2009/05/18/sql-server-fix-management-studio-error-saving-changes-in-not-permitted-the-changes-you-have-made-require-the-following-tables-to-be-dropped-and-re-created-you-have-either-made-changes-to-a-tab/): Today, we will delve into a very simple issue that one of the Jr. Developers at my organization confronted. I have a preference for T-SQL. According to me, all the developers should always use T-SQL instead of Design feature of SQL Server Management Studio (SSMS). In fact, sound knowledge of T-SQL has the potential to make a huge difference in the development of the developer. One issue with using design mode of SSMS is that it sometimes adds too much overhead to the actual code and locks up the complete database. In the earlier version of SSMS, it was quite common... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting - International Speaker Visiting](https://blog.sqlauthority.com/2009/05/17/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-international-speaker-visiting/): It is my pleasure to announce Gandhinagar SQL Server User Group Meeting on May 20, 2009 Wednesday. Mark this date as we will be having international speaker Rushabh Mehta of SolidQ attending our session. Rushabh Mehta is a Mentor for Solid Quality Mentors’ global Business Intelligence division, based in USA, and is also the Managing Director for Solid Quality India Pvt. Ltd. I will have more information about his technical session, location and meeting time tomorrow. This will be once in a life time opportunity. If you are in Gujarat state, India and you do not attend this session, you will... - [SQL SERVER - How to Drop Temp Table - Check Existence of Temp Table](https://blog.sqlauthority.com/2009/05/17/sql-server-how-to-drop-temp-table-check-existence-of-temp-table/): I have received following questions numerous times: “How to check existence of Temp Table in SQL Server Database?” “How to drop Temp Table from TempDB?” “When I try to drop Temp Table I get following error. Msg 2714, Level 16, State 6, Line 4 There is already an object named ‘#temp’ in the database. How can I fix it?” “Can we have only one Temp Table or we can have multiple Temp Table?” “I have SP using Temp Table, when it will run simultaneously, will it overwrite data of temp table?” In fact I have already answer this question earlier in... - [SQLAuthority News - TechEd India 2009 - Day 3 - Product Group Meeting - Final Presentations - Meeting Friends](https://blog.sqlauthority.com/2009/05/16/sqlauthority-news-teched-india-2009-day-3-product-group-meeting-final-presentations-meeting-friends/): TechEd India 2009 has ended today and I’ve already started missing it! This three-day event was one of the best events of this year so far. I got the platform to meet best of the best people in the industry today. If I have to rate my days at TechEd I will assign the highest rating to day 3 as it was the most significant day. However, in today’s article I will not be writing in detail about the last day because most of the things that I want to discuss have been covered by NDA. Besides, I learnt some vital... - [SQLAuthority News - TechEd India 2009 - Day 2 - In-Person Meeting with Industry Leaders - Community Party](https://blog.sqlauthority.com/2009/05/15/sqlauthority-news-teched-india-2009-day-2-in-person-meeting-with-industry-leaders-community-party/): Action-packed day 2 of TechEd India is over, and I feel that today was even better day than day 1. So many things were going on simultaneously and keeping track of them is a hard task. Even today I got the chance to meet some renowned industry leaders. Apart from having real time conversation with Industry Leaders, I had a great time attending the various Tech Sessions. Highlight of the day was Vinod Kumar’s session on “Reducing the size of your database using Data Compression/Binary Compression in SQL Server 2008“. Vinod commenced this session by bringing forth some causal questions to... - [SQLAuthority News - TechEd India 2009 - Day 1 - Authors Tech Session - SQL Server Cheat Sheet - Meeting Great People](https://blog.sqlauthority.com/2009/05/14/sqlauthority-news-teched-india-2009-day-1-authors-tech-session-sql-server-cheat-sheet-meeting-great-people/): First day of TechEd India 2009 is over and when I recall the day I can say that it was truly a blast! This immensely huge and grand event was conducted successfully. I am having a tough time trying to recapitulate the first day as there were several different activities worth covering. Let me start with the three most important events of day. Steve Ballmer – Microsoft CEO – was the Keynote speaker at TechEd India. He is really an enthusiastic person. As soon as he showed up on stage, the entire auditorium was charged with energy. People were extremely keen... - [SQLAuthority News - TechEd India 2009 - Day 0 - Day 1 - Authors Tech Session - SQL Server Cheat Sheet - Catch Me Live](https://blog.sqlauthority.com/2009/05/13/sqlauthority-news-teched-india-2009-day-0-day-1-authors-tech-session-sql-server-cheat-sheet-catch-me-live/): Presently, I am at TechEd India 2009 in Hyderabad as one of the participants of this prestigious event. I will be heading a session on SQL Server Management Studio 2008 New Features. I had recently blogged about TechEd 2009 India here. Excerpt from the previous article “Tech.Ed-India is a great opportunity to gear yourself up to keep pace with the latest technology innovations and trends.  This event offers you the platform to get comprehensive hands-on-training and free certifications in some of the most sought after technologies of today. In fact, it is a must-attend event for all developers and IT Professionals.”... - [SQLAuthority News - Release of SQL Server 2008 R2 Announced](https://blog.sqlauthority.com/2009/05/12/sqlauthority-news-release-of-sql-server-2008-r2-announced/): SQL Server 2008 R2 expands on the value delivered in SQL Server 2008 by providinga wealth of new features and capabilities that can benefit your entire organization. This release will further improve IT Efficiency with new and enhanced management capabilities and empower business users to access, integrate, analyze and share information using business intelligence tools they already know. Capitalize on Hardware Innovation Optimize Hardware Resources Manage Efficiently at Scale Enhance Collaboration Across Development and IT Improve the Quality of Your Data Manage User-Generated Analytical Applications Report with Ease Get More Out of Your Data Build Robust Analytical Applications Consolidate Your Data... - [SQL SERVER - How to Drop Primary Key Contraint ](https://blog.sqlauthority.com/2009/05/12/sql-server-how-to-drop-primary-key-contraint/): One area that always, unfailingly pulls my interest is SQL Server Errors and their solution. I enjoy the challenging task of passing through the maze of error to find a way out with a perfect solution. However, when I received the following error from one of my regular readers, I was a little stumped at first! After some online probing, I figured out that it was actually syntax from MySql and not SQL Server. The reader encountered error when he ran the following query. ALTER TABLE Table1 DROP PRIMARY KEY GO Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword... - [SQL SERVER - Questions and Answers with Database Administrators](https://blog.sqlauthority.com/2009/05/11/sql-server-questions-and-answers-with-database-administrators/): I have been in India for long time now, and at present, I am managing a very large outsourcing project. Recently, we conducted few interviews since the project required more Database Administrators and Senior Developers, and I must say it was an enthralling experience for me! I got the opportunity to meet some very talented and competent programmers from all over the country. Scores of interesting questions were discussed between the interviewers and the candidates, which made the whole interview process nothing short of an enriching occasion! I am listing some of the interesting questions discussed during the interviews. Some are... - [SQL SERVER - 10 Reasons for Database Outsourcing](https://blog.sqlauthority.com/2009/05/10/sql-server-10-reasons-for-database-outsourcing/): 10 Reasons for Database Outsourcing While you may feel that your IT material is safe and handled effectively within your own company, these reasons may give you some perspective on why you may want to consider other options. Cost Reduction – Perhaps the most popular reason to outsource your database is the overall reduction in cost that would benefit your company.  No longer do you have to pay people to check up and maintain your servers, verify that they have uninterrupted power supplies, and ensure their security from hackers.  By going with an IT company that does this exclusively, you can... - [SQLAuthority News - Book Review - Beginners Guide to SQL Server Integration Services Using Visual Studio 2005](https://blog.sqlauthority.com/2008/01/28/sqlauthority-news-book-review-beginners-guide-to-sql-server-integration-services-using-visual-studio-2005/): Beginners Guide to SQL Server Integration Services Using Visual Studio 2005 (Paperback) by Jayaram Krishnaswamy (Author) Link to Amazon Short Summary: SQL Server Integration Services Using Visual Studio 2005 contains all the information and education needed for one to begin with SSIS. It covers all the basic concepts in depth and moves towards advance concepts of Extraction, Transformation and Loading (ETL). One book for all the beginners in SSIS. Detail Summary: SQL Server Integration Services (SSIS) is a comprehensive ETL tool available in SQL Server 2005. It is integrated with Visual Studio 2005 (VS2K5). SSIS is replacement of Data Transformation Services... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2008/01/27/sqlauthority-news-sql-joke-sql-humor-sql-laugh-funny-quotes/): Following is the collection of some funny quotes regarding computers. Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Rich Cook. UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. Dennis Ritchie. The perfect computer has been developed. You just feed in your problems and they never come out again. Al Goodman. Computers make it easier to do a lot of things, but most of the things they make... - [SQLAuthority News - Microsoft SQL Server 2000 MSIT Configuration Pack for Configuration Manager 2007](https://blog.sqlauthority.com/2008/01/26/sqlauthority-news-microsoft-sql-server-2000-msit-configuration-pack-for-configuration-manager-2007/): Microsoft SQL Server 2000 MSIT Comprehensive Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2000 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2000 MSIT Intermediate Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2000 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2000 MSIT Basic Configuration Pack for Configuration Manager 2007 This... - [SQL SERVER - 2005 - Database Table Partitioning Tutorial - How to Horizontal Partition Database Table](https://blog.sqlauthority.com/2008/01/25/sql-server-2005-database-table-partitioning-tutorial-how-to-horizontal-partition-database-table/): I have received calls from my DBA friend who read my article SQL SERVER - 2005 - Introduction to Partitioning. He suggested that I should write a simple tutorial about how to horizontal partition database table. Here is a simple tutorial which explains how a table can be partitioned. - [SQL SERVER - 2005 - Introduction to Partitioning](https://blog.sqlauthority.com/2008/01/24/sql-server-2005-introduction-to-partitioning/): Partitioning is the database process or method where very large tables and indexes are divided in multiple smaller and manageable parts. SQL Server 2005 allows to partition tables using defined ranges and also provides management features and tools to keep partition tables in optimal performance. Tables are partition based on column which will be used for partitioning and the ranges associated to each partition. Example of this column will be incremental identity column, which can be partitioned in different ranges. Different ranges can be on different partitions, different partition can be on different filegroups, and different partition can be on different... - [SQLAuthority News - Download Microsoft SQL Server 2005 Assessment Configuration Pack](https://blog.sqlauthority.com/2008/01/23/sqlauthority-news-download-microsoft-sql-server-2005-assessment-configuration-pack/): Microsoft SQL Server 2005 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Gramm-Leach Bliley Act compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains... - [SQLAuthority News - Fix : Remote Desktop Copy Paste Stop Working](https://blog.sqlauthority.com/2008/01/22/sqlauthority-news-fix-remote-desktop-copy-paste-stop-working/): Today’s article is not related to SQL Server 100%, however it is quite related to SQL Server, or atleast I found it while working with SQL Server. Just two days ago, while I was working with remote SQL Server using Remote Desktop tool provided by Windows XP. Suddenly, copy/paste feature of windows stop working on remote desktop. I was not able to copy from local machine to remote machine and remote machine to local machine, both ways. I was able to copy/paste from remote machine to remote machine and local machine to local machine. I thought may be if I restart... - [SQL SERVER - Get a Row Per File of a Database as Stored in the Master Database](https://blog.sqlauthority.com/2008/01/21/sql-server-2005-get-a-row-per-file-of-a-database-as-stored-in-the-master-database/): Each database has a minimum of two files associated with the database. If a database has more than one filegroup it will have many files associated with one database. Following quick script will give you recordset per file of a database which is stored in master database. - [SQL SERVER - Introduction to Statistical Functions - VAR, STDEVP, STDEV, VARP](https://blog.sqlauthority.com/2008/01/20/sql-server-introduction-to-statistical-functions-var-stdevp-stdev-varp/): Yesterday I wrote article about SQL SERVER – Introduction to Aggregate Functions. I received one email that four of the aggregate functions are statistical function and I should write something about that. VAR, STDEVP, STDEV, VARP are statistical functions as well they absolutely fit in the definition of aggregate function as well. The usage of this function is pretty simple so instead of explaining them I will go to example right away. USE AdventureWorks; GO SELECT VAR(Bonus) 'Variance', STDEVP(Bonus) 'Standard Deviation', STDEV(Bonus) 'Standard Deviation', VARP(Bonus) 'Variance for the Population' FROM Sales.SalesPerson; GO All the functions returns result as datatype float. VAR... - [SQL SERVER - Introduction to Aggregate Functions](https://blog.sqlauthority.com/2008/01/19/sql-server-introduction-to-aggregate-functions/): Recently I have been taking many interviews to increase work force in my companies outsourcing establishment. One question I ask to all interview candidates. What is Aggregate Function? So far I have received two different kind of response. First, I do not know. Second, AVG, SUM, COUNT are aggregate functions. The second response is good enough but not technically correct. None of the candidate have gave me good definition of Aggregate Function. Definition from BOL is Aggregate functions perform a calculation on a set of values and return a single value. Following functions are aggregate functions. AVG, MIN, CHECKSUM_AGG, SUM, COUNT,... - [SQL SERVER - 2005 Best Practices Analyzer (January 2008)](https://blog.sqlauthority.com/2008/01/18/sql-server-2005-best-practices-analyzer-january-2008/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD TOOL HERE Best Practice Analyzer (BPA) Tutorial Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Job Description of Database Administrator (DBA) or Database Developer](https://blog.sqlauthority.com/2008/01/17/sqlauthority-news-job-description-of-database-administrator-dba-or-database-developer/): Job Description of Database Administrator (DBA) or Database Developer Develop standards and guidelines to guide the use and acquisition of software and to protect vulnerable information. Modify existing databases and database management systems or direct programmers and analysts to make changes. Test programs or databases, correct errors and make necessary modifications. Plan, coordinate and implement security measures to safeguard information in computer files against accidental or unauthorized damage, modification or disclosure. Approve, schedule, plan, and supervise the installation and testing of new products and improvements to computer systems, such as the installation of new databases. Train users and answer questions. Establish... - [SQLAuthroity News - Microsoft SQL Server 2000 Assessment Configuration Pack](https://blog.sqlauthority.com/2008/01/16/sqlauthroity-news-microsoft-sql-server-2000-assessment-configuration-pack/): Microsoft SQL Server 2000 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2000 servers in order to support your Federal Information Security Management Act compliance efforts. Microsoft SQL Server 2000 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2000 servers in order to support your Gramm-Leach Bliley Act compliance efforts. Microsoft SQL Server 2000 Assessment Configuration Pack for Health Insurance Portability... - [SQL SERVER - What is - DML, DDL, DCL and TCL - Introduction and Examples](https://blog.sqlauthority.com/2008/01/15/sql-server-what-is-dml-ddl-dcl-and-tcl-introduction-and-examples/): DML DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. Examples: SELECT, UPDATE, INSERT statements DDL DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. Examples: CREATE, ALTER, DROP statements DCL DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it. Examples: GRANT, REVOKE statements TCL TCL is abbreviation of Transactional Control Language. It is used to... - [SQL SERVER - Time Out Due to Executing DELETE on Large RecordSet](https://blog.sqlauthority.com/2008/01/14/sql-server-time-out-due-to-executing-delete-on-large-recordset/): Just a day ago, I received following question: “I have large table more than 1M rows. I want to delete every row in my table. Everytime I ran DELETE statement, it times out and does not do it job. The data in table is useless and I do not need it ever. Your suggestion please.” The reason I decided to write article about this question because I receive similar questions very often. I think many readers will find answer to this question useful. My answer to his question is here with: “If DELETE is timing out use TRUNCATE instead. It will... - [SQLAuthority News - Good Motivational Quotes for Interviews](https://blog.sqlauthority.com/2008/01/13/sqlauthority-news-good-motivational-quotes-interviews/): Here are few motivational quotes for candidates who are appearing for interview. I have collected this throughout the years and it is running list of the interview. Please feel free to let me know if you find any such good interview quote and I will update in this list. - [SQL SERVER - 2005 - Change Compatibility Level - T-SQL Procedure](https://blog.sqlauthority.com/2008/01/12/sql-server-2005-change-compatibility-level-t-sql-procedure/): Six months ago I wrote article about SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility. Yesterday I received an email asking that one of my blog reader is not able to use the sp_dbcmptlevel command with error that database is in use. He has asked me to write about proper procedure of changing database compatibility which will always work. First read my previous article SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility as it has explained many details about compatibility. The best practice to change the compatibility level of database is in following three steps.... - [SQL SERVER - Reclaim Space After Dropping Variable - Length Columns Using DBCC CLEANTABLE](https://blog.sqlauthority.com/2008/01/11/sql-server-reclaim-space-after-dropping-variable-length-columns-using-dbcc-cleantable/): All DBA and Developers must have observed when any variable length column is dropped from table, it does not reduce the size of table. Table size stays the same till Indexes are reorganized or rebuild. There is also DBCC command DBCC CLEANTABLE, which can be used to reclaim any space previously occupied with variable length columns. Variable length columns include varchar, nvarchar, varchar(max), nvarchar(max), varbinary, varbinary(max), text, ntext, image, sql_variant, and xml. Space can be reclaimed when variable length column is also modified to lesser length. - [SQL SERVER - 2005 - Display Fragmentation Information of Data and Indexes of Database Table](https://blog.sqlauthority.com/2008/01/10/sql-server-2005-display-fragmentation-information-of-data-and-indexes-of-database-table/): One of my friend involved with large business of medical transcript invited me for SQL Server improvement talk last weekend. I had great time talking with group of DBA and developers. One of the topic which was discussed was how to find out Fragmentation Information for any table in one particular database. For SQL Server 2000 it was easy to find using DBCC SHOWCONTIG command. DBCC SHOWCONTIG has some limitation for SQL Server 2000. SQL Server 2005 has sys.dm_db_index_physical_stats dynamic view which returns size and fragmentation information for the data and indexes of the specified table or view. You can run... - [SQL SERVER - Execute Same Query and Statement Multiple Times Using Command GO](https://blog.sqlauthority.com/2008/01/09/sql-server-execute-same-query-and-statement-multiple-times-using-command-go/): Following question was asking by one of long time reader who really liked trick of SQL SERVER – Explanation SQL Command GO and SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL. She asked how can I execute same code multiple times without Copy and Paste multiple times in Query Editor. The answer to this question is very simple. Use the command GO. Following example demonstrate how GO can be used to execute same code multiple times. SELECT GETDATE() AS CurrentTime GO 5 Above code will return current time 5 times as GO is followed... - [SQL SERVER - Export Data From SQL Server to Microsoft Excel Datasheet](https://blog.sqlauthority.com/2008/01/08/sql-server-2005-export-data-from-sql-server-2005-to-microsoft-excel-datasheet/): Question: How to Export Data From SQL Server to Microsoft Excel Datasheet? - [SQL SERVER - 2005 - Introduction and Explanation to SYNONYM - Helpful T-SQL Feature for Developer](https://blog.sqlauthority.com/2008/01/07/sql-server-2005-introduction-and-explanation-to-synonym-helpful-t-sql-feature-for-developer/): One of my friend and extremely smart DBA Jonathan from Las Vegas has pointed out nice little enhancement in T-SQL. I was very pleased when I learned about SYNONYM feature in SQL Server 2005. DBA have been referencing database objects in four part names. SQL Server 2005 introduces the concept of a synonym. A synonyms is a single-part name which can replace multi part name in SQL Statement. Use of synonyms cuts down typing long multi part server name and can replace it with one synonyms. It also provides an abstractions layer which will protect SQL statement using synonyms from changes... - [SQL SERVER - Download Frequently Asked Generic Interview Questions](https://blog.sqlauthority.com/2008/01/06/sql-server-download-frequently-asked-generic-interview-questions/): Yesterday I posted article about SQL SERVER – Most Frequently Asked Generic Interview Questions. I always enjoy when I receive emails and comments about my article. Many readers have asked me to write more about this, I suggest that my readers help me here and add their suggestion and answers to original article. The common question asked to me is why I have not included answers with this questions. Each question is very unique to each individual and its answer can be very different from person to person. There is no right or wrong answer here. Just answer what you feel... - [SQL SERVER - Most Frequently Asked Generic Interview Questions](https://blog.sqlauthority.com/2008/01/05/sql-server-most-frequently-asked-generic-interview-questions/): Tell me about yourself. What experience do you have in this field? How many years of experience do you have in area you are applying for? Why did you leave your last job? Why are you planning to leave your current job? What do you know about this organization? Why do you want to work for this organization? How would you describe your ideal job? How long would you expect to work for us if hired? What have you done to improve your knowledge recently? What do co-workers say about you? What irritates you about co-workers? What kind of person would... - [SQL SERVER - Quick Note on CROSS APPLY](https://blog.sqlauthority.com/2008/01/04/sql-server-2005-cross-apply/): Yesterday I wrote article about SQL SERVER – 2005 – Last Ran Query – Recently Ran Query. I had used CROSS APPLY in the query. I got email from one reader asking what is CROSS APPLY. In simpler words, cross apply is like inner join to table valued function which can take parameters. This particular operation is not possible to do using regular JOIN syntax You can see example of CROSS APPLY in my article here. - [SQL SERVER - 2005 - Last Ran Query - Recently Ran Query](https://blog.sqlauthority.com/2008/01/03/sql-server-2005-last-ran-query-recently-ran-query/): How many times we have wondered what were the last few queries ran on SQL Server? Following quick script demonstrates last ran query along with the time it was executed on SQL Server 2005. SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest ORDER BY deqs.last_execution_time DESC Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL – sys.dm_exec_query_stats, BOL – sys.dm_exec_sql_text - [SQLAuthority New - Best Practices for Speeding Up Your Web Site](https://blog.sqlauthority.com/2008/01/03/sqlauthority-new-best-practices-for-speeding-up-your-web-site/): Steve Souders, Chief Performance Yahoo! Best Practices for Speeding Up Your Web Site. I suggest everybody should read this basic guidelines. They are extremely important for high performance websites. 1. Make Fewer HTTP Requests 2. Use a Content Delivery Network 3. Add an Expires Header 4. Gzip Components 5. Put Stylesheets at the Top 6. Put Scripts at the Bottom 7. Avoid CSS Expressions 8. Make JavaScript and CSS External 9. Reduce DNS Lookups 10. Minify JavaScript 11. Avoid Redirects 12. Remove Duplicate Scripts 13. Configure ETags 14. Make Ajax Cacheable Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 15281 SQL Server blocked access to STATEMENT OpenRowset/OpenDatasource of](https://blog.sqlauthority.com/2008/01/02/sql-server-fix-error-15281-sql-server-blocked-access-statement-openrowsetopendatasource-component-ad-hoc-distributed-queries-component-turned-off/): Error 15281 Msg 15281, Level 16, State 1, Line 3 SQL Server blocked access to STATEMENT ‘OpenRowset/OpenDatasource’ of component ‘Ad Hoc Distributed Queries’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ad Hoc Distributed Queries’ by using sp_configure. For more information about enabling ‘Ad Hoc Distributed Queries’, see “Surface Area Configuration” in SQL Server Books Online. - [SQLAuthority New - Happy New Year 2008](https://blog.sqlauthority.com/2008/01/01/sqlauthority-new-happy-new-year-2008/): Today is New Year and I wish you all Best for Year 2008. Let us all start our new year with motivational new year quote. We will open the book. Its pages are blank. We are going to put words on them ourselves. The book is called “Opportunity” and its first chapter is New Year’s Day. – Edith Lovejoy Pierce Microsoft has big gift for all SQL Server fans and developers. It is realizing SQL Server 2008. Today in New Year let us have some laugh together. We will continue together with SQL Server articles from tomorrow. I hope you enjoy... - [SQLAuthority News - Thank You to Blog Readers](https://blog.sqlauthority.com/2007/12/31/sqlauthority-news-thank-you-to-blog-readers/): Thank You very much for reading SQLAuthority.com for entire 2007 year. Wish you the BEST for year 2008. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Remove Duplicate Characters From a String](https://blog.sqlauthority.com/2007/12/30/sql-server-remove-duplicate-characters-from-a-string/): Follow up of my previous article of Remove Duplicate Chars From String here is another great article written by Madhivanan where similar solution is suggested with alternate method of Number table approach. Check out Remove duplicate characters from a string Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Change Password of SA Login Using Management Studio](https://blog.sqlauthority.com/2007/12/29/sql-server-change-password-of-sa-login-using-management-studio/): Login into SQL Server using Windows Authentication. In Object Explorer, open Security folder, open Logins folder. Right Click on SA account and go to Properties. Change SA password, and confirm it. Click OK. Make sure to restart the SQL Server and all its services and test new password by log into system using SA login and new password. Reference : Pinal Dave (https://blog.sqlauthority.com) UPDATE : There has been discussion about restarting the SQL Server and all its services. Please read all of them before making final decision for your scenario. - [SQL SERVER - Difference Between Quality Assurance and Quality Control - QA vs QC](https://blog.sqlauthority.com/2007/12/28/sql-server-difference-between-quality-assurance-and-quality-control-qa-vs-qc/): Regular readers of this blog are aware of my current outsourcing assignment. I am managing very large outsourcing project in India. One thing is very special in all Indian offices are “Tea Time.” Everybody wants to attend Tea Time not only for tea or coffee but for the interesting discussion occurs at that time. This is the time when all the department employees are together and discussing whatever they wish.Today there was an interesting discussion about Quality Assurance (QA) and Quality Control (QC). - [SQLAuthority News - Book Review - A Practitioner's Guide to Software Test Design](https://blog.sqlauthority.com/2007/12/27/sqlauthority-news-book-review-a-practitioners-guide-to-software-test-design/): A Practitioner's Guide to Software Test Design is one book containing all the important latest test design approaches. This book makes life of software tester very easy. Software tester can find all the information in this book instead of searching through hundreds of books, periodicals and websites. - [SQL SERVER - TRUNCATE Can't be Rolled Back Using Log Files After Transaction Session Is Closed](https://blog.sqlauthority.com/2007/12/26/sql-server-truncate-cant-be-rolled-back-using-log-files-after-transaction-session-is-closed/): You might have listened and read either of following sentence many many times. “DELETE can be rolled back and TRUNCATE can not be rolled back”. OR “DELETE can be rolled back as well as TRUNCATE can be rolled back”. As soon as above sentence is completed, someone will object it saying either TRUNCATE can be or can not be rolled back. Let us make sure that we understand this today, in simple words without talking about theory in depth. While database is in full recovery mode, it can rollback any changes done by DELETE using Log files. TRUNCATE can not be... - [SQL SERVER - Mirrored Backup Introduction and Explanation](https://blog.sqlauthority.com/2007/12/25/sql-server-mirrored-backup-introduction-and-explanation/): SQL Server 2005 Enterprise Edition and Development Edition supports mirrored backup. Mirroring a media set increases backup reliability by adding redundancy of backup media which effectively reduces the impact of backup-device failing. While taking backup of database, same backup is taken on multiple media or locations. T-SQL code to take Mirrored Backup : BACKUP DATABASE AdventureWorks TO DISK = 'c:\AdventureWorksBackup.bak' MIRROR TO DISK = 'd:\AdventureWorksBackupCopy.bak' WITH FORMAT; Above script will create two backups at two different locations, if backup of one location is corrupted backup from another location will work fine. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Delete Duplicate Records - Count Duplicate Records Links](https://blog.sqlauthority.com/2007/12/25/sql-server-delete-duplicate-records-count-duplicate-records-links/): I have wrote following two articles for Duplicate Rows Management in SQL Server. SQL SERVER – Count Duplicate Records – Rows SQL SERVER – Delete Duplicate Records – Rows Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Object Oriented Database Management Systems](https://blog.sqlauthority.com/2007/12/24/sql-server-object-oriented-database-management-systems/): I have received few emails and comments about why I do not write about Object Oriented Database Management Systems (OODBMS). The reason for that is that I am big follower of Relational Database Management Systems (RDBMS) and that particularly of Microsoft SQL Server. If you are interested in reading about OODBMS, I have came across one interesting article, which I can share here. Visit : AN EXPLORATION OF OBJECT ORIENTED DATABASE MANAGEMENT SYSTEMS by Dare Obasanjo The purpose of above mentioned paper is to provide answers to the following questions What is an Object Oriented Database Management System (OODBMS)? Is an... - [SQLAuthority News - Download Microsoft SQL Server 2000/2005 Management Pack](https://blog.sqlauthority.com/2007/12/24/sqlauthority-news-download-microsoft-sql-server-20002005-management-pack/): Note: Download Microsoft SQL Server 2000/2005 Management Pack by Microsoft The SQL Server Management Pack monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems. Availability and performance monitoring is done using synthetic transactions. In addition, the Management Pack collects Event Log alerts and provides associated knowledge articles with additional user details, possible causes, and suggested resolutions. The Management Pack discovers Database Engines, Database Instances, and Databases and can optionally discover Database File and Database File Group objects. Feature Summary: Active Directory Helper Service SQL Server Agent Backup Databases and Tables DBCC Full... - [SQLAuthority News - Jobs, Search, Best Articles, Homepage](https://blog.sqlauthority.com/2007/12/24/sqlauthority-news-jobs-search-best-articles-homepage/): If you are looking for solution of any of your question : Search SQLAuthority If you are looking for best job in IT field : Find Job or email pinal@sqlauthority.com If you are looking for talented IT professional : Post Job or email pinal@sqlauthority.com If you want to read my personally selected articles : Best Articles If you want to know more about me : pinaldave.com If you want to subscribe to my blog : Email or Feed Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - New DataTypes DATE and TIME](https://blog.sqlauthority.com/2007/12/23/sql-server-2008-new-datatypes-date-and-time/): One of our project manager asked me why SQL Server does not have only DATE or TIME datatypes? I thought his question is very valid, he is not DBA however he understands the RDBMS concepts very well. I find his question very interesting. I told him that there are ways to do that in SQL Server 2005 and earlier versions. He asked me but if there are DATE and TIME datatypes not DATETIME combined. This question we all DBA had for many years and we all wanted DATE and TIME separate datatypes then DATETIME combined. Microsoft has incorporated this feature in... - [SQL SERVER - Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script](https://blog.sqlauthority.com/2007/12/22/sql-server-difference-between-index-rebuild-and-index-reorganize-explained-with-t-sql-script/): Index Rebuild : This process drops the existing Index and Recreates the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REBUILD GO Index Reorganize : This process physically reorganizes the leaf nodes of the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REORGANIZE GO Recommendation: Index should be rebuild when index fragmentation is great than 40%. Index should be reorganized when index fragmentation is between 10% to 40%. Index rebuilding process uses more CPU and it locks the database resources. SQL Server development version and Enterprise version has option ONLINE, which can be turned on when Index is rebuilt.... - [SQL SERVER - Enabling Clustered and Non-Clustered Indexes - Interesting Fact](https://blog.sqlauthority.com/2007/12/21/sql-server-enabling-clustered-and-non-clustered-indexes-interesting-fact/): While playing with Indexes I have found following interesting fact. I did some necessary tests to verify that it is true. When a clustered index is disabled, all the nonclustered indexes on the same tables are auto disabled as well. User do not need to disable non-clustered index separately. However, when clustered index is enabled, it does not automatically enable nonclustered index. All the nonclustered indexes needs to be enabled individually. I wondered if there is any short cut to enable all the indexes together. Index rebuilding came to my mind instantly. I ran T-SQL command of rebuilding all the indexes... - [SQL SERVER - DISTINCT Keyword Usage and Common Discussion](https://blog.sqlauthority.com/2007/12/20/sql-server-distinct-keyword-usage-and-common-discussion/): Jr. DBA asked me a day ago, how to apply DISTINCT keyword to only first column of SELECT. When asked for additional information about question, he showed me following query. SELECT Roles, FirstName, LastName FROM UserNames He wanted to apply DISTINCT to only Roles and not across FirstName and LastName. When he finished I realize that it is not possible and there is logical error in thinking query like that. I helped him with what he needed however, after he left I realize that answer to his original question was “NO”. Distinct can not be applied to only few columns it... - [SQL SERVER - Cumulative Update Package 5 for SQL Server 2005 Service Pack 2](https://blog.sqlauthority.com/2007/12/19/sql-server-cumulative-update-package-5-for-sql-server-2005-service-pack-2/): Microsoft SQL Server 2005 hotfixes are created for specific SQL Server service packs. You must apply a SQL Server 2005 Service Pack 2 hotfix to an installation of SQL Server 2005 Service Pack 2. By default, any hotfix that is provided in a SQL Server service pack is included in the next SQL Server service pack. Cumulative Update 5 contains hotfixes for SQL Server 2005 issues that have been fixed since the release of Service Pack 2. Latest Build 3215. Download Information Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - RML Utilities for SQL Server](https://blog.sqlauthority.com/2007/12/19/sqlauthority-news-rml-utilities-for-sql-server/): The RML utilities allow you to process SQL Server trace files and view reports showing how SQL Server is performing. For example, you can quickly see: Which application, database or login is using the most resources, and which queries are responsible for that Whether there were any plan changes for a batch during the time when the trace was captured and how each of those plans performed What queries are running slower in today’s data compared to a previous set of data Download RML Utilities for SQL Server (x86) Download RML Utilities for SQL Server (x64) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Get Information of Index of Tables and Indexed Columns](https://blog.sqlauthority.com/2007/12/18/sql-server-get-information-of-index-of-tables-and-indexed-columns/): Knowledge of T-SQL inbuilt functions and store procedure can save great amount of time for developers. Following is very simple store procedure which can display name of Indexes and the columns on which indexes are created. Very handy stored Procedure. USE AdventureWorks; GO EXEC sp_helpindex 'Person.Address' GO Above SP will return following information. IndexName – IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode Index_Description – nonclustered, unique located on PRIMARY Index_Keys – AddressLine1, AddressLine2, City, StateProvinceID, PostalCode Let me know if you think this kind of small tips are useful to you. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to Find Details About TempDB Information](https://blog.sqlauthority.com/2007/12/17/sql-server-t-sql-script-to-find-details-about-tempdb/): Two days ago I wrote an article about SQL SERVER - TempDB Restrictions - Temp Database Restrictions. Since then I have received few emails asking details about Temp DB. I use following T-SQL Script to know details about my TempDB. This script is a pretty old script but it does work great most of the time. I strongly encourage all of you to use a script to check your TempDB Information. - [SQL SERVER - Solution - Log File Very Large - Log Full](https://blog.sqlauthority.com/2007/12/16/sql-server-solution-log-file-very-large-log-full/): I have been receiving following question again and again either through email or through comments on this blog. My log file is too big, what should I do? Answer to this question is in three steps. Backup the log file to any device. Truncate the log file. Shrink the log file. I have previously written two article about this issue. Refer them for additional information and details. SQL SERVER – Shrinking Truncate Log File – Log Full(Script) SQL SERVER – Shrinking Truncate Log File – Log Full – Part 2(Management Studio) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - TempDB Restrictions - Temp Database Restrictions](https://blog.sqlauthority.com/2007/12/15/sql-server-tempdb-restrictions-temp-database-restrictions/): While conducting Interview for my outsourcing project, I asked one question to interviewer that what are the restrictions on TempDB? The candidate was not able to answer the question. I thought it would be good for all my readers to know the answer to this question so if you face this question in an interview or if you meet me in the interview you will be able to answer this question. - [SQLAuthority News - Top 10 Tips for Successful Software Outsourcing](https://blog.sqlauthority.com/2007/12/14/sqlauthority-news-top-10-tips-for-successful-software-outsourcing/): Few days ago, I wrote article about SQLAuthority Author Visit – IT Outsourcing to India – Top 10 Reasons Companies Outsource. I received quite a few emails regarding this article. I was really impressed that how much vendors care about their reputation and their client. I received so many requests from my blog readers who are interested in learning how to be successful at Software Outsourcing. I decided to write top 10 tips for the same. I have not described them in depth as they are pretty self explanatory. Define the scope of project clearly and as much as detail it... - [SQL SERVER - Do Not Store Images in Database - Store Location of Images (URL)](https://blog.sqlauthority.com/2007/12/13/sql-server-do-not-store-images-in-database-store-location-of-images-url/): Just a day ago I received phone call from my friend in Bangalore. He asked me What do I think of storing images in database and what kind of datatype he should use? I have very strong opinion about this issue. I suggest to store the location of the images in the database using VARCHAR datatype instead of any BLOB or other binary datatype. Storing the database location reduces the size of database greatly as well updating or replacing the image are much simpler as it is just an file operation instead of massive update/insert/delete in database. Reference : Pinal Dave... - [SQL SERVER - White Papers: Migration from Oracle Sybase, or Microsoft Access to Microsoft SQL Server](https://blog.sqlauthority.com/2007/12/12/sql-server-white-papers-migration-from-oracle-sybase-or-microsoft-access-to-microsoft-sql-server/): Guide to Migrating from Oracle to SQL Server 2005 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2005. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. The entire migration process using SQL Server Migration Assistant for Oracle (SSMA Oracle) is explained in depth, with a special focus on converting database objects and PL/SQL code. Guide to Migrating from Sybase ASE to SQL Server 2005 This white paper covers known issues for migrating Sybase Adaptive Server Enterprise database to SQL Server... - [SQL SERVER - Microsoft Synchronization Services for ADO.NET v2.0 CTP1 Refresh](https://blog.sqlauthority.com/2007/12/11/sql-server-microsoft-synchronization-services-for-adonet-v20-ctp1-refresh/): Microsoft Synchronization Services for ADO.NET provides the ability to synchronize data from disparate sources over two-tier, N-tier, and service-based architectures. Rather than simply replicating a database and its schema, the Synchronization Services application programming interface (API) provides a set of components to synchronize data between data services and a local store. Applications are increasingly used on mobile clients, such as laptops and devices, that do not have a consistent or reliable network connection to a central server. It is crucial for these applications to work against a local copy of data on the client. Equally important is the need to synchronize... - [SQLAuthority News - Microsoft SQL Server 2008 Community Technology Preview (November 2007) VHD](https://blog.sqlauthority.com/2007/12/10/sqlauthority-news-microsoft-sql-server-2008-community-technology-preview-november-2007-vhd/): SQL Server 2008, the next release of Microsoft SQL Server, will provide a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with relevant insights. This download comes as a pre-configured VHD. This allows you to trial SQL Server 2008 CTP in a virtual environment. Download from here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ACID (Atomicity, Consistency, Isolation, Durability)](https://blog.sqlauthority.com/2007/12/09/sql-server-acid-atomicity-consistency-isolation-durability/): ACID (an acronym for Atomicity Consistency Isolation Durability) is a concept that Database Professionals generally look for when evaluating databases and application architectures. For a reliable database all this four attributes should be achieved. - [SQL SERVER - Generic Architecture Image](https://blog.sqlauthority.com/2007/12/08/sql-server-generic-architecture-image/): Just a day ago, while I was surfing Wikipedia about SQL Server, I came across this generic architecture image. I found it interesting. Click on image to view it in large size. The physical structure of the database is divided into the MDF and LDF. The part of MDF contains file group, data files, tables and indexes, extended and page. The LDF file contains a transaction log file. The physical architecture is about how the data is actually stored in the file system. Page, extend, database files are physical architecture. - [SQL SERVER - FIX : Error : 3702 Cannot drop database because it is currently in use.](https://blog.sqlauthority.com/2007/12/07/sql-server-fix-error-3702-cannot-drop-database-because-it-is-currently-in-use/): Msg 3702, Level 16, State 3, Line 2 Cannot drop database “DataBaseName” because it is currently in use. This is a very generic error when DROP Database is command is executed and the database is not dropped. The common mistake user is kept the connection open with this database and trying to drop the database. The following commands will raise above error: USE AdventureWorks; GO DROP DATABASE AdventureWorks; GO Fix/Workaround/Solution: The following commands will not raise an error and successfully drop the database: USE Master; GO DROP DATABASE AdventureWorks; GO If you want to drop the database use master database first... - [SQL SERVER - 2005 - Dynamic Management Views (DMV) and Dynamic Management Functions (DMF)](https://blog.sqlauthority.com/2007/12/06/sql-server-2005-dynamic-management-views-dmv-and-dynamic-management-functions-dmf/): Dynamic Management Views (DMV) and Dynamic Management Functions (DMF) return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance. They can exactly tell what is going on with SQL Server and its objects at the moment.There are tow kinds of DMVs and DMFs. Server-scoped dynamic management views and functions. Database-scoped dynamic management views and functions. All dynamic management views and functions exist in the sys schema and follow this naming convention dm_*. When you use a dynamic management view or function, you must prefix the name of the view or... - [SQL SERVER - UDF - Remove Duplicate Chars From String](https://blog.sqlauthority.com/2007/12/05/sql-server-udf-remove-duplicate-chars-from-string/): Few days ago, I received following wonderful UDF from one of this blog reader. This UDF is written for specific purpose of removing duplicate chars string from one large string. Virendra Chauhan, author of this UDF is working as DBA in Lutheran Health Network. CREATE FUNCTION dbo.REMOVE_DUPLICATE_INSTR (@datalen_tocheck INT,@string VARCHAR(255)) RETURNS VARCHAR(255) AS BEGIN DECLARE @str VARCHAR(255) DECLARE @count INT DECLARE @start INT DECLARE @result VARCHAR(255) DECLARE @end INT SET @start=1 SET @end=@datalen_tocheck SET @count=@datalen_tocheck SET @str = @string WHILE (@count <=255) BEGIN IF (@result IS NULL) BEGIN SET @result='' END SET @result=@result+SUBSTRING(@str,@start,@end) SET @str=REPLACE(@str,SUBSTRING(@str,@start,@end),'') SET @count=@count+@datalen_tocheck END RETURN @result END... - [SQLAuthority Author Visit - IT Outsourcing to India - Top 10 Reasons Companies Outsource](https://blog.sqlauthority.com/2007/12/04/sqlauthority-author-visit-it-outsourcing-to-india-top-10-reasons-companies-outsource/): Yesterday I had meeting with few of the leading outsourcing companies in Ahmedabad, India. Regular readers of this blog knows that I am currently in India handling large scale outsourcing assignment. My responsibilities includes managing application development, system architecture and database architecture. The purpose of meeting was to exchange the views and learn methodologies from one another regarding how to provide quality service to offshore clients. There were about 10-15 Sr. Managers from different outsourcing company. The conversation was excellent and we all felt that we have learned a lot from each other. Two major things discussed were quality of products... - [SQL SERVER - Grouping JOIN Clauses In SQL](https://blog.sqlauthority.com/2007/12/03/sql-server-grouping-join-clauses-in-sql/): I always enjoy writing and reading articles about JOIN Clauses. One of my friend and the best ColdFusion Expert Ben Nadel has written good article about SQL JOINs. There are few interesting comments as well at the end of article. “JOIN grouping is pretty powerful and can get you out of those sticky situations that involve mixed table relationship rules. ” Ben Nadel – Grouping JOIN Clauses In SQL Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Q and A with Database Administrators](https://blog.sqlauthority.com/2007/12/02/sql-server-qa-with-database-administrators/): I have been in India for more than a month now, as I am leading a very large outsourcing project. We have conducted few interviews since the project required more Database Administrators and Senior Developers. I am listing few of the questions discussed during all the interviews. The whole event of interviews was very interesting. I met some very good programmers from all over the country. Many interesting questions were discussed between interviewers and candidates. I am listing some of those questions here. Some are technical and some are just my personal opinions. I will appreciate your thought about this article.... - [SQL SERVER - Sharpen Your Skills: Brush up on FILLFACTOR, ISNULL, NULLIF, and % as wildcard and operator](https://blog.sqlauthority.com/2007/12/01/sql-server-sharpen-your-skills-brush-up-on-fillfactor-isnull-nullif-and-as-wildcard-and-operator/): Read my article in SQL Server Magazine December 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download SQL Server 2005 Books Online (September 2007)](https://blog.sqlauthority.com/2007/11/30/sqlauthority-news-download-sql-server-2005-books-online-september-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The September 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - Database Interview Questions and Answers Complete List](https://blog.sqlauthority.com/2007/11/29/sql-server-database-interview-questions-and-answers-complete-list/): Update: I have updated this article series and newly updated article series is over here. If you are subscribed to my blog you will know that I receive request to send Database or SQL Server very frequently. Following is list of articles of my questions and answers series. Download SQL Server Interview Questions and Answers Complete List Complete Series of SQL Server Interview Questions and Answers SQL Server Interview Questions and Answers – Introduction SQL Server Interview Questions and Answers – Part 1 SQL Server Interview Questions and Answers – Part 2 SQL Server Interview Questions and Answers – Part 3... - [SQL SERVER - Correct Syntax for Stored Procedure SP](https://blog.sqlauthority.com/2007/11/28/sql-server-correct-syntax-for-stored-procedure-sp/): Just a day ago, I received interesting question about correct syntax for Stored Procedure. Many readers of this blog will think that it is very simple question. The reason this is interesting is the question behavior of BEGIN … END statements and GO command in Stored Procedure. Let us first see what is correct syntax. Correct Syntax: CREATE PROCEDURE usp_SelectRecord AS BEGIN SELECT * FROM TABLE END GO I have seen many new developers write statements after END statement. This will not work but will probably execute first fine when stored procedure is created. Rule is anything between BEGIN and END... - [SQL SERVER - 2005 - List All Stored Procedure in Database](https://blog.sqlauthority.com/2007/11/27/sql-server-2005-list-all-stored-procedure-in-database/): Run following simple script on SQL Server 2005 to retrieve all stored procedure in database. SELECT * FROM sys.procedures; This will ONLY work with SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Rules of Third Normal Form and Normalization Advantage - 3NF](https://blog.sqlauthority.com/2007/11/26/sql-server-rules-of-third-normal-form-and-normalization-advantage-3nf/): I always ask question about Third Normal Form in interviews I take. Q. What is Third Normal Form and what is its advantage? A. Third Normal Form (3NF) is most preferable normal form in RDBMS. Normalization is the process of designing a data model to efficiently store data in a database. The rules of 3NF are mentioned here Make a separate table for each set of related attributes, and give each table a primary key. If an attribute depends on only part of a multi-valued key, remove it to a separate table If attributes do not contribute to a description of... - [SQLAuthority News - SQL Server Compact 3.5 Downloads and ReportViewer Visual Studio Download](https://blog.sqlauthority.com/2007/11/25/sqlauthority-news-sql-server-compact-35-downloads-and-reportviewer-visual-studio-download/): SQL Server Compact 3.5 Books Online and Samples SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the Books Online and Samples for SQL Server Compact 3.5 SQL Server Compact 3.5 for Windows Mobile SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the CAB files and DLL’s that are used to install SQL Server Compact 3.5 on the Windows Mobile Devices platform SQL Server... - [SQL SERVER - Upgrade Advise - From 2000 to 2005 or 2008](https://blog.sqlauthority.com/2007/11/24/sql-server-upgrade-advise-from-2000-to-2005-or-2008/): There has some good amount of discussion going on in SQL Server community about should we upgrade from SQL Server 2000 to SQL Server 2005 or wait for SQL Server 2008. I have received quite a few email and invitations to participate in forums on this topic. Instead of talking about this topic on different places, I have decided to write my opinion on my blog. I recommend to upgrade to SQL Server 2000 users to SQL Server 2005. SQL Server 2008 is due next year. The RTM may or may not be available till February 2008. After the release the... - [SQL SERVER - 2008 - November CPT5 New Improvement](https://blog.sqlauthority.com/2007/11/23/sql-server-2008-november-cpt5-new-improvement/): The progress map of SQL Server 2008 is diagrammatically listed here. I am listing the new improvements here as list. Data Collection and Performance Warehouse for Relational Engine Service Broker Enhancements Registered Servers Enhancements Synchronous net-changes change tracking for SQL Server T-SQL IntelliSense Declarative Management Framework (DMF) Enhancements Geo-spatial Support Analysis Services Query and Writeback Performance Robust Report Server Platform Integration Services – Lookup Enhancements Analysis Services MDX Query Optimizer – Block Computation Analysis Services Aggregation Design Analysis Services Cube Design Reporting Services Scale Engine Transparent Data Encryption Resource Governor – Limit Specification Backup Compression Plan Freezing Fully Parallel Plans Scale... - [SQL SERVER - Shrinking Truncate Log File - Log Full - Part 2](https://blog.sqlauthority.com/2007/11/22/sql-server-shrinking-truncate-log-file-log-full-part-2/): About a year ago, I wrote SQL SERVER - Shrinking Truncate Log File - Log Full. I was just going through some of the earlier posts and comments. - [SQL SERVER - Generate Incremented Linear Number Sequence](https://blog.sqlauthority.com/2007/11/21/sql-server-generate-incremented-linear-number-sequence/): Just a day ago, I received interesting question on this blog. Read original question here. This is very good question and after reading this question I quickly wrote small script as answer. Let us see the question and answer together. Q. How can we generate incremented linear number in sql server as in oracle we generate in via sequence? - [SQL SERVER - Sharpen Your Skills: Joins, Groupings, and Data Types](https://blog.sqlauthority.com/2007/11/20/sql-server-sharpen-your-skills-joins-groupings-and-data-types/): Read my article in SQL Server Magazine November 2007 Edition [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server 2008 Community Technology Preview (CTP) Download Now Available](https://blog.sqlauthority.com/2007/11/19/sqlauthority-news-sql-server-2008-community-technoloypreview-ctp-download-now-available/): Download the latest SQL Server 2008 Community Technology Preview (CTP) and try out the latest features of SQL Server 2008! The SQL Server development team uses your CTP feedback to help refine and enhance product features. Download it today and send your feedback. Microsoft SQL Server 2008, the next release of Microsoft SQL Server, provides a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with... - [SQLAuthority News - Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide - SQL Server, ColdFusion, ASP.NET](https://blog.sqlauthority.com/2007/11/18/sqlauthority-news-job-opportunity-in-ahmedabad-india-to-work-with-technology-leaders-worldwide-sql-server-coldfusion-aspnet/): If you have one or more years of experience in any web based programming language (.NET, ColdFusion, PHP) and interested in SQL Server as well willing to locate Ahmadabad, India. Please send me your resume, if selected you may get chance to work with one of the most progressing industry in world as well some smartest technology leaders worldwide. Salary depends on Experience. If selected for interview I suggest you go over SQL Server Interview Questions and Answers Complete List Download, as there is great chance I may be participating in interview. Please send your resume at pinaldave “at” yahoo.com and... - [SQL SERVER - 2005 - Best Practices for SQL Server Health Check](https://blog.sqlauthority.com/2007/11/17/sql-server-2005-best-practices-for-sql-server-health-check/): Here are few of the best practices one should follow for SQL Server Health Check. - [SQL SERVER - Generate Script with Data from Database - Database Publishing Wizard](https://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/): I really enjoyed writing about SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects. Since then the I have received question that how to copy data as well along with schema. The answer to this is Database Publishing Wizard. This wizard is very flexible and works with modes like schema only, data only or both. It generates a single SQL script file which can be used to recreate the contents of a database by manually executing the script on a target server. - [SQLAuthority News - Microsoft SQL Server 2005 Assessment Configuration Pack Download](https://blog.sqlauthority.com/2007/11/15/sqlauthority-news-microsoft-sql-server-2005-assessment-configuration-pack-download/): Microsoft SQL Server 2005 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Gramm-Leach Bliley Act compliance efforts Microsoft SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Database Dilbert](https://blog.sqlauthority.com/2007/11/14/sqlauthority-news-sql-joke-sql-humor-sql-laugh-database-dilbert/): This is my favorite Dilbert. Dilbert is an American comic strip written and illustrated by Scott Adams, first published in the year 1969. - [SQLAuthority News - Microsoft SQL Server 2005 MSIT Three Configuration Pack for Configuration Manager 2007](https://blog.sqlauthority.com/2007/11/14/sqlauthority-news-microsoft-sql-server-2005-msit-three-configuration-pack-for-configuration-manager-2007/): Microsoft SQL Server 2005 MSIT Basic Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2005 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2005 MSIT Intermediate Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2005 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2005 MSIT Comprehensive Configuration Pack for Configuration Manager 2007 This... - [SQL SERVER - DBCC CHECKDB Introduction and Explanation - DBCC CHECKDB Errors Solution](https://blog.sqlauthority.com/2007/11/13/sql-server-dbcc-checkdb-introduction-and-explanation-dbcc-checkdb-errors-solution/): DBCC CHECKDB checks the logical and physical integrity of all the objects in the specified database. If DBCC CHECKDB ran on database user should not run DBCC CHECKALLOC, DBCC CHECKTABLE, and DBCC CHECKCATALOG on database as DBCC CHECKDB includes all the three command. Usage of these included DBCC commands is listed below. - [SQL SERVER - FIX : ERROR Msg 1803 The CREATE DATABASE statement failed. The primary file must be at least 2 MB to accommodate a copy of the model database](https://blog.sqlauthority.com/2007/11/12/sql-server-fix-error-msg-1803-the-create-database-statement-failed-the-primary-file-must-be-at-least-2-mb-to-accommodate-a-copy-of-the-model-database/): Following error occurs when database which is attempted to be created is smaller than Model Database. It is must that all the databases are larger than Model database and 512KB. Following code will create the error discussed in this post. CREATE DATABASE Tests ON ( NAME = 'Tests', FILENAME = 'c:\tests.mdf', SIZE = 512KB ) GO Msg 1803, Level 16, State 1, Line 1 The CREATE DATABASE statement failed. The primary file must be at least 2 MB to accommodate a copy of the model database. Fix/WorkAround/Solution : Create database which is larger than Model database and 512KB. Size of the... - [SQLAuthority News - The Equations of Relativist](https://blog.sqlauthority.com/2007/11/12/sqlauthority-news-the-equations-of-relativist/): F = mg ….. Galileo F = ma ….. Newton E = mc²….. Einstein Reference : Pinal Dave (https://blog.sqlauthority.com) , Great Site – relationary) - [SQL SERVER - FIX : ERROR Msg 5174 Each file size must be greater than or equal to 512 KB](https://blog.sqlauthority.com/2007/11/12/sql-server-fix-error-msg-5174-each-file-size-must-be-greater-than-or-equal-to-512-kb/): Following error occurs when database which is attempted to be created is smaller than 512KB. It is must that all the databases are larger than 512KB. It will also follow with another error 1802, which is due to previous error 5174. Following code will create the error discussed in this post. CREATE DATABASE Tests ON ( NAME = 'Tests', FILENAME = 'c:\tests.mdf', SIZE = 12KB ) GO Msg 5174, Level 16, State 1, Line 1 Each file size must be greater than or equal to 512 KB. Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names... - [SQLAuthority News - SQL Server 2005 Powers Global Forensic Data Security Tool](https://blog.sqlauthority.com/2007/11/11/sqlauthority-news-sql-server-2005-powers-global-forensic-data-security-tool/): Note :  Download Whitepaper by Microsoft Find out how SQL Server 2005 powers a 27 TB data management system called ICE 3.0 that gathers forensic data from more than 85 Microsoft corporate proxy servers into a single database. The Information Security team at Microsoft uses an internal tool called Information Security Consolidated Event Management (ICE 3.0) to gather forensic data from more than 85 proxy servers around the world. Powered by SQL Server 2005, the 27 TB data management system collects different types of global evidence, such as inbound and outbound e-mail traffic, Login events, and Web browsing, into a single... - [SQL SERVER - 2005 2000 - Search String in Stored Procedure](https://blog.sqlauthority.com/2007/11/10/sql-server-2005-2000-search-string-in-stored-procedure/): SQL Server has released SQL Server 2000 edition before 7 years and SQL Server 2005 edition before 2 years now. There are still few users who have not upgraded to SQL Server 2005 and they are waiting for SQL Server 2008 in February 2008 to SQL Server 2008 to release. This blog has is heavily visited by users from both the SQL Server products. I have two previous posts which demonstrate the code which can be searched string in stored procedure. Many users get confused with the script version and try to execute SQL Server 2005 version on SQL Server 2000,... - [SQL SERVER - Versions, CodeNames, Year of Release](https://blog.sqlauthority.com/2007/11/09/sql-server-versions-codenames-year-of-release/): Just a day ago, while I was discussing one of the project with another outsourcing team lead in India (who is leading team of 100+ programmer and developer) he asked me if I know all the codenames of the SQL Server releases so far. I knew only two code names SQL Server 2005 – Yukon and SQL Server 2008 – Katmai. Once our meeting was over, I could not stop thinking about this question. I search online and very easily I found answer to this question on wikipedia. 1993 – SQL Server 4.21 for Windows NT 1995 – SQL Server 6.0,... - [SQLAuthority News - Book Review - SQL Server 2005 Management and Administration (Paperback)](https://blog.sqlauthority.com/2007/11/08/sqlauthority-news-book-review-sql-server-2005-management-and-administration-paperback/): SQL Server 2005 Management and Administration (Paperback) by Ross Mistry (Author), Chris Amaris (Author), Alec Minty (Author), Rand Morimoto (Author) Link to Amazon Short Summary: SQL SERVER 2005 is a trusted database platform that provides organizations a competitive advantage by allowing them to obtain faster results and make better business decisions. This book covers all the topics which can help Database Administrators to be successful and effective. Detail summary: This book is covers all the topics and modules of the SQL Server 2005, e.g. database engine, Analysis Services, Integration Services, replication, Reporting Services, Notification Services, services broker and full text search.... - [SQLAuthority News - 1 Million Visitors in last 1 year - [Update 2019]](https://blog.sqlauthority.com/2007/11/07/sqlauthority-news-1-million-visitors-in-last-1-year-update-2019/): It is indeed a bit day for me. I am very happy that I have 1 million visitors in just last 1 year. Read my story of 365 days. - [SQLAuthority News - Microsoft Synchronization Services for ADO.NET v2.0 CTP1](https://blog.sqlauthority.com/2007/11/06/sqlauthority-news-microsoft-synchronization-services-for-adonet-v20-ctp1/): Microsoft Synchronization Services for ADO.NET provides the ability to synchronize data from disparate sources over two-tier, N-tier, and service-based architectures. Rather than simply replicating a database and its schema, the Synchronization Services application programming interface (API) provides a set of components to synchronize data between data services and a local store. Applications are increasingly used on mobile clients, such as laptops and devices, that do not have a consistent or reliable network connection to a central server. It is crucial for these applications to work against a local copy of data on the client. Equally important is the need to synchronize... - [SQLAuthority News - Few Add-ons for SQLAuthority](https://blog.sqlauthority.com/2007/11/05/sqlauthority-news-few-add-ons-for-sqlauthority/): SQL Random Article Find Post SQL Jobs Search SQLAuthority Subscribe Email Update SQLAuthority Feed My Other Blog Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Best Articles on SQLAuthority.com](https://blog.sqlauthority.com/2007/11/04/sqlauthority-news-best-articles-on-sqlauthoritycom/): SQL SERVER – Cursor to Kill All Process in Database SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored procedure SQL SERVER – Shrinking Truncate Log File – Log Full SQL SERVER – Simple Example of Cursor SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case SQL SERVER – Restore Database Backup using SQL Script (T-SQL) SQL SERVER – T-SQL Script to find the CD key from Registry SQL SERVER – Delete Duplicate Records – Rows SQL SERVER – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation SQL SERVER... - [SQLAuthority News - Best SQLAuthority Articles on Other Popular Sites](https://blog.sqlauthority.com/2007/11/03/sqlauthority-news-best-sqlauthority-articles-on-other-popular-sites/): Best SQLAuthority Articles on Other Popular Sites SQL SERVER – UDF vs. Stored Procedures and Having vs. WHERE (SQL Server Magazine) SQL SERVER – Pre-Code Review Tips – Tips For Enforcing Coding Standards (dotnetslackers.com) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Best Downloads on SQLAuthority.com](https://blog.sqlauthority.com/2007/11/02/sqlauthority-news-best-downloads-on-sqlauthoritycom/): Best Downloads on SQLAuthority.com SQL SERVER – Query Analyzer Shortcuts SQL Server Interview Questions and Answers Complete List Download SQL SERVER – Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts) SQL SERVER Database Coding Standards and Guidelines Complete List Download SQL SERVER – Data Warehousing Interview Questions and Answers Complete List Download Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - First Birthday of Blog - 365 Post in One Year](https://blog.sqlauthority.com/2007/11/01/sqlauthority-news-first-birthday-of-blog-365-post-in-one-year/): Hello Everyone, Today is birthday of this blog. Exactly one year ago, I started this journey of SQL Server and today I have reached first mile stone. There are so many great experience I had during this year. One thing I enjoyed the most is My Extremely Knowledgeable and Friendly Readers. I have learned a lot from all my readers, their emails and comments on this blog. You have been wonderful part of this blog. I was very surprised when I counted how many articles I had posted last year. It was perfect 365! One article a day!! Once again, I... - [SQL SERVER - Importance of Master Database for SQL Server Startup](https://blog.sqlauthority.com/2007/10/31/sql-server-importance-of-master-database-for-sql-server-startup/): I have received following questions. I will list all the questions here and answer them together. What is the purpose of Master database? - [SQL SERVER - Business Intelligence (BI) Basic Terms Explanation](https://blog.sqlauthority.com/2007/10/30/sql-server-business-intelligence-bi-basic-terms-explanation/): Business Intelligence Business intelligence is a method of storing and presenting key enterprise data so that anyone in your company can quickly and easily ask questions of accurate and timely data. Effective BI allows end users to use data to understand why your business go the particular results that it did, to decide on courses of action based on past data, and to accurately forecast future results. Data Warehouse A single structure that usually, but not always, consists of one or more cubes. Data Mart A defined subset of a data warehouse, often a single cube from a group. It represents... - [SQL SERVER - Disable All Triggers on a Database - Disable All Triggers on All Servers](https://blog.sqlauthority.com/2007/10/29/sql-server-disable-all-triggers-on-a-database-disable-all-triggers-on-all-servers/): Just a day ago, I received question in email regarding my article SQL SERVER – 2005 Disable Triggers – Drop Triggers. Question : How to disable all the triggers for database? Additionally, how to disable all the triggers for all servers? Answer: Disable all the triggers for a single database: USE AdventureWorks; GO DISABLE TRIGGER Person.uAddress ON AdventureWorks; GO Disable all the triggers for all servers: USE AdventureWorks; GO DISABLE TRIGGER ALL ON ALL SERVER; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL-Triggers - [SQL SERVER - Tell me What You Want to Listen - My 2 TechED 2011 Sessions](https://blog.sqlauthority.com/2011/03/17/sql-server-tell-me-what-you-want-to-listen-my-2-teched-2011-sessions/): I am going to present two sessions at TechEd India on March 25th, 2011. I would like to know what do you want me to cover in this session. Watch the video taken by my wife when I was preparing for the session. Sessions Date: March 25, 2011 Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Date and Time: March 25, 2011 12:00 PM to 01:00 PM SQL Server Waits and Queues – Your Gateway to Perf. Troubleshooting Date and Time: March 25, 2011 04:15 PM to 05:15 PM I promise following for both of my sessions: I will... - [SQLAuthority News - I am Presenting 2 Sessions at TechEd India](https://blog.sqlauthority.com/2011/03/16/sqlauthority-news-i-am-presenting-2-sessions-at-teched-india/): TechED is the event which I am always excited about. It is one of the largest technology in India. Microsoft Tech Ed India 2011 is the premier technical education and networking event for tech professionals interested in learning, connecting and exploring a broad set of current and soon-to-be released Microsoft technologies, tools, platforms and services. I am going to speak at the TechED on two very interesting and advanced subjects. Venue: The LaLiT Ashok Kumara Krupa High Grounds Bangalore – 560001, Karnataka, India Sessions Date: March 25, 2011 Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Date and Time:... - [SQL SERVER - SQLServer Quiz 2011 - Do you know your execution plan - Two questions - One Answer](https://blog.sqlauthority.com/2011/03/15/sql-server-sqlserver-quiz-2011-do-you-know-your-execution-plan-two-questions-one-answer/): My friend Jacob Sebastian has SQL Server Quiz 2011 launched. This time when he asked me to come up with quiz question – I wanted to come up with something which is new and make participant to think about it. After carefully thinking I come with question which I really like to solve myself. Here is the details: 1) Using Single table only Once in Single SELECT statement generate execution plan which have JOIN operator. Explain the reason for the same. 2) Using Single table only Once in Single SELECT statement generate execution plan which have parallelism operator. Explain the reason... - [SQL SERVER - Guest Post - Architecting Data Warehouse - Niraj Bhatt](https://blog.sqlauthority.com/2011/03/14/sql-server-guest-post-architecting-data-warehouse-niraj-bhatt/): Niraj Bhatt works as an Enterprise Architect for a Fortune 500 company and has an innate passion for building / studying software systems. He is a top rated speaker at various technical forums including Tech·Ed, MCT Summit, Developer Summit, and Virtual Tech Days, among others. Having run a successful startup for four years Niraj enjoys working on – IT innovations that can impact an enterprise bottom line, streamlining IT budgets through IT consolidation, architecture and integration of systems, performance tuning, and review of enterprise applications. He has received Microsoft MVP award for ASP.NET, Connected Systems and most recently on Windows Azure.... - [SQL SERVER - Pending IO request in SQL Server - DMV](https://blog.sqlauthority.com/2011/03/13/sql-server-pending-io-request-in-sql-server-dmv/): I received following question: “How do we know how many pending IO requests are there for database files (.mdf, .ldf) individually?” Very interesting question and indeed answer is very interesting as well. Here is the quick script which I use to find the same. It has to be run in the context of the database for which you want to know pending IO statistics. USE DATABASE GO SELECT vfs.database_id, df.name, df.physical_name ,vfs.FILE_ID, ior.io_pending FROM sys.dm_io_pending_io_requests ior INNER JOIN sys.dm_io_virtual_file_stats (DB_ID(), NULL) vfs ON (vfs.file_handle = ior.io_handle) INNER JOIN sys.database_files df ON (df.FILE_ID = vfs.FILE_ID) I keep this script handy as it... - [SQLAuthority News - Download - Microsoft SQL Server Compact 4.0](https://blog.sqlauthority.com/2011/03/12/sqlauthority-news-download-microsoft-sql-server-compact-4-0/): Microsoft SQL Server Compact 4.0 is a free, embedded database that software developers can use for building ASP.NET websites and Windows desktop applications. SQL Server Compact 4.0 has a small footprint and supports private deployment of its binaries within the application folder, easy application development in Visual Studio and WebMatrix, and seamless migration of schema and data to SQL Server. You can download very small file of SQL Server CE from here. Books Online is the primary documentation for SQL Server Compact 4.0. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward... - [SQL SERVER - Finding Latch Statistics](https://blog.sqlauthority.com/2011/03/11/sql-server-finding-latch-statistics/): Last month I wrote SQL Server Wait Types and Queues series SQL SERVER – Summary of Month – Wait Type – Day 28 of 28. I had great fun to write the series. I learned a lot and I felt this has created some deep interest on the subject with others. I recently received very interesting question from one of the reader after reading SQL SERVER – PAGELATCH_DT, PAGELATCH_EX, PAGELATCH_KP, PAGELATCH_SH, PAGELATCH_UP – Wait Type – Day 12 of 28 that if they can know what kind of latches are waiting and what is their count. Absolutely! SQL Server team has... - [SQL SERVER - Sharing your ETL Resources Across Applications with Ease](https://blog.sqlauthority.com/2011/03/10/sql-server-sharing-your-etl-resources-across-applications-with-ease/): Frequently an organization will find that the same resources are used in multiple ETL applications, for example, the same database, general purpose processing logic, or file system locations. Creating an easy way to reuse these resources across multiple applications would increase efficiency and reduce errors. Moreover, not every ETL developer has the same skill set, and it is likely that one developer will be more adept at writing code while another is more comfortable configuring database connections. Real productivity gains will come when these developers are able to work independently while still making their work available to others assigned to the same project. These are the benefits of a centralized version control system. - [SQLAuthority News - Stay Connected and Social Media](https://blog.sqlauthority.com/2011/03/09/sqlauthority-news-stay-connected-and-social-media/): I think I have finally gotten back my faith in social media. If you are following my blog I am sure you are aware of my views on social media – SQLAuthority News – Social Media Confusion – Twitter, FaceBook, LinkedIn and Me. I was not happy about how social media was evolving. Whenever I go to Twitter, LinkedIn or Facebook, I noticed the same updates everywhere. I just thought I was wasting my time doing the same thing everywhere. I strongly believe that there is no dictator on internet. Nobody has authority over others, everybody can express their ideas as... - [SQL SERVER - Difference between COUNT(DISTINCT) vs COUNT(ALL)](https://blog.sqlauthority.com/2011/03/08/sql-server-difference-between-countdistinct-vs-countall/): This blog post is written in response to the T-SQL Tuesday hosted by Jes Schultz Borland. Earlier today, I was presenting a 45-minute session at the Community College about “The Beginning SQL Server Database”. One of the students asked me the following question. What is the difference between COUNT(DISTINCT) vs COUNT(ALL)? I found this question from the student very interesting. He seems to have read the documentation (Book Online) and was then asking me this question. I always carry laptop which has SQL Server installed. I quickly opened it and ran the following script. After looking at the result, I think... - [SQL SERVER - Enable PowerPivot Plugin in Excel](https://blog.sqlauthority.com/2011/03/07/sql-server-enable-powerpivot-plugin-in-excel/): Recently I had interesting experience at one conference. My PowerPivot plugin got disabled and I had no clue how to enable the same. After while, I figured out how to enable the same. Once I got back from the event, I searched online and realize that many other people online are facing the same problem. Here is how I solved the problem. When I started Excel it did not load PowerPivot plugin. I found in option>> Add in the plug in to be disabled. I enabled the plugin and it worked very well. Let us see that with images. Reference: Pinal... - [SQL SERVER - Running Multiple Batch Files Together in Parallel](https://blog.sqlauthority.com/2011/03/06/sql-server-running-multiple-batch-files-together-in-parallel/): Recently I was preparing a demo for my next technical session, I had to do run a SQL code in parallel. I decided to use Batch File to run the code. I am not the best guy to with command shell so I did it with following setup. Code of tsql.sql SELECT 1 ColumnName Code of command.bat sqlcmd -S . -i tsql.sql timeout 100 Code of  AllBatch.bat start cmd.exe /C “command.bat” start cmd.exe /C “command.bat” start cmd.exe /C “command.bat” Now I ran AllBatch.bat and it run all the three files in parallel and simulated my needed scenario. I believe there should... - [SQLAuthority News - Fast Track Data Warehouse 3.0 Reference Guide](https://blog.sqlauthority.com/2011/03/05/sqlauthority-news-fast-track-data-warehouse-3-0-reference-guide/): https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/gg605238(v=msdn.10)?redirectedfrom=MSDN I am very excited that Fast Track Data Warehouse 3.0 reference guide has been announced. As a consultant, I have always enjoyed working with Fast Track Data Warehouse project as it truly expresses the potential of the SQL Server Engine. Here are a few details of the enhancement of the Fast Track Data Warehouse 3.0 reference architecture. - [SQL SERVER - Concurrency Problems and their Relationship with Isolation Level](https://blog.sqlauthority.com/2011/03/04/sql-server-concurrancy-problems-and-their-relationship-with-isolation-level/): Concurrency is simply put capability of the machine to support two or more transactions working with the same data at the same time. This usually comes up with data is being modified, as during the retrieval of the data this is not the issue. Most of the concurrency problems can be avoided by SQL Locks. There are four types of concurrency problems visible in the normal programming. 1)      Lost Update – This problem occurs when there are two transactions involved and both are unaware of each other. The transaction which occurs later overwrites the transactions created by the earlier update. 2)     ... - [SQL SERVER - Demo Script - Keeping CPU Busy](https://blog.sqlauthority.com/2011/03/03/sql-server-demo-script-keeping-cpu-busy/): Recently face very interesting situation, during presentations at event, I was asked very famous questions: “My CPU is very high all the time, how can I reduce it?” This is very interesting question and there are many answers and a single blog post is not good enough to justify this subject. I presented few situation to the person who asked the question. The member of the audience who asked question came to me afterwords and asked me few detailed questions. To answer him, I quickly wrote query which simulate high CPU. Here is the script which I wrote which increased CPU... - [SQLAuthority News - Uncut and Unedited Video Interview of Pinal Dave](https://blog.sqlauthority.com/2011/03/02/sqlauthority-news-uncut-and-unedited-video-interview-of-pinal-dave/): Earlier this year Lohith (@kashyapa) from Bangalore took my ‘Uncut and Unedited’ video interview. It was really fun to answer his questions as it was very different from regular interview. He asked few personal details few technical details and made me show few secrets. [youtube=http://www.youtube.com/watch?v=k3yLkPt2LIc] I think if you want to see me Uncut and Unedited I urge you to watch the video. He has previously interviewed few celebrities as well. I think I am the only one in the list who is not celebrity. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Pinal Dave: Blogger, MVP and now Interviewee by Michael J Swart](https://blog.sqlauthority.com/2011/03/01/sqlauthority-news-pinal-dave-blogger-mvp-and-now-interviewee-by-michael-j-swart/): Michael J. Swart is a very unique person. I have often exchanged emails with him and also used a couple of his scripts in my presentations (with his permission). Every time I conduct spatial database presentation, I always start with his script where he has drawn the wonderful image of Botticelli’s Birth of Venus. I often think he is more of a creative artist than IT professional. However, if you read his blog posts and articles, they are top notch and each article is as creative as his caricatures. He is wonderful, inspiring, creative and most importantly, very humble. He recently... - [SQL SERVER - Summary of Month - Wait Stats and Wait Type - Day 28 of 28](https://blog.sqlauthority.com/2011/02/28/sql-server-summary-of-month-wait-type-day-28-of-28/): I am glad to announce that the month of Wait Types, Wait Stats and Queues is very successful. I am glad that it was very well received and there was a great amount of participation from the community. - [SQL SERVER - Best Reference - Wait Type - Day 27 of 28](https://blog.sqlauthority.com/2011/02/27/sql-server-best-reference-wait-type-day-27-of-28/): I have great learning experience to write my article series on Extended Event. This was truly learning experience where I have learned way more than I would have learned otherwise. Besides my blog series there was excellent quality reference available on internet which one can use to learn this subject further. Here is the list of resources (in no particular order): sys.dm_os_wait_stats (Book OnLine) – This is excellent beginning point and official documentations on the wait types description. SQL Server Best Practices Article by Tom Davidson – I think this document goes without saying the BEST reference available on this subject.... - [SQL SERVER - Guest Post - Glenn Berry - Wait Type - Day 26 of 28](https://blog.sqlauthority.com/2011/02/26/sql-server-guest-post-glenn-berry-wait-type-day-26-of-28/): Glenn Berry works as a Database Architect at NewsGator Technologies in Denver, CO. He is a SQL Server MVP, and has a whole collection of Microsoft certifications, including MCITP, MCDBA, MCSE, MCSD, MCAD, and MCTS. He is also an Adjunct Faculty member at University College – University of Denver, where he has been teaching since 2000. He is one wonderful blogger and often blogs at here. I am big fan of the Dynamic Management Views (DMV) scripts of Glenn. His script are extremely popular and the reality is that he has inspired me to start this series with his famous DMV... - [SQL SERVER - 2011 - Wait Type - Day 25 of 28](https://blog.sqlauthority.com/2011/02/25/sql-server-2011-wait-type-day-25-of-28/): Since the beginning of the series, I have been getting the following question again and again: “What are the changes in SQL Server 2011 – Denali with respect to Wait Types?” SQL Server 2011 – Denali is yet to be released, and making statements on the subject will be inappropriate. Denali CTP1 has been released so I suggest that all of you download the same and experiment on it. I quickly compared the wait stats of SQL Server 2008 R2 and Denali (CTP1) and found the following changes: Wait Types Exists in SQL Server 2008 R2 and Not Exists in SQL... - [SQL SERVER - 2000 - DBCC SQLPERF(waitstats) - Wait Type - Day 24 of 28](https://blog.sqlauthority.com/2011/02/24/sql-server-2000-dbcc-sqlperfwaitstats-wait-type-day-24-of-28/): I have received many comments, email, suggestions and motivations for my current series of wait types and wait statistics. One of the questions which I keep on receiving almost every other day is whether all of the discussions I have presented so far are also applicable to SQL Server 2000. Additionally, I receive another question asking me if wait statistics matters in SQL Server 2000. If it is, then the asker wants to know how to measure wait types for SQL Server 2000. In SQL Server, you can run the following command to get a list of all the wait types:... - [SQL SERVER - OLEDB - Link Server - Wait Type - Day 23 of 28](https://blog.sqlauthority.com/2011/02/23/sql-server-oledb-link-server-wait-type-day-23-of-28/): When I decided to start writing about this wait type, the very first question that came to my mind was, “What does ‘OLEDB’ stand for?” A quick search on Wikipedia tells me that OLEDB means Object Linking and Embedding Database. (How many of you knew this?) Anyway, I found it very interesting that this wait type was in one of the top 10 wait types in many of the systems I have come across in my performance tuning experience. Books On-Line: OLEDB occurs when SQL Server calls the SQL Server Native Client OLE DB Provider. This wait type is not used... - [SQL SERVER - Guest Post - Jacob Sebastian - Filestream - Wait Types - Wait Queues - Day 22 of 28](https://blog.sqlauthority.com/2011/02/22/sql-server-filestream-wait-types-wait-queues-day-22-of-28/): Jacob Sebastian is a SQL Server MVP, Author, Speaker and Trainer. Jacob is one of the top rated expert community. Jacob wrote the book The Art of XSD – SQL Server XML Schema Collections and wrote the XML Chapter in SQL Server 2008 Bible. See his Blog | Profile. He is currently researching on the subject of Filestream and have submitted this interesting article on the very subject. What is FILESTREAM? FILESTREAM is a new feature introduced in SQL Server 2008 which provides an efficient storage and management option for BLOB data. Many applications that deal with BLOB data today stores... - [SQL SERVER - Guest Posts - Feodor Georgiev - The Context of Our Database Environment - Going Beyond the Internal SQL Server Waits - Wait Type - Day 21 of 28](https://blog.sqlauthority.com/2011/02/21/sql-server-the-context-of-our-database-environment-going-beyond-the-internal-sql-server-waits-wait-type-day-21-of-28/): This guest post is submitted by Feodor. Feodor Georgiev is a SQL Server database specialist with extensive experience of thinking both within and outside the box. He has wide experience of different systems and solutions in the fields of architecture, scalability, performance, etc. Feodor has experience with SQL Server 2000 and later versions, and is certified in SQL Server 2008. In this article Feodor explains the server-client-server process, and concentrated on the mutual waits between client and SQL Server. This is essential in grasping the concept of waits in a ‘global’ application plan. Recently I was asked to write a blog... - [SQL SERVER - MSQL_XP - Wait Type - Day 20 of 28](https://blog.sqlauthority.com/2011/02/20/sql-server-msql_xp-wait-type-day-20-of-28/): In this blog post, I am going to discuss something from my field experience. While consultation, I have seen various wait typed, but one of my customers who has been using SQL Server for all his operations had an interesting issue with a particular wait type. Our customer had more than 100+ SQL Server instances running and the whole server had MSSQL_XP wait type as the most number of wait types. While running sp_who2 and other diagnosis queries, I could not immediately figure out what the issue was because the query with that kind of wait type was nowhere to be... - [SQL SERVER - PREEMPTIVE and Non-PREEMPTIVE - Wait Type - Day 19 of 28](https://blog.sqlauthority.com/2011/02/19/sql-server-preemptive-and-non-preemptive-wait-type-day-19-of-28/): In this blog post, we are going to talk about a very interesting subject. I often get questions related to SQL Server 2008 Book-Online about various Preemptive wait types. I got a few questions asking what these wait types are and how they could be interpreted. To get current wait types of the system, you can read this article and run the script: SQL SERVER – DMV – sys.dm_os_waiting_tasks and sys.dm_exec_requests – Wait Type – Day 4 of 28. Before we continue understanding them, let us study first what PREEMPTIVE and Non-PREEMPTIVE waits in SQL Server mean. PREEMPTIVE: Simply put, this wait... - [SQL SERVER - LOGBUFFER - Wait Type - Day 18 of 28](https://blog.sqlauthority.com/2011/02/18/sql-server-logbuffer-wait-type-day-18-of-28/): At first, I was not planning to write about this wait type. The reason was simple- I have faced this only once in my lifetime so far maybe because it is one of the top 5 wait types. I am not sure if it is a common wait type or not, but in the samples I had it really looks rare to me. From Book On-Line: LOGBUFFER Occurs when a task is waiting for space in the log buffer to store a log record. Consistently high values may indicate that the log devices cannot keep up with the amount of log... - [SQL SERVER - Introduction to Adaptive ETL Tool - How adaptive is your ETL?](https://blog.sqlauthority.com/2011/02/17/sql-server-introduction-to-adaptive-etl-tool-how-adaptive-is-your-etl/): I am often reminded by the fact that BI/data warehousing infrastructure is very brittle and not very adaptive to change. There are lots of basic use cases where data needs to be frequently loaded into SQL Server or another database. What I have found is that as long as the sources and targets stay the same, SSIS or any other ETL tool for that matter does a pretty good job handling these types of scenarios. But what happens when you are faced with more challenging scenarios, where the data formats and possibly the data types of the source data are changing from... - [SQL SERVER - WRITELOG - Wait Type - Day 17 of 28](https://blog.sqlauthority.com/2011/02/17/sql-server-writelog-wait-type-day-17-of-28/): WRITELOG is one of the most interesting wait types. So far we have seen a lot of different wait types, but this log type is associated with log file which makes it interesting to deal with. - [SQL SERVER - Guest Post - Jonathan Kehayias - Wait Type - Day 16 of 28](https://blog.sqlauthority.com/2011/02/16/sql-server-guest-post-jonathan-kehayias-wait-type-day-16-of-28/): Jonathan Kehayias (Blog | Twitter) is a MCITP Database Administrator and Developer, who got started in SQL Server in 2004 as a database developer and report writer in the natural gas industry. After spending two and a half years working in TSQL, in late 2006, he transitioned to the role of SQL Database Administrator. His primary passion is performance tuning, where he frequently rewrites queries for better performance and performs in depth analysis of index implementation and usage. Jonathan blogs regularly on SQLBlog, and was a coauthor of Professional SQL Server 2008 Internals and Troubleshooting. On a personal note, I think... - [SQL SERVER - LCK_M_XXX - Wait Type - Day 15 of 28](https://blog.sqlauthority.com/2011/02/15/sql-server-lck_m_xxx-wait-type-day-15-of-28/): Locking is a mechanism used by the SQL Server Database Engine to synchronize access by multiple users to the same piece of data, at the same time. In simpler words, it maintains the integrity of data by protecting (or preventing) access to the database object. From Book On-Line: LCK_M_BU Occurs when a task is waiting to acquire a Bulk Update (BU) lock. LCK_M_IS Occurs when a task is waiting to acquire an Intent Shared (IS) lock. LCK_M_IU Occurs when a task is waiting to acquire an Intent Update (IU) lock. LCK_M_IX Occurs when a task is waiting to acquire an Intent... - [SQL SERVER - BACKUPIO, BACKUPBUFFER - Wait Type - Day 14 of 28](https://blog.sqlauthority.com/2011/02/14/sql-server-backupio-backupbuffer-wait-type-day-14-of-28/): Backup is the most important task for any database admin. Your data is at risk if you are not performing database backup. Honestly, I have seen many DBAs who know how to take backups but do not know how to restore it. (Sigh!) In this blog post we are going to discuss about one of my real experiences with one of my clients – BACKUPIO. When I started to deal with it, I really had no idea how to fix the issue. However, after fixing it at two places, I think I know why this is happening but at the same... - [SQL SERVER - FT_IFTS_SCHEDULER_IDLE_WAIT - Full Text - Wait Type - Day 13 of 28](https://blog.sqlauthority.com/2011/02/13/sql-server-ft_ifts_scheduler_idle_wait-full-text-wait-type-day-13-of-28/): In the last few days during this series, I got many question about this Wait type. It would be great if you read my original related wait stats query in the first post because I have filtered it out in WHERE clause. However, I still get questions about this being one of the most wait types they encounter. The truth is, this is a background task processing and it really does not matter and it should be filtered out. There are many new Wait types related to Full Text Search that are introduced in SQL Server 2008. If you run the... - [SQL SERVER - PAGELATCH_DT, PAGELATCH_EX, PAGELATCH_KP, PAGELATCH_SH, PAGELATCH_UP - Wait Type - Day 12 of 28](https://blog.sqlauthority.com/2011/02/12/sql-server-pagelatch_dt-pagelatch_ex-pagelatch_kp-pagelatch_sh-pagelatch_up-wait-type-day-12-of-28/): This is another common wait type. However, I still frequently see people getting confused with PAGEIOLATCH_X and PAGELATCH_X wait types. Actually, there is a big difference between the two. PAGEIOLATCH is related to IO issues, while PAGELATCH is not related to IO issues but is oftentimes linked to a buffer issue. Before we delve deeper in this interesting topic, first let us understand what Latch is. Latches are internal SQL Server locks which can be described as very lightweight and short-term synchronization objects. Latches are not primarily to protect pages being read from disk into memory. It’s a synchronization object for... - [SQL SERVER - ASYNC_IO_COMPLETION - Wait Type - Day 11 of 28](https://blog.sqlauthority.com/2011/02/11/sql-server-async_io_completion-wait-type-day-11-of-28/): For any good system three things are vital: CPU, Memory and IO (disk). Among these three, IO is the most crucial factor of SQL Server. Looking at real-world cases, I do not see IT people upgrading CPU and Memory frequently. However, the disk is often upgraded for either improving the space, speed or throughput. Today we will look at another IO-related wait type. From Book On-Line: Occurs when a task is waiting for I/Os to finish. ASYNC_IO_COMPLETION Explanation: Any tasks are waiting for I/O to finish. If by any means your application that’s connected to SQL Server is processing the data... - [SQL SERVER - IO_COMPLETION - Wait Type - Day 10 of 28](https://blog.sqlauthority.com/2011/02/10/sql-server-io_completion-wait-type-day-10-of-28/): For any good system three things are vital: CPU, Memory and IO (disk). Among these three, IO is the most crucial factor of SQL Server. Looking at real-world cases, I do not see IT people upgrading CPU and Memory frequently. However, the disk is often upgraded for either improving the space, speed or throughput. Today we will look at an IO-related wait types. From Book On-Line: Occurs while waiting for I/O operations to complete. This wait type generally represents non-data page I/Os. Data page I/O completion waits appear as PAGEIOLATCH_* waits. IO_COMPLETION Explanation: Any tasks are waiting for I/O to finish.... - [SQLAuthority News - DotNET Challenge of Sorting Generic List](https://blog.sqlauthority.com/2011/02/10/sqlauthority-news-dotnet-challenge-of-sorting-generic-list/): This is a quick announcement of .NET challenge posted by Nupur Dave. She has asked very interesting question. If you are interested in learning .NET and winning iPAD by Red-Gate. I strongly suggest that all of you should attempt the quiz. Here is the question: How to insert an item in sorted generic list such that after insertion list would be sorted? You can visit .NET Challenge to answer the question. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - PAGEIOLATCH_DT, PAGEIOLATCH_EX, PAGEIOLATCH_KP, PAGEIOLATCH_SH, PAGEIOLATCH_UP - Wait Type - Day 9 of 28](https://blog.sqlauthority.com/2011/02/09/sql-server-pageiolatch_dt-pageiolatch_ex-pageiolatch_kp-pageiolatch_sh-pageiolatch_up-wait-type-day-9-of-28/): It is very easy to say that you replace your hardware as that is not up to the mark. In reality, it is very difficult to implement. It is really hard to convince an infrastructure team to change any hardware because they are not performing at their best. I had a nightmare related to this issue in a deal with an infrastructure team as I suggested that they replace their faulty hardware. This is because they were initially not accepting the fact that it is the fault of their hardware. But it is really easy to say “Trust me, I am... - [SQL SERVER - SOS_SCHEDULER_YIELD - Wait Type - Day 8 of 28](https://blog.sqlauthority.com/2011/02/08/sql-server-sos_scheduler_yield-wait-type-day-8-of-28/): This is a very interesting wait type and quite often seen as one of the top wait types. Let us discuss this today. From Book On-Line: Occurs when a task voluntarily yields the scheduler for other tasks to execute. During this wait the task is waiting for its quantum to be renewed. SOS_SCHEDULER_YIELD Explanation: SQL Server has multiple threads, and the basic working methodology for SQL Server is that SQL Server does not let any “runnable” thread to starve. Now let us assume SQL Server OS is very busy running threads on all the scheduler. There are always new threads coming... - [SQL SERVER - Automation Process Good or Ugly](https://blog.sqlauthority.com/2011/02/08/sql-server-automation-process-good-or-ugly/): This blog post is written in response to T-SQL Tuesday hosted by SQL Server Insane Asylum. The idea of this post really caught my attention. Automation – something getting itself done after the initial programming, is my understanding of the subject. The very next thought was – is it good or evil? The reality is there is no right answer. However, what if we quickly note a few things, then I would like to request your help to complete this post. We will start with the positive parts in SQL Server where automation happens. The Good If I start thinking of... - [SQL SERVER - CXPACKET - Parallelism - Advanced Solution - Wait Type - Day 7 of 28](https://blog.sqlauthority.com/2011/02/07/sql-server-cxpacket-parallelism-advanced-solution-wait-type-day-7-of-28/): Earlier we discussed about the what is the common solution to solve the issue with CXPACKET wait time. Today I am going to talk about few of the other suggestions which can help to reduce the CXPACKET wait. If you are going to suggest that I should focus on MAXDOP and COST THRESHOLD – I totally agree. I have covered them in details in yesterday’s blog post. Today we are going to discuss few other way CXPACKET can be reduced. Potential Reasons: If data is heavily skewed, there are chances that query optimizer may estimate the correct amount of the data... - [SQLAuthority News - Presenting at Virtual Tech Days TechEd Pre-Con - February 9, 2011](https://blog.sqlauthority.com/2011/02/07/sqlauthority-news-presenting-at-virtual-tech-days-teched-pre-con-february-9-2011/): I will be presenting on following subject on Virtual Tech Days TechEd Pre-Con – February 9, 2011. Auditing Made Easy: Change Tracking and Change Data Capture Date and Time: February 9, 2011 11:45am-12:45pm Location: Online In this fast paced demo oriented session we will go over few of concept which are related to real life problem at customers. We often see developers and DBA looking for details like who has dropped the table, who has last modified any object as well what was actually modified. SQL Server 2008 has all the answers. It has various new methods for Auditing where not... - [SQL SERVER - CXPACKET - Parallelism - Usual Solution - Wait Type - Day 6 of 28](https://blog.sqlauthority.com/2011/02/06/sql-server-cxpacket-parallelism-usual-solution-wait-type-day-6-of-28/): CXPACKET has to be most popular one of all wait stats. I have commonly seen this wait stat as one of the top 5 wait stats in most of the systems with more than one CPU. Books On-Line: Occurs when trying to synchronize the query processor exchange iterator. You may consider lowering the degree of parallelism if contention on this wait type becomes a problem. CXPACKET Explanation: When a parallel operation is created for SQL Query, there are multiple threads for a single query. Each query deals with a different set of the data (or rows). Due to some reasons, one... - [SQL SERVER - Capturing Wait Types and Wait Stats Information at Interval - Wait Type - Day 5 of 28](https://blog.sqlauthority.com/2011/02/05/sql-server-capturing-wait-types-and-wait-stats-information-at-interval-wait-type-day-5-of-28/): Earlier, I have tried to cover some important points about wait stats in detail. Here are some points that we had covered earlier. DMV related to wait stats reset when we reset SQL Server services DMV related to wait stats reset when we manually reset the wait types However, at times, there is a need of making this data persistent so that we can take a look at them later on. Sometimes, performance tuning experts do some modifications to the server and try to measure the wait stats at that point of time and after some duration. I use the following... - [SQL SERVER - DMV - sys.dm_os_waiting_tasks and sys.dm_exec_requests - Wait Type - Day 4 of 28](https://blog.sqlauthority.com/2011/02/04/sql-server-dmv-sys-dm_os_waiting_tasks-and-sys-dm_exec_requests-wait-type-day-4-of-28/): Previously, we covered the DMV sys.dm_os_wait_stats, and also saw how it can be useful to identify the major resource bottleneck. However, at the same time, we discussed that this is only useful when we are looking at an instance-level picture. Quite often we want to know about the processes going in our server at the given instant. Here is the query for the same. This DMV is written taking the following into consideration: we want to analyze the queries that are currently running or which have recently ran and their plan is still in the cache. SELECT dm_ws.wait_duration_ms, dm_ws.wait_type, dm_es.status, dm_t.TEXT, dm_qp.query_plan,... - [SQL SERVER - DMV - sys.dm_os_wait_stats Explanation - Wait Type - Day 3 of 28](https://blog.sqlauthority.com/2011/02/03/sql-server-dmv-sys-dm_os_wait_stats-explanation-wait-type-day-3-of-28/): The key Dynamic Management View (DMV) that helps us to understand wait stats is sys.dm_os_wait_stats; this DMV gives us all the information that we need to know regarding wait stats. However, the interpretation is left to us. This is a challenge as understanding wait stats can often be quite tricky. Anyway, we will cover few wait stats in one of the future articles. Today we will go over the basic understanding of the DMV. The Official Book OnLine Reference for DMV is over here: sys.dm_os_wait_stats. I suggest you all to refer this for all the accuracy. Following is a statement from the online book: “Specific... - [SQL SERVER - Signal Wait Time Introduction with Simple Example - Wait Type - Day 2 of 28](https://blog.sqlauthority.com/2011/02/02/sql-server-signal-wait-time-introduction-with-simple-example-day-2-of-28/): In this post, let’s delve a bit more in depth regarding wait stats. The very first question: when do the wait stats occur? Here is the simple answer. When SQL Server is executing any task, and if for any reason it has to wait for resources to execute the task, this wait is recorded by SQL Server with the reason for the delay. Later on we can analyze these wait stats to understand the reason the task was delayed and maybe we can eliminate the wait for SQL Server. It is not always possible to remove the wait type 100%, but there are... - [SQL SERVER - Wait Stats - Wait Types - Wait Queues - Day 0 of 28](https://blog.sqlauthority.com/2011/02/01/sql-server-wait-stats-wait-types-wait-queues-day-0-of-28-2/): This blog post will have running account of the all the blog post I will be doing in this month related to SQL Server Wait Types and Wait Queues. SQL SERVER – Introduction to Wait Stats and Wait Types – Wait Type – Day 1 of 28 SQL SERVER – Signal Wait Time Introduction with Simple Example – Wait Type – Day 2 of 28 SQL SERVER – DMV – sys.dm_os_wait_stats Explanation – Wait Type – Day 3 of 28 SQL SERVER – DMV – sys.dm_os_waiting_tasks and sys.dm_exec_requests – Wait Type – Day 4 of 28 SQL SERVER – Capturing Wait Types and Wait Stats... - [SQL SERVER - Introduction to Wait Stats and Wait Types - Wait Type - Day 1 of 28](https://blog.sqlauthority.com/2011/02/01/sql-server-introduction-to-wait-stats-and-wait-types-wait-type-day-1-of-28/): I have been working a lot on Wait Stats and Wait Types recently. Last Year, I requested blog readers to send me their respective server’s wait stats. I appreciate their kind response as I have received  Wait stats from my readers. I took each of the results and carefully analyzed them. I provided necessary feedback to the person who sent me his wait stats and wait types. Based on the feedbacks I got, many of the readers have tuned their server. After a while I got further feedbacks on my recommendations and again, I collected wait stats. I recorded the wait stats and my recommendations and did... - [SQL SERVER - What is Fill Factor and What is the Best Value for Fill Factor](https://blog.sqlauthority.com/2011/01/31/sql-server-what-is-fill-factor-and-what-is-the-best-value-for-fill-factor/): Working in performance tuning area, one has to know about Index and Index Maintenance. For any Index the most important property is Fill Factor. Fill factor is the value that determines the percentage of space on each leaf-level page to be filled with data. In an SQL Server, the smallest unit is a page, which is made of  Page with size 8K. Every page can store one or more rows based on the size of the row. The default value of the Fill Factor is 100, which is same as value 0. The default Fill Factor (100 or 0) will allow... - [SQL SERVER - Denali - SEQUENCE is not IDENTITY](https://blog.sqlauthority.com/2011/01/30/sql-server-2011-sequence-is-not-identity/): Yesterday I posted blog post on the subject SQL SERVER – 2011 – Introduction to SEQUENCE – Simple Example of SEQUENCE and I received comment where user was not clear about difference between SEQUENCE and IDENTITY. The reality is that SEQUENCE not like IDENTITY. There is very clear difference between them. Identity is about single column. Sequence is always incrementing and it is not dependent on any table. Here is the quick example of the same. USE AdventureWorks2008R2 GO CREATE SEQUENCE [Seq] AS [int] START WITH 1 INCREMENT BY 1 MAXVALUE 20000 GO -- Run five times SELECT NEXT VALUE FOR... - [SQL SERVER - Denali - Introduction to SEQUENCE - Simple Example of SEQUENCE](https://blog.sqlauthority.com/2011/01/29/sql-server-2011-introduction-to-sequence-simple-example-of-sequence/): SQL Server 2011 will contain one of the very interesting feature called SEQUENCE. I have waited for this feature for really long time. I am glad it is here finally. SEQUENCE allows you to define a single point of repository where SQL Server will maintain in memory counter. USE AdventureWorks2008R2 GO CREATE SEQUENCE [Seq] AS [int] START WITH 1 INCREMENT BY 1 MAXVALUE 20000 GO SEQUENCE is very interesting concept and I will write few blog post on this subject in future. Today we will see only working example of the same. Let us create a sequence. We can specify various... - [SQLAuthority News - Deployment guide for Microsoft SharePoint Foundation 2010](https://blog.sqlauthority.com/2011/01/28/sqlauthority-news-deployment-guide-for-microsoft-sharepoint-foundation-2010/): SharePoint and SQL Server both goes together – hands to hand. SharePoint installation is very interesting. At various organizations, the installation is very different and have various needs. SQL Server installation with SharePoint is equally important and I have often seen that it is being neglected. Microsoft has published the Deployment Guide for SharePoint Foundation. It talks about various database aspects as well. For optimal sharepoint installation the required version of SQL Server, including service packs and cumulative updates must be installed on the database server. The installation must include any additional features, such as SQL Analysis Services, and the appropriate... - [SQL SERVER - What is a Technology Evangelist?](https://blog.sqlauthority.com/2011/01/27/sql-server-what-is-a-technology-evangelist/): When you hear that someone is an “evangelist” the first thing that might pop into your mind is the Christian church.  In fact, the term did come from Christianity, and basically means someone who spreads the news about their faith.  In the technology world, the same definition is true. Technology evangelists are individuals who, professionally or in their spare time, spread the news about the latest new products.  Sounds like a salesperson, right?  No they are absolutely different. Salespeople also keep up to date with a large number of people, and like to convince others to buy their product – and... - [SQL SERVER - Reducing Page Contention on TempDB](https://blog.sqlauthority.com/2011/01/26/sql-server-reducing-page-contention-on-tempdb/): I have recently received following email asking about how to reduce page contention on TempDB. "We are using Trace Flag 1118 to reduce the tempDB contention on our servers (2000 and 2005). What is your opinion? We have read lots of material, would you please answer me in single line." - [SQL SERVER - Denali - Clipboard Ring - CTRL+SHIFT+V](https://blog.sqlauthority.com/2011/01/25/sql-server-2011-clipboard-ring-ctrlshiftv/): While I was writing my earlier post SQL SERVER – 2011 – Multi-Monitor SSMS Windows, I found out that there is one more similar feature which existed in Visual Studio is also now part of SQL Server 2011 (Denali). The feature is called clipboard ring feature. This is how it works. Select Multiple object one by one using regular CTRL + X. Now instead of pasting using CTRL+V use CTRL+SHIFT+V. Well, you will see that that pasted value is rotating based on what you have earlier selected in CTRL+V. I was really happy as I think this is one of the feature... - [SQL SERVER - Denali - Multi-Monitor SSMS Windows](https://blog.sqlauthority.com/2011/01/24/sql-server-2011-multi-monitor-ssms-windows/): I have a dual screen arrangement at my home system. I love it because it’s very convenient. When I am working with SQL Server 2008 R2 or any earlier versions, I would want to use both of the Monitor so I open two separate SQL Server Management Studio and work along with it. I have no complaints with my system, at all. I am totally fine with it. However, sometimes I face small issues, like when I just want a small code open in a separate window but I do not want the windows to take over the whole of another window.... - [SQLAuthority News - Download Whitepaper - Enabling and Securing Data Entry with Analysis Services Writeback](https://blog.sqlauthority.com/2011/01/23/sqlauthority-news-download-whitepaper-enabling-and-securing-data-entry-with-analysis-services-writeback/): SQL Server Analysis Service have many features which are commonly requested and many already exists in the system. Security Data Entry is very important feature and SSAS supports writeback feature.  Analysis Services is a tool for aggregating information and providing business users with the ability to analyze and support decision making in their business. By using the built-in writeback feature in Analysis Services, business users can also modify their data points to perform what-if analysis or supplement any existing data. The techniques described in this article derive from the author’s professional experience in the design and development of complex financial analysis applications used... - [SQL SERVER- Differences Between Left Join and Left Outer Join](https://blog.sqlauthority.com/2011/01/22/sql-server-differences-between-left-join-and-left-outer-join/): There are a few questions that I had decided not to discuss on this blog because I think they are very simple and many of us know it. Many times, I even receive not-so positive notes from several readers when I am writing something simple. However, assuming that we know all and beginners should know everything is not the right attitude. Since day 1, I have been keeping a small journal regarding questions that I receive in this blog. There are around 200+ questions I receive every day through emails, comments and occasional phone calls. Yesterday, I received a comment with... - [SQLAuthority News - 1600 Blog Post Articles - A Milestone](https://blog.sqlauthority.com/2011/01/21/sqlauthority-news-1600-blog-post-articles-a-milestone/): It was really a very interesting moment for me when I was writing my 1600th milestone blog post. Now it`s a lot more exciting because this time it`s my 1600th blog post. Every time I write a milestone blog post such as this, I have the same excitement as when I was writing my very first blog post. Today I want to write about a few statistics of the blog. Statistics I am frequently asked about my blog stats, so I have already published my blog stats which are measured by WordPress.com. Currently, I have more than 22 Million+ Views on... - [SQLAuthority News - Scaling Up Your Data Warehouse with SQL Server 2008 R2](https://blog.sqlauthority.com/2011/01/20/sqlauthority-news-scaling-up-your-data-warehouse-with-sql-server-2008-r2/): Data Warehouses are suppose to be containing huge amount of the data from the beginning. However, there are cases when too big is not enough. Every Data Warehouse Admin will agree that they have faced situation where they will need to scale up their data warehouse. Microsoft has released white paper discussing the same. Here is the abstract from the Microsoft Official site: SQL Server 2008 introduced many new functional and performance improvements for data warehousing, and SQL Server 2008 R2 includes all these and more. This paper discusses how to use SQL Server 2008 R2 to get great performance as your... - [SQL SERVER - Shrinking Database is Bad - Increases Fragmentation - Reduces Performance](https://blog.sqlauthority.com/2011/01/19/sql-server-shrinking-database-is-bad-increases-fragmentation-reduces-performance/): Earlier, I had written two articles related to Shrinking Database. I wrote about why Shrinking Database is not good. - [SQL SERVER - 4 Tips for ETL Software IDE Developers](https://blog.sqlauthority.com/2011/01/18/sql-server-4-tips-for-etl-software-ide-developers/): In a previous blog, I introduced the notion of Semantic Types. To an end-user, a seamlessly integrated semantic typing engine significantly increases the ease of use of an ETL IDE (integrated development environment, or developer studio). This led me to think about other ease-of-use issues I have encountered while building ETL applications. When I get stumped while programming, I find myself asking the variations on these questions: “How do I…?” “Now what?” “Why isn’t this working?” “Why do I have to redo the work I just did?” It seems to me that a good ETL IDE will anticipate these questions and seek... - [SQL SERVER - A Funny Cartoon on Index](https://blog.sqlauthority.com/2011/01/17/sql-server-a-funny-cartoon-on-index/): Performance Tuning has been my favorite subject and I have done it for many years now. Today I will list one of the most common conversations about Index I have heard in my life. Let us see a funny cartoon on the Index and Performance Tuning. - [SQLAuthority News - Whitepaper Download - Using Star Join and Few-Outer-Row Optimizations to Improve Data Warehousing Queries](https://blog.sqlauthority.com/2011/01/16/sqlauthority-news-whitepaper-download-using-star-join-and-few-outer-row-optimizations-to-improve-data-warehousing-queries/): Size of the database is growing every day. Many organizations now a days have more than TB of the Data in their system. Performance is always part of the issue. Microsoft is really paying attention to the same and also focusing on improving performance for Data Warehousing. Microsoft has recently released whitepaper on the performance tuning subject of Data Warehousing. Here is the abstract about the whitepaper from official site: In this white paper we discuss two of the new features introduced in SQL Server 2008, Star Join and Few-Outer-Row optimizations. These two features are in SQL Server 2008 R2 as... - [SQLAuthority News - Best Practices for Data Warehousing with SQL Server 2008 R2](https://blog.sqlauthority.com/2011/01/15/sqlauthority-news-best-practices-for-data-warehousing-with-sql-server-2008-r2/): An integral part of any BI system is the data warehouse—a central repository of data that is regularly refreshed from the source systems. The new data is transferred at regular intervals  by extract, transform, and load (ETL) processes. This whitepaper talks about what are best practices for Data Warehousing. This whitepaper discusses ETL, Analysis, Reporting as well relational database. The main focus of this whitepaper is on mainly ‘architecture’ and ‘performance’. Download Best Practices for Data Warehousing with SQL Server 2008 R2 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Quick Look at SQL Server Configuration for Performance Indications](https://blog.sqlauthority.com/2011/01/14/sql-server-quick-look-at-sql-server-configuration-for-performance-indications/): Earlier I wrote SQL SERVER – Beginning SQL Server: One Step at a Time – SQL Server Magazine. That was the first article on the series of my real world experience of Performance Tuning experience. I have written second part the same series over here. Read second part over here: Quick Look at SQL Server Configuration for Performance Indications.[Articles are relocated so links are disabled] In this second part I talk about two types of my clients. 1) Those who want instant results 2) Those who want the right results It is really fun to work with both the clients. I talk... - [SQL SERVER - A Quick Note on DB_ID() and DB_NAME() - Get Current Database ID - Get Current Database Name](https://blog.sqlauthority.com/2011/01/13/sql-server-a-quick-note-on-db_id-and-db_name-get-current-database-id-get-current-database-name/): Quite often a simple things makes experienced DBA to look for simple thing. Here are few things which I used to get confused couple of years ago. Now I know it well and have no issue but recently I see one of the DBA getting confused when looking at the DBID from one of the DMV and not able to related that directly to Database Name. -- Get Current DatabaseID SELECT DB_ID() DatabaseID; -- Get Current DatabaseName SELECT DB_NAME() DatabaseName; -- Get DatabaseName from DatabaseID SELECT DB_NAME(4) DatabaseName; -- Get DatabaseID from DatabaseName SELECT DB_ID('tempdb') DatabaseID; -- Get all DatabaseName and... - [SQLAuthority News - Download SQL Server 2008 R2 Upgrade Technical Reference Guide](https://blog.sqlauthority.com/2011/01/12/sqlauthority-news-download-sql-server-2008-r2-upgrade-technical-reference-guide/): I recently come across very interesting white paper written for Microsoft by Solid Quality Mentors. A successful upgrade to SQL Server 2008 R2 should be smooth and trouble-free. To do that smooth transition, you must plan sufficiently for the upgrade and match the complexity of your database application. Otherwise, you risk costly and stressful errors and upgrade problems. SQL Server 2008 R2 Upgrade Technical Reference Guide is one of the best and comprehensive reference guide I have seen on the subject of SQL Server 2008 R2 upgrade. There are so many various subjects discussed about upgrade which one would always wanted... - [SQL SERVER - Performance Tuning Resolution](https://blog.sqlauthority.com/2011/01/11/sql-server-performance-tuning-resolution/): This blog post is written in response to T-SQL Tuesday hosted by MidnightDBAs. Taking resolutions is such an interesting subject. I think just like records, these are broken way more often. I find this is the funniest thing as we all take resolutions every year but not every year, we can manage to keep them. Well, does it mean we should not take resolutions? In fact I support resolutions. Every year, I take a resolution that I will strive reduce my body weight and I usually manage to keep eating healthy till the end of January. When February begins, I begin... - [SQLAuthority News - Free Trip on SQL Cruise](https://blog.sqlauthority.com/2011/01/10/sqlauthority-news-free-trip-on-sql-cruise/): Everybody wants to go cruising.  I want to relax in a cruise as well, of course! (Anybody who wants to be my sponsor? Just kidding!) My family wants to go to a cruise, too. Even though I really want go to a cruise, I always wonder about one thing: what happens if I get bored on the cruise because I’d just look at the water most of the time? The best recommendation to avoid boredom on board is to travel with friends. How many friends usually accompany you when travelling? I have several good friends going on a cruise, and this is the... - [SQL SERVER - master Database Log File Grew Too Big](https://blog.sqlauthority.com/2011/01/09/sql-server-master-database-log-file-grew-too-big/): Couple of the days ago, I received following email and I find this email very interesting and I feel like sharing with all of you. Note: Please read the whole email before providing your suggestions. “Hi Pinal, If you can share these details on your blog, it will help many. We understand the value of the master database and we take its regular back up (everyday midnight). Yesterday we noticed that our master database log file has grown very large. This is very first time that we have encountered such an issue. The master database is in simple recovery mode; so... - [SQL SERVER - Get File Statistics Using fn_virtualfilestats](https://blog.sqlauthority.com/2011/01/08/sql-server-get-file-statistics-using-fn_virtualfilestats/): Quite often when I am staring at my SSMS I wonder what is going on under the hood in my SQL Server. I often want to know which database is very busy and which database is bit slow because of IO issue. Sometime, I think at the file level as well. I want to know which MDF or NDF is busiest and doing most of the work. Following query gets the same results very quickly. SELECT DB_NAME(vfs.DbId) DatabaseName, mf.name, mf.physical_name, vfs.BytesRead, vfs.BytesWritten, vfs.IoStallMS, vfs.IoStallReadMS, vfs.IoStallWriteMS, vfs.NumberReads, vfs.NumberWrites, (Size*8)/1024 Size_MB FROM ::fn_virtualfilestats(NULL,NULL) vfs INNER JOIN sys.master_files mf ON mf.database_id = vfs.DbId AND... - [SQL SERVER - DMV - sys.dm_exec_query_optimizer_info - Statistics of Optimizer](https://blog.sqlauthority.com/2011/01/07/sql-server-dmv-sys-dm_exec_query_optimizer_info-statistics-of-optimizer/): Incredibly, SQL Server has so much information to share with us. Every single day, I am amazed with this SQL Server technology. Sometimes I find several interesting information by just querying few of the DMV. And when I present this info in front of my client during performance tuning consultancy, they are surprised with my findings. Today, I am going to share one of the hidden gems of DMV with you, the one which I frequently use to understand what’s going on under the hood of SQL Server. SQL Server keeps the record of most of the operations of the Query Optimizer. We can... - [SQL SERVER - Beginning SQL Server: One Step at a Time - SQL Server Magazine](https://blog.sqlauthority.com/2011/01/06/sql-server-beginning-sql-server-one-step-at-a-time-sql-server-magazine/): I am glad to announce that along with SQLAuthority.com, I will be blogging on the prominent site of SQL Server Magazine. My association with SQL Server Magazine has been quite long, I have written nearly 7 to 8 SQL Server articles for the print magazine and it has been a great experience. I used to stay in the United States at that time. I moved back to India for good, and during this process, I had put everything on hold for a while. Just like many things, “temporary” things become “permanent” – coming back to SQLMag was on hold for long... - [SQL SERVER - Copy Statistics from One Server to Another Server](https://blog.sqlauthority.com/2011/01/05/sql-server-copy-statistics-from-one-server-to-another-server/): I was recently working on a performance tuning project in Dubai (yeah I was able to see the tallest tower from the window of my work place). I had a very interesting learning experience there. There was a situation where we wanted to receive the schema of original database from a certain client. However, the client was not able to provide us any data due to privacy issues. The schema was very important because without having an access to underlying data, it was a bit difficult to judge the queries etc. For example, without any primary data, all the queries are... - [SQL SERVER - Unused Index Script - Download](https://blog.sqlauthority.com/2011/01/04/sql-server-2008-unused-index-script-download/): Performance Tuning is quite interesting and Index plays a vital role in it. A proper index can improve the performance and a bad index can hamper the performance. Here is the script from my script bank, which I use to identify unused indexes on any database. Let us see script for unused index. - [SQL SERVER - Missing Index Script - Download](https://blog.sqlauthority.com/2011/01/03/sql-server-2008-missing-index-script-download/): Performance Tuning is quite interesting and Index plays a vital role in it. A proper index can improve the performance and a bad index can hamper the performance. In this blog post we will discuss about Missing Index. - [SQL SERVER - Reduce the Virtual Log Files (VLFs) from LDF file](https://blog.sqlauthority.com/2011/01/02/sql-server-reduce-the-virtual-log-files-vlfs-from-ldf-file/): Earlier, I wrote a quite note on SQL SERVER – Detect Virtual Log Files (VLF) in LDF. Because of this I got responses suggesting too many VLFs are bad for log file. This prompts to a simple question: “How many is ‘too many’ VLFs?” I suggest that you go and read an article written by Kimberly over here. I am sure that you are going to have a clear understanding of what a good number for your VLFs is from that article. If you have lots of VLFs, you can reduce them right away using the following method: (I am just attempting to... - [SQLAuthority News - Resolution for New Year 2011](https://blog.sqlauthority.com/2011/01/01/sqlauthority-news-resolution-for-new-year-2011/): Today is the first day of the year so I want to write something very light. Last Year: 2010 Last Year was a blast; really traveled a lot. My family and I went on vacation. There I enjoyed being father, rolling on the floor and playing with my daughter. Here is the list of the countries I visited throughout 2010: Singapore (twice) Malaysia (twice) Sri Lanka (thrice) Nepal (once) United States of America (twice) United Arab Emirates (UAE) (once) My daughter who just completed 1 year on September 1, 2010 has so far visited three countries: Singapore, Malaysia and Sri Lanka,... - [SQLAuthority News - Community Service and Public Speaking Engagements](https://blog.sqlauthority.com/2010/12/31/sqlauthority-news-community-service-and-public-speaking-engagements/): Today is the last day of the year and I was going over my memories for year 2010. Almost all of them are good and I feel for sure better person in terms of knowledge, nature and overall human being. Looking back at the year, it is very satisfying as I was able to go out in public and help community out at various capacity. Thought, most of the time my contribution was as speaker, many times, I have reached out and helped organized event and worked at any capacity to get the event out. I have taken parts in many... - [SQL SERVER - Detect Virtual Log Files (VLF) in LDF](https://blog.sqlauthority.com/2010/12/30/sql-server-detect-virtual-log-files-vlf-in-ldf/): In one of the recent training engagements, I was asked if it true that there are multiple small log files in the large log file (LDF). I found this question very interesting as the answer is yes. Multiple small Virtual Log Files commonly known as VLFs together make an LDF file. The writing of the VLF is sequential and resulting in the writing of the LDF file is sequential as well. This leads to another talk that one does not need more than one log file in most cases. However, in short, you can use following DBCC command to know how many... - [SQLAuthority News - My Evaluation of Singapore SharePoint Conference ](https://blog.sqlauthority.com/2010/12/29/sqlauthority-news-my-evaluation-of-singapore-sharepoint-conference/): Earlier this year, I presented at SQLAuthority News – Presenting at South East Asia SharePoint Conference – Oct 26, 27, 2010 – Singapore. It was an unforgettable experience to present at Singapore SharePoint Conference as I was the only SQL Speaker at the event. The event was filled with SharePoint enthusiasts and many other experts from all around the globe. The event was indeed one of the best organized events I have attended in subcontinent. I just received my feedback score of the event. I was very much surprised and stunned and at the same time humbled. My rating are very high and also my... - [SQL SERVER - Plan Cache and Data Cache in Memory](https://blog.sqlauthority.com/2010/12/28/sql-server-plan-cache-and-data-cache-in-memory/): I get following question almost all the time when I go for consultations or training. I often end up providing the scripts to my clients and attendees. Instead of writing new blog post, today in this single blog post, I am going to cover both the script and going to link to original blog posts where I have mentioned about this blog post. Plan Cache in Memory USE AdventureWorks GO SELECT [text], cp.size_in_bytes, plan_handle FROM sys.dm_exec_cached_plans AS cp CROSS APPLY sys.dm_exec_sql_text(plan_handle) WHERE cp.cacheobjtype = N'Compiled Plan' ORDER BY cp.size_in_bytes DESC GO Further explanation of this script is over here: SQL SERVER... - [SQL SERVER - ORDER BY ColumnName vs ORDER BY ColumnNumber](https://blog.sqlauthority.com/2010/12/27/sql-server-order-by-columnname-vs-order-by-columnnumber/): I strongly favor ORDER BY ColumnName. I read one of the blog post where blogger compared the performance of the two SELECT statement and come to conclusion that ColumnNumber has no harm to use it. Let us understand the point made by first that there is no performance difference. Run following two scripts together: USE AdventureWorks GO -- ColumnName (Recommended) SELECT * FROM HumanResources.Department ORDER BY GroupName, Name GO -- ColumnNumber (Strongly Not Recommended) SELECT * FROM HumanResources.Department ORDER BY 3,2 GO If you look at the result and see the execution plan you will see that both of the query... - [SQL SERVER - Server Side Paging in SQL Server Denali - Part2](https://blog.sqlauthority.com/2010/12/26/sql-server-server-side-paging-in-sql-server-2011-part2/): The best part of the having blog is that SQL Community helps to keep it running with new ideas. Earlier I wrote about SQL SERVER – Server Side Paging in SQL Server Denali – A Better Alternative. A very popular article on that subject. I had used variables for “number of the rows” and “number of the pages”. Blog reader send me email asking in their organizations these values are stored in the table. Is there any the new syntax can read the data from the table. Absolutely YES! USE AdventureWorks2008R2 GO CREATE TABLE PagingSetting (RowsPerPage INT, PageNumber INT) INSERT INTO... - [SQLAuthority News - 18 Seconds of Fame - My PASS Experience](https://blog.sqlauthority.com/2010/12/25/sqlauthority-news-18-seconds-of-fame-my-pass-experience/): Happy Holidays to All of YOU! Life is full of little and happy surprises. I think Christmas and Santa are based on it. I just received very interesting email earlier today, I had no idea about it. Earlier this year, I had visited Seattle to attend SQLPASS – read the complete summary over here: SQLAuthority News – SQLPASS Nov 8-11, 2010-Seattle – An Alternative Look at Experience. While I was walking down, someone has stopped me and asked if they can talk to me for 15 seconds, I said yes and they had shot quick movie with mobile. The conversation was... - [SQLAuthority News - Feature Pack for Microsoft SQL Server 2005 SP4](https://blog.sqlauthority.com/2010/12/24/sqlauthority-news-feature-pack-for-microsoft-sql-server-2005-sp4/): If you are still using SQL Server 2005 – I suggest that you consider migrating to later version of the SQL Server 2008/2008 R2. Due to any reason, you wanted to continue using SQL Server 2005, I suggest that you take a look at the Feature Pack for Microsoft SQL Server 2005 SP4. There are many different tools and features available in pack, which can be very handy and can solve issues. Microsoft ADOMD.NET Microsoft Core XML Services (MSXML) 6.0 Microsoft OLEDB Provider for DB2 Microsoft SQL Server Management Pack for MOM 2005 Microsoft SQL Server 2000 PivotTable Services Microsoft SQL... - [SQL SERVER - Index Created on View not Used Often - Observation of the View - Part 2](https://blog.sqlauthority.com/2010/12/23/sql-server-index-created-on-view-not-used-often-observation-of-the-view-part-2/): Earlier, I have written an article about SQL SERVER – Index Created on View not Used Often – Observation of the View. I received an email from one of the readers, asking if there would no problems when we create the Index on the base table. Well, we need to discuss this situation in two different cases. Before proceeding to the discussion, I strongly suggest you read my earlier articles. To avoid the duplication, I am not going to repeat the code and explanation over here. In all the earlier cases, I have explained in detail how Index created on the... - [SQL SERVER - Public Training and Private Training - Differences and Similarities - Public Training vs Private Training](https://blog.sqlauthority.com/2010/12/22/sql-server-public-training-and-private-training-differences-and-similarities/): Earlier this year, I was on Road SQL Server Seminars. I did many SQL Server Performance Trainings and SQL Server Performance Consultations throughout the year but I feel the most rewarding exercise is always the one when instructor learns something from students, too. I was just talking to my wife, Nupur – she manages my logistics and administration related activities – and she pointed out that this year I have done 62% consultations and 38% trainings. I was bit surprised as I thought the numbers would be reversed. Every time I review the year, I think of training done at organizations. Well, I... - [SQL SERVER - Index Created on View not Used Often - Observation of the View](https://blog.sqlauthority.com/2010/12/21/sql-server-index-created-on-view-not-used-often-observation-of-the-view/): I always enjoy writing about concepts on Views. Views are frequently used concepts, and so it’s not surprising that I have seen so many misconceptions about this subject. To clear such misconceptions, I have previously written the article SQL SERVER – The Limitations of the Views – Eleven and more…. I also wrote a follow up article wherein I demonstrated that without even creating index on the basic table, the query on the View will not use the View. You can read about this demonstration over here: SQL SERVER – Index Created on View not Used Often – Limitation of the... - [SQL SERVER - Securing TRUNCATE Permissions in SQL Server](https://blog.sqlauthority.com/2010/12/20/sql-server-securing-truncate-permissions-in-sql-server/): Download the Script of this article from here. On December 11, 2010, Vinod Kumar, a Databases & BI technology evangelist from Microsoft Corporation, graced Ahmedabad by spending some time with the Community during the Community Tech Days (CTD) event. As he was running through a few demos, Vinod asked the audience one of the most fundamental and common interview questions – “What is the difference between a DELETE and TRUNCATE?“ Ahmedabad SQL Server User Group Expert Nakul Vachhrajani has come up with excellent solutions of the same. I must congratulate Nakul for this excellent solution and as a encouragement to User... - [SQLAuthority News - Microsoft SQL Server 2005 Service Pack 4 RTM](https://blog.sqlauthority.com/2010/12/19/sqlauthority-news-microsoft-sql-server-2005-service-pack-4-rtm/): Service Pack 4 (SP4) for Microsoft SQL Server 2005 is now available for download. SQL Server 2005 service packs are cumulative, and this service pack upgrades all service levels of SQL Server 2005 with SP4. Download Microsoft SQL Server 2005 Service Pack 4 RTM - [SQLAuthority News - Final Service Pack of SQL Server 2008 R2](https://blog.sqlauthority.com/2010/12/19/sqlauthority-news-final-service-pack-of-sql-server-2008-r2/): In this blog post, we will see the list of the final service pack of SQL Server 2008 and SQL Server 2008 R2. Comprehensive Database Performance Health Check - [SQL SERVER - Index Created on View not Used Often - Limitation of the View 12](https://blog.sqlauthority.com/2010/12/18/sql-server-index-created-on-view-not-used-often-limitation-of-the-view-12/): I have previously written on the subject SQL SERVER – The Limitations of the Views – Eleven and more…. This was indeed a very popular series and I had received lots of feedback on that topic. Today we are going to discuss something very interesting as well. Let us learn about the issue of index created on view on used often. - [SQLAuthority News - A Successful Community Tech Days in Ahmedabad - December 11, 2010](https://blog.sqlauthority.com/2010/12/17/sqlauthority-news-a-successful-community-techdays-at-ahmedabad-december-11-2010/): We recently had one of the best community events in Ahmedabad. We were fortunate that we had SQL Experts from around the world to have presented at this event. This gathering was very special because besides Jacob Sebastian and myself, we had two other speakers traveling all the way from Florida (Rushabh Mehta) and Bangalore (Vinod Kumar).There were a total of nearly 170 attendees and the event was a blast. Here are the details of the Tech Days event. - [SQL SERVER - Server Side Paging in SQL Server 2012 Performance Comparison](https://blog.sqlauthority.com/2010/12/16/sql-server-server-side-paging-in-sql-server-2011-performance-comparison/): Earlier, I have written about SQL SERVER – Server Side Paging in SQL Server 2012 – A Better Alternative. I got many emails asking for performance analysis of paging. Here is the quick analysis of it. The real challenge of paging is all the unnecessary IO reads from the database. Network traffic was one of the reasons why paging has become a very expensive operation. I have seen many legacy applications where a complete resultset is brought back to the application and paging has been done. As what you have read earlier, SQL Server 2011 offers a better alternative to an... - [SQL SERVER - Server Side Paging in SQL Server 2012 - A Better Alternative](https://blog.sqlauthority.com/2010/12/15/sql-server-server-side-paging-in-sql-server-2011-a-better-alternative/): Ranking has improvement considerably from SQL Server 2000 to SQL Server 2005/2008 to SQL Server 2012. Here is the blog article where I wrote about SQL Server 2005/2008 paging method SQL SERVER – 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) – CTE vs. Derived Table. One can achieve this using OVER clause and ROW_NUMBER() function. Now SQL Server 2011 has come up with the new Syntax for paging. Here is how one can easily achieve it. USE AdventureWorks2008R2 GO DECLARE @RowsPerPage INT = 10, @PageNumber INT = 5 SELECT * FROM Sales.SalesOrderDetail ORDER BY SalesOrderDetailID OFFSET @PageNumber*@RowsPerPage ROWS FETCH... - [SQL SERVER - What the Business Says Is Not What the Business Wants](https://blog.sqlauthority.com/2010/12/14/sql-server-what-the-business-says-is-not-what-the-business-wants/): Let us discuss about What the Business Says Is Not What the Business Wants. Steve raised a very interesting question. - [SQLAuthority News - SQL Server 2008 for Oracle DBA](https://blog.sqlauthority.com/2009/11/21/sqlauthority-news-sql-server-2008-for-oracle-dba/): This 15 modules, level 300 course provides students with the knowledge and skills to capitalize on their skills and experience as an Oracle DBA to manage a Microsoft SQL Server 2008 system. This workshop provides a quick start for the Oracle DBA to map, compare, and contrast the realm of Oracle database management to SQL Server database management. Module 1: Database and Instance Module 2: Database Architecture Module 3: Instance Architecture Module 4: Data Objects Module 5: Data Access Module 6: Data Protection Module 7: Basic Administration Module 8: Server Management Module 9: Managing Schema Objects Module 10: Database Security Module... - [SQLAuthority News - Book Review - Expert SQL Server 2008 Encryption by Michael Coles](https://blog.sqlauthority.com/2009/11/20/sqlauthority-news-book-review-expert-sql-server-2008-encryption-by-michael-coles/): Expert SQL Server 2008 Encryption (Paperback) Michael Coles (Author), Rodney Landrum (Author) Link to Amazon “What is your opinion on encryption? What I mean is: In a world filled with data, how do you see encryption?” This is the precise question Michael Coles posed to me on March 3rd of this year, while we were heading to Starbucks in Seattle. We were both attending the Microsoft MVP Summit there. In the information era, security has become one of the most vital aspects of life. Although the topic may seem a little mundane, its importance cannot be overemphasized. It is the pillar... - [SQL SERVER - Understanding Table Hints with Examples](https://blog.sqlauthority.com/2009/11/19/sql-server-understanding-table-hints-with-examples/): Introduction Today we have a very interesting subject to look at. I tried to look for help online but have not found any other documentation besides what we have from the Book Online. Let us try to understand what are the different kinds of hints available in SQL Server and how they are helpful. What is a Hint? Hints are options and strong suggestions specified for enforcement by the SQL Server query processor on DML statements. The hints override any execution plan the query optimizer might select for a query. Before we continue to explore this subject, we need to consider... - [SQL SERVER - Size of Index Table - A Puzzle to Find Index Size for Each Index on Table](https://blog.sqlauthority.com/2009/11/18/sql-server-size-of-index-table-a-puzzle-to-find-index-size-for-each-index-on-table/): It is very easy to find out some basic details of any table using the following Stored Procedure. USE AdventureWorks GO EXEC sp_spaceused [HumanResources.Shift] GO Above query will return following resultset The above SP provides basic details such as rows, data size in table, and Index size of all the indexes on the table. If we look at this carefully, a total of three indexes can be found on the table HumanResources.Shift. USE AdventureWorks GO SELECT * FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('HumanResources.Shift') GO The above query will give result with query listing all the index on the table. There is... - [SQL SERVER - 2005 2008 - Backup, Integrity Check and Index Optimization By Ola Hallengren](https://blog.sqlauthority.com/2009/11/17/sql-server-2005-2008-backup-integrity-check-and-index-optimization-by-ola-hallengren/): Script of Backup, Integrity Check and Index Optimization are the most important scripts for any developer. SQL Expert and true SQL enthusiast Ola Hallengren is known for his excellent scripts. Please try it out and let me know what you think. The documentation is available on http://ola.hallengren.com/Documentation.html and the script can be downloaded from http://ola.hallengren.com. Here is brief documentation sent by Ola himself for his script in his own words. Backup Maintenance I think that most of you have experienced the error messages “BACKUP LOG cannot be performed because there is no current database backup.” and “Cannot perform a differential backup... - [SQLAuthority News - Notes of Excellent Experience at SQL PASS 2009 Summit, Seattle](https://blog.sqlauthority.com/2009/11/16/sqlauthority-news-notes-of-excellent-experience-at-sql-pass-2009-summit-seattle/): Update: Do not forget to checkout last three photos and follow me on twitter (of course!) I have previously documented my four-day experience of SQL PASS 2009 Summit at Seattle. There were many reasons for SQL enthusiasts to attend the SQL PASS event; I am listing my own reasons here in order of importance to me. Networking with SQL fellows and experts Putting face to the name or avatar Learning and improving my SQL skills Understanding the structure of the largest SQL Server Professional Association Attending my favorite training sessions During these four days, there was so much happening that it... - [SQL SERVER - Whitepaper Consolidation Using SQL Server 2008](https://blog.sqlauthority.com/2009/11/15/sql-server-whitepaper-consolidation-using-sql-server-2008/): Consolidation Using SQL Server 2008 Writer: Allan Hirt, Megahirtz LLC (allan@sqlha.com) Technical Reviewers: Lindsey Allen, Madhan Arumugam, Ben DeBow, Sung Hsueh, Rebecca Laszlo, Claude Lorenson, Prem Mehra, Mark Pohto, Sambit Samal, and Buck Woody Published: October 2009 Many companies are considering or have already implemented consolidation of computing resources, including Microsoft SQL Server instances and databases, in their organization. A consolidation effort is a complex task that requires information, a detailed plan and timeline for success, and a strategy for administering the consolidated environment. This white paper walks through the journey of gathering and analyzing the information to base all planning... - [SQLAuthority News - Disk Partition Alignment Best Practices for SQL Server](https://blog.sqlauthority.com/2009/11/14/sqlauthority-news-disk-partition-alignment-best-practices-for-sql-server/): Disk Partition Alignment Best Practices for SQL Server Writers: Jimmy May, Denny Lee Contributors: Mike Ruthruff, Robert Smith, Bruce Worthington, Jeff Goldner, Mark Licata, Deborah Jones, Michael Thomassy, Michael Epprecht, Frank McBath, Joseph Sack, Matt Landers, Jason McKittrick, Linchi Shea, Juergen Thomas, Emily Wilson, John Otto, Brent Dowling Technical Reviewers: Mike Ruthruff, Robert Smith, Bruce Worthington, Emily Wilson, Lindsey Allen, Stuart Ozer, Thomas Kejser, Kun Cheng, Nicholas Dritsas, Paul Mestemaker, Alexei Khalyako, Mike Anderson, Bong Kang Published: May 2009 Disk partition alignment is a powerful tool for improving SQL Server performance. Configuring optimal disk performance is often viewed as much art... - [SQL SERVER - Policy Based Management - Create, Evaluate and Fix Policies](https://blog.sqlauthority.com/2009/11/13/sql-server-policy-based-management-create-evaluate-and-fix-policies/): Introduction This article will cover the most spectacular feature of SQL 2008 – Policy-based management and how the configuration of SQL Server with policy-based management architecture can make a powerful difference. Policy based management is loaded with several advantages. It can help you implement various policies for reliable configuration of the system. It also provides additional administration assistance to DBAs and helps them effortlessly manage various tasks of SQL Server across the enterprise. Basics of Policy Management SQL server 2008 has introduced policy management framework, which is the latest technique for SQL server database engine. SQL policy administrator uses SQL Server... - [SQL SERVER - Disable CHECK Constraint - Enable CHECK Constraint](https://blog.sqlauthority.com/2009/11/12/sql-server-disable-check-constraint-enable-check-constraint/): Foreign Key and Check Constraints are two types of constraints that can be disabled or enabled when required. This type of operation is needed when bulk loading operations are required or when there is no need to validate the constraint. The T-SQL Script that does the same is very simple. USE AdventureWorks GO -- Disable the constraint ALTER TABLE HumanResources.Employee NOCHECK CONSTRAINT CK_Employee_BirthDate GO -- Enable the constraint ALTER TABLE HumanResources.Employee WITH CHECK CHECK CONSTRAINT CK_Employee_BirthDate GO It is very interesting that when the constraint is enabled, the world CHECK is used twice – WITH CHECK CHECK CONSTRAINT. I often ask those to find the mistake in this script when they claim to... - [SQL SERVER - Sharepoint Resource Available for SQL Server](https://blog.sqlauthority.com/2009/11/11/sql-server-sharepoint-resource-available-for-sql-server/): Here is quick list of the tools which are available for SQL Server and Sharepoint. These are recently updated resources from Microsoft. External Collaboration Toolkit for SharePoint This solution allows users to create collaboration environments that use the familiar SharePoito deploy a SharePoint-based environment for collaboration with people outside your firewall. The accelerator allows users to create collaboration environments that use the familiar SharePoint interface. Because the solution is easy to use, end users are more likely to use it rather than revert to e-mail. SQL Server Reporting Services Add-in for SharePoint Technologies The Microsoft SQL Server 2005 Reporting Services Add-in... - [SQL Authority News - Training MS SQL Server 2005/2008 Query Optimization And Performance Tuning](https://blog.sqlauthority.com/2009/11/10/sql-authority-news-training-ms-sql-server-20052008-query-optimization-and-performance-tuning/): This is very short note announcing details about my course details for 'Training MS SQL Server 2005/2008 Query Optimization And Performance Tuning'. - [SQL SERVER - Removing Key Lookup - Seek Predicate - Predicate - An Interesting Observation Related to Datatypes](https://blog.sqlauthority.com/2009/11/09/sql-server-removing-key-lookup-seek-predicate-predicate-an-interesting-observation-related-to-datatypes/): Recently, I have been working on Query Optimization project. While working on it, I found the following interesting observation. This entire concept may appear very simple, but if you are working in the area of query optimization and server tuning, you will find such useful hints. Before we start, let us understand the difference between Seek Predicate and Predicate. Seek Predicate is the operation that describes the b-tree portion of the Seek. Predicate is the operation that describes the additional filter using non-key columns. Based on the description, it is very clear that Seek Predicate is better than Predicate as it... - [SQL SERVER - Stored Procedure are Compiled on First Run - SP taking Longer to Run First Time](https://blog.sqlauthority.com/2009/11/08/sql-server-stored-procedure-are-compiled-on-first-run-sp-taking-longer-to-run-first-time/): During the PASS summit, one of the attendees asked me the following question. Why the Stored Procedure takes long time to run for first time? The reason for the same is because Stored Procedures are compiled when it runs first time. When I answered the same, he replied that Stored Procedures are pre-compiled, and this should not be the case. In fact, Stored Procedures are not pre-compiled; they compile only during their first time execution. There is a misconception that stored procedures are pre-compiled. They are not pre-compiled, but compiled only during the first run. For every subsequent runs, it is... - [SQLAuthority News - Data Compression Strategy Capacity Planning and Best Practices](https://blog.sqlauthority.com/2009/11/07/sqlauthority-news-data-compression-strategy-capacity-planning-and-best-practices/): Data Compression: Strategy, Capacity Planning and Best Practices SQL Server Technical Article Writer: Sanjay Mishra Contributors: Marcel van der Holst, Peter Carlin, Sunil Agarwal Technical Reviewer: Stuart Ozer, Lindsey Allen, Juergen Thomas, Thomas Kejser, Burzin Patel, Prem Mehra, Joseph Sack, Jimmy May, Cameron Gardiner, Mike Ruthruff, Glenn Berry (SQL Server MVP), Paul S Randal (SQLskills.com), David P Smith (ServiceU Corporation) Published: May 2009 The data compression feature in SQL Server 2008 helps compress the data inside a database, and it can help reduce the size of the database. Apart from the space savings, data compression provides another benefit: Because compressed data... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 4](https://blog.sqlauthority.com/2009/11/06/sqlauthority-news-sql-pass-summit-seattle-2009-day-4/): Fourth day was awesome! I had scheduled nearly 8 meetings with different groups of people today. It was really great fun. Let us see the keypoints for the same. PASS President Wayne Snyder honored and thanked Kevin Kline for his 10 YEARS of service. Kevin then gets a well-deserved standing ovation from the entire audience. Next year’s PASS Summit will be in Seattle from November 8 to 11, 2010. Dell Key note was little flat in delivery. Dell was primary sponsor for the event. Dr. David DeWitt, Technical Fellow, Data & Storage Platform Division at Microsoft starts presentation entitled “From 1... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 3](https://blog.sqlauthority.com/2009/11/05/sqlauthority-news-sql-pass-summit-seattle-2009-day-3/): The third day at SQL PASS Summit was education + entertainment day for me. During the last 10 days, I woke up at 4:00 AM regularly. However, as I had way too much fun yesterday at various parties earlier, I did not get up till 7:30 AM. By the time I woke up, I realized that I was late for my early breakfast meeting with Solid Quality Global Mentors. I somehow managed to reach there at 8:00 AM and we talked for nearly an hour. After the meeting, I headed to Keynote. Keynote is the best time of the day and... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 2](https://blog.sqlauthority.com/2009/11/04/sqlauthority-news-sql-pass-summit-seattle-2009-day-2/): The second day of PASS started with very engaging and it started with an original game invented by Stuart Ainsworth. This game involves finding twitter people in real life. As I was not one of the square in bingo, I had decided to participate in game myself and try to win if I can. During this process, I felt guilty that I borrowed a pen from Stuart and did not return it back. In fact, after a while someone took the pen from me and never returned it. It is true that karma pays off! I should have returned it right... - [SQLAuthority News - SQLPASS Summit, Seattle 2009 - Day 1](https://blog.sqlauthority.com/2009/11/03/sqlauthority-news-sql-pass-summit-seattle-2009-day-1/): Day 1 at SQLPASS was awesome. I usually write everything in detail when I have to cover any project. This time, I have decided to cover this event little bit different and with lots of images. For day 1, I have more than 90 photos taken with many SQL celebrities and different sessions. I will be not able to cover all the photos taken today in this post. I will gradually post all the photos as I will do follow up posts. In this post, I will cover my activities on day 1 as well few of the photos that give you a visual tour of the spot that I have covered in one day. - [SQLAuthority News - 3 Year Old Blog - PASS Summit 2009 - 10.5 Million Views](https://blog.sqlauthority.com/2009/11/02/sqlauthority-news-3-year-old-blog-pass-summit-2009-10-5-million-views/): This blog has reached a remarkable milestone. It is 3 years old today. So far, there have been more than 10.5 million views on this blog and more than 1140 articles. It is really exciting that on this very important day, I am attending my very first SQL PASS in Seattle. The feeling and excitement to attend the very first summit cannot be put into words. I have been waiting to attend this summit for almost a year now, and today this dream is materializing with my blog’s “birthday.” You can read all of my articles written thus far here. I... - [SQL Authority News - Advanced T-SQL with Itzik Ben-Gan - Solid Quality Mentors](https://blog.sqlauthority.com/2009/11/01/sql-authority-news-advanced-t-sql-with-itzik-ben-gan-solid-quality-mentors/): As mentioned earlier in a blog post SQL SERVER – Advanced T-SQL with Itzik Ben-Gan – A Dream Coming True, I got the wonderful opportunity to attend the course of Itzik Ben-Gan. Itzik is one of the true masters of SQL Server, and his fame had set my expectations quite high. The most interesting aspect is that I have taught a similar course in India several times, and I was quite familiar with all the slides and examples. As I already knew a lot about this course, I was wondering if I would be able to enjoy the class or learn something... - [SQLAuthority News - New PASS President Rushabh Mehta](https://blog.sqlauthority.com/2009/10/31/sqlauthority-news-new-pass-president-rushabh-mehta/): The Professional Association for SQL Server (PASS) is an independent, not-for-profit association, dedicated to supporting, educating, and promoting the Microsoft SQL Server community. From local user groups and special interest groups (Virtual Chapters) to webcasts and the annual PASS Community Summit – the largest gathering of SQL Server professionals in the world – PASS is dedicated to helping its members Connect, Share, and Learn. Today was a big day as PASS announced the executive board members for the term starting on Jan 1, 2010. I would like to express my congratulations to all new executives of PASS. Please read official press... - [SQLAuthority News - India Market and Third Party SQL Server Tools](https://blog.sqlauthority.com/2009/10/30/sqlauthority-news-india-market-and-third-party-sql-server-tools/): Last week, I had wonderful time attending meeting of small ISV (Independent Software Vendors). Several topics were discussed, but the one topic that caught my attention was the adoption of the third party SQL Server tools. There were around 100+ top level managers who take decision regarding what resources are needed for projects. I had a great time talking to them. I have delivered a session on the subject “SQL Server – A Scalable Performance Database Platform“. Whenever I receive the right opportunity, it gives me great pleasure to talk about SQL Server. I have been working with SQL Server, and... - [SQLAuthority News - Birds-of-a-Feather (BOF) Lunch - SQL PASS Summit, Seattle, 2009](https://blog.sqlauthority.com/2009/10/29/sqlauthority-news-birds-of-a-feather-bof-lunch-sql-pass-summit-seattle-2009/): I received few emails regarding where can people meet me at SQL PASS event in Seattle. I am currently in Bellevue attending Itzik Ben-Gan’s class. I am immensely enjoying the class, and I shall post details about the class once it is over. If you are attending SQL PASS and interested to meet me, I will be present at Birds-of-a-Feather (BOF) Lunch. I will be talking on the subject Change Data Capture (CDC). Please note that this lunch is for all of us; moreover, it is not necessary that I will be talking on only subject of Change Data Capture. In... - [SQL SERVER - Tuning the Performance of Change Data Capture in SQL Server 2008](https://blog.sqlauthority.com/2009/10/28/sql-server-tuning-the-performance-of-change-data-capture-in-sql-server-2008/): Change data capture (CDC) is a new feature in SQL Server 2008 designed to capture insert, update, merge, and delete activities applied to SQL Server tables and to avail those changes in an easy-to-understand format. Conventionally, detecting changes in a source database to transfer these changes to a data warehouse required any of the following: Special columns in the source tables (time stamps, row versions). Triggers that capture changes. Comparison of the source and the destination systems. The above methods can have significant disadvantages: special columns require a change in the source database schema, and in many cases, a change in... - [SQL SERVER - How to Enable Index - How to Disable Index - Incorrect syntax near 'ENABLE'](https://blog.sqlauthority.com/2009/10/27/sql-server-how-to-enable-index-how-to-disable-index-incorrect-syntax-near-enable/): Many times I have seen that the index is disabled when there is large update operation on the table. Bulk insert of very large file updates in any table using SSIS is usually preceded by disabling the index and followed by enabling the index. I have seen many developers running the following query to disable the index. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO While enabling the same index, I have seen developers using the following INCORRECT syntax, which results in error. USE AdventureWorks GO ----INCORRECT Syntax Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact ENABLE GO Msg 102, Level 15, State... - [SQL SERVER - Advanced T-SQL with Itzik Ben-Gan - A Dream Coming True](https://blog.sqlauthority.com/2009/10/26/sql-server-advanced-t-sql-with-itzik-ben-gan-a-dream-coming-true/): As from my blog posts, all of you are probably aware that I am very much excited for attending SQL PASS at Seattle from Nov 1, 2009. As the days to the summit were nearing, I could already feel the rush of adrenalin in my veins. May be because of this, I could not wait any longer and so I headed towards Seattle a week earlier! As Robert Cain mentioned on twitter, I finally arrived at Seattle a week earlier than the start date of the summit. I landed in Seattle on the evening of Oct 24, 2009. As I was... - [SQLAuthority News - Best Practices for Integration Services Configurations](https://blog.sqlauthority.com/2009/10/25/sqlauthority-news-best-practices-for-integration-services-configurations/): Best Practices for Integration Services Configurations by Jamie Thomson This article explains what SQL Server Integration Services configurations are used for, why you should use Integration Services configurations, and what options you have for leveraging configurations. It will also make some simple recommendations that are based on my experiences of building Integration Services packages in a real-world environment. An understanding of the terms “package”, “Business Intelligence Development Studio”, and “dtexec.exe” in the context of Integration Services is assumed. There five basic types of Integration Services configurations. XML Configuration File Environment Variable Configuration Parent Package Configuration Registry Configuration SQL Server Configuration Read... - [SQL SERVER - Link to SQL Server Book Online - BOL](https://blog.sqlauthority.com/2009/10/24/sql-server-link-to-sql-server-book-online-bol/): Do you keep following Book Online Links handy? I do and I use them a lot. SQL Server 2008 R2 SQL Server 2008 SQL Server 2005 SQL Server 2000 I do and I use them a lot. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - PASS Sessions - I will be there!](https://blog.sqlauthority.com/2009/10/23/sqlauthority-news-pass-sessions-i-will-be-there/): As PASS is now one week away and I am all excited for the same. I am going to attend following two sessions for sure. I encourage all of you to also visit the same sessions. We can all talk about SQL , SQL Integration as well Beyond Relations. First sessions I will be attending of Rushabh Mehta, he is Managing Director of Solid Quality India. Overcoming SSIS Deployment and Configuration Challenges Presenter: Rushabh Mehta (Solid Quality Learning) Session Details It is no secret that a main deficiency of SSIS is deployment. Have you wanted to punch a wall before when... - [SQL SERVER - Difference Between Candidate Keys and Primary Key In Simple Words](https://blog.sqlauthority.com/2009/10/22/sql-server-difference-candidate-keys-primary-key-simple-words/): Introduction Not long ago, I had an interesting and extended debate with one of my friends regarding which column should be primary key in a table. The debate instigated an in-depth discussion about candidate keys and primary keys. My present article revolves around the two types of keys. Let us first try to grasp the definition of the two keys. Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. Primary... - [SQL SERVER - Introduction to Business Intelligence - Important Terms & Definitions](https://blog.sqlauthority.com/2009/10/21/sql-server-introduction-to-business-intelligence-important-terms-definitions/): What is Business Intelligence Business intelligence (BI) is a broad category of application programs and technologies for gathering, storing, analyzing, and providing access to data from various data sources, thus providing enterprise users with reliable and timely information and analysis for improved decision making. To put it simply, BI is an umbrella term that refers to an assortment of software applications for analyzing an organization’s raw data for intelligent decision making for business success. BI as a discipline includes a number of related activities, including decision support, data mining, online analytical processing (OLAP), querying and reporting, statistical analysis and forecasting. - [SQLAuthority News - PASS 2009 Sessions on Query Optimization and Performance Tuning](https://blog.sqlauthority.com/2009/10/20/sqlauthority-news-pass-2009-sessions-on-query-optimization-and-performance-tuning/): PASS Summit 2009 is now only 10 days away and I am very excited for the same. I can not wait to attend the summit as this is the most awaited conference of SQL Server in world. Everybody will be there and there will be something for everybody. My core expertise is in Query Optimization and Performance Tuning area, and when I see the list of PASS session on the subject, I am totally speechless. There are so many great speaker at PASS who are there to talk on the subject. It is absolutely not possible to attend all of them... - [SQL SERVER - Change Collation of Database Column - T-SQL Script - Consolidating Collations - Extention Script](https://blog.sqlauthority.com/2009/10/19/sql-server-change-collation-of-database-column-t-sql-script-consolidating-collations-extention-script/): This document is created by Brian Cidern, he has written this excellent extension to SQL Expert who SQL SERVER – Change Collation of Database Column – T-SQL Script. His scripts are not only extremely helpful to achieve the task of consolidating collations in quick script. His script not only works perfectly but excellent piece of code and logic. Hats off to you Brian! You can reach Brian at his email address (brians.sql.blog (at) gmail (dot) com) or leave comment here. Download all scripts and explanation here About Collation Consolidation At some time in your DBA career, you may find yourself in... - [SQLAuthority News - Whitepaper - Auditing in SQL Server 2008](https://blog.sqlauthority.com/2009/10/18/sqlauthority-news-whitepaper-auditing-in-sql-server-2008/): Auditing in SQL Server 2008 SQL Server Technical Article Writer: Il-Sung Lee, Art Rask Technical Reviewer: Jack Richins, Rick Byham, Sameer Tejani, Al Comeau, JC Cannon Published: February 2009 With SQL Server Audit, SQL Server 2008 introduces an important new feature that provides a true auditing solution for enterprise customers. While SQL Trace can be used to satisfy many auditing needs, SQL Server Audit offers a number of attractive advantages that may help DBAs more easily achieve their goals such as meeting regulatory compliance requirements. These include the ability to provide centralized storage of audit logs and integration with System Center,... - [SQLAuthority News - Happy Diwali and New Year](https://blog.sqlauthority.com/2009/10/17/sqlauthority-news-happy-diwali-and-new-year/): I wish all of you Happy Diwali and New Year. Dīwali is a significant festival an official holiday in India. While Divali is popularly known as the “festival of lights”, the most significant spiritual meaning is “the awareness of the inner light”. Database tip of the day : Test your backup strategy. Yesterday night I had received call from old client, who lost his live server. When I asked for his backup system, which I helped him to set up, he informed me that as server did not crashed for entire year that did not have it properly. Well, I helped... - [SQL SERVER - Recently Executed T-SQL Query](https://blog.sqlauthority.com/2009/10/16/sql-server-recently-executed-t-sql-query/): About a year ago, I wrote blog post about SQL SERVER – 2005 – Last Ran Query – Recently Ran Query.  Since, then I have received many question regarding how this is better than fn_get_sql() or DBCC INPUTBUFFER. The Short Answer in is both of them will be deprecated. Please refer to following update query to recently executed T-SQL query on database. SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest ORDER BY deqs.last_execution_time DESC Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Enable Automatic Statistic Update on Database](https://blog.sqlauthority.com/2009/10/15/sql-server-enable-automatic-statistic-update-on-database/): In one of the recent projects, I found out that despite putting good indexes and optimizing the query, I could not achieve an optimized performance and I still received an unoptimized response from the SQL Server. On examination, I figured out that the culprit was statistics. The database that I was trying to optimize had auto update of the statistics was disabled. Let us learn about how to Enable Automatic Statistic Update on Database. - [SQLAuthority News - First Editorial - T-SQL Challenges Beginners](https://blog.sqlauthority.com/2009/10/14/sqlauthority-news-first-editorial-t-sql-challenges-beginners/): I would like to welcome all of you to very first editorial for T-SQL Challenges for Beginners. T-SQL Challenges began with the aim to help community to come out of regular mind set of just reading articles online. There is plenty of reading material available online, but there are very few that can make us use our brain cells. T-SQL Challenges are very well received in community, and today, we are receiving more than 200 responses for every challenge in a very short time. The real challenge is how to keep everybody involved. T-SQL Challenges is focused and encourage experts to... - [SQL SERVER - Comic Slow Query - SQL Joke](https://blog.sqlauthority.com/2009/10/13/sql-server-comic-slow-query-sql-joke/): Community TechDays at Ahmedabad was a great successful event. In fact, this can be considered the biggest event held in Ahmedabad thus far along with the community. I have posted a detailed report of the same at Community TechDays in Ahmedabad – A Successful Event. After the event, I received many emails requesting the comic slow query I had shown in my presentation. - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup - Part 3](https://blog.sqlauthority.com/2009/10/12/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup-part-3/): Earlier I have written two different articles on the subject Remove Bookmark Lookup. This article is as part 3 of the original article. Please read the first two articles here before continuing reading this article. - [SQLAuthority News - Accessing SQL Server Databases with PHP](https://blog.sqlauthority.com/2009/10/11/sqlauthority-news-accessing-sql-server-databases-with-php/): Accessing SQL Server Databases with PHP SQL Server Technical Article Writer: Brian Swan Published: August 2008 The SQL Server 2005 Driver for PHP is a Microsoft-supported extension of PHP 5 that provides data access to SQL Server 2005 and SQL Server 2008. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2008. The SQL Server 2005 Driver for PHP API provides a comprehensive data access solution from PHP, and includes support for many features including Windows Authentication, transactions, parameter binding, streaming, metadata access, connection pooling, and error handling. This paper discusses... - [SQL SERVER - Download Logical Query Processing Poster](https://blog.sqlauthority.com/2009/10/10/sql-server-download-logical-query-processing-poster/): You can download the poster from Itzik Ben-Gan’s T-SQL Querying page over here. Earlier this year, I had written article on SQL SERVER – Logical Query Processing Phases – Order of Statement Execution and I had asked one question to readers. I got very good response for this question. Today, I am going to discuss about one of the errata I have made there. I had displayed the Logical Query Processing order, where I had incorrectly listed the last two operations. I have listed the operations as ORDER BY first and TOP afterwards. The fact is that TOP is always executed first and ORDER BY after that. - [SQL SERVER - Queries Waiting for Memory Allocation to Execute](https://blog.sqlauthority.com/2009/10/09/sql-server-queries-waiting-for-memory-allocation-to-execute/): In one of the recent projects, I was asked to create a report of queries that are waiting for memory allocation. The reason was that we were doubtful regarding whether the memory was sufficient for the application. The following query can be useful in similar case. Queries that do not have to wait on a memory grant will not appear in the resultset of following query. SELECT TEXT, query_plan, requested_memory_kb, granted_memory_kb,used_memory_kb, wait_order FROM sys.dm_exec_query_memory_grants MG CROSS APPLY sys.dm_exec_sql_text(sql_handle) CROSS APPLY sys.dm_exec_query_plan(MG.plan_handle) Please note that wait_order will give order of query waiting on memory to execute. This is a very important script, I suggest that you... - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup - Part 2](https://blog.sqlauthority.com/2009/10/08/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup-part-2/): This article is follow up of my previous article SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup. Please do read my previous article before continuing further. I have described there two different methods to reduce query execution cost. Let us compare the performance of the SELECT statement of the previous query. We have created two different indexes on the table. Method 1: Creating covering non-clustered index. In this method, we will create a non-clustered index that contains the columns used in the SELECT statement along with the column used in the WHERE... - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup](https://blog.sqlauthority.com/2009/10/07/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup/): Today, I would like to share one very quick tip about how to remove bookmark lookup or RID lookup. Let us first understand Bookmark lookup or RID lookup. Please note that from SQL Server 2005 SP1 onwards, Bookmark look up is known as Key look up. When a small number of rows are requested by a query, the SQL Server optimizer will try to use a non-clustered index on the column or columns contained in the WHERE clause to retrieve the data requested by the query. If the query requests data from columns not present in the non-clustered index, SQL Server... - [SQL SERVER - Interesting Observation - Query Hint - FORCE ORDER](https://blog.sqlauthority.com/2009/10/06/sql-server-interesting-observation-query-hint-force-order/): SQL Server never stops to amaze me. As regular readers of this blog already know that besides conducting corporate training, I work on large-scale projects on query optimizations and server tuning projects. In one of the recent projects, I have noticed that a Junior Database Developer used the query hint Force Order; when I asked for details, I found out that the basic concept was not properly understood by him. - [SQLAuthority News - Community TechDays in Ahmedabad - A Successful Event - Oct 3, 2009](https://blog.sqlauthority.com/2009/10/05/sqlauthority-news-community-techdays-in-ahmedabad-a-successful-event/): Community TechDays at Ahmedabad was a great successful event. In fact, this can be considered the biggest event held in Ahmedabad thus far along with community. This event was held by Microsoft and PASS (Professional Association of SQL Server). The goal of this event was to dive deep into the world of Microsoft technologies and get trained on the latest from Microsoft. Well, we could successfully achieve the same and build real connections with Microsoft experts and community members. - [SQL SERVER - Choose Right Edition of SQL Server Express for Your Application](https://blog.sqlauthority.com/2009/10/04/sql-server-choose-right-edition-of-sql-server-express-for-your-application/): SQL Server Express is better alternative of MySQL. I have recently helped quite a few organizations to move to SQL Server Express recently. However, one question keep on coming up quite often regarding which is the right edition for SQL Server Express. SQL Server Express have more than one edition available. Here is the quick guide to select right edition for SQL Server. After reading above guide if you are still not sure which edition you should select, leave a comment here or send me email and I will get back to you. SQL Server 2008 Express with Advanced Services –... - [SQLAuthority News - Database Encryption in SQL Server 2008 Enterprise Edition](https://blog.sqlauthority.com/2009/10/03/sqlauthority-news-database-encryption-in-sql-server-2008-enterprise-edition/): Database Encryption in SQL Server 2008 Enterprise Edition SQL Server Technical Article Writers: Sung Hsueh Technical Reviewers: Raul Garcia, Sameer Tejani, Chas Jeffries, Douglas MacIver, Byron Hynes, Ruslan Ovechkin, Laurentiu Cristofor, Rick Byham, Sethu Kalavakur Published: February 2008 TDE does not replace cell-level encryption, EFS, or BitLocker. This white paper compares TDE with these other encryption methods for application developers and database administrators. While this is not a technical, in-depth review of TDE, technical implementations are explored and a familiarity with concepts such as virtual log files and the buffer pool are assumed. The user is assumed to be familiar with... - [SQLAuthority News - SQL Server 2008 - The Other Side of Index - Community Tech Days](https://blog.sqlauthority.com/2009/10/02/sqlauthority-news-sql-server-2008-the-other-side-of-index-live-presentation-in-ahmedabad/): Community Tech Days are here Tomorrow in Ahmedabad on Oct 3, 2009. I will be presenting the session ‘SQL Server 2008 – The Other Side of Index’. I will be available there whole day if you want to meet and discuss SQL. I will be starting my session with following cartoon. You will have to attend the session in person to see what I am going to cover in the session. - [SQL SERVER - SQL Server Management Studio and Client Statistics](https://blog.sqlauthority.com/2009/10/01/sql-server-sql-server-management-studio-and-client-statistics/): Client Statistics is very important. Many a time, people relate queries execution plan with query cost. This is not a good comparison. Both are different parameters, and they are not always related. It is possible that the query cost of any statement is less, but the amount of the data returned is considerably large, which is causing any query to run slow. How do we know if any query is retrieving a large amount data or very little data? In one way, it is quite easy to figure this out by just looking at the result set; however, this method cannot... - [SQLAuthority News - Community Tech Days - Oct 3, 2009 - SQL Server 2008 - The Other Side of Index](https://blog.sqlauthority.com/2009/09/30/sqlauthority-news-community-tech-days-oct-3-2009-sql-server-2008-the-other-side-of-index/): Microsoft Community Tech Days are here! Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Community Tech Days are coming to Ahmedabad on Oct 3, 2009. I will be presenting the session ‘SQL Server 2008 – The Other Side of Index’. I will be talking about the other side of Index where we will be thinking out of the typical way of creating Indexes. Take a look at the following common conversation. Person 1: My Query is running slow. Person 2: How about create an index on it? Person 1:... - [SQL SERVER - Interesting Observation - Execution Plan and Results of Aggregate Concatenation Queries](https://blog.sqlauthority.com/2009/09/29/sql-server-interesting-observation-execution-plan-and-results-of-aggregate-concatenation-queries/): Working with SQL Server has never seems to be monotonous – no matter how long one has worked with it. Quite often, I come across some excellent comments that I feel like acknowledging them as blog posts. Recently, I wrote an article on SQL SERVER – Execution Plan and Results of Aggregate Concatenation Queries Depend Upon Expression Location, which is well received in community. Before you read this article further, I request you to read original article. I received very interesting comments from Bob on the blog, where he explained why this is happening. Further, he talked about a similar kind... - [SQLAuthority News - Download IIS Database Manager](https://blog.sqlauthority.com/2009/09/28/sqlauthority-news-download-iis-database-manager/): IIS Database Manager allows you to easily manage your local and remote databases from within IIS Manager. IIS Database Manager automatically discovers databases based on the Web server or application configuration and also provides the ability to connect to any database on the network. Once connected, IIS Database Manager provides a full array of management options including managing tables, views, stored procedures and data, as well as running ad hoc queries. Here are a few articles to get you started on using the IIS Database Manager: Basics of the IIS Database Manager Working with Tables Working with Views Working with Stored... - [SQLAuthority News - FILESTREAM Storage in SQL Server 2008](https://blog.sqlauthority.com/2009/09/27/sqlauthority-news-filestream-storage-in-sql-server-2008/): This white paper describes the FILESTREAM feature of SQL Server 2008, which allows storage of and efficient access to BLOB data using a combination of SQL Server 2008 and the NTFS file system. This white paper is Written By: Paul S. Randal (SQLskills.com) Read the white paper here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - FIX : An error occurred while executing this command. If this error persists, please contact your Live Meeting administrator.](https://blog.sqlauthority.com/2009/09/26/sqlauthority-news-fix-an-error-occurred-while-executing-this-command-if-this-error-persists-please-contact-your-live-meeting-administrator/): Recently, while I was scheduling a live meeting for one of my online training sessions, I kept receiving the following error message repeatedly. I had never encountered this type of error before, and despite searching online for a long time, I could not solve this problem. After several failed attempts, I finally managed to fix this error with the help of Solid Quality Mentors IT Support Mentor – Victor. He suggested that instead of just typing my name in the “To” field, I should clear the cache by pressing CTRL + DELETE or perform force lookup by selecting the contact person... - [SQL SERVER - Outer Join in Indexed View - Question to Readers](https://blog.sqlauthority.com/2009/09/25/sql-server-outer-join-in-indexed-view-question-to-readers/): Today I have question for you. Just a day ago I was reading whitepaper Improving Performance with SQL Server 2008 Indexed Views. Following is question and answer I read in the white paper. Q. Why can’t I use OUTER JOIN in an indexed view? A. Rows can logically disappear from an indexed view based on OUTER JOIN when you insert data into a base table. This makes incrementally updating OUTER JOIN views relatively complex to implement, and the performance of the implementation would be slower than for views based on standard (INNER) JOIN. Here I would like to ask you one... - [SQL SERVER - Interesting Observation - Index on Index View Used in Similar Query](https://blog.sqlauthority.com/2009/09/24/sql-server-interesting-observation-index-on-index-view-used-in-similar-query/): Recently, I was working on an optimization project for one of the large organizations. While working on one of the queries, we came across a very interesting observation. We found that there was a query on the base table and when the query was run, it used the index, which did not exist in the base table. On careful examination, we found that the query was using the index that was on another view. This was very interesting as I have personally never experienced a scenario like this. In simple words, “Query on the base table can use the index created... - [SQL SERVER - Insert Values of Stored Procedure in Table - Use Table Valued Function](https://blog.sqlauthority.com/2009/09/23/sql-server-insert-values-of-stored-procedure-in-table-use-table-valued-function/): I recently got many emails requesting to write a simple article. I also got a request to explain different ways to insert the values from a stored procedure into a table. Let us quickly look at the conventional way of doing the same with Table Valued Function. - [SQLAuthority News - Article 1100 and Community Service](https://blog.sqlauthority.com/2009/09/22/sqlauthority-news-article-1100-and-community-service/): This is 1100 the post of on my blog post on this blog. Just looking at the last 100 post of my blog, I have realized besides writing blog posts there are lots of other community events, I have been involved with. Let me quickly list few of the important community events and post, I have been involved with. There are three very important event in my life during last 100 posts. Three Very Important Event SQLAuthority News – 1000th Article Milestone – 8 Millions Views – Solid Quality Mentors SQLAuthority News – MVP Award Renewed SQLAuthority News – Shaivi Dave... - [SQL SERVER - Introduction to Service Broker and Sample Script](https://blog.sqlauthority.com/2009/09/21/sql-server-intorduction-to-service-broker-and-sample-script/): Service Broker in Microsoft SQL Server 2005 is a new technology that provides messaging and queuing functions between instances. The basic functions of sending and receiving messages forms a part of a “conversation.” Each conversation is considered to be a complete channel of communication. Each Service Broker conversation is considered to be a dialog where two participants are involved. Service broker find applications when single or multiple SQL server instances are used. This functionality helps in sending messages to remote databases on different servers and processing of the messages within a single database. In order to send messages between the instances,... - [SQL SERVER - Execution Plan and Results of Aggregate Concatenation Queries Depend Upon Expression Location](https://blog.sqlauthority.com/2009/09/20/sql-server-execution-plan-and-results-of-aggregate-concatenation-queries-depend-upon-expression-location/): I was reading the blog of Ward Pond, and I came across another note of Microsoft. I really found it very interesting. The given explanation was very simple; however, I would like to rewrite it again. Let us execute the following script. This script inserts two values ‘A’ and ‘B’ in the table and outputs a simple code to concatenate each other to produce the result ‘AB’. IF EXISTS( SELECT * FROM sysobjects WHERE name = 'T1' ) DROP TABLE T1 GO CREATE TABLE T1( C1 NCHAR(1)  ) INSERT T1 VALUES( 'A' ) INSERT T1 VALUES( 'B' ) DECLARE @Str0 VARCHAR(4) SET @Str0 =... - [SQLAuthority News - SQL Server Accelerator for Business Intelligence (BI) ](https://blog.sqlauthority.com/2009/09/19/sqlauthority-news-sql-server-accelerator-for-business-intelligence-bi/): I have wonderful experience at my recent Business Intelligence tour. I will write down in detail about my experience at different location. However, today I would like to talk about one particular question which was asked at all the locations. It was about SQL Server Accelerator for Business Intelligence (BI). Many attendee asked me how to use this tool. SQL Server Accelerator for Business Intelligence (BI) is no more supported by Microsoft. Microsoft does not provide any support for this solution accelerator and has no plans to release future versions. Microsoft SQL Server 2005 and later versions include most of the... - [SQLAuthority News - Community Tech Days Oct 3, 2009 - Ahmedabad](https://blog.sqlauthority.com/2009/09/18/sqlauthority-news-community-tech-days-oct-3-2009-ahmedabad/): Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Build real connections with Microsoft experts and community members, and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. What more... You can watch some of these sessions LIVE online, from the comfort of your workstation as well. - [SQL SERVER - Converting Stored Procedure into Table Valued Function](https://blog.sqlauthority.com/2009/09/17/sql-server-converting-stored-procedure-into-table-valued-function/): In one of my recent articles, I mentioned the use of Table Valued Function (TVF) instead of Stored Procedure (SP). I received a follow up email asking what type of SP can be converted into a TVF. This is indeed a very interesting question! In fact, not all the SPs qualify to be converted to a TVF. Please note that I am not encouraging to convert all the SPs to TVFs. Each SPs have their own usage and need. Here, I shall discuss about the type of SP that can be converted to a TVF. First of all, you need to... - [SQLAuthority News - Download Microsoft SQL Server StreamInsight CTP2](https://blog.sqlauthority.com/2009/09/16/sqlauthority-news-download-microsoft-sql-server-streaminsight-ctp2/): Note:   Download Microsoft SQL Server StreamInsight CTP2 by Microsoft Microsoft SQL Server StreamInsight is a platform for the continuous and incremental processing of unending sequences of events (event streams) from multiple sources with near-zero latency. These requirements, shared by vertical markets such as manufacturing, oil and gas, utilities, financial services, health care, web analytics, and IT and data center monitoring, make traditional store and query techniques impractical for timely and relevant processing of data. StreamInsight allows software developers to create innovative solutions in the domain of Complex Event Processing that satisfy these needs. It allows to monitor, mine, and develop insights... - [SQL SERVER - Cryptography in SQL Server 2008](https://blog.sqlauthority.com/2009/09/15/sql-server-cryptography-in-sql-server-2008/): SQL Server, particularly the 2005 and 2008 versions, offers the functionality of cryptography. In the following, this functionality is briefly explained. Introduction Any database professional will support the encryption of data. However, the encryption of data has to be carried out at the database engine level. This is quite tricky as there the database performance can be affected by the process of decryption, data manipulation, and then re-encryption when data is being updated. SQL Server offers robust data security. Further, it is important to have strong knowledge of cryptography in SQL Server in order to avoid many problems that are encountered... - [SQL SERVER - Plan Caching and Schema Change - An Interesting Observation](https://blog.sqlauthority.com/2009/09/14/sql-server-plan-caching-and-schema-change-an-interesting-observation/): Last week, I had published details regarding SQL SERVER – Plan Caching in SQL Server 2008 by Greg Low on this blog. Similar to any other white paper, I have read this paper very carefully and enjoyed reading it. One particular topic in the white paper that caught my attention is definition of schema change. I was well aware of this definition, but I have often found that users are not familiar with what exactly does a schema change mean. Many people assume that a change in the table structure is schema change. In fact, creating or dropping index on any... - [SQL SERVER - Introduction to Spatial Coordinate Systems: Flat Maps for a Round Planet](https://blog.sqlauthority.com/2009/09/13/sql-server-introduction-to-spatial-coordinate-systems-flat-maps-for-a-round-planet/): Introduction to Spatial Coordinate Systems: Flat Maps for a Round Planet SQL Server Technical Article Writers: Isaac Kunen Project Editor: Diana Steinmetz Published: July 2008 I recently read this very interesting white paper. I really found it very interesting as this one was one very easy to read and humourous white paper related to SQL Server. The white paper is starts with very interesting note regarding Columbus. Contrary to popular opinion, Columbus did not prove that the Earth is round. Pythagoras, Plato, and Aristotle claimed a round Earth based on philosophic and observational grounds. More impressively, Eratosthenes measured the Earth’s circumference... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2](https://blog.sqlauthority.com/2009/09/12/sqlauthority-news-risk-and-health-assessment-program-for-microsoft-sql-server-scoping-tool-v1-2/): This download package is intended for Microsoft Premier Customers Only. This package includes all of the scoping tools necessary to prepare and qualify your environment to receive a Risk and Health Assessment Program for Microsoft SQL Server. Download Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Why I am Going to Attend PASS Summit Unite 2009- Seattle](https://blog.sqlauthority.com/2009/09/11/sqlauthority-news-why-i-am-going-to-attend-pass-summit-unite-2009-seattle/): PASS Summit Unite2009 – the premier event for SQL Server professionals – will be held in Seattle from November 2 to 5. It is the largest and the most intensive Microsoft SQL Server conference in the world organized by SQL Server users for SQL Server users. This year marks the 10th Anniversary of PASS Community Summit, making the event even more special. Every year, this event sees a large number of attendees as apart from high quality technical sessions, it provides unparalleled access to the Microsoft SQL Server development, SQL CAT, and Customer Service and Support teams. PASS Summit is an... - [SQL SERVER - SQL Server Desktop Screen Background](https://blog.sqlauthority.com/2009/09/10/sql-server-sql-server-desktop-screen-background/): Buck Woody (MSFT) has published a blog post about SQL Server Desktop Screen Background. I really like the SQL Server Desktop background and I have replaced that background on my work laptop. I came across this particular post because I am a regular reader of his blog. Few of the other interesting posts written by him are following. - [SQL SERVER - Difference between SQL Server Express and MySQL](https://blog.sqlauthority.com/2009/09/09/sql-server-difference-between-sql-server-express-and-mysql/): Both SQL Server express and MySQL are two of the Relational Database Systems (RDBMS) available today. Both are freely available and meant for running smaller or embedded databases, yet there are also significant differences between them. - [SQLAuthority News - Shaivi Dave - Baby SQLAuthority](https://blog.sqlauthority.com/2009/09/08/sqlauthority-news-shaivi-dave-baby-sqlauthority/): Six days ago, on September 1st, 2009 07:03:40 AM, God blessed us with beautiful baby girl. As per Hindu Namkaran Sanskar (naming ritual), we have decided to name her as Shaivi Dave. Thank you all for all the wonderful suggestions for the baby name. Selecting the right name for the little one is really one of the most challenging tasks. According to Vedas, in Hindu religion, each occasion of a person’s life calls for elaborate rituals. After the birth of a child, naming ceremony or the Namkaran Samskar is considered one of the most important events. - [SQL SERVER - Importance of Database Schemas in SQL Server](https://blog.sqlauthority.com/2009/09/07/sql-server-importance-of-database-schemas-in-sql-server/): Beginning with SQL Server 2005, Microsoft introduced the concept of database schemas. A schema is now an independent entity- a container of objects distinct from the user who created those objects. Previously, the terms ‘user’ and ‘database object owner’ meant one and the same thing, but now the two are separate. This concept of separation of ‘user’ and ‘object owner’ may be a bit puzzling the first time one encounters it. Perhaps an example may better illustrate the concept: In SQL Server 2000, a schema was owned by, and was inextricably linked to, only one database principal (a principal is any... - [SQL SERVER - Find Gaps in The Sequence](https://blog.sqlauthority.com/2009/09/06/sql-server-find-gaps-in-the-sequence/): I have previously written two articles on the subject of missing identity and both are very well received by community. I had great fun to write article as many SQL Server expert participated in both the articles. Expert Imran Mohammed had provided excellent script to find missing identity. Please read both the articles for additional information before reading this article about finding gaps in the sequence. - [SQL SERVER - FIX - ERROR : Cannot drop the database because it is being used for replication. (Microsoft SQL Server, Error: 3724)](https://blog.sqlauthority.com/2009/09/05/sql-server-fix-error-cannot-drop-the-database-because-it-is-being-used-for-replication-microsoft-sql-server-error-3724/): I have set up replication at many different organization. One error I quite commonly face is after I have removed replication I can not remove database. When I try to remove the database it gives me following error. Cannot drop the database because it is being used for replication. (Microsoft SQL Server, Error: 3724) Fix/Workaround/Solution: The solution is very simple. Create the empty database with the same name on another server/instance first. Take full back of the same and forced restore over this database. Do let me know if you have any better idea or suggestion. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Designing SQL Server 2005 Analysis Services Cubes for Excel 2007 PivotTables](https://blog.sqlauthority.com/2009/09/04/sql-server-designing-sql-server-2005-analysis-services-cubes-for-excel-2007-pivottables/): In my recent Business Intelligence Training Roadshow August September 2009 I quite often get request to provide more details about Analysis Service Cubes for Excel 2007 PivotTable. Here is the white paper on the same subject. Microsoft Office Excel 2007 takes advantage of most of the features in Microsoft SQL Server 2005 Analysis Services. To take full advantage of these features, it is important to keep in mind the end-user experience in Office Excel 2007 when you are designing cubes. This document outlines how you can create a good end-user experience by optimizing the cube design for Office Excel 2007 PivotTable... - [SQL SERVER - What is Data Mining - A Simple Introductory Note](https://blog.sqlauthority.com/2009/09/03/sql-server-what-is-data-mining-a-simple-introductory-note/): According to MacLennan et al. (2009), data mining is defined as “the process of analyzing data to find hidden patterns using automatic methodologies.” Consider the following simple example that explains this concept. By analyzing the data on the items purchased from a supermarket or a chain of such stores, information on the products that are sold most can be obtained and accordingly supply of that particular products are increased and vice versa. Data mining, in short, is an analytical activity that studies the hidden patterns in a huge pile of data after appropriately classifying and sorting it. Who all are involved... - [SQL SERVER - Mirrored Backup and Restore and Split File Backup - Introduction](https://blog.sqlauthority.com/2009/09/02/sql-server-mirrored-backup-restore-split-file-backup-introduction/): Introduction - Mirrored Backup This article is based on a real life experience of the author while working with database backup and restore during his consultancy work for various organizations. We will go over the following important concepts of database backup and restore. Conventional Backup and Restore Spilt File Backup and Restore Mirror File Backup Understanding FORMAT Clause Miscellaneous details about Backup and Restore - [SQL SERVER - Download Script of Change Data Capture (CDC)](https://blog.sqlauthority.com/2009/09/01/sql-server-download-script-of-change-data-capture-cdc/): My article written on subject of Introduction to Change Data Capture (CDC) in SQL Server 2008 is quite a popular and I have received many request for uploading the script associated with this subject. - [SQLAuthority News - Baby SQLAuthority is here!](https://blog.sqlauthority.com/2009/09/01/sqlauthority-news-baby-sqlauthority-is-here/): September 1st, 2009 07:03:40 AM was one of the most beautiful moment of my life! God has graced us with baby girl. Nupur (my wife) and I am very happy today. We have no words to express our happiness. Baby girl and mother both are very healthy. We have yet to name our baby girl. Do you have any suggestions for Indian name? Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Effect of Oracle acquiring MySQL - A Delayed Analysis](https://blog.sqlauthority.com/2009/08/31/sqlauthority-news-effect-of-oracle-acquiring-mysql-a-delayed-analysis/): On 20 April 2009, Oracle Corporation announced its acquisition of Sun Microsystems in a deal worth about US$ 6 billion. This would have been just another one of corporate mega-deals that sound interesting in the news but really have no effect on your life. Except for the fact that with the purchase, Oracle acquired the world’s most widely used open-source database engine- MySQL. About 12 million small databases, mainly in websites and small businesses, run on the open-source MySQL platform, since it is stable, easily adaptable and most important of all for cash-strapped small companies, free. Note that ‘free’ here means... - [SQLAuthority News - Application and Multi-Server Management](https://blog.sqlauthority.com/2009/08/30/sqlauthority-news-application-and-multi-server-management/): SQL Server 2008 R2 – Application and Multi-Server Management SQL Server Technical Article Title: SQL Server 2008 R2Application and Multi-Server Management Introduction Writers: Geoff Allix Technical Reviewers: Joanne Hodgins, Omri Bahat, Morgan Oslake Published: February 2010 SQL Server 2008 R2 introduces new management tools to help improve IT efficiency and productivity. Investments in application and multi-server management will help organizations proactively manage database environments efficiently at scale through centralized visibility into resource utilization. Such investments can help streamline consolidation and upgrade initiatives across the application lifecycle—all with tools that make it fast and easy. This paper introduces the new extensions in... - [SQL SERVER - Plan Caching in SQL Server 2008](https://blog.sqlauthority.com/2009/08/29/sql-server-plan-caching-in-sql-server-2008-by-greg-low/): Plan Caching in SQL Server 2008 SQL Server Technical Article Writer:Greg Low, SolidQ Australia Technical Reviewers From Solid Quality Mentors: Andrew Kelly, Eladio Rincón, Itzik Ben-Gan Technical Reviewers From Microsoft: Adam Prout, Campbell Fraser, Xin Zhang Published: August 2009 - [SQL SERVER - Best Practices – Implementation of Database Object Schemas](https://blog.sqlauthority.com/2009/08/28/sql-server-best-practices-implementation-of-database-object-schemas/): SQL Server Best Practices – Implementation of Database Object Schemas SQL Server Technical Article Writer: Michael Redman Technical Reviewers: Sanjay Mishra, Juergen Thomas, Jimmy May, Burzin Patel, Glenn Berry (SQL Server MVP), Prem Mehra, Lindsey Allen, Thomas Kejser, Joseph Sack, Wanda He, Sharon Bjeletich Published: November 2008 - [SQL SERVER - Introduction to SQL Azure](https://blog.sqlauthority.com/2009/08/27/sql-server-introduction-to-sql-azure/): What is SQL Azure? In short, SQL Azure is simply a Microsoft branding change. SQL Services and SQL Data Services are now known as Microsoft SQL Azure and SQL Azure Database. There are a few changes, but fundamentally Microsoft’s plans to extend SQL server capabilities in cloud as web-based services remain intact. SQL Azure will continue to deliver an integrated set of services for relational databases. The reporting, analytics and data synchronization with end-users and partners also remains unchanged. This makes it most appealing to current users of SQL Server. SQL Azure is going to be the Next Big Thing from... - [SQL SERVER - SQL Server Express - A Complete Reference Guide](https://blog.sqlauthority.com/2009/08/26/sql-server-sql-server-express-a-complete-reference-guide/): SQL Server Express is one of the most valuable products of Microsoft. Very often, I face many questions with regard to SQL Server Express. Today, we will be covering some of the most commonly asked questions. - [SQLAuthority News - Business Intelligence Training Roadshow August September 2009](https://blog.sqlauthority.com/2009/08/25/sqlauthority-news-business-intelligence-training-roadshow-august-september-2009/): UPDATE : This is FREE training. I quite often receive request from readers and expert from all over the world if I do any training for SQL Server. Currently I am on Tour of 8 different stats of India and will be training on Business Intelligence Boot Camp. Here is quick image of the topics, which I am going to cover this boot camp. Currently, I am schedule to deliver the same course in many of the cities as described below. Let me know if you are interested in doing similar session at your city or organization and we can arrange... - [SQL SERVER - Index Seek vs. Index Scan - Diffefence and Usage - A Simple Note](https://blog.sqlauthority.com/2009/08/24/sql-server-index-seek-vs-index-scan-diffefence-and-usage-a-simple-note/): In this article we shall examine the two modes of data search and retrieval using indexes- index seek and index scan, and the differences between the two. - [SQLAuthority News - SQL Server 2008 Migration White Papers](https://blog.sqlauthority.com/2009/08/23/sqlauthority-news-sql-server-2008-migration-white-papers/): Quite often I get project when I am asked to migrate different database to SQL Server. Microsoft has excellent white papers written for this series. Guide to Migrating from MySQL to SQL Server 2008 In this migration guide you will learn the differences between the MySQL and SQL Server 2008 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2008 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2008. It describes the implementation differences of database... - [SQLAuthority News - Microsoft SQL Server 2008 Books Online](https://blog.sqlauthority.com/2009/08/22/sqlauthority-news-microsoft-sql-server-2008-books-online/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - Get Query Plan Along with Query Text and Execution Count](https://blog.sqlauthority.com/2009/08/21/sql-server-get-query-plan-along-with-query-text-and-execution-count/): Quite often, we need to know how many any particular objects have been executed on our server and what their execution plan is. I use the following handy script, which I use when I need to know the details regarding how many times any query has ran on my server along with its execution plan. You can add an additional WHERE condition if you want to learn about any specific object. - [SQL SERVER - FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.](https://blog.sqlauthority.com/2009/08/20/sql-server-fix-error-cannot-open-database-requested-by-the-login-the-login-failed-login-failed-for-user-nt-authoritynetwork-service/): This error is quite common and I have received it few times while I was working on a recent consultation project. Cannot open database requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’. This error occurs when you have configured your application with IIS, and IIS goes to SQL Server and tries to login with credentials that do not have proper permissions. This error can also occur when replication or mirroring is set up. If you search online, there are many different solutions provided to solve this error, and many of these solutions work fine. However,... - [SQLAuthority News - Two Virtual Tech Days Sessions - Watch it Online](https://blog.sqlauthority.com/2009/08/19/sqlauthority-news-two-virtual-tech-days-sessions-watch-it-online/): Indias premier online technical event is back again with the 6th Edition of Microsoft Virtual TechDays, scheduled to be held between August 19 -21, 2009. During these three days, you will have an opportunity to deep-dive into latest Microsoft Technologies and get a resolution to your most puzzling technical problems directly from the Technology Experts. I will be presenting two of the SQL Server Sessions on second day of the event on August 20th, 2009. SQL Server 2008: High Availability with SQL Server 2008 – “When, what where and how? Timing: 10:30am-11:45am Often in implementing High-Availability (HA) options with SQL Server... - [SQLAuthority News - Beyond Relational Interview on SQL Server 2008 Beyond Relational](https://blog.sqlauthority.com/2009/08/18/sqlauthority-news-beyond-relational-interview-on-sql-server-2008-beyond-relational/): SQL Server MVP and my personal friend Jacob Sebastian has published my interview on subject of Beyond Relational on his famous site Beyond Relational. Jacob is quite known for his T-SQL challenges as well. If you have not ever tried one, I suggest you give it a try and you will be addicted to it. Beyond Relational is interesting term. In simple terms, this means that it is beyond relations to traditional RDBMS. There are so many things to talk about when we stop thinking in terms of relationals. When we say “beyond relationals”, this does not mean that we move... - [SQL SERVER - Measure CPU Pressure - Detect CPU Pressure](https://blog.sqlauthority.com/2009/08/17/sql-server-measure-cpu-pressure-detect-cpu-pressure/): The CPU is responsible for not only SQL Server operations but also all the OS tasks related to the CPU. Let us learn about measuring CPU Pressure.  - [SQLAuthority News - Evaluate the Microsoft SQL Server 2008 R2 August Community Technology Preview (CTP)](https://blog.sqlauthority.com/2009/08/16/sqlauthority-news-evaluate-the-microsoft-sql-server-2008-r2-august-community-technology-preview-ctp/): SQL Server 2008 R2 expands on the value delivered in SQL Server 2008 to help your organization scale with confidence and improve IT and developer efficiency with new and enhanced tools for application and multi-server management, master data services and complex event processing. The new Self Service BI capabilities will empower end users to access, integrate, analyze and share information using business intelligence tools they already know – Microsoft Office. The August Customer Technology Preview (CTP) includes Application and Multi-server Management which will help organizations manage database environments efficiently at scale with increased visibility and control across the application lifecycle. The... - [SQL SERVER - Introduction to Change Data Capture (CDC) in SQL Server 2008](https://blog.sqlauthority.com/2009/08/15/sql-server-introduction-to-change-data-capture-cdc-in-sql-server-2008/): Simple-Talk.com has published my very first article on their site. This article is introducing Change Data Capture – the new concept introduced in SQL Server 2008. Change Data Capture records INSERTs, UPDATEs, and DELETEs applied to SQL Server tables, and makes a record available of what changed, where, and when, in simple relational ‘change tables’ rather than in an esoteric chopped salad of XML. These change tables contain columns that reflect the column structure of the source table you have chosen to track, along with the metadata needed to understand the changes that have been made. - [SQL SERVER - Find Table in Every Database of SQL Server - Part 2 Extension](https://blog.sqlauthority.com/2008/05/05/sql-server-find-table-every-database-sql-server-part-2-extension/): Long time blog reader and SQL Server Expert Simon Worth has suggested two additional method to achieve same results as described in article SQL SERVER – Find Table in Every Database of SQL Server. Method 1 sp_msforeachdb "SELECT '?' DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE '%address%'" Method 2 CREATE TABLE #TableNameResults (DatabaseName VARCHAR(100) NOT NULL, TableName VARCHAR(100) NOT NULL) INSERT INTO #TableNameResults EXEC sp_msforeachdb "SELECT '?' DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE '%address%'" SELECT * FROM #TableNameResults DROP TABLE #TableNameResults Reference : Pinal Dave (https://blog.sqlauthority.com), Simon Worth - [SQL SERVER - 2000 - SQL SERVER - Delete Duplicate Records - Rows - Readers Contribution](https://blog.sqlauthority.com/2008/05/04/sql-server-2000-sql-server-delete-duplicate-records-rows-readers-contribution/): I am proud on readers of this blog. One of the reader asked asked question on article SQL SERVER – Delete Duplicate Records – Rows and another reader followed up with nice quick answer. Let us read them both together. - [SQL SERVER 2005 - Vista Ultimate and SQL Server 2005 DEV Edition](https://blog.sqlauthority.com/2008/05/03/sql-server-2005-vista-ultimate-and-sql-server-2005-dev-edition/): I have been asked many times before “Does SQL Server Dev edition can be installed on Vista operating system?” I decided to find out the answer of this myself. I have just got new system which has Vista Ultimate Installed on it. I installed SQL Server 2005 dev edition on it. While installing it suggested that there are few component will not work with Vista and to make them work make sure to install SQL Server 2005 SP2. I was any way planning to install that. Once installation of SQL Server 2005 over, I installed SQL Server 2005 SP2. After restart... - [SQL SERVER - How to Rename Database Objects to Comply With Naming Conventions](https://blog.sqlauthority.com/2008/05/02/sql-server-how-to-rename-database-objects-to-comply-with-naming-conventions/): Christopher Miller read article of SQL SERVER Database Coding Standards and Guidelines Complete List Download and came up with wonderful SQL Server Script to rename all their database constraint with more organized constraint names, which helps to easily identify the constraint database exist on. Christopher Miller – “When we submit our schema updates internally, we usually catch any deviation from our naming conventions.  It’s not a perfect process and every now and then, something slips through the cracks.  We then correct the schema update to use the appropriate naming convention.  if we have been using the schema changes internally, we may... - [SQLAuthority News - Write for SQLAuthority](https://blog.sqlauthority.com/2008/05/01/sqlauthority-news-write-for-sqlauthority/): I always enjoy writing for my readers. Many times, I receive very good note, comments or article from my great experts of SQL Server. I really enjoy learning from my reader. If you are reader of SQLAuthority and you think you have knowledge, script or concept which benefit other readers of this blog, please feel free to send that to me. I love sharing good article and knowledge with my readers. You do not have to be well known to write article, just something which can interest other fellow readers like you, will be good article for this blog. It will... - [SQL SERVER - Find Table in Every Database of SQL Server - Part 2](https://blog.sqlauthority.com/2008/04/30/sql-server-find-table-in-every-database-of-sql-server-part-2/): Yesterday I wrote about SQL SERVER – Find Table in Every Database of SQL Server. Today we will see another method how we can achieve the same result using Information_Schema view. Refer my previous article here for additional information. CREATE PROCEDURE usp_FindTableNameInAllDatabase @TableName VARCHAR(256) AS DECLARE @DBName VARCHAR(256) DECLARE @varSQL VARCHAR(512) DECLARE @getDBName CURSOR SET @getDBName = CURSOR FOR SELECT name FROM sys.databases CREATE TABLE #TmpTable (TABLE_CATALOG VARCHAR(128), TABLE_SCHEMA VARCHAR(128), TABLE_NAME VARCHAR(256), TABLE_TYPE VARCHAR(10)) OPEN @getDBName FETCH NEXT FROM @getDBName INTO @DBName WHILE @@FETCH_STATUS = 0 BEGIN SET @varSQL = 'USE ' + @DBName + '; INSERT INTO #TmpTable SELECT *... - [SQL SERVER - Find Table in Every Database of SQL Server](https://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/): Just a day ago, one of the Jr. Developer requested that if I can help her with finding one particular table in every database on SQL Server. We have many Database Server and on some of the Database Server we have nearly 200 databases on it. The requirement was to find out one particular table from all the database. This was not possible by visual inspection as it might take lots of time and human error was possible. She was aware of the system view sys.tables. SELECT * FROM sys.Tables WHERE name LIKE '%Address%' The limitation of query mentioned above is... - [SQL SERVER - Download FAQ Sheet - SQL Server in One Page](https://blog.sqlauthority.com/2008/04/28/sql-server-download-faq-sheet-sql-server-in-one-page/): One of the most popular request I have received on this blog is to create one page which list all the SQL Server FAQs. SQL Server technology is very broad as well very deep. This is my humble attempt to list few of the daily used details in one page. Let me know your opinion and suggestion. Download SQL Server FAQ Sheet in PDF format Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query Analyzer Shortcuts - Part 2](https://blog.sqlauthority.com/2008/04/27/sql-server-query-analyzer-shortcuts-part-2/): I enjoy reader’s articles to read as much as I enjoy expert’s articles. One of blog reader Praveen Barath always have good ideas to share. Here is Praveen Barath’s comment on my previous article Query Analyzer Shortcuts. MSSQL server 2005 is a database platform , Platform because from one window you can connect to any of MSSQL services like SSMS, SSRS,SSIS,SSAS..etc. I am coming to your doubt why they shifted to SSMS as it s far slow. As the matter of fact MSSQL 2005 is more graphical more user friendly and handy tool, I hope once you will aware of all... - [SQL SERVER - Optimization Rules of Thumb - Best Practices - Reader's Article](https://blog.sqlauthority.com/2008/04/26/sql-server-optimization-rules-of-thumb-best-practices-readers-article/): This article has been written by blog reader and SQL Server Expert Praveen Barath in response to my previous article SQL SERVER – Optimization Rules of Thumb – Best Practices. Well Query Optimizations rules are not limited. It depends on business needs as well, For example we always suggest to have a relationship between tables but if they are heavily used for Update insert delete, I personally don’t recommended coz it will effect performance as I mentioned it all depends on Business needs; Here are few more tips I hope will help you to understand. One: only “tune” SQL after code... - [SQL SERVER - Optimization Rules of Thumb - Best Practices](https://blog.sqlauthority.com/2008/04/25/sql-server-optimization-rules-of-thumb-best-practices/): There are few rules for optimizing slow running query. Let us look at them one by one see how it can help. Rule # 1 : Always look at query plan first. I always start looking at query plan. There is always something which catches eyes. I pay special attention to part which has taken the most expensive part of whole execution plan. Rule # 2 : Table scan or clustered index scan needs to be optimized to table seek (if your table is small it does not matter and table scan gives you better result). Table scan happens when index... - [SQLAuthority News - Authors Personal Bookmarks](https://blog.sqlauthority.com/2008/04/25/sqlauthority-news-authors-personal-bookmarks/): Just like everybody else I also keep my personal bookmarks of websites. Recently I have reorganized my bookmarks in two categories. Please visit them and let me know your opinion. SQLAuthority BEST Articles SQLAuthority FAVORITE Articles Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Microsoft Office Visio 2007 Professional SQL Server Add-In](https://blog.sqlauthority.com/2008/04/24/sqlauthority-news-download-microsoft-office-visio-2007-professional-sql-server-add-in/): Note : Download Microsoft Office Visio 2007 Professional SQL Server Add-In by Microsoft Visio Infrastructure for SQL Servers is a tool which is meant for IT administrators who require constant interactions with the users for the installations of the SQL server in any IT infrastructure. Visio Infrastructure for SQL Servers is a tool which is meant for IT administrators who require constant interactions with the users for the installations of the SQL server in any IT infrastructure. This tool eases the constant communication between the end user and the administrator where administrators will have a ready to install visual representation of... - [SQL SERVER - Converting Subqueries to Joins](https://blog.sqlauthority.com/2008/04/23/sql-server-converting-subqueries-to-joins/): There is always more than one way to do one thing in any programming languages. In SQL Server there is always more than one way to achieve same result set. It is quite often I see that developers write subqueries in place of joins or joins in place subqueries. - [SQL SERVER - Join Better Performance - LEFT JOIN or NOT IN?](https://blog.sqlauthority.com/2008/04/22/sql-server-better-performance-left-join-or-not-in/): First of all answer this question : Which method of T-SQL is better for performance LEFT JOIN or NOT IN when writing a query? The answer is: It depends! It all depends on what kind of data is and what kind query it is etc. In that case just for fun guess one option LEFT JOIN or NOT IN. If you need to refer the query which demonstrates the mentioned clauses, review following two queries for Join Better Performance. - [SQL SERVER - 2008 - Update Resolving Conflict Between SQL Server 2005 and SQL Server 2008](https://blog.sqlauthority.com/2008/04/21/sql-server-2008-update-resolving-conflict-between-sql-server-2005-and-sql-server-2008/): I have been receiving many complains where user has installed SQL Server 2008 and when trying to install SQL Server 2005 after that installation never completed. Well, Microsoft has provided solution for this issue. Download the patch and install it first and then try to install SQL Server 2005 and it should install fine. Update for Windows Server 2008 for Itanium-based Systems (KB950636) Install this update to resolve an issue where SQL Server 2005 installation is not completed successfully on a system running Windows Server 2008. Update for Windows Server 2008 x64 Edition (KB950636) Install this update to resolve an issue... - [SQL SERVER - Identifiers As Valid Object Names](https://blog.sqlauthority.com/2008/04/20/sql-server-identifiers-as-valid-object-names/): Previous I wrote blog post about SQL SERVER – Explanation and Example Four Part Name. It was explaining the new feature of SQL Server 2005 of Schema. Few days ago I received email from Chi-Ho, Min of Taiwan, he suggested that he was successfully able to use column without completely specifying all the parts but just using servername…tablename. Please note the three dots (.) between servername and table. It was interesting what Chi-Ho observed so I decided to share with all of you. Please visit SQL SERVER – Explanation and Example Four Part Name for basic understanding of the four part... - [SQL SERVER - Is Cursor Database Object or Datatype?](https://blog.sqlauthority.com/2008/04/19/sql-server-is-cursor-database-object-or-datatype/): Whenever we want to loop something we always look for logic like WHILE LOOP or FOR LOOP. Trust me on my word that both of them are cursor when it is about SQL Server. - [SQL SERVER - Generate Foreign Key Scripts For Database](https://blog.sqlauthority.com/2008/04/18/sql-server-generate-foreign-key-scripts-for-database/): Regular reader of SQLAuthority.com blog Madhaiyan Seenivasan has send email with one very interesting script. This script generates all the foreign key addition script for your database. Many times there are situations where one need to drop all the foreign key and add them back. This SQL Script can be used for the same purpose. You can execute the SP by executing its name like EXEC DBO.SPGetForeignKeyInfo IF EXISTS ( SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[SPGetForeignKeyInfo]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) DROP PROCEDURE dbo.SPGetForeignKeyInfo GO CREATE PROCEDURE DBO.SPGetForeignKeyInfo AS /* Author : Seenivasan This procedure is used for Generating Foreign Key script. */ SET NOCOUNT ON DECLARE @FKName NVARCHAR(128) DECLARE @FKColumnName NVARCHAR(128)... - [SQLAuthority News - My Favorite Link of This Blog](https://blog.sqlauthority.com/2008/04/17/sqlauthority-news-my-favorite-link-of-this-blog/): I have written more than 500 article on this blog so far and the number is increasing. Many times I get this question, which one link do I click the most. It is very interesting for myself to read my previous articles, as I often like to read them and update it if I am missing anything or post a follow up articles or post a answer to any question in comment. There is no simple pattern for me to read my previous article. I like the random article of my blog. I use following link which send me to random... - [SQL SERVER - 2008 - Row Constructors - Load Temp Tables From Stored Procedures](https://blog.sqlauthority.com/2008/04/16/sql-server-2008-row-constructors-load-temp-tables-from-stored-procedures/): While playing with SQL Server 2008 I found new feature of “Row Constructors”, where I can load temp table from stored procedure directly. Look at the following SQL where I have to use OpenQuery from server to itself creating loopback server and execute stored procedure and insert into temp table. INSERT INTO #TempTable SELECT * FROM OPENQUERY(ServerName, 'exec StoredProc') Above mentioned same query can be now written with simpler statement as described here. INSERT INTO #TempTable EXEC StoredProc Note that this does not work with real tables or any other objects. This feature is only available to load temp tables. Reference... - [SQL SERVER - Surface Area Configuration Tools Reduce Exposure To Security Risks](https://blog.sqlauthority.com/2008/04/15/sql-server-surface-area-configuration-tools-reduce-exposure-to-security-risks/): Read my article published at SQL Server Magazine Surface Area Configuration Tools Reduce Exposure To Security Risks [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Slammer (Computer Worm)](https://blog.sqlauthority.com/2008/04/14/sql-server-sql-slammer-computer-worm/): Just a day ago, while talking with my outsourcing team one of the DBA asked me question. Is there any virus associated with SQL Server? I really find this question very interesting as I did not know if there are any viruses associated with SQL Server. I searched Google for this answer and I found link on wikipedia about SQL slammer, which is computer worm. Following excerpt is taken from wikipedia : The SQL slammer worm is a computer worm that caused a denial of service on some Internet hosts and dramatically slowed down general Internet traffic, starting at 05:30 UTC... - [SQL SERVER - 2008 - Important Resources](https://blog.sqlauthority.com/2008/04/13/sql-server-2008-important-resources/): In one of the recent public speaking event I was asked if I can list some important resources of SQL Server 2008. I promised that I will post the links on my blog. Here are Important Resources for SQL Server 2008. Learn more about data programmability http://www.microsoft.com/sql/2008/technologies/dataprogrammability.mspx Learn more about spatial data http://www.microsoft.com/sql/2008/technologies/spatial.mspx Learn more about SQL Server 2008 http://www.microsoft.com/sql/2008/default.mspx Discover SQL Server 2008: Webcasts, Virtual Labs, and White Papers http://www.microsoft.com/sql/2008/learning/default.mspx SQL Server 2008 training http://www.microsoft.com/learning/sql/2008/default.mspx Download latest SQL Server CTP http://www.microsoft.com/sql/2008/prodinfo/download.mspx Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Download Presentation and Whitepapers](https://blog.sqlauthority.com/2008/04/12/sql-server-2008-download-presentation-and-whitepapers/): SQL Server 2008 Manageability Learn about the new manageability improvements in SQL server 2008 that enables you to administer, monitor and maintain your data platform infrastructure while reducing the time and cost of management. This session provides an overview of the new manageability improvements that enables you to manage the infrastructure with policies, monitor and optimize your platform with insights and relevant information and scale your management across multiple servers. SQL Server 2008 Business Intelligence platform Learn how the new enhancements in SQL server 2008 provide a comprehensive and scalable Business Intelligence platform that enables you to integrate and manage your... - [SQL SERVER - 2005 - Find Database Collation Using T-SQL and SSMS - Part 2](https://blog.sqlauthority.com/2008/04/11/sql-server-2005-find-database-collation-using-t-sql-and-ssms-part-2/): Previously I have written two different ways to find database collation SQL SERVER – 2005 – Find Database Collation Using T-SQL and SSMS. One of blog reader jwwishart has posted another method for doing the same. SELECT collation_name FROM sys.databases WHERE name = 'AdventureWorks' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Restore Database Using Corrupt Datafiles (.mdf and .ldf) - Part 2](https://blog.sqlauthority.com/2008/04/10/sql-server-2005-restore-database-using-corrupt-datafiles-mdf-and-ldf-part-2/): Blog reader Donald Crowther has posted following comment. I have not tested this solution and when I tried to test it, it did not work for me. However, I have received email from two of my Jr. DBA who have done experiment about this and they are suggesting it works. If you have tried everything and you have given up to find solution. Try following suggestion. Make sure you have taken backup of your physical file and also this exercise you do at your own risk. ALTER DATABASE test SET emergency GO ALTER DATABASE test SET single_user GO DBCC checkdb (test,... - [SQL SERVER - 2005 - Connection Strings For .NET](https://blog.sqlauthority.com/2008/04/09/sql-server-2005-connection-strings-for-net/): SQL Native Client ODBC Driver Standard security Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Uid=myUsername;Pwd=myPassword; Trusted Connection Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes; Connecting to an SQL Server instance Driver={SQL Native Client};Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes; SQL Native Client OLE DB Provider Standard security Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase; Uid=myUsername;Pwd=myPassword; Trusted connection Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes; Connecting to an SQL Server instance Provider=SQLNCLI;Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes; SqlConnection (.NET) Standard Security Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; Trusted Connection Server=myServerAddress;Database=myDataBase;Trusted_Connection=True; Connecting to an SQL Server instance Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=True; Connecting to an SQL Server instance via an IP address Data Source=192.168.1.100,1433;Network Library=DBMSSOCN; Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword; Reference : Pinal Dave (https://blog.sqlauthority.com), ConnectionStrings - [SQL SERVER - Change Order of Column In Database Tables](https://blog.sqlauthority.com/2008/04/08/sql-server-change-order-of-column-in-database-tables/): One question I received quite often. How to change the order of the column in database table? It happens many times table with few columns is already created. After a while there is need to add new column to the previously existing table. Sometime it makes sense to add new column in middle of columns at specific places. There is no direct way to do this in SQL Server currently. Many users want to know if there is any workaround or solution to this situation. First of all, If there is any application which depends on the order of column it... - [SQL SERVER - 2005 - Restore Database Using Corrupt Datafiles (.mdf and .ldf)](https://blog.sqlauthority.com/2008/04/07/sql-server-2005-restore-database-using-corrupt-datafiles-mdf-and-ldf/): Just received question from one of the DBA Question: I do not have full backup of my database. My .mdf and .ldf are corrupted. Is there any way I can restore database now? Answer: Sorry. I do not think there is any way you can do it. Try attaching this files to database using db_attach but if that does not work, it will be very difficult make it work. If any of blog reader know fix for this, please post here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 15 Best Practices for Better Database Performance](https://blog.sqlauthority.com/2008/04/06/sql-server-15-best-practices-for-better-database-performance/): In this blog post we will see 15 best practices for better Database Performance. - [SQL SERVER - 2005 - Transferring Ownership of a Schema to a User](https://blog.sqlauthority.com/2008/04/05/sql-server-2005-transferring-ownership-of-a-schema-to-a-user/): One of the blog reader asked me how transfer of ownership of schema to another users. Follow the simple script and you will be able to transfer ownership of schema to another user. ALTER AUTHORIZATION ON SCHEMA::SchemaName TO UserName; GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL Server - Good Articles on Database Collation](https://blog.sqlauthority.com/2008/04/04/sql-server-good-articles-collation-databases/): I often get asked what is Database Collation in SQL Server and if there are some good articles related to Collation. Here are some articles. - [SQLAuthority News - Learn New Things - Self Criticism](https://blog.sqlauthority.com/2008/04/03/sqlauthority-news-learn-new-things-self-criticism/): I came across two interesting web pages and I really thought they had very good articles. I would like to share that with my blog readers today. I am just listing the abstract here. Please read the original articles they are much more interesting and enjoyable. Readers if you find any interesting site like this, let me know and I will write about it. 10 Ways to Learn New Things in Development 1. Read books. 2. Read Code 3. Write Code 4. Talk to other developers 5. Teach others 6. Listen to podcasts 7. Read blogs 8. Learn a new language... - [SQL SERVER - Find Nth Highest Salary of Employee - Query to Retrieve the Nth Maximum value](https://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/): This question is quite a popular question and it is interesting that I have been receiving this question every other day. I have already answer this question here. “How to find Nth Highest Salary of Employee”. Please read my article here to find Nth Highest Salary of Employee table : SQL SERVER – Query to Retrieve the Nth Maximum value I have re-wrote the same article here with example of SQL Server 2005 Database AdventureWorks : SQL SERVER – 2005 – Find Nth Highest Record from Database Table Just a day ago, I have received another script to get the same... - [SQL SERVER - Microsoft SQL Server 2000/2005 Management Pack Download](https://blog.sqlauthority.com/2008/04/01/sql-server-microsoft-sql-server-20002005-management-pack-download/): The SQL Server Management Pack monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems. Availability and performance monitoring is done using synthetic transactions. In addition, the Management Pack collects Event Log alerts and provides associated knowledge articles with additional user details, possible causes, and suggested resolutions. The Management Pack discovers Database Engines, Database Instances, and Databases and can optionally discover Database File and Database File Group objects. Feature Summary: • Active Directory Helper Service • SQL Server Agent • Backup • Databases and Tables • DBCC • Full Text Search • Log... - [SQL SERVER - Popular Articles of SQLAuthority Blog](https://blog.sqlauthority.com/2008/03/31/sql-server-popular-articles-of-sqlauthority-blog/): I receive this email quite often that which are most popular articles on my blog. There is already list on right navigation bar of my weekly popular article. If you are interested to know which are most popular articles as per readers and my opinion here are two listed. SQL SERVER Database Coding Standards and Guidelines Complete List Download SQL Server Interview Questions and Answers Complete List Download Let me know which articles is your favorite article on this blog. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Heap Structure - What is Heap?](https://blog.sqlauthority.com/2008/03/30/sql-server-introduction-to-heap-structure-what-is-heap/): Sometime simple questions are very interesting. A day ago, jr. developer asked me question : What is Heap? In SQL Server 2005 data is stored within tables. Data within a table is grouped together into allocation unites based on their column data types, what it means is one kind of data types are stored together in allocation unites. Data within this allocation unit is stored in pages. Each pages are of size 8KB. Group of 8 pages is stored together and they are referred as Extent. Pages within a table store the data rows with structure which helps to search/locate data... - [SQL SERVER - 2005 - List All Column With Identity Key In Specific Database](https://blog.sqlauthority.com/2008/03/29/sql-server-2005-list-all-column-with-indentity-key-in-specific-database/): Question I received in Email : How to list all the columns in the database which are used as identity key in my database? - [SQL SERVER - Introduction to sys.dm_exec_query_optimizer_info](https://blog.sqlauthority.com/2008/03/28/sql-server-2005-introduction-to-sysdm_exec_query_optimizer_info/): Many times when I am just bored I surf Book On Line for SQL Server 2005. Almost all the time I find something new which makes me believe that I have lot to learn and there are so many things I am not aware of. Today I found system catalog view sys.dm_exec_query_optimizer_info. I just enjoyed reading about it and now I will share this with you. - [SQL SERVER - 2005 - Find Index Fragmentation Details - Slow Index Performance](https://blog.sqlauthority.com/2008/03/27/sql-server-2005-find-index-fragmentation-details-slow-index-performance/): Just a day ago, while using one index I was not able to get the desired performance from the table where it was applied. I just looked for its fragmentation and found it was heavily fragmented. After I reorganized index it worked perfectly fine. Here is the quick script I wrote to find fragmentation of the database for all the indexes. SELECT ps.database_id, ps.OBJECT_ID, ps.index_id, b.name, ps.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS ps INNER JOIN sys.indexes AS b ON ps.OBJECT_ID = b.OBJECT_ID AND ps.index_id = b.index_id WHERE ps.database_id = DB_ID() ORDER BY ps.OBJECT_ID GO You can REBUILD or... - [SQLAuthority News - Few Links About SQLAuthority](https://blog.sqlauthority.com/2008/03/26/sqlauthority-news-few-links-about-sqlauthority/): I have listed few important links of SQLAuthority.com, I still receive some repeated questions. I do my best to respond to all of my readers, however, most of the time I am sending them link to one of my previously written article. Many times most of the answers can be found right away by searching in this blog. I have created special search engine, which exclusively searches in this blog. Search SQLAuthority.com – http://search.sqlauthority.com Finding good database developer job is very hard and finding good database developer is even harder. For the same reason I have attempted to created only SQL... - [SQL SERVER - Simple Puzzle Using Union and Union All - Answer](https://blog.sqlauthority.com/2008/03/25/sql-server-simple-puzzle-using-union-and-union-all-answer/): Yesterday I posted a puzzle SQL SERVER – Simple Puzzle Using Union and Union All, today we will see the answer of this. Following image explains the answer of puzzle. You can read the explanation of why this is answer read my previous article SQL SERVER – Union vs. Union All – Which is better for performance? Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Simple Puzzle Using Union and Union All](https://blog.sqlauthority.com/2008/03/24/sql-server-simple-puzzle-using-union-and-union-all/): I often get request to write puzzles using SQL Server. Today, I am presenting one very simple but very interesting puzzle. What will be the output of following two SQL Scripts. First try to answer without running this two script in Query Editor. Script 1 SELECT 1 UNION ALL (SELECT 1 UNION SELECT 2) GO Script 2 (SELECT 1 UNION ALL SELECT 1) UNION SELECT 2 GO Hint : This puzzle is based on my previous article SQL SERVER – Union vs. Union All – Which is better for performance? Answer : SQL SERVER – Simple Puzzle Using Union and Union... - [SQL SERVER - 2005 - Mechanisms to Ensure Integrity and Consistency of Databases - Locking and Row Versioning](https://blog.sqlauthority.com/2008/03/23/sql-server-2005-mechanisms-to-ensure-integrity-and-consistency-of-databases-locking-and-row-versioning/): Today I was going through Book On Line while researching something, I come across one interesting small article about two mechanisms to ensure integrity and consistency of databases – 1) Locking 2) Row Versioning Let us see their definition from Book Online Itself. Locking Each transaction requests locks of different types on the resources, such as rows, pages, or tables, on which the transaction is dependent. The locks block other transactions from modifying the resources in a way that would cause problems for the transaction requesting the lock. Each transaction frees its locks when it no longer has a dependency on... - [SQL SERVER - 2005 - Find Highest / Most Used Stored Procedure](https://blog.sqlauthority.com/2008/03/22/sql-server-2005-find-highest-most-used-stored-procedure/): How many times we all DBA’s might have wonder which stored procedure is executing most in the database? I have wondered it often and I have written following small script which gives me answer to my above questions. I am also retrieving few additional data along with the highest used SP names. You can change the name of the database from AdventureWorks to any database which you are curious about. If WHERE clause is completely removed it will give results for all the database. SELECT TOP 10 qt.TEXT AS 'SP Name', qs.execution_count AS 'Execution Count', qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime', qs.total_worker_time AS 'TotalWorkerTime',... - [SQL SERVER - Introduction to Live Lock - What is Live Lock?](https://blog.sqlauthority.com/2008/03/21/sql-server-introduction-to-live-lock-what-is-live-lock/): Some questions are very interesting to answer. I just received following question in Email. What is Live Lock? A Live lock is one, where a request for exclusive lock is denied continuously because a series of overlapping shared locks keeps on interfering each other and to adapt from each other they keep on changing the status which further prevents them to complete the task. In SQL Server Live Lock occurs when read transactions are applied on table which prevents write transaction to wait indefinitely. This is different then deadlock as in deadlock both the processes wait on each other. A human... - [SQLAuthority News - Book Review - Joe Celkos SQL Puzzles and Answers, Second Edition, Second Edition](https://blog.sqlauthority.com/2008/03/20/sqlauthority-news-book-review-joe-celkos-sql-puzzles-and-answers-second-edition-second-edition/): Joe Celko’s SQL Puzzles and Answers, Second Edition, Second Edition (The Morgan Kaufmann Series in Data Management Systems) (Paperback) by Joe Celko (Author) Link to Amazon Short Review: This book is for all of them who enjoy little puzzles or just something which gives them challenge. Some puzzles took hours to solve and some were straight forward. This book teaches you some basic principles and patterns as well satisfy your need for brain teasers. Detail Review: This book for all the SQL programmers regardless of database language you prefer. Book contains examples in different languages (SQL Server, Oracle, Sybase, Informix etc).... - [SQL SERVER - Add Column With Default Column Constraint to Table](https://blog.sqlauthority.com/2008/03/19/sql-server-add-column-with-default-column-constraint-to-table/): Just a day ago while working with database Jr. Developer asked me question how to add column along with column constraint. He also wanted to specify the name of the constraint. The newly added column should not allow NULL value. He requested my help as he thought he might have to write many lines to achieve what was requested. - [SQL SERVER - 2005 - Analysis Services Query Performance Top 10 Best Practices](https://blog.sqlauthority.com/2008/03/18/sql-server-2005-analysis-services-query-performance-top-10-best-practices/): Analysis Services Query Performance Top 10 Best Practices Optimize cube and measure group design Define effective aggregations Use partitions Write efficient MDX Use the query engine cache efficiently Ensure flexible aggregations are available to answer queries. Tune memory usage Tune processor usage Scale up where possible Scale out when you can no longer scale up Technet Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download White Papers - Migration from MySQL, Oracle, Sybase, or Microsoft Access to Microsoft SQL Server](https://blog.sqlauthority.com/2008/03/17/sqlauthority-news-download-white-papers-migration-from-mysql-oracle-sybase-or-microsoft-access-to-microsoft-sql-server/): Note : Download White Papers by Microsoft Guide to Migrating from MySQL to SQL Server 2005 This migration guide explains the differences between the MySQL and SQL Server 2005 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2005 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2005. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. Guide to Migrating from Sybase ASE to SQL Server 2005 This... - [SQL SERVER - 2005 - Retrieve Any User Defined Object Details Using sys objects Database](https://blog.sqlauthority.com/2008/03/16/sql-server-2005-retrieve-any-user-defined-object-details-using-sysobjects-database/): sys.objects object catalog view contains a row for each user-defined, schema-scoped object that is created within a database. You can retrieve any user defined object details by querying sys.objects database. Let us see one example of sys.objects database usage. You can run following query to retrieve all the information regarding name of foreign key, name of the table it FK belongs and the schema owner name of table. USE AdventureWorks; GO SELECT name AS ObjectName, OBJECT_NAME(schema_id) SchemaName, OBJECT_NAME(parent_object_id) ParentObjectName, name, * FROM sys.objects WHERE type = 'F' GO You can use any of the following in your WHERE clause and retrieve... - [SQL SERVER - 2005 - Retrieve Processes Using Specified Database](https://blog.sqlauthority.com/2008/03/15/sql-server-2005-retrieve-processes-using-specified-database/): Blog Reader Jim Sz posted quick but very interesting script. If user want to know how many processes are there in any particular database it can be retrieved querying sys.processes database. USE master GO DECLARE @dbid INT SELECT @dbid = dbid FROM sys.sysdatabases WHERE name = 'AdventureWorks' IF EXISTS (SELECT spid FROM sys.sysprocesses WHERE dbid = @dbid) BEGIN SELECT 'These processes are using current database' AS Note, spid, last_batch, status, hostname, loginame FROM sys.sysprocesses WHERE dbid = @dbid END GO Reference : Pinal Dave (https://blog.sqlauthority.com), Jim Sz - [SQL SERVER - 2005 - What is CLR?](https://blog.sqlauthority.com/2008/03/14/sql-server-2005-clr/): CLR is Common Language Runtime. Here is the diagram which explains the architecture of the CLR. - [SQL SERVER - FIX : Error : 3702 Cannot drop database because it is currently in use - Part 2](https://blog.sqlauthority.com/2008/03/13/sql-server-fix-error-3702-cannot-drop-database-because-it-is-currently-in-use-part-2/): Following error is very generic error and I have previously written SQL SERVER – FIX : Error : 3702 Cannot drop database because it is currently in use. Msg 3702, Level 16, State 3, Line 2 Cannot drop database “DataBaseName” because it is currently in use. One of the reader Dave have posted additional information in comments. I will list his advise here. First read the original post here. If you are still getting the error after you try using USE master GO DROP DATABASE (databaseName) GO Close SQL Server Management Studio completely. Open it again and connect as normal. Now... - [SQL SERVER - 2005 - Find Nth Highest Record from Database Table - Using Ranking Function ROW_NUMBER](https://blog.sqlauthority.com/2008/03/12/sql-server-2005-find-nth-highest-record-from-database-table-using-ranking-function-row_number/): I have previously written SQL SERVER – 2005 – Find Nth Highest Record from Database Table where I have shown query to find 4th highest record from database table. Everytime when I write blog I am always very eager to read comments of readers. Some of regular readers are industry leaders and and their comments always teach us all something new. One of them is Nicholas Paldino [.NET/C# MVP]. He has always provided valuable solution and comments to this blog. His recent comment about finding Nth Highest Record is quite an interesting. USE AdventureWorks GO SELECT t.* FROM ( SELECT e1.*,... - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - Part 3](https://blog.sqlauthority.com/2008/03/11/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql-part-3/): Please read SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL before continuing this article. I had asked users to come up with alternate solution of the same problem. Khadar Khan came up with good solution using CTE SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL – Part 2. Today we will see the solution suggested by Dave Arthur. This solution is quite good as it uses UNION ALL instead of OR clause. USE AdventureWorks GO SELECT A.* FROM ( SELECT TOP 1 * FROM Sales.SalesOrderDetail ORDER BY SalesOrderDetailID) A UNION ALL SELECT B.*... - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - Part 2 - CTE](https://blog.sqlauthority.com/2008/03/10/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql-part-2/): Please read SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL before continuing this article. I had asked users to come up with an alternate solution of the same problem. In this blog post we will see solution with the help of CTE.  - [SQLAuthority News - Authors Most Visited Article on Blog](https://blog.sqlauthority.com/2008/03/09/sqlauthority-news-authors-most-visited-article-on-blog/): I received many emails regarding SQLAuthority News – 500th Post – An Interesting Journey with SQL Server. One of the email asked interesting question regarding my most visited article on this blog. It was interesting to know that reader wants to know which article I visit the most. Following is the link to the article which I personal visit most of the time while working as Principal Database Administrator. SQL SERVER – 2005 – Search Stored Procedure Code – Search Stored Procedure Text Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Nth Highest Record from Database Table](https://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/): I had previously written SQL SERVER - Query to Retrieve the Nth Maximum value. I just received an email that if I can write this using AdventureWorks database as it is a default sample database for SQL Server 2005 and the user can run the query against it and understand it better. Let us see how we can find highest record from database. - [SQLAuthority News - 500th Post - An Interesting Journey with SQL Server](https://blog.sqlauthority.com/2008/03/07/sqlauthority-news-500th-post-an-interesting-journey-with-sql-server/): I am very pleased to write my 500th post. After 500 posts, I still have same feeling when I wrote first post on this blog. I would like to thank my family for their continuous support in writing this blog. Most of all I want to thank all of YOU for being wonderful readers of this blog, without your continuous participation and communication, this blog could not be what it is right now. THANK YOU. Some of the milestones in this wonderful Journey to SQL Authority. Search SQLAuthority Feature to search exclusively SQLAuthoritive.com. Readers can search the blog for immediate answers.... - [SQLAuthority News - SQL Server 2005 is The Data Platform Leader](https://blog.sqlauthority.com/2008/03/06/sqlauthority-news-sql-server-2005-is-the-data-platform-leader/): Questions I often get asked : How big is market for SQL Server? Is SQL Server industry leader? Does learning SQL Server technology will help future career? Why did you pick SQL Server as your expertise? I just love SQL Server. Let us read following article taken directly from Microsoft, which explains why SQL Server is Data Platform Leader. Microsoft is positioned in Leaders Quadrant for Magic Quadrant for Business Intelligence Platforms, 2008 Microsoft is positioned in Leaders Quadrant for Magic Quadrant for Data Warehouse Database Management Systems, 2007 SQL Server is the fastest growing Database and Business Intelligence vendor SQL... - [SQL SERVER - Simple Example of Cursor - Sample Cursor Part 2](https://blog.sqlauthority.com/2008/03/05/sql-server-simple-example-of-cursor-sample-cursor-part-2/): I have recently received email that I should update SQL SERVER – Simple Example of Cursor with example of AdventureWorks database. Simple Example of Cursor using AdventureWorks Database is listed here. USE AdventureWorks GO DECLARE @ProductID INT DECLARE @getProductID CURSOR SET @getProductID = CURSOR FOR SELECT ProductID FROM Production.Product OPEN @getProductID FETCH NEXT FROM @getProductID INTO @ProductID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @ProductID FETCH NEXT FROM @getProductID INTO @ProductID END CLOSE @getProductID DEALLOCATE @getProductID GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold](https://blog.sqlauthority.com/2008/03/04/sql-server-2005-a-simple-way-to-defragment-all-indexes-in-a-database-that-is-fragmented-above-a-declared-threshold/): Just a day ago, I received email from regular reader Rajiv Kayasthy about a script which demonstrates the A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold. He found this script on TechNet BOL and was attempting to run on SQL Server but was getting continuous error Msg 2501, Level 16, State 45, Line 1 Cannot find a table or object with the name “TableName”. Check the system catalog. After looking at the script provided on BOL I found that it has very small error. It was retrieving data without prefixing database schema.... - [SQL SERVER - Sharpen Your Basic SQL Server Skills - Learn the distinctions between unique constraint and primary key constraint and the easiest way to get random rows from a table](https://blog.sqlauthority.com/2008/03/03/sql-server-sharpen-your-basic-sql-server-skills-learn-the-distinctions-between-unique-constraint-and-primary-key-constraint-and-the-easiest-way-to-get-random-rows-from-a-table/): Read my article in SQL Server Magazine March 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL](https://blog.sqlauthority.com/2008/03/02/sql-server-how-to-retrieve-top-and-bottom-rows-together-using-t-sql/): Just a day ago, while working with some inventory related projects, I faced one interesting situation. I had to find TOP 1 and BOTTOM 1 record together. I right away that I should just do UNION but then I realize that UNION will not work as it will only accept one ORDER BY clause. If you specify more than one ORDER BY clause. It will give an error. Let us see how we can retrieve top and bottom rows together. - [SQL SERVER - Transfer The Logins and The Passwords Between Instances of SQL Server 2005](https://blog.sqlauthority.com/2008/03/01/sql-server-transfer-the-logins-and-the-passwords-between-instances-of-sql-server-2005/): This question was asked to me by one of reader. “I just upgraded my server with better hardware and newer operating system. How can I transfer the logins and the passwords between two of my SQL Server?” I think Microsoft has wonderful documentation for this issue. kb 918992 I will briefly describe the solution here : Run the script in Query Editor. It will generate the script of username and password in the windows. USE master GO IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL DROP PROCEDURE sp_hexadecimal GO CREATE PROCEDURE sp_hexadecimal @binvalue varbinary(256), @hexvalue varchar(256) OUTPUT AS DECLARE @charvalue varchar(256) DECLARE @i... - [SQL SERVER - Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial](https://blog.sqlauthority.com/2008/02/29/sql-server-introduction-to-sql-server-encryption-and-symmetric-key-encryption-tutorial/): SQL Server 2005 provides encryption as a new feature to protect data against the attacks of hackers. Hackers may be able to get hold of the database or tables, but they wouldn’t understand the data or be able to use it. It is very important to encrypt crucial security related data when stored in the database, as well while transmitting across a network between the client and the server. Read my complete article here : Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Dynamic Case Statement - FIX : ERROR 156 : Incorrect syntax near the keyword](https://blog.sqlauthority.com/2008/02/28/sql-server-dynamic-case-statement-fix-error-156-incorrect-syntax-near-the-keyword/): One of my friend sent me query asking me how to generate dynamic case statements in SQL. Every time he tries to run following query he is getting Error 156 : Incorrect syntax near the keyword. He was frustrated with following two queries. There are two different ways to solve the problem when user want to Incorrect Query 1 : USE AdventureWorks GO DECLARE @OrderDirection VARCHAR(5) SET @OrderDirection = ‘DESC’ SELECT * FROM Production.WorkOrder WHERE ProductID = 722 ORDER BY OrderQty CASE WHEN @OrderDirection = ‘DESC’ THEN DESC ELSE ASC END GO ResultSet: Msg 156, Level 15, State 1, Line 8... - [SQLAuthority News - SQL Server 2008 R2 Support Ends on July 9, 2019](https://blog.sqlauthority.com/2008/02/27/sqlauthority-news-sql-server-2008-r2-support-ends-on-july-9-2019/): It is indeed true Microsoft will official support ends of the product on July 9, 2019. Comprehensive Database Performance Health Check.  - [SQL SERVER - SELECT 1 vs SELECT * - An Interesting Observation](https://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/): Many times I have seen issue of SELECT 1 vs SELECT * discussed in terms of performance or readability while checking for existence of rows in table. I ran quick 4 tests about this observed that I am getting same result when used SELECT 1 and SELECT *. I think smart readers of this blog will come up the situation when SELECT 1 and SELECT * have different execution plan when used to find existence of rows. - [SQLAuthority News - Latest SQL Server Management Studio Blogs](https://blog.sqlauthority.com/2008/02/25/sqlauthority-news-latest-sql-server-management-studio-blogs/): SQL Server Management Studio is an amazing product and I am personally a big fan of the same. Here are the few latest blog written on the same subject. - [SQL SERVER - 2005 - Licensing Model Compared to Other Database Products](https://blog.sqlauthority.com/2008/02/24/sql-server-2005-licensing-model-compared-to-other-database-products/): Yesterday on this blog I wrote about SQL SERVER – 2005 – Understanding Licensing Model. I have received many questions about pricing and comparing SQL Server with other RDBMS. One of the reason I like SQL Server because I am strong believer of licensed software usage and SQL Server is feature rich and dirt cheap compared to other comparable products. Let us review following chart and table which explains the difference. https://www.microsoft.com/en-us/sql-server/sql-server-2016 If you are interested to read about more about this you can review original article from where I have taken above information. Reference : Pinal Dave (https://blog.sqlauthority.com) , SQL... - [SQL SERVER - Understanding Licensing Models](https://blog.sqlauthority.com/2008/02/23/sql-server-understanding-licensing-models/): The licensing structure has evolved to reflect advances in technology and diverse use cases. Below are the primary licensing models available: - [SQL SERVER - Find All The User Defined Functions (UDF) - Part 2](https://blog.sqlauthority.com/2008/02/22/sql-server-find-all-the-user-defined-functions-udf-part-2/): Few days ago, I wrote about SQL SERVER – Find All The User Defined Functions (UDF) in a Database. Regular reader of this blog Madhivanan has suggested following alternate method to do the same task of finding all the user defined functions in database. USE AdventureWorks GO SELECT specific_name,specific_schema FROM information_schema.routines WHERE routine_type='function' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download SQL Server 2017](https://blog.sqlauthority.com/2008/02/21/sqlauthority-news-download-sql-server-2017/): This was a very old blog post and I have decided to re-write this as it was no longer useful. In this blog post, we will learn about SQL Server 2017. Here is how you can download SQL Server 2017 related material. - [SQLAuthority New - SQL Server 2008 Books Online CTP (February 2008)](https://blog.sqlauthority.com/2008/02/21/sqlauthority-new-sql-server-2008-books-online-ctp-february-2008/): Download a Community Technology Preview (CTP) version of the documentation and tutorials for Microsoft SQL Server 2008. SQL Server 2008 Books Online CTP (February 2008) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF to Return a Calendar for Any Date for Any Year](https://blog.sqlauthority.com/2008/02/20/sql-server-udf-to-return-a-calendar-for-any-date-for-any-year/): It gives me great pleasure to write articles like today’s one because I have received great comment from one of regular reader who has taken UDF written by me and created another UDF using that UDF which enhances functionality of it. I had written previous article about SQL SERVER – UDF – Function to Display Current Week Date and Day – Weekly Calendar. Reader of this blog and great SQL expert Dan Golden has wrote another UDF which uses UDF written by me. I thank Dan Golden for his contribution to this blog. I have modified his function a bit to... - [SQL SERVER - 2005 - FIX: Error message when you run a query against a table that does not have a clustered index in SQL Server 2005: "A severe error occurred on the current command"](https://blog.sqlauthority.com/2008/02/19/sql-server-2005-fix-error-message-when-you-run-a-query-against-a-table-that-does-not-have-a-clustered-index-in-sql-server-2005-a-severe-error-occurred-on-the-current-command/): In SQL Server 2005 while testing Indexes I had created a table with one non clustered index only. I did not create any clustered index on table. After that I ran SELECT statement, it gave me following error. I was very surprised when I looked at error. It says Msg 0, what it means is that this error is not known error to Microsoft and it might be bug. Msg 0, Level 11, State 0, Line 0 A severe error occurred on the current command. The results, if any, should be discarded. Msg 0, Level 20, State 0, Line 0 A... - [SQLAuthority News - Download SQL Server 2008 February CTP (CTP 6)](https://blog.sqlauthority.com/2008/02/18/sqlauthority-news-download-sql-server-2008-february-ctp-ctp-6/): SQL Server 2008 February CTP (CTP 6) has been released. Download from here. It will direct you to page which is dated November 2007. Continue with November 2007 which will take you to February 2008 CTP 6 Download page. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - How to Escape Single Quotes - Fix: Error: 105 Unclosed quotation mark after the character string](https://blog.sqlauthority.com/2008/02/17/sql-server-how-to-escape-single-quotes-fix-error-105-unclosed-quotation-mark-after-the-character-string/): Jr. Developer asked me other day how to escape single quote? User can escape single quote using two single quotes (NOT double quote). - [SQL SERVER - Msg: 2593 : There are ROWCOUNT rows in PAGECOUNT pages for object 'OBJECT'.](https://blog.sqlauthority.com/2008/02/16/sql-server-msg-2593-there-are-rowcount-rows-in-pagecount-pages-for-object-object/): There are ROWCOUNT rows in PAGECOUNT pages for object 'OBJECT'. This message is displayed when DBCC command is ran for any database. It is harmless and displayed for information purpose only. For each database DBCC commands displays number of rows and number of pages it is using. DBCC CHECKALLOC is exception for this messages. - [SQL SERVER - Index Reorganize or Index Rebuild](https://blog.sqlauthority.com/2008/02/15/sql-server-index-reorganize-or-index-rebuild/): Recently, I have received one question quite often about when to Index Reorganize and when to Index Rebuild. I have already written about this topic earlier but it seems that many are unable to search it. SQL SERVER – Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script If you have any question you can search exclusively SQLAuthority at http://search.SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Performance Monitor - How to Use Perfmon](https://blog.sqlauthority.com/2008/02/14/sql-server-introduction-to-performance-monitor-how-to-use-perfmon/): Yesterday I wrote about SQL SERVER – Introduction to Three Important Performance Counters. I received few questions about how to use Perfmon. Here is very brief introduction to Perfmon. There are three ways to launch Perfmon. 1) Type “start perfmon” at the command prompt. 2) Go to Start | Programs | Administrative Tools | Performance Monitor. 3) Go to Start | Run | Perfmon. Follow the images which explains how to use Perfmon and add different counters. Right click to bring up Add Counters Menu. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Three Important Performance Counters](https://blog.sqlauthority.com/2008/02/13/sql-server-introduction-to-three-important-performance-counters/): Performance Counters are very important to evaluate. There are more than thousands of Performance Counters. Today I will cover three basic but very important Performance Counters. Processor:% Processor Time It reports the total processor time with respect to the available capacity of the server. If counter is between 50 to 70 % consistently, investigate the process which is taking long time. PhysicalDisk:Avg.Disk Queue Length It indicates wait time for processes to use disk resources. As a disk is reading and writing data some requests cannot be immediately filled, those requests are queued. If many simultaneous requests are waiting, investigate the process... - [SQL SERVER - Get Current Database Name](https://blog.sqlauthority.com/2008/02/12/sql-server-get-current-database-name/): Yesterday while I was writing script for SQL SERVER – 2005 – Find Unused Indexes of Current Database . I realized that I needed SELECT statement where I get the name of the current Database. It was very simple script. SELECT DB_NAME() AS DataBaseName It will give you the name the database you are running using while running the query. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Find Unused Indexes of Current Database](https://blog.sqlauthority.com/2008/02/11/sql-server-2005-find-unused-indexes-of-current-database/): Simple but accurate following script will give you list of all the indexes in the database which are unused. If indexes are not used they should be dropped as Indexes reduces the performance for INSERT/UPDATE statement. Indexes are only useful when used with SELECT statement. Script to find unused Indexes. USE AdventureWorks GO DECLARE @dbid INT SELECT @dbid = DB_ID(DB_NAME()) SELECT OBJECTNAME = OBJECT_NAME(I.OBJECT_ID), INDEXNAME = I.NAME, I.INDEX_ID FROM SYS.INDEXES I JOIN SYS.OBJECTS O ON I.OBJECT_ID = O.OBJECT_ID WHERE OBJECTPROPERTY(O.OBJECT_ID,'IsUserTable') = 1 AND I.INDEX_ID NOT IN ( SELECT S.INDEX_ID FROM SYS.DM_DB_INDEX_USAGE_STATS S WHERE S.OBJECT_ID = I.OBJECT_ID AND I.INDEX_ID = S.INDEX_ID AND DATABASE_ID = @dbid)... - [SQLAuthority News - RIP: Ken Henderson, 1967 - 2008](https://blog.sqlauthority.com/2008/02/10/sqlauthority-news-rip-ken-henderson-1967-2008/): Ken Henderson, a nationally recognized consultant and leading DBMS practitioner, consults on high-end client/server projects away on Sunday, January 27, in Meeker, Oklahoma. Ken was an inspirational author of the SQL Server Guru’s Guide series of books. We will miss his forever. He was the author I respected the most. I have reviewed his book SQLAuthority News – Book Review – SQL Server 2005 Practical Troubleshooting: The Database Engine earlier on this blog. That was one great book. You can read sample chapter from that book here. Download Sample Chapter of SQL Server 2005 Practical Troubleshooting: The Database Engine. Let us... - [SQLAuthority News - 2008 - Download - SQL Server 2008 Brochure](https://blog.sqlauthority.com/2008/02/09/sqlauthority-news-2008-download-sql-server-2008-brochure/): SQL Server 2008 Brochure is available to download. It contains many information like available Server Editions, Top New Features, New Available Technologies and additional resources. - [SQL SERVER - Microsoft SQL Server Compact 3.5 SP1 Beta for ADO.Net Entity Framework Beta 3](https://blog.sqlauthority.com/2008/02/08/sql-server-microsoft-sql-server-compact-35-sp1-beta-for-adonet-entity-framework-beta-3/): SQL Server Compact 3.5 SP1 Beta release for the ADO.Net Entity Framework Beta 3 enables the following scenarios: Applications can work in terms of a more application-centric conceptual model, including types with inheritance, complex members, and relationships Applications are freed from hard-coded dependencies on a particular data engine or storage schema Mappings between the conceptual application model and the storage-specific schema can change without changing the application code Developers can work with a consistent application object model that can be mapped to various storage schemas, possibly implemented in different database management systems Multiple application models can be mapped to a single... - [SQL SERVER - Sharpen Your Basic SQL Server Skills - Database backup demystified](https://blog.sqlauthority.com/2008/02/07/sql-server-sharpen-your-basic-sql-server-skills-database-backup-demystified/): Read my article in SQL Server Magazine January 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Import CSV File Into SQL Server Using Bulk Insert - Load Comma Delimited File Into SQL Server](https://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/): This is a very common request recently – How to import CSV file into SQL Server? How to load CSV file into SQL Server Database Table? How to load comma delimited file into SQL Server? Let us see the solution in quick steps. CSV stands for Comma Separated Values, sometimes also called Comma Delimited Values. Create TestTable USE TestData GO CREATE TABLE CSVTest (ID INT, FirstName VARCHAR(40), LastName VARCHAR(40), BirthDate SMALLDATETIME) GO Create CSV file in drive C: with name sweetest. text with the following content. The location of the file is C:\csvtest.txt 1,James,Smith,19750101 2,Meggie,Smith,19790122 3,Robert,Smith,20071101 4,Alex,Smith,20040202 Now run following script to load... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Funny Microsoft Quotes](https://blog.sqlauthority.com/2008/02/05/sqlauthority-news-sql-joke-sql-humor-sql-laugh-funny-microsoft-quotes/): I have received many emails that I should write more post like SQLAuthority News – SQL Joke, SQL Humor, SQL Laugh – Funny Quotes. - [SQL SERVER - Simple Example of WHILE Loop with BREAK and CONTINUE](https://blog.sqlauthority.com/2008/02/04/sql-server-simple-example-of-while-loop-with-break-and-continue/): WHILE statement sets a condition for the repeated execution of an SQL statement or statement block. Following is very simple example of WHILE Loop with BREAK and CONTINUE. USE AdventureWorks; GO DECLARE @Flag INT SET @Flag = 1 WHILE (@Flag < 10) BEGIN BEGIN PRINT @Flag SET @Flag = @Flag + 1 END IF(@Flag > 5) BREAK ELSE CONTINUE END WHILE loop can use SELECT queries as well. You can find following example of BOL very useful. USE AdventureWorks; GO WHILE ( SELECT AVG(ListPrice) FROM Production.Product) < $300 BEGIN UPDATE Production.Product SET ListPrice = ListPrice * 2 SELECT MAX(ListPrice) FROM Production.Product... - [SQL SERVER - FIX : ERROR : Cannot find template file for new query (C:\Program Files\Microsoft SQL Server\90\Tools\ Binn\VSShell\Common7\ IDE\sqlworkbenchprojectitems\Sql\ SQLFile.sql)](https://blog.sqlauthority.com/2008/02/03/sql-server-fix-error-cannot-find-template-file-for-new-query-cprogram-filesmicrosoft-sql-server90toolsbinnvsshellcommon7idesqlworkbenchprojectitemssqlsqlfilesql/): Just a day ago while playing with SQL Server I suddenly faced a new kind of error, which I have never seen before. This error happens when clicked on New Query in SQL Server Management Studio. Let us learn in this blog post how we will fix the error - cannot find template file for a new query.  - [SQL SERVER - Find All The User Defined Functions (UDF) in a Database](https://blog.sqlauthority.com/2008/02/02/sql-server-find-all-the-user-defined-functions-udf-in-a-database/): Following script is very simple script which returns all the User Defined Functions for particular database. USE AdventureWorks; GO SELECT name AS function_name ,SCHEMA_NAME(schema_id) AS schema_name ,type_desc FROM sys.objects WHERE type_desc LIKE '%FUNCTION%'; GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Great Job with Great Pay](https://blog.sqlauthority.com/2008/02/01/sql-server-find-great-job-with-great-pay/): One question I have been asked consistently “Where can I find Great Job with Great Pay related to SQL Server?”. I have been aware of the fact that there are many jobs in market but finding one job which gives satisfaction in job as well has great salary are few. All the great places are usually taken by best employees and they do not change their job. Due to the same reason, I have created job board where companies can list their jobs as well all good candidate can find best job according to their requirement. Find Great Job with Great... - [SQL SERVER - Top 10 Best Practices for SQL Server Maintenance for SAP](https://blog.sqlauthority.com/2008/01/31/sql-server-top-10-best-practices-for-sql-server-maintenance-for-sap/): Top 10 Best Practices for SQL Server Maintenance for SAP By Takayuki Hoshino SQL Server provides an excellent database platform for SAP applications. The following recommendations provide an outline of best practices for maintaining SQL Server database for an SAP implementation. 1) Perform a full database backup daily 2) Perform transaction log backup Every 10 to 30 minutes 3) Back up system partition in case of configuration changes 4) Back up system databases in case of configuration changes 5) Run DBCC CHECKDB periodically (ideally before the full database backup) 6) Evaluate security patches monthly (and install them if they are necessary)... - [SQL SERVER - FIX : ERROR : The query processor could not start the necessary thread resources for parallel query execution](https://blog.sqlauthority.com/2008/01/30/sql-server-fix-error-the-query-processor-could-not-start-the-necessary-thread-resources-for-parallel-query-execution/): ERROR : The query processor could not start the necessary thread resources for parallel query execution. - [SQLAuthority New - O'relly Style Book Cover for SQLAuthority](https://blog.sqlauthority.com/2008/01/29/sqlauthority-new-orelly-style-book-cover-for-sqlauthority/): Yo Ming, Chin regular reader from Los Angeles, CA has sent me following image for SQLAuthority. Checkout O’reillymaker and create your own Book Cover. Reference : Pinal Dave (https://blog.sqlauthority.com) , O’reillymaker - [SQLAuthority News - Download Whitepaper Using SharePoint List Data in PowerPivot](https://blog.sqlauthority.com/2011/06/19/sqlauthority-news-download-whitepaper-using-sharepoint-list-data-in-powerpivot/): One of the many features of Microsoft SQL Server PowerPivot is the range of data sources that can be used to import data. Anything, from Microsoft SQL Server relational databases, Oracle databases, and Microsoft Access databases, to text documents, can be used as data sources in PowerPivot. In this paper, I explain one of the new and upcoming data sources that people are excited about – SharePoint list data in the form of Atom feeds. This white paper goes on to explain the different ways you can import SharePoint list data into PowerPivot, what types of lists are supported, various components... - [SQL SERVER - Selecting Domain from Email Address](https://blog.sqlauthority.com/2011/06/18/sql-server-selecting-domain-from-email-address/): Recently I came across a quick need where I needed to retrieve domain of the email address. The email address is in the database table. I quickly wrote following script which will extract the domain and will also count how many email addresses are there with the same domain address. SELECT RIGHT(Email, LEN(Email) - CHARINDEX('@', email)) Domain , COUNT(Email) EmailCount FROM   dbo.email WHERE  LEN(Email) > 0 GROUP BY RIGHT(Email, LEN(Email) - CHARINDEX('@', email)) ORDER BY EmailCount DESC Above script will select the domain after @ character. Please note, if there is more than one @ character in the email, this script will... - [SQL SERVER - Solution - Puzzle - Statistics are not Updated but are Created Once](https://blog.sqlauthority.com/2011/06/17/sql-server-solution-puzzle-statistics-are-not-updated-but-are-created-once/): Earlier I asked puzzle why statistics are not updated. Read the complete details over here: Statistics are not Updated but are Created Once In the question I have demonstrated even though statistics should have been updated after lots of insert in the table are not updated.(Read the details SQL SERVER – When are Statistics Updated – What triggers Statistics to Update) In this example I have created following situation: Create Table Insert 1000 Records Check the Statistics Now insert 10 times more 10,000 indexes Check the Statistics – it will be NOT updated Auto Update Statistics and Auto Create Statistics for database... - [SQL SERVER - Free Online Training on .net and SQL](https://blog.sqlauthority.com/2011/06/16/sql-server-free-online-training-on-net-and-sql/): I around 10 Free Online Training Codes available of .NET and SQL Training from Pluralsight. I am willing to give it to someone who wants learn technology this weekend. You just have to go to my Facebook page and leave a comment explaining in one line – what course will you learn during weekend. I will send all this codes to 10 winners whom I will randomly select using Facebook. Meanwhile do you know how can you generate Zero without using any numbers in T-SQL. My friend Madhivanan has done that and I find it very interesting.Run following T-SQL code –... - [SQL SERVER - Solution - Puzzle - SELECT * vs SELECT COUNT(*)](https://blog.sqlauthority.com/2011/06/15/sql-server-solution-puzzle-select-vs-select-count/): Earlier I have published Puzzle Why SELECT * throws an error but SELECT COUNT(*) does not. This question have received many interesting comments. Let us go over few of the answers, which are valid. Before I start the same, let me acknowledge Rob Farley who has not only answered correctly very first but also started interesting conversation in the same thread. The usual question will be what is the right answer. I would like to point to official Microsoft Connect Items which discusses the same. RGarvao https://connect.microsoft.com/SQLServer/feedback/details/671475/select-test-where-exists-select tiberiu utan http://connect.microsoft.com/SQLServer/feedback/details/338532/count-returns-a-value-1 Rob Farley count(*) is about counting rows, not a particular column.... - [SQLAuthority News - BI Quiz Question - How to Optimize Cube? - Hints](https://blog.sqlauthority.com/2011/06/14/sqlauthority-news-bi-quiz-question-how-to-optimize-cube-hints/): I earlier wrote about SQL BI Quiz over here. The details of the quiz is as following: Working with huge data is very common when it is about Data Warehousing. It is necessary to create Cubes on the data to make it meaningful and consumable. There are cases when retrieving the data from cube takes lots of the time. Let us assume that your cube is returning you data very quickly. Suddenly on one day it is returning the data very slowly. What are the three things will you to diagnose this. After diagnose what you will do to resolve performance... - [SQL SERVER - Watch Online and Download - Inside of Next Generation SQL Server - Best Practices Analyzer using Microsoft Baseline Configuration Analyzer](https://blog.sqlauthority.com/2011/06/14/sql-server-watch-online-and-download-inside-of-next-generation-sql-server-best-practices-analyzer-using-microsoft-baseline-configuration-analyzer/): I presented on subject Inside of Next Generation SQL Server – Denali online at Zeollar.com. This sessions are really fun as they are online, downloadable, and 100% demo oriented. I used SQL Server ‘Denali’ CTP 1 to present on the subject of What is New in Denali. My earlier session on the Topic of Best Practices Analyzer is also available to watch online here: SQL SERVER – Video – Best Practices Analyzer using Microsoft Baseline Configuration Analyzer I enjoyed presenting a lot on above two subjects. I would like to ask your opinion on the same. You can download the sessions... - [SQL SERVER - First Month as DBA Trainee - Disasters and Recovery](https://blog.sqlauthority.com/2011/06/14/sql-server-first-month-as-dba-trainee-disasters-and-recovery/): This blog post is written in response to the T-SQL Tuesday hosted by Allen Kinsel. He has selected very interesting subject for T-SQL Tuesday – Disaster and Recovery. This subject took me in past – my past. There were various things, I had done or proposed when I started very first month as a DBA trainee. I was tagged along with very senior DBA in my organization who always protected me or correct my mistake. He was great guy and totally understand the young mind of over-enthusiastic Trainee DBA. I respect him very much. Here are few things which I had... - [SQL SERVER - Extending SQL Azure with Azure worker role - Guest Post by Paras Doshi](https://blog.sqlauthority.com/2011/06/13/sql-server-extending-sql-azure-with-azure-worker-role-guest-post-by-paras-doshi/): This is guest post by Paras Doshi. Paras Doshi is a research Intern at SolidQ.com and a Microsoft student partner. He is currently working in the domain of SQL Azure. SQL Azure is nothing but a SQL server in the cloud. SQL Azure provides benefits such as on demand rapid provisioning, cost-effective scalability, high availability and reduced management overhead. To see an introduction on SQL Azure, check out the post by Pinal here In this article, we are going to discuss how to extend SQL Azure with the Azure worker role. In other words, we will attempt to write a custom... - [SQL SERVER - PHP on Windows and SQL Server Training Kit](https://blog.sqlauthority.com/2011/06/12/sql-server-php-on-windows-and-sql-server-training-kit/): The PHP on Windows and SQL Server Training Kit includes a comprehensive set of technical content including demos and hands-on labs to help you understand how to build PHP applications using Windows, IIS 7.5 and SQL Server 2008 R2. This release includes the following: PHP & SQL Server Demos Integrating SQL Server Geo-Spatial with PHP SQL Server Reporting Services and PHP PHP & SQL Server Hands On Labs Introduction to Using SQL Server with PHP Using SQL Server Full-Text Search and FILESTREAM Storage with PHP New: Getting Started with SQL Server Migration Assistant for MySQL Download SQL Server PHP on Windows... - [SQL SERVER - Integration Services Balanced Data Distributor - SSIS Balanced Data Distributor](https://blog.sqlauthority.com/2011/06/11/sql-server-integration-services-balanced-data-distributor-ssis-balanced-data-distributor/): Microsoft SSIS Balanced Data Distributor (BDD) is a new SSIS transform. - [SQLAuthority News - Presenting at Tech-Ed On Road - Ahmedabad - June 11, 2011 - Wait Types and Queues](https://blog.sqlauthority.com/2011/06/10/sqlauthority-news-presenting-at-tech-ed-on-road-ahmedabad-june-11-2011-wait-types-and-queues/): I will be presenting in person on the subject SQL Server Wait Types and Queues at Ahmedabad on June 11, 2011. Here is the quick summary of the session. SQL Server Waits and Queues – Your Gateway to Perf. Troubleshooting Time: 11:15am – 12:15pm – June 11, 2011 Just like a horoscope, SQL Server Waits and Queues can reveal your past, explain your present and predict your future. SQL Server Performance Tuning uses the Waits and Queues as a proven method to identify the best opportunities to improve performance. A glance at Wait Types can tell where there is a bottleneck.... - [SQL SERVER - Online Session on What is New in Denali - Today Online](https://blog.sqlauthority.com/2011/06/09/sql-server-online-session-on-what-is-new-in-denali-today-online/): I will be presenting today on subject Inside of Next Generation SQL Server – Denali online at Zeollar.com. This sessions are really fun as they are online, downloadable, and 100% demo oriented. I will be using SQL Server ‘Denali’ CTP 1 to present on the subject of What is New in Denali. The webcast will start at 12:30 PM sharp and will end at 1 PM India Time. It will be 100% demo oriented and no slides. I will be covering following topics in the session. SQL SERVER – Denali Feature – Zoom Query Editor SQL SERVER – Denali – Improvement... - [SQL SERVER - 5 Tips for Improving Your Data with expressor Studio](https://blog.sqlauthority.com/2011/06/08/sql-server-5-tips-for-improving-your-data-with-expressor-studio/): It’s no secret that bad data leads to bad decisions and poor results.  However, how do you prevent dirty data from taking up residency in your data store?  Some might argue that it’s the responsibility of the person sending you the data.  While that may be true, in practice that will rarely hold up.  It doesn’t matter how many times you ask, you will get the data however they decide to provide it. So now you have bad data.  What constitutes bad data?  There are quite a few valid answers, for example: Invalid date values Inappropriate characters Wrong data Values that... - [SQL SERVER - Three Puzzling Questions - Need Your Answer](https://blog.sqlauthority.com/2011/06/07/sql-server-three-puzzling-questions-need-your-answer/): Last week I had asked three questions on my blog. I got very good response to the questions. I am planning to write summary post for each of three questions next week. Before I write summary post and give credit to all the valid answers. I was wondering if I can bring to notice of all of you this week. Why SELECT * throws an error but SELECT COUNT(*) does not This is indeed very interesting question as not quite many realize that this kind of behavior SQL Server demonstrates out of the box. Once you run both the code and... - [SQL SERVER - BI Quiz - Troubleshooting Cube Performance](https://blog.sqlauthority.com/2011/06/06/sql-server-bi-quiz-troubleshooting-cube-performance/): My friend Jacob Sebastian runs SQL BI Quiz competition. Where there are 30 different questions on each day of the month. Winners get opportunity to participate in this Quiz, learn something new and win great awards. Working with huge data is very common when it is about Data Warehousing. It is necessary to create Cubes on the data to make it meaningful and consumable. There are cases when retrieving the data from cube takes lots of the time. Let us assume that your cube is returning you data very quickly. Suddenly on one day it is returning the data very slowly.... - [SQLAuthority News - SQL Server 2008 R2 Update for Developers Training Kit - Download - May Update](https://blog.sqlauthority.com/2011/06/05/sqlauthority-news-sql-server-2008-r2-update-for-developers-training-kit-download-may-update/): I often receive the question what is the quickest way to learn SQL Server 2008 R2. Microsoft have published developers training kit which one can download and learn at your own pace, it has tutorials, videos, and hands-on lab which one can practice. This training kit has been published earlier and has been refreshed in May 2011. The May 2011 update provides support for Windows 7 SP1, Windows Server 2008 R2 SP1 and Visual Studio 2010 SP1. Additionally, any demos or hands-on labs that no longer have a Visual Studio 2008 dependency were updated to Visual Studio 2010. The training kit... - [SQLAuthority News - Download Pre-configured VHD - SQL Server 2008 R2 Standard on Windows Server 2008 R2 SP1 Standard](https://blog.sqlauthority.com/2011/06/05/sqlauthority-news-download-pre-configured-vhd-sql-server-2008-r2-standard-on-windows-server-2008-r2-sp1-standard/): It is extremely simple to test out latest SQL Server 2008 R2. You can even get pre-configured ready to use VHD, which you can download and use it. This becomes very easy as one does not have to do anything besides downloading VHD and installing it on Hyper-V. Download Pre-configured VHD – SQL Server 2008 R2 Standard provides a trusted, productive and intelligent data platform that enables you to run your most demanding mission-critical applications, reduce time and cost of development and management of applications, and deliver actionable insight to your entire organization. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Question to You - When to use Function and When to use Stored Procedure](https://blog.sqlauthority.com/2011/06/04/sql-server-question-to-you-when-to-use-function-and-when-to-use-stored-procedure/): This week has been very interesting week. I have asked few questions to users and have received remarkable participation on the subject. Q1) SQL SERVER – Puzzle – SELECT * vs SELECT COUNT(*) Q2) SQL SERVER – Puzzle – Statistics are not Updated but are Created Once Keeping the same spirit up, I am asking the third question over here. Q3) When to use User Defined Function and when to use Stored Procedure in your development? - [SQLAuthority News - Community Tech Days - TechEd on The Road - Ahmedabad - June 11, 2011](https://blog.sqlauthority.com/2011/06/03/sqlauthority-news-community-tech-days-teched-on-the-road-ahmedabad-june-11-2011/): TechEd on Road is back! In Ahmedabad June 11, 2011! Inviting all Professional Developers, Project Managers, Architects, IT Managers, IT Administrators and Implementers of Ahmedabad to be a part of Tech•Ed on the Road, on 11th June, 2011. We have put together the best sessions from Tech•Ed India 2011 for you in your city. Focal point will be technologies like Database and BI, Windows 7, ASP.NET. REGISTER HERE! Venue: Venue: Ahmedabad Management Association (AMA) Dr. Vikram Sarabhai Marg, University Area, Ahmedabad, Gujarat 380 015 Time: 9:30AM – 5:30PM The biggest attraction of the event is session HTML5 – Future of the... - [SQL SERVER - Puzzle - Statistics are not Updated but are Created Once](https://blog.sqlauthority.com/2011/06/02/sql-server-puzzle-statistics-are-not-updated-but-are-created-once/): After having excellent response to my quiz – Why SELECT * throws an error but SELECT COUNT(*) does not?I have decided to ask another puzzling question to all of you. I am running this test on SQL Server 2008 R2. Here is the quick scenario about my setup. Create Table Insert 1000 Records Check the Statistics Now insert 10 times more 10,000 indexes Check the Statistics – it will be NOT updated Note: Auto Update Statistics and Auto Create Statistics for database is TRUE Expected Result – Statistics should be updated – SQL SERVER – When are Statistics Updated – What... - [SQL SERVER - Creating All New Database with Full Recovery Model](https://blog.sqlauthority.com/2011/06/01/sql-server-creating-all-new-database-with-full-recovery-model/): Sometimes, complex problems have very simple solutions. Let us see the following email which I received recently. “Hi Pinal, In our system when we create new database, by default, they are all created with the Simple Recovery Model. We have to manually change the recovery model after we create the database. We used the following simple T-SQL code: CREATE DATABASE dbname. We are very frustrated with this situation. We want all our databases to have the Full Recovery Model option by default. We are considering the following methods; please suggest the most efficient one among them. 1) Creating a Policy; when... - [SQLAuthority News - Best SQLAuthority Posts of May](https://blog.sqlauthority.com/2011/05/31/sqlauthority-news-best-sqlauthority-posts-of-may/): Month of May is always interesting and full of enthusiasm. Lots of good articles shared and lots of enthusiast communication on technology. This month we had 140 Character Cartoon Challenge Winner. We also had interesting conversation on what kind of lock WITH NOLOCK takes on objects as well. A quick tutorial on how to import CSV files into Database using SSIS started few other related questions. I also had fun time with community activities. I attended MVP Open Day. Vijay Raj also took awesome photos of my daughter – Shaivi. I have gain my faith back in Social Media and have... - [SQL SERVER - Puzzle - SELECT * vs SELECT COUNT(*)](https://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/): Earlier this weekend I have presented at Bangalore User Group on the subject of SQL Server Tips and Tricks. During the presentation I have asked a question to attendees. It was very interesting to see that I have received various different answer to my question. Here is the same puzzle for you and I would like to see what your answer to this question. - [SQL Azure - SQL Azure Throttling and Decoding Reason Codes](https://blog.sqlauthority.com/2011/05/29/sql-azure-sql-azure-throttling-and-decoding-reason-codes/): I was recently reading on the subject SQL Azure Throttling and Decoding Reason Codes and end up reading the article over here. What I really liked is the explanation of the subject with Graphic. I have never seen any better explanation of this subject. I really liked this diagram. However, based on reason code one has to adjust their resource usages. I now wonder do we have any tool available which can directly analysis the reason codes and based on it gives output that what kind of the throttling is happening. One of the idea I immediately got that I can... - [SQL SERVER - A Quick Notes on SQL Azure](https://blog.sqlauthority.com/2011/05/28/sql-server-a-quick-notes-on-sql-azure/): I was recently attending a small meeting where I was asked if I can share few things to be considered when designing SQL Azure database. Today I am sharing the same notes over here. - [SQL SERVER - Copy Database from Instance to Another Instance - Copy Paste in SQL Server](https://blog.sqlauthority.com/2011/05/27/sql-server-copy-database-from-instance-to-another-instance-copy-paste-in-sql-server/): SQL Server has a feature which copy database from one database to another database and it can be automated as well using SSIS. - [SQL SERVER - Getting Columns Headers without Result Data - SET FMTONLY ON](https://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/): I was recently watching a videos online of TechEd 2011 USA (link) and I learned that SET FMTONLY ON is going to be replaced with enhanced DMVs in future versions of SQL Server. I really liked the new direction of the product. However, SET FMTONLY ON is really have done its job so far. I have used it many times so far and always find it useful. SET FMTONLY ON returns only metadata to the client. It can be used to test the format of the response without actually running the query. When this setting is ON the resultset only have... - [SQLAuthority News - Most Valuable Photographer - Vijay Raj](https://blog.sqlauthority.com/2011/05/25/sqlauthority-news-most-valuable-photographer-vijay-raj/): A good snapshot stops a moment from running away.  ~Eudora Welty If I could tell the story in words, I wouldn’t need to lug around a camera.  ~Lewis Hine Vijay Raj is a passionate Technology Evangelist and a Microsoft MVP. He recently took few snaps of my daughter. As soon as he put the images on his album online, it was instant hit and was wallpaper of many desktops. Every praise one does for Vijay is not enough. I personally have no words to express my feeling after looking at the photos he has taken. If you really like the photos,... - [SQL SERVER - What is SQL Azure](https://blog.sqlauthority.com/2011/05/24/sql-server-sql-azure/): A very common question which I often receive is What is SQL Azure? - [SQL SERVER - Running SSIS Package in Scheduled Job](https://blog.sqlauthority.com/2011/05/23/sql-server-running-ssis-package-in-scheduled-job/): I previously wrote article SQL SERVER – Import CSV File into Database Table Using SSIS. I was asked following question by reader that how to run the same SSIS package from command prompt. In response to the same I have written article SQL SERVER – Running SSIS Package From Command Line. Within few minutes of the blog post, I received email from another blog reader asking if this can be scheduled in SQL Server Agent Job. - [SQL SERVER - Download PowerPivot Security Architecture Diagram ](https://blog.sqlauthority.com/2011/05/22/sql-server-download-powerpivot-security-architecture-diagram/): Security Architecture Diagram is very interesting and very important aspect of the database. I am currently attending the MVP Open Day event and one of the attendee asked if I can write about PowerPivot Security Architecture. This subject is very well explained earlier using diagram by Microsoft. Microsoft has published poster which explains this security architecture diagram. Included in this diagram are: Service Accounts SharePoint Databases Security Hardening Automatic Data Refresh User Identity Flow PowerPivot Permissions Levels Download PowerPivot Security Architecture Technical diagram (.pdf) Download PowerPivot Security Architecture Technical diagram (.vsd) Download PowerPivot Security Architecture Technical diagram (.xps) Reference : Pinal... - [SQL SERVER - Running SSIS Package From Command Line](https://blog.sqlauthority.com/2011/05/21/sql-server-running-ssis-package-from-command-line/): I previously wrote article SQL SERVER – Import CSV File into Database Table Using SSIS. I was asked following question by reader that how to run the same SSIS package from command prompt. This is really interesting question and very easy one as well. You can execute SSIS Package using command line utility. C:\>dtexec.exe /F "C:\ImportCSV\Package.dtsx" When you run above command it will give you start time, end time and total progress of the package as well. There are various options of the DTEXEC available you can see that using dtexec.exe /? In future we will see how the SSIS task can... - [SQL SERVER - Management Studio and Browser in Same Application - SSMS Browser](https://blog.sqlauthority.com/2011/05/20/sql-server-management-studio-and-browser-in-same-application/): First of all - I must confess that I was not aware of this feature till I noticed it today. At home, I have multiple monitors, but when I am traveling, I have single laptop along with me. It is often that when I am working with SQL Server I have to refer web for information on the subject I am working on. Let us understand about SSMS Browser in this blog post. - [SQL SERVER - Connecting to Server Using Windows Authentication by SQLCMD](https://blog.sqlauthority.com/2011/05/19/sql-server-connecting-to-server-using-windows-authentication-by-sqlcmd/): Recently I got a call from an old friend I used to call “DJ”. Here is the exact conversation we had about SQLCMD. - [SQL SERVER - FIX - ERROR - Service Logon Failure (ObjectExplorer)](https://blog.sqlauthority.com/2011/05/18/sql-server-fix-error-service-logon-failure-objectexplorer/): Just another day I received following error while starting my agent. As soon as I received following error I felt like Deja Vu. I had similar feeling few days ago. I quickly looked at my blog post history and I found out following article SQL SERVER – Fix : Error : The request failed or the service did not respond in timely fashion. Consult the event log or other applicable error logs for details. TITLE: Microsoft SQL Server Management Studio —————————— Unable to start service SQLSERVERAGENT on server PINALKUMAR. (mscorlib) —————————— ADDITIONAL INFORMATION: Service Logon Failure (ObjectExplorer) Indeed this was again... - [SQLAuthority News - Facebook Page and Twitter - Connect Using Social Media](https://blog.sqlauthority.com/2011/05/17/sqlauthority-news-facebook-page-and-twitter-connect-using-social-media/): I often get question if I am active on social media. I am very much active on social media. I have noticed that we have all are active on Facebook, I have created Facebook page where you can do discussion and follow on my updates. SQLAuthority.com Page I am very active on twitter as well – you can follow me there as well. Twitter: @pinaldave You can subscribe to SQLAuthority.com blog posts using email as well, this way you will get daily doze of SQL in your mail box. Subscribe to SQLAuthority.com Via Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Server Compression Estimator](https://blog.sqlauthority.com/2011/05/16/sql-server-sql-server-compression-estimator/): I recently come across an interesting tool called 'SQL Server Compression Estimator'. I find this tool very interesting. This tool is a pretty decent tool and I used it on a couple of my personal server and it gave me a good estimate. - [SQL SERVER - Attending MVP Open Day - May 2011](https://blog.sqlauthority.com/2011/05/15/sql-server-attending-mvp-open-day-may-2011/): The MVP Open Day is an exclusive event for Asia Pacific & Greater China MVPs. MVPs from the region gather and have great time together. It is mix of education, fun and networking. I have previously written my experience over here. SQLAuthority News – MVP Open Day South Asia – Jan 20, 2010 – Jan 23, 2010 – Review Part Fun SQLAuthority News – MVP Open Day South Asia – Jan 20, 2010 – Jan 23, 2010 – Review Part Business SQLAuthority News – Author Visit – South Asia MVP Open Day 2008 – Goa – Group Photo This year again,... - [SQLAuthority News - Restart Remote Computer - Shutdown Remote Computer](https://blog.sqlauthority.com/2011/05/14/sqlauthority-news-restart-remote-computer-shutdown-remote-computer/): I often work with multiple computer system. This machines are different machines. When I login using remote desktop to different machine, I often want to restart or shutdown the computer. Remote desktop does not let me shutdown computer when I have remote system as Windows 7. At this time, I walk myself to the physical computer and restart the machine. This is not convenient if I am doing it often. I recently searched for command prompt solution for the same and I learned it today. If you are going to say this is so 90s. Well, I am late by 20... - [SQL SERVER - Vote for My Session in SQL PASS](https://blog.sqlauthority.com/2011/05/13/sql-server-vote-for-my-session-in-sql-pass/): Please Vote for My Session in SQL PASS SQL Server Waits and Queues – Your Gateway to Performance Troubleshooting Session Level: 300 Session Category: Regular Session (75 minutes) Session Track: Enterprise Database Administration and Deployment Just like a horoscope, SQL Server Waits and Queues can reveal your past, explain your present and predict your future. SQL Server Performance Tuning uses the Waits and Queues as a proven method to identify the best opportunities to improve performance. A glance at Wait Types can tell where there is a bottleneck. Learn how to identify bottlenecks and potential resolutions in this fast paced, advanced... - [SQL SERVER - Import CSV File into Database Table Using SSIS](https://blog.sqlauthority.com/2011/05/12/sql-server-import-csv-file-into-database-table-using-ssis/): It is very frequent request to upload CSV file to database or Import CSV file into database. I have previously written article how one can do this using T-SQL over here SQL SERVER – Import CSV File Into SQL Server Using Bulk Insert – Load Comma Delimited File Into SQL Server. - [SQL SERVER – expressor 3.2 Release Review](https://blog.sqlauthority.com/2011/05/11/sql-server-expressor-3-2-release-review/): I have been following expressor software for some time now and they have recently released a new version of their expressor Studio desktop ETL application. I am pleased to find out that the download and installation experience of this application has been greatly simplified. expressor Studio no longer requires users to install a license key after they download and install the product. They have also eliminated a Microsoft Visio dependency from their product. Removing the license requirement and Visio dependency has made download and installation much easier. - [SQL SERVER - Resource Database ID - 32767](https://blog.sqlauthority.com/2011/05/10/sql-server-resource-database-id-32767/): Earlier I blogged about SQL SERVER – What Kind of Lock WITH (NOLOCK) Hint Takes on Object?. After reading the post, I got question by one of the blog reader. “Hi Pinal, I see in your blog post you have Database ID which is 32767. Everytime I want to get the name of the database from database_ID I use following function but this time this function returned NULL. SELECT DB_NAME(32767) When I tried to list all the databases uses following script it did not have that database ID as well. SELECT * FROM sys.databases I assume you have created this many database... - [SQL SERVER - Common Table Expression (CTE) and Few Observation](https://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/): This blog post is written in response to the T-SQL Tuesday hosted by Bob Pusateri. He has picked very interesting topic which is related to APPLY clause of the T-SQL. When I read the subject, I really liked the subject. This is very new subject and it is quite a interesting choice by Bob. Common Table Expression (CTE) are introduced in SQL Server 2005 so it is available with us from last 6 years. Over the years I have seen lots of implementation of the same as well lots of misconceptions. Earlier I had presented on this subject many places. Here... - [SQL SERVER - SQL Server Management Pack Guide for System Center Operations Manager 2007](https://blog.sqlauthority.com/2011/05/09/sql-server-sql-server-management-pack-guide-for-system-center-operations-manager-2007/): The SQL Server Management Pack provides the capabilities for Operations Manager 2007 SP1 and R2 to discover SQL Server 2005, 2008, and 2008 R2. It monitors SQL Server components such as database engine instances, databases, and SQL Server agents. The monitoring provided by this management pack includes performance, availability, and configuration monitoring, performance data collection, and default thresholds. You can integrate the monitoring of SQL Server components into your service-oriented monitoring scenarios. In addition to health monitoring capabilities, this management pack includes dashboard views, extensive knowledge with embedded inline tasks, and views that enable near real-time diagnosis and resolution of detected... - [SQL SERVER - What Kind of Lock WITH (NOLOCK) Hint Takes on Object?](https://blog.sqlauthority.com/2011/05/08/sql-server-what-kind-of-lock-with-nolock-hint-takes-on-object/): Recently I was talking with Vinod Kumar regarding NOLOCK. Suddenly he asked me do I know what kind of lock WITH(NOLOCK) hint takes on object. The immediate response of mine was that NOLOCK does not take any lock. He responded suggesting that I should think more and answer. I realized right after his suggestion to think harder and I said Schema Lock. Yes, WITH(NOLOCK) hint takes Schema Lock on the object which is accessed. Here is the script to prove it. Step 1: Run following script with query hint NOLOCK SELECT * FROM sys.all_objects a WITH (NOLOCK) CROSS JOIN sys.all_objects b... - [SQL SERVER - 2008 - 2008 R2 - Create Script to Copy Database Schema and All The Objects - Data, Schema, Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects](https://blog.sqlauthority.com/2011/05/07/sql-server-2008-2008-r2-create-script-to-copy-database-schema-and-all-the-objects-data-schema-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/): Quite often I get the request regarding how to copy all the objects – including schema and data from any database and re-create it on another instance. SQL Server 2008 and SQL Server 2008 R2 has script generator wizard which does it for us. I ask you to pay special attention to image #5. After the script is generated, the next challenge often users face is how to execute this large script as SQL Server Management Studio does not open the file. One can use SQLCMD for the same. See that in the last image of this post. Pay attention to... - [SQL SERVER - Video - Best Practices Analyzer using Microsoft Baseline Configuration Analyzer](https://blog.sqlauthority.com/2011/05/06/sql-server-video-best-practices-analyzer-using-microsoft-baseline-configuration-analyzer/): Yesterday I presented on the subject Check SQL Server Health using Best Practices Analyzer. There was great response to the session. Many asked me if the session is recorded so they can watch it later on. Absolutely, the session is recorded and you can watch it at your convince. Not only you can watch the session online but can also download the same and watch it while traveling or on your Windows Phone. Video of Check SQL Server Health using Best Practices Analyzer If you want to download the resources which I have used in this presentation here is the link... - [SQL SERVER - Presenting on Best Practices Analyzer using Microsoft Baseline Configuration Analyzer](https://blog.sqlauthority.com/2011/05/05/sql-server-presenting-on-best-practices-analyzer-using-microsoft-baseline-configuration-analyzer/): Today (May 5, 2011) I will be presenting on Presenting on Best Practices Analyzer using Microsoft Baseline Configuration Analyzer at . I will be presenting on following subjects. The tools which I will be using in the demonstration are following: Engine – Backups outdated for databases Engine – Database files and backups exist on the same volume Engine – SQL Server tempdb database not configured optimally Engine – Authentication Mode Engine – Database consistency check not current Engine – Databases using simple recovery model Microsoft Baseline Configuration Analyzer 2.0 Microsoft Baseline Configuration Analyzer 2.0 (MBCA 2.0) can help you maintain optimal system... - [SQL SERVER - Cartoon Challenge - 140 Character Winner is Here](https://blog.sqlauthority.com/2011/05/04/sql-server-cartoon-challenge-140-character-winner-is-here/): Earlier Idera has announced contest where participant can win Windows Mobile Phone by writing 140 character. Here is the details of the contest SQLAuthority News – Win Windows Phone from Idera in 140 Characters – A Cartoon Challenge of SQL. We received more than 200 comments on the blog post and more than 250 qualifying entries. It was not possible to pick winner out of all those entries. I reached out to good folks at Idera for helping me select the winner. After going back and forward and with lots of revision we come up with winning entry. Idera has also... - [SQL SERVER - Interview on Wait Types and Wait Queues - SQL Doctor](https://blog.sqlauthority.com/2011/05/04/sql-server-interview-on-wait-types-and-wait-queues/): Earlier this year I have written a whole month on the subject SQL Server Wait Types and Wait Queues SQL SERVER – Summary of Month – Wait Type – Day 28 of 28. The focus of this series was very simple - define a problem and solve it. I learned a lot while I wrote this series. While I am writing this blog, I am very much delighted that SQL Doctor team of Idera software is very kind to implement a few of the tricks from the blog post. - [SQL SERVER - Error: Failed to retrieve data for this request. Microsoft.SqlServer.Management.Sdk.Sfc - 'DATABASEPROPERTY' is not a recognized built-in function name. (Microsoft SQL Server, Error: 195)](https://blog.sqlauthority.com/2011/05/03/sql-server-error-failed-to-retrieve-data-for-this-request-microsoft-sqlserver-management-sdk-sfc-databaseproperty-is-not-a-recognized-built-in-function-name-microsoft-sql-server-error-1/): I have four different machine at home. Office Laptop – Provided by work organization Personal Laptop – My wife uses it Demo Machine – A very old machine – I think I can only do demo of my messenger only – it is 32 bit – single CPU 1 GB RAM I work with SQL Server 2008 (R2) and SQL Server ‘Denali’ and often connect to both the instances. Recently while I was connecting to Denali I encountered following error. Failed to retrieve data for this request. Microsoft.SqlServer.Management.Sdk.Sfc) ‘DATABASEPROPERTY’ is not a recognized built-in function name. (Microsoft SQL Server, Error: 195)... - [SQL SERVER - Performance Improvement with of Executing Stored Procedure with Result Sets in SQL Server 2012](https://blog.sqlauthority.com/2011/05/02/sql-server-performance-improvement-with-of-executing-stored-procedure-with-result-sets-in-denali/): Earlier I posted article SQL SERVER – Denali – Executing Stored Procedure with Result Sets. After reading this SQL Expert Ramdas asked following and very interesting question: This is a nice feature and i am sure would be used a lot. How is the performance of this as compared with using temp tables? I really loved this question, I ran the following code and measured the performance difference using execution plans. USE AdventureWorks2008R2 GO CREATE PROCEDURE mySP (@ShiftID INT) AS SELECT [ShiftID] ,[Name] ,[StartTime] ,[EndTime] ,[ModifiedDate] FROM [HumanResources].[Shift] WHERE [ShiftID] = @ShiftID GO -- Executing Stored Procedure EXEC mySP @ShiftID = 2... - [SQL SERVER - Migration Assistant for Access, MySQL, Oracle, Sybase](https://blog.sqlauthority.com/2011/05/01/sql-server-migration-assistant-for-access-mysql-oracle-sybase/): SQL Server Migration Assistant (SSMA) is a free supported tool from Microsoft that simplifies database migration process from Sybase Adaptive Server Enterprise (ASE) to SQL Server or SQL Azure. SSMA automates all aspects of migration including migration assessment analysis, schema and SQL statement conversion, data migration as well as migration testing. SSMA for Access 5.0 Microsoft SQL Server Migration Assistant (SSMA) for Access is a tool to automate migration from Microsoft Access database(s) to SQL Server or SQL Azure. SSMA for MySQL 5.0 Microsoft SQL Server Migration Assistant (SSMA) for MySQL is a tool to automate migration from MySQL database to... - [SQL SERVER - CTAS - Create Table As SELECT - What is CTAS?](https://blog.sqlauthority.com/2011/04/30/sql-server-ctas-create-table-as-select-what-is-ctas/): I have been working with the database for many years and I am aware of many common terminologies. Recently I was attending training myself and the instructor used the word 'CTAS' in the class. One of the attendees did not know the definition of this abbreviation. From this, I realized that not all of us come from the same background and we all have different levels and areas of expertise. - [SQL SERVER - 2012 - Executing Stored Procedure with Result Sets - New](https://blog.sqlauthority.com/2011/04/29/sql-server-2012-executing-stored-procedure-result-sets-new/): After reading my earlier article SQL SERVER – Denali – Executing Stored Procedure with Result Sets, one of the readers asked if this new feature (syntax) support multiple resultset of the stored procedure? Very interesting question indeed as most of the stored procedures that I usually come across have more than one resultset. I quickly look up the syntax online and realize it can be done quite easily. If you are using the earlier method of the temp table inserting the value of the stored procedure by executing, then the it does not support multiple resultset. This new capability of T-SQL can... - [SQL SERVER - 2012 - Executing Stored Procedure with Result Sets](https://blog.sqlauthority.com/2011/04/28/sql-server-denali-executing-stored-procedure-with-result-sets/): Here is a normal conversation I heard when I saw that the function (UDF) was used instead of the procedure (SP). Q: Why are you using User Defined Function instead of Stored Procedure? A: I cannot SELECT from SP, but I can from UDF. SQL Server’s next version ‘Denali’ is coming up with a very interesting feature called WITH RESULT SET. Using this feature, you can run the stored procedure and rename the columns used in it. The usual procedure of creating TempTable, executing the stored procedure and inserting the data into the TempTable may be time-consuming, that is why Denali... - [SQL SERVER - Introduction to SQL Azure - Creating Database and Connecting Database](https://blog.sqlauthority.com/2011/04/27/sql-server-introduction-to-sql-azure-creating-database-and-connecting-database/): I recently logged into new Azure Portal and I really think the product team has done excellent job to make it user-friendly and self intuitive. Here are the quick steps I have done after I logged into the portal here: Purchased subscription Created Server Created Database Connect using Database Honestly it is that simple. Here is the screen representations of the same.   Here you can specify your current IP address in start and end range. This way only from your IP you can connect to the server. I have noticed that one developer kept the IP Range Start: 0.0.0.0 and... - [SQLAuthority News - Pluralsight On-Demand FREE for SQL Server Course](https://blog.sqlauthority.com/2011/04/26/sqlauthority-news-pluralsight-on-demand-free-for-sql-server-course/): The Moral of Story You can watch the most popular SQL Server – TSQL course on Pluralsight On-Demand for FREE for the next 48 hours. It starts NOW! The Story Learning is always difficult. After learning how to apply your knowledge, learning in real life is even more difficult. Technology is moving faster than the speed of light and new technologies are always emerging – this is now the reality of the new technology world. Between all of this, I personally have very little time to learn new technology. I do not like eBooks (this statement warrants a whole new blog... - [SQLAuthority News - 1700th Blog Posts - Over 25 Millions of Views - A SQL Milestone](https://blog.sqlauthority.com/2011/04/25/sqlauthority-news-1700th-blog-posts-over-25-millions-of-views-a-sql-milestone/): It has been a tradition in this blog to write a “milestone blog post” for every 100th post. I am always looking forward to this because I am given a chance to do only three times a year. This year 2011 has been very nice to me so far- lots of interesting things have been happening. I listed a few here: (in no particular order) SQL SERVER – Summary of Month – Wait Type – Day 28 of 28 My series on wait types and queues has made me a whole different person. I have started to look at the database... - [SQL SERVER - How to ALTER CONSTRAINT](https://blog.sqlauthority.com/2011/04/24/sql-server-how-to-alter-constraint/): After reading my earlier blog post SQL SERVER – Prevent Constraint to Allow NULL. I recently received question from user regarding how to alter the constraint. No. We cannot alter the constraint, only thing we can do is drop and recreate it. Here is the CREATE and DROP script. CREATE DATABASE TestDB GO USE TestDB GO CREATE TABLE TestTable (ID INT, Col1 INT, Col2 INT) GO -- Create Constraint on Col1 ALTER TABLE TestTable ADD CONSTRAINT CK_TestTable_Col1 CHECK (Col1 > 0) GO -- Dropping Constraint on Col1 ALTER TABLE TestTable DROP CONSTRAINT CK_TestTable_Col1 GO -- Clean up USE MASTER GO ALTER... - [SQL SERVER - How to Use Decode in SQL Server?](https://blog.sqlauthority.com/2011/04/23/sql-server-using-decode-in-sql-server/): One of the reader of the blog has sent me question regarding how to use DECODE function in SQL Server. - [SQL SERVER - Potential Bottlenecks for Performance](https://blog.sqlauthority.com/2011/04/22/sql-server-potential-bottlenecks-for-performance/): In recent GIDS presentation, I was asked can I name potential bottlenecks for performance. I was taken back to my collage life with this question. I remember that I have memorized following names as potential bottlenecks. CPU RAM Hard Disk Network Application Code Today when I look back at this, I still think the same reference is correct. It seems very interesting that technology has really moved ahead but the essence and basics of  any subject are still same. Can you think of any other kind of bottleneck, which is not subset of above five topics which I have mentioned. Reference:... - [SQL SERVER - Prevent Constraint to Allow NULL ](https://blog.sqlauthority.com/2011/04/21/sql-server-prevent-constraint-to-allow-null/): With naked eyes, we often spot the evident problems but the specific details are missed many a time. Something similar happened recently. One of the blog readers sent me an email asking about a bug in how CHECK CONSTRAINT works. He suggested that check constraint accepts NULL even though the rule is specified. After looking at the whole script, I found out what he has done and how to prevent this type of error. Let us first reproduce the script where the constraint allows NULL value in the column. CREATE DATABASE TestDB GO USE TestDB GO CREATE TABLE TestTable (ID INT,... - [SQLAuthority News - Last 5 Days to WIN Windows Phone 7 - 140 Words to Win](https://blog.sqlauthority.com/2011/04/20/sqlauthority-news-last-5-days-to-win-windows-phone-7-140-words-to-win/): You can win Windows 7 Phone by writing only 140 Characters. You need to leave a comment over here: SQLAuthority News – Win Windows Phone from Idera in 140 Characters – A Cartoon Challenge of SQL over here. There are so far around 150 comments and I believe that chances of one person to win the contest is pretty decent. I have been personally using Windows 7 Phone for quite a some time and I really love it. Follow me on twitter to keep updated with updates. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Sudden Death of SSD on my Laptop - A Warning for SSD Users](https://blog.sqlauthority.com/2011/04/19/sqlauthority-news-sudden-death-of-ssd-on-my-laptop-a-warning-for-ssd-users/): The solid state drive on my personal laptop just died. Here’s the story. I have a DELL XPS laptop which is now 2.5 years old. The laptop had demonstrated no issues. About 6 months ago, I decided to upgrade the hard drive to solid state drive. There was a lot of hype in the market for SSD and it seemed that everybody is praising it. After thinking about it, I­­ finally chose to upgrade my personal laptop by purchasing SSD it with Rs. 15,000 (~USD 320). The SSD that I bought contains 120 GB and supports TRIM as well. For six... - [SQL SERVER - Speaking on T-SQL Worst Practices at Great Indian Developer Summit 2011 - Bangalore](https://blog.sqlauthority.com/2011/04/18/sql-server-speaking-on-t-sql-worst-practices-at-great-indian-developer-summit-2011-bangalore/): Presenting in front of techies is always fun. I will be speaking at Great Indian Developer Summit 2011 – Bangalore on April 19, 2011. Here is the details of my session: Session Title:“What did I do?” – T-SQL Worst Practices “Oh My God! What did I do?” Chances are you have heard, or even uttered, this expression. This demo-oriented session will have many examples where developers were dumbfounded by their own mistakes. The goal of this session is to learn which small details can be dangerous to the production environment and SQL Server as a whole. We will talk about common... - [SQL SERVER - Applying NOLOCK Hint at Query Level - NOLOCK for whole Transaction](https://blog.sqlauthority.com/2011/04/17/sql-server-applying-nolock-hint-at-query-level-nolock-for-whole-transaction/): Just received very interesting question in email: “How do I apply NOLOCK hint to my whole query. I know that I can use NOLOCK at every table level but I have many tables in my query and I want to apply the same to all the tables. I want to do something like following script. SELECT * FROM AdventureWorks.Sales.SalesOrderDetail sod INNER JOIN AdventureWorks.Sales.SalesOrderHeader soh ON sod.SalesOrderID = soh.SalesOrderID ORDER BY sod.ModifiedDate OPTION (NOLOCK) When I ran it it gives me following error: Msg 102, Level 15, State 1, Line 7 Incorrect syntax near ‘NOLOCK’. Please recommend.” I just never thought of... - [SQL SERVER - Making Database to Read Only - Changing Database to Read/Write](https://blog.sqlauthority.com/2011/04/16/sql-server-making-database-to-read-only-changing-database-to-readwrite/): I recently received the following comments on my earlier blog about Making database to read only. "Today i was trying to attach the (MDF,NDF,LDF ) sql server 2008 database which i have received from my client. After attachment the database status is showing (Read-Only) (Eg.database name (Read-Only). How do i make to normal mode for the data updation. is there any query available to resolve this problem. Your help will be highly helpful." Let's learn Making Database to Read Only and Changing Database to Read/Write. - [SQL SERVER - Finding Location of Log File when Primary Datafile is Crashed](https://blog.sqlauthority.com/2011/04/15/sql-server-finding-location-of-log-file-when-primary-datafile-is-crashed/): My friend and SQL Expert Vinod Kumar asked a very interesting question in his latest blog post. Quick Quiz:Do you need the primary data file available to backup your transaction log after a crash? This question can have multiple answers. While he asked the question on blog, I was sitting very next to him and he asked what do I think about it. We had less than 10 minutes during the lunch break after which we had to get back on work. To simulate Primary Datafile is corrupted (again please note – this is just a quick exercise and not real... - [SQL SERVER - Transaction Log Impact Detection Using DMV - dm_tran_database_transactions ](https://blog.sqlauthority.com/2011/04/14/sql-server-transaction-log-impact-detection-using-dmv-dm_tran_database_transactions/): Just a few days ago before I received the email from blog reader asking if there is any DMV which can provide details about the effect of a transaction on the transaction log file. Absolutely! Here is a quick script which can provide the necessary details: SELECT transaction_id, DB_NAME(database_id) DatabaseName, database_transaction_begin_time TransactionBegin, CASE database_transaction_type WHEN 1 THEN 'Read/Write' WHEN 2 THEN 'Read only' WHEN 3 THEN 'System' END AS TransactionType, CASE database_transaction_state WHEN 1 THEN 'Not Initialized' WHEN 3 THEN 'Transaction No Log' WHEN 4 THEN 'Transaction with Log' WHEN 5 THEN 'Transaction Prepared' WHEN 10 THEN 'Commited' WHEN 11 THEN 'Rolled... - [SQL SERVER - FIX - ERROR : Msg 3201, Level 16 Cannot open backup device . Operating system error 5(Access is denied.)](https://blog.sqlauthority.com/2011/04/13/sql-server-fix-error-msg-3201-level-16-cannot-open-backup-device-operating-system-error-5access-is-denied/): Recently I formatted my computer and installed fresh SQL Server in it. I installed the AdventureWorks database in my database. Once done, I wanted to run few test scripts on my database. Just like every DBA, I decided to take backup of my database - this way I can restore it back to attain an original database state. As soon as I ran the backup command I ended up with the following error. This error is due to a permissions issue on the local disk and user account which is running SQL Server. In this blog post we will talk about the operating system error. - [SQL SERVER - Query to Recent Query on Server with Execution Plan Function to Get SQL](https://blog.sqlauthority.com/2011/04/12/sql-server-query-to-recent-query-on-server-with-execution-plan-function-to-get-sql/): This blog post is written in response to the T-SQL Tuesday hosted by Matt Velic. He has picked very interesting topic which is related to APPLY clause of the T-SQL. When I read the subject, I really liked the subject. This is very new subject and it is quite a interesting choice by Matt. I tried to explain in simpler words regarding APPLY but it is not that easy to explain. Instead Here is the quick theory from BOL: The APPLY operator allows you to invoke a table-valued function for each row returned by an outer table expression of a query.... - [SQL SERVER – expressor Studio Includes Powerful Scripting Capabilities](https://blog.sqlauthority.com/2011/04/11/sql-server-expressor-studio-includes-powerful-scripting-capabilities/): One of the major problems in developing a data integration application is writing transformation code.  Many tools try to meet this need by providing a large number of operators that minimize coding through configuration. Specialized operators are fine for basic transformations, but most ETL transformations require logic specific to the particular application.  For that, tools resort to full featured coding tools such as Microsoft Visual Studio.  expressor software has taken a different approach.  The expressor Studio tool provides a light-weight scripting language called expressor Datascript and integrates an editing environment into each programmable operator. These tools allow development of transformation scripts... - [SQL SERVER - TempDB in RAM for Performance](https://blog.sqlauthority.com/2011/04/10/sql-server-tempdb-in-ram-for-performance/): Performance Tuning is always the most interesting subject when we talk about software application. While I was recently discussing performance tuning with my friend, we started to talk about the best practices for TempDb. I also pointed my friend to the excellent blog post written by Cindy Gross on the subject: Compilation of SQL Server TempDB IO Best Practices. One of the discussion points was that we should put TempDB on the drive which is always giving better performance. - [SQL SERVER - Add New Column With Default Value](https://blog.sqlauthority.com/2011/04/09/sql-server-add-new-column-with-default-value/): SQL Server is a very interesting system, but the people who work in SQL Server are even more remarkable. The amount of communication, the thought process, the brainstorming that they do are always phenomenal. Today I will share a quick conversation I have observed in one of the organizations that I recently visited. While we were heading to the conference room, we passed by some developers and I noticed the following script on the screen of one of the developers. CREATE TABLE TestTable (FirstCol INT NOT NULL) GO ------------------------------ -- Option 1 ------------------------------ -- Adding New Column ALTER TABLE TestTable ADD... - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day Next](https://blog.sqlauthority.com/2011/04/08/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-next/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next Day 4 – March 26, 2011 I woke up again at 5.00 AM. I really had nothing to do. Everything was over the night before, but waking up at this time had become a habit after I... - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day 3](https://blog.sqlauthority.com/2011/04/07/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-3/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next Day 3 – March 25, 2011 My wife woke me up at 5.00 AM. Two hours of power sleep seemed inadequate as I had only less than 6 hours of sleep during the last 3 days. Today... - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day 2](https://blog.sqlauthority.com/2011/04/06/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-2/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next Day 2 – March 24, 2011 I woke up once again at 5.00 AM as I was planning to leave at 6.00 AM. While I was heading towards the venue, I was thinking about the remaining day... - [SQLAuthority News - Win Windows Phone from Idera in 140 Characters - A Cartoon Challenge of SQL](https://blog.sqlauthority.com/2011/04/05/sqlauthority-news-win-windows-phone-from-idera-in-140-characters-a-cartoon-challenge-of-sql/): I personally have Windows Phone and I love it. The user friendliness and integration with social media is remarkable. My wife Nupur is big fan of Windows Live tools and Windows Phone as well. Well, this blog post is not about our preference of Windows Phone but about YOU a unlocked Windows Phone. The Windows Phone will be directly sponsored by Idera. If you want to win Windows Phone. Just do one thing, complete following cartoon. Every day queries go slow and we think it is SQL Server but the reality is that it is us who need to know the... - [SQL SERVER - MondayMeme - 11 Words or Less](https://blog.sqlauthority.com/2011/04/04/sql-server-mondaymeme-11-words-or-less/): My friend Thomas LaRock [Blog | Twitter] started interested tradition of writing a blog post of 11 words of less. Following the same SQL Expert and my fellow friend Amit Banerjee [Blog | Twitter] wrote interesting 11 words statement and tagged me. Here is my contribution: “Use Wait Types and Queues to Get Quick Performance Bottleneck.” I am not going to tag anybody but if you have quick one liner do share over here or blog yourself and link back. Reference: Pinal Dave (https://blog.sqlauthority.com)   - [SQLAuthority News - A Million Hits a Month - A Milestone](https://blog.sqlauthority.com/2011/04/04/sqlauthority-news-a-million-hits-a-month-a-milestone/): March 2011 has been very good month. SQLAuthority Blog got more than 1 Million Hits in a single month. Total hits so far is around 25 Million from the inception of the blog. My statistics are maintained by WordPress.com by themselves. I have shared the same over here. You can see the permanent page of the same over here as well. I am very thankful to all of you for your unconditional support to this blog. You can subscribe to blog by Feed, Email and Twitter. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day 1](https://blog.sqlauthority.com/2011/04/03/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-1/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next Day 1 – March 23, 2011 After my 3 hours of power sleep, I was up before 5.00 AM. I got ready and headed to TechEd Venue. Even though it was pretty early and very dark, it... - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day 0](https://blog.sqlauthority.com/2011/04/02/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-0/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next TechEd India is the one of the best Technology Events in India. The event venue was at Hotel Lalit Ashok, Bangalore. This three-day event was from March 23 to March 25, 2011, and this was my third... - [SQLAuthority News - Today is First April - April Fool's Day](https://blog.sqlauthority.com/2011/04/01/sqlauthority-news-today-is-first-april-april-fools-day/): I was planning to write something technical today but I realize that today is April 1st, and it is April Fool’s Day. When I used to be kid, I really enjoyed this day. There was innocent fun to play a small prank on friends. As I grew older it started to fade off. Since couple of years, I am considering this day as more like day for fun and good laugh. I got following images from very good friend through email. I will be stunned and speechless if this happens to me. Kudos to those who worked hard to pull the... - [SQL SERVER - 'Denali' - A Simple Example of Contained Databases](https://blog.sqlauthority.com/2011/03/31/sql-server-denali-a-simple-example-of-contained-databases/): Recently I was asked with the question: What is new for Database Security in SQL Server “Denali”? I think this is a very interesting question as I always wanted to talk about Contained Database, and this question gives me the chance to do so. Let us start with discussing contained database. A Contained Database is a database which contains all the necessary settings and metadata, making database easily portable to another server. This database will contain all the necessary details and will not have to depend on any server where it is installed for anything. You can take this database and... - [SQL SERVER - TechEd 2011 - Random Question and Answers](https://blog.sqlauthority.com/2011/03/30/sql-server-teched-2011-random-question-and-answers/): Three Days of TechED 2011 India was great event and I had so much fun that I can not express. I met around 1000 people during this 3 days and discussed a lot of things. I got few question again and again. I thought about blogging all of those 7 commonly asked question on blog. 1) What is “Denali”? A. Denali is mountain but if you are asking about SQL Server – it is code name of the next version. 2) When is “Denali” releasing? A. It is next version of SQL Server so Microsoft will announce the release date. You... - [SQL SERVER - Fix : Error : The request failed or the service did not respond in a timely fashion](https://blog.sqlauthority.com/2011/03/29/sql-server-fix-error-the-request-failed-or-the-service-did-not-respond-in-timely-fashion-consult-the-event-log-or-other-applicable-error-logs-for-details/): Two days ago, I was participating TechEd India 2011 and I had a great time presenting on various subjects. My computer fortunately behaved very well and I consider myself lucky for it. However, very next day, today, when I went to the office and turned on the machine, it did not start SQL Server. I was a bit confused and very quickly checked SQL Server Services. I noticed that services were OFF. I tried to turn on the services, but it keeps on giving me following error about request failed. - [SQL SERVER - Denali - Improvement in Startup Options](https://blog.sqlauthority.com/2011/03/28/sql-server-denali-improvement-in-startup-options/): I often work with advanced features of the SQL Server and this really led me to change how SQL Server is starting up. Recently I was changing the start up options in SQL Server and I was very delighted when I saw the startup option screen in Denali. It has really improved and is very convenient to use. Now I realized that the more I use Denali, the more I love it. - [SQL SERVER - 32 Bit - 64 Bit - HTML5 - Database Backup Restore](https://blog.sqlauthority.com/2011/03/27/sql-server-32-bit-64-bit-html5-database-backup-restore/): During TechEd India I was attending HTML5 session along with regular Database sessions. Couple of attendees were discussing database there and I find the incidence very interesting. - [SQL SERVER - Related Scripts for TechEd 2011 Presentations](https://blog.sqlauthority.com/2011/03/26/sql-server-related-scripts-for-teched-2011-presentations/): I had great time yesterday presenting at TechEd India 2011 on two subjects – Wait Types and Extended Events. I had shared the links of where all the scripts can be downloaded in the last slide. Here is the same links one more time. Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Scripts: Extended Events SQL Server Waits and Queues – Your Gateway to Perf. Troubleshooting Scripts: SQL SERVER – Summary of Month – Wait Type – Day 28 of 28 Videos, Slide decks are the complete report of the event will be posted on the blog very soon.... - [SQLAuthority News - Win Surprise Gift at TechED 2011 Sessions - Wait Types and Extended Events](https://blog.sqlauthority.com/2011/03/25/sqlauthority-news-win-surprise-gift-at-teched-2011-sessions-wait-types-and-extended-events/): A quick note for all – If you are attending my TechEd sessions today here are few notes for you. Session Time Sessions Date: March 25, 2011 Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Date and Time: March 25, 2011 12:00 PM to 01:00 PM SQL Server Waits and Queues – Your Gateway to Perf. Troubleshooting Date and Time: March 25, 2011 04:15 PM to 05:15 PM Surprise Gifts If you are attending the session – rest assure – few of you are going to get very interesting surprise gift. A good quality one! To win – you... - [SQL SERVER - Tomorrow 2 Sessions on Performance Tuning at TechEd India 2011 - March 25, 2011](https://blog.sqlauthority.com/2011/03/24/sql-server-tomorrow-2-sessions-on-performance-tuning-at-teched-india-2011-march-25-2011/): Tomorrow is the third day of the TechED India 2011 at Bangalore. I will be speaking on two very interesting sessions. If you are developer, database administrator or just want to learn something new and interesting, I suggest you attend my two sessions tomorrow. Here is the details of the session. Sessions Date: March 25, 2011 Here is the abstract of the session: Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Date and Time: March 25, 2011 12:00 PM to 01:00 PM History repeats itself! SQL Server 2008 has introduced a very powerful, yet very minimal reoccurring feature called... - [SQL SERVER - Denali - ObjectID in Negative - Local TempTable has Negative ObjectID](https://blog.sqlauthority.com/2011/03/23/sql-server-denali-objectid-in-negative-local-temptable-has-negative-objectid/): I used to run the following script to generate random large results. However, when I ran this on Denali I noticed a very interesting behavior: SELECT o1.OBJECT_ID,o1.name, o2.OBJECT_ID, o2.name FROM sys.all_objects o1 CROSS JOIN sys.all_objects o2 I noticed lots of negative object_ID’s on Denali, whereas my experience on SQL Server 2008 R2 as well as the earlier versions was it was always giving me a positive number. This whole thing interested me so I decided to find out objects which belonged to the negative object_ID. When I looked at the name of the object, it was very evident that it belonged... - [SQLAuthority News - Solid Quality Journal - Importance of Statistics](https://blog.sqlauthority.com/2011/03/22/sqlauthority-news-solid-quality-journal-importance-of-statistics/): My article on “Important of Statistics” has been published in Solid Quality Journal. Statistics are a key part of getting solid performance. In this article we will go over the basics of the statistics and various best practices related to Statistics. We will go over various frequently asked questions like when to update statistics and difference between sync and async update of statistics. We will also discuss the pros and cons of the statistics update. I have answered one very important questions in this article: Should keep Auto Create Statistics and Auto Update Statistics settings true/on? Download Importance of Statistics Reference:... - [SQL SERVER - SQL Server Migration Assistant (SSMA) - Tools - Video - Download](https://blog.sqlauthority.com/2011/03/21/sql-server-sql-server-migration-assistant-ssma-tools-video-download/): I was recently working on learning various new stuff. I just would like to share very interesting resources here today. Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from any other data platform to SQL Server 2005, SQL Server 2008, SQL Server 2008 R2 and SQL Azure. Here are few important resources links: Microsoft SQL Server Migration Assistant (SSMA) Team’s Blog One very front page of the blog, I noticed very interesting diagram – where it displays four database products. One can click on any of them to go to... - [SQL SERVER - 2012 - Zoom Query Editor](https://blog.sqlauthority.com/2011/03/20/sql-server-denali-feature-zoom-query-editor/): SQL Server next version ‘Denali’ is coming up with very neat feature which can be used while presentations, group discussion or for people who prefers large fonts. - [SQL SERVER - Log File Growing for Model Database - model Database Log File Grew Too Big](https://blog.sqlauthority.com/2011/03/19/sql-server-log-file-growing-for-model-database-model-database-log-file-grew-too-big/): After reading my earlier article SQL SERVER – master Database Log File Grew Too Big, I received an email recently from another reader asking why does the log file of model database grow every day when he is not carrying out any operation in the model database. As per the email, he is absolutely sure that he is doing nothing on his model database; he had used policy management to catch any T-SQL operation in the model database and there were none. This was indeed surprising to me. I sent a request to access to his server, which he happily agreed... - [SQL SERVER 2008 - 2012 - Declare and Assign Variable in Single Statement](https://blog.sqlauthority.com/2011/03/18/sql-server-2008-2011-declare-and-assign-variable-in-single-statement/): Many of us are tend to overlook simple things even if we are capable of doing complex work. In SQL Server 2008, inline variable assignment is available. This feature exists from last 3 years, but I hardly see its utilization. One of the common arguments was that as the project migrated from the earlier version, the feature disappears. I totally accept this argument and acknowledge it. However, my point is that this new feature should be used in all the new coding – what is your opinion? The code which we used in SQL Server 2005 and the earlier version is... - [SQL SERVER - INSERT TOP (N) INTO Table - Using Top with INSERT](https://blog.sqlauthority.com/2010/02/27/sql-server-insert-top-n-into-table-using-top-with-insert/): During my recent training at one of the clients, I was asked regarding the enhancement in TOP clause. When I demonstrated my script regarding how TOP works along with INSERT, one of the attendees suggested that I should also write about this script on my blog. Let me share this with all of you and do let me know what you think about this. Note that there are two different techniques to limit the insertion of rows into the table. Method 1: INSERT INTO TABLE … SELECT TOP (N) Cols… FROM Table1 Method 2: INSERT TOP(N) INTO TABLE … SELECT Cols…... - [SQLAuthority News - Keeping Your Ducks in a Row](https://blog.sqlauthority.com/2010/02/26/sqlauthority-news-keeping-your-ducks-in-a-row/): Last year during my visit to SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 2 I have received ducks from the event. Well during the same event I had learned from Jonathan Kehayias the saying of ‘Keeping Your Ducks in a Row‘. The most popular theory suggests that “ducks in a row” came from the world of sports, specifically bowling. Early bowling pins were often shorter and thicker than modern pins, which lead to the nickname ducks. Before the advent of automatic resetting machines, these “duck pins” would be manually put back into place between bowling rounds. Therefore, having... - [SQLAuthority News - MUGH - Microsoft User Group Hyderabad - Feb 2, 2010 Session Review](https://blog.sqlauthority.com/2010/02/25/sqlauthority-news-mugh-microsoft-user-group-hyderabad-feb-2-2010-session-review/): Earlier this month, I was very fortunate to visit Microsoft User Group Hyderabad lead by Hima Vindu Vejella. Hima is a very enthusiastic leader and kind person. I had a wonderful time meeting her as well her husband during my visit to Hyderabad. I had presented session on Index, which was well received. Brief information on this session is given below: The Other Side of SQL Server Index: Advanced Solutions to Ancient Problem SQL Server Index is very powerful tool and when in hand of the less skilled expert, the same tool can pose a danger to its performance and kill... - [SQL SERVER - Introduction to Rollup Clause](https://blog.sqlauthority.com/2010/02/24/sql-server-introduction-to-rollup-clause/): In this article we will go over basic understanding of Rollup clause in SQL Server. ROLLUP clause is used to do aggregate operation on multiple levels in hierarchy. Let us understand how it works by using an example. - [Data Mining Algorithms (Analysis Services - Data Mining)](https://blog.sqlauthority.com/2010/02/23/sqlauthority-news-links-to-book-on-line-data-mining-algorithms-analysis-services-data-mining/): I quite often receive requests for the Data Mining Algorithms details. Book Online has wonderful resources for the same. I suggest to read them here. - [SQLAuthority News - Blog Subscription and Comments RSS](https://blog.sqlauthority.com/2010/02/22/sqlauthority-news-blog-subscription-and-comments-rss/): Quite often I get email where many readers ask me how to get email from SQLAuthority.com blog. Today very quickly I will go over few standard practices of this blog using you can stay connected with SQLAuthority.com First the most important is search: I received hundreds of emails and hundreds of comments every day. I try to answer each of them but if you have any urgent question I strongly suggest to search in my custom SQLAuthority.com Search. It searches in all the blogs as well in the comments. Search @ SQLAuthority.com If you want to stay connected with SQLAuthority.com using... - [SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table)](https://blog.sqlauthority.com/2010/02/21/sql-server-if-existsselect-null-from-table-vs-if-existsselect-1-from-table/): Few days ago I wrote article about SQL SERVER – Stored Procedure Optimization Tips – Best Practices. I received lots of comments on particular blog article. In fact, almost all the comments are very interesting. If you have not read all the comments, I strongly suggest to read them. Click here to read the comments. The most interesting comment conversation is among Divya, Brian and Marko. Please read the comments of Marko for sure. It is the comment, which has triggered this post. Comments by Divya I have seen in one of the blogs to use EXISTS like IF EXISTS(Select null... - [SQL SERVER - Recompile Stored Procedure at Run Time](https://blog.sqlauthority.com/2010/02/20/sql-server-recompile-stored-procedure-at-run-time/): I recently received an email from reader after reading my previous article on SQL SERVER – Plan Recompilation and Reduce Recompilation – Performance Tuning regarding how to recompile any stored procedure at run time. There are multiple ways to do this. If you want your stored procedure to always recompile at run time, you can add the keyword RECOMPILE when you create the stored procedure. Additionally, if the stored procedure has to be recompiled at only one time, in that case, you can add RECOMPILE word one time only and run the SP as well. Let us go over these two options. - [SQLAuthority News - Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1](https://blog.sqlauthority.com/2010/02/19/sqlauthority-news-microsoft-sql-server-migration-assistant-2008-for-mysql-v1-0-ctp1-2/): Microsoft SQL Server Migration Assistant (SSMA) 2008 is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL to SQL Server 2008 and SQL Azure. SSMA 2008 for MySQL v1.0 CTP1 provides an assessment of migration efforts as well as automates schema and data migration. Download Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1 Download Microsoft SQL Server Migration Assistant 2005 for MySQL v1.0 CTP1 Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Plan Recompilation and Reduce Recompilation - Performance Tuning](https://blog.sqlauthority.com/2010/02/18/sql-server-plan-recompilation-and-reduce-recompilation-performance-tuning/): Recompilation process is same as compilation and degrades server performance. In SQL Server 2000 and earlier versions, this was a serious issue but in SQL server 2005, the severity of this issue has been significantly reduced by introducing a new feature called Statement-level recompilation. When SQL Server 2005 recompiles stored procedures, only the statement that causes recompilation is compiled, rather than the entire procedure. Recompilation occurs because of following reason: On schema change of objects. Adding or dropping column to/from a table or view Adding or dropping constraints, defaults, or rules to or from a table. Adding or dropping an index... - [SQLAuthority News - SQL Server Technical Article - The Data Loading Performance Guide](https://blog.sqlauthority.com/2010/02/17/sqlauthority-news-sql-server-technical-article-the-data-loading-performance-guide/): Note: SQL Server Technical Article – The Data Loading Performance Guide by Microsoft The white paper describes load strategies for achieving high-speed data modifications of a Microsoft SQL Server database. “Bulk Load Methods” and “Other Minimally Logged and Metadata Operations” provide an overview of two key and interrelated concepts for high-speed data loading: bulk loading and metadata operations. After this background knowledge, white paper describe how these methods can be used to solve customer scenarios. Script examples illustrating common design pattern are found in “Solving Typical Scenarios with Bulk Loading” Special consideration must be taken when you need to load and... - [SQL SERVER - Stored Procedure Optimization Tips - Best Practices](https://blog.sqlauthority.com/2010/02/16/sql-server-stored-procedure-optimization-tips-best-practices/): We will go over how to optimize Stored Procedure with making simple changes in the code. Please note there are many more other tips, which we will cover in future articles. - [SQL SERVER - Difference Between Update Lock and Exclusive Lock](https://blog.sqlauthority.com/2010/02/15/sql-server-difference-between-update-lock-and-exclusive-lock/): I have often got this question on this blog as well in different SQL Training. What is the difference between Update Lock and Exclusive Lock? When Exclusive Lock is on any processes no other lock can be placed on that row or table. Every other process have to wait till Exclusive Lock is complete its tasks. Update Lock is kind of Exclusive Lock except it can be placed on the row which already have Shared Lock on it. Update Lock reads the data of row which has Shared Lock, as soon as Update Lock is ready to change the data it... - [SQLAuthority News - SuperFlow for Creating SRS Report Models in Configuration Manager 2007](https://blog.sqlauthority.com/2010/02/14/sqlauthority-news-superflow-for-creating-srs-report-models-in-configuration-manager-2007/): Note : Download SuperFlow for Creating SRS Report Models in Configuration Manager 2007 by Microsoft The SuperFlow interactive content model provides a structured and interactive interface for viewing documentation. Each SuperFlow includes comprehensive information about a specific dataflow, workflow, or process. Depending on the focus of the SuperFlow, you will find overview information, steps that include detailed information, procedures, sample log entries, best practices, real-world scenarios, troubleshooting information, security information, animations, or other information. Each SuperFlow also includes links to relevant resources, such as Web sites or local files that are copied to your computer when you install the SuperFlow. The... - [SQLAuthority News - Download SQL Server 2008 Express Datasheet](https://blog.sqlauthority.com/2010/02/13/sqlauthority-news-download-sql-server-2008-express-datasheet/): Microsoft® SQL Server® 2008 Express is a free edition of SQL Server ideal for learning, developing and powering desktop and small server applications and for redistribution by ISVs. Download SQL Server 2008 Express Datasheet Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad Community Tech Days - Jan 30, 2010 - Huge Success](https://blog.sqlauthority.com/2010/02/12/sqlauthority-news-ahmedabad-community-tech-days-jan-30-2010-huge-success/): Ahmedabad Community Tech Days was held on Jan 30, 2010 at Bhaikaka Hall. This event was very received well and attended by a large number of technology enthusiasts and a number of TOP speakers from various technologies. During this event Pinal Dave (myself) and Jacob Sebastian had decided to do something different as the theme was innovation and efficiency. I presented session on SQL Azure, and Jacob presented session on SQL Server R2. This was a bit different than our usual relational SQL Server Presentation. This event was very well received, and we had received great feedback from the attendees. In... - [SQL SERVER - ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE](https://blog.sqlauthority.com/2010/02/11/sql-server-alter-database-dbname-set-single_user-with-rollback-immediate/): I have recently been conducting lots of training on SQL Server technology. During these trainings, I quite often create new databases and drop them as well. Many times, I am not able to drop the database as one of my instances might be using the database. As I am working on my laptop and very confident regarding dropping the database, I always take my database in single user and drop it immediately. ALTER DATABASE [YourDbName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; The above query will rollback any transaction which is running on that database and brings SQL Server database in a single... - [SQLAuthority News - Converting a Delimited String of Values into Columns](https://blog.sqlauthority.com/2010/02/10/sqlauthority-news-converting-a-delimited-string-of-values-into-columns/): This blog post is about two great bloggers and their excellent series of blog posts. It was quite unusual to see two bloggers posting articles that are supporting each other and constantly improving the articles to the next level. Two blogs which I am going to mention here are as follows: SELECT Blog FROM Brad.Schulz CROSS APPLY SQL.Server() – Brad Schulz and Demystifying SQL Server – Adam Haines. Before continuing this blog post, I suggest you all to bookmark these blogs for future reference. The whole thing started when Adam tried to answer the question “How to transform a delimited values... - [SQL SERVER - Brief Note about StreamInsight - What is StreamInsight](https://blog.sqlauthority.com/2010/02/09/sql-server-brief-note-about-streaminsight-what-is-streaminsight/): StreamInsight is a new event processing platform introduced in upcoming version SQL Server 2008 R2. Similar to other components such as SSIS, SSAS or Service Broker, it also needs to be installed along with the SQL Server. Up to SQL Server 2005, Microsoft’s main focus on SQL Server was to build a platform to efficiently store, manage, and retrieve data. However, now, Microsoft enhanced SQL Server to accept, monitor, and respond to complex and high number of events in near zero latency. For this, Microsoft introduced StreamInsight using the following approaches: Continuous and incremental processing of unending sequences of events. Lightweight... - [SQL SERVER - Find the Size of Database File - Find the Size of Log File](https://blog.sqlauthority.com/2010/02/08/sql-server-find-the-size-of-database-file-find-the-size-of-log-file/): I encountered the situation recently where I needed to find the size of the log file. When I tried to find the script by using Search@SQLAuthority.com I was not able to find the script at all. Here is the script, if you remove the WHERE condition you will find the result for all the databases. SELECT DB_NAME(database_id) AS DatabaseName, Name AS Logical_Name, Physical_Name, (size*8)/1024 SizeMB FROM sys.master_files WHERE DB_NAME(database_id) = 'AdventureWorks' GO Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Server 2008 R2 Update for Developers Training Kit](https://blog.sqlauthority.com/2010/02/07/sql-server-sql-server-2008-r2-update-for-developers-training-kit/): Note:   Download SQL Server 2008 R2 Update for Developers Training Kit by Microsoft SQL Server 2008 R2 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2008. The SQL Server 2008 R2 Update for Developers Training Kit is ideal for developers who want to understand how to take advantage of the key improvements introduced in SQL Server 2008 and SQL Server 2008 R2 in their applications, as well as for developers who are new to SQL Server. The training kit is brought to you by Microsoft Developer and Platform Evangelism. Download SQL Server... - [SQLAuthority News - Presenting Two Sessions at TechED Sri Lanka](https://blog.sqlauthority.com/2010/02/06/sqlauthority-news-presenting-two-sessions-at-teched-sri-lanka/): I will be presenting following two sessions at TechEd Sri Lanka this week. I am very excited as this is very first time I will be presenting in TechEd event. I have previously presented many sessions but I have never presented at this premier Microsoft Event. I will be presenting on following two subject. The history of the Log: Change Data Capture (CDC) Pinal Dave on 8-Feb-10 at 02.00 – 03.15 Learn to capture the history of data using CDC. An age old method of writing queries and triggers to capture change in database table is replaced with much powerful asynchronous... - [SQL SERVER - Stream Aggregate Showplan Operator - Reason of Compute Scalar before Stream Aggregate](https://blog.sqlauthority.com/2010/02/05/sql-server-stream-aggregate-showplan-operator-reason-of-compute-scalar-before-stream-aggregate/): I keep a check on the questions received from my readers; when any question crosses my threshold, I surely try to blog about it online. Stream Aggregate is a quite commonly encountered showplan operator. I have often found it in very simple COUNT(*) operation’s execution plan. If you like to read an official note on the subject, you can read the same on Book Online over here. The Stream Aggregate operator groups rows by one or more columns and then calculates one or more aggregate expressions returned by the query. Running the following query will give you Stream Aggregate Operator in... - [SQL SERVER - Get the List of Object Dependencies - sp_depends and information_schema.routines](https://blog.sqlauthority.com/2010/02/04/sql-server-get-the-list-of-object-dependencies-sp_depends-and-information_schema-routines-and-sys-dm_sql_referencing_entities/): Recently, I read a question on my friend‘s SQL site regarding the following: sp_depends does not give appropriate results whereas information_schema. routines do give proper answers. - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010 - Review Part Fun](https://blog.sqlauthority.com/2010/02/03/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010-review-part-fun/): MVP Open Day South Asia was held in Hyderabad from Jan 20, 2010 to Jan 23, 2010. This event was a fun-filled event as well as an educational one. The event was held at Microsoft IDC at Hyderabad, the largest Microsoft Development location after Redmond. I had great time meeting my friends and some of the renowned experts from all over the South Asia. The whole event started with networking with other MVPs as well as Product Group members. Besides lots of learning and meeting experts, this event was filled with fun too. The best thing for me was that I... - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010 - Review Part Business](https://blog.sqlauthority.com/2010/02/02/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010-review-part-business/): MVP Open Day South Asia was held in Hyderabad from Jan 20, 2010 to Jan 23, 2010. This event was a fun-filled as well as an educational event. This event was held at Microsoft IDC at Hyderabad – the largest Microsoft Development location after Redmond. I had a great time meeting my friends and some of the renowned experts from all over the South Asia. The whole event started with networking with other MVPs as well with Product Group members. - [SQL SERVER - Question - How to Convert Hex to Decimal](https://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/): In one of the recent projects, I realize the bottleneck of the query was an inline function which was converting Hex to Decimal. I optimized the inline function and reduced the query running time to one-tenth of the original running time. Later, I was eager to find out the script my blog readers might be using for hex to decimal conversion. Please leave your comments here and I will consider all the valid answers and publish with due credit to the author in one of the future posts. If the script you have posted here is not your original script, I... - [SQL SERVER - Location of Resource Database in SQL Server Editions](https://blog.sqlauthority.com/2010/01/31/sql-server-location-of-resource-database-in-sql-server-editions/): While working on a project of database backup and recovery, I found out that my client was not aware of the resource database at all. Location of Resource. - [SQL SERVER - Several Readers Questions and Readers Answers](https://blog.sqlauthority.com/2010/01/30/sql-server-several-readers-questions-and-readers-answers/): I often get questions on blog and many times I even get answers from readers as well. This article is collection of few of the questions and answers by readers of this blog. Q. How the records of a table can be scripted in INSERT INTO statements? A. In SQL Server 2008 : Right click Database > Tasks > Generate Scripts > In the wizard on Choose Script Option page, set Script Data option to True and complete the wizard.For SQL 2005 or earlier versions, use Database Publishing Wizard. For more details about Database Publishing wizard, please visit the blog https://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/... - [SQLAuthority News - Leadership Quotes and Inspiration](https://blog.sqlauthority.com/2010/01/29/sqlauthority-news-leadership-quotes-inspiration/): There is a big difference between leader and manager. There are plenty of interesting details written on this subject on the internet. In a recent presentation on leadership of one of the organizations I have presented a few of the quotes on the leadership subject to them. The leadership quotes were very much appreciated by the team so I am writing them over here. - [SQLAuthority News - Community Tech Days - Jan 30, 2010 - Must Attend](https://blog.sqlauthority.com/2010/01/28/sqlauthority-news-community-tech-days-jan-30-2010-must-attend/): Attend deep technology sessions for developers and IT professionals, as some of the best-known names come to your city to share their insights in topics ranging from .Net, Visual studio, Silverlight, to Windows and SQL Server. Build connections with Microsoft experts and community members and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. In Ahmedabad this event will happen on January 30, 2010. Just like last event we are expecting this time as well the event will have astonishing success and huge response. We will have five tech sessions back to back... - [SQLAuthority News - SQL Server 2008 R2 - Release Date in May 2010](https://blog.sqlauthority.com/2010/01/27/sqlauthority-news-sql-server-2008-r2-release-date-in-may-2010/): Microsoft has announced that SQL Server 2008 R2 will be available by May 2010. Its CTP (Community Technology Preview) version was already available from August 2009. It is still available for download. - [SQLAuthority News - Download White Paper - Troubleshooting Performance Problems in SQL Server 2008](https://blog.sqlauthority.com/2010/01/26/sqlauthority-news-download-white-paper-troubleshooting-performance-problems-in-sql-server-2008/): Troubleshooting Performance Problems in SQL Server 2008 SQL Server Technical Article Writers: Sunil Agarwal, Boris Baryshnikov, Keith Elmore, Juergen Thomas, Kun Cheng, Burzin Patel Technical Reviewers: Jerome Halmans, Fabricio Voznika, George Reynya Published: March 2009 It’s not uncommon to experience the occasional slowdown of a database running the Microsoft SQL Server database software. The reasons can range from a poorly designed database to a system that is improperly configured for the workload. As an administrator, you want to proactively prevent or minimize problems; if they occur, you want to diagnose the cause and take corrective actions to fix the problem whenever... - [SQL SERVER - Find Statistics Update Date - Update Statistics](https://blog.sqlauthority.com/2010/01/25/sql-server-find-statistics-update-date-update-statistics/): Statistics are one of the most important factors of a database as it contains information about how data is distributed in the database objects (tables, indexes etc). It is quite common to listen people talking about not optimal plan and expired statistics. Quite often I have heard the suggestion to update the statistics if query is not optimal. Please note that there are many other factors for query to not perform well; expired statistics are one of them for sure. If you want to know when your statistics was last updated, you can run the following query. USE AdventureWorks GO SELECT... - [SQLAuthority News - Download Sample Database for Microsoft SQL Server](https://blog.sqlauthority.com/2010/01/24/sqlauthority-news-download-sample-databases-for-microsoft-sql-server-2008-december-2009-samples-refresh-4/): This post is a response to one of the most asked questions where to get Sample Database for SQL Server 2008. The name of the new sample database is AdventureWorks.  - [SQLAuthority News - Remote BLOB Store Provider Library Implementation Specification](https://blog.sqlauthority.com/2010/01/23/sqlauthority-news-remote-blob-store-provider-library-implementation-specification/): Remote BLOB Store Provider Library Implementation Specification logo-sql08.gif SQL Server Technical Article Writers: Kevin Farlee, Pradeep Madhavarapu Technical Reviewer: Pradeep Madhavarapu, Michael Warmington Published: August 2008 Remote BLOB Store (RBS) is designed to move the storage of large binary data (BLOBs) from database servers to commodity storage solutions. With RBS, BLOB data is stored in storage solutions such as Content Addressable Stores (CAS), commodity hardware with data integrity and fault-tolerance systems, or mega service storage solutions like MSN Blue. A reference to the BLOB is stored in the database. An application stores and accesses BLOB data by calling into the RBS... - [SQL SERVER - Execution Plan - Estimated I/O Cost - Estimated CPU Cost - No Unit](https://blog.sqlauthority.com/2010/01/22/sql-server-execution-plan-estimated-io-cost-estimated-cpu-cost-no-unit/): During the SQL Server Optimization training, I enjoy teaching the Execution Plan. I am always sure that questions related to the estimated cost will be raised by attendees. Following are some common questions related to costs: - [SQLAuthority News - Community Tech Days - Jan 30, 2010 - Event Announcement](https://blog.sqlauthority.com/2010/01/21/sqlauthority-news-community-tech-days-jan-30-2010-event-announcement/): Attend deep technology sessions for developers and IT professionals, as some of the best-known names come to your city to share their insights in topics ranging from .Net, Visual studio, Silverlight, to Windows and SQL Server. Build connections with Microsoft experts and community members and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. In Ahmedabad this event will happen on January 30, 2010. Just like last event we are expecting this time as well the event will have astonishing success and huge response. We will have five tech sessions back to back... - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010](https://blog.sqlauthority.com/2010/01/20/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010/): Microsoft has organized an Open Day for all MVP the South Asia MVP.  The MVP Open Day is a three day invitation-only event that is hosted at MSIDC. The event will feature a roster of keynotes and deep dive technical sessions delivered by experts from the product group. Microsoft India Development Center (MSIDC) is one of Microsoft’s largest development centers outside the headquarters in Redmond. The MVP Open Day is an exclusive event for Asia Pacific & Greater China MVPs. MVP is exceptional technical community leader. Microsoft MVP site further explains MVP as “At Microsoft, we believe that by participating in technical... - [SQL SERVER - SSMS Query Command(s) completed successfully without ANY Results](https://blog.sqlauthority.com/2010/01/19/sql-server-ssms-query-commands-completed-successfully-without-any-results/): Yesterday night, I received a phone call from one of my friends with whom I used to work in USA. I was very pleased to receive this call from my old friend after 2 years, but the situation was not good on his side. He said that whatever query he runs, he just receives a message like Query Command(s) completed successfully without any result. However, when he opened a new window, it worked fine. He said he could not figure out the reason for the same and his manager who was standing nearby asked him to find out the reason and... - [SQL SERVER - DMV Error: FIX: Error: Msg 297, Level 16 The user does not have permission to perform this action](https://blog.sqlauthority.com/2010/01/18/sql-server-dmv-error-fix-error-msg-297-level-16-the-user-does-not-have-permission-to-perform-this-action/): I just received an email from one of the readers asking for help with error he encountered while attempting to run DMV. Msg 297, Level 16, State 1, Line 1 The user does not have permission to perform this action. Fix/Solution/Workaround: The above error is usually generated when the user who is trying to run the DMV does not have access to the run the DMV. I suggested him to contact his server admin to grant him VIEW SERVER STATE permissions so that he can run the DMV. Example: If user does not have VIEW SERVER STATE permissions when he runs... - [SQL SERVER - Get Server Version and Additional Info](https://blog.sqlauthority.com/2010/01/17/sql-server-get-server-version-and-additional-info/): It is quite common to get the SQL Server version details from following query. SELECT @@VERSION VersionInfo GO Recently I have been using following SP to get version details as it also provides me few more information about the server where the SQL Server is installed. EXEC xp_msver GO Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] I like to use the second one but again that is my preference. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Windows Azure Platform Training Kit - December Update](https://blog.sqlauthority.com/2010/01/16/sqlauthority-news-download-windows-azure-platform-training-kit-december-update/): Note :  Download Windows Azure Platform Training Kit – December Update by Microsoft I wanted to read some good SQL Azure related to documentation, I tried to do searching online. While searching I landed over Windows Azure Platform Training Kit. This contains lots of SQL Server related content.I downloaded it and started to explore, I suggest if you are interested in Azure Platform you download it as well. The Azure Services Training Kit includes a comprehensive set of technical content including hands-on labs, presentations, and demos that are designed to help you learn how to use the Windows Azure platform including:... - [SQL SERVER - Initializing a Merge Subscription Without a Snapshot](https://blog.sqlauthority.com/2010/01/15/sql-server-initializing-a-merge-subscription-without-a-snapshot/): During recent course of Disaster Recovery and Performance Tuning, I had very interesting conversation with students regarding Initializing a Merge Subscription Without a Snapshot and Initializing a Transactional Subscription Without a Snapshot. After the discussion when we were looking at MSDN pages one thing caught my notice was the note on the top of the MSDN page regarding future support of the feature for Initializing a Merge Subscription Without a Snapshot. In the book on line on the subject Initializing a Merge Subscription Without a Snapshot it suggests that this feature will be deprecated in future, whereas there is no such... - [SQLAuthority News - Vote for SQL Server 2005 Service Pack 4 - Vote for SQL Server 2008 Service Pack 2](https://blog.sqlauthority.com/2010/01/15/sqlauthority-news-vote-for-sql-server-2005-service-pack-4-vote-for-sql-server-2008-service-pack-2/): It has been long time since Microsoft has released SQL Server 2005 SP3 and SQL Server 2008 SP1. It is the time when the new SPs should be released. SQL Server 2005 Service Pack 4 SQL Server 2008 Service Pack 2 Many thanks to Steve Jones of SQLServerCentral.com for this excellent initiative. I voted there, have you voted? Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Busiest Database](https://blog.sqlauthority.com/2010/01/14/sql-server-find-busiest-database/): In my recent training I was asked to how to find which is the busiest database in any SQL Server Instance. What he really meant by this is which database was doing lots of read and write operation. To find the answer to this question I decided to look into the DMV which contains all the details of the executed query. From the DMV sys.dm_exec_query_stats I found three most important columns to determine busiest database. DMV sys.dm_exec_query_stats contained columns total_logical_reads, total_logical_writes, sql_handle. Column sql_handle can help to to determine the original query by CROSS JOINing DMF sys.dm_exec_sql_text. From DMF sys.dm_exec_sql_text Database... - [SQLAuthority News - SQL Server Migration QuickStart](https://blog.sqlauthority.com/2010/01/13/sqlauthority-news-sql-server-migration-quickstart/): The SQL Server Migration QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to help you get details about how to approach your customers who want to improve the return on investment from their data platforms by migrating to SQL Server from their existing Oracle or Sybase platforms. SQL Server Migration QuickStart Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fragmentation - Detect Fragmentation and Eliminate Fragmentation](https://blog.sqlauthority.com/2010/01/12/sql-server-fragmentation-detect-fragmentation-and-eliminate-fragmentation/): Q. What is Fragmentation? How to detect fragmentation and how to eliminate it? A. Storing data non-contiguously on disk is known as fragmentation. Before learning to eliminate fragmentation, you should have a clear understanding of the types of fragmentation. We can classify fragmentation into two types: Internal Fragmentation: When records are stored non-contiguously inside the page, then it is called internal fragmentation. In other words, internal fragmentation is said to occur if there is unused space between records in a page. This fragmentation occurs through the process of data modifications (INSERT, UPDATE, and DELETE statements) that are made against the table... - [SQL SERVER - The server network address "TCP://SQLServer:5023" can not be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418)](https://blog.sqlauthority.com/2010/01/11/the-server-network-address-tcpsqlserver5023-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-that-the-ports-for-the-local-and-remote-endpoints-are-operational-microso/): While doing SQL Mirroring, we receive the following as the most common error: The server network address “TCP://SQLServer:5023” cannot be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418) The solution to the above problem is very simple and as follows. Fix/WorkAround/Solution: Try all the suggestions one by one. Suggestion 1: Make sure that on Mirror Server the database is restored with NO RECOVERY option (This is the most common problem). Suggestion 2: Make sure that from Principal the latest LOG backup is... - [SQLAuthority News - Download - Microsoft Sync Framework Power Pack for SQL Azure November CTP (32-bit)](https://blog.sqlauthority.com/2010/01/10/sqlauthority-news-download-microsoft-sync-framework-power-pack-for-sql-azure-november-ctp-32-bit/): This release features the SQL Azure provider for Microsoft Sync Framework, a plug-in for Visual Studio 2008 Professional SP1 and the tool SQL Azure Data Sync Tool for SQL Server, all of which simplify using Sync Framework and SQL Azure together. Download Microsoft Sync Framework Power Pack for SQL Azure November CTP (32-bit) Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1](https://blog.sqlauthority.com/2010/01/09/sqlauthority-news-microsoft-sql-server-migration-assistant-2008-for-mysql-v1-0-ctp1/): Microsoft SQL Server Migration Assistant (SSMA) 2008 is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL to SQL Server 2008 and SQL Azure. Download Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1 Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad - Gandhinagar SQL Server User Group Meet - Dec 19, 2009](https://blog.sqlauthority.com/2010/01/08/sqlauthority-news-ahmedabad-gandhinagar-sql-server-user-group-meet-dec-19-2009/): Just like every month Ahmedabad and Gandhinagar SQL Server User Group meeting was held on Dec 19, 2009, at Ahmedabad. The interactive meeting was huge success as we had wonderful audience. We had three speakers this time. Tejas Shah talked about “Write CROSS TAB Query with PIVOT”. Tejas is an excellent SQL Expert and a very talented individual. It gives me great pleasure when I see any UG member who updates himself to next level. Tejas has earlier presented many sessions at UG, but this was one of the best sessions. He started with a very basic example and then took... - [SQLAuthority News - Webcasts - Resources for IT Managers and their Teams](https://blog.sqlauthority.com/2010/01/07/sqlauthority-news-webcasts-resources-for-it-managers-and-their-teams/): Pinal Dave and Jacob Sebastian are both SQL Server MVP are doing webcasts for IT Managers and their Teams. Join us for a 4 series webcast as follows: Part 1: Infrastructure and Resource Management for Business Intelligence – Jan 7 Part 2: BI on your desktop – End to end BI solution from MS – Jan 28 Part 3: IT Managers and Mission Critical Data – What, Why, When and How to manage – Feb 4 Part 4: Understanding security and compliance for Enterprise – Feb 11 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON - A Transactional Behavior](https://blog.sqlauthority.com/2010/01/06/sql-server-unique-nonclustered-index-creation-with-ignore_dup_key-on-a-transactional-behavior/): Earlier, I had written on SQL SERVER – Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON, and I received a comment regarding when this option can be useful. On the same day, I met Jacob Sebastian—my close friend and SQL Server MVP, I discussed this question with him. During our discussion, we came up with following example. When we have situation where we are dealing with INSERT and TRANSACTION, we can see this feature in action. Let us consider an example where we have two tables. One table has all the data and the second table has partial data. If you... - [SQL SERVER - SQL Server RDL Specification](https://blog.sqlauthority.com/2010/01/05/sql-server-sql-server-rdl-specification/): Report Definition Language (RDL) is an XML-based schema for defining reports. The goal of RDL is to promote the interoperability of commercial reporting products by defining a common schema that allows interchange of report definitions. To encourage interoperability, RDL includes the notion of compliance levels that products may choose to support. Download the RDL Specifications for SQL Server by clicking the links below. RDL Specification for SQL Server 2008 (.xps format) RDL Specification for SQL Server 2008 (.pdf format) RDL Specification for SQL Server 2005 (.pdf format) RDL Specification for SQL Server 2000 (.pdf format) Abstract courtesy : Microsoft Reference: Pinal... - [SQL SERVER - Fix: Error: 262 : SHOWPLAN permission denied in database](https://blog.sqlauthority.com/2010/01/05/sql-server-fix-error-262-showplan-permission-denied-in-database/): During one of my recent training class when I asked students to check the execution plan using (can be enabled using CTRL+M), they received error as following. Msg 262, Level 14, State 4, Line 1 SHOWPLAN permission denied in database ‘AdventureWorks’. - [SQL SERVER - Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON](https://blog.sqlauthority.com/2010/01/04/sql-server-unique-nonclustered-index-creation-with-ignore_dup_key-on/): In one of my recent training course, I was asked question regarding what is the importance of setting IGNORE_DUP_KEY = ON when creating unique nonclustered index. Here is the short answer: When nonclustered index is created without any option the default option is IGNORE_DUP_KEY = OFF, which means when duplicate values are inserted it throws an error regarding duplicate value. If option is set with syntaxIGNORE_DUP_KEY = ON when duplicate values are inserted it does not thrown an error but just displays warning. Let us try to understand this with example. Option 1: IGNORE_DUP_KEY = OFF Option 2: IGNORE_DUP_KEY = ON... - [SQLAuthority News - TechDays Session at Infosys Mysore 2009 - Change Data Capture and PowerPivot](https://blog.sqlauthority.com/2010/01/03/sqlauthority-news-techdays-session-at-infosys-mysore-2009-change-data-capture-and-powerpivot/): It has been a great pleasure to visit Infosys Mysore for an MSDN session. I had previously visited Infosys Bangalore for Technical session. Please read the details of earlier visit SQLAuthority News – Notes from TechDays 2009 at Infosys, Bangalore. This event was held on Dec 10, 2009. I have been recently presenting the subject of Change Data Capture; it has been great fun as it is a very interesting subject that really captures your attention. It was a well-received session that lasted for nearly 1.5 hours instead of regular 30 min. The smart crowd at Infosys received the subject very... - [SQL SERVER - Find Location of Data File Using T-SQL](https://blog.sqlauthority.com/2010/01/02/sql-server-find-location-of-data-file-using-t-sql/): While preparing for the training course of Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning, I needed to find out where my database files are stored on my hard drive. It is when following script came in handy to find the location of the data file using T-SQL.  - [SQL SERVER - FIX: Error: 1807 Could not obtain exclusive lock on database 'model'. Retry the operation later.](https://blog.sqlauthority.com/2010/01/01/sql-server-fix-error-1807-could-not-obtain-exclusive-lock-on-database-model-retry-the-operation-later/): While working on query optimization project, I encountered following error. Msg 1807, Level 16, State 3, Line 1 Could not obtain exclusive lock on database ‘model’. Retry the operation later. Msg 1802, Level 16, State 4, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors. The resolution of above problem is quick and easy. Fix/Workaround/Solution: Disconnect and Reconnect your SQL Server Management Studio’s session. Your error will go away. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 1200th Post - An Important Milestone](https://blog.sqlauthority.com/2009/12/31/sqlauthority-news-1200th-post-an-important-milestone/): Today is the last day of 2009 and this is my 1200th post! This year had been a wonderful year for me. I was actively involved with the community, and there were a lot of occasions where I could work along with IT professionals to resolve their issues in projects. Today, as this is my 1200th post and last day of 2009, we will go over few but very important milestones of this year (of course, in my life). Instead of longer list, I have decided to list only the most important events. Event listed event are in order of its... - [SQL SERVER - Fix Error 1949, Level 16: Cannot create index on view. The function yields nondeterministic results](https://blog.sqlauthority.com/2009/12/30/sql-server-fix-error-msg-1949-level-16-cannot-create-index-on-view-the-function-yields-nondeterministic-results-use-a-deterministic-system-function-or-modify-the-user-defined-function-to-r/): Recently, during my training session in Hyderabad, one of the attendees wanted to know the reason of the following error that he encountered every time he tried to create a view. He informed me that he is also creating the index using WITH SCHEMABINDING option. Let us see we can fix error 1949. Msg 1949, Level 16, State 1, Line 1 Cannot create index on view . The function yields nondeterministic results. Use a deterministic system function, or modify the user-defined function to return deterministic results. - [SQL SERVER - Get Date of All Weekdays or Weekends of the Year](https://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/): Today’s article is created based on wonderful contribution from Tejas Shah. Tejas is very prominent SQL Expert and .NET wizard. He has answered the query of a reader on this blog who raised the following question: how to generate the date for all the Sundays in the upcoming year. Tejas replied here with a script. What I really liked about the script is that it is very easy to understand, and also it can be customized very quickly. DECLARE @Year AS INT, @FirstDateOfYear DATETIME, @LastDateOfYear DATETIME -- You can change @year to any year you desire SELECT @year = 2010 SELECT... - [SQL SERVER - Difference Temp Table and Table Variable - Effect of Transaction](https://blog.sqlauthority.com/2009/12/28/sql-server-difference-temp-table-and-table-variable-effect-of-transaction/): Few days ago I wrote an article on the myth of table variable stored in the memory—it was very well received by the community. Read complete article here: SQL SERVER – Difference TempTable and Table Variable – TempTable in Memory a Myth. Today, I am going to write an article which follows the same series; in this, we will continue talking about the difference between TempTable and TableVariable. Both have the same structure and are stored in the database — in this article, we observe the effect of the transaction on the both the objects. DECLARE @intVar INT SET @intVar =... - [SQL SERVER - Download FREE SQL SERVER Express Edition and Service Pack 1](https://blog.sqlauthority.com/2009/12/27/sql-server-download-free-sql-server-express-edition-and-service-pack-1/): Here is the quick link from where SQL Server 2008 Express Edition can be downloaded. Download SQL Server 2008 Express Edition You can download it with many additional details as described in following image. Click on above link to go to page and select desired version. Additionally, please install SQL Server 2008 Express Service Pack 1. You can read one of my previous article where I have covered SQL Server 2008 Express in detail SQL SERVER – SQL Server Express – A Complete Reference Guide. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Whitepaper SQL Server 2008 Full-Text Search: Internals and Enhancements](https://blog.sqlauthority.com/2009/12/26/sql-server-whitepaper-sql-server-2008-full-text-search-internals-and-enhancements/): SQL Server 2008 Full-Text Search: Internals and Enhancements SQL Server Technical Article Writer: Fernando Azpeitia Lopez, Microsoft Corp. Published: July 2008 Database systems must go beyond the traditional realm of relational data by covering an increasing amount and variety of unstructured and semistructured information, be it speech, documents, XML, bioinformatics, chemical, or multimedia. Search is a key technology capable of working with vast amounts of data: it is scalable, low-latency, and very user-friendly. It is just what is needed to make a database the best place to store all types of data. SQL Server 2008 introduces a new Full-Text Engine that... - [SQL SERVER - CDC and TRUNCATE - Cannot truncate table because it is published for replication or enabled for Change Data Capture](https://blog.sqlauthority.com/2009/12/25/sql-server-cdc-and-truncate-cannot-truncate-table-because-it-is-published-for-replication-or-enabled-for-change-data-capture/): Few days ago, I got the great opportunity to visit Bangalore Infosys. Please read the complete details for the event here: SQLAuthority News – Notes from TechDays 2009 at Infosys, Bangalore. I mentioned during the session that CDC is asynchronous and it reads the log file to populate its data. I had received a very interesting question during the session. The question is as follows: does CDC feature capture the data during the truncate operation? Answer: It is not possible or not applicable. Truncate is operation that is not logged in the log file, and if one tries to truncate the... - [SQL Authority News - Training SQL Server Query Optimization And Performance Tuning](https://blog.sqlauthority.com/2009/12/24/sql-authority-news-training-ms-sql-server-2005-2008-query-optimization-performance-tuning/): Earlier this year we had offered Query Optimization course and it was sold out in minutes. Due to popular demand we are offering the same course in the very first week of next year. The title of the course is ‘MS SQL Server Query Optimization And Performance Tuning‘. This three day course is an intensive course designed to give attendees an in-depth look at the query optimization and performance tuning concepts and methods found in SQL Server. This course is designed to prepare the SQL Server developers and administrators for a transition to SQL Server while discussing best practices for a variety of topics. - [SQL SERVER - ORDER BY Clause and TOP WITH TIES](https://blog.sqlauthority.com/2009/12/23/sql-server-order-by-clause-and-top-with-ties/): Recently, on this blog, I published an article on SQL SERVER – Interesting Observation – TOP 100 PERCENT and ORDER BY; this article was very well received because of the observation made in it. One of the comments suggested the workaround was to use clause WITH TIES along with TOP and ORDER BY. That is not the correct solution; however, but the same comment brings up the question regarding how WITH TIES clause actually works. First of all, the clause WITH TIES can be used only with TOP and ORDER BY, both the clauses are required. Let us understand from one... - [SQLAuthority News - Meeting SQL Expert Imran at Hyderabad](https://blog.sqlauthority.com/2009/12/22/sqlauthority-news-meeting-sql-expert-imran-at-hyderabad/): I was very fortunate to meet the SQL Server Expert and one of the top participants of this blog Imran Mohammed. Imran has been very active on this blog and have previously contributed with few articles as well. I have been communicating with Imran for a long time; he is always very active and quick to reply. Many times, he has solved various difficult problems of readers which. He always goes an extra mile to resolve such problems – once I happened to see him spend more than 10 hours to solve a problem posed by a reader. When I met... - [SQL SERVER - Comma Separated Values (CSV) from Table Column - Part 2](https://blog.sqlauthority.com/2009/12/21/sql-server-comma-separated-values-csv-from-table-column-part-2/): In my earlier post, I wrote about how one can use XML to convert table to string SQL SERVER – Comma Separated Values (CSV) from Table Column. The same article is also published on channel 9 SQLAuthority News – Featured on Channel 9. One of the very interesting points that was discussed on show was about the usage of function SUBSTRING. I found the following point very valid: SUBSTRING usage limits the length of the XML to be used. I have re-written the same function with function STUFF, and it removes any limit imposed on the script. USE AdventureWorks GO --... - [SQLAuthority News - Migrating DTS Packages to Integration Services](https://blog.sqlauthority.com/2009/12/20/sqlauthority-news-migrating-dts-packages-to-integration-services/): Migrating DTS Packages to Integration Services Writer: Brian Knight Published: July 2008 SQL Server Integration Services (SSIS) brings a revolutionary concept of enterprise-class ETL to the masses. The engine is robust enough to handle hundreds of millions of rows with ease, but is simple enough to let both developers and DBAs engineer an ETL process. In this whitepaper, you will see the benefits of migrating your SQL Server 2000 Data Transformation Services (DTS) packages to Integration Services by using two proven methods. You will also see how you can run and manage your current DTS packages inside of the SQL Server... - [SQLAuthority News - Migrating to SQL Server from Other Database Products](https://blog.sqlauthority.com/2009/12/19/sqlauthority-news-migrating-to-sql-server-from-other-database-products/): Guide to Migrating from MySQL to SQL Server 2008 In this migration guide you will learn the differences between the MySQL and SQL Server 2008 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2008 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2008. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. The entire migration process using SQL Server Migration Assistant (SSMA) 2008 for Oracle is explained... - [SQL SERVER - Differences in Vulnerability between Oracle and SQL Server](https://blog.sqlauthority.com/2009/12/18/sql-server-differences-in-vulnerability-between-oracle-and-sql-server/): In the IT world, but not among experienced DBAs, there has been a long-standing myth that the Oracle database platform is more stable and more secure than SQL Server from Microsoft. This is due to a variety of reasons; but in my opinion, the main ones are listed below: A. Microsoft development platforms are generally more error-prone and full of bugs. This (unfairly) projects the weaknesses of earlier versions of Windows onto its other products such as SQL Server, which is a very stable and secure platform in its own right. B. Oracle has been around for longer than SQL Server... - [SQLAuthority News - Hub-And-Spoke: Building an EDW with SQL Server and Strategies of Implementation](https://blog.sqlauthority.com/2009/12/17/sqlauthority-news-hub-and-spoke-building-an-edw-with-sql-server-and-strategies-of-implementation/): Hub-And-Spoke: Building an EDW with SQL Server and Strategies of Implementation logo-sql08.gif SQL Server Technical Article Writers: Mark Theissen, Eric Kraemer Published: February 2009 To date, the implementation of a true hub-and-spoke architecture for a data warehouse environment has been an idealized and elusive goal. Although building a centralized “hub,” or enterprise data warehouse (EDW) that supports company-wide detail data is achievable, building and maintaining “spokes,” or dependent departmental data marts has proved to be the challenge. Most data warehouse environments have evolved to one of two architectures: a centralized EDW or a series of distributed and/or federated data marts. In... - [SQL SERVER - Fillfactor, Index and In-depth Look at Effect on Performance](https://blog.sqlauthority.com/2009/12/16/sql-server-fillfactor-index-and-in-depth-look-at-effect-on-performance/): I would like to start this post with an interesting question: Where in MS SQL Server is “100” equals to “0”?  And I am not talking about data types now.. Today I will be presenting the answer to this question and some topics related to it. Creating Indices in SQL Server is one of the most important tasks of any SQL DBA. Performance of your database is directly depends on your skills and proficiency in creating and maintaining the right number and quality of indices.. As a DBA, you can use “FILLFACTOR,” which is one of the important arguments that can... - [SQL SERVER - Difference TempTable and Table Variable - Table Variable in Memory a Myth](https://blog.sqlauthority.com/2009/12/15/sql-server-difference-temptable-and-table-variable-temptable-in-memory-a-myth/): Recently, I have been conducting many training sessions at a leading technology company in India. During the discussion of temp table and table variable, I quite commonly hear that Table Variables are stored in memory and Temp Tables are stored in TempDB. I would like to bust this misconception by suggesting following: Temp Table and Table Variable — both are created in TempDB and not in memory. Let us prove this concept by running the following T-SQL script. /* Check the difference between Temp Table and Memory Tables */ -- Get Current Session ID SELECT @@SPID AS Current_SessionID -- Check the space usage in page files SELECT user_objects_alloc_page_count FROM sys.dm_db_session_space_usage WHERE session_id = (SELECT @@SPID ) GO -- Create Temp Table and insert three thousand rows CREATE TABLE #TempTable (Col1... - [SQLAuthority News - An Year of Personal Events - A Life Outside SQL](https://blog.sqlauthority.com/2009/12/14/sqlauthority-news-an-year-of-personal-events-a-life-outside-sql/): Today I will keep the words very short and will convey story in three simple photographs. This post answers the question – “Do I have life outside SQL?” YES! I do and it is very beautiful. December 12, 2009 September 1, 2009 December 12, 2008 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - White Paper - Partitioned Table and Index Strategies Using SQL Server 2008](https://blog.sqlauthority.com/2009/12/13/sql-server-white-paper-partitioned-table-and-index-strategies-using-sql-server-2008/): Partitioned Table and Index Strategies Using SQL Server 2008 Writer: Ron Talmage, Solid Quality Mentors Technical Reviewer: Denny Lee, Wey Guy, Kevin Cox, Lubor Kollar, Susan Price – Microsoft Greg Low, Herbert Albert – Solid Quality Mentors When a database table grows in size to the hundreds of gigabytes or more, it can become more difficult to load new data, remove old data, and maintain indexes. Just the sheer size of the table causes such operations to take much longer. Even the data that must be loaded or removed can be very sizable, making INSERT and DELETE operations on the table... - [SQLAuthority News - Featured on Channel 9](https://blog.sqlauthority.com/2009/12/12/sqlauthority-news-featured-on-channel-9/): This blog was featured on Channel 9 MSDN over here : TWC9: Scott Hanselman, Jon Galloway, Bing, parallel unit tests, more. I was very proud that this blog was discussed for more than 5 mins (from min 18 to min 23) on my favorite online show. Scott Hanselman, Jon Galloway along with Dan Fernandez make this show very live and very very entertaining. The article which was featured in the show is SQL SERVER – Comma Separated Values (CSV) from Table Column. Here are few screenshot from the show. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ERROR: FIX: Cannot drop server because it is used as a Distributor in replication](https://blog.sqlauthority.com/2009/12/11/sql-server-error-fix-cannot-drop-server-because-it-is-used-as-a-distributor-in-replication/): Replication has been my favorite subject when it comes to resolving errors. I have found that many DBAs are stuck with the solving of the problem of replication for hours; however, the solution is very easy. One of the very common errors in replication occurs when replication is removed from any server. I have seen the following error as one attempts to remove replication from the same server when the publisher and distributor are on the same server. Cannot drop server ‘repl_distributor’ because it is used as a Distributor in replication. Cannot drop the distribution database ‘distribution’ because it is currently... - [SQL SERVER - Future of Business Intelligence](https://blog.sqlauthority.com/2009/12/10/sql-server-future-of-business-intelligence/): Business Intelligence (BI) is slated to play bigger roles in all kinds of businesses in the coming years. This is not surprising as data analysis and smarter decision making has made the use of BI inevitable in all sizes of businesses across all sectors, including Real estate, IT, mobile devices, governmental agencies, scientific and engineering communities and R&D labs, banking and insurance, to name a few. BI can effectively deal with industry-specific constraints, operations and objectives thereby helping organizations to better understand their customers, optimize their operations, minimize risk, manage revenue, and ultimately improve their results. Moreover, the changing economic environment,... - [SQL SERVER - Business Intelligence - Aligning Business Metrics](https://blog.sqlauthority.com/2009/12/09/sql-server-business-intelligence-aligning-business-metrics/): Today, executive management and managers need the latest information to drive intelligent decisions for business success. More informed decisions mean more revenue, less risk, decreased cost, and improved operational control for business agility and competitiveness. Besides, in today’s fast paced, technology-driven business world, organizations are continually struggling to deal with growing data volumes and complexity to use their own data efficiently. Constrained with competitive environments and data complexity are COO, IT Managers and Business Consultants who are asking for less information more easily for smarter, faster decision-making. They want information that is highly visual, up-to-date, personalized and secure. Also, they want... - [SQL SERVER - Fix : Error : Invalid object name 'sys.configurations'. (Microsoft SQL Server, Error: 208)](https://blog.sqlauthority.com/2009/12/08/sql-server-fix-error-invalid-object-name-sys-configurations-microsoft-sql-server-error-208/): As you all know that SQL Azure CTP has been released; here, I have included a step-by-step guide for how to configure the CTP: SQL SERVER – Azure Start Guide – Step by Step Installation Guide. For pricing and introduction, please read SQLAuthority News – SQL Azure – Microsoft SQL Data Services – Introduction and Pricing. I received many comments times when people are connected to the SQL Azure they receive following error. Invalid object name ‘sys.configurations’. (Microsoft SQL Server, Error: 208) Fix/Workaround/Solution: 1. Close out all the Connect to Server Dialogue 2. Click on the New Query button from the... - [SQL Server - White Paper - An Introduction to Fast Track Data Warehouse Architectures by Erik Veerman](https://blog.sqlauthority.com/2009/12/07/sql-server-white-paper-an-introduction-to-fast-track-data-warehouse-architectures-by-erik-veerman/): An Introduction to Fast Track Data Warehouse Architectures SQL Server Technical Article Writer: Erik Veerman, Solid Quality Mentors Technical Reviewer: Mark Theissen, Scotty Moran, Val Fontama Published: February 2009 The performance and stability of any application solution—whether line of business, transactional, or business intelligence (BI)—hinges on the integration between solution design and hardware platform. Choosing the appropriate solution architecture—especially for BI solutions—requires balancing the application’s intended purpose and expected use with the hardware platform’s components. Poor planning, bad design, and misconfigured or improperly sized hardware often lead to ongoing, unnecessary spending and, even worse, unsuccessful projects. The ultimate goal of the... - [SQL SERVER - White Papers - Consolidation Guidance for SQL Server - Consolidation Using SQL Server 2008](https://blog.sqlauthority.com/2009/12/06/sql-server-white-papers-consolidation-guidance-for-sql-server-consolidation-using-sql-server-2008/): Consolidation Using SQL Server 2008 Writer: Allan Hirt, Megahirtz LLC (allan@sqlha.com) Technical Reviewers: Lindsey Allen, Madhan Arumugam, Ben DeBow, Sung Hsueh, Rebecca Laszlo, Claude Lorenson, Prem Mehra, Mark Pohto, Sambit Samal, and Buck Woody Published: October 2009 What are the considerations when creating a consolidation plan for my environment? What are the key differentiators among the three consolidation options? How can I use these differentiators to choose the appropriate consolidation option for my environment? Read Consolidation Guidance for SQL Server Many companies are considering or have already implemented consolidation of computing resources, including Microsoft SQL Server instances and databases, in their... - [SQLAuthority News - Notes from TechDays 2009 at Infosys, Bangalore](https://blog.sqlauthority.com/2009/12/05/sqlauthority-news-notes-from-techdays-2009-at-infosys-bangalore/): I recently had opportunity to attend TechDays 2009 Infosys. The dates of the event was Nov 16-17, 2009. This event was the largest technology conference by Microsoft in Infosys. Microsoft Tech Days focused on positioning Microsoft as the company to bet on for future technology investments by businesses and consumers alike. The event was a showcase of Microsoft’s products and solutions to technologists, decision-makers, technology influencers, and analysts. The in-campus event in Infosys was attended by 2500 tech professionals and decision makers. The event was also broadcast live to all non-Bangalore Infosys locations by using Infosys’ internal infrastructure. 2.5K Attendees I... - [SQL SERVER - 2008 Star Join Query Optimization](https://blog.sqlauthority.com/2009/12/04/sql-server-2008-star-join-query-optimization/): Business Intelligence (BI) plays a significant role in businesses nowadays. Moreover, the databases that deal with the queries related to BI are presently facing an increase in workload. At present, when queries are sent to very large databases, millions of rows are returned. Also the users have to go through extended query response times when joining multiple tables are involved with such queries. ‘Star Join Query Optimization’ is a new feature of SQL Server 2008 Enterprise Edition. This mechanism uses bitmap filtering for improving the performance of some types of queries by the effective retrieval of rows from fact tables. Improved... - [SQLAuthority News - Airline Review - Paramount, Kingfisher, Go Air, Indigo, Jet Airways, Indian Airlines, Spicejet ](https://blog.sqlauthority.com/2009/12/03/sqlauthority-news-airline-review-paramount-kingfisher-go-air-indigo-jet-airways-indian-airlines-spicejet/): First of all, this is a totally different article that I have ever written on this site. As the regular readers of my blog are aware that I am always traveling due to my different assignments at work. In last two months, I have been on flight for 36 times; this makes me a regular air traveler, who travels almost every other day. For instance, considering a month of 24 days (excluding the weekends), for two months, there are 48 business days. In such case, I was almost on air always! There are many airlines in India, and I have traveled... - [SQL SERVER - Validate an XML Document in TSQL using XSD by Jacob Sebastian](https://blog.sqlauthority.com/2009/12/02/sql-server-validate-an-xml-document-in-tsql-using-xsd-by-jacob-sebastian/): Let us learn about XML Document in TSQL using XSD by Jacob Sebastian. - [SQLAuthority News - A Daily Doze of Technology - Alvin Ashcraft's Morning Dew](https://blog.sqlauthority.com/2009/12/01/sqlauthority-news-a-daily-doze-of-technology-alvin-ashcrafts-morning-dew/): A common question that I receive is regarding how I keep myself updated with latest information about technology and what is going on at present. I read lots of blogs and books. I am usually traveling 4 days in my any regular work week. I read physical books at the time. I prefer to read the books in hard copy and not on the computer screen. If you ever spot me reading books, quite often you can see me with a fiction book rather than a SQL Book. Ok… So the question is what do I read to keep myself updated... - [SQL SERVER - Size of Index Table for Each Index - Solution](https://blog.sqlauthority.com/2009/11/30/sql-server-size-of-index-table-for-each-index-solution/): Earlier I have posted small question on this blog and requested help from readers to participate here and provide solution. Please read the original Puzzle here. SQL SERVER – Size of Index Table – A Puzzle to Find Index Size for Each Index on Table The puzzle was to write a query that will return the size for each index that is on any particular table. We need a query that will return an additional column in the above listed query and it should contain the size of the index. So far I have found two potential solutions. I have done... - [SQL SERVER - Azure Start Guide - Step by Step Installation Guide](https://blog.sqlauthority.com/2009/11/29/sql-server-azure-start-guide-step-by-step-installation-guide/): As SQL Azure CTP is released I have included here step by step guide for how to configure the CTP. For pricing and introduction please read SQLAuthority News – SQL Azure – Microsoft SQL Data Services – Introduction and Pricing First it has to be configured online at Login using your Live ID Type in invitation code received from Microsoft for CTP. You can request one for your self here. Accept the TOU. Once logged it you will have to create server username and password. Click on my project and it will provide you details about your servername where your data... - [SQLAuthority News - SQL Server R2 Resources Downloads, Documentations](https://blog.sqlauthority.com/2009/11/28/sqlauthority-news-sql-server-r2-resources-downloads-documentations/): Microsoft SQL Server 2008 R2 November Community Technology Preview Building on SQL Server 2008, R2 provides an even more scalable data platform with comprehensive tools for managing your databases and applications, improving the quality of your data, and empowering your users to build rich analyses and reports using tools they are already familiar with. Microsoft SQL Server 2008 R2 November Community Technology Preview Feature Pack The Microsoft SQL Server 2008 R2 Feature Pack is a collection of stand-alone packages which provide additional value for SQL Server 2008 R2. SQL Server 2008 R2 Books Online Community Technology Preview November 2009 Download the... - [SQLAuthority News - Subscribe to Blog - Search a Blog](https://blog.sqlauthority.com/2009/11/27/sqlauthority-news-subscribe-to-blog-search-a-blog/): Quite often I get request if I send blog post in newsletter or through email. Here are few important links. You can for sure get email of my post, however, I strongly suggest to visit blog as if there are any updates in my post they are reflected on blog. Subscribe to blog post through email Subscribe SQLAuthority Feed Search SQLAuthority – This is very powerful search. Give it a try. Follow me on Twitter Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server 2008 Analysis Services Performance Guide](https://blog.sqlauthority.com/2009/11/26/sqlauthority-news-sql-server-2008-analysis-services-performance-guide/): Because Microsoft SQL Server Analysis Services query and processing performance tuning is a fairly broad subject, this white paper organizes performance tuning techniques into the following three segments. Enhancing Query Performance – Query performance directly impacts the quality of the end user experience. As such, it is the primary benchmark used to evaluate the success of an online analytical processing (OLAP) implementation. Analysis Services provides a variety of mechanisms to accelerate query performance, including aggregations, caching, and indexed data retrieval. In addition, you can improve query performance by optimizing the design of your dimension attributes, cubes, and Multidimensional Expressions (MDX) queries.... - [SQL SERVER - Comma Separated Values (CSV) from Table Column](https://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/): I use following script very often and I realized that I have never shared this script on this blog before. Creating Comma Separated Values (CSV) from Table Column is a very common task, and we all do this many times a day. Let us see the example that I use frequently and its output. - [SQL SERVER - Interesting Observation - TOP 100 PERCENT and ORDER BY](https://blog.sqlauthority.com/2009/11/24/sql-server-interesting-observation-top-100-percent-and-order-by/): Today we will go over a very simple, but interesting subject. The following error is quite common if you use ORDER BY while creating any view: Msg 1033, Level 15, State 1, Procedure something, Line 5 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. The error also explains the solution for the same – use of TOP. I have seen developers and DBAs using TOP very causally when they have to use the ORDER BY clause. Theoretically, there is no need of ORDER BY... - [SQL SERVER - A Common Design Problem - Should the Primary Key Always be a Clustered Index](https://blog.sqlauthority.com/2009/11/23/sql-server-a-common-design-problem-should-the-primary-key-always-be-a-clustered-index/): In SQL Server, whenever we create any key, a Primary Key automatically creates clustered index on the same. I like this feature and I use this feature every now and then. The question is does the change of any column as Primary Key should also create a Clustered Index? Moreover, is there any case, where one would not do the same? One of the recent conversations I had with one SQL Expert is with regard to the SSN number. The discussion was that SSN numbers are always unique and never repeated and hence are the best candidates for primary key. Additionally... - [SQL SERVER - Remove Bookmark Key Lookup - 4 Different Ideas](https://blog.sqlauthority.com/2009/11/22/sql-server-remove-bookmark-key-lookup-4-different-ideas/): I quite often get request to summarized my ideas about Removing bookmark lookup on this blog post. Bookmark lookup or key lookup are bad for any query as they force query engine to lookpup corresponding row in the table or index as it does not find required data from just reading the data. Here are list of my four post written on the same subject. SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup – Part... - [SQL SERVER - Fix : Error : 1326 Cannot connect to Database Server Error: 40 - Could not open a connection to SQL Server](https://blog.sqlauthority.com/2008/08/09/sql-server-fix-error-1326-cannot-connect-to-database-server-error-40-could-not-open-a-connection-to-sql-server/): If you are receiving the following error related to connection to SQL Server, this blog is for you.  - [SQLAuthority News - Security Update for SQL Server 2000 Service Pack 4 and MSDE 2000](https://blog.sqlauthority.com/2008/08/08/sqlauthority-news-security-update-for-sql-server-2000-service-pack-4-and-msde-2000/): If you are still using SQL Server 2000 (you should have upgraded to SQL Server 2005 by now), there is Security Upgrade for Service Pack 4 and MSDE. Download SQL Server 2000 Security Upgrade Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Released To Manufacturing Available](https://blog.sqlauthority.com/2008/08/08/sql-server-2008-released-to-manufacturing-available/): Microsoft has Released To Manufacturing available for SQL Server 2008. Released To Manufacturing (RTM) means that code of SQL Server 2008 has been approved by MS team and it is being send to manufacture. It will be while before it is available on distribute media on store shelves. Currently it is available for download by MSDN and TechNet subscribers. I want to congratulate MS SQL Server team for releasing the version of SQL Server on time. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - EXCEPT Clause in SQL Server is Similar to MINUS Clause in Oracle](https://blog.sqlauthority.com/2008/08/07/sql-server-except-clause-in-sql-server-is-similar-to-minus-clause-in-oracle/): One of the JR. Developer asked me a day ago, does SQL Server has similar operation like MINUS clause in Oracle. Absolutely, EXCEPT clause in SQL Server is exactly similar to MINUS operation in Oracle. The EXCEPT query and MINUS query returns all rows in the first query that are not returned in the second query. Each SQL statement within the EXCEPT query and MINUS query must have the same number of fields in the result sets with similar data types. Let us see that using example below. First create table in SQL Server and Oracle. CREATE TABLE EmployeeRecord (EmpNo INT... - [SQL SERVER - Query to Find Column From All Tables of Database](https://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/): One question came up just a day ago while I was writing SQL SERVER – 2005 – Difference Between INTERSECT and INNER JOIN – INTERSECT vs. INNER JOIN. How many tables in database AdventureWorks have column name like ‘EmployeeID’? It was quite an interesting question and I thought if there are scripts which can do this would be great. I quickly wrote down following script which will go return all the tables containing specific column along with their schema name. USE AdventureWorks GO SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name, c.name AS column_name FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID... - [SQL SERVER - 2005 - Get Field Name and Type of Database Table](https://blog.sqlauthority.com/2008/08/05/sql-server-2005-get-field-name-and-type-of-database-table/): In today’s article we will see question of one of reader Mohan and answer from expert Imran Mohammed. Imran thank you for answering question of Mohan. Question of Mohan: hi all, how can i get field name and type etc. in MS-SQL server 2005. is there any query available??? Answer from Imran Mohammed: @mohan use database_name Sp_help table_name This stored procedure gives all the details of column, their types, any indexes, any constraints, any identity columns and some good information for that particular table. Second method: select column_name ‘Column Name’, data_type ‘Data Type’, character_maximum_length ‘Maximum Length’ from information_schema.columns where table_name =... - [SQLAuthority News - SQLAuthority Site With New Banner](https://blog.sqlauthority.com/2008/08/04/sqlauthority-news-sqlauthority-site-with-new-banner/): I am glad to inform all the blog readers regarding new updated banner of this site. I would like to thank Ritesh, Sanjay and Rashmika who have spent their time to create the banner and gift to SQLAuthority. I really liked the new banner and I think it goes better with the theam of this site. Let me know what is your opinion about new banner. Old Banner : New Banner : (Click on banner) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Difference Between INTERSECT and INNER JOIN - INTERSECT vs. INNER JOIN](https://blog.sqlauthority.com/2008/08/03/sql-server-2005-difference-between-intersect-and-inner-join-intersect-vs-inner-join/): INTERSECT operator in SQL Server 2005 is used to retrieve the common records from both the left and the right query of the Intersect Operator. INTERSECT operator returns almost same results as INNER JOIN clause many times. When using INTERSECT operator the number and the order of the columns must be the same in all queries as well data type must be compatible. Let us see understand how INTERSECT and INNER JOIN are related.We will be using AdventureWorks database to demonstrate our example. Example 1: Simple Example of INTERSECT SELECT * FROM HumanResources.EmployeeDepartmentHistory WHERE EmployeeID IN (1,2,3) INTERSECT SELECT * FROM... - [SQL SERVER - Effect of Order of Join In Query](https://blog.sqlauthority.com/2008/08/02/sql-server-effect-of-order-of-join-in-query/): Let us try to understand this subject with example. We will use Adventurworks database for this purpose. Table which we will be using are HumanResources.Employee (290 rows), HumanResources.EmployeeDepartmentHistory (296 rows) and HumanResources.Department (16 rows). We will be running following two queries and observe the output. In the resultset the order of first column (EmployeeID) is different in both the cases when whole resultset is same. When compared both the results they are same but the order of rows is different in both the resultset. Query 1 : SELECT he.EmployeeID, he.Title, hd.Name, hd.GroupName, hdh.StartDate FROM HumanResources.Employee he LEFT JOIN HumanResources.EmployeeDepartmentHistory hdh ON... - [SQL SERVER - 2008 - Get Current System Date Time](https://blog.sqlauthority.com/2008/08/01/sql-server-2008-get-current-system-date-time/): How to get current system date time in SQL Server? - [SQL SERVER - 2008 - Find Current System Date Time and Time Offset](https://blog.sqlauthority.com/2008/07/31/sql-server-2008-find-current-system-date-time-and-time-offset/): If you want to find current datetime in SQL Server I suggest to read the following post : SQL SERVER – Retrieve Current Date Time in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()} This post is related to new feature available in SQL Server 2008. In SQL Server 2008 there is a function which provides current offset of the system from GMT time as well. Basically it shows the system datetime with offset. I think this can be useful in some of the instances where SQL Server are depending on the time offset. SELECT SYSDATETIMEOFFSET() AS 'Windows System Time' GO Reference : Pinal Dave... - [SQLAuthority News - Author BirthDay - SQL Server Birthday](https://blog.sqlauthority.com/2008/07/30/sqlauthority-news-author-birthday-sql-server-birthday/): It always suprise me how many people remember my birthday and take time from their busy life to call me, email me, wish me or send me their warm greetings. I would like to express my gratitude to them. Today is my birthday and I had decided to take a day off and does not talk about SQL Server. Due to urgent matter at my work, I am at office working just like usual. Well, when I decide not to talk about SQL Server today on blog, let us talk about birthdays. Let me ask all of you one question about... - [SQL SERVER - SQL SERVER - Simple Example of Recursive CTE - Part 2 - MAXRECURSION - Prevent CTE Infinite Loop](https://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/): Yesterday I wrote about SQL SERVER – SQL SERVER – Simple Example of Recursive CTE. I right away received email from regular reader John Mildred that if I can prevent infinite recursion of CTE. Sure! recursion can be limited. Use the option of MAXRECURSION. USE AdventureWorks GO WITH Emp_CTE AS ( SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate FROM HumanResources.Employee WHERE ManagerID IS NULL UNION ALL SELECT e.EmployeeID, e.ContactID, e.LoginID, e.ManagerID, e.Title, e.BirthDate FROM HumanResources.Employee e INNER JOIN Emp_CTE ecte ON ecte.EmployeeID = e.ManagerID ) SELECT * FROM Emp_CTE OPTION (MAXRECURSION 5) GO Now if your CTE goes beyond 5th recursion it will throw an... - [SQL SERVER - Simple Example of Recursive CTE](https://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/): Recursive is the process in which the query executes itself. It is used to get results based on the output of base query. We can use CTE as Recursive CTE (Common Table Expression). You can read my previous articles about CTE by searching at http://search.SQLAuthority.com . Here, the result of CTE is repeatedly used to get the final resultset. The following example will explain in detail where I am using AdventureWorks database and try to find hierarchy of Managers and Employees. USE AdventureWorks GO WITH Emp_CTE AS ( SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate FROM HumanResources.Employee WHERE ManagerID IS NULL... - [SQL SERVER - mssqlsystemresource - Resource Database](https://blog.sqlauthority.com/2008/07/27/sql-server-mssqlsystemresource-resource-database/): Just a day ago I received following email “Dear Pinal, While I was exploring my computer in directory C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data I have found database mssqlsystemresource. What is mssqlsystemresource? Thanks, Joseph Kazeka” Simple question like this are very interesting. mssqlsystemresource is Resource Database. It is read only database and contains system objects (i.e. sys.objects, sys.modules and other sys schema objects). Resource database does not contain any of user data. The purpose of resource database is to facilitates upgrading to new version of SQL Server without any hassle. In previous versions whenever version of SQL Server was upgraded all the previous... - [SQLAuthority News - Readers Selection - Readers Most Favorite Articles](https://blog.sqlauthority.com/2008/07/26/sqlauthority-news-readers-selection-readers-most-favorite-articles/): I have been receiving many emails from my readers about their favorite article. Few days ago, I asked in one of my post SQLAuthority News – Updated My Personal Book Mark Pages, which articles are most favorite articles of my readers. I have received tremendous response to my question and my mailbox overflowed. Based on readers response I have created list of readers most favorite articles. Let me know which one is your most favorite article. SQLAuthority News – Reader’s Selection Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQLAuthority T-Shirts, Mug, Hat and Other Product](https://blog.sqlauthority.com/2008/07/25/sqlauthority-news-sqlauthority-t-shirts-mug-hat-and-other-product/): I frequently get request for SQLAuthority T-Shirts. After continuous requests from many of loyal readers, I am posting link to SQLAuthoirty Products. SQLAuthority Products I have no intention to make money from this site or any product sale. All the product are sold from the site directly at no profit or profit sent to Child Rights and You directly. If this blog has been helpful to you and if you want to help me. Please stand up for the child rights. Donate money to Child Rights and You by visiting their site directly. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC SHRINKFILE Takes Long Time to Run](https://blog.sqlauthority.com/2008/07/25/sql-server-dbcc-shrinkfile-takes-long-time-to-run/): If you are DBA who are involved with Database Maintenance and file group maintenance, you must have experience that many times DBCC SHRINKFILE operations takes long time but any other operations with Database are relative quicker. Rebuilding index is quite resource intensive task but that happens faster than DBCC SHRINKFILE. Well, answer to this is very simple. DBCC SHRINKFILE is a single threaded operation. A single threaded operation does not take advantage of multiple CPUs and have no effect how many RAM are available. Hyperthreaded CPU even provides worst performance. If you rebuild indexes before you run DBCC SHRINKFILE operations, shrinking... - [SQL SERVER - 2005 -Track Down Active Transactions Using T-SQL](https://blog.sqlauthority.com/2008/07/24/sql-server-2005-track-down-active-transactions-using-t-sql/): Just a day ago, I was wondering how many active transaction are currently in my database. I found following DMV very useful – very simple and to the point. Following SQL will return currently active transaction. SELECT * FROM sys.dm_tran_session_transactions Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to Log Viewer](https://blog.sqlauthority.com/2008/07/23/sql-server-introduction-to-log-viewer/): SQL Server log data is very important for any DBA to troubleshoot SQL Server related problems. In SQL Server 2000 there was no facility to check System and Application log, however in SQL Server 2005 there is facility of the log viewer. It is very useful tool and very easy to use as well. In SQL Server 2005 all the windows event logs can be seen along with SQL Server logs. Interface for all the logs is same and can be launched from the same place. This log can be exported and filtered as well. Following two images describes the how... - [SQL SERVER - Clear SQL Server Memory Caches](https://blog.sqlauthority.com/2008/07/22/sql-server-clear-sql-server-memory-caches/): If SQL Server is running slow and operations are throwing errors due to lack of memory, it is necessary to look into memory issue. If SQL Server is restarted all the cache memory is automatically cleaned up. In production server it is not possible to restart the server. In this scenario following three commands can be very useful. When executed following three commands will free up memory for SQL Server by cleaning up its cache. DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX - ERROR : 9004 An error occurred while processing the log for database. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log.](https://blog.sqlauthority.com/2008/07/21/sql-server-fix-error-9004-an-error-occurred-while-processing-the-log-for-database-if-possible-restore-from-backup-if-a-backup-is-not-available-it-might-be-necessary-to-rebuild-the-log/): ERROR : 9004 An error occurred while processing the log for database. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log. If you receive above error it means you are in great trouble. This error occurs when database is attempted to attach and it does not get attached. I have solved this error using following methods. Hope this will help anybody who is facing the same error. Microsoft suggest there are two solution to this problem. 1) Restore from a backup. Create Empty Database with same name and physical files (.ldf... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - July 19 2008](https://blog.sqlauthority.com/2008/07/21/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-july-19-2008/): Ahmedabad SQL Server User Group is just 2 months old chapter but it is getting extremely popular among enthusiastic IT professionals. I have joined this group and suggest all the developers of Ahmedabad and surrounding areas to join this group. It does not matter which application you are using but SQL Server is same everywhere. Ahmedabad SQL Server User Group is very fortunate to have Jacob Sebastian (SQL Server MVP) as President of the Usergroup. Jacob is co-founder and CTO of Excellence Infonet, Ahmedabad. You can read his articles at http://jacobsebastian.blogspot.com and www.sqlkatmai.com. In recent meeting I had presented learning session... - [SQL SERVER - Change the Port of Service Broker Configuration](https://blog.sqlauthority.com/2008/07/20/sql-server-change-the-port-of-service-broker-configuration/): Just two days ago, I wrote a small note about SQL SERVER - Introduction to Service Broker. - [SQL Server - Fix - Error : 9692 The _MSG protocol transport cannot listen on port because it is in use by another process.](https://blog.sqlauthority.com/2008/07/19/sql-server-fix-error-9692-the-_msg-protocol-transport-cannot-listen-on-port-because-it-is-in-use-by-another-process/): If you face following error the solution of this is very simple. Error : 9692 The _MSG protocol transport cannot listen on port because it is in use by another process. Above error comes up with Service Broker. Service Broker is used to send Database Emails. Read more about SQL SERVER – Introduction to Service Broker. Solution/Fix/WorkAround: Option 1: Run netstat -aon on command prompt and determine what program is using the port described in the error. Once figured out disable the application which is using that port. Option 2: Alternatively, the port on which Service Broker is running can be... - [SQL SERVER - Introduction to Service Broker](https://blog.sqlauthority.com/2008/07/18/sql-server-introduction-to-service-broker/): Service Broker is message queuing for SQL Server. It is used for sending emails and through Database Mails. You can read about SQL SERVER – Difference Between Database Mail and SQLMail here. Service Broker is feature which provides facility to SQL Server to send an asynchronous, transactional message. - [SQLAuthority News - Updated My Personal Book Mark Pages](https://blog.sqlauthority.com/2008/07/18/sqlauthority-news-updated-my-personal-book-mark-pages/): It has been long time since I have updated my personal book mark list. I have just refreshed it. You are all welcome to checkout my personally picked articles. SQLAuthority Best Articles SQLAuthority Favorite Articles I often visit above two links to read my selected articles. If you have any personal favorite from SQLAuthority.com and I have not included that to my list you can let me know and if I like it I will add to that list. I am also going to start new list very soon, which will be Readers Chosen Articles. So I suggest you start suggesting... - [SQLAuthority News - Ahmedabad SQL Server Usergroup Meeting](https://blog.sqlauthority.com/2008/07/17/sqlauthority-news-ahmedabad-sql-server-usergroup-meeting/): I will be attending Ahmedabad SQL Server Usergroup Meeting on July 19, 2008. I will be taking session about “SQL Server Best Practices“. I invite all of the SQL enthusiastic to stop by User Group Meeting and meet all the fellow developers, DBAs and members. Location : 401, TIME SQUARE, CG road, Op Bazar Calcutta, Ahmedabad, India Date and Time : July 19, 2008 6:30 PM onwards Hope to see all of you there. If you with to attend the meeting, please register your name by sending an email to jacob.reliancesp[at]gmail.com latest by Saturday 12 Noon. And for those of you... - [SQL SERVER - Readers Contribution to Site - Simple Example of Cursor](https://blog.sqlauthority.com/2008/07/16/sql-server-readers-contribution-to-site-simple-example-of-cursor/): eaders are very important to me. Without their active participation this site would not be the community helping web site. I encourage readers participation and request that you help other users with your knowledge. I recently come across very good communication between two of blog readers. I want to thank you Imran Mohammed for taking time to answer this question as well many other questions. Expert like Imran makes this world better. Let us read the question from Anthony from here. All, I am using Microsoft SQL 2005 and am trying to create a cursor that will take data from several... - [SQL SERVER - Deferred Name Resolution](https://blog.sqlauthority.com/2008/07/15/sql-server-deferred-name-resolution/): One of my Jr. Developer always wondered when she creates any Stored Procedure (SP) and if there is incorrect table name in the SP it creates the SP fine but while executing it gives run time error. However, if there is any valid table from database is referenced in SP with incorrect column name it will not let user create SP at all. Question : How come when table name is incorrect SP can be created successfully but when incorrect column is used SP can not be created? Answer : Deferred Name Resolution of database is the root cause for this... - [SQL SERVER - 2008 - Introduction to SPARSE Columns - Part 2](https://blog.sqlauthority.com/2008/07/14/sql-server-2008-introduction-to-sparse-columns-part-2/): Previously I wrote about SQL SERVER – 2008 – Introduction to SPARSE Columns. Let us understand the concept of SPARSE column in more detail. I suggest you read the first part before continuing reading this article. All SPARSE columns are stored as one XML column in database. Let us see some of the advantage and disadvantage of SPARSE column. Advantages of SPARSE column are: INSERT, UPDATE, and DELETE statements can reference the sparse columns by name. SPARSE column can work as one XML column as well. SPARSE column can take advantage of filtered Indexes, where data are filled in the row.... - [SQL SERVER - SP_CONFIGURE - Displays or Changes Global Configuration Settings](https://blog.sqlauthority.com/2008/07/13/sql-server-sp_configure-displays-or-changes-global-configuration-settings/): It is very good to know our server and its feature which are available for configurations. SQL Server always has many features which can be enabled or disabled. One should at least know what are the options SQL Server provides. This blog post we will learn how to display or change global configuration settings. - [SQL SERVER - 2008 - User Account - sa or sysadmin](https://blog.sqlauthority.com/2008/07/12/sql-server-2008-user-account-sa-or-sysadmin/): Just a day ago, I noticed ‘sysadmin’ user in SQL Server 2008. While looking more into it, I found that it has same account rights as ‘sa’ account. ‘sysadmin’ is actually replacement for legacy ‘sa’ account. ‘sa’ still exist in SQL Server 2008, however, it will be deprecated in future versions of SQL Server. It is recommended to all the users who switch to SQL Server 2008 to start migrating to ‘sysadmin’ from ‘sa’. - [SQL SERVER - 2005 - Two Important Security Update](https://blog.sqlauthority.com/2008/07/11/sql-server-2005-two-important-security-update/): If you are using SQL Server 2005, following two are very important security updates not to be missed. Security Update for SQL Server 2005 Service Pack 2 (KB948108) A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. Security Update for SQL Server 2005 Service Pack 2 (KB948109) A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Introduction to SPARSE Columns](https://blog.sqlauthority.com/2008/07/10/sql-server-2008-introduction-to-sparse-columns/): I have been writing recently about how SQL Server 2008 is better in terms of Data Stage and Backup Management. I have received very good replies from many users and have requested to write more about it. Today we will look into another interesting concept of SPARSE column. The reason I like this feature because it is way better in terms of how columns are managed in SQL Server. SPARSE column are better at managing NULL and ZERO values in SQL Server. It does not take any space in database at all. If column is created with SPARSE clause with it... - [SQL SERVER - 2008 - Two Convenient Features Inline Assignment - Inline Operations](https://blog.sqlauthority.com/2008/07/09/sql-server-2008-two-convenient-features-inline-assignment-inline-operations/): Sometimes things just go very convenient and we wish that how come it was not available in earlier versions. Let us see two features here. If it was SQL Server earlier versions we might have to write more lines to achieve what we can achieve in lesser lines. Following small example with only one variable demonstrates this feature. SQL Server 2005 version: DECLARE @idx INT SET @idx = 0 SET @idx = @idx + 1 SELECT @idx GO SQL Server 2008 version: This version demonstrates two important feature of Inline Assignment and Inline Operations DECLARE @idx INT = 0 SET @idx+=1 SELECT... - [SQL SERVER - Find Space Used For Any Particular Table](https://blog.sqlauthority.com/2008/07/08/sql-server-find-space-used-for-any-particular-table/): We often run out of the space in our drive and that is the number 1 cause of SQL Server engine stop running on various machines. Quite often we wonder how much space if any of the objects takes in the database. It is very simple to find out the space used by any table in the database. - [SQLAuthority News - Thank You to Awarding Author SQL MVP](https://blog.sqlauthority.com/2008/07/07/sqlauthority-news-thank-you-to-awarding-author-sql-mvp/): I received award from Microsoft for SQL Server Most Valuable Professional a week ago. I have received many many congratulations messages from many readers for getting this award. I thank all of you for sending me messages and your wishes. Honestly, I think this is all of yours award and I am just receiving this award for everybody who is reading and participating on this community forum. My goal is that more and more user participation occurs on this website and I publish few articles which are really contribution from readers. If you are reading this blog and have any idea... - [SQL SERVER - 2008 - Introduction to Row Compression](https://blog.sqlauthority.com/2008/07/06/sql-server-2008-introduction-to-row-compression/): In my previous article SQL SERVER – 2008 – Introduction to New Feature of Backup Compression I wrote about Row Compression and I have received many request to write in detail about Row Compression. I like when I get request about any subject to write about from my readers. Row Compression feature apply to zeros and null values and optimize their space in SQL Server. In fact, due to Row Compression feature SQL Server does not take any disk space for zero or null values. Any datatypes (decimal, datetime, money, int etc) if they are storing zero or null values in... - [SQL SERVER - Difference Between Database Mail and SQLMail](https://blog.sqlauthority.com/2008/07/05/sql-server-difference-between-database-mail-and-sqlmail/): In recent user group meeting in my city Ahmedabad, I have found that not every user knows difference between these two features of SQL Server. I do not blame any user for not knowing difference between Database Mail and SQLMail as this is very confusing sometime. I will try to explain this concept here. - [SQL SERVER - Deprecated DataType vardecimal](https://blog.sqlauthority.com/2008/07/04/sql-server-deprecated-datatype-vardecimal/): I received following email yesterday from Satnam Singh- Computer Programmer from Bangalore. “Dear Pinal, Congratulations for being MVP. You truely deserved it. I wonder why have you never written newly introduced feature of vardecimal. Keep up good work! Satnam Singh Developer – Bangalore.” In SQL Server 2005 SP2 they have introduced new concept of vardecimal, which reduces the size of zero and null values. Generically vardecimal values ranges upto 20 bytes in storage place, however when zero or null values are used it reduces the values to only 2 bytes, this way it saves valuable storage place. This feature is now... - [SQL SERVER - 2008 - Introduction to New Feature of Backup Compression](https://blog.sqlauthority.com/2008/07/03/sql-server-2008-introduction-to-new-feature-of-backup-compression/): Backup and Data Storage is my most favorite subject and I have not written about this for some time. I was experimenting with new feature of SQL Server 2008 and I come across very interesting feature of Backup compression. Let us see example of Database AdventureWorks with and without compression. After taking backup with compression enabled and without compression the file size can be compared to see the difference it makes with compressing the database. BACKUP DATABASE AdventureWorks TO DISK='C:\Backup\AW_NoCompression.bak' GO BACKUP DATABASE AdventureWorks TO DISK='C:\Backup\AW_WithCompression.bak' WITH COMPRESSION GO SQL Server 2008 supports backup data compression at database level. First of... - [SQL SERVER - 2008 - Insert Multiple Records Using One Insert Statement - Use of Row Constructor](https://blog.sqlauthority.com/2008/07/02/sql-server-2008-insert-multiple-records-using-one-insert-statement-use-of-row-constructor/): I previously wrote article about SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL. I am glad that in SQL Server 2008 we have new feature which will make our life much more easier. We will be able to insert multiple rows in SQL with using only one SELECT statement. Previous method 1: USE YourDB GO INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('First',1); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Second',2); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Third',3); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Fourth',4); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Fifth',5); GO Previous method 2:... - [SQLAuthority News - Microsoft Most Valuable Professional Award for SQL Server - MVP](https://blog.sqlauthority.com/2008/07/01/sqlauthority-news-microsoft-most-valuable-professional-award-for-sql-server-mvp/): I am very glad to announce that Microsoft has awarded me Most Valuable Professional Award for SQL Server. I would like to thank Microsoft and MVP Lead Abhishek for awarding this honor to me. MVP is most prestigious award and I am very pleased to receive it. I thank all of my readers for their continuous support in my journey. Please feel free to contact me if you need any help or assistance. Pinal Dave SQL – MVP, MCDBA, MCAD, MCP Bachelors of Engineering (Electronics and Communications), Masters of Science (Computer Networks) Founder – SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - High Availability - Hot Add Memory](https://blog.sqlauthority.com/2008/06/30/sql-server-2008-high-availability-hot-add-memory/): After reading my previous article about SQL SERVER – 2008 – High Availability – Hot Add CPU the same developer who suggested Hot Add CPU asked me if there are any restrictions in Hot Adding Memory. Yes, there are few restictions to Hot Add Memory as well. I am listing them here. 1) Underlying hardware is always key concern. Hardware should be capable to add memory when previous memories are operational. 2) Operating system should be either Windows Server 2003 or 2008 Enterprise or Datacenter Edition. 3) This feature is only available in 64-bit SQL Server Enterprise Edition, or the 32-bit... - [SQLAuthority News - Rise in SQL Injection Attacks Exploiting Unverified User Data Input](https://blog.sqlauthority.com/2008/06/29/sqlauthority-news-rise-in-sql-injection-attacks-exploiting-unverified-user-data-input/): Microsoft is aware of a recent escalation in a class of attacks targeting Web sites that use Microsoft ASP and ASP.NET technologies but do not follow best practices for secure Web application development. These SQL injection attacks do not exploit a specific software vulnerability, but instead target Web sites that do not follow secure coding practices for accessing and manipulating data stored in a relational database. When a SQL injection attack succeeds, an attacker can compromise data stored in these databases and possibly execute remote code. Clients browsing to a compromised server could be forwarded unknowingly to malicious sites that may... - [SQL SERVER - 2008 - High Availability - Hot Add CPU](https://blog.sqlauthority.com/2008/06/28/sql-server-2008-high-availability-hot-add-cpu/): One of team member suggested that we should upgrade to SQL Server 2008 because its new feature is very cool “Hot Add CPU”. Yes, I agree it is very cool feature. I am eagerly waiting for RTM of SQL Server 2008 so I can upgrade our servers to SQL Server 2008. However, to use the feature of High Availability of “Hot Add CPU” has many restrictions and I am not sure we will be in need of that right away or for atleast couple of year. Let us look at few of the restrictions for using Hot Add CPU 1) Hardware... - [SQL SERVER - Difference Between DBMS and RDBMS](https://blog.sqlauthority.com/2008/06/27/sql-server-difference-between-dbms-and-rdbms/): What is the difference between DBMS and RDBMS? DBMS – Data Base Management System RDBMS – Relational Data Base Management System or Relational DBMS A DBMS has to be persistent, that is it should be accessible when the program created the data ceases to exist or even the application that created the data restarted. A DBMS also has to provide some uniform methods independent of a specific application for accessing the information that is stored. RDBMS adds the additional condition that the system supports a tabular structure of the data, with enforced relationships between the tables. This excludes the databases that... - [SQLAuthority News - Famous Quotes From Bill Gates - Part 2](https://blog.sqlauthority.com/2008/06/26/sqlauthority-news-famous-quotes-from-bill-gates-part-2/): My previous article about Bill Gates SQLAuthority News – Famous Quotes From Bill Gates got really lots of readers and got lots of request in email that I should have follow up article about other famous quotes from Bill Gates which are missing from original article. This blog is not about Quotes but SQL Server, but little fun never hurts. SQL Server is product of Microsoft, which Bill Gates is Chairman of, so indirectly this article is about SQL Server. “The computer was born to solve problems that did not exist before.” – Bill Gates “Your most unhappy customers are your... - [SQLAuthority Download - SQL Server Cheatsheet](https://blog.sqlauthority.com/2008/06/25/sqlauthority-download-sql-server-cheatsheet/): I think this is most popular question I receive in email, if I have SQL Server cheat sheet. Well, SQL Server is very wide subject and covering all the main topics of SQL Server will take 100 pages book as cheat sheet. I have tried to create one page cheat sheet which I use for my daily use. I use this quite often and my teammates uses them as well. You can download and print this cheat sheet and use it for your personal reference. If you have any suggestions, please let me know and I will see if I can... - [SQLAuthority News - Microsoft Source Code Analyzer for SQL Injection](https://blog.sqlauthority.com/2008/06/24/sqlauthority-news-microsoft-source-code-analyzer-for-sql-injection/): Microsoft Source Code Analyzer for SQL Injection is a static code analysis tool for finding SQL Injection vulnerabilities in ASP code. Customers can run the tool on their ASP source code to help identify code paths that are vulnerable to SQL Injection attacks. Perform the following steps to download and install the Microsoft Source Code Analyzer for SQL Injection: 1. Download msscasi_asp_pkg.exe to a temporary directory. 2. Run msscasi_asp_pkg.exe. 3. Enter an installation directory when prompted. 4. After extracting the files, read the usage section of the Readme.htm file for next steps. Download Code Analyzer Abstract courtesy : Microsoft Reference :... - [SQLAuthority News - Release Notes for SQL Server 2008 Release Candidate 0](https://blog.sqlauthority.com/2008/06/23/sqlauthority-news-release-notes-for-sql-server-2008-release-candidate-0/): All product should be documented. Particularly when any release happens product must have release notes because release notes educates people about product and its usage. Microsoft has also release notes for SQL Server 2008. This Release Notes document contains information for Microsoft SQL Server 2008 Release Candidate 0 (RC0) that supplements the SQL Server 2008 RC0 Readme and Books Online documentation. Download Release Notes Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Create Check Constraint on Column](https://blog.sqlauthority.com/2008/06/22/sql-server-create-check-constraint-on-column/): I found one of the Jr. Developer writing trigger for the requirement where he wanted to make sure invalidate data does not enter in table column. I suggested him to write Check Constraint. Check Constraints are very handy to make sure all the data in the table is validated before it enters in the database. Let us check constraint on over one of the table on postalcode table in database AdventureWorks database. Constraint will suggest that value which is larger than 11 character can not be inserted into the column. Once constraint is created, it can be tested by tring to... - [SQLAuthority News - White Paper: Security Overview for Database Administrators](https://blog.sqlauthority.com/2008/06/21/sqlauthority-news-white-paper-security-overview-for-database-administrators/): Note:   Download White Paper by Microsoft SQL Server 2008 is secure by design, default, and deployment. Microsoft is committed to communicating information about threats, countermeasures, and security enhancements as necessary to keep your data as secure as possible. This paper covers some of the most important security features in SQL Server 2008. It tells you how, as an administrator, you can install SQL Server securely and keep it that way, even as applications and users make use of the data stored within. Included in This Document * Introduction * Secure Configuration o Windows Update o Surface Area Configuration * Authorization o... - [SQL SERVER - Find Current Identity of Table](https://blog.sqlauthority.com/2008/06/20/sql-server-find-current-identity-of-table/): Many times we need to know what is the current identity of the column. I have found one of my developer using aggregated function MAX() to find the current identity. USE AdventureWorks GO SELECT MAX(AddressID) FROM Person.Address GO However, I prefer following DBCC command to figure out current identity. USE AdventureWorks GO DBCC CHECKIDENT ('Person.Address') GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - White Paper: SQL Server 2008 Compared to Oracle Database 11g](https://blog.sqlauthority.com/2008/06/19/sqlauthority-news-white-paper-sql-server-2008-compared-to-oracle-database-11g/): Note: Download White Paper by Microsoft Microsoft SQL Server has steadily gained ground on other database systems and now surpasses the competition in terms of performance, scalability, security, developer productivity, business intelligence (BI), and compatibility with the 2007 Microsoft Office System. It achieves this at a considerably lower cost than does Oracle Database 11g. - [SQLAuthority News - Famous Quotes From Bill Gates](https://blog.sqlauthority.com/2008/06/18/sqlauthority-news-famous-quotes-from-bill-gates/): Bill Gates Quotes – “Success is a lousy teacher. It seduces smart people into thinking they can’t lose.” “Until we’re educating every kid in a fantastic way, until every inner city is cleaned up, there is no shortage of things to do.” “If I’d had some set idea of a finish line, don’t you think I would have crossed it years ago?” “If I had to say what is the thing that I feel best about, it’s being involved in this whole software revolution and what comes out of that.” “Whenever new technologies come along, parents have a legitimate concern about... - [SQL SERVER - 2008 - SQL Server Start Time](https://blog.sqlauthority.com/2008/06/17/sql-server-2008-sql-server-start-time/): I have been playing with SQL Server 2008 recently. There are many new features which SQL Server 2008 have. One of the interesting addition to SQL Server 2008 is system table field which records when SQL Server was started. This field has data type as datetime that is why it is precise to 3 milisecond. Note : This will not work with SQL Server 2005 or earlier version. This works with SQL Server 2008 only. SELECT sqlserver_start_time FROM sys.dm_os_sys_info ResultSet: sqlserver_start_time ———————– 2008-06-27 20:51:53.317 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to SERVERPROPERTY and example](https://blog.sqlauthority.com/2008/06/16/sql-server-introduction-to-serverproperty-and-example/): SERVERPROPERTY is very interesting system function. It returns many of the system values. I use it very frequently to get different server values like Server Collation, Server Name etc. Run following script to see all the properties of server. SELECT 'BuildClrVersion' ColumnName, SERVERPROPERTY('BuildClrVersion') ColumnValue UNION ALL SELECT 'Collation', SERVERPROPERTY('Collation') UNION ALL SELECT 'CollationID', SERVERPROPERTY('CollationID') UNION ALL SELECT 'ComparisonStyle', SERVERPROPERTY('ComparisonStyle') UNION ALL SELECT 'ComputerNamePhysicalNetBIOS', SERVERPROPERTY('ComputerNamePhysicalNetBIOS') UNION ALL SELECT 'Edition', SERVERPROPERTY('Edition') UNION ALL SELECT 'EditionID', SERVERPROPERTY('EditionID') UNION ALL SELECT 'EngineEdition', SERVERPROPERTY('EngineEdition') UNION ALL SELECT 'InstanceName', SERVERPROPERTY('InstanceName') UNION ALL SELECT 'IsClustered', SERVERPROPERTY('IsClustered') UNION ALL SELECT 'IsFullTextInstalled', SERVERPROPERTY('IsFullTextInstalled') UNION ALL SELECT 'IsIntegratedSecurityOnly', SERVERPROPERTY('IsIntegratedSecurityOnly') UNION ALL... - [SQL SERVER - 2008 - Inline Variable Assignment](https://blog.sqlauthority.com/2008/06/15/sql-server-2008-inline-variable-assignment/): I loved this feature. I have always wanted this feature to be present in SQL Server. Last time when I met developers from Microsoft SQL Server, I had talked about this feature. I think this feature saves some time but make the code more readable. ---- SQL Server 2005 Way DECLARE @MyVar INT SET @MyVar = 5 SELECT @MyVar AS TestVar GO ---- SQL Server 2008 Way DECLARE @MyVar INT&nbsp;= 5 SELECT @MyVar AS TestVar GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 600 Article and Over 3 Million Readers](https://blog.sqlauthority.com/2008/06/14/sqlauthority-news-600-article-and-over-3-million-readers/): Today is 600th article on this blog and so far over 3 Million readers have visited this blog. Popularity of this blog is increating everyday due to active participation from some good readers. When people share their ideas and their opinion whole world becomes better place. I encourage all of my readers to send me their thoughts, articles and ideas. I will be happy to share tips and tricks of readers with this blog. I have received many emails where people have asked me why I do not write about my favorite articles on this blog. Well, actually I do write... - [SQL SERVER - 2008 - Introduction to Policy Management - Enforcing Rules on SQL Server](https://blog.sqlauthority.com/2008/06/13/sql-server-2008-introduction-to-policy-management-enforcing-rules-on-sql-server/): I have previous written article about SQL SERVER Database Coding Standards and Guidelines Complete List Download. I just received question from one of the blog reader is there any way we can just prevent violation of company policy. Well Policy Management can come into handy in this scenario. - [SQL SERVER - 2008 - Step By Step Installation Guide With Images](https://blog.sqlauthority.com/2008/06/12/sql-server-2008-step-by-step-installation-guide-with-images/): SQL SERVER 2008 Release Candidate 0 has been released for some time and I have got numerous request about how to install SQL Server 2008. I have created this step by step guide Installation Guide. Images are used to explain the process easier. - [SQL SERVER - 2008 - Four Key Pillars](https://blog.sqlauthority.com/2008/06/11/sql-server-2008-four-key-pillars/): As SQL Server 2008 is now ready to ship its final product in few months, I get many questions about what is new and attractive in SQL Server 2008. SQL SERVER 2008 has four key pillars. 1) Enterprise Data Platform It has heavily reliable database platform and can be expanded very quickly. IT also supports Hardware Security Module and Enterprise Key Management tools. Performance is key feature of SQL Server 2008. 2) Beyond Relational This edition supports spatial datatypes, which can be used for Global Positioning System and Geographic Information System. Additionally, arbitrary size of the files can be stored in... - [SQL SERVER - Microsoft SQL Server 2008 Reporting Services Add-in for Microsoft SharePoint Technologies](https://blog.sqlauthority.com/2008/06/10/sql-server-microsoft-sql-server-2008-reporting-services-add-in-for-microsoft-sharepoint-technologies/): Note: Download Here by Microsoft Microsoft SQL Server 2008 Reporting Services Add-in for SharePoint Technologies Release Candidate (RC0) (Reporting Services Add-in) enables you to take advantage of SQL Server 2008 Release Candidate (RC0) report processing and management capabilities within Windows SharePoint Services (WSS) 3.0 or Microsoft Office SharePoint Server 2007. The download provides the following functionality: A Report Viewer Web Part that provides report viewing capability, export to other rendering formats, page navigation, search, print, and zoom. Web application pages so that you can create subscriptions and schedules, and manage reports, models, and data sources. Support for using standard Windows SharePoint... - [SQLAuthority News - SQL Server 2008 Release Candidate 0](https://blog.sqlauthority.com/2008/06/09/sqlauthority-news-sql-server-2008-release-candidate-0/): Download Microsoft SQL Server 2008 Release Candidate 0 (RC0) and preview the latest features of SQL Server 2008! The SQL Server development team uses your feedback to help refine and enhance product features. Evaluate SQL Server 2008 RC0 today and send your feedback. SQL Server 2008 provides a comprehensive data platform that is secure, reliable, manageable, and scalable for your mission critical applications. With it, developers can create new applications that can store and consume any type of data on any device, enabling your users to make informed decisions with relevant insights. SQL Server 2008 RC0 will automatically expire after 180... - [SQL SERVER - Order of Conditions in WHERE Clause](https://blog.sqlauthority.com/2008/06/08/sql-server-order-of-conditions-in-where-clauses/): Sr. Developer in my organization asked me the following question about WHERE clause.  Question: Does the order of conditions matter in WHERE clause? - [SQL SERVER - PIVOT and UNPIVOT Table Examples](https://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/): I previously wrote two articles about PIVOT and UNPIVOT tables. I really enjoyed writing about them as it was interesting concept. One of the Jr. DBA at my organization asked me following question. “If we PIVOT any table and UNPIVOT that table do we get our original table?” I really think this is good question. Answers is Yes, you can but not always. When we pivot the table we use aggregated functions. If due to use of this function if data is aggregated, it will be not possible to get original data back. Let me explain this issue demonstrating simple example.... - [SQLAuthority News - Subscribe to the Newsletter for 3 Important Scripts](https://blog.sqlauthority.com/2008/06/06/sqlauthority-news-subscribe-to-the-newsletter-for-3-important-scripts/): Lots of people ask me how to stay in touch with SQLAuthority.com. Well, the answer is very simple, you can subscribe to the newsletter of SQLAuthority.com by going to URL here: https://go.sqlauthority.com.  - [SQL SERVER - Compound Assignment Operators - A Simple Example](https://blog.sqlauthority.com/2008/06/05/sql-server-2008-compound-assignment-operators/): SQL SERVER 2008 has introduced new concept of Compound Assignment Operators. Compound Assignment Operators are available in many other programming languages for quite some time. Compound Assignment Operators is operator where variables are operated upon and assigned on the same line. - [SQL SERVER - Create a Comma Delimited List Using SELECT Clause From Table Column](https://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/): I received following question in email : How to create a comma delimited list using SELECT clause from table column? - [SQL SERVER - Example of DISTINCT in Aggregate Functions](https://blog.sqlauthority.com/2008/06/03/sql-server-example-of-distinct-in-aggregate-functions/): Just a day ago, I was was asked this question in one of the teaching session to my team members. One of the member asked me if I can use DISTINCT in Aggregate Function and does it make any difference. Of course! It does make difference. DISTINCT can be used to return unique rows from a result set and it can be used to force unique column values within an aggregate function. USE AdventureWorks GO SELECT SUM(DISTINCT ReorderPoint) ResultDistinct FROM Production.Product GO SELECT SUM(ReorderPoint) ResultNoDistinct FROM Production.Product GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Order Of Column In Index](https://blog.sqlauthority.com/2008/06/02/sql-server-order-of-column-in-index/): I just found one of my Jr. DBA to create many indexes with lots of column in it. After talking with him I found out that he really does not understand how really Index works. He was under impression that if he has more columns in one index, that index has higher chance of getting selected during execution of query and speed up the query. It was very much incorrect. He did not understand important of the order of column in created index. Order really matters and the column which is at first order matters the most in Index. The selection... - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 4](https://blog.sqlauthority.com/2008/06/01/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-4/): I have been asked many times when there is DATENAME function available why do I go in exercise of writing UDF For the getting the day of the week. Answer is : I just like it! SELECT DATENAME(dw, GETDATE()) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Create Default Constraint Over Table Column](https://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/): Very frequently Jr. Developers request script for creating default constraint over table column. I have written following small script for creating default constraint. I think this will be useful to many other developers who want this script to keep handy. - [SQLAuthority News - 3 Million Readers and Continuing Journey](https://blog.sqlauthority.com/2008/05/30/sqlauthority-news-3-million-readers-and-continuing-journey/): I would like to express my deep gratitude towards your active participation on this blog. There are more than 3 Million of you have visited this site as well contributed to make it successful. You can read my personally selected articles here. SQLAuthority – Best Articles SQLAuthority – Favorite Articles Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UNPIVOT Table Example](https://blog.sqlauthority.com/2008/05/29/sql-server-unpivot-table-example/): My previous article SQL SERVER – PIVOT Table Example encouraged few of my readers to ask me question about UNPIVOT table. UNPIVOT table is reverse of PIVOT Table. USE AdventureWorks GO CREATE TABLE #Pvt ([CA] INT NOT NULL, [AZ] INT NOT NULL, [TX] INT NOT NULL); INSERT INTO #Pvt ([CA], [AZ], [TX]) SELECT [CA], [AZ], [TX] FROM ( SELECT sp.StateProvinceCode FROM Person.Address a INNER JOIN Person.StateProvince sp ON a.StateProvinceID = sp.StateProvinceID ) p PIVOT ( COUNT (StateProvinceCode) FOR StateProvinceCode IN ([CA], [AZ], [TX]) ) AS pvt; SELECT StateProvinceCode, Customer_Count FROM ( SELECT [CA], [AZ], [TX] FROM #Pvt ) t UNPIVOT (... - [SQLAuthority News - Download - Windows Server 2008 w/ SQL Server 2005](https://blog.sqlauthority.com/2008/05/28/sqlauthority-news-download-windows-server-2008-w-sql-server-2005/): Note: Download Here by Microsoft This download comes as a pre-configured VHD. This download enables testing of application designs on the Windows Server Platform. As design gets more closely integrated into the process of building websites and web applications it becomes more critical to have all the necessary software installed on your machine to enable you to preview and review the designs you are working on. Often this is the only way of ensuring your designs will remain intact and look as intended when the finished project goes live on the web. Working on a web based project today generally involves... - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 3](https://blog.sqlauthority.com/2008/05/27/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-3/): Datetime functions and stored procedures always interests me. Nanda Kumar has suggested modification to previous written article about SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 2. He has improved on UDF. CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) DECLARE @weekDay INT ----Here I have subtracted 7 For keeping Sunday as the First day like wise for Monday we need to subtract 2 and so on SET @weekDay=((DATEPART(dw,@dtDate)+@@DATEFIRST-7)%7) SELECT @rtDayofWeek = CASE @weekDay WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN... - [SQLAuthority News - SQL SERVER 2008 - New Logo](https://blog.sqlauthority.com/2008/05/26/sqlauthority-news-sql-server-2008-new-logo/): Microsoft SQL Server 2008 has new logo. I really liked the new design. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to Devide One Column into Two Column](https://blog.sqlauthority.com/2008/05/25/sql-server-t-sql-script-to-devide-one-column-into-two-column/): Just a day ago, we faced situation where one column in database contained two values which were separated by comma. We wanted to separate this two values in their own columns. It was interesting that value of the column was variable and something dynamic needed to be written. Following is quick script which separates one column into two columns. The separate between two values in comma. CREATE TABLE EMP_Demo (EMP_PAY VARCHAR(20), EMP_NAME VARCHAR(20), PAY_SCALE VARCHAR(20)); INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('ALPESH,7009') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('KRUTI,9909') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('TANMAY,16000.7') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('NESHA,6060.8') INSERT INTO EMP_DEMO(EMP_PAY) VALUES ('DEVANG,14000') UPDATE... - [SQL Authority News - SQL Server Interview Questions - SQL Related Jobs - DBA Job Description](https://blog.sqlauthority.com/2008/05/24/sql-authority-news-sql-server-interview-questions-sql-related-jobs-dba-job-description/): I like to help every candidate who are finding job. I have previously written article here which can help all the people who are looking for job or looking for candidates. SQL Server Interview Questions and Answers Complete List Download Find Job Related to SQL SERVER SQL Server DBA- Job Description Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 2](https://blog.sqlauthority.com/2008/05/23/sql-server-sql-server-udf-get-the-day-of-the-week-function-part-2/): I have written article about SQL SERVER – UDF – Get the Day of the Week Function. I have received good modified script from reader Mihir Popat has suggested another code where Sunday does not have to be necessary the first day of the week. CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) DECLARE @weekDay INT -- Here I have subtracted 7 For keeping Sunday as the First day -- like wise for Monday we need to subtract 2 and so on SET @weekDay = ((DATEPART(dw,GETDATE())+@@DATEFIRST-7)%7) SELECT @rtDayofWeek = CASE @weekDay WHEN 1 THEN 'Sunday' WHEN 2 THEN... - [SQL SERVER - PIVOT Table Example](https://blog.sqlauthority.com/2008/05/22/sql-server-pivot-table-example/): This is quite a popular question and I have never wrote about this on my blog. A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table. - [SQL SERVER - 2005 - Twelve Tips For Optimizing Sql Server 2005 Query Performance](https://blog.sqlauthority.com/2008/05/21/sql-server-2005-twelve-tips-for-optimizing-sql-server-2005-query-performance/): I recently came across very nice article about optimization tips for SQL Server 2005. Here is the list of those 12 tips. Twelve Tips For Optimizing Sql Server 2005 Query Performance 1. Turn on the execution plan, and statistics 2. Use Clustered Indexes 3. Use Indexed Views 4. Use Covering Indexes 5. Keep your clustered index small. 6. Avoid cursors 7. Archive old data 8. Partition your data correctly 9. Remove user-defined inline scalar functions 10. Use APPLY 11. Use computed columns 12. Use the correct transaction isolation level Reference : Pinal Dave (https://blog.sqlauthority.com) , Original Article - [SQL SERVER - 2008 - Choosing the Right Edition for Your Needs](https://blog.sqlauthority.com/2008/05/20/sql-server-2008-choosing-the-right-edition-for-your-needs/): Enterprise SQL Server 2008 is a comprehensive data platform that meets the high demands of enterprise online transaction processing and data warehousing applications. Standard SQL Server 2008 Standard is a complete data management and business intelligence platform providing best-in-class ease of use and manageability for running departmental applications. Workgroup Run branch locations on this reliable data management and reporting platform that provides secure remote synchronization and management capabilities. Compact Available as a free download, build stand-alone and occasionally connected applications for mobile devices, desktops, and Web clients on all Microsoft Windows platforms. Express Available as a free download, Express is ideal... - [SQLAuthority Download - Providing Security for Web Applications and Infrastructure: Best Practices for Managing Security Risks](https://blog.sqlauthority.com/2008/05/19/sqlauthority-download-providing-security-for-web-applications-and-infrastructure-best-practices-for-managing-security-risks/): Note :  Download PPT by Microsoft Providing Security for Web Applications and Infrastructure: Best Practices for Managing Security Risks The Windows Live Security team shares best practices – from platform and network security to incident management – in providing security for web applications and infrastructure. Organizations across the globe face unique challenges in enhancing security for Web applications and their IT infrastructures. Issues such as improper Web server configuration, weak authentication policies, and invalidated Web requests can lead to unauthorized user access and potential attacks. The Microsoft Windows Live team provides services to millions of customers each month for e-mail, mobile... - [SQLAuthority News - SQL SERVER Database Administrator Job Description](https://blog.sqlauthority.com/2008/05/18/sqlauthority-news-sql-server-database-administrator-job-description/): I have previously written article about SQLAuthority News – Job Description of Database Administrator (DBA) or Database Developer. I have received quite a lot of request to update it or post something similar. Writing SQL Articles are easier then writing Job description for DBA. I have read many job description and job posting at Best SQL Jobs and found following job description. DBA Job Description The Data Base Administrator (DBA) is responsible for providing technical support for the database environment including overseeing the development and organization of the databases, assessment and implementation of new technologies, and providing Information Technology with a... - [SQL SERVER - Ideal TempDB FileGrowth Value](https://blog.sqlauthority.com/2008/05/17/sql-server-ideal-tempdb-filegrowth-value/): Just a day ago, while installing SQL Server on our development machine Jr. DBA asked me what should be kept file growth of the TempDB. I really have not thought about this till moment and I looked at MS site. - [SQL SERVER - Find Table in Every Database of SQL Server - Part 3](https://blog.sqlauthority.com/2008/05/16/sql-server-find-table-in-every-database-of-sql-server-part-3/): Previously I wrote two articles about SQL SERVER – Find Table in Every Database of SQL Server SQL SERVER – Find Table in Every Database of SQL Server – Part 2 I recently received email from SQL Expert and Blog Reader Greg Steinkuhler. People like Greg Steinkuhler makes this whole world better place. He wrote absolutely wonderful script which runs on network and have shared with community. Hats Off to you! His original email is listed here: Hi Pinal Dave, After reading the article on your website in reference to “Find Table in Every Database of SQL Server” I tried to... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Silly Mistake](https://blog.sqlauthority.com/2008/05/15/sql-server-sql-joke-sql-humor-sql-laugh-silly-mistake/): It is really very bad of person to laugh on others misfortune, however dark humor is based on the same concept. It has been long time since I wrote something funny on this blog. Recently, I have came across forum discussion regarding backup misery of one of the developer. I feel very sorry for the DBA who lost their backup but I found the suggestions of other “SQL Experts” really humorous and helpful as well. Read whole communication here Some of the witty lines are : OK, take a deep breath. Write a resignation letter. Go into your bosses office. Own... - [SQL SERVER - Orphaned MS DTC Transaction Information](https://blog.sqlauthority.com/2008/05/14/sql-server-orphaned-ms-dtc-transaction-information/): Few days ago, one of our application was crashing IIS application pool because of unhandled exception. After researched we figured out the case of it was orphaned MS DTC transaction. When multiple connections are operating over one MS DTC transaction, this problem sometime shows up. As many connection are working none of them try to roll back the MS DTC transaction, this creates orphaned connection, which crashes IIS application pool. You can figure out if there is orphaned connection or not in your application from following quick script. If there are orphaned connection it will show up in result otherwise script... - [SQL SERVER - Four Basic SQL Statements - SQL Operations](https://blog.sqlauthority.com/2008/05/13/sql-server-four-basic-sql-statements-sql-operations/): There are four basic SQL Operations or SQL Statements. SELECT – This statement selects data from database tables. UPDATE – This statement updates existing data into database tables. INSERT – This statement inserts new data into database tables. DELETE – This statement deletes existing data from database tables. If you want complete syntax for this four basic statement, please download FAQ (PDF) from SQL SERVER – Download FAQ Sheet – SQL Server in One Page Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable - Part 2](https://blog.sqlauthority.com/2008/05/12/sql-server-sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable-part-2/): Some questions never get old. One of them is temp table variable and temp table in SQL Server. I have previously wrote about this indepth here : SQL SERVER – Comparison : Similarity and Difference #TempTable vs @TempVariable Recently I received question: Can temporary table have indexes? If yes, are they really useful and efficient? When nonclustered index are created a separate table is created, what happens in the case of when temporary table? I really liked the question of user. Yes, temporary table can have indexes. If you have to use temporary table more than one time in your operation,... - [SQL SERVER 2005 - Microsoft Will Release SP3 Soon](https://blog.sqlauthority.com/2008/05/11/sql-server-2005-microsoft-will-release-sp3-soon/): I have received quite a few inquires if Microsoft is going to release SP3 for SQL Server or not? Yes! Microsoft is going to release SP3 very soon. The exact date is not announced yet. You can read the announcement of SP3 here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Function Property - Deterministic or Non-Deterministic](https://blog.sqlauthority.com/2008/05/10/sql-server-function-property-deterministic-or-non-deterministic/): I recently received question through email that how to determine if any user defined function is deterministic or non-deterministic? First go through two articles I have written about deterministic and non-deterministic function. SQL SERVER – Deterministic Functions and Nondeterministic Functions SQL SERVER – 2005 – Use of Non-deterministic Function in UDF – Find Day Difference Between Any Date and Today You can run following code to determine if function is deterministic or not. SELECT OBJECTPROPERTY(OBJECT_ID('dbo.ufnGetAccountingStartDate'), 'IsDeterministic') IsFunctionDeterministic Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 7311 - You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server](https://blog.sqlauthority.com/2008/05/09/sql-server-fix-error-7311-you-may-receive-an-error-message-when-you-try-to-run-distributed-queries-from-a-64-bit-sql-server-2005-client-to-a-linked-32-bit-sql-server-2000-server-or-to-a-linked-s/): Following email is received from SQL Server Expert Roy Cheung. He faced issue of creating and running distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server. He has found solution and would like to share with SQLAuthority Blog Readers. Hi Pinal, Recently, I’ve a problem on create and run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server. The solution below works perfect for us, I think it is good to share. http://blogs.msdn.com/sql_protocols/archive/2006/08/10/694657.aspx Thanks, Roy If you have tip or solution like this and would... - [SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database - Part 2](https://blog.sqlauthority.com/2008/05/08/sql-server-2005-find-tables-with-foreign-key-constraint-in-database-part-2/): What I love most about this blog is active readers participation. If readers are becoming contributor is the true success for any blog or online community. Recently many readers have contributed their suggestions and script to this blog. Joffery has provided nice script which is modification to previous article of SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database. Following note is from Joffery: Hi Pinal Very interesting article and of great help. I made a little addition to your code. As I wanted also to know what the FKs are doing in the Table (referential integrity... - [SQL SERVER - Create Database Error in Windows Vista](https://blog.sqlauthority.com/2008/05/07/sql-server-create-database-error-in-windows-vista/): I recently receive question from one of the blog reader that he is having problem creating database in Windows Vista. Read original comment here. I have installed vista ultimate and sql server 2005 developer edition in my computer.I also connect SQL 2005 in window authentication but when I CREATE any database in following query CREATE DATABASE MANEESH USE MANEESH Its give me everytime following error:- Msg 262, Level 14, State 1, Line 1 CREATE DATABASE permission denied in database ‘master’. & Msg 911, Level 16, State 1, Line 1 Could not locate entry in sysdatabases for database ‘maneesh’. No entry found with... - [SQL SERVER 2005 - FIX Error: 18456 : VISTA Windows Authentication](https://blog.sqlauthority.com/2008/05/06/sql-server-2005-fix-error-18456-vista-windows-authentication/): In previous post I have mentioned about SQL SERVER 2005 – Vista Ultimate and SQL Server 2005 DEV Edition. There was one simple issue with the installation. I was not able to login using windows authentication method. I was able to successful login using sa username and password. I kept on receiving following error. TITLE: Connect to Server —————————— Cannot connect to SQLAUTHORITY. —————————— ADDITIONAL INFORMATION: Login failed for user ‘SQLAUTHORITY\Pinal’. (Microsoft SQL Server, Error: 18456) For help, click: —————————— BUTTONS: OK —————————— After a while I realize that this may be due to one needs Administrator rights to do any... - [SQL SERVER - Denali - Conversion Function - TRY_PARSE() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/07/sql-server-denali-conversion-function-try_parse-a-quick-introduction/): In SQL Server Denali, there are three new conversion functions being introduced, namely: PARSE() TRY_PARSE() TRY_CONVERT() Today we will quickly take a look at the TRY_PARSE() function. The TRY_PARSE() function can convert any string value to Numeric or Date/Time format. If the passed string value cannot be converted to Numeric or Date/Time format, it will result to a NULL. The PARSE() function relies on Common Language Runtime (CLR) to convert the string value. If there is no CLR installed in the server, the TRY_PARSE() function will return an error. Additionally, please note that TRY_PARSE() only works for String Values to be... - [SQL SERVER - A Guide to Integrating SQL Server with XML, C#, and PowerShell - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/09/07/sql-server-a-guide-to-integrating-sql-server-with-xml-c-and-powershell-book-available-for-sql-server-certification/): We recently gave away 7 physical books of Joes 2 Pros Book Volume 5. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. All objects... - [SQL SERVER - Denali - Conversion Function - PARSE() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/06/sql-server-denali-conversion-function-parse-a-quick-introduction/): In SQL Server Denali, there are three new conversion functions being introduced, namely: PARSE() TRY_PARSE() TRY_CONVERT() Today we will quickly look at PARSE() function. PARSE() function can convert any string value to Numeric or Date/Time format. If passed string value cannot be converted to Numeric or Date/Time format, it will result to an error. PARSE() function relies on Common Language Runtime (CLR) to convert the string value. If there is no CLR installed on the server, PARSE() function will return an error. Additionally, please note that PARSE only works for String Values to be converted to Numeric and Date/Time. If you... - [SQL SERVER - Download Denali CTP3 and Denali CTP 3 Product Guide](https://blog.sqlauthority.com/2011/09/06/sql-server-download-denali-ctp3-and-denali-ctp-3-product-guide/): Microsoft SQL Server code name ‘Denali’ enables a cloud-ready information platform that will help organizations unlock breakthrough insights across the organization as well as quickly build solutions and extend data across on-premises and public cloud backed by capabilities for mission critical confidence. Download Denali CTP3. Additionally you can read what are new features of the Denali CTP3 on TechNet Wiki. The SQL Server code name ‘Denali’ Community Technical Preview 3 (CTP3) Product Guide download contains the latest datasheets, white papers, click-through and auto-running demonstrations, hands-on lab previews, technical presentations, and other useful links to help you evaluate the SQL Server code... - [SQLAuthority News - Whitepaper - Running SQL Server with Hyper-V Dynamic Memory Best Practices and Considerations - Consolidating Databases Using Virtualization Planning Guide](https://blog.sqlauthority.com/2011/09/05/sqlauthority-news-whitepaper-running-sql-server-with-hyper-v-dynamic-memory-best-practices-and-considerations/): I was recently looking for best practices for Hyper-V and SQL Server and I ended up whitepaper which was published in July earlier this year. I really wish I had come across this whitepaper earlier but any way still it is better to be late then never. Download Running SQL Server with Hyper-V Dynamic Memory – Best Practices and Considerations Memory is a critical resource to Microsoft SQL Server workloads, especially in a virtualized environment where resources are shared and contention for shared resources can lead to negative impact on the workload. Windows Server 2008 R2 SP1 introduced Hyper-V Dynamic Memory,... - [SQL SERVER - Programming and Development - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/09/05/sql-server-programming-and-development-book-available-for-sql-server-certification/): We recently gave away 7 physical books of Joes 2 Pros Book Volume 4. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. All objects... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - OpenXML Options - Day 35 of 35](https://blog.sqlauthority.com/2011/09/04/sql-server-tips-from-the-sql-joes-2-pros-development-series-openxml-options-day-35-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. OpenXML Options The last posts introduced us to the OpenXML function. We learned the two required parameters for this function are the handle (which must be in the form of an integer) and the rowpattern (to know what part of the XML has your data). The OpenXML function offers some helpful options for querying. This post will explore the two main syntaxes for rowpattern recursion... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Preparing XML in Memory - Day 34 of 35](https://blog.sqlauthority.com/2011/09/03/sql-server-tips-from-the-sql-joes-2-pros-development-series-preparing-xml-in-memory-day-34-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. Preparing XML in Memory If you want to take XML data and create a result set in SQL Server, you must first store the XML in memory. The process of preparing XML in SQL includes storing the XML in memory and processing the XML so that all the data and metadata is ready and available for you to query. Recall that element levels in your... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Shredding XML - Day 33 of 35](https://blog.sqlauthority.com/2011/09/02/sql-server-tips-from-the-sql-joes-2-pros-development-series-shredding-xml-day-33-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. Shredding XML Our introduction to XML in the last 3 days of posts thus far has focused on seeing tabular data taken from SQL Server and streamed into well-formed XML instead of the rowset data we typically work with.  The next two posts will focus on the reverse process.  Our starting point will be data which is already in XML and which we will... - [SQLAuthority News - Programming & Development For Microsoft SQL Server 2008](https://blog.sqlauthority.com/2011/09/02/sqlauthority-news-programming-development-for-microsoft-sql-server-2008/): I just can not resist sharing this video which my wife took while I was reading the book I co-authored. After long debate with my wife I have decided to put this video on youtube for public viewing. I initially thought, it is good to just have this in personal collection but my wife Nupur insisted on putting it live. [youtube=http://www.youtube.com/watch?v=l1rvrBQUU-s] You can buy my book from Amazon.com and Flipkart. We did receive few notes from user that it is listed as out-of-stock. There may be some glitch but the book has been always available as there is enough copies of... - [SQLAuthority News - SQL Wait Stats Joes 2 Pros Book Released Today - 30 Million Views Completed](https://blog.sqlauthority.com/2011/09/01/sqlauthority-news-sql-wait-stats-joes-2-pros-book-released-today-30-million-views-completed/): Happy Ganesh Chaturthi to all the friends of SQLAuthority.com. On today's auspicious day I have three news to share - 1) Shaivi's 2nd Birthday 2) New Book Released 3) 30 Millions Views. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Using Root With Auto XML Mode - Day 32 of 35](https://blog.sqlauthority.com/2011/09/01/sql-server-tips-from-the-sql-joes-2-pros-development-series-using-root-with-auto-xml-mode-day-32-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. XML Path Mode The XML Raw and Auto modes are great for displaying data as all attributes or all elements – but not both at once. If you want your XML stream to have some of its data shown in attributes and some shown as elements, then you can use the XML Path mode. The following Select statement shows us all locations and the employees who work in... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Using Root With Auto XML Mode - Day 31 of 35](https://blog.sqlauthority.com/2011/08/31/sql-server-tips-from-the-sql-joes-2-pros-development-series-using-root-with-auto-xml-mode-day-31-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. Using Root With Auto XML Mode Now let’s add a root element (also called root node), so that our stream will be well-formed XML. Using the ROOT keyword in combination with the Auto mode produces the same result as it does with the Raw mode:  your XML stream will contain a root (named <root> by default). To specify a name for the root, put this name in the... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - What is XML? - Day 30 of 35](https://blog.sqlauthority.com/2011/08/30/sql-server-tips-from-the-sql-joes-2-pros-development-series-what-is-xml-day-30-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. Let’s look at another example from the Employee table.  If you ran the reset script for this chapter, you should see 14 JProCo employees showing in your Employee table. Next we will add FOR XML RAW to view the result from the Employee table as an XML output using the raw mode. We have changed our Employee table result to output as XML RAW.... - [SQL SERVER - SSQL Architecture Basics - Core Architecture Concepts - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/08/29/sql-server-ssql-architecture-basics-core-architecture-concepts-book-available-for-sql-server-certification/): We recently give away 7 physical books of Joes 2 Pros Book Volume 3. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. All objects... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - What is XML? - Day 29 of 35](https://blog.sqlauthority.com/2011/08/29/sql-server-tips-from-the-sql-joes-2-pros-development-series-what-is-xml-day-28-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. What is XML? A common observation by people seeing an XML file for the first time is that it looks like just a bunch of data inside a text file. XML files are text-based documents, which makes them easy to read.  All of the data is literally spelled out in the document and relies on a just a few characters (<, >, =)... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Structured Error Handling - Day 28 of 35](https://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. In everyday life, not everything you plan on doing goes your way. For example, recently I planned to turn left on Rosewood Avenue to head north to my office. To my surprise, the road was blocked because of construction. I still needed to head north, even though the signs told me that turning that direction was impossible. I could have treated the... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - SQL Server Error Messages - Day 27 of 35](https://blog.sqlauthority.com/2011/08/27/sql-server-tips-from-the-sql-joes-2-pros-development-series-sql-server-error-messages-day-27-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. SQL Server Error Messages By now, most readers have likely learned that it is better to deal with problems early on while they are small.  SQL Server detects and helps you identify most errors before you are even allowed to run the code. For example, if you try to run a query against a table which does not exist, SQL Server informs... - [SQL SERVER - Table Valued Functions - Day 26 of 35](https://blog.sqlauthority.com/2011/08/26/sql-server-tips-from-the-sql-joes-2-pros-development-series-table-valued-functions-day-26-of-35/): Let us learn about table valued functions. Every day one winner from the United States will get Joes 2 Pros Volume 4. - [SQL SERVER - Author's Book is Available in India and USA](https://blog.sqlauthority.com/2011/08/25/sql-server-authors-book-is-available-in-india-and-usa/): I am feeling very good to write this short blog post. My book is now officially available on in India and USA. In India you can get it from Flipkart – In USA you can get it from Amazon – This book is just like this blog and contains all the complex subject in very simple manner. I am confident that you will for sure like this book if you like this blog. Here is quick video shot by my wife when I was reading my own book. See the original post to see the video. [youtube=http://www.youtube.com/watch?v=l1rvrBQUU-s] Here is quick secret... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Table-Valued Store Procedure Parameters - Day 25 of 35](https://blog.sqlauthority.com/2011/08/25/sql-server-tips-from-the-sql-joes-2-pros-development-series-table-valued-store-procedure-parameters-day-25-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. Note: If you want to setup the sample JProCo database on your system you can watch this video. For this post you will want to run the SQLProgrammingChapter5.1Setup.sql script from Volume 4. Table-Valued Store Procedure Parameters Stored procedures can easily take a single parameter and use a variable to populate it.  A stored procedure can readily handle two parameters in this same fashion.  However,... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Easy Introduction to CHECK Options - Day 24 of 35](https://blog.sqlauthority.com/2011/08/24/sql-server-tips-from-the-sql-joes-2-pros-development-series-easy-introduction-to-check-options-day-24-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. Using Check Option CHECK OPTION is a very handy tool we can use with our views. If I give you the definition right away and you don’t already know what it does then is just confusing. However the examples make perfect sense. So let’s save the definition for the end of this post. First let’s look at the creation of the vHighValueGrants... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Introduction to Views - Day 23 of 35](https://blog.sqlauthority.com/2011/08/23/sql-server-tips-from-the-sql-joes-2-pros-development-series-introduction-to-views-day-23-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. View Options Not every query may be turned into a view.  There are rules which must be followed before your queries may be turned into views. View Rules This query includes a simple aggregation which totals the grant amounts according to each EmpID.  It’s a handy report, but we can’t turn it into a view. The error message shown displays when you... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - All about SQL Constraints - Day 22 of 35](https://blog.sqlauthority.com/2011/08/22/sql-server-tips-from-the-sql-joes-2-pros-development-series-all-about-sql-constraints-day-22-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. Check Constraints My old track coach would tell us to give 110% effort. However, had my math teacher heard this, he would have explained that a percentage value exceeding 100% in this context is not possible. For the coach it was a fun way that implies that you will give all you have, but then somehow you will give 10% more than... - [SQL SERVER - SQL Query Techniques For Microsoft SQL Server 2008 - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/08/22/sql-server-sql-query-techniques-for-microsoft-sql-server-2008-book-available-for-sql-server-certification/): We recently give away 7 physical books of Joes 2 Pros Book Volume 2. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. All objects... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - All about SQL Statistics - Day 21 of 35](https://blog.sqlauthority.com/2011/08/21/sql-server-tips-from-the-sql-joes-2-pros-development-series-all-about-sql-statistics-day-21-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. Real Life Statistics We are not surprised to see warm ski jackets appearing on display shelves starting in September. It’s not yet cold, but we know that winter time is a few months away based on our own recollection of the weather, which we’ve observed in previous seasons and prior years.  Our own memory of temperature and weather patterns is a knowledge... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Introduction to Page Split - Day 20 of 35](https://blog.sqlauthority.com/2011/08/20/sql-server-tips-from-the-sql-joes-2-pros-development-series-introduction-to-page-split-day-20-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. From yesterdays post we learned that the clustered index is the placement order of a table’s records in memory pages. When you insert new records, then each record will be inserted into the memory page in the order it belongs. Rick Morelan’s SSN (555-55-5555) belongs with the 5’s, so his record will be physically inserted in memory between Jonny Dirt and Sally... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - The Clustered Index - Simple Understanding - Day 19 of 35](https://blog.sqlauthority.com/2011/08/19/sql-server-tips-from-the-sql-joes-2-pros-development-series-the-clustered-index-simple-understanding-day-19-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. Since the physical storage of data impacts the speed and efficiency of our queries, in tomorrow’s post we will explore how clustered indexes can impact the physical location of data and the way SQL Server retrieves query data. For today we will need to know the basics of the Clustered Index. The Clustered Index What is clustering or a clustered index? Let’s... - [SQL SERVER - Geography Data Type - Calculating Distance Between Two Points on the Earth - Day 18 of 35](https://blog.sqlauthority.com/2011/08/18/sql-server-tips-from-the-sql-joes-2-pros-development-series-geography-data-type-calculating-distance-between-two-points-on-the-earth-day-18-of-35/): In this blog post we will learn about Geography Data Type. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Sparse Data and Space Used by Sparse Data - Day 17 of 35](https://blog.sqlauthority.com/2011/08/17/sql-server-tips-from-the-sql-joes-2-pros-development-series-sparse-data-and-space-used-by-sparse-data-day-17-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. Sparse Data Fields with fixed length data types (e.g., int, money) always consume their allotted space irrespective of how much data the field actually contains. This is true even if the field is populated with a null. Occasionally you will encounter a column in your database which is rarely used. For example, suppose you have a field called [Violation] in a table... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - System and Time Data Types - Day 16 of 35](https://blog.sqlauthority.com/2011/08/16/sql-server-tips-from-the-sql-joes-2-pros-development-series-system-and-time-data-types-day-16-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. System and Time Data Types Keeping track of date and time data points has always been a critical part of online transactional databases. For example, each sales invoice record needs a date-time stamp, as do systems which track quotes and customer contacts regarding sales opportunities. Think of how many times during your workday that you rely on a date-time stamp as helpful... - [SQLAuthority News - Pluralsight Giving Away Free Subscription to Quiz Participants](https://blog.sqlauthority.com/2011/08/16/sqlauthority-news-pluralsight-giving-away-free-subscription-to-quiz-participants/): I am sure readers of this site are familiar with Pluralsight.  It is an online training site that describes itself as “a company created by developers, specifically for developers.”  At their site you can find training courses on a variety of topics and weekly webcasts by industry specialists. Right now the latest news on the blog is that businesses can subscribe to Pluralsight to help train their employees: Pluralsight subscriptions for businesses.  The blog has also introduced course assessments so that users can track their progress – and employers can see how well their employees are doing. Pluralsight is also going... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Data Row Space Usage and NULL Storage - Day 15 of 35](https://blog.sqlauthority.com/2011/08/15/sql-server-tips-from-the-sql-joes-2-pros-development-series-data-row-space-usage-and-null-storage-day-15-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. Data Row Space Usage Most of a table’s space is occupied by its records. Indexes and other properties use a relatively small amount of known space for the table.  Suppose your company – or a hiring manager – shows you the design of the SalesInvoiceDetail table and says, “We expect this table to receive an average of 100,000 records per day during... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Output Clause in Simple Examples - Day 14 of 35](https://blog.sqlauthority.com/2011/08/14/sql-server-tips-from-the-sql-joes-2-pros-development-series-output-clause-in-simple-examples-day-14-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Output We will first begin our work with the OUTPUT clause, by diving into hands-on examples of deleting, inserting, and updating table data. Later, we will demonstrate logging these types of changes in a separate storage table. Note: The OUTPUT statement uses temporary INSERTED and/or DELETED tables. These memory-resident tables are used to determine the changes being caused by the INSERT, DELETE or UPDATE statements.... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Ranking Functions - Advanced NTILE in Detail - Day 13 of 35](https://blog.sqlauthority.com/2011/08/13/sql-server-tips-from-the-sql-joes-2-pros-development-series-ranking-functions-advanced-ntile-in-detail-day-13-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Ranking Functions Part 2 (NTILE) A friend of mine recently told me she’s very proud of her son, because he is consistently in the upper quarter of every class he takes. Right there she performed a calculation similar to the NTILE function. She didn’t know it, but she tiled the class into four pieces and then identified which piece her son belongs in.... - [SQL SERVER - Ranking Functions - RANK( ), DENSE_RANK( ), and ROW_NUMBER( ) - Day 12 of 35](https://blog.sqlauthority.com/2011/08/12/sql-server-tips-from-the-sql-joes-2-pros-development-series-ranking-functions-rank-dense_rank-and-row_number-day-12-of-35/): In this blog post we will discuss about Ranking Functions like RANK( ), DENSE_RANK( ), and ROW_NUMBER( ). Ranking Functions (Part 1) There are four ranking functions in SQL server. Today we will look at RANK( ), DENSE_RANK( ), and ROW_NUMBER( ).These functions all have the same basic behavior. Where they differ is in the handling of tie values. These three functions produce identical results, until a tying value in your data is present. - [SQL SERVER - SafePeak - The Plug and Play Immediate Acceleration Solution](https://blog.sqlauthority.com/2011/08/11/sql-server-safepeak-the-plug-and-play-immediate-acceleration-solution/): Let us learn about SafePeak - The Plug and Play Immediate Acceleration Solution. Introduction - Plug and Play Given how important performance is these days among SQL Server critical applications, I was excited to look into a new product by SafePeak Technologies that aims to immediately resolve, in a plug-and-play way, the performance, scalability and peaks challenges of SQL Server applications on the Cloud, hosting servers and enterprise data centers. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Advanced Aggregates with the Over Clause - Day 11 of 35](https://blog.sqlauthority.com/2011/08/11/sql-server-tips-from-the-sql-joes-2-pros-development-series-advanced-aggregates-with-the-over-clause-day-11-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Partitioning with the Over Clause (Part 2) Yesterday we learned how the over clause can be used to compare your number against the overall aggregated number for an entire result set. Sometimes you might want your number to be compared against its category and not all records from a table. For example I don’t get any joy in saying I never won... - [SQL SERVER - Who needs ETL Version Control?](https://blog.sqlauthority.com/2011/08/10/sql-server-who-needs-etl-version-control/): While making some changes (read: mistakes) to my ETL business logic the other day, it occurred to me much too late that those unfortunate changes had replaced the once properly working logic with now very flawed logic.  The good news was that I remembered what the working logic was supposed to be.  The bad news, I had to re-create it.  Had I had the working logic already checked-in under version control, I could have saved myself the two hours of wasted time and effort.  In an ETL team development setting, these types of issues could easily multiply and significantly impede developer... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Aggregates with the Over Clause - Day 10 of 35](https://blog.sqlauthority.com/2011/08/10/sql-server-tips-from-the-sql-joes-2-pros-development-series-aggregates-with-the-over-clause-day-10-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Aggregates with the Over Clause You have likely heard the business term “Market Share”. If your company is the biggest and has sold 15 million units in an industry that has sold a total of 50 million units then your company’s market share is 30% (15/50 = .30). Market share represents your number divide by the sum of all other numbers. In... - [SQL SERVER - Use INSERT INTO ... SELECT instead of Cursor](https://blog.sqlauthority.com/2011/08/10/sql-server-use-insert-into-select-instead-of-cursor/): This blog post is written in response to the post showing some of the worst practices of past. Well, just like last month’s theme, everybody learns by doing it one step at a time. In my case, I started my career as a network engineer and had no database knowledge during that time. I can still remember my old code which became quite a laughingstock when it was sent for a code review. This story is indeed interesting, so instead of writing shortly, I am going to write today in detail. It happened about 8 years ago when I was working... - [SQL SERVER - The SQL Hands-On Guide for Beginners - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/08/09/sql-server-the-sql-hands-on-guide-for-beginners-book-available-for-sql-server-certification/): We recently give away 7 physical books of Joes 2 Pros eBook Volume 1. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. United States:... - [SQL SERVER - Tips from the Development Series - Overriding Identity Fields - Day 9 of 35](https://blog.sqlauthority.com/2011/08/09/sql-server-tips-from-the-sql-joes-2-pros-development-series-overriding-identity-fields-tricks-and-tips-of-identity-fields-day-9-of-35/): In this blog post we are going to discuss about Overriding Identity Fields. For students new to the database world, it helps to begin thinking about ID fields in the context of larger organizations with lots of activity. A customer service department has a constant flow of activity and many representatives are entering data in the system simultaneously. The same is true for large billing departments. These are examples where an identity field helps to ensure the entities you care about get tracked properly. A CustomerID value that is automatically generated with each new record makes sure each new customer gets a unique number – even if you have many reps all entering data at the same time. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Many to Many Relationships - Day 8 of 35](https://blog.sqlauthority.com/2011/08/08/sql-server-tips-from-the-sql-joes-2-pros-development-series-many-to-many-relationships-day-8-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Many to Many relationships If anyone has done some shopping on the internet you are familiar with the term “Shopping Cart” or “Shopping basket”. After you have selected a product you want to buy the storefront will gladly let you keep on shopping until there are many items in you shopping cart. On my last trip to Amazon.com I put 3 things... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Dirty Records and Table Hints - Day 7 of 35](https://blog.sqlauthority.com/2011/08/07/sql-server-tips-from-the-sql-joes-2-pros-development-series-dirty-records-and-table-hints-day-7-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Dirty Records Recap Most SQL people know what a “Dirty Record” is. You might also call that an “Intermediate record”. In case this is new to you here is a very quick explanation. The simplest way to describe the steps of a transaction is to use an example of updating an existing record into a table. When the insert runs, SQL Server gets... - [SQL SERVER - Row Constructors - Day 6 of 35](https://blog.sqlauthority.com/2011/08/06/sql-server-tips-from-the-sql-joes-2-pros-development-series-row-constructors-day-6-of-35/): In this blog post we will learn about Row Constructors. Row Constructors Most records we insert will come from a connection made to SQL from some external process. For example a web page ADO.NET connection to you company data layer or some data feed from an SSIS package. Still most seed data or special inserts may come from the INSERT INTO DML statement. Before SQL 2008 if you had to insert 20 records you needed 20 separate INSERT INTO statements. Now you can do all 20 inserts in one transaction. Let’s start off our example by creating a very simple table with the following code. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Finding un-matching Records - Day 5 of 35](https://blog.sqlauthority.com/2011/08/05/sql-server-tips-from-the-sql-joes-2-pros-development-series-finding-un-matching-records-day-5-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Finding un-matching Records Often time we want to find records in one table that have no matching key in another table. This is common for things like finding products that have never sold, or students who did not re-enroll. Something we were expecting is missing. Records in one table were expecting some related activity in another table and did not find them.... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Efficient Query Writing Strategy - Day 4 of 35](https://blog.sqlauthority.com/2011/08/04/sql-server-tips-from-the-sql-joes-2-pros-development-series-efficient-query-writing-strategy-day-4-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Query Writing Strategy Some people may push back on this next technique or misunderstand until getting to the very end. The goal is to have fewer errors as you write complex queries more quickly by making sure the easy stuff works first. If you are a SQL expert who only works on the same database for the rest of your life who... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Finding Apostrophes in String and Text - Day 3 of 35](https://blog.sqlauthority.com/2011/08/03/sql-server-tips-from-the-sql-joes-2-pros-development-series-finding-apostrophes-in-string-and-text-day-3-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Finding Apostrophes in string and text - [SQL SERVER - Tips from the SQL Development Series - Wildcard - Querying Special Characters - Day 2 of 35](https://blog.sqlauthority.com/2011/08/02/sql-server-tips-from-the-sql-joes-2-pros-development-series-wildcard-querying-special-characters-day-2-of-35/): In this blog post we will learn various tips related to Querying Special Characters with the help of wildcard in SQL Server. Some special characters can be tricky to pattern match since they themselves can represent different values at different times. Let look at some examples. Here is a quick look at all the records in the [Grant] table of the JProCo database. Note: Since [Grant] is also a keyword it must be enclosed in square brackets or double quotes to designate it as the [Grant] table and now the keyword. Take a look at many of the names in the GrantName field and notice we have many names with special symbols in them. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Wildcard Basics Recap - Day 1 of 35](https://blog.sqlauthority.com/2011/08/01/sql-server-tips-from-the-sql-joes-2-pros-development-series-wildcard-basics-recap-day-1-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Wildcard ranges If you have ever been to a convention where they have a morning registration desk that must handle thousands of people in a short time you know they must put some pre-planning thought into how to handle this burst of volume. In fact often they will have many registration desks running in parallel to make things run faster. The first... - [SQL SERVER - Win a Book a Day - Contest Rules - Day 0 of 35](https://blog.sqlauthority.com/2011/08/01/sql-server-win-a-book-a-day-contest-rules-day-0-of-35/): Learning is an extremely important part of life. From the first step, everybody progresses in life and learns something new. Earlier this year, SQLAuthority.com had a month-long series on SQL Server Interview Questions. It was extremely popular series, and I received a lot of encouraging comments. While I compiled the received feedback, one important feedback was the need of good basic learning.  The reason for writing this series is to present a proper learning structure rather than a simple blog post. And here is your chance to win some exciting gifts – For the next 35 days, every day at SQLAuthority.com,... - [SQL SERVER - The Difficult Interview Question - Moment of the Life - Day 31 of 31](https://blog.sqlauthority.com/2011/07/31/sql-server-the-difficult-interview-question-moment-of-the-life-day-31-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Complete List of all the Interview Questions and Answers Series blogs. We have spent the last 30 days going over questions and answers you may come up against when you are being interviewed.  Of course, I am only human and I can’t provide you with the answer to every question, or even the answer to every situation – because sometimes acing an interview is more than getting all the answers right. Sometimes acing an interview is more about impressing... - [SQL SERVER - Interview Questions and Answers - Guest Post by Jacob Sebastian - Day 30 of 31](https://blog.sqlauthority.com/2011/07/30/sql-server-interview-questions-and-answers-guest-post-by-jacob-sebastian-day-30-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Jacob Sebastian is a SQL Server MVP, Author, Speaker and my personal friend. Jacob is one of the top rated expert in SQL Community. Jacob wrote the book The Art of XSD – SQL Server XML Schema Collections and wrote the XML Chapter in SQL Server 2008 Bible. He has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. I encourage all the readers to participate in T-SQL Challenges. I am very much... - [SQL SERVER - Interview Questions and Answers - Guest Post by Feodor Georgiev - Day 29 of 31](https://blog.sqlauthority.com/2011/07/29/sql-server-interview-questions-and-answers-guest-post-by-feodor-georgiev-day-29-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Feodor Georgiev is a SQL Server database specialist with extensive experience of thinking both within and outside the box. He has wide experience of different systems and solutions in the fields of architecture, scalability, performance, etc. Feodor has experience with SQL Server 2000 and later versions, and is certified in SQL Server 2008. He has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. About a month ago I wrote a post... - [SQL SERVER - Interview Questions and Answers - Guest Post by Nakul Vachhrajani - Day 28 of 31](https://blog.sqlauthority.com/2011/07/28/sql-server-interview-questions-and-answers-guest-post-by-nakul-vachhrajani-day-28-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Nakul Vachhrajani is a Technical Lead and systems development professional with iGATE Patni having a total IT experience of more than 6 years. He has comprehensive grasp on Database Administration, Development and Implementation with MS SQL Server and C, C++, Visual C++/C#. He has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. Interviews – A Definition The Merriam-Webster English dictionary defines an “Interview” in two ways. A formal consultation usually to... - [SQL SERVER - Latest expressor Data Integration Platform Posts](https://blog.sqlauthority.com/2011/07/28/sql-server-latest-expressor-data-integration-platform-posts/): I continue to frequently post new articles on expressor and would like to share with you my latest three posts: Introduction to expressor Datascript Modules 5 Tips for improving your data with expressor Studio expressor 3.2 Release Review I will soon be blogging about their upcoming 3.4 release to keep you informed about the latest developments around their product. If you haven’t tried yet, consider downloading and test-driving their Studio product – it’s absolutely free. Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interview Questions and Answers - Guest Post by Rick Morelan - Day 27 of 31](https://blog.sqlauthority.com/2011/07/27/sql-server-interview-questions-and-answers-guest-post-by-rick-morelan-day-27-of-31/): Rick Morelan is finest SQL Expert. He is very much known for his excellent book series Joes 2 Pros. His books are not only an inspiration to many who wants to learn SQL Server properly, but a MUST read for any SQL enthusiast. He has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. - [SQL SERVER - Interview Questions and Answers - Guest Post by Malathi Mahadevan - Day 26 of 31](https://blog.sqlauthority.com/2011/07/26/sql-server-interview-questions-and-answers-guest-post-by-malathi-mahadevan-day-26-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Malathi Mahadevan who is known SQL Server Expert has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. I encourage all the readers to read her excellent blog and follower her on twitter. One of the questions i was asked – and a regular at most interviews where i work is ‘What is the toughest challenge you have faced at your present job and how did you handle it’? Before looking at... - [SQL SERVER - Azure Interview Questions and Answers - Guest Post by Paras Doshi - Day 25 of 31](https://blog.sqlauthority.com/2011/07/25/sql-server-azure-interview-questions-and-answers-guest-post-by-paras-doshi-day-25-of-31/): Please read the Introductory Post before continue reading Azure interview question and answers. - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Data Warehouseing Concepts - Day 24 of 31](https://blog.sqlauthority.com/2011/07/24/sql-server-interview-questions-and-answers-frequently-asked-questions-data-warehouseing-concepts-day-24-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is Hybrid Slowly Changing Dimension? Hybrid SCDs are combination of both SCD 1 and SCD 2. It may happen that in a table, some columns are important and we need to track changes for them, i.e. capture the historical data for them, whereas in some columns even if the data changes, we do not care. What is BUS Schema? BUS Schema consists of a master suite of confirmed... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Data Warehouseing Concepts - Day 23 of 31](https://blog.sqlauthority.com/2011/07/23/sql-server-interview-questions-and-answers-frequently-asked-questions-data-warehouseing-concepts-day-23-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is ETL? ETL is abbreviation of extract, transform, and load. ETL is software that enables businesses to consolidate their disparate data while moving it from place to place, and it doesn’t really matter that that data is in different forms or formats. The data can come from any source. ETL is powerful enough to handle such data disparities. First, the extract function reads data from a specified source... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Data Warehouseing Concepts - Day 22 of 31](https://blog.sqlauthority.com/2011/07/22/sql-server-interview-questions-and-answers-frequently-asked-questions-data-warehouseing-concepts-day-22-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is OLTP? OLTP is abbreviation of On-Line Transaction Processing. This system is an application that modifies data At the very instant it is received and has a large number of concurrent users. What is OLAP? OLAP is abbreviation of Online Analytical Processing. This system is an application that collects, manages, processes and presents multidimensional data for analysis and management purposes. What is the Difference between OLTP and OLAP?... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Data Warehouseing Concepts - Day 21 of 31](https://blog.sqlauthority.com/2011/07/21/sql-server-interview-questions-and-answers-frequently-asked-questions-data-warehouseing-concepts-day-21-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs 4) Data Warehousing Concepts Interview Questions & Answers What is Data Warehousing? A data warehouse is the main repository of an organization’s historical data, its corporate memory. It contains the raw material for management’s decision support system. The critical factor leading to the use of a data warehouse is that a data analyst can perform complex queries and analysis, such as data mining, on the information without slowing down... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 20 of 31](https://blog.sqlauthority.com/2011/07/20/sql-server-interview-questions-and-answers-frequently-asked-questions-day-20-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What are Policy Management Terms? To have a better grip on the concept of Policy-based management, there are some key terms you need to understand. Target – A type of entity that is appropriately managed by Policy-based management. For example, a table, database and index, to name a few. Facet -A property that can be managed in policy-based management. A clear example of facet is the name of Trigger... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 19 of 31](https://blog.sqlauthority.com/2011/07/19/sql-server-interview-questions-and-answers-frequently-asked-questions-day-19-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs How can I Track the Changes or Identify the Latest Insert-Update-Delete from a Table? In SQL Server 2005 and earlier versions, there is no inbuilt functionality to know which row was recently changed and what the changes were. However, in SQL Server 2008, a new feature known as Change Data Capture (CDC) has been introduced to capture the changed data. (Read more here) What is the CPU Pressure? CPU... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 18 of 31](https://blog.sqlauthority.com/2011/07/18/sql-server-interview-questions-and-answers-frequently-asked-questions-day-18-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs How to Copy Data from One Table to Another Table? There are multiple ways to do this. 1) INSERT INTO SELECT This method is used when table is already created in the database earlier and data have to be inserted into this table from another table. If columns listed in the INSERT clause and SELECT clause are same, listing them is not required. 2) SELECT INTO This method is... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 17 of 31](https://blog.sqlauthority.com/2011/07/17/sql-server-interview-questions-and-answers-frequently-asked-questions-day-17-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs How will you Handle Error in SQL SERVER 2008? SQL Server now supports the use of TRY…CATCH constructs for providing rich error handling. TRY…CATCH lets us build error handling at the level we need, in the way we need to by setting a region where if any error occurs, it will break out of the region and head to an error handler. The basic structure is as follows: BEGIN... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 16 of 31 - CTE- Joins](https://blog.sqlauthority.com/2011/07/16/sql-server-interview-questions-and-answers-frequently-asked-questions-day-16-of-31/): Please read the Introductory Post before continuing reading interview questions and answers. In this blog post we will learn about few popular topics of SQL Server like CTE and joins.  - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 15 of 31](https://blog.sqlauthority.com/2011/07/15/sql-server-interview-questions-and-answers-frequently-asked-questions-day-15-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is Service Broker? Service Broker is a message-queuing technology in SQL Server that allows developers to integrate SQL Server fully into distributed applications. Service Broker is a feature which provides facility to SQL Server to send an asynchronous, transactional message. It allows a database to send a message to another database without waiting for the response; so the application will continue to function if the remote database is... - [Interview Questions and Answers - FAQ - Day 14 of 31](https://blog.sqlauthority.com/2011/07/14/sql-server-interview-questions-and-answers-frequently-asked-questions-day-14-of-31/): Please read the Introductory Post before continuing reading interview questions and answers. What are the basic functions? - [SQL SERVER - Query to Find Duplicate Indexes - Script to Find Redundant Indexes](https://blog.sqlauthority.com/2011/07/13/sql-server-query-to-find-duplicate-indexes-script-to-find-redundant-indexes/): I was recently delivering session on Performance Tuning subject. I was asking if there is any harm having duplicate indexes. Of course, duplicate indexes are nothing but overhead on the database system. Database system has to maintain two sets of indexes when it has to do update, delete, insert on the table which has duplicate indexes. There is also a possibility that indexes are overlapped. For example, Index1 have Col1, Col2, Col3 but Index2 have Col1,Col2,Col3,Col4,Col5. Here Index1 and Index2 are overlapping and there is no need of Index1, which should be removed. Following is the script which does the same... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 13 of 31](https://blog.sqlauthority.com/2011/07/13/sql-server-interview-questions-and-answers-frequently-asked-questions-day-13-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is Aggregate Functions? Aggregate functions perform a calculation on a set of values and return a single value. Aggregate functions ignore NULL values except COUNT function. HAVING clause is used, along with GROUP BY for filtering query using aggregate values. The following functions are aggregate functions. AVG, MIN, CHECKSUM_AGG, SUM, COUNT, STDEV, COUNT_BIG, STDEVP, GROUPING, VAR, MAX, VARP (Read more here ) What is Use of @@ SPID... - [SQL SERVER - Database Worst Practices](https://blog.sqlauthority.com/2011/07/12/sql-server-database-worst-practices-new-town-and-new-job-and-new-disasters/): Let us talk about SQL SERVER - Database Worst Practices. Instead of writing best practices, I am going to write about few of the bad ones. - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 12 of 31](https://blog.sqlauthority.com/2011/07/12/sql-server-interview-questions-and-answers-frequently-asked-questions-day-12-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs How does Using a Separate Hard Drive for Several Database Objects Improves Performance Right Away? A non-clustered index and tempdb can be created on a separate disk to improve performance. (Read more here) How to Find the List of Fixed Hard Drive and Free Space on Server? We can use the following Stored Procedure to figure out the number of fixed drives (hard drive) a system has along with free... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 11 of 31](https://blog.sqlauthority.com/2011/07/11/sql-server-interview-questions-and-answers-frequently-asked-questions-day-11-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is Difference between Table Aliases and Column Aliases? Do they Affect Performance? Usually, when the name of the table or column is very long or complicated to write, aliases are used to refer them. e.g. SELECT VeryLongColumnName col1 FROM VeryLongTableName tab1 In the above example, col1 and tab1 are the column alias and table alias, respectively. They do not affect the performance at all. What is the difference... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 10 of 31](https://blog.sqlauthority.com/2011/07/10/sql-server-interview-questions-and-answers-frequently-asked-questions-day-10-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What Command do we Use to Rename a db, a Table and a Column? To Rename db sp_renamedb ‘oldname’ , ‘newname If someone is using db it will not accept sp_renmaedb. In that case, first bring db to single user mode using sp_dboptions. Use sp_renamedb to rename the database. Use sp_dboptions to bring the database to multi-user mode. e.g. USE MASTER; GO EXEC sp_dboption AdventureWorks, 'Single User', True GO... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 9 of 31](https://blog.sqlauthority.com/2011/07/09/sql-server-interview-questions-and-answers-frequently-asked-questions-day-9-of-31/): Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is CHECK Constraint? A CHECK constraint is used to limit the values that can be placed in a column. The check constraints are used to enforce domain integrity. (Read more here) What is NOT NULL Constraint? A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to enforce domain integrity, as the check constraints. (Read more here) What is the difference between UNION and UNION ALL? UNION The UNION... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 8 of 31](https://blog.sqlauthority.com/2011/07/08/sql-server-interview-questions-and-answers-frequently-asked-questions-day-8-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs Which Command using Query Analyzer will give you the Version of SQL Server and Operating System? SELECT SERVERPROPERTY('Edition') AS Edition, SERVERPROPERTY('ProductLevel') AS ProductLevel, SERVERPROPERTY('ProductVersion') AS ProductVersion GO (Read more here) What is an SQL Server Agent? The SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose... - [SQL SERVER - Introduction to expressor Datascript Modules](https://blog.sqlauthority.com/2011/07/08/sql-server-introduction-to-expressor-datascript-modules/): With the release of expressor 3.3, expressor software has added a significant new feature to the expressor Studio tool – the ability to easily extend functionality through the incorporation of reusable script files.  A developer using expressor Studio may write these scripts and add them to any number of projects, or you can integrate scripts written by other developers.  Let’s see how this works. Suppose you want to execute a one-to-many application in which each incoming record needs to be parsed into multiple output records.  For example, a record containing monthly data over a year period needs to be reworked so... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 7 of 31](https://blog.sqlauthority.com/2011/07/07/sql-server-interview-questions-and-answers-frequently-asked-questions-day-7-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What are Different Types of Locks? Shared Locks: Used for operations that do not change or update data (read-only operations), such as a SELECT statement. Update Locks: Used on resources that can be updated. It prevents a common form of deadlock that occurs when multiple sessions are reading, locking, and potentially updating resources later. Exclusive Locks: Used for data-modification operations, such as INSERT, UPDATE, or DELETE. It ensures that... - [Interview Questions and Answers - Frequently Asked Questions - Day 6 of 31](https://blog.sqlauthority.com/2011/07/06/sql-server-interview-questions-and-answers-frequently-asked-questions-day-6-of-31/): Please read the Introductory Post before continuing reading interview questions and answers. Some more questions are included in the blog. - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 5 of 31](https://blog.sqlauthority.com/2011/07/05/sql-server-interview-questions-and-answers-frequently-asked-questions-day-5-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is an Identity? Identity (or AutoNumber) is a column that automatically generates numeric values. A start and increment value can be set, but most DBAs leave these at 1. A GUID column also generates unique keys. Updated based on the comment of Aaron Bertrand. (Blog) What is DataWarehousing? Subject-oriented, which means that the data in the database is organized so that all the data elements relating to the... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 4 of 31](https://blog.sqlauthority.com/2011/07/04/sql-server-interview-questions-and-answers-frequently-asked-questions-day-4-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is the Difference between a Function and a Stored Procedure? UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section, whereas Stored procedures cannot be. UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables. Inline UDF’s can be thought of as views that take parameters and can be used in JOINs and other Rowset operations.... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 3 of 31](https://blog.sqlauthority.com/2011/07/03/sql-server-interview-questions-and-answers-frequently-asked-questions-day-3-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is a Stored Procedure? A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 2 of 31](https://blog.sqlauthority.com/2011/07/02/sql-server-interview-questions-and-answers-frequently-asked-questions-day-2-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs 1) General Questions on SQL SERVER What is RDBMS? Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Introduction - Day 1 of 31](https://blog.sqlauthority.com/2011/07/01/sql-server-interview-questions-and-answers-frequently-asked-questions-introduction-day-1-of-31/): Click here to get free chapters (PDF) in the mailbox List of all the Interview Questions and Answers Series blogs Posts covering interview questions and answers always make for interesting reading.  Some people like the subject for their helpful hints and thought provoking subject, and others dislike these posts because they feel it is nothing more than cheating.  I’d like to discuss the pros and cons of a Question and Answer format here. Interview Questions and Answers are Helpful Just like blog posts, books, and articles, interview Question and Answer discussions are learning material.  The popular Dummy’s books or Idiots Guides... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Complete Downloadable List - Day 0 of 31](https://blog.sqlauthority.com/2011/07/01/sql-server-interview-questions-and-answers-frequently-asked-questions-complete-downloadable-list-day-0-of-31/): This blog post is running list of the blog posts in the series of Interview Questions and Answers. At the end of the 31st day of the month, a FREE PDF will be posted here which can be downloadable for offline review. SQL SERVER – Interview Questions and Answers – Frequently Asked Questions – Introduction – Day 1 of 31 In this very first blog post – various aspect of the interview questions and answers are discussed. Some people like the subject for their helpful hints and thought provoking subject, and others dislike these posts because they feel it is nothing more... - [SQL SERVER - Two Puzzles - Answer and Win USD 25 Gift Card](https://blog.sqlauthority.com/2011/06/30/sql-server-two-puzzles-answer-and-win-usd-25-gift-card/): Today I have two simple T-SQL Puzzle. You can answer them and win USD 25 Gift card. The gift card will be sent in email to winner. You will get choice of Gift Card brand based on your preference and country location. Puzzle 1: What will be the outcome and why? DECLARE @x REAL; SET @x = 9E-40 SELECT @x; The outcome here is obvious as I have used negative number in assignment. What is the reason behind the same? Puzzle 2: Why will be the outcome different from Puzzle 1: DECLARE @y REAL; SET @y = 9E+40 SELECT @y; The... - [SQL SERVER - Find Details for Statistics of Whole Database](https://blog.sqlauthority.com/2011/06/29/sql-server-find-details-for-statistics-of-whole-database-dmv-t-sql-script/): I was recently asked is there a single script which can provide all the necessary details about statistics for any database. - [SQLAuthority News - Monthly list of Puzzles and Solutions on SQLAuthority.com](https://blog.sqlauthority.com/2011/06/28/sqlauthority-news-monthly-list-of-puzzles-and-solutions-on-sqlauthority-com/): This month has been very interesting month for SQLAuthority.com we had multiple and various puzzles which everybody participated and lots of interesting conversation which we have shared. Let us start in latest puzzles and continue going down. There are few answers also posted on facebook as well. SQL SERVER – Puzzle Involving NULL – Resolve – Error – Operand data type void type is invalid for sum operator This puzzle involves NULL and throws an error. The challenge is to resolve the error. There are multiple ways to resolve this error. Readers has contributed various methods. Few of them even have supplied... - [SQL SERVER - Puzzle Involving NULL - Resolve - Error - Operand data type void type is invalid for sum operator](https://blog.sqlauthority.com/2011/06/27/sql-server-puzzle-involving-null-resolve-error-operand-data-type-void-type-is-invalid-for-sum-operator/): Today is Monday let us start this week with interesting puzzle. Yesterday I had also posted quick question here: SQL SERVER – T-SQL Scripts to Find Maximum between Two Numbers - [SQL SERVER - T-SQL Scripts to Find Maximum between Two Numbers](https://blog.sqlauthority.com/2011/06/26/sql-server-t-sql-scripts-to-find-maximum-between-two-numbers/): There are plenty of the things life one can make it simple. I really believe in the same. I was yesterday traveling for community related activity. On airport while returning I met a SQL Enthusiast. He asked me if there is any simple way to find maximum between two numbers in the SQL Server. I asked him back that what he really mean by Simple Way and requested him to demonstrate his code for finding maximum between two numbers. Here is his code: DECLARE @Value1 DECIMAL(5,2) = 9.22 DECLARE @Value2 DECIMAL(5,2) = 8.34 SELECT (0.5 * ((@Value1 + @Value2) + ABS(@Value1... - [SQLAuthority News - Download Whitepaper - SQL Server 2008 R2 Analysis Services Operations Guide](https://blog.sqlauthority.com/2011/06/25/sqlauthority-news-download-whitepaper-sql-server-2008-r2-analysis-services-operations-guide/): SQL Server Analysis Service (SSAS) has been always interesting subject for research. Analysis Services cubes are a very powerful tool in the hands of the business intelligence (BI) developer. They provide an easy way to expose even large data models directly to business users. Microsoft has published very informative white paper on Analysis Services Operations Guide. This white paper is authored by Thomas Kejser, John Sirmon, and Denny Lee. In this guide you will find information on how to test and run Microsoft SQL Server Analysis Services in SQL Server 2005, SQL Server 2008, and SQL Server 2008 R2 in a production... - [SQL SERVER - BI Quiz Hint - Performance Tuning Cubes - Hints](https://blog.sqlauthority.com/2011/06/24/sql-server-bi-quiz-hint-performance-tuning-cubes-hints/): I earlier wrote about SQL BI Quiz over here and here. - [SQLAuthority News - Ahmedabad Tech Ed On Road June 11, 2011 - A Grand Success of Community Tech Days](https://blog.sqlauthority.com/2011/06/23/sqlauthority-news-ahmedabad-tech-ed-on-road-june-11-2011-an-event-to-remember-a-grand-success-of-community-tech-days/): I am very excited to announce the huge success of the Microsoft Community Tech Days in Ahmedabad, on 11 June 2011. The turnout for this seminar was huge, and there was a great response from the audience. In fact, the AMA where the conference was held can seat 275 people – but there were over 50 people standing, the event coordinators had to find 150 more chairs, and we even had to turn away 30 people at the door because there was just no more room. This means that there were over 500 attendees! - [SQL SERVER - SSAS - Multidimensional Space Terms and Explanation](https://blog.sqlauthority.com/2011/06/22/sql-server-ssas-multidimensional-space-terms-and-explanation/): I was presenting on SQL Server session at one of the Tech Ed On Road event in India. I was asked very interesting question during ‘Stump the Speaker‘ session. I am sharing the same with all of you over here. Question: Can you tell me in simple words what is dimension, member and other terms of multidimensional space? There is no simple example for it. This is extreme fundamental question if you know Analysis Service. Those who have no exposure to the same and have not yet started on this subject, may find it a bit difficult. I really liked his... - [SQL SERVER - List of Article on Expressor Data Integration Platform](https://blog.sqlauthority.com/2011/06/22/sql-server-list-of-article-on-expressor-data-integration-platform/): The ability to transform data into meaningful and actionable information is the most important information in current business world. In this fast growing and changing business needs effective data integration is single most important thing in making proper decision making. I have been following expressor software since November 2010, when I met expressor team in Seattle. Here are my posts on their innovative data integration platform and expressor Studio, a free desktop ETL tool: 4 Tips for ETL Software IDE Developers Introduction to Adaptive ETL Tool – How adaptive is your ETL? Sharing your ETL Resources Across Applications with Ease expressor Studio Includes Powerful... - [SQL SERVER - Solution - Generating Zero Without using Any Numbers in T-SQL](https://blog.sqlauthority.com/2011/06/21/sql-server-solution-generating-zero-without-using-any-numbers-in-t-sql/): SQL Server MVP and my friend Madhivanan has asked very interesting question on his blog regarding How to Generate Zero without using Any Numbers in T-SQL. He has demonstrated various methods how one can generate Zero. When I posted note regarding how one he has generated Zero without using number in my blog post for Free Online Training, blog readers have come up with few very interesting answers. I really found them very interesting and here I am listing them with due credit. Special mention to Andery.ca as the answer Andery provided is the one, I myself come up with after... - [SQLAuthority News - Job Interviewing the Right Way (and for the Right Reasons) - Guest Post by Feodor Georgiev](https://blog.sqlauthority.com/2011/06/20/sqlauthority-news-job-interviewing-the-right-way-and-for-the-right-reasons-guest-post-by-feodor-georgiev/): Feodor Georgiev is a SQL Server database specialist with extensive experience of thinking both within and outside the box. He has wide experience of different systems and solutions in the fields of architecture, scalability, performance, etc. Feodor has experience with SQL Server 2000 and later versions, and is certified in SQL Server 2008. Feodor has written excellent article on Job Interviewing the Right Way. Here is his article in his own language. A while back I was thinking to start a blog post series on interviewing and employing IT personnel. At that time I had just read the ‘Smart and gets... - [SQL SERVER – Precision of SMALLDATETIME – A 1 Minute Precision](https://blog.sqlauthority.com/2010/06/01/sql-server-precision-of-smalldatetime-a-1-minute-precision/): I am myself surprised that I am writing this post today. I am going to present one of the very known facts of SQL Server SMALLDATETIME datatype. Even though this is a very well-known datatype, many a time, I have seen developers getting confused with precision of the SMALLDATETIME datatype. The precision of the datatype SMALLDATETIME is 1 minute. It discards the seconds by rounding up or rounding down any seconds greater than zero. Let us see the following example DECLARE @varSDate AS SMALLDATETIME SET @varSDate = '1900-01-01&nbsp;12:12:01' SELECT @varSDate C_SDT SET @varSDate = '1900-01-01&nbsp;12:12:29' SELECT @varSDate C_SDT SET @varSDate =... - [SQLAuthority News - Monthly Roundup of Best SQL Posts](https://blog.sqlauthority.com/2010/05/31/sqlauthority-news-monthly-roundup-of-best-sql-posts/): After receiving lots of requests from different readers for long time I have decided to write first monthly round up. If all of you like it I will continue writing the same every month. In fact, I really like the idea as I was able to go back and read all of my posts written in this month. This month was started with answering one of the most common question asked me to about What is Adventureworks? Many of you know the answer but to the surprise more number of the reader did not know the answer. There were few extra... - [SQLAuthority News - Guest Post - Performance Counters Gathering using Powershell](https://blog.sqlauthority.com/2010/05/30/sqlauthority-news-guest-post-performance-counters-gathering-using-powershell/): Laerte Junior has previously helped me personally to resolve the issue with Powershell installation on my computer. He did an awesome job to help. He has sent this another wonderful article regarding performance counter for readers of this blog. I really liked it and I expect all of you who are Powershell geeks, you will like the same as well. - [SQLAuthority News - SQL Funny Quotes](https://blog.sqlauthority.com/2010/05/29/sqlauthority-news-guest-post-fault-contract-in-wcf-with-learning-video/): Here are few SQL Funny Quotes. Q. What if your Dad loses his car keys? A. 'Parent keys not found!' - [SQL SERVER - Disabled Index and Update Statistics](https://blog.sqlauthority.com/2010/05/28/sql-server-disabled-index-and-update-statistics/): When we try to update the statistics, it throws an error as if the clustered index is disabled. Now let us enable the clustered index only and attempt to update the statistics of the table right after that. Let us learn about Disabled Index and Update Statistics. - [SQL SERVER - DATE and TIME in SQL Server 2008](https://blog.sqlauthority.com/2010/05/27/sql-server-date-and-time-in-sql-server-2008/): I was thinking about DATE and TIME datatypes in SQL Server 2008. I earlier wrote about the about best practices of the same. Recently I had written one of the scripts written for SQL Server 2008 had to run on SQL Server 2005 (don’t ask me why!), I had to convert the DATE and TIME datatypes to DATETIME. Let me run a quick demo for the same. - [SQLAuthority News - SQL Server Technology Evangelists and Evangelism](https://blog.sqlauthority.com/2010/05/26/sqlauthority-news-sql-server-technology-evangelists-and-evangelism/): This is the exact conversation that I had with three people during the recent SQL Server Public Training. Person 1: “Are you an SQL Server Evangelist?” Pinal : “No, but Vinod Kumar is.” Person 1: “Who are you?” Person 2: “He is Pinal, haha!” Person 1: “I know that, but don’t you evangelize SQL Server Technology?” Pinal : “Hmm… I do that…” Person 1: “In that case, why don’t you call yourself an Evangelist?” Pinal : “…! …” Person 2: “Good Question! Who are you Pinal?” Pinal : “I think you are asking my title, is that correct?” Person 1: “Maybe.”... - [SQLAuthority News - Win MS Office License - Last 2 days](https://blog.sqlauthority.com/2010/05/26/sqlauthority-news-win-ms-office-license-last-2-days/): Just a note for everybody who is from India and want to win FREE Office License, participate in very easy contest here. SQLAuthority News – Virtual Launch Event for Office 2010 – Contest – Win MS Office License Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Whitepaper - SQL Azure vs. SQL Server](https://blog.sqlauthority.com/2010/05/25/sqlauthority-news-whitepaper-sql-azure-vs-sql-server/): SQL Server and SQL Azure are two Microsoft Products which goes almost together. There are plenty of misconceptions about SQL Azure. I have seen enough developers not planning for SQL Azure because they are not sure what exactly they are getting into. Some are confused thinking Azure is not powerful enough. I disagree and strongly urge all of you to read following white paper written and published by Microsoft. SQL Azure vs. SQL Server by Dinakar Nethi, Niraj Nagrani SQL Azure Database is a cloud-based relational database service from Microsoft. SQL Azure provides relational database functionality as a utility service. Cloud-based... - [SQLAuthority News – Microsoft SQL Server 2008 R2 – PowerPivot for Microsoft Excel 2010](https://blog.sqlauthority.com/2010/05/24/sqlauthority-news-microsoft-sql-server-2008-r2-powerpivot-for-microsoft-excel-2010/): Microsoft has really and truly created some buzz for PowerPivot. I have been asked to show the demo of Powerpivot in recent time even when I am doing relational database training. Attached is the few details where everyone can download PowerPivot and use the same. Microsoft SQL Server 2008 R2 – PowerPivot for Microsoft Excel 2010 – RTM Microsoft® PowerPivot for Microsoft® Excel 2010 provides ground-breaking technology, such as fast manipulation of large data sets (often millions of rows), streamlined integration of data, and the ability to effortlessly share your analysis through Microsoft® SharePoint 2010. Microsoft PowerPivot for Excel 2010 Samples... - [SQL SERVER – Check the Isolation Level with DBCC useroptions](https://blog.sqlauthority.com/2010/05/24/sql-server-check-the-isolation-level-with-dbcc-useroptions/): In recent consultancy project coordinator asked me – “can you tell me what is the isolation level for this database?” I have worked with different isolation levels but have not ever queried database for the same. I quickly looked up bookonline and found out the DBCC command which can give me the same details. You can run the DBCC UserOptions command on any database to get few details about dateformat, datefirst as well isolation level. DBCC useroptions Set Option                  Value --------------------------- -------------- textsize                    2147483647 language                    us_english dateformat                  mdy datefirst                   7 lock_timeout                -1 quoted_identifier           SET arithabort                  SET ansi_null_dflt_on           SET ansi_warnings               SET ansi_padding               ... - [SQLAuthority News - Virtual Launch Event for Office 2010 - Contest - Win MS Office License](https://blog.sqlauthority.com/2010/05/23/sqlauthority-news-virtual-launch-event-for-office-2010-contest-win-ms-office-license/): Office products are integral products of any PC. I accept that without Office Suites, I can not survive or make enough leaving. I am blogger and use word to create my blogs. I am SQL Server Trainer  and I use PowerPoint as my presentation tool. I am SQL Server consultant and I use Excel to keep my work log. I can not see my life with Office Tools. Just like any other Microsoft Product there is strong community following Office Tools. Please count me in. The same community is hosting a Virtual Launch Event for Office 2010 on May 25 and... - [SQLAuthority News - Downloads Available for Microsoft SQL Server Compact 3.5](https://blog.sqlauthority.com/2010/05/22/sqlauthority-news-downloads-available-for-microsoft-sql-server-compact-3-5/): There are few downloads released for Microsoft SQL Server Compact 3.5. Here is quick lists of the same. Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Desktop SQL Server Compact 3.5 SP2 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP2 and Synchronization Services for ADO.NET version 1.0 SP1 on Windows desktop. Microsoft SQL Server Compact 3.5 Service Pack 2 Server Tools SQL Server Compact 3.5 SP2 Server Tools Windows Installer (MSI) file installs replication components on the computer... - [SQL SERVER - Simple Example of Snapshot Isolation - Reduce the Blocking Transactions](https://blog.sqlauthority.com/2010/05/21/sql-server-simple-example-of-snapshot-isolation-reduce%c2%a0the%c2%a0blocking%c2%a0transactions/): To learn any technology and move to a more advanced level, it is very important to understand the fundamentals of the subject first. Today, we will be talking about something which has been quite introduced a long time ago but not properly explored when it comes to the isolation level. Snapshot Isolation was introduced in SQL Server in 2005. However, the reality is that there are still many software shops which are using the SQL Server 2000, and therefore cannot be able to maintain the Snapshot Isolation. Many software shops have upgraded to the later version of the SQL Server, but... - [SQLAuthority News – Professional Development and Community](https://blog.sqlauthority.com/2010/05/20/sqlauthority-news-professional-development-and-community/): I was recently invited by Hyderabad Techies to deliver a keynote for their 16-day online session called TECH THUNDERS. This event has been running from May 15 and will continue up to the end of the month May 30). There would be a total of 30 sessions. In every evening of those 16 day, there will be either one or two sessions from several noted industry experts. It is the same group which has received the Microsoft Community Impact Award as the Best User Group in India as for developers. This was my opportunity to talk about Professional Development. - [SQLAuthority News – Updated Favorite Scripts and Best Articles Page](https://blog.sqlauthority.com/2010/05/19/sqlauthority-news-updated-favorite-scripts-and-best-articles-page/): I have been writing on this blog for around 4 years now and have contributed with more than 1300 blog posts. Many times, I have been asked regarding what is my most favorite article or which is the most essential script for developers and DBA. This is very difficult to answer as I so much effort has been put on my blog and a large amount of content has been generated. However, I do keep a running list of my most favorite scripts and articles. This same are listed on the side bar of this blog as well; I am including... - [SQLAuthority Book Review - DBA Survivor: Become a Rock Star DBA](https://blog.sqlauthority.com/2010/05/18/sqlauthority-book-review-dba-survivor-become-a-rock-star-dba/): DBA Survivor: Become a Rock Star DBA – Thomas LaRock Link to Amazon Link to Flipkart First of all, I thank all my readers when I wrote that I could not get this book in any local book stores, because they offered me to send a copy of this good book. A very special mention goes to Sripada and Jayesh for they gave so much effort in finding my home address and sending me the hard copy. Before, I did not have the copy of the book, but now I have two of it already! It surprises me how my readers... - [SQLAuthority News - Bookmark - Deprecated Database Engine Features in SQL Server 2008](https://blog.sqlauthority.com/2010/05/17/sqlauthority-news-bookmark-deprecated-database-engine-features-in-sql-server-2008/): When anyone asked me if any specific feature is available in SQL Server 2008 or if any feature will be disabled in future versions of SQL Server, I always pointed to the following list where all the deprecated database engine features are listed. - [SQLAuthority News - Storage and SQL Server Capacity Planning and configuration - SharePoint Server 2010](https://blog.sqlauthority.com/2010/05/16/sqlauthority-news-storage-and-sql-server-capacity-planning-and-configuration-sharepoint-server-2010/): Just a day ago, I was asked how do you plan SQL Server Storage Capacity. Here is the excellent article published by Microsoft regarding SQL Server capacity planning for SharePoint 2010. This article touches all the vital areas of this subject. Here are the bullet points for the same. Gather storage and SQL Server space and I/O requirements Choose SQL Server version and edition Design storage architecture based on capacity and IO requirements Determine memory requirements Understand network topology requirements Configure SQL Server Validate storage performance and reliability Read the original article published by Microsoft here: Storage and SQL Server Capacity... - [SQL SERVER - List All the DMV and DMF on Server](https://blog.sqlauthority.com/2010/05/15/sql-server-list-all-the-dmv-and-dmf-on-server/): "How many DMV and DVF are there in SQL Server 2008?" - this question was asked to me in one of the recent SQL Server Training. - [SQL SERVER - Find Most Expensive Queries Using DMV](https://blog.sqlauthority.com/2010/05/14/sql-server-find-most-expensive-queries-using-dmv/): The title of this post is what I can express here for this quick blog post. I was asked in recent query tuning consultation project, if I can share my script which I use to figure out which is the most expensive queries are running on SQL Server. This script is very basic and very simple, there are many different versions are available online. This basic script does do the job which I expect to do - find out the most expensive queries in SQL Server Box. - [SQL SERVER - Four Posts on Removing the Bookmark Lookup - Key Lookup](https://blog.sqlauthority.com/2010/05/13/sql-server-four-posts-on-removing-the-bookmark-lookup-key-lookup/): Recently, I have observed that not many people have proper understanding of what is bookmark lookup or key lookup. Increasing numbers of the questions tells me that this is something that developers encounter every single day, but have no idea how to deal with. I have previously written three posts on this subject. All those who are looking for further information can check out the following three posts. SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key... - [SQL SERVER - Understanding ALTER INDEX ALL REBUILD with Disabled Clustered Index](https://blog.sqlauthority.com/2010/05/12/sql-server-understanding-alter-index-all-rebuild-with-disabled-clustered-index/): This blog is in response to the ongoing communication with the reader who had earlier asked the question of SQL SERVER – Disable Clustered Index and Data Insert. The same reader has asked me the difference between ALTER INDEX ALL REBUILD and ALTER INDEX REBUILD along with disabled clustered index. Instead of writing a big theory, we will go over the demo right away. Here are the steps that we intend to follow. 1) Create Clustered and Nonclustered Index 2) Disable Clustered and Nonclustered Index 3) Enable – a) All Indexes, b) Clustered Index USE tempdb GO -- Drop Table if Exists IF EXISTS (SELECT *... - [SQL SERVER - Spatial Database Queries - What About BLOB](https://blog.sqlauthority.com/2010/05/11/sql-server-spatial-database-queries-what-about-blob-t-sql-tuesday-006/): Michael Coles is one of the most interesting book authors I have ever met. He has a flair of writing complex stuff in a simple language. There are a very few people like that. I really enjoyed reading his recent book, Expert SQL Server 2008 Encryption. I strongly suggest taking a look at it. Let us learn about Spatial Database Queries. - [SQL SERVER - Size of Index Table for Each Index - Solution 3 - Powershell Index Size](https://blog.sqlauthority.com/2010/05/10/sql-server-size-of-index-table-for-each-index-solution-3-powershell/): If you are a Powershell user, the name of the Laerte Junior is not a new name. He is the one man with exceptional knowledge of Powershell. He is not only very knowledgeable, but also very kind and eager to those in need. I have been attempting to setup Powershell for many days, but constantly facing issues. I was not able to get going with this tool. Finally, yesterday I sent email to Laerte in response to his comment posted here. Within 5 minutes, Laerte came online and helped me with the solution. He spend nearly 15 minutes working along with me to solve my problem with installation. And yes, he did resolve it remotely without looking at my screen – What a skilled and exceptional person!! I will soon post a detail note about the issue I faced and resolved with the help of Laerte. Let us see how we can find Powershell Index Size. - [SQL SERVER - Size of Index Table for Each Index - Solution 2](https://blog.sqlauthority.com/2010/05/09/sql-server-size-of-index-table-for-each-index-solution-2/): Earlier I had ran puzzle where I asked question regarding size of index table for each index in database over here SQL SERVER – Size of Index Table – A Puzzle to Find Index Size for Each Index on Table. I had received good amount answers and I had blogged about that here SQL SERVER – Size of Index Table for Each Index – Solution. As a comment to that blog I have received another very interesting comment and that provides near accurate answers to original question. Many thanks to Rama Mathanmohan for providing wonderful solution. SELECT OBJECT_NAME(i.OBJECT_ID) AS TableName, i.name... - [SQLAuthority News - MSDN Flash Mentions - TechNet Flash Mention - Top Community Contributors (Annual) Winner](https://blog.sqlauthority.com/2010/05/08/sqlauthority-news-msdn-flash-mentions-technet-flash-mention-top-community-contributors-annual-winner/): I was going over my email to reach the famous Inbox (0), and I happened to come across TechNet Flash and MSDN Flash emails. I had kept them because those email editions had my names mentioned in them. Immediately, I took the screenshot of these. I am posting them here for later reference. It is always good idea to store important information for revisiting the memory lane. As a recent update, Microsoft has awarded me Top Community Contributors (Annual) Winners. I am thankful to you all as I would have not done this without your valuable contribution. I want to dedicate... - [SQLAuthority News - List of Master Data Services White Paper](https://blog.sqlauthority.com/2010/05/07/sqlauthority-news-list-of-master-data-services-white-paper/): Since my TechEd India 2010 presentation I am very excited with SQL Server 2010 Master Data Services. I just come across very interesting white paper on Microsoft site related to this subject. Here is the list of the same and location where you can download them. They are all written by Top Experts at Microsoft. - [SQLAuthority News - SQL Server 2008 R2 Hosted Trial](https://blog.sqlauthority.com/2010/05/06/sqlauthority-news-sql-server-2008-r2-hosted-trial/): This is a bit old news but for me but it will new for many of you know. SQLPASS, Dell, Microsoft and MaximumASP has come together and build hosted environment for free to all of us to use and experiment with. Register now to try out up to seven labs: SQL Server 2008 R2 – Multi Server Management SQL Server 2008 R2 – PowerPivot SQL Server 2008 R2 – Reporting Services SQL Server 2008 R2 – Master Data Services SQL Server 2008 R2 – StreamInsight SQL Server Integration Services – Introduction SQL Server Integration Services – Intermediate to Advanced Now this... - [SQLAuthority News - Wireless Router Security and Attached Devices - Complex Password](https://blog.sqlauthority.com/2010/05/06/sqlauthority-news-wireless-router-security-and-attached-devices-complex-password/): In the last week, I have received calls from friends who told me that they have got strange emails from me. To my surprise, I did not send them any emails. I was not worried until my wife complained that she was not able to find one of the very important folders containing our daughter’s photo that is located in our shared drive. This was alarming in my par, so I started a search around my computer’s folders. Again, please note that I am by no means a security expert. I checked my entire computer with virus and spyware, and strangely,... - [SQL SERVER - Get Latest SQL Query for Sessions - DMV](https://blog.sqlauthority.com/2010/05/05/sql-server-get-latest-sql-query-for-sessions-dmv/): In recent SQL Training I was asked, how can one figure out what was the last SQL Statement executed in sessions. The query for this is very simple. It uses two DMVs and created following quick script for the same. SELECT session_id, TEXT FROM sys.dm_exec_connections CROSS APPLY sys.dm_exec_sql_text(most_recent_sql_handle) AS ST While working with DMVs if you ever find any DMV has column with name sql_handle you can right away join that DMV with another DMV sys.dm_exec_sql_text and can get the text of the SQL statement. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Microsoft SQL Server 2005/2008 Query Optimization and Performance Tuning Training](https://blog.sqlauthority.com/2010/05/04/sqlauthority-news-microsoft-sql-server-20052008-query-optimization-performance-tuning-training/): Last 3 days to register for the courses. This is one time offer with big discount. The deadline for the course registration is 5th May, 2010. There are two different courses are offered by Solid Quality Mentors 1) Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning – Pinal Dave Date: May 12-14, 2010 Price: Rs. 14,000/person for 3 days Discount Code: ‘SQLAuthority.com’ Effective Price: Rs. 11,000/person for 3 days 2) SharePoint 2010 – Joy Rathnayake Date: May 10-11, 2010 Price: Rs. 11,000/person for 3 days Discount Code: ‘SQLAuthority.com’ Effective Price: Rs. 8,000/person for 2 days Download the complete PDF brochure.... - [SQL SERVER - SHRINKFILE and TRUNCATE Log File in SQL Server 2008](https://blog.sqlauthority.com/2010/05/03/sql-server-shrinkfile-and-truncate-log-file-in-sql-server-2008/): Note: Please read the complete post before taking any actions. This blog post would discuss SHRINKFILE and TRUNCATE Log File. The script mentioned in the email received from reader contains the following questionable code: “Hi Pinal, If you could remember, I and my manager met you at TechEd in Bangalore. We just upgraded to SQL Server 2008. One of our jobs failed as it was using the following code. The error was: Msg 155, Level 15, State 1, Line 1 ‘TRUNCATE_ONLY’ is not a recognized BACKUP option. The code was: DBCC SHRINKFILE(TestDBLog, 1) BACKUP LOG TestDB WITH TRUNCATE_ONLY DBCC SHRINKFILE(TestDBLog, 1)... - [SQL SERVER - The Difference between Dual Core vs. Core 2 Duo](https://blog.sqlauthority.com/2010/05/02/sql-server-the-difference-between-dual-core-vs-core-2-duo/): I have decided that I would not write on this subject until I have received a total of 25 questions on this subject about dual core.  - [SQL SERVER - What is AdventureWorks?](https://blog.sqlauthority.com/2010/05/01/sql-server-what-is-adventureworks/): A few days ago, I received DM asking What is an AdventureWorks database and why in all the examples I use that instead of any other database (e.g. Pubs or  Northwind)? As matter of fact, when I went back to my question list, which I have yet not answered, there were a few more variations of this same question. - [SQLAuthority News - TechEd India - April 12-14, 2010 Bangalore - An Unforgettable Experience](https://blog.sqlauthority.com/2010/04/30/sqlauthority-news-teched-india-april-12-14-2010-bangalore-an-unforgettable-experience-an-opportunity-of-a-lifetime/): TechEd India was one of the largest Technology events in India led by Microsoft. This event was attended by more than 3,000 technology enthusiasts, making it one of the most well-organized events of the year. Though I attempted to attend almost all the technology events here, I have not seen any bigger or better event in Indian subcontinents other than this. There are 21 Technical Tracks at Tech·Ed India 2010 that span more than 745 learning opportunities. I was fortunate enough to be a part of this whole event as a speaker and a delegate, as well. - [SQL SERVER - Disable Clustered Index and Data Insert](https://blog.sqlauthority.com/2010/04/29/sql-server-disable-clustered-index-and-data-insert/): Earlier today, I received following email. “Dear Pinal, We looked at your script and found out that in your script of disabling indexes, you have only included selected non-clustered index during the bulk insert and missed to disabled all the clustered index. Our DBA [name removed] has changed your script a bit and included all the clustered indexes. Since then our application is not working. When DBA [name removed] tried to enable clustered indexes again he is facing error Incorrect syntax error. We are in deep problem [word replaced] [Removed Identity of organization and few unrelated stuff ]” I have replied... - [SQL SERVER - GUID vs INT - Your Opinion](https://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/): I think the title is clear what I am going to write in your post. This is age old problem and I want to compile the list stating advantages and disadvantages of using GUID and INT as a Primary Key or Clustered Index or Both (the usual case). Let me start a list by suggesting one advantage and one disadvantage in each case. INT Advantage: Numeric values (and specifically integers) are better for performance when used in joins, indexes and conditions. Numeric values are easier to understand for application users if they are displayed. Disadvantage: If your table is large, it... - [SQLAuthority News - Public Training Classes In Hyderabad 12-14 May - SQL and 10-11 May SharePoint](https://blog.sqlauthority.com/2010/04/27/sqlauthority-news-public-training-classes-in-hyderabad-12-14-may-microsoft-sql-server-20052008-query-optimization-performance-tuning-2/): There were lots of request about providing more details for the blog post through email address specified in the article SQLAuthority News – Public Training Classes In Hyderabad 12-14 May – Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning. Here is the complete brochure of the course. There are two different courses are offered by Solid Quality Mentors 1) Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning – Pinal Dave Date: May 12-14, 2010 Price: Rs. 14,000/person for 3 days Discount Code: ‘SQLAuthority.com‘ Effective Price: Rs. 11,000/person for 3 days 2) SharePoint 2010 – Joy Rathnayake Date: May 10-11,... - [SQLAuthority News - Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning Training](https://blog.sqlauthority.com/2010/04/26/sqlauthority-news-public-training-classes-in-hyderabad-12-14-may-microsoft-sql-server-20052008-query-optimization-performance-tuning/): After successfully delivering many corporate training as well as the private training we are launching the Public Training in Hyderabad for SQL Server 2008. I will be leading the training on Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning Training. - [SQL SERVER – Attach mdf file without ldf file in Database](https://blog.sqlauthority.com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/): Background Story: One of my friends recently called up and asked me if I had spare time to look at his database and give him a performance tuning advice. Because I had some free time to help him out, I said yes. I asked him to send me the details of his database structure and sample data. He said that since his database is in a very early stage and is small as of the moment, so he told me that he would like me to have a complete database. My response to him was “Sure! In that case, take a... - [SQLAuthority News - Free Download - Microsoft SQL Server 2008 R2 RTM - Express with Management Tools - SQL Server 2008 R2 Books Online](https://blog.sqlauthority.com/2010/04/25/sqlauthority-news-free-download-microsoft-sql-server-2008-r2-rtm-express-with-management-tools/): This blog post is in response to several inquiry about Free Download of SQL Server 2008 R2 RTM. Microsoft has announced SQL Server 2008 R2 as RTM (Release To Manufacture). Microsoft® SQL Server® 2008 R2 Express is a powerful and reliable data management system that delivers a rich set of features, data protection, and performance for embedded applications, lightweight Web Sites and applications, and local data stores. Download Microsoft SQL Server 2008 R2 RTM – Express with Management Tools. Download Microsoft SQL Server 2008 R2 RTM – Management Studio Express. Download SQL Server 2008 R2 Books Online. Reference : Pinal Dave... - [SQL SERVER - T-SQL Script to Take Database Offline - Take Database Online](https://blog.sqlauthority.com/2010/04/24/sql-server-t-sql-script-to-take-database-offline-take-database-online/): Blog reader Joyesh Mitra recently left a comment to one of my very old posts about SQL SERVER – 2005 Take Off Line or Detach Database, which I have written focusing on taking the database offline. However, I did not include how to bring the offline database to online in that post. The reason I did not write it was that I was thinking it was a very simple script that almost everyone knows. However, it seems to me that there is something I found advanced and that is simple for other people sometime, in this case, I thought simple and... - [SQL SERVER - Update Statistics are Sampled By Default](https://blog.sqlauthority.com/2010/04/23/sql-server-update-statistics-are-sampled-by-default-2/): After reading my earlier post SQL SERVER – Create Primary Key with Specific Name when Creating Table on Statistics, I have received another question by a blog reader. The question is as follows: Question: Are the statistics sampled by default? Answer: Yes. The sampling rate can be specified by the user and it can be anywhere between a very low value to 100%. Let us do a small experiment to verify if the auto update on statistics is left on. Also, let’s examine a very large table that is created and statistics by default- whether the statistics are sampled or not.... - [SQL SERVER - Create Primary Key with Specific Name when Creating Table](https://blog.sqlauthority.com/2010/04/22/sql-server-create-primary-key-with-specific-name-when-creating-table/): It is interesting how sometimes the documentation of simple concepts is not available online. I had received email from one of the reader where he has asked how to create Primary key with a specific name when creating the table itself. He said, he knows the method where he can create the table and then apply the primary key with specific name. The attached code was as follows: CREATE TABLE [dbo].[TestTable]( [ID] [int] IDENTITY(1,1) NOT NULL, [FirstName] [varchar](100) NULL) GO ALTER TABLE [dbo].[TestTable] ADD  CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED ([ID] ASC) GO He wanted to know if we can create Primary Key as part of the table name as well, and... - [SQL SERVER - When Are Statistics Updated - What Triggers Statistics to Update](https://blog.sqlauthority.com/2010/04/21/sql-server-when-are-statistics-updated-what-triggers-statistics-to-update/): If you are an SQL Server Consultant/Trainer involved with Performance Tuning and Query Optimization, I am sure you have faced the following questions many times. When is statistics updated? What is the interval of Statistics update? What is the algorithm behind update statistics? These are the puzzling questions and more. - [SQL SERVER - Find Max Worker Count using DMV - 32 Bit and 64 Bit](https://blog.sqlauthority.com/2010/04/20/sql-server-find-max-worker-count-using-dmv-32-bit-and-64-bit/): During several recent training courses, I found it very interesting that Worker Thread is not quite known to everyone despite the fact that it is a very important feature. At some point in the discussion, one of the attendees mentioned that we can double the Worker Thread if we double the CPU (add the same number of CPU that we have on current system). The same discussion has triggered this quick article. Here is the DMV which can be used to find out Max Worker Count SELECT max_workers_count FROM sys.dm_os_sys_info Let us run the above query on my system and find... - [SQL SERVER - Find Most Active Database in SQL Server - DMV dm_io_virtual_file_stats](https://blog.sqlauthority.com/2010/04/19/sql-server-find-most-active-database-in-sql-server-dmv-dm_io_virtual_file_stats/): Few days ago, I wrote about SQL SERVER – Find Current Location of Data and Log File of All the Database. There was very interesting conversation in comments by blog readers. Blog reader and SQL Expert Sreedhar has very interesting DMV presented which lists the most active database in SQL Server. For quick reference he has included the size of the disk in KB, MB and GB as well. SELECT DB_NAME(mf.database_id) AS databaseName, name AS File_LogicalName, CASE WHEN type_desc = 'LOG' THEN 'Log File' WHEN type_desc = 'ROWS' THEN 'Data File' ELSE type_desc END AS File_type_desc ,mf.physical_name ,num_of_reads ,num_of_bytes_read ,io_stall_read_ms ,num_of_writes ,num_of_bytes_written ,io_stall_write_ms ,io_stall... - [SQLAuthority News - Free eBook Download - Introducing Microsoft SQL Server 2008 R2](https://blog.sqlauthority.com/2010/04/18/sqlauthority-news-free-ebook-download-introducing-microsoft-sql-server-2008-r2/): Microsoft Press has published a FREE eBook on the most awaiting releases of SQL Server 2008 R2. The book is written by Ross Mistry and Stacia Misner. Ross is my personal friend and one of the most active book writers in SQL Server Domain. When I see his name on any book, I am sure that it will be high quality and easy to read book. - [SQL SERVER - SELECT TOP Shortcut in SQL Server Management Studio (SSMS)](https://blog.sqlauthority.com/2010/04/17/sql-server-select-top-shortcut-in-sql-server-management-studio-ssms/): This is tool is pretty old, yet always comes as a handy tip. I had a great trip at TechEd in India. And, during one of my presentations, I was asked if there are any shortcuts to SELECT only TOP 100 records from SSMS. I immediately told him that if he explores the table in SSMS, he can just right click on it and SELECT TOP 1000 records. If he wanted only 100 records, then he could edit that 1000 to 100 by means of going to Options. Go to Options, then hover the mouse over the SQL Server Object Explorer,... - [SQLAuthority News - Best Compliment - DBA Survivor: Become a Rock Star DBA](https://blog.sqlauthority.com/2010/04/16/sqlauthority-news-best-compliment-dba-survivor-become-rock-star-dba/): Today's blog post is about the best compliment I have ever received. I am very, very happy and would like to share my feelings with you. Thomas Larock (Blog | Twitter) (known as SQLRockstar) keeps the excellent ranking of the blogger in the SQL Server Arena. I am a big fan of this list and have been referring lots of people. - [SQLAuthority News - Tips for Traveling to Nepal](https://blog.sqlauthority.com/2010/04/15/sqlauthority-news-tips-for-traveling-to-nepal/): If you are a regular reader of this blog, you might know that I travel nearly 20+ days out of 30 days in a month. There are cases when I don’t have a chance to go home for an entire month and my family has to travel to different cities just to meet me. During my recent visit, one of my acquaintances suggested that I should blog about my travel experiences as well. This can be helpful to others who are traveling to the country or city. This blog post is about Nepal. - [SQL SERVER - What is Spatial Database? - Developing with SQL Server Spatial and Deep Dive into Spatial Indexing](https://blog.sqlauthority.com/2010/04/14/sql-server-what-is-spatial-database-developing-with-sql-server-spatial-and-deep-dive-into-spatial-indexing/): What is Spatial Database? A spatial database is a database that is optimized to store and query data related to objects in space, including points, lines and polygons. While typical databases can understand various numeric and character types of data, additional functionality needs to be added for databases to process spatial data types. (Source: Wikipedia) Today I will be talking about the same subject at Microsoft TechEd India. If you want to learn about how to spatial aspect of data and how to integrate them with SQL Server this is the perfect session for you. Spatial is very special concept of... - [SQL SERVER - Configure Management Data Collection in Quick Steps - T-SQL Tuesday #005](https://blog.sqlauthority.com/2010/04/13/sql-server-configure-management-data-collection-in-quick-steps-t-sql-tuesday-005/): This article was written as a response to T-SQL Tuesday #005 – Reporting. The three most important components of any computer and server are the CPU, Memory, and Hard disk specification. This post talks about  how to get more details about these three most important components using the Management Data Collection. Management Data Collection generates the reports for the three said components by default. Configuring Data Collection is a very easy task and can be done very quickly. Please note: There are many different ways to get reports generated for CPU, Memory and IO. You can use DMVs, Extended Events as... - [SQLAuthority News - Three Posts on Reporting - T-SQL Tuesday #005](https://blog.sqlauthority.com/2010/04/13/sqlauthority-news-three-posts-on-reporting-t-sql-tuesday-005/): If you are following my blog, you already know that I am more of “T-SQL and Performance Tuning” type of person. I do have a good understanding of Business Intelligence suit and I also do certain training sessions on the same subject. When I was writing the blog post for T-SQL Tuesday #005 – Reporting, I realized that I have written a post that clearly explains how to generate reports using SQL Server Management Studio. Here is a quick recap on how one can use SSMS and out-of-the-box reports which can help many developers. Please note that they can be resource-intensive... - [SQL SERVER - What is MDS? - Master Data Services in Microsoft SQL Server](https://blog.sqlauthority.com/2010/04/12/sql-server-what-is-mds-master-data-services-in-microsoft-sql-server-2008-r2/): What is MDS? Master Data Services helps enterprises standardize the data people rely on to make critical business decisions. With Master Data Services, IT organizations can centrally manage critical data assets company wide and across diverse systems, enable more people to securely manage master data directly, and ensure the integrity of information over time. (Source: Replace with Microsoft) - [SQLAuthority News - SQL Server Cheat Sheet](https://blog.sqlauthority.com/2010/04/11/sqlauthority-news-spot-the-sqlauthority-baby-contest-sql-server-cheat-sheet/): I received many requests for the same. I have only 30 copies available at this moment. I will print more copies of the cheat sheet. - [SQLAuthority News - Speaking Sessions at TechEd India - 3 Sessions - 1 Panel Discussion](https://blog.sqlauthority.com/2010/04/10/sqlauthority-news-speaking-sessions-at-teched-india-3-sessions-1-panel-discussion/): Microsoft Tech-Ed India 2010 is considered as the major Technology event of the year for various IT professionals and developers. This event will feature a comprehensive forum in order   to learn, connect, explore, and evolve the current technologies we have today. I would recommend this event to you since here you will learn about today’s cutting-edge trends, thereby enhancing your work profile and getting ahead of the rest. But, the most important benefit of all might be the networking opportunity that that you can attain by attending the forum. You can build personal connections with various Microsoft experts and peers that... - [SQLAuthority News - Meeting with Allen Bailochan Tuladhar - An Unlimited Experience](https://blog.sqlauthority.com/2010/04/09/sqlauthority-news-meeting-with-allen-bailochan-tuladhar-an-unlimited-experience/): I recently came back from my 9-day trip in Nepal and I must say that this is one of the best trips I had in my lifetime. Allen Bailochan Tuladhar is a wonderful person and an extreme enthusiast for Microsoft Technology. Allen is the Chief Executive Officer of Unlimited Technologies Pvt Ltd., Country Manager of Microsoft MDP Nepal, the Member Secretary of Nepali Language in Information Technology, and member of the Steering Committee of the Government of Nepal. It an was unlimited experience for sure. - [SQLAuthority News - Author Visit Review - TechMela Nepal - March 29-30, 2010](https://blog.sqlauthority.com/2010/04/08/sqlauthority-news-author-visit-review-techmela-nepal-march-29-30-2010/): I was very fortunate to attend TechMela at Kathmandu, Nepal on 29th and 30th of March 2010. I would like to thank Allen Bailochan Tuladhar from Microsoft MDP Nepal for inviting me. Allen is a person with seemingly infinite energy and unlimited passion for Microsoft Technology. If you get an opportunity to spend just one hour with him, you will surely be more enthusiastic with regards to Microsoft Technology. And, I was lucky enough that I was able to spend about a total of 9 days with him in Kathmandu, working along with him in the Tech Community. TechMela is considered... - [SQLAuthority News - Milestone of 1300th Post and A Few Updates](https://blog.sqlauthority.com/2010/04/07/sqlauthority-news-milestone-of-1300th-post-and-few-updates/): Today is my 1300th blog post and I realize that my blog has been quite running such a long journey. I have been writing for a lengthy time on this tech blog. Today I would like to go back and briefly recall the posts that were part of my blog’s history. Read all list of all my blog posts here. This blog only started as a list of personal bookmarks. I used to just write down scripts on the blog for my personal use. I was the one who wrote many scripts here for the servers that I was maintaining to... - [SQL SERVER - Retrieve and Explore Database Backup without Restoring Database - Idera virtual database](https://blog.sqlauthority.com/2010/04/06/sql-server-retrieve-and-explore-database-backup-without-restoring-database-idera-virtual-database/): I recently downloaded Idera’s SQL virtual database, and tested it. There are a few things about this tool which caught my attention. Let us learn about Retrieve and Explore Database Backup without Restoring Database. - [SQL SERVER - 2008 - Introduction to Snapshot Database - Restore From Snapshot](https://blog.sqlauthority.com/2010/04/05/sql-server-2008-introduction-to-snapshot-database-restore-from-snapshot/): Snapshot database is one of the most interesting concepts that I have used at some places recently. Here is a quick definition of the subject from Book On Line: A Database Snapshot is a read-only, static view of a database (the source database). Multiple snapshots can exist on a source database and can always reside on the same server instance as the database. Each database snapshot is consistent, in terms of transactions, with the source database as of the moment of the snapshot’s creation. A snapshot persists until it is explicitly dropped by the database owner. If you do not know... - [SQL SERVER - Enable Identity Insert - Import Expert Wizard](https://blog.sqlauthority.com/2010/04/04/sql-server-enable-identity-insert-import-expert-wizard/): I recently got an email from an old friend who told me that when he tries to execute the SSIS package, it fails because of some identity error. After a few series of debugging and opening his package, we finally figured out that he has the following problem. Let's learn how to Enable Identity Insert – Import Expert Wizard. - [SQL SERVER - Difference Between GRANT and WITH GRANT](https://blog.sqlauthority.com/2010/04/03/sql-server-difference-between-grant-and-with-grant/): What is the difference between GRANT and WITH GRANT when giving permissions to the user? This is a very interesting question recently asked me to during my session at TechMela Nepal. Let us first see the syntax and analyze. GRANT: USE master; GRANT VIEW ANY DATABASE TO username; GO WITH GRANT: USE master; GRANT VIEW ANY DATABASE TO username WITH GRANT OPTION; GO The difference between these options is very simple. In case of only GRANT, the username cannot grant the same permission to other users. On the other hand, with the option WITH GRANT, the username will be able to give the permission after receiving requests... - [SQL SERVER - Simple Installation of Master Data Services (MDS) and Sample Packages - Very Easy](https://blog.sqlauthority.com/2010/04/02/sql-server-simple-installation-of-master-data-services-mds-and-sample-packages-very-easy/): I twitted recently about: ‘Installing #sql Server 2008 R2 – Master Data Services. Painless.’ After doing so, I got quite a few emails from other users as to why I thought it was painless. The reason was very simple- I was able to install it rather quickly on my laptop without any issues. There were a few requests along with these emails sent to me, which regards to how to install MDS, as well sample databases. Please note that I am the admin of my machine and I installed this MDS as the admin as well. Talk to your network administrator... - [SQLAuthority News - MS Access Database is the Way to Go - April 1st Humor](https://blog.sqlauthority.com/2010/04/01/sqlauthority-news-ms-access-database-is-the-way-to-go-april-1st-humor/): First of all, today is April 1- April Fool’s Day, so I have written this post for some light entertainment. My friend has just sent me an email about why a person should go for Access Database. For a short background, I used to be an MS Access user once (I will not call myself MS Access DBA), and I must say I had a good time with Database at that time. As time passed by, I moved from MS Access to SQL Server. Well, as for my friend’s email, his reasons considering MS Access usage really made me laugh. MS... - [SQLAuthority News - Fun Quotes about Technology](https://blog.sqlauthority.com/2010/03/31/sqlauthority-news-fun-quotes-technology/): SQL Server can be boring subject many times. In this blog post, let us see some of the fun quotes. - [SQL SERVER - World Shape files Download and Upload to Database - Spatial Database](https://blog.sqlauthority.com/2010/03/30/sql-server-world-shapefile-download-and-upload-to-database-spatial-database/): During my recent, training I was asked by a student if I know a place where he can download spatial files for all the countries around the world, as well as if there is a way to upload shape files to a database. Here is a quick tutorial for it. - [SQL SERVER - Introduction to Extended Events - Finding Long Running Queries](https://blog.sqlauthority.com/2010/03/29/sql-server-introduction-to-extended-events-finding-long-running-queries/): The job of an SQL Consultant is very interesting as always. The month before, I was busy doing query optimization and performance tuning projects for our clients, and this month, I am busy delivering my performance in Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning Course. I recently read white paper about Extended Event by SQL Server MVP Jonathan Kehayias. You can read the white paper here: Using SQL Server 2008 Extended Events. I also read another appealing chapter by Jonathan in the book, SQLAuthority Book Review – Professional SQL Server 2008 Internals and Troubleshooting. After reading these excellent notes by Jonathan, I decided to upgrade my course and include Extended Event as one of the modules. - [SQLAuthority News - Author Visit to Nepal TechMela - 2 Technical Sessions](https://blog.sqlauthority.com/2010/03/28/sqlauthority-news-author-visit-to-nepal-techmela-2-technical-sessions/): Microsoft MDP Nepal is going to organize a Tech Mela for the IT community of Nepal on March 29 & 30, 2010 (2066 Chaitra 16 & 17), Monday and Tuesday,  at the Russian Center for Science & Culture, Kamalpokhari, Kathmandu. The objective of the event is to enhance and exchange knowledge about Information Technology, as well as Microsoft products and technologies, with the IT community. I am very excited to attend this one-of-a-kind event in Nepal. - [SQL SERVER - FIX : ERROR : 4214 BACKUP LOG cannot be performed because there is no current database backup](https://blog.sqlauthority.com/2010/03/27/sql-server-fix-error-4214-backup-log-cannot-be-performed-because-there-is-no-current-database-backup/): I recently got following email from one of the readers. It is about Backup Log file. - [SQL SERVER - Generate Report for Index Physical Statistics - SSMS](https://blog.sqlauthority.com/2010/03/26/sql-server-generate-report-for-index-physical-statistics-ssms/): Few days ago, I wrote about SQL SERVER – Out of the Box – Activity and Performance Reports from SSSMS (Link). A user asked me a question regarding if we can use similar reports to get the detail about Indexes. Yes, it is possible to do the same. There are similar type of reports are available at Database level, just like those available at the Server Instance level. You can right click on Database name and click Reports. Under Standard Reports, you will find following reports. Disk Usage Disk Usage by Top Tables Disk Usage by Table Disk Usage by Partition... - [SQL SERVER - Out of the Box - Activity and Performance Reports from SSSMS](https://blog.sqlauthority.com/2010/03/25/sql-server-default-activty-and-performance-reports-from-sssms/): SQL Server management Studio 2008 is a wonderful tool and has many different features. Many times, an average user does not use them as they are not aware about these features. Today, we will learn one such feature. SSMS comes with many inbuilt performance reports and activity reports, but we do not use it to the full potential. - [SQL SERVER - Fix : Error : 8501 MSDTC on server is unavailable. Changed database context to publisherdatabase](https://blog.sqlauthority.com/2010/03/24/sql-server-fix-error-8501-msdtc-on-server-is-unavailable-changed-database-context-to-publisherdatabase/): During configuring replication on one of the server, I received following error. This is very common error and the solution of the same is even simpler. MSDTC on server is unavailable. Changed database context to publisherdatabase. (Microsoft SQL Server, Error: 8501) Solution: Enable “Distributed Transaction Coordinator” in SQL Server. Method 1: Click on Start–>Control Panel->Administrative Tools->Services Select the service “Distributed Transaction Coordinator” Right on the service and choose “Start” Method 2: Type services.msc in the run command box Select “Services” manager; Hit Enter Select the service “Distributed Transaction Coordinator” Right on the service and choose “Start” Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - We're sorry... ... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now. ](https://blog.sqlauthority.com/2010/03/23/sqlauthority-news-were-sorry-but-your-computer-or-network-may-be-sending-automated-queries-to-protect-our-users-we-cant-process-your-request-right-now/): I use multiple browser many times when I am working with multiple projects simultaneously. Often I use Google Reader to read few feeds. Recently, I faced the following error and this error will not go. I even restarted my computer and rebooted my network. I am confident that my computer does not have viruses or malware, I could not tackle this error. When I opened Google Reader on another browser, it worked fine. Finally, I found the solution and I want share it with all of you. Error We’re sorry… … but your computer or network may be sending automated queries.... - [SQL SERVER - Enumerations in Relational Database - Best Practice](https://blog.sqlauthority.com/2010/03/22/sql-server-enumerations-in-relational-database-best-practice/): This article has been submitted by Marko Parkkola, Data systems designer at Saarionen Oy, Finland. Marko is excellent developer and always thinking at next level. You can read his earlier comment which created very interesting discussion here: SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table). I must express my special thanks to Marko for sending this best practice for Enumerations in Relational Database. He has really wrote excellent piece here and welcome comments here. Enumerations in Relational Database This is a subject which is very basic thing in relational databases but often not very well understood... - [SQL SERVER - Fix : Error : 3117 : The log or differential backup cannot be restored because no files are ready to rollforward](https://blog.sqlauthority.com/2010/03/21/sql-server-fix-error-3117-the-log-or-differential-backup-cannot-be-restored-because-no-files-are-ready-to-rollforward/): I received the following email from one of my readers. Dear Pinal, I am new to SQL Server and our regular DBA is on vacation. Our production database had some problem and I have just restored full database backup to production server. When I try to apply log back I am getting following error. I am sure, this is valid log backup file. Screenshot is attached. [Few other details regarding server/ip address removed] Msg 3117, Level 16, State 1, Line 1 The log or differential backup cannot be restored because no files are ready to roll forward. Msg 3013, Level 16,... - [SQLAuthority News - Microsoft SQL Server Protocol Documentation Download](https://blog.sqlauthority.com/2010/03/20/sqlauthority-news-microsoft-sql-server-protocol-documentation-download/): Download Microsoft SQL Server Protocol Documentation Authored by Microsoft The Microsoft SQL Server protocol documentation provides detailed technical specifications for Microsoft proprietary protocols (including extensions to industry-standard or other published protocols) that are implemented and used in Microsoft SQL Server to interoperate or communicate with Microsoft products. The documentation includes a set of companion overview and reference documents that supplement the technical specifications with conceptual background, overviews of inter-protocol relationships and interactions, and technical reference information. Abstract courtesy Microsoft Microsoft SQL Server Protocol Documentation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interview Questions & Answers Needs Your Help](https://blog.sqlauthority.com/2010/03/19/sql-server-interview-questions-answers-needs-your-help/): Click here to get free chapters (PDF) in the mailbox About an year ago, I had posted SQL Server related Interview Questions and Answers. It was very well received in community. I have received many comments, suggestions and emails on this subject. I am planning to upgrade the Interview Questions and Answers and take it to next level. Here, I need your help. Please your comments, suggestions, expectation or potential interview Question (along with answer) here. Your input will be very valuable. As time goes by we all learn and get better. There were few things missing at that time when... - [SQL SERVER - Mirroring Configured Without Domain - The server network address TCP://SQLServerName:5023 can not be reached or does not exist](https://blog.sqlauthority.com/2010/03/18/sql-server-mirroring-configured-without-domain-the-server-network-address-tcpsqlservername5023-can-not-be-reached-or-does-not-exist/): Regular readers of my blog will be aware of my friend who called me few days ago with very a funny SQL Problem SQL SERVER – SSMS Query Command(s) completed successfully without ANY Results. This time, it did not take long before he called me up with another interesting problem, although the issue he was facing this time was not that interesting and also very specific to him, however, he insisted me to share with all of you. Let us understand his situation at first. My friend is preparing for DBA exam Exam 70-450: PRO: Designing, Optimizing and Maintaining a Database... - [SQL SERVER - Difference Between ROLLBACK IMMEDIATE and WITH NO_WAIT during ALTER DATABASE](https://blog.sqlauthority.com/2010/03/17/sql-server-difference-between-rollback-immediate-and-with-no_wait-during-alter-database/): We are going to discuss something very simple topic. Difference Between ROLLBACK IMMEDIATE and WITH NO_WAIT during ALTER DATABASE. - [SQL SERVER - Quick Note of Database Mirroring](https://blog.sqlauthority.com/2010/03/16/sql-server-quick-note-of-database-mirroring/): Just a day ago, I was invited at Round Table meeting at prestigious organization. They were planning to implement High Availability solution using Database Mirroring. During the meeting, I have made few notes of what was being discussed there. I just thought it would be interested for all of you know about it. Database Mirroring works on physical log records. SQL Server 2008 compresses the Transaction Log at Principal Server before it is transferred to mirror server. System databases can not be mirrored. Database which needs to be mirrored requires it to be in FULL recovery mode. High Safety Mode –... - [SQL SERVER - MAXDOP Settings to Limit Query to Run on Specific CPU](https://blog.sqlauthority.com/2010/03/15/sql-server-maxdop-settings-to-limit-query-to-run-on-specific-cpu/): This is very simple and known tip. Query Hint MAXDOP – Maximum Degree Of Parallelism can be set to restrict query to run on a certain CPU. Please note that this query cannot restrict or dictate which CPU to be used, but for sure, it restricts the usage of number of CPUs in a single batch. Let us consider the following example of this query. The following query usually runs on multicore on a dual core machine (please note it may not be the case with your machine). USE AdventureWorks GO SELECT * FROM Sales.SalesOrderDetail ORDER BY ProductID GO Now the same... - [SQLAuthority News - Interesting Whitepaper - We Loaded 1TB in 30 Minutes with SSIS, and So Can You](https://blog.sqlauthority.com/2010/03/14/sqlauthority-news-interesting-whitepaper-we-loaded-1tb-in-30-minutes-with-ssis-and-so-can-you/): We Loaded 1TB in 30 Minutes with SSIS, and So Can You SQL Server Technical Article Writers: Len Wyatt, Tim Shea, David Powell Published: March 2009 In February 2008, Microsoft announced a record-breaking data load using Microsoft SQL Server Integration Services (SSIS): 1 TB of data in less than 30 minutes. That data load, using SQL Server Integration Services, was 30% faster than the previous best time using a commercial ETL tool. This paper outlines what it took: the software, hardware, and configuration used. We will describe what we did to achieve that result, and offer suggestions for how to relate... - [SQLAuthority News - SQL Server 2008 R2 Update for Developers Training Kit (March 2010 Update)](https://blog.sqlauthority.com/2010/03/13/sqlauthority-news-sql-server-2008-r2-update-for-developers-training-kit-march-2010-update/): Note: Download SQL Server 2008 R2 Update for Developers Training Kit (March 2010 Update) Authored by Microsoft SQL Server 2008 R2 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2008. The SQL Server 2008 R2 Update for Developers Training Kit is ideal for developers who want to understand how to take advantage of the key improvements introduced in SQL Server 2008 and SQL Server 2008 R2 in their applications, as well as for developers who are new to SQL Server. The training kit is brought to you by Microsoft Developer and Platform... - [SQLAuthority News - Download Microsoft SQL Server JDBC Driver 3.0 CTP 1](https://blog.sqlauthority.com/2010/03/13/sqlauthority-news-download-microsoft-sql-server-jdbc-driver-3-0-ctp-1/): Note:  Download Microsoft SQL Server JDBC Driver 3.0 CTP 1 Authored by Microsoft Download the SQL Server JDBC Driver 3.0 CTP, a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform, Enterprise Edition 5. In its continued commitment to interoperability, Microsoft has released a preview of the upcoming Java Database Connectivity (JDBC) driver. The SQL Server JDBC Driver 3.0 CTP download is available to all SQL Server users at no additional charge, and provides access to SQL Server 2000, SQL Server 2005, and SQL Server 2008 from any Java application,... - [SQL SERVER - Checklist for Analyzing Slow-Running Queries](https://blog.sqlauthority.com/2010/03/12/sql-server-checklist-for-analyzing-slow-running-queries/): I am recently working on upgrading my class Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning with additional details and more interesting examples. While working on slide deck I realized that I need to have one solid slide which talks about checklist for analyzing slow running queries. A quick search on my saved book mark link come up with interesting book online link. This link very clearly suggests: To save time, consult this checklist before you contact your technical support provider. I strongly suggest you to do the same, first consult this checklist and if you still further need... - [SQL SERVER - Force Index Scan on Table - Use No Index to Retrieve the Data - Query Hint](https://blog.sqlauthority.com/2010/03/11/sql-server-force-index-scan-on-table-use-no-index-to-retrieve-the-data-query-hint/): Recently I received the following two questions from readers and both the questions have very similar answers. Question 1: I have a unique requirement where I do not want to use any index of the table; how can I achieve this? Question 2: Currently my table uses clustered index and does seek operation; how can I convert seek to scan? First of all, I am not going to analysis their need of why, in fact, they want to convert seek to scan or use no index here. The requirement is strange as using no index or scanning large table may reduce... - [SQLAuthority Book Review - Professional SQL Server 2008 Internals and Troubleshooting](https://blog.sqlauthority.com/2010/03/10/sqlauthority-book-review-professional-sql-server-2008-internals-and-troubleshooting/): Professional SQL Server 2008 Internals and Troubleshooting by Christian Bolton, Justin Langford, Brent Ozar, James Rowland-Jones, Steven Wort Link to Amazon (Worldwide) Link to Flipkart (India) Brief Review: Having a book on internal and associating that with real life is “almost” an impossible task. The reason for using the word “almost” is because this book has accomplished this very well. This internals book is written by keeping real life scenarios as top focus. The highlight of the book is that it teaches how to use internals to troubleshoot the real life issues of performance, storage, query processing and all the other... - [SQL SERVER - Improve Performance by Reducing IO - Creating Covered Index](https://blog.sqlauthority.com/2010/03/09/sql-server-improve-performance-by-reducing-io-creating-covered-index/): This blog post is in the response of the T-SQL Tuesday #004: IO by Mike Walsh. The subject of this month is IO. Here is my quick blog post on how Cover Index can Improve Performance by Reducing IO. Let us kick off this post with disclaimers about Index. Index is a very complex subject and should be exercised with experts. Too many indexes, and in particular, too many covering indexes can hamper the performance. Again, indexes are very important aspect of performance tuning. In this post, I am demonstrating very limited capacity of Index. We will create covering index for... - [SQLAuthority News - SQL SERVER 2008 R2 Pricing](https://blog.sqlauthority.com/2010/03/08/sql-server-2008-r2-pricing/): I was recently asked question about SQL Server 2008 pricing. I have bookmarked official site here which lists the pricing. Official site: What’s New in SQL Server 2008 R2 Editions Editions Per Processor PricingRetail Per Server Plus CAL PricingRetail Parallel Data Warehouse $57,498 Not offered via Server CAL Datacenter $57,498 Not offered via Server CAL Enterprise $28,749 $13,969 with 25 CALs Standard $7,499 $1,849 with 5 CALs However, I have bookmarked following site of Brent Ozar SQL Server 2008 R2 Pricing and Feature Changes. I think Brent has answered one very interesting question there that SQL Server R2 is FREE for... - [SQLAuthority News - Office 2010 Readiness Check - Are you ready for Office 2010?](https://blog.sqlauthority.com/2010/03/07/sqlauthority-news-office-2010-readiness-check-are-you-ready-for-office-2010/): PowerPivot for Excel is a data analysis tool that delivers unmatched computational power directly within the application users already know and love—Microsoft Excel. Office 2010 is the next version of Office 2010. We all know Office 2010 is on the verge of getting released and the reviews available online say that it’s a phenomenal product. My friend Vijay Raj has written excellent article on Office 2010 Readiness Check. Vijay is a Microsoft MVP, focusing on Application Setup and Deployment. He is also a Springboard Series Technical Expert Panel member for Windows 7.  He is one among the core team members at... - [SQLAuthority News - SQL Server Modeling CTP - Nov 2009 Release 2 (formerly Oslo)](https://blog.sqlauthority.com/2010/03/06/sqlauthority-news-sql-server-modeling-ctp-nov-2009-release-2-formerly-oslo/): Note : Download SQL Server Modeling CTP – Nov 2009 Release 2 (formerly Oslo)  by Microsoft SQL Server Modeling (formerly code name “Oslo”) is a set of future technologies that provide significant productivity gains across the lifecycle of .NET applications by enabling developers, architects, and IT professionals to work together more effectively with SQL Server at the center of the application lifecycle. The components of the SQL Server Modeling CTP are: “M” is a highly productive, developer friendly, textual language for defining schemas, queries, values, functions and DSLs for SQL Server databases “Quadrant” is a customizable tool for interacting with large... - [SQL SERVER - Order of Columns in Update Statement Does not Matter](https://blog.sqlauthority.com/2010/03/05/sql-server-order-of-columns-in-update-statement-does-not-matter/): I recently received few comments that I have not written on simple subjects recently. In fact, this blog is dedicated to all those who are really learning SQL Server and almost all the articles and posts are posted here keeping this goal in mind. One of the questions in the email which requested to write simple subjects was “Does the order of columns in UPDATE statements matter?” Let me try to answer this question today. The question in detail: Does the order of the columns in UPDATE statements matter? For example, is there any difference between option 1 and option 2... - [SQL SERVER - Rollback TRUNCATE Command in Transaction](https://blog.sqlauthority.com/2010/03/04/sql-server-rollback-truncate-command-in-transaction/): This is a very common concept that truncate cannot be rolled back. Let us learn in today's blog post that Rollback TRUNCATE is possible. - [SQL SERVER - Performance Comparison - INSERT TOP (N) INTO Table - Using Top with INSERT](https://blog.sqlauthority.com/2010/03/03/sql-server-performance-comparison-insert-top-n-into-table-using-top-with-insert/): Recently I wrote about SQL SERVER – INSERT TOP (N) INTO Table – Using Top with INSERT I mentioned about how TOP works with INSERT. I have mentioned that I will write about the performance in next article. Here is the performance comparison of the two options. - [SQLAuthority News - Excellent Event - TechEd Sri Lanka - Feb 8, 2010](https://blog.sqlauthority.com/2010/03/02/sqlauthority-news-excellent-event-teched-sri-lanka-feb-8-2010/): TechEd Sri Lanka was held at Waters Edge, Colombo between Feb 8 and Feb 10, 2010. It was one of the largest successful technical event in Sri Lanka. I was extremely surprised to how technically sound this event was and how excited the TechEd attendees were. I presented there on two different subject. They were very enthusiastic and had so many interesting questions during the session. One of my session received rating of 8.9. I must thank you to all the attendees for sending their feedback and appreciating my session. Both of my session have received feedback above average. The Other... - [SQL SERVER - Data and Page Compressions - Data Storage and IO Improvement](https://blog.sqlauthority.com/2010/03/01/sql-server-data-and-page-compressions-data-storage-and-io-improvement/): The performance of SQL Server is primarily decided by the disk I/O efficiency. Improving I/O definitely improves the performance. SQL Server 2008 introduced Data and Backup compression features to improve the disk I/O. Here, I will explain Data compression. Data compression implies the reduction in the disk space reserved by data. Therefore, data compression can be configured for a table, clustered index, non-clustered index, indexed view or a partition of table or index. Data compression is implemented at two levels: ROW and PAGE. Even page compression automatically implements row compression. Tables and indexes can be compressed when they are created by... - [SQLAuthority News - Hyderabad Techies February Fever Feb 11, 2010 - Indexing for Performance](https://blog.sqlauthority.com/2010/02/28/sqlauthority-news-hyderabad-techies-february-fever-feb-11-2010-indexing-for-performance/): I recently presented in Hyderabad User Group on the subject of The Other Side of SQL Server Index: Advanced Solutions to Ancient Problem , you can read more about this event here SQLAuthority News – MUGH – Microsoft User Group Hyderabad – Feb 2, 2010 Session Review. I really had great time talking about Index and Index Tuning. Index is very important part of database performance tuning and understanding it is a big thing. I have learned a lot of performance tuning tricks from Itzik Ben-Gan and Greg Low. After successful session at Hyderabad User Group, I have presented follow up... - [SQL SERVER - Clear Drop Down List of Recent Connection From SQL Server Management Studio](https://blog.sqlauthority.com/2008/11/05/sql-server-clear-drop-down-list-of-recent-connection-from-sql-server-management-studio/): Quite often it happens that SQL Server Management Studio’s Dropdown box is cluttered with many different SQL Server’s name. Sometime it contains the name of the server which does not exist or developer does not have access to it. It is very easy to clean the list and start over. Delete mru.dat file from following location. For SQL Server 2005: C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat If you can not find mru.dat at above location look for mru.dat in following folder. C:\Documents and Settings\[user]\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM\mru.dat For SQL Server 2008: C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\mru.dat If you can not... - [SQL SERVER - Fix : Error: 4064 - Cannot open user default database. Login failed. Login failed for user](https://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/): I have received following question nearly 10 times in last week though emails. Many users have received following error while connecting to the database. This error happens when database is dropped for which is default for some of the database user. When user try to login and their default database is dropped following error shows up. Cannot open user default database. Login failed. Login failed for user ‘UserName’. (Microsoft SQL Server, Error: 4064) The fix for this problem is very simple. Fix/Workaround/Solution: First click on Option>> Button of “Connect to Server” Prompt. Now change the connect to database to any existing... - [SQLAuthority News - SQL Server Security Whitepapers](https://blog.sqlauthority.com/2008/11/03/sqlauthority-news-sql-server-security-whitepapers/): Microsoft has published following three security related white papers. I suggest to all my readers to read them. Read the summary know what is covered in those  white papers. Engine Separation of Duties for the Application Developer – Separation of duties is an important consideration for databases and database applications. By properly defining schemas and roles, you can create a distinction between users who can manipulate data from those that administer the database. This paper discusses the topics of which application developers should be aware and provides a heuristic example to guide you in achieving separation of duties. Database Encryption in... - [SQL SERVER - Fix : Error : Login failed for user 'UserName'. The user is not associated with a trusted SQL Server connection](https://blog.sqlauthority.com/2008/11/02/sql-server-fix-error-login-failed-for-user-username-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Recently I have got two desktop computers at home and both of them are very powerful machine. Machine 1 : Windows Vista SP1 with SQL Server 2008 Machine 2 : Windows 2003 with SQL Server 2005 with SP2 When I was trying to connect from SQL Server 2008 to SQL Server 2005 using Windows Authentication I was getting following error. Login failed for user ‘UserName’. The user is not associated with a trusted SQL Server connection. To resolve this error follow the steps below on computer with SQL Server 2005. Create new user with Administrator privilege with same username and password... - [SQL SERVER - Stored Procedure WITH ENCRYPTION and Execution Plan](https://blog.sqlauthority.com/2008/11/01/sql-server-stored-procedure-with-encryption-and-execution-plan/): Stored Procedures are very important and most of the business logic of my applications are always coded in Stored Procedures. Sometime it is necessary to hide the business logic from end user due to security reasons or any other reason. Keyword WITH ENCRYPTION is used to encrypt the text of the Stored Procedure. One SP are encrypted it is not possible to get original text of the SP from SP itself. User who created SP will need to save the text to be used to create SP somewhere safe to reuse it again. Interesting observation: What prompted me to write this... - [SQL SERVER - DECLARE Multiple Variables in One Statement](https://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/): Just a day ago, while I was enjoying mini vacation during festival of Diwali I met one of the .NET developer who is big fan of Oracle. While discussing he suggested that he wished SQL Server should have feature where multiple variable can be declared in one statement. I requested him to not judge wonderful product like SQL Server with just one feature. SQL Server is great product and it has many feature which are very unique to SQL Server. Regarding feature of SQL Server where multiple variable can be declared in one statement, it is absolutely possible to do. Method... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2008/10/30/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007/): Note:   Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Feature Bullet Summary: The following list gives an overview of the features of the SQL Server management pack. Refer to the SQL Server management pack guide for more detail. Support for Enterprise, Standard and Express... - [SQLAuthority News - Download SQL Server 2005 Service Pack 3 - CTP](https://blog.sqlauthority.com/2008/10/29/sqlauthority-news-download-sql-server-2005-service-pack-3-ctp/): The CTP version of SQL Server 2005 Service Pack 3 (SP3) is now available. You can use these packages to upgrade any of the following SQL Server 2005 editions: Enterprise Enterprise Evaluation Developer Standard Workgroup For a summary list of What’s new in SQL Server 2005 SP3 CTP, review the What’s New document. These packages have been made available for general testing purposes only. Do not deploy the CTP software in production. Download SQL Server 2005 Service Pack 3 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Happy Diwali to All of You](https://blog.sqlauthority.com/2008/10/28/sqlauthority-news-happy-diwali-to-all-of-you/): SQLAuthority Wishes Happy Diwali to All of You. Diwali is one of the important Hindu festivals, which comprises of four consecutive days of celebrations. - [SQLAuthority News - Download Microsoft SQL Server 2008 Feature Pack, October 2008](https://blog.sqlauthority.com/2008/10/27/sqlauthority-news-download-microsoft-sql-server-2008-feature-pack-october-2008/): Note: Download Microsoft SQL Server 2008 Feature Pack, October 2008 by Microsoft - [SQLAuthority News - Definition - Outsourcing, Offshoring, Nearshoring, Offshore Outsourcing](https://blog.sqlauthority.com/2008/10/26/sqlauthority-news-definition-outsourcing-offshoring-nearshoring-offshore-outsourcing/): Outsourcing - Outsourcing is subcontracting a process, such as product design or manufacturing, to a third-party company. Outsourcing involves the transfer of the management and/or day-to-day execution of an entire business function to an external service provider. - [SQL SERVER - INNER JOIN using LEFT JOIN statement - Performance Analysis](https://blog.sqlauthority.com/2008/10/25/sql-server-inner-join-using-left-join-statement-performance-analysis/): Just a day ago, while I was working with JOINs I find one interesting observation, which has prompted me to create following example. Before we continue further let me make very clear that INNER JOIN should be used where it can not be used and simulating INNER JOIN using any other JOINs will degrade the performance. If there are scopes to convert any OUTER JOIN to INNER JOIN it should be done with priority. Run following two script and observe the resultset. Resultset will be identical. USE AdventureWorks GO / Example of INNER JOIN / SELECT p.ProductID, piy.ProductID FROM Production.Product p INNER JOIN Production.ProductInventory piy ON piy.ProductID = p.ProductID... - [SQLAuthority News - TOP Downloads - Bookmark](https://blog.sqlauthority.com/2008/10/24/sqlauthority-news-top-downloads-bookmark/): Recently I have gotten many, many requests for SQL Server Interview Questions and Answers as well as related articles. It seems many people are looking for Job or appearing for an interview at this time of the year. I have included lists of the my top downloads in the sidebar of the blog, still I receive many curious questions as side bar does not show up in the RSS feed. - [Author Visit - MVP Open Day 2008 - Goa - November 15-17](https://blog.sqlauthority.com/2008/10/23/author-visit-mvp-open-day-2008-goa-november-15-17/): I will be attending MVP Open Day 2008 in Goa from November 15 to November 17. I am eagerly waiting to attend the Open Day. If you are in Goa during that time we can meet sometime in evening after sessions are over. Following is the comics related to MVP Open Day 2008. - [SQLAuthority News - Running SQL Server 2008 in a Hyper-V Environment Best Practices and Performance Considerations](https://blog.sqlauthority.com/2008/10/22/sqlauthority-news-running-sql-server-2008-in-a-hyper-v-environment-best-practices-and-performance-considerations/): Hyper-V in Windows Server 2008 is a powerful virtualization technology that can be used by corporate IT to consolidate under-utilized servers, lowering TCO and maintaining or improving Quality of Service. Through a series of test scenarios that are representative of SQL Server application fundamentals, this document provides best practice recommendations on running SQL Server in Windows Hyper-V environment. White paper talks about many subjects and various topics. I enjoyed reading following sections. Setup and Configuration of Hyper-V Configurations Hyper-V Preinstall Checklist and Considerations Storage Configuration Recommendations Monitoring SQL Server on Hyper-V Configurations Test Methodology, Workloads Results, Observations, and Recommendations Different kind... - [SQL SERVER - Fix : Error : Incorrect syntax near. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel](https://blog.sqlauthority.com/2008/10/21/sql-server-fix-error-incorrect-syntax-near-you-may-need-to-set-the-compatibility-level-of-the-current-database-to-a-higher-value-to-enable-this-feature-see-help-for-the-stored-procedure-sp_db/): I have seen developers confused many times when they receive the following error message. Incorrect syntax near. Let us learn. - [SQL SERVER - Transaction and Local Variables - Swap Variables - Update All At Once Concept](https://blog.sqlauthority.com/2008/10/20/sql-server-transaction-and-local-variables-swap-variables-update-all-at-once-concept/): This article is inspired from two sources. Let us learn today about how to swap variables by updating everything at once concepts. 1) My year old article - SQL SERVER - Effect of TRANSACTION on Local Variable - After ROLLBACK and After COMMIT 2) Discussion with SQL Server MVP - Jacob Sebastian - SQLAuthority News - Author Visit - SQL Hour at Patni Computer Systems I usually summarize my article at the end, but this time let me summarize first and we will understand the article next. - [SQL SERVER - Introduction to CLR - Simple Example of CLR Stored Procedure](https://blog.sqlauthority.com/2008/10/19/sql-server-introduction-to-clr-simple-example-of-clr-stored-procedure/): CLR is abbreviation of Common Language Runtime. In SQL Server 2005 and later version of it database objects can be created which are created in CLR. Stored Procedures, Functions, Triggers can be coded in CLR. CLR is faster than T-SQL in many cases. CLR is mainly used to accomplish task which are not possible by T-SQL or can use lots of resources. CLR can be usually implemented where there is intense string operation, thread management or iteration methods which can be complicated for T-SQL. Implementing CLR provides more security to Extended Stored Procedure. Let us create one very simple CLR where... - [SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice - Part 2](https://blog.sqlauthority.com/2008/10/18/sql-server-retrieve-select-only-date-part-from-datetime-best-practice-part-2/): A year ago I wrote post about SQL SERVER – Retrieve – Select Only Date Part From DateTime – Best Practice where I have discussed two different methods of getting datepart from datetime. Method 1: SELECT DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())) Method 2: SELECT CONVERT(VARCHAR(10),GETDATE(),111) I have summarized my post suggesting that either method works fine and I prefer to use Method 2. However, with additional tests and looking at SQL Server internals very carefully, I want to suggest that Method 1 is better in terms of performance. While running on GETDATE() both of the above functions are equally fast and... - [SQL SERVER - Get Common Records From Two Tables Without Using Join](https://blog.sqlauthority.com/2008/10/17/sql-server-get-common-records-from-two-tables-without-using-join/): I really enjoy answering questions which I receive from either comments or Email. My passion is shared by SQL Server Expert Imran Mohammed. He frequently SQL community members by answering their questions frequently and promptly. Sachin Asked: Following is my scenario, Suppose Table 1 and Table 2 has same column e.g. Column1 Following is the query, 1. Select column1,column2 From Table1 2. Select column1 From Table2 I want to find common records from these tables, but i don’t want to use Join clause bcoz for that i need to specify the column name for Join condition. Will you help me to... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting - October 2008](https://blog.sqlauthority.com/2008/10/17/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-october-2008/): Tomorrow is third Saturday of the Month and every third Saturday we have Ahmedabad User Group Meeting. Our user group is growing and getting interesting. Everybody who attended last months User Group (UG) Meeting realized that how important it is to attend UG meetings. UG President Jacob Sebastian (SQL Server – MVP) presented excellent session on “Real World example of CTE”.I personally enjoyed the session very much. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my article here where... - [SQL SERVER - Downgrade Database to Previous Version](https://blog.sqlauthority.com/2008/10/16/sql-server-downgrade-database-to-previous-version/): Today I am writing on the topic which I do not like to write much. I enjoy writing usually positive or affirmative posts. Recently I got email from two different DBA where they upgraded to SQL Server 2005 trial version on their production server and now as their trial version was expire they wanted to downgrade their database to previous licensed version they had. The main questions is how they can downgrade the from SQL Server 2005 to SQL Server 2000? Answer is : Not Possible. There are no tools or native SQL Server facility which does this. I am also... - [SQL SERVER - Introduction and Example of UNION and UNION ALL](https://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/): It is very much interesting when I get request from blog reader to re-write my previous articles. I have received few request to rewrite my article SQL SERVER – Union vs. Union All – Which is better for performance? wi.th examples. I request you to read my previous article first to understand what is the concept and read this article to understand the same concept with example. xe=”color:green;”>/* Create First Table */ DECLARE @Table1 TABLE (Col INT) INSERT INTO @Table1 SELECT 1 INSERT INTO @Table1 SELECT 2 INSERT INTO @Table1 SELECT 3 INSERT INTO @Table1 SELECT 4 INSERT INTO @Table1 SELECT 5 /* Create Second Table */ DECLARE @Table2 TABLE (Col INT) INSERT INTO @Table2... - [SQL SERVER - Get Numeric Value From Alpha Numeric String - UDF for Get Numeric Numbers Only](https://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/): SQL is great with String operations. Many times, I use T-SQL to do my string operation. Let us see User Defined Function, which I wrote few days ago, which will return only Numeric values from AlphaNumeric values. CREATE FUNCTION dbo.udf_GetNumeric (@strAlphaNumeric VARCHAR(256)) RETURNS VARCHAR(256) AS BEGIN DECLARE @intAlpha INT SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric) BEGIN WHILE @intAlpha > 0 BEGIN SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' ) SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric ) END END RETURN ISNULL(@strAlphaNumeric,0) END GO /* Run the UDF with different test values */ SELECT dbo.udf_GetNumeric('') AS 'EmptyString'; SELECT dbo.udf_GetNumeric('asdf1234a1s2d3f4@@@') AS 'asdf1234a1s2d3f4@@@'; SELECT dbo.udf_GetNumeric('123456') AS '123456'; SELECT dbo.udf_GetNumeric('asdf') AS 'asdf'; SELECT dbo.udf_GetNumeric(NULL) AS 'NULL'; GO As... - [SQLAuthority News - Book Review - Pro SQL Server 2005 Replication (Definitive Guide)](https://blog.sqlauthority.com/2008/10/13/sqlauthority-news-book-review-pro-sql-server-2005-replication-definitive-guide/): Pro SQL Server 2005 Replication (Definitive Guide) (Hardcover) by Sujoy Paul (Author) Link to Amazon Quick Review: This is good book for any novice developer to start in the world of database replication implementation and maintenance. Replication is important part of highly availability and one book covers all the concept and methodology at one place. Detail Review: Replication is the process of sharing information so as to ensure consistency between redundant resources, such as software or hardware components, to improve reliability, fault-tolerance, or accessibility. Database replication can be used on many database management systems, usually with a master/slave relationship between the... - [SQLAuthority News - SQL Injection - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2008/10/12/sqlauthority-news-sql-injection-sql-joke-sql-humor-sql-laugh/): It has been a long time since I wrote about SQL Humor. Following is the cartoon sent to me by many (more than 10 times) so far by many users. I did not publish it till now as it has been quite popular and I believed many people had already seen it. However, recently by one of the quite big personality asked me why I have not included this in my blog, so I have finally decided to include that in my blog. Let us read humor about SQL Injection. - [SQLAuthority News - Download - Microsoft SQL Server 2008 Feature Pack, August 2008](https://blog.sqlauthority.com/2008/10/11/sqlauthority-news-download-microsoft-sql-server-2008-feature-pack-august-2008/): Download the 2008 Feature Pack for Microsoft SQL Server 2008, a collection of stand-alone install packages that provide additional value for SQL Server 2008. The Feature Pack is a collection of stand-alone install packages that provide additional value for SQL Server 2008. It includes the latest versions of: Redistributable components for SQL Server 2008. Add-on providers for SQL Server 2008. Backward compatibility components for SQL Server 2008. Download Feature Pack Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Enhenced TRIM() Function - Remove Trailing Spaces, Leading Spaces, White Space, Tabs, Carriage Returns, Line Feeds](https://blog.sqlauthority.com/2008/10/10/sql-server-2008-enhenced-trim-function-remove-trailing-spaces-leading-spaces-white-space-tabs-carriage-returns-line-feeds/): After reading my article SQL SERVER – 2008 – TRIM() Function – User Defined Function, I have received email and comments where user are asking if it is possible to remove trailing spaces, leading spaces, white space, tabs, carriage returns, line feeds etc. I found following script posted by Russ and Erik. It is modified a bit from original script. CREATE FUNCTION dbo.LTrimX(@str VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN DECLARE @trimchars VARCHAR(10) SET @trimchars = CHAR(9)+CHAR(10)+CHAR(13)+CHAR(32) IF @str LIKE '[' + @trimchars + ']%' SET @str = SUBSTRING(@str, PATINDEX('%[^' + @trimchars + ']%', @str), 8000) RETURN @str END GO CREATE FUNCTION dbo.RTrimX(@str VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN... - [SQL SERVER - 2008 - TRIM() Function - User Defined Function](https://blog.sqlauthority.com/2008/10/09/sql-server-2008-trim-function-user-defined-function/): I just received following question in email by James Louren. “How come SQL Server 2000, 2005 does not have function TRIM()? Is there any way to get similar results. What about SQL Server 2008?” James has asked very interesting question. I have previously wrote about SQL SERVER – TRIM() Function – UDF TRIM(). Today my answer is no different than what I answered in earlier post. SQL Server does not have function which can trim leading or trailing spaces of any string at the same time. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. SQL... - [SQLAuthority News - SQL Server 2008 - Microsoft Certifications for 70-432 70-433 70-450 70-452](https://blog.sqlauthority.com/2008/10/08/sqlauthority-news-sql-server-2008-microsoft-certifications-for-70-432-70-433-70-450-70-452/): I have received many emails requesting information about SQL Server certifications examples. Microsoft has released new set of exams for SQL Server 2008 certifications. I am listing them here for quick reference. Exam 70-432 – TS: Microsoft SQL Server 2008, Implementation and Maintenance Installing and Configuring SQL Server 2008 (10 percent) Maintaining SQL Server Instances (13 percent) Managing SQL Server Security (15 percent) Maintaining a SQL Server Database (16 percent) Performing Data Management Tasks (14 percent) Monitoring and Troubleshooting SQL Server (13 percent) Optimizing SQL Server Performance (10 percent) Implementing High Availability (9 percent) ————————————— Exam 70-433 – TS: Microsoft SQL... - [SQL SERVER - 2008 - High Resolution Wallpaper and Screen Saver](https://blog.sqlauthority.com/2008/10/07/sql-server-2008-high-resolution-wallpaper-and-screen-saver/): Recently I came across two very interesting ‘objects’ of SQL Server 2008. SQL Server 2008 High Resolution Wallpaper SQL Server 2008 Screen Saver Click Here to Download Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - SQL Hour at Patni Computer Systems](https://blog.sqlauthority.com/2008/10/07/sqlauthority-news-author-visit-sql-hour-at-patni-computer-systems/): Ahmedabad SQL Server User Group has started organizing a special event, “SQL Hour”, where we visit IT companies and interact with the SQL Server professionals. We had the first meeting this Saturday, 4th October 2008 at Patni Computer Systems, Gandhinangar. This meeting was lead by SQL Server User Group President Jacob Sebastian, who is known for his knowledge of “SQL Server – Behind the Scene”. He presented first session where he explained what is User Group and importance of “SQL Hour”. The meeting was very interesting and attendees were very responsive. We want to congratulate all the attendees as they really... - [SQLAuthority News - Upgrade SQL Server With SA Renamed - Rebuild System Databases - SQL Server 2008](https://blog.sqlauthority.com/2008/10/06/sqlauthority-news-upgrade-sql-server-with-sa-renamed-rebuild-system-databases-sql-server-2008/): I recently came across two interesting blog post by PSS SQL Server Engineers. They have written two interesting SQL Server 2008 related post and it can be very helpful to those who come across the issues mentioned in them. How to Rebuild System Databases in SQL Server 2008 Rarely but sometime there is need to rebuilding the System Databases. In SQL Server 2008 there is no facility to rebuild only msdb database. All the system database have to be rebuilt if any of the database has to be rebuild. System Databases like mssqlsystemresource can be rebuilt only by running Repair from... - [SQL SERVER - 2008 - Fix Connection Error with Visual Studio 2008 - Server Version is not supported - VS SP1 ISO Download](https://blog.sqlauthority.com/2008/10/05/sql-server-2008-fix-connection-error-with-visual-studio-2008-server-version-is-not-supported-vs-sp1-iso-download/): I previously wrote article SQL SERVER – 2008 – Fix Connection Error with Visual Studio 2008 – Server Version is not supported where I discussed how downloading Visual Studio SP1 will fix the error of Visual Studio 2008 connecting to SQL Server 2008. I have provided link to SP1 which was downloading only installer and after that it downloads SP1 component from internet. .NET Expert Vidya Vrat Agarwal has pointed out that Visual Studio SP1 can be downloaded as ISO. It is really good that now after downloading only one it can be used again to installed SP1 on multiple computers.... - [SQLAuthority News - Cumulative update package 1 for SQL Server 2008](https://blog.sqlauthority.com/2008/10/04/sqlauthority-news-cumulative-update-package-1-for-sql-server-2008/): Cumulative update package 1 for SQL Server 2008 is released. Click on link : http://support.microsoft.com/kb/956717/en-us Update : I have received few emails where developer did not find where to click on the support page to download the update package. Following image describes the link which is on very top of the page. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Find If Index is Being Used in Database](https://blog.sqlauthority.com/2008/10/03/sql-server-2008-find-if-index-is-being-used-in-database/): It is very often I get query that how to find if any index is being used in database or not. If any database has many indexes and not all indexes are used it can adversely affect performance. If number of index is higher it reduces the INSERT / UPDATE / DELETE operation but increase the SELECT operation. It is recommended to drop any unused indexes from table to improve the performance. Before dropping the index it is important to check if index is being used or not. I have wrote quick script which can find out quickly if index is... - [SQLAuthority News - Download - Visual Studio Team System 2008 Database Edition GDR September CTP](https://blog.sqlauthority.com/2008/10/03/sqlauthority-news-download-visual-studio-team-system-2008-database-edition-gdr-september-ctp/): In addition to providing support for SQL Server 2008 database projects, this release incorporates many previously released Power Tools as well as several new features. The new features include distinct Build and Deploy phases, Static Code Analysis and improved integration with SQL CLR projects. Database Edition no longer requires a Design Database. Therefore, it is no longer necessary to install an instance of SQL Express or SQL Server prior to using Database Edition. Let us learn about Visual Studio Team System. - [SQLAuthority News - Download - Microsoft SQL Server 2008 Books Online (August 2008)](https://blog.sqlauthority.com/2008/10/02/sqlauthority-news-download-microsoft-sql-server-2008-books-online-august-2008/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Descriptions of the... - [SQL Server - 2008 - Cheat Sheet - One Page PDF Download](https://blog.sqlauthority.com/2008/10/02/sql-server-2008-cheat-sheet-one-page-pdf-download/): Very frequently I have been asked to create a page, post or article where in one page all the important concepts of SQL Server are covered. SQL Server 2008 is very large subject and can not be even covered 1000 of pages. In daily life of DBA there are few commands very frequently used and for novice developers it is good to keep all the important SQL Script and SQL Statements handy. I have attempted to create cheat sheet for SQL Server 2008 most important commands. User can print this in one A4 size page and keep along with them. This can be used in interviews where T-SQL scripts are being asked. - [SQL SERVER - Example of PIVOT UNPIVOT Cross Tab Query in Different SQL Server Versions](https://blog.sqlauthority.com/2008/10/01/sql-server-example-of-pivot-unpivot-cross-tab-query-in-different-sql-server-versions/): Transforming rows to columns (PIVOT/CROSS TAB) and columns to rows (UNPIVOT) may be one of the common requirements that all of us must have seen several times in our programming life. SQL Server 2005 introduced two new operators: PIVOT and UNPIVOT that made writing cross-tab queries easier. My friend and SQL Server MVP Jacob Sebastian has posted an example that transform rows to columns using PIVOT operator. The reverse operation of PIVOT is UNPIVOT. PIVOT operator is available only in SQL Server 2005/2008. It does not exists in SQL Server 2000. Developers who are still using SQL Server 2000 should upgrade... - [SQLAuthority News - Security Update for SQL Server 2005 Service Pack 2](https://blog.sqlauthority.com/2008/09/30/sqlauthority-news-security-update-for-sql-server-2005-service-pack-2/): Developers who are using SQL Server Service Pack 2 must install this security patch for it. A security issue has been identified in the SQL Server 2005 Service Pack 2 that could allow an attacker to compromise your system and gain control over it. You can help protect your computer by installing this update from Microsoft. After you install this item, you may have to restart your computer. Download Security Patch for SQL Server Service Pack 2 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Puzzle - Solution - Computed Columns Datatype Explanation](https://blog.sqlauthority.com/2008/09/29/sql-server-puzzle-solution-computed-columns-datatype-explanation/): Just a day before I wrote article SQL SERVER – Puzzle – Computed Columns Datatype Explanation which was inspired by SQL Server MVP Jacob Sebastian. I suggest that before continuing this article read original puzzle question SQL SERVER – Puzzle – Computed Columns Datatype Explanation. The question was if computed column was of datatype TINYINT how to create Computed Column of datatype INT? Before we continue with the answer let us run following script and understand how computed column is created. USE AdventureWorks GO CREATE TABLE MyTable ( ID TINYINT NOT NULL IDENTITY (1, 1), FirstCol TINYINT NOT NULL, SecondCol TINYINT NOT NULL, ThirdCol TINYINT NOT NULL, ComputedCol AS (FirstCol+SecondCol)*ThirdCol... - [SQL SERVER - Renaming SP is Not Good Idea - Renaming Stored Procedure Does Not Update sys.procedures](https://blog.sqlauthority.com/2008/09/28/sql-server-renaming-stored-procedure-does-not-update-sysprocedures/): I have written many articles about renaming a table, columns, and procedures SQL SERVER - How to Rename a Column Name or Table Name, here I found something interesting about renaming the stored procedures and felt like sharing it with you all. Let us learn about how renaming stored procedure does not update sys.procedures. - [SQL SERVER - Puzzle - Computed Columns Datatype Explanation](https://blog.sqlauthority.com/2008/09/27/sql-server-puzzle-computed-columns-datatype-explanation/): Yesterday I wrote post about SQL SERVER – Get Answer in Float When Dividing of Two Integer. I received excellent comment from SQL Server MVP Jacob Sebastian. Jacob has clarified the concept which I was trying to convey. He is famous for his “behind the scene insight“. When I read his comment, I realize another interesting concept which is related to same idea which is being discussed in this post. Let us read what Jacob says first. Jacob Sebastian: Nice post and something that is very much useful in the day-to-day programming life. Just wanted to add to what is already... - [SQL SERVER - Get Answer in Float When Dividing of Two Integer](https://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/): Many times we have requirements of some calculations amongst different fields in Tables. One of the software developers here was trying to calculate some fields having integer values and divide it which gave incorrect results in integer where accurate results including decimals was expected. Something as follows, Example, USE [AdventureWorks] GO CREATE TABLE [dbo].ConvertExample( [ID] [int] NULL, [Field1] [int] NULL, [Field2] [int] NULL, [Field3] [int] NULL, [Field4] [int] NULL ) GO INSERT INTO [dbo].ConvertExample VALUES (1,30,40,60,80) GO INSERT INTO [dbo].ConvertExample VALUES (2,20,10,50,80) GO INSERT INTO [dbo].ConvertExample VALUES (3,15,140,90,60) GO INSERT INTO [dbo].ConvertExample VALUES (1,60,0,5,2) GO SELECT * FROM [dbo].ConvertExample GO SELECT... - [SQL SERVER - Guidelines and Coding Standards Complete List Download](https://blog.sqlauthority.com/2008/09/25/sql-server-guidelines-and-coding-standards/): Coding standards and guidelines are very important for any developer on the path to a successful career. A coding standard is a set of guidelines, rules and regulations on how to write code. Coding standards should be flexible enough or should take care of the situation where they should not prevent best practices for coding. They are basically the guidelines that one should follow for better understanding. - [SQL SERVER - Guidelines and Coding Standards Part - 2](https://blog.sqlauthority.com/2008/09/24/sql-server-coding-standards-guidelines-part-2/): To express apostrophe within a string, nest single quotes (two single quotes). Example: SET @sExample = 'SQL''s Authority' When working with branch conditions or complicated expressions, use parenthesis to increase readability. IF ((SELECT 1 FROM TableName WHERE 1=2) ISNULL) To mark a single line as comment use (–) before the statement. To mark a section of code as comment use (/*…*/). If there is no need for resultset then use syntax that doesn’t return a resultset. IF EXISTS   (SELECT 1 FROM UserDetails WHERE UserID = 50) Rather than, IF EXISTS  (SELECT COUNT (UserID) FROM UserDetails WHERE UserID = 50) Use a graphical execution plan... - [SQL SERVER - Guidelines and Coding Standards Part - 1](https://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/): Use “Pascal” notation for SQL server Objects Like Tables, Views, Stored Procedures. Also tables and views should have ending “s”. Example: UserDetails Emails If you have big subset of table group than it makes sense to give prefix for this table group. Prefix should be separated by _. Example: Page_ UserDetails Page_ Emails Use following naming convention for Stored Procedure. sp<Application Name>_[<group name >_]<action type><table name or logical instance> Where action is: Get, Delete, Update, Write, Archive, Insert… i.e. verb Example: spApplicationName_GetUserDetails spApplicationName_UpdateEmails Use following Naming pattern for triggers: TR_<TableName>_<action><description> Example: TR_Emails_LogEmailChanges TR_UserDetails_UpdateUserName Indexes : IX_<tablename>_<columns separated by_> Example: IX_UserDetails_UserID Primary... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - September 2008](https://blog.sqlauthority.com/2008/09/22/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-september-2008/): On September 20, 2008 was one of the best day so far for Ahmedabad SQL Server User Group Meeting. We had two very interesting sessions by two SQL Server MVPs. SQL Server MVP Jacob Sebastian had began the meeting with very interesting introduction note. Along with many news Usergroup President Jacob Sebastian announced that SQL Server 2008 RTM (Release to Manufactor) is out. Jacob explained that difference between CTP ( Community Technology Preview) and RTM. RTM means MS SQL Server developer team has signed off on final version of product. Currently, SQL Server 2008 is available to MSDN Subscribers, TechNet Subscribers,... - [SQL SERVER - 2008 - Fix Connection Error with Visual Studio 2008 - Server Version is not supported](https://blog.sqlauthority.com/2008/09/21/sql-server-2008-fix-connection-error-with-visual-studio-2008-server-version-is-not-supported/): While attending conference SQLAuthority Author Visit – Microsoft Student Partner Conference, some developers informed me that SQL SERVER 2008 cannot be connected to Visual Studio 2008 and error displays as MS does not support SQL Server version. I was surprised initially as I could not believe that two MS products are not compatible. When trying myself I got the same error. SQL Server 2008 when connected to Visual Studio 2008 gives the error that “This server version is not supported.  Only servers up to Microsoft SQL Server 2005 are supported“. This error can be easily resolved by just installing Service pack. Download... - [SQLAuthority Author Visit - Ahmedabad User Group Meeting September 2008](https://blog.sqlauthority.com/2008/09/20/sqlauthority-author-visit-ahmedabad-user-group-meeting-september-2008/): Today is third Saturday of the Month and every third Saturday we have Ahmedabad User Group Meeting. Our user group is growing and getting interesting. Everybody who attended last months User Group (UG) Meeting realized that how important it is to attend UG meetings. UG President Jacob Sebastian (SQL Server – MVP) presented excellent session on “Transaction Isolation Levels and Locks in SQL Server”.I personally enjoyed the session very much. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my... - [Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/): The interview is a very important event for any person. A good interview questions leads to good career if the candidate is willing to learn. - [SQL SERVER - 2008 - Interview Questions and Answers - Part 8](https://blog.sqlauthority.com/2008/09/19/sql-server-2008-interview-questions-and-answers-part-8/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download What is Data Compression? In SQL SERVE 2008 Data Compression comes in two flavors: Row Compression Page Compression Row Compression Row compression changes the format of physical storage of data. It minimize the metadata (column information, length, offsets etc) associated with each record. Numeric data types and fixed length strings are stored in variable-length storage format, just like Varchar.  (Read More Here) Page Compression Page compression allows common data to be shared between rows for a given page. Its... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 7](https://blog.sqlauthority.com/2008/09/18/sql-server-2008-interview-questions-and-answers-part-7/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download How can we rewrite sub-queries into simple select statements or with joins? Yes we can write using Common Table Expression (CTE). A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. E.g. USE AdventureWorks... - [SQL SERVER - Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2008/09/17/sql-server-2008-interview-questions-and-answers-part-6/): Interview Questions and Answers - [SQL SERVER - 2008 - Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2008/09/16/sql-server-2008-interview-questions-and-answers-part-5/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download What command do we use to rename a db, a table and a column? To rename db sp_renamedb 'oldname' , 'newname' If someone is using db it will not accept sp_renmaedb. In that case first bring db to single user using sp_dboptions. Use sp_renamedb to rename database. Use sp_dboptions to bring database to multi user mode. E.g. USE master; GO EXEC sp_dboption AdventureWorks, 'Single User', True GO EXEC sp_renamedb 'AdventureWorks', 'AdventureWorks_New' GO EXEC sp_dboption AdventureWorks, 'Single User', False GO... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2008/09/15/sql-server-2008-interview-questions-and-answers-part-4/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER Which command using Query Analyzer will give you the version of SQL server and operating system? SELECT SERVERPROPERTY ('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') What is SQL Server Agent? SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose is to ease the implementation of tasks for the DBA, with its full-function... - [SQL SERVER - 2008 - Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2008/09/14/sql-server-2008-interview-questions-and-answers-part-3/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER 2) Common Questions Asked Which TCP/IP port does SQL Server run on? How can it be changed? SQL Server runs on port 1433. It can be changed from the Network Utility TCP/IP properties -> Port number, both on client and the server. What are the difference between clustered and a non-clustered index? (Read More Here) A clustered index is a special type of index that reorders the way records in the table are... - [SQL SERVER - Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2008/09/13/sql-server-2008-interview-questions-and-answers-part-2/): This is the second part of the blog post series Interview Questions and Answers.Click here to get free chapters (PDF) in the mailbox - [SQL SERVER - 2008 - Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2008/09/12/sql-server-2008-interview-questions-and-answers-part-1/): Click here to get free chapters (PDF) in the mailbox SQL SERVER – 2008 – Interview Questions and Answers Complete List Download 1) General Questions of SQL SERVER What is RDBMS? Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the... - [SQLAuthority News - 700 Articles and Author Updates](https://blog.sqlauthority.com/2008/09/11/sqlauthority-news-700-articles-and-author-updates/): It is always interested to write article when reached at milestone. I start to receive many emails and suggestions just about when this blog is reaching any milestone. One question keep on coming to me is why do I write or what is in it for me? Satisfaction! I enjoy writing and helping community and by writing blog that is what I get. Lots of things have happened since last milestone of 600th article. 1) Microsoft presented most prestigious Microsoft SQL Server MVP Award. This award is given to Exceptional Technical Community Leader. 2) I am vice president of SQL Server... - [SQLAuthority News - SharePoint - Steps To Create A Custom WebPart - Deploy It SharePoint Site](https://blog.sqlauthority.com/2008/09/10/steps-to-create-a-custom-webpart-and-deploy-it-in-sharepoint-site/): SharePoint is one interesting software from Microsoft. My outsourcing location unit is working on one large project of SharePoint. Based on users feedback and overwhelming response to article SQL Server – Error : Fix : SharePoint Stop Working After Changing Server (Computer) Name I am posting one more article which is very important for SharePoint developers. SharePoint does not allow custom coding for any of the webpart. It is possible to create webpart in Visual Studio and integrate it with SharePoint. The process to create webpart in .NET framework and make it working in SharePoint often fails due to lack of... - [SQL Server - Error : Fix : SharePoint Stop Working After Changing Server (Computer) Name](https://blog.sqlauthority.com/2008/09/09/sql-server-error-fix-sharepoint-stop-working-after-changing-server-computer-name/): If Microsoft Office SharePoint Server (MOSS) and your database (MS SQL Server) are running together on same physical server, changing the name of the server (computer) using operating system may create non-functional SharePoint website. When you change the physical server name the SharePoint is already connected to the SQL instance of old computer name (OldServerName/SQLInstance) and on changing the name the SharePoint will not able to connect the SQL Server  as now the SQL Server instance will run on new computer name (NewServerName/SQLInstance). To solve this problem you need to reconfigure the entire Microsoft Office SharePoint Server with SQL Server Instance.... - [SQL SERVER - 2008 - Creating Primary Key, Foreign Key and Default Constraint](https://blog.sqlauthority.com/2008/09/08/sql-server-2008-creating-primary-key-foreign-key-and-default-constraint/): Primary key, Foreign Key and Default constraint are the 3 main constraints that need to be considered while creating tables or even after that. It seems very easy to apply these constraints but still we have some confusions and problems while implementing it. So I tried to write about these constraints that can be created or added at different levels and in different ways or methods. Primary Key Constraint: Primary Keys constraints prevents duplicate values for columns and provides unique identifier to each column, as well it creates clustered index on the columns. 1)      Create Table Statement  to create Primary Key... - [SQL SERVER - Explanation about Usage of Unique Index and Unique Constraint](https://blog.sqlauthority.com/2008/09/07/sql-server-explanation-about-usage-of-unique-index-and-unique-constraint/): I enjoy reading questions from blog readers and answering them. One of the another SQL enthusiastic is Imran who also regularly answer questions of users on this community blog. Recently he has answered in detail about when to use Unique Index and when to use Unique Constraint. Cristiano asked following questions : i need to know how work when there is a situation that there is a Unique Key and this field “alow null”, but when i am going to create a Unique Key the SQLSERVER saw that there were values duplicated and the values are “nulls”. How do i sove... - [SQL SERVER - Find Primary Key Using SQL Server Management Studio](https://blog.sqlauthority.com/2008/09/06/sql-server-find-primary-key-using-sql-server-management-studio/): Imran Mohammed is great SQL Expert and always eager to help community members. He enjoys answering question and solving problems of other community fellows. His answers are always detailed and trustworthy. Today we will see interesting question from Prasant and excellent answer from Imran Mohammed. Question from Prasant: Hi, I want to drop the primary key on one table but i cannot know which constraint is there. Is there a way to drop the primary key without specifying constraint. The basic idea of doing this is : I have one table with 4 columns e.g. 1. SrNo 2. NodeID 3. EnrollmentNo... - [SQL SERVER - 2008 - Creating Full Text Catalog and Full Text Search](https://blog.sqlauthority.com/2008/09/05/sql-server-creating-full-text-catalog-and-index/): Full Text Index helps to perform complex queries against character data. These queries can include words or phrase searching. We can create a full-text index on a table or indexed view in a database. Only one full-text index is allowed per table or indexed view. The index can contain up to 1024 columns. Software developer Monica Monica, who helped with screenshots also informed that this feature works with the RTM (Ready to Manufacture) version of SQL Server 2008 and does not work on CTP (Community Technology Preview) versions. Let us learn about Creating Full Text Catalog and Full Text Search in this blog post. - [SQLAuthority News - Download SQL Server Related Products](https://blog.sqlauthority.com/2008/09/05/sqlauthority-news-download-sql-server-related-products/): Configuration Manager 2007 R2 Evaluation Configuration Manager R2 now also supports Windows Vista SP1 and Windows Server 2008, integrates support for application virtualization, and provides an update to operating system deployment capability initially shipped in Configuration Manager. In addition, Client Status Reporting, SQL Reporting, and Forefront Client reporting are all now available. System Center Operations Manager 2007 SP1 Documentation This download contains documentation for System Center Operations Manager 2007 SP1. Microsoft® Visual Studio Team System 2008 Database Edition GDR August CTP Microsoft® Visual Studio Team System 2008 Database Edition GDR implements support for SQL Server 2008. Abstract courtesy : Microsoft Reference... - [SQLAuthirty Author Visit - SQL SERVER - User Group Meeting - Ahmedabad - August 30, 2008](https://blog.sqlauthority.com/2008/09/04/sqlauthirty-author-visit-sql-server-user-group-meeting-ahmedabad-august-30-2008/): I always enjoy participating in SQL Server User Group. We had recent meeting of Ahmedabad User Group on August 30. We had many things discussed in meeting. I enjoyed meeting fellows from different company who visited user group. The major discussion we had was quality of programmers and quality of work done by programmers. We all felt that looking at current market everybody is rushing for IT jobs. Finding right job is difficult and finding right candidate for job is even more difficult. User groups are the place for good developers to show up for good networking with industry leads and... - [SQLAuthority Author Visit - Microsoft Student Partner Conference](https://blog.sqlauthority.com/2008/09/03/sqlauthority-author-visit-microsoft-student-partner-conference/): The Microsoft Student Partner Program is a worldwide initiative to sponsor students who are interested in technology. The program mainly focuses on improving students skills for enjoyability, called Microsoft Student Partners (MSP). I was recently (August 30, 2008) invited to present technical session at conference held in my City. I really enjoyed presenting the session with very enthusiastic students. I see all the students as future strong members of developer community and Microsoft is doing great job encouraging them and giving them global platform. The program allows selected students to work along with professionals from Microsoft and to be a student... - [SQL SERVER - 2008 - Hardware and Software Requirements for Installing SQL Server 2008](https://blog.sqlauthority.com/2008/09/02/sql-server-hardware-and-software-requirements-for-installing-sql-server-2008/): The following sections list the minimum hardware and software requirements to install and run SQL Server 2008. The following requirements apply to all SQL Server 2008 installations: 1.Framework SQL Server Setup installs the following software components required by the product: – NET Framework 3.5 – SQL Server Native Client – SQL Server Setup support files 2. Software SQL Server Setup requires Microsoft Windows Installer 4.5 or a later version, and Microsoft Data Access Components (MDAC) 2.8 SP1 or a later version. You can download MDAC 2.8 SP1 from the MDAC downloads Web site. 3. Internet Software Microsoft Internet Explorer 6 SP1... - [SQL SERVER - Introduction to Filtered Index - Improve performance with Filtered Index](https://blog.sqlauthority.com/2008/09/01/sql-server-2008-introduction-to-filtered-index-improve-performance-with-filtered-index/): Filtered Index is a new feature in SQL SERVER 2008. Filtered Index is used to index a portion of rows in a table that means it applies filter on INDEX which improves query performance, reduce index maintenance costs, and reduce index storage costs compared with full-table indexes. - [SQL SERVER - 2008 - Introduction to Table-Valued Parameters with Example](https://blog.sqlauthority.com/2008/08/31/sql-server-table-valued-parameters-in-sql-server-2008/): Table-Valued Parameters is a new feature introduced in SQL SERVER 2008. In earlier versions of SQL SERVER it is not possible to pass a table variable in stored procedure as a parameter, but now in SQL SERVER 2008 we can use Table-Valued Parameter to send multiple rows of data to a stored procedure or a function without creating a temporary table or passing so many parameters. Table-valued parameters are declared using user-defined table types. To use a Table Valued Parameters we need follow steps shown below: Create a table type and define the table structure Declare a stored procedure that has... - [SQL SERVER - FIX : ERROR : Could Not Connect to SQL Server - TDSSNIClient initialization failed with error 0x7e, status code 0x60](https://blog.sqlauthority.com/2008/08/30/sql-server-fix-error-could-not-connect-to-sql-server-tdssniclient-initialization-failed-with-error-0x7e-status-code-0x60/): This is a very common error faced by so many people and I get lots of questions regarding this error. This error occurs due to many reasons and I have already posted few solutions on this error, see if you can find your solution here SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server SQL SERVER – Fix : Error : 1326 Cannot connect to Database Server Error: 40 – Could not open a connection to SQL Server or Recently when I was trying to create new user and connect to SQL SERVER... - [SQL SERVER - Few Useful DateTime Functions to Find Specific Dates](https://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/): Recently I have recieved email from Vivek Jamwal, which contains many useful SQL Server Date functions. ----Today SELECT GETDATE() 'Today' ----Yesterday SELECT DATEADD(d,-1,GETDATE()) 'Yesterday' ----First Day of Current Week SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) 'First Day of Current Week' ----Last Day of Current Week SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) 'Last Day of Current Week' ----First Day of Last Week SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0) 'First Day of Last Week' ----Last Day of Last Week SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6) 'Last Day of Last Week' ----First Day of Current Month SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) 'First Day of Current Month' ----Last Day of Current Month SELECT DATEADD(ms,- 3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0))) 'Last Day of Current Month' ----First Day of Last Month SELECT DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)) 'First Day of Last Month' ----Last Day of Last Month SELECT DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))) 'Last Day of Last Month' ----First Day of Current Year SELECT DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0) 'First Day of Current Year' ----Last Day of Current Year SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE())+1,0))) 'Last Day of Current Year' ----First Day of Last Year SELECT DATEADD(yy,-1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)) 'First Day of Last Year' ----Last Day of Last Year SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0))) 'Last Day of Last Year' ResultSet: Today ———————– 2008-08-29 21:54:58.967 Yesterday ———————– 2008-08-28 21:54:58.967 First Day of Current Week ————————- 2008-08-25 00:00:00.000 Last Day of Current Week ———————— 2008-08-31 00:00:00.000 First Day of... - [SQL SERVER - 2008 - Introduction to Merge Statement - One Statement for INSERT, UPDATE, DELETE](https://blog.sqlauthority.com/2008/08/28/sql-server-2008-introduction-to-merge-statement-one-statement-for-insert-update-delete/): MERGE is a new feature that provides an efficient way to perform multiple DML operations. In previous versions of SQL Server, we had to write separate statements to INSERT, UPDATE, or DELETE data based on certain conditions, but now, using MERGE statement we can include the logic of such data modifications in one statement that even checks when the data is matched then just update it and when unmatched then insert it. - [SQLAuthority News - Microsoft SQL Server 2008 R2 Report Builder 3.0](https://blog.sqlauthority.com/2008/08/27/sqlauthority-news-download-sql-server-2008-report-builder-20-rc1/): Microsoft SQL Server 2008 Reporting Services Report Builder 2.0 supports the full capabilities of SQL Server 2008 Reporting Services including flexible report layout, data visualizations and richly formatted text. The download includes the following functionality above the RC0 release of Report Builder: - [SQLAuthority News - SQL Server Express 2008 Downloads](https://blog.sqlauthority.com/2008/08/27/sqlauthority-news-sql-server-express-2008-downloads/): Microsoft SQL Server 2008 Express with Tools Microsoft SQL Server 2008 Express with Tools (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes graphical management tools. SQL Server 2008 Express provides powerful and reliable data management tools and rich features, data protection, and fast performance. It is ideal for small server applications and local data stores. Download Microsoft SQL Server 2008 Express with Tools Microsoft SQL Server 2008 Express with Advanced Services Microsoft SQL Server 2008 Express with Advanced Services (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes... - [SQL SERVER - How to Rename a Column Name or Table Name](https://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/): I often get requests from blog reader for T-SQL script to rename database table column name or rename table itself. Here is a video demonstrating the discussion [youtube=http://www.youtube.com/watch?v=5xviNDISwis] The script for renaming any column : sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN' The script for renaming any object (table, sp etc) : sp_RENAME '[OldTableName]' , '[NewTableName]' This article demonstrates two examples of renaming database object. Renaming database table column to new name. Renaming database table to new name. In both the cases we will first see existing table. Rename the object. Test object again with new name. 1. Renaming database table column to... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting - August 2008](https://blog.sqlauthority.com/2008/08/25/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-august-2008/): I will be attending Ahmedabad SQL Server Usergroup Meeting on August 30, 2008. I will be taking session about “SQL Server CTE and Recursive CTE“. The most important part of August Meeting is there will be presentation on “Transaction Isolation Levels and Locks in SQL Server” from user group President Jacob Sebastian. I invite all of the SQL enthusiastic to stop by User Group Meeting and meet all the fellow developers, DBAs and members. Location : 401, TIME SQUARE, CG road, Op Bazar Calcutta, Ahmedabad, India Date and Time : August 30, 2008 6:30 PM onwards Hope to see all of... - [SQLAuthority News - 4 Million Visits - over 675 SQL Server Articles](https://blog.sqlauthority.com/2008/08/25/sqlauthority-news-4-million-visits-over-675-sql-server-articles/): Thank you to all of my readers for supporting this blog. It has been wonderful journey all the way. I strongly encourage all my readers to actively contribute in discussion and writing article for blog. Today this blog has completed 4 Million visits and there are over 675 articles published on this blog. I have been awarded SQL MVP award from Microsoft during course of this “Journey of SQL Server”. I would like to thank Microsoft and all of my readers for their continuous support. If you have good idea about any SQL Server article please let me know and I... - [SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server - Fix Connection Problems of SQL Server](https://blog.sqlauthority.com/2008/08/24/sql-server-fix-error-40-could-not-open-a-connection-to-sql-server-fix-connection-problems-of-sql-server/): Everyday I get lots of question regarding error : An error has occurred while establishing a connection to the server when connecting to SQL server 2005, this failure may be caused by the fact that under default settings SQL server does not allow remote connection. ( provider: Named Pipes Provider, error: 40 – could not open a connection to SQL server. ) This error happens due to many reasons. There are few solutions already given on my original threads.I encourage to read following two articles first and see if you can find your solution. If you can not find any solution... - [SQL SERVER - 2008 - Configure Database Mail - Send Email From SQL Database](https://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/): Today in this article I would discuss about the Database Mail which is used to send the Email using SQL Server.  Previously I had discussed about SQL SERVER – Difference Between Database Mail and SQLMail. Database mail is the replacement of the SQLMail with many enhancements. So one should stop using the SQL Mail and upgrade to the Database Mail. Special thanks to Software Developer Monica, who helped with all the images and extensive testing of subject matter of this article. Here is the video of the same subject: [youtube=http://www.youtube.com/watch?v=ZGDBB2uwNp8] In order to send mail using Database Mail in SQL Server, there... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case - Part 2](https://blog.sqlauthority.com/2008/08/22/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case-part-2/): I had previously written SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case and I had really enjoyed writing it. Above script converts first letter of each word from sentence to upper case. For example this function will convert this string to title case! will be converted to This Function Will Convert This String To Title Case! However if you just want to convert first word of complete sentence you can use following quick script. USE AdventureWorks GO DECLARE @varString VARCHAR(100) SET @varString = 'this function will convert this string to title case!' SELECT... - [SQL SERVER - Behind the Scene of SQL Server Activity of - Transaction Log - Shrinking Log](https://blog.sqlauthority.com/2008/08/21/sql-server-behind-the-scene-of-sql-server-activity-of-transaction-log-shrinking-log/): Imran Mohammed continues to help community of SQL Server with his very enthusiastic writing and deep understanding of SQL Server architecture. Let us read what Imran has to say about how Transaction Log works and Shrinking of Log works. Question from lauraV Please help me understand. I am taking a full backup once a day, and transaction logs once every hour. Why is my LDF file not retaining a “normal” size? It continues to grow. I do not want to break the chain and use truncate only, though I have done this and it fixes the problem. I would very much... - [SQLAuthority News - Microsoft SQL Server Management Pack for Microsoft Operations Manager 2005](https://blog.sqlauthority.com/2008/08/21/sqlauthority-news-microsoft-sql-server-management-pack-for-microsoft-operations-manager-2005/): Note:  Download Microsoft Operations Manager 2005 by Microsoft The Microsoft SQL Server Management Pack provides both proactive and reactive monitoring of SQL Server 2008, 2005 and SQL Server 2000 in an enterprise environment. Availability and configuration monitoring, performance data collection, and default thresholds are built for enterprise-level monitoring. Both local and remote connectivity checks help ensure database availability. With the embedded expertise in the SQL Server Management Pack, you can proactively manage SQL Server, and identify issues before they become critical. This Management Pack increases the security, availability, and performance of your SQL Server infrastructure. The Microsoft SQL Server Management Pack... - [SQLAuthority News - Find Your IP Address - What Is My IP Address](https://blog.sqlauthority.com/2008/08/20/sqlauthority-news-find-your-ip-address-what-is-my-ip-address/): While developing often my developers need to know which IP address is of local network when looked from outside. I am working in large outsourcing company and we have local intranet setup. When connecting to remote servers from local system or from remote servers to local system we always want to know our Live IP address. Previously we have used many different methods to know our Live IP but nothing is reliable. External services often go down or provide incorrect information. I have added new feature to my site where any user can visit the page and find out their outgoing... - [SQL SERVER - Disable All the Trigger of Current Database](https://blog.sqlauthority.com/2008/08/19/sql-server-disable-all-the-trigger-of-current-database/): I have previously written article about SQL SERVER – Disable All Triggers on a Database – Disable All Triggers on All Servers. This is alternate method to achieve the same task. Following article is sent by Manish Kaushik. I recommend all of you to read original article along with this article for complete idea. CREATE PROCEDURE [dbo].[DisableAllTriggers] AS DECLARE @string VARCHAR(8000) DECLARE @tableName NVARCHAR(500) DECLARE cur CURSOR FOR SELECT name AS tbname FROM sysobjects WHERE id IN(SELECT parent_obj FROM sysobjects WHERE xtype='tr') OPEN cur FETCH next FROM cur INTO @tableName WHILE @@fetch_status = 0 BEGIN SET @string ='Alter table '+ @tableName + ' Disable trigger all' EXEC (@string)... - [SQL SERVER - Detailed Explanation of Transaction Lock, Lock Type, Avoid Locks](https://blog.sqlauthority.com/2008/08/18/sql-server-detailed-explanation-of-transaction-lock-lock-type-avoid-locks/): Loyal reader of this blog and “Great SQL Expert” Imran Mohammed always have good attitude towards any problem. Many times his answers very interesting to read and details are very accurate. I came across his two interesting comment on this blog and I would like to share this all of you. Priyank asked following question. Can u tell us something about how to find which sql table is having the lock and of what type. also please tell us how to remove a lock from a locked table thanks Priyank Imran Mohammed answered in great depth to this question. I personally... - [SQL SERVER - 2005 - Best Practices Analyzer (August 2008)](https://blog.sqlauthority.com/2008/08/17/sql-server-2005-best-practices-analyzer-august-2008/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. This download is the August 2008 release of SQL Server 2005 Best Practices Analyzer. Download Best Practices Analyzer Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - XML - Split a Delimited String - Generate a Delimited String](https://blog.sqlauthority.com/2008/08/17/sql-server-xml-split-a-delimited-string-generate-a-delimited-string/): SQL Server MVP and my very good friend Jacob Sebastian has written two wonderful articles about SQL Server and XML. I encourage to read this two articles to anybody who are interested in learning SQL and XML. Let us see how to Split a Delimited String. - [SQLAuthority News - Tip of the Minute](https://blog.sqlauthority.com/2008/08/16/sqlauthority-news-tip-of-the-minute/): Since my new personal website is launched I have received many comments and emails regarding new section of Tip of the Minute. Right navigation bar of the my personal website https://www.pinaldave.com/ contains section of the Tip of the Minute. Every time when page is refreshed it displays one new tip related to SQL Server. Few of the tips from the page I am listing here. Avoid unnecessary use of temporary tables. Try to use constraints instead of triggers, rules, and defaults whenever possible. SQL Server agent, allows you to schedule your own jobs and scripts. If any reader who will send... - [SQLAuthority News - Happy Indepedance Day to India](https://blog.sqlauthority.com/2008/08/15/sqlauthority-news-happy-indepedance-day-to-india/): India’s Independence Day is celebrated on August 15 to commemorate its independence on that day in 1947. The day is a national holiday in India. India will celebrate its 61st Independent day on August 15, 2008. Happy Independence Day to India Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Introduction to Online Indexing Operation](https://blog.sqlauthority.com/2008/08/15/sql-server-2008-introduction-to-online-indexing-operation/): When index is created or recreated it usually decreases performance of database. Either SQL takes long time for response or it does not response at all as transactions are blocked. When new table or database goes live it is not possible to find out exactly how many indexes are needed. After running queries on near to production data it is possible to find out which index can perform better. It is important in highly sensitive application to have data always available. SQL Server 2005 and later versions have provided feature called “Online Indexing”. Everytime index is updated it puts lock on... - [SQL SERVER - Get Date Time in Any Format - UDF - User Defined Functions](https://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/): One of the reader Nanda of SQLAuthority.com has posted very detailed script of converting any date time in desired format. I suggest every reader of this blog to save this script in your permanent code bookmark and use it when you need it. Let us learn about User Defined Functions. - [SQLAuthority News - Authors Personal Website Renovate - SQL Centric Website](https://blog.sqlauthority.com/2008/08/13/sqlauthority-news-authors-personal-website-renovate-sql-centric-website/): I am very pleased to announce my newly renovated website. I always liked my previous website as it was “Valid XHTML 1.1” and “Valid CSS 2.0”. Since I become MVP last month I have been receiving many emails where people were expecting more from my personal website. My blog http://www.SQLAuthority.com and my personal website https://www.pinaldave.com/ both are my heavily visited website but there was something missing when connecting them together. New website which went live today has all the missing elements to connect both my blog and website together. New website is also “Valid XHTML 1.1” and “Valid CSS 2.0”. One... - [SQLAuthority News - SQL Server 2008 Pricing and Licensing](https://blog.sqlauthority.com/2008/08/12/sqlauthority-news-sql-server-2008-pricing-and-licensing/): Note: SQL Server 2008 Pricing and Licensing by Microsoft SQL Server licensing and pricing are to intervined subjects and very important. I strongly suggest to use properly licensed SQL Server in any production environment. The concept of licensing can be confusing sometime to new administrators. If there is any confusion one should read following documentation from Microsoft for the purpose of clear idea and understanding. SQL Server 2008 is available under three licensing models: Server plus device client access license (CAL). Requires a license for the computer running the Microsoft server product, as well as CALs for each client device. Server... - [SQLAuthority News - Microsoft SQL Server 2008 Books Online - BOL - English](https://blog.sqlauthority.com/2008/08/12/sqlauthority-news-microsoft-sql-server-2008-books-online-bol-english/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. The Help viewer used by Books Online requires the Microsoft .NET Framework version 2.0. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and... - [SQLAuthority News - SQL Server 2008 Downloads Availables](https://blog.sqlauthority.com/2008/08/11/sqlauthority-news-sql-server-2008-downloads-availables/): SQL Server Compact 3.5 SP1 for Windows Mobile SQL Server Compact 3.5 SP1 for devices Windows Installer (MSI) file contains the CAB files and the DLLs for installing SQL Server Compact 3.5 SP1 on the Windows mobile devices. SQL Server Compact 3.5 SP1 and Synchronization Services for ADO.NET v1.0 SP1 for Windows Desktop SQL Server Compact 3.5 SP1 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP1 and Synchronization Services for ADO.NET version 1.0 SP1 on Windows desktop. SQL Server Compact... - [SQL SERVER - Download and Install Sample Database AdventureWorks 2005 - Detail Tutorial](https://blog.sqlauthority.com/2008/08/10/sql-server-2008-download-and-install-samples-database-adventureworks-2005-detail-tutorial/): Just a day ago I received a question from a reader who just installed SQL Server 2008. After the installation user did not find any sample database along with installation. The user wants to install the sample database which he is very much used to. Let us learn about Sample Database AdventureWorks. - [SQLAuthority News - Microsoft SQL Server ODBC Driver for Linux Available Now](https://blog.sqlauthority.com/2011/12/04/sqlauthority-news-microsoft-sql-server-odbc-driver-for-linux-available-now/): We discussion pretty much everything that DBA do in their daily life. Microsoft SQL Server ODBC Driver for Linux Available Now. - [SQLAuthority News - Download Whitepaper 5 Tips for a Smooth SSIS Upgrade to SQL Server 2012](https://blog.sqlauthority.com/2011/12/03/sqlauthority-news-download-whitepaper-5-tips-for-a-smooth-ssis-upgrade-to-sql-server-2012/): Microsoft SQL Server 2012 Integration Services (SSIS) provides significant improvements in both the developer and administration experience. This article provides tips that can help to make the upgrade to Microsoft SQL Server 2012 Integration Services successful. The tips address editing package configurations and specifically connection strings, converting configurations to parameters, converting packages to the project deployment model, updating Execute Package tasks to use project references and parameterizing the PackageName property. TIP #1: Edit Package Configuration and Data Source after upgrading TIP #2: Convert to project deployment model using Project Conversion Wizard TIP #3: Update Execute Package Task to use project reference... - [SQL SERVER - Effect of SET NOCOUNT on @@ROWCOUNT](https://blog.sqlauthority.com/2011/12/02/sql-server-effect-of-set-no-count-on-rowcount/): Today I had very interesting experience when I was presenting on SQL Server. While I was presenting the session when I ran query SQL Server Management Studio returned message like (8 row(s) affected) and (2 row(s) affected) etc. After a while at one point, I started to prove usage of @@ROWCOUNT function. - [SQL SERVER - Where Can YOU Get My Books - SQL Server Interview Question and Answers](https://blog.sqlauthority.com/2011/12/01/sql-server-where-can-you-get-my-books-sql-server-interview-question-and-answers-2/): Earlier month I released by third book SQL Server Interview Question and Answers. The focus of this book is ‘master the basics’. If you rate yourself 10 out of 10 in SQL Server – this book is not for you but if you want to learn fundamentals or want to refresh your fundamentals this book is for YOU. Earlier I was overwhelmed by love you all have shown to this book on release date leading our three digit inventory to run out of stock. Read detail blog post about the subject over here A Real Story of Book Getting ‘Out of... - [SQL SERVER - Fix: Error: File Cannot be Loaded Because the Execution of Scripts is Disabled on This System](https://blog.sqlauthority.com/2011/11/30/sql-server-fix-error-file-cannot-be-loaded-because-the-execution-of-scripts-is-disabled-on-this-system-please-see-get-help-about_signing-for-more-details/): Yesterday I formatted my computer and did a fresh install as it was due from a long time. After the fresh install when I tried to install Semantic Search application using PowerShell, I was stopped by the following error. The error was related to an execution of scripts.  - [SQL SERVER - Using expressor Composite Types to Enforce Business Rules](https://blog.sqlauthority.com/2011/11/29/sql-server-using-expressor-composite-types-to-enforce-business-rules/): One of the features that distinguish the expressor Data Integration Platform from other products in the data integration space is its concept of composite types, which provide an effective and easily reusable way to clearly define the structure and characteristics of data within your application.  An important feature of the composite type approach is that it allows you to easily adjust the content of a record to its ultimate purpose.  For example, a record used to update a row in a database table is easily defined to include only the minimum set of columns, that is, a value for the key... - [SQLAuthority News - SafePeak's SQL Server Performance Contest - Winners](https://blog.sqlauthority.com/2011/11/28/sqlauthority-news-safepeaks-sql-server-performance-contest-winners/): SafePeak, the unique automated SQL performance acceleration and performance tuning software vendor, announced the winners of their SQL Performance Contest 2011. The contest quite unique: the writer of the best / most interesting and most community liked “performance story” would win an expensive gadget. The judges were the community DBAs that could participating and Like’ing stories and could also win expensive prizes. Robert Pearl SQL MVP, was the contest supervisor. I liked most of the stories and decided then to contact SafePeak and suggested to participate in the give-away and they have gladly accepted the same. The winner of best story... - [SQL SERVER - Powershell - Get a List of Fixed Hard Drive and Free Space on Server](https://blog.sqlauthority.com/2011/11/27/sql-server-powershell-get-a-list-of-fixed-hard-drive-and-free-space-on-server/): Earlier I have written this article SQL SERVER – Get a List of Fixed Hard Drive and Free Space on Server. I recently received excellent comment by MVP Ravikanth. He demonstrated that how the same can be done using Powershell. It is very sweet and quick solution. Here is the powershell script. Run the same in your powershell windows. Get-WmiObject -Class Win32_LogicalDisk | Select -Property DeviceID, @{Name=’FreeSpaceMB’;Expression={$_.FreeSpace/1MB} } | Format-Table -AutoSize Well, I ran this script in my powershell window, it gave me following result – very accurately and easily. Get-WmiObject -Class Win32_LogicalDisk | Select -Property DeviceID, @{Name=’FreeSpaceMB’;Expression={$_.FreeSpace/1MB} } | Format-Table... - [SQL SERVER - Get Directory Structure using Extended Stored Procedure xp_dirtree](https://blog.sqlauthority.com/2011/11/26/sql-server-get-directory-structure-using-extended-stored-procedure-xp_dirtree/): Many years ago I wrote article SQL SERVER – Get a List of Fixed Hard Drive and Free Space on Server where I demonstrated using undocumented Stored Procedure to find the drive letter in local system and available free space. I received question in email from reader asking if there any way he can list directory structure within the T-SQL. When I inquired more he suggested that he needs this because he wanted set up backup of the data in certain structure. Well, there is one undocumented stored procedure exists which can do the same. However, please be vary to use any... - [SQL SERVER - DVM sys.dm_os_sys_info Column Name Changed in SQL Server 2012](https://blog.sqlauthority.com/2011/11/25/sql-server-dvm-sys-dm_os_sys_info-column-name-changed-in-sql-server-2012/): SQL SERVER - DVM sys.dm_os_sys_info Column Name Changed in SQL Server. Let us learn about it in today's blog post. - [SQL SERVER - Solution to Puzzle - Simulate LEAD() and LAG() without Using SQL Server 2012 Analytic Function](https://blog.sqlauthority.com/2011/11/24/sql-server-solution-to-puzzle-simulate-lead-and-lag-without-using-sql-server-2012-analytic-function/): Earlier I wrote a series on SQL Server Analytic Functions of SQL Server 2012. During the series to keep the learning maximum and having fun, we had few puzzles. One of the puzzle was simulating LEAD() and LAG() without using SQL Server 2012 Analytic Function. Please read the puzzle here first before reading the solution : Write T-SQL Self Join Without Using LEAD and LAG. When I was originally wrote the puzzle I had done small blunder and the question was a bit confusing which I corrected later on but wrote a follow up blog post on over here where I describe... - [SQL SERVER - 2012 - Summary of All the Analytic Functions - MSDN and SQLAuthority](https://blog.sqlauthority.com/2011/11/23/sql-server-2012-summary-of-all-the-analytic-functions-msdn-and-sqlauthority/): SQL Server 2012 (RC0 Available here) has introduced new analytic functions. These functions were long awaited and I am glad that they are now here. Before when any of this function was needed, people used to write long T-SQL code to simulate these functions. But now there’s no need of doing so. Having available native function also helps performance as well readability. - [SQL SERVER - Introduction to PERCENTILE_DISC() - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/22/sql-server-introduction-to-percentile_disc-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical function PERCENTILE_DISC(). The book online gives following definition of this function: Computes a specific percentile for sorted values in an entire rowset or within distinct partitions of a rowset in Microsoft SQL Server 2012 Release Candidate 0 (RC 0). For a given percentile value P, PERCENTILE_DISC sorts the values of the expression in the ORDER BY clause and returns the value with the smallest CUME_DIST value (with respect to the same sort specification) that is greater than or equal to P. If you are clear with understanding of the function – no need to read further.... - [SQL SERVER - Puzzle to Win Print Book - Explain Value of PERCENTILE_CONT() Using Simple Example](https://blog.sqlauthority.com/2011/11/21/sql-server-puzzle-to-win-print-book-explain-value-of-percentile_cont-using-simple-example/): From last several days I am working on various Denali Analytical functions and it is indeed really fun to refresh the concept which I studied in the school. Earlier I wrote article where I explained how we can use PERCENTILE_CONT() to find median over here SQL SERVER – Introduction to PERCENTILE_CONT() – Analytic Functions Introduced in SQL Server 2012. Today I am going to ask question based on the same blog post. Again just like last time the intention of this puzzle is as following: Learn new concept of SQL Server 2012 Learn new concept of SQL Server 2012 even if you are... - [SQL SERVER - Introduction to PERCENTILE_CONT() - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/20/sql-server-introduction-to-percentile_cont-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical function PERCENTILE_CONT(). The book online gives following definition of this function: Calculates a percentile based on a continuous distribution of the column value in Microsoft SQL Server 2012 Release Candidate 0 (RC 0). The result is interpolated and might not be equal to any of the specific values in the column. If you are clear with understanding of the function – no need to read further. If you got lost here is the same in simple words – it is lot like finding median with percentile value. Now let’s have fun following query: USE AdventureWorks... - [SQL SERVER - 2012 RC0 Various Resources and Downloads](https://blog.sqlauthority.com/2011/11/19/sql-server-2012-rc0-various-resources-and-downloads/): Microsoft SQL Server 2012 Release Candidate 0 (RC0) Microsoft SQL Server 2012 RC0 enables a cloud-ready information platform that will help organizations unlock breakthrough insights across the organization. Microsoft SQL Server 2012 Express RC Microsoft SQL Server 2012 Express RC0 is a powerful and reliable free data management system that delivers a rich set of features, data protection, and performance for embedded applications, lightweight Web Sites, applications, and local data stores. Microsoft SQL Server 2012 Semantic Language Statistics RC0 The Semantic Language Statistics Database is a required component for the Statistical Semantic Search feature in Microsoft SQL Server 2012 Semantic Language... - [SQL SERVER - Introduction to PERCENT_RANK() - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/18/sql-server-introduction-to-percent_rank-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical functions PERCENT_RANK(). This function returns relative standing of a value within a query result set or partition. It will be very difficult to explain this in words so I’d like to attempt to explain its function through a brief example. Instead of creating a new table, I will be using the AdventureWorks sample database as most developers use that for experiment purposes. Now let’s have fun following query: USE AdventureWorks GO SELECT SalesOrderID, OrderQty, RANK() OVER(ORDER BY SalesOrderID) Rnk, PERCENT_RANK() OVER(ORDER BY SalesOrderID) AS PctDist FROM Sales.SalesOrderDetail WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER... - [SQL SERVER - Puzzle to Win Print Book and Free 30 Days Online Training Material](https://blog.sqlauthority.com/2011/11/17/sql-server-puzzle-to-win-print-book-and-free-30-days-online-training-material/): Yesterday I had asked a simple question SQL SERVER – Puzzle to Win Print Book – Write T-SQL Self Join Without Using LEAD and LAG with keeping two simple intention. We can all learn about new feature of SQL Server 2012 We can learn new feature of SQL Server 2012 while practicing on earlier version of SQL Server. While I was creating question due to copy-paste error the question was not correctly created. In simple word – I made a mistake. This created some confusion and I feel bad about this. Here is what we will do. Please read the question again... - [SQL SERVER - Puzzle to Win Print Book - Write T-SQL Self Join Without Using LEAD and LAG](https://blog.sqlauthority.com/2011/11/16/sql-server-puzzle-to-win-print-book-write-t-sql-self-join-without-using-first-_value-and-last_value/): Last week we asked a puzzle SQL SERVER – Puzzle to Win Print Book – Functions FIRST_VALUE and LAST_VALUE with OVER clause and ORDER BY . This puzzle got very interesting participation. The details of the winner is listed here. In this puzzle we received two very important feedback. This puzzle cleared the concepts of First_Value and Last_Value to the participants. As this was based on SQL Server 2012 many could not participate it as they have yet not installed SQL Server 2012. I really appreciate the feedback of user and decided to come up something as fun and helps learn new... - [SQL SERVER - Introduction to LEAD and LAG - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/15/sql-server-introduction-to-lead-and-lag-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical function LEAD() and LAG(). These functions accesses data from a subsequent row (for lead) and previous row (for lag) in the same result set without the use of a self-join . It will be very difficult to explain this in words so I will attempt small example to explain you this function. Instead of creating new table, I will be using AdventureWorks sample database as most of the developer uses that for experiment. Let us fun following query. USE AdventureWorks GO SELECT s.SalesOrderID,s.SalesOrderDetailID,s.OrderQty, LEAD(SalesOrderDetailID) OVER (ORDER BY SalesOrderDetailID ) LeadValue, LAG(SalesOrderDetailID) OVER (ORDER BY SalesOrderDetailID... - [SQLAuthority News - A Real Story of Book Getting 'Out of Stock' to A 25% Discount Story Available](https://blog.sqlauthority.com/2011/11/14/sqlauthority-news-a-real-story-of-book-getting-out-of-stock-to-a-25-discount-story-available/): As many of my readers may know, I have recently written a few books.  Right now I’d like to talk about SQL Server Interview Questions and Answers (https://blog.sqlauthority.com/sql-server-books/sql-server-interview-questions-and-answers-for-all-database-developers-and-developers-administrators/ ), my newest release. What inspired me to write this book was similar to my motivations for my previous titles – I wanted to help people understand SQL Server concepts and ace interview questions so that they could get a great job they love, as much as I love my own job. If you are new to SQL Server, don’t think I left you out of my book writing efforts. If you are... - [SQL SERVER - CSVExpress and Quick Data Load](https://blog.sqlauthority.com/2011/11/13/sql-server-csvexpress-and-quick-data-load/): One of the newest ETL tools is CSVexpress.com.  This is a program that can quickly load any CSV file into ODBC compliant databases uses data integration.  For those of you familiar with databases and how they operate, the question that comes to mind might be what use this program will have in your life. I have written earlier article on this subject over here SQL SERVER – Import CSV into Database – Transferring File Content into a Database Table using CSVexpress. You might know that RDBMS have automatic support for loading CSV files into tables – but it is not quite... - [SQLAuthority News - Various Microsoft SQL Server Documentations Available for Download](https://blog.sqlauthority.com/2011/11/12/sqlauthority-news-various-microsoft-sql-server-documentations-available-for-download/): Microsoft has recently released various SQL Server related documentation and here I have listed them here for quick reference. - [SQL SERVER - Puzzle to Win Print Book - Functions FIRST_VALUE and LAST_VALUE with OVER clause and ORDER BY](https://blog.sqlauthority.com/2011/11/11/sql-server-puzzle-to-win-print-book-functions-first_value-and-last_value-with-over-clause-and-order-by/): Some time an interesting feature and smart audience makes total difference at places. From last two days, I have been writing on SQL Server 2012 feature FIRST_VALUE and LAST_VALUE. Please read following post before I continue today as this question is based on the same. Introduction to FIRST_VALUE and LAST_VALUE Introduction to FIRST_VALUE and LAST_VALUE with OVER clause As a comment of the second post I received excellent question from Nilesh Molankar. He asks what will happen if we change few things in the T-SQL. I really like this question as this kind of questions will make us sharp and help... - [SQL SERVER - OVER clause with FIRST _VALUE and LAST_VALUE - Analytic Functions Introduced in SQL Server 2012 - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING](https://blog.sqlauthority.com/2011/11/10/sql-server-over-clause-with-first-_value-and-last_value-analytic-functions-introduced-in-sql-server-2012-rows-between-unbounded-preceding-and-unbounded-following/): Yesterday I had discussed two analytical functions FIRST_VALUE and LAST_VALUE. After reading the blog post I received very interesting question. “Don’t you think there is bug in your first example where FIRST_VALUE is remain same but the LAST_VALUE is changing every line. I think the LAST_VALUE should be the highest value in the windows or set of result.” I find this question very interesting because this is very commonly made mistake. No there is no bug in the code. I think what we need is a bit more explanation. Let me attempt that first. Before you do that I suggest you... - [SQL SERVER - Introduction to FIRST _VALUE and LAST_VALUE - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/09/sql-server-introduction-to-first-_value-and-last_value-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical functions FIRST_VALUE() and LAST_VALUE(). This function returns first and last value from the list. It will be very difficult to explain this in words so I’d like to attempt to explain its function through a brief example. Instead of creating a new table, I will be using the AdventureWorks sample database as most developers use that for experiment purposes. Now let’s have fun following query: USE AdventureWorks GO SELECT s.SalesOrderID,s.SalesOrderDetailID,s.OrderQty, FIRST_VALUE(SalesOrderDetailID) OVER (ORDER BY SalesOrderDetailID) FstValue, LAST_VALUE(SalesOrderDetailID) OVER (ORDER BY SalesOrderDetailID) LstValue FROM Sales.SalesOrderDetail s WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER BY s.SalesOrderID,s.SalesOrderDetailID,s.OrderQty... - [SQLAuthority News - Updates on Contests, Books and SQL Server](https://blog.sqlauthority.com/2011/11/08/sqlauthority-news-updates-on-contests-books-and-sql-server/): There are lots of things happening on this blog and I feel sometime it is difficult to keep up. One of the suggestion I keep on receiving if there is a single page where one can visit and know the updates. I did consider of the same at some point but in era of RSS Feed it is difficult to have proper audience to that page. Here are few updates on various contest and books give away in recent time. Combo set of 5 Joes 2 Pros Book – 1 for YOU and 1 for Friend – I have received so... - [SQL SERVER - Introduction to CUME_DIST - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/08/sql-server-introduction-to-cume_dist-analytic-functions-introduced-in-sql-server-2012/): This blog post is written in response to the T-SQL Tuesday post of Prox ‘n’ Funx. This is a very interesting subject. By the way Brad Schulz is my favorite guy when it is about blogging. I respect him as well learn a lot from him. Everybody is writing something new his subject, I decided to start SQL Server 2012 analytic functions series. SQL Server 2012 introduces new analytical function CUME_DIST(). This function provides cumulative distribution value. It will be very difficult to explain this in words so I will attempt small example to explain you this function. Instead of creating... - [SQL SERVER - Video - Performance Improvement in Columnstore Index](https://blog.sqlauthority.com/2011/11/07/sql-server-video-performance-improvement-in-columnstore-index/): I earlier wrote an article about SQL SERVER – Fundamentals of Columnstore Index and it got very well accepted in community. However, one of the suggestion I keep on receiving for that article is that many of the reader wanted to see columnstore index in the action but they were not able to do that. Some of the readers did not install SQL Server 2012 or some did not have good machine to recreate the big table involved in the demo. For the same reason, I have created small video for that. [youtube=http://youtu.be/C-Ay6UxMfMo] I have written two more article on columstore... - [SQL SERVER - Updating Data in A Columnstore Index](https://blog.sqlauthority.com/2011/11/06/sql-server-updating-data-in-a-columnstore-index/): So far I have written two articles on Columnstore Indexes, and both of them got very interesting readership. In fact, just recently I got a query on my previous article on Columnstore Index. Read the following two articles to get familiar with the Columnstore Index. They will give you a reference to the question which was asked by a certain reader: SQL SERVER – Fundamentals of Columnstore Index SQL SERVER – How to Ignore Columnstore Index Usage in Query Here is the reader’s question: ” When I tried to update my table after creating the Columnstore index, it gives me an... - [SQL SERVER - SSMS 2012 Reset Keyboard Shortcuts to Default](https://blog.sqlauthority.com/2011/11/05/sql-server-ssms-2012-reset-keyboard-shortcuts-to-default/): As a technologist, I love my laptop very much and I do not lend it to anyone as I am usually worried that my settings would be messed up when I get it back from its borrower. Honestly, I love how I have set up my laptop and I enjoy the settings and programs I have placed on my computer. If someone changes things there – it will surely be annoying for me. Recently at one of the conferences I was attending in, a small accident happened – one of the speaker’s hard drives failed. The owner immediately panicked due to... - [SQL SERVER 2012 Editions - Highlights of The Cloud-Ready Information Platform](https://blog.sqlauthority.com/2011/11/04/sql-server-2012-editions-highlights-of-the-cloud-ready-information-platform/): Microsoft has just announced SQL Server 2012 Editions information on official SQL Server 2012 site. SQL Server 2012 will be available in three main editions: Enterprise Business Intelligence Standard The other editions are Web, Developer and Express. Here is the salient features of each of the edition: Enterprise Advanced high availability with AlwaysOn High performance data warehousing with ColumnStore Maximum virtualization (with Software Assurance) Inclusive of Business Intelligence edition’s capabilities Business Intelligence Rapid data discovery with Power View Corporate and scalable reporting and analytics Data Quality Services and Master Data Services Inclusive of the Standard edition’s capabilities Standard Standard continues to... - [SQLAuthority News - SQL Server Interview Questions And Answers Book Summary](https://blog.sqlauthority.com/2011/11/04/sqlauthority-news-sql-server-interview-questions-and-answers-book-summary/): Today we are using computers for various activities, motor vehicles for traveling to places, and mobile phones for conversation. How many of us can claim the invention of micro-processor, a basic wheel, or the telegraph? Similarly, this book was not written overnight. The journey of this book goes many years back with many individuals to be thanked for. To begin with, we want to thank all those interviewers who reject interviewees by saying they need to know ‘the key things’ regardless of having high grades in class. The whole concept of interview questions and answers revolves around knowing those ‘key things’.... - [SQLAuthority News - New Book Released - SQL Server Interview Questions And Answers](https://blog.sqlauthority.com/2011/11/03/sqlauthority-news-new-book-released-sql-server-interview-questions-and-answers/): Two days ago, on birthday of my blog – I asked simple question – Guess! What is in this box? I have received lots of interesting comments on the blog about what is in it. Many of you got it absolutely incorrect and many got it close to the right answer but no one got it 100% correct. Well, no issue at all, I am going to give away the price to whoever has the closest answer first in personal email. Here is the answer to the question about what is in the box? Here it is – the box has... - [SQL SERVER - Import CSV into Database - Transferring File Content into a Database Table using CSVexpress](https://blog.sqlauthority.com/2011/11/02/sql-server-import-csv-into-database-transferring-file-content-into-a-database-table-using-csvexpress/): One of the most common data integration tasks I run into is a desire to move data from a file into a database table.  Generally the user is familiar with his data, the structure of the file, and the database table, but is unfamiliar with data integration tools and therefore views this task as something that is difficult.  What these users really need is a point and click approach that minimizes the learning curve for the data integration tool.  This is what CSVexpress (www.CSVexpress.com) is all about!  It is based on expressor Studio, a data integration tool I’ve been reviewing over... - [SQLAuthority News - 5th Anniversary Giveaways](https://blog.sqlauthority.com/2011/11/01/sqlauthority-news-5th-anniversary-giveaways/): Please read my 5th Anniversary post and my quick note on history of the Database. I am sure that we all have friends and we value friendship more than anything. In fact, the complete model of Facebook is built on friends. If you have lots of friends, you must be a lucky person. Having a lot of friends is indeed a good thing. I consider all you blog readers as my friends so now I want do something for you. What is it? Well, send me details about how many of your friends like my page and you would have a... - [SQLAuthority News - History of the Database - 5 Years of Blogging at SQLAuthority](https://blog.sqlauthority.com/2011/11/01/sqlauthority-news-history-of-the-database-5-years-of-blogging-at-sqlauthority/): Don’t miss the Contest:Participate in 5th Anniversary Contest   Today is this blog’s birthday, and I want to do a fun, informative blog post. Five years ago this day I started this blog. Intention – my personal web blog. I wrote this blog for me and still today whatever I learn I share here. I don’t want to wander too far off topic, though, so I will write about two of my favorite things – history and databases.  And what better way to cover these two topics than to talk about the history of databases. If you want to be technical,... - [SQL SERVER - Database Dynamic Caching by Automatic SQL Server Performance Acceleration](https://blog.sqlauthority.com/2011/10/31/sql-server-database-dynamic-caching-by-automatic-sql-server-performance-acceleration/): My second look at SafePeak’s new version (2.1) revealed to me few additional interesting features. For those of you who hadn’t read my previous reviews SafePeak and not familiar with it, here is a quick brief: SafePeak is in business of accelerating performance of SQL Server applications, as well as their scalability, without making code changes to the applications or to the databases. SafePeak performs database dynamic caching, by caching in memory result sets of queries and stored procedures while keeping all those cache correct and up to date. Cached queries are retrieved from the SafePeak RAM in microsecond speed and not send to the SQL Server. The application gets much faster results (100-500 micro seconds), the load on the SQL Server is reduced (less CPU and IO) and the application or the infrastructure gets better scalability. - [SQL SERVER - How to Ignore Columnstore Index Usage in Query](https://blog.sqlauthority.com/2011/10/30/sql-server-how-to-ignore-columnstore-index-usage-in-query/): Earlier I wrote about SQL SERVER – Fundamentals of Columnstore Index and very first question I received in email was as following. “We are using SQL Server 2012 CTP3 and so far so good. In our data warehouse solution we have created 1 non-clustered columnstore index on our large fact table. We have very unique situation but your article did not cover it. We are running few queries on our fact table which is working very efficiently but there is one query which earlier was running very fine but after creating this non-clustered columnstore index this query is running very slow. We... - [SQL SERVER - Fundamentals of Columnstore Index](https://blog.sqlauthority.com/2011/10/29/sql-server-fundamentals-of-columnstore-index/): There are two kind of storage in database. Row Store and Column Store. Row store does exactly as the name suggests – stores rows of data on a page – and column store stores all the data in a column on the same page. These columns are much easier to search – instead of a query searching all the data in an entire row whether the data is relevant or not, column store queries need only to search much lesser number of the columns. This means major increases in search speed and hard drive use. Additionally, the column store indexes are heavily compressed, which translates to even greater memory and faster searches. I am sure this looks very exciting and it does not mean that you convert every single index from row store to columnstore index. One has to understand the proper places where to use row store or column store indexes. Let us understand in this article what is the difference in Columnstore type of index. - [SQLAuthority News - Online Webcast How to Identify Resource Bottlenecks - Wait Types and Queues](https://blog.sqlauthority.com/2011/10/28/sqlauthority-news-online-webcast-how-to-identify-resource-bottlenecks-wait-types-and-queues/): As all of you know I have been working a recently on the subject SQL Server Wait Statistics, the reason is since I have published book on this subject SQL Wait Stats Joes 2 Pros: SQL Performance Tuning Techniques Using Wait Statistics, Types & Queues [Amazon] | [Flipkart] | [Kindle], lots of question and answers I am encountering. When I was writing the book, I kept version 1 of the book in front of me. I wanted to write something which one can use right away. I wanted to create an primer for everybody who have not explored wait stats method... - [SQLAuthority News - SQL Server Wait Stats - eBook to Download on Kindle - Answer to FREE PDF Download Request](https://blog.sqlauthority.com/2011/10/27/sqlauthority-news-sql-server-wait-stats-ebook-to-download-on-kindle-answer-to-free-pdf-download-request/): Being a book author is a completely new experience for me. I am yet to come across the issues faced by expert book authors. I assume that these interesting issues can be routine ones for expert book authors. One of the biggest requests I am getting for my SQL Server Wait Stats [Amazon] | [Flipkart] | [Kindle] book is my humble attempt to write a book. This is our very first experiment, and the book is beginning of the subject of SQL Server Wait Stats; we will come up with a new version of the book later next year when we... - [SQLAuthority News - Book Signing Event - SQLPASS 2011 Event Log](https://blog.sqlauthority.com/2011/10/26/sqlauthority-news-book-signing-event-sqlpass-2011-event-log/): I have been dreaming of writing book for really long time, and I finally got the chance – in fact, two chances!  I recently wrote two books: SQL Programming Joes 2 Pros: Programming and Development for Microsoft SQL Server 2008 [Amazon] | [Flipkart] | [Kindle] and SQL Wait Stats Joes 2 Pros: SQL Performance Tuning Techniques Using Wait Statistics, Types & Queues [Amazon] | [Flipkart] | [Kindle].  I had a lot of fun writing these two books, even though sometimes I had to sacrifice some family time and time for other personal development to write the books. The good side of... - [SQLAuthority News - Meeting SQL Friends - SQLPASS 2011 Event Log](https://blog.sqlauthority.com/2011/10/25/sqlauthority-news-meeting-sql-friends-sqlpass-2011-event-log/): One of the biggest reason I go to SQLPASS is that my friends are going there too. There are so many friends with whom I often talk on Facebook and Twitter but I rarely get time to meet them as well talk with them. One thing I am usually sure that many fo them will be for sure attend SQLPASS. This is one event which every SQL Server Enthusiast should attend. Just like everybody I had pleasant time to meet many of my SQL friends. There were so many friends that I met and I did not click photo. There were... - [SQLAuthority News - Story of Seattle - SQLPASS 2011 Event Log](https://blog.sqlauthority.com/2011/10/24/sqlauthority-news-story-of-seattle-sqlpass-2011-event-log/): Just like every year I attended SQL PASS in Seattle earlier this month. The event was scheduled from Oct 11-14, 2011 in the convention center of the Seattle. I have been to Seattle more than 6 times so far so it is not a new city for me anymore. The city has always impressed me with its vibrant life and pleasant weather. Just like every other time, I had excellent experience once again in the city. Though I just arrived on the day of the event and left right after the event was over – I hardly visited Seattle – still... - [SQL SERVER - Dedicated Access Control for SQL Server Express Edition - An error occurred while obtaining the dedicated administrator connection (DAC) port.](https://blog.sqlauthority.com/2011/10/23/sql-server-dedicated-access-control-for-sql-server-express-edition-an-error-occurred-while-obtaining-the-dedicated-administrator-connection-dac-port/): Recently I had faced very interesting situation. Due to some reason we were not able to login into the production server for one of client. The reason for the same was that server was very busy, we had to login into the system and bring server to normal situation. When all the attempts failed, I decided to login using Dedicated Administrator Connection (DAC). However when I attempted to connect using DAC it threw following error for me. C:\Users\pinald>sqlcmd -A -d master -S .\SQLEXPRESS Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : SQL Server Network Interfaces: An error occurred while obtaining... - [Personal Notes - Random Thoughts and Random Ideas](https://blog.sqlauthority.com/2011/10/22/personal-notes-random-thoughts-and-random-ideas/): There are days when I keep on wondering about SQL, and even my life overall. Let us see some random thoughts and random ideas. - [SQL SERVER - DATEDIFF - Accuracy of Various Dateparts](https://blog.sqlauthority.com/2011/10/21/sql-server-datediff-accuracy-of-various-dateparts/): I recently received the following question through email and I found it very interesting so I want to share it with you. “Hi Pinal, In SQL statement below the time difference between two given dates is 3 sec, but when checked in terms of Min it says 1 Min (whereas the actual min is 0.05Min) SELECT DATEDIFF(MI,'2011-10-14 02:18:58' , '2011-10-14 02:19:01') AS MIN_DIFF Is this is a BUG in SQL Server ?” Answer is NO. It is not a bug; it is a feature that works like that. Let us understand that in a bit more detail. When you instruct SQL... - [SQL SERVER - TRACEWRITE - Wait Type - Wait Related to Buffer and Resolution](https://blog.sqlauthority.com/2011/10/20/sql-server-tracewrite-wait-type-wait-related-to-buffer-and-resolution/): Earlier this year I wrote for a whole month on SQL Server Wait Stats and the series was one of the best reviewed I have ever written. The same series has been enhanced and compiled into a book as SQL Server Wait Stats [Amazon] | [Flipkart] | [Kindle]. The best part of this book is it is an evolving book. I am planning to expand this book at certain intervals. Yesterday I came across a very interesting system, where the top most wait type was TRACEWRITE. The DBA of the system reached out to me asking what this wait types means... - [SQL SERVER - A Simple Quiz - T-SQL Brain Trick](https://blog.sqlauthority.com/2011/10/19/sql-server-a-simple-quiz-t-sql-brain-trick/): Today we are going to have very simple and interesting question. Run following T-SQL Code in SSMS. There are total of five lines. Three T-SQL statements separated by two horizontal lines. SELECT MAX(OBJECT_ID) FROM sys.objects ______________________________________ SELECT MIN(OBJECT_ID) FROM sys.objects ______________________________________ SELECT COUNT(OBJECT_ID) FROM sys.objects Now when you execute individual lines only it will give you error as Msg 2812, Level 16, State 62, Line 1 Could not find stored procedure '______________________________________'. However, when you executed all the five statement together it will give you following resultset. What is the reason of the same? Please leave your comment as answer. I... - [SQL SERVER - Next Version of SQL Server 'Denali' is Officially Named as SQL Server 2012](https://blog.sqlauthority.com/2011/10/18/sql-server-next-version-of-sql-server-denali-is-officially-named-as-sql-server-2012/): Recently I attended SQLPASS 2011 and it had few announcements and some of them really important. I am going to write in detail in future all the announcements. However, there is one announcement needs special attention and blog post. The official name of the next version of the SQL Server. So far we were all addressing the next version of the SQL Server as SQL Server ‘Denali’. Microsoft VP Ted Kummert announced the official name of the next version of the SQL Server – SQL Server 2012. The version of the SQL Server will be 11. The release date is estimated... - [SQLAuthority News - Your Performance Story - My Contribution to Your Learning](https://blog.sqlauthority.com/2011/10/18/sqlauthority-news-your-performance-story-my-contribution-to-your-learning/): I was recently playing with SafePeak‘s performance tuning tool, while I was on their site, I noticed that they have contest running where they are giving away expensive gadgets. The contest has some really nice entries and I few of the participants are my close friends as well. I liked most of the stories. I contacted the contest owners that if I can also participate in the give-away and they have gladly accepted the same. Now you can win my  SQL Programming Joes 2 Pros (vol 4) [Amazon] | [Flipkart] | [Kindle] by participating into the contest. You can share your... - [SQLAuthority News - SafePeak version 2.1 for SQL Server Performance Acceleration](https://blog.sqlauthority.com/2011/10/17/sqlauthority-news-safepeak-releases-a-major-update-safepeak-version-2-1-for-sql-server-performance-acceleration/): Couple of months ago I had the opportunity to share with my first look at SafePeak, a new and unique software solution for improving SQL Server performance and solving bottlenecks, accelerates the data access and cuts the CPU and IO of your SQL Server. SafePeak unique approach not just tells you about the problems but actually resolves them automatically and improves SQL Server performance and the performance of the applications dramatically. Let us read about Performance Acceleration. - [SQL SERVER - Three DMVs - sys.dm_server_memory_dumps - sys.dm_server_services - sys.dm_server_registry](https://blog.sqlauthority.com/2011/10/16/sql-server-denali-three-dmvs-sys-dm_server_memory_dumps-sys-dm_server_services-sys-dm_server_registry/): In this blog post we will see three new DMVs which are introduced in Denali. The DMVs are very simple and there is not much to describe them. So here is the simple game. I will be asking a question back to you after seeing the result of the each of the DMV and you help me to complete this blog post. - [SQLAuthority News - SQL Server 2008 SP3 Available to Download](https://blog.sqlauthority.com/2011/10/15/sqlauthority-news-sql-server-2008-sp3-available-to-download/): This news is one week late but still very useful as per my perspective. Please note this are for SQL Server 2008 and will not work with SQL Server 2008 R2. SQL Server 2008 Service Pack 3 Enhanced upgrade experience from previous versions of SQL Server to SQL Server 2008 SP3. In addition, we have increased the performance & reliability of the setup experience. In SQL Server Integration Services logs will now show the total number of rows sent in Data Flows. Enhanced warning messages when creating the maintenance plan if the Shrink Database option is enabled. Resolving database issue with... - [SQL SERVER - SQLPASS Memory Lane of 2009 and 2010](https://blog.sqlauthority.com/2011/10/14/sql-server-sqlpass-memory-lane-of-2009-and-2010/): Today is the last day of the SQLPASS 2011 and I will be soon posting SQL Server 2011 experience over here. We all change, life change, event changes, experiences change and but memory hardly changes. I have quite commonly noticed that we all remember the good memories for long time and no matter how bad the memories are we often forget the same. Here is my experience of my earlier experience of attending SQLPASS. SQLAuthority News – SQLPASS Nov 8-11, 2010-Seattle – An Alternative Look at Experience SQLAuthority News – Notes of Excellent Experience at SQL PASS 2009 Summit, Seattle Every... - [SQLAuthority News - SQLPASS - Today FREE 100 SQL Wait Stats Book Print Copy - Book Signing](https://blog.sqlauthority.com/2011/10/13/sqlauthority-news-sqlpass-today-free-100-sql-wait-stats-book-print-copy/): “If there’s a book you really want to read, but it hasn’t been written yet, then you must write it.” ~Toni Morrison I wrote book on SQL Wait Stats. [Amazon] | [Flipkart] | [Kindle] I really wanted to learn about SQL Wait Stats. There was no real book available so I wrote the book myself. Since I wrote this book, I feel I can now more 100 pages to what I had contributed. I am very fortunate that my SQL Wait Stats book is very well accepted in community. Every author who authors book has dream that his book is well received... - [SQLAuthority News - SQLPASS - 100 SQL Wait Stats Book Print Copy Giveaway - A Book Every Minute for an Hour Tomorrow](https://blog.sqlauthority.com/2011/10/12/sqlauthority-news-sqlpass-100-sql-wait-stats-book-print-copy-giveaway-a-book-every-minute-for-an-hour-tomorrow/): “Appreciation is a wonderful thing: It makes what is excellent in others belong to us as well” – Voltaire “The greatest of all gifts is the power to estimate things at their true worth” – Francois De La Rochefoucauld Please Note: The date and time are Thursday 13 at 1 PM (not Wednesday) – there are few emails asking for the same. Quotes listed above are really relevant to the news of the day. Regular readers of my blog knows that I have published SQL Server Wait Stats [Amazon] | [Flipkart] book. I am glad to say that this book has... - [SQL SERVER - expressor Studio 3.4 Rules Editor - ETL Graphical Coding Tool](https://blog.sqlauthority.com/2011/10/11/sql-server-expressor-studio-3-4-rules-editor-etl-graphical-coding-tool/): New in the expressor Studio 3.4 release is the rules editor.  This graphical coding tool replaces the transform editor of earlier versions.  The rules editor works in concert with the newly introduced attribute propagation functionality to minimize the amount of data mapping and coding you need to provide.  The expressor folks are telling me that in a future release we will be able to save and reuse rules, which will make everyone’s  application development tasks even simpler and less prone to errors. So what’s attribute propagation?  expressor’s starting point observation is that in any transformation most values are either copied from... - [SQLAuthority News - Why I am Going to Attend PASS Summit Unite 2011 - Seattle](https://blog.sqlauthority.com/2011/10/11/sqlauthority-news-why-i-am-going-to-attend-pass-summit-unite-2011-seattle/): For the third year in a row, I am attending the SQLPASS Summit, October 11-14. Every year I have explained my reasons for attending this conference in Seattle, and this year I will state those reasons again. WHY? I have written two articles on this subject, which you can read here: 2009 and 2010. My main reason for attending has not changed – I love it! Why should I attend PASS Summit? There are not one or two but many reasons why I should be a part of PASS Summit. First, it is a good platform to learn the latest skills... - [SQLAuthority News - Milestone - 1900th Post and 31 Million Views - Thank You!](https://blog.sqlauthority.com/2011/10/10/sqlauthority-news-milestone-1900th-post-and-31-million-views-thank-you/): I really never thought that I would be writing this post - honestly! After 1900th post and almost 5 years, this has been a journey and lots of learning. I get to write a 100 “mile stone” post 3-4 times a year, so I am happy to be writing this one. I am eagerly looking forward to my 2000th blog post as well. - [SQLAuthority News - System Center Monitoring Pack for Microsoft SQL Server 2008 R2 Parallel Data Warehouse Appliance](https://blog.sqlauthority.com/2011/10/09/sqlauthority-news-system-center-monitoring-pack-for-microsoft-sql-server-2008-r2-parallel-data-warehouse-appliance/): Microsoft is continuously releasing System Center Monitoring Pack for Microsoft SQL Server 2008 R2 Parallel Data Warehouse Appliance - [SQLAuthority News - SQL Server Quiz 2011 - All was well few moments before all went wrong - Reasons and Resolutions](https://blog.sqlauthority.com/2011/10/08/sqlauthority-news-sql-server-quiz-2011-all-was-well-few-moments-before-all-went-wrong-reasons-and-resolutions/): I earlier wrote about DBA Quiz at All was well few moments before all went wrong – Reasons and Resolutions. I have even announced that I will give away one print book of SQL Wait Stats book. SQL Programming Joes 2 Pros (vol 4) [Amazon] | [Flipkart]- Chapter 13 has few interesting hints. However, I want to announce one more thing today. I will give giving away not one but 2 copies of the SQL Wait Stats books [Amazon] | [Flipkart] . SQL Wait Stats book is available for very low cost on Kindle at this moment. This is special promotion... - [SQL SERVER - Server Side Paging in SQL Server CE (Compact Edition)](https://blog.sqlauthority.com/2011/10/07/sql-server-server-side-paging-in-sql-server-ce-compact-edition/): SQL Server Denali is coming up with new T-SQL of Paging. I have written about the same earlier. SQL SERVER – Server Side Paging in SQL Server Denali – A Better Alternative SQL SERVER – Server Side Paging in SQL Server Denali Performance Comparison SQL SERVER – Server Side Paging in SQL Server Denali – Part2 What is very interesting is that SQL Server CE 4.0 have the same feature introduced. Here is the quick example of the same. To run the script in the example, you will have to do install Webmatrix 4.0 and download sample database. Once done you... - [SQL SERVER - Detecting Database Case Sensitive Property using fn_helpcollations()](https://blog.sqlauthority.com/2011/10/06/sql-server-detecting-database-case-sensitive-property-using-fn_helpcollations/): In my recent Office Hours, I received a question on how to determine the case sensitivity of the database. Let us learn about how we can Detecting Database Case Sensitive Property using fn_helpcollations(). - [SQLAuthority News - SQL Wait Stats Book - Available as Kindle eBook - October Special](https://blog.sqlauthority.com/2011/10/05/sqlauthority-news-sql-wait-stats-book-available-as-kindle-ebook-october-special/): Get SQL Wait Stats – Kindle Edition Last month I released my SQL Wait Stats  book. This book is the beginning of my journey in wait stats. It has been extremely popular and so far in India it has sold all the print copies twice on Flipkart. This book is available in the United States on Amazon and it has gotten a tremendous response as well. What is special about this book is that it gives you the opportunity to start on performance tuning instantly after receiving the book. The scripts are very simple and they are all available online on... - [SQL SERVER - Quick Note about JOIN - Common Questions and Simple Answers](https://blog.sqlauthority.com/2011/10/04/sql-server-quick-note-about-join-common-questions-and-simple-answers/): This blog post is written in response to the T-SQL Tuesday post of JOIN. This is a very interesting subject. Years ago, I wrote my article about SQL SERVER – Introduction to JOINs – Basic of JOINs, ‑ till date, it is my most favorite article on the blog. Today we are going to talk about join and lots of things related to the JOIN. I recently started office hours to answer questions and issues of the community. I receive so many questions that are related to JOIN. I will share few of the same over here. Most of them are... - [SQL SERVER - CE - 3 Links to Performance Tuning Compact Edition](https://blog.sqlauthority.com/2011/10/04/sql-server-ce-3-links-to-performance-tuning-compact-edition/): Today, I am going to do webcast online on how to improve performance for SQL CE. Here are three articles which I am going to base my session. Database Design and Performance (SQL Server Compact Edition) Use Database Denormalization Decide Between Variable and Fixed-length Columns Create Smaller Row Lengths Use Smaller Key Lengths Publication Article Types and Options Query Performance Tuning (SQL Server Compact Edition) Improve Indexes Choose What to Index Use the Query Optimizer Understand Response Time vs. Total Time Rewrite Subqueries to Use JOIN Use Parameterized Queries Query Only When You Must Optimizing Connectivity (SQL Server Compact Edition) Synchronization... - [SQL SERVER - SQL Backup and FTP - A Quick and Handy Tool](https://blog.sqlauthority.com/2011/10/03/sql-server-sql-backup-and-ftp-a-quick-and-handy-tool/): Scroll down at the end of this post to win my SQL Wait Stats Book. I have used this tool extensively since 2009 at numerous occasion and found it to be very impressive. What separates it from the crowd the most – it is it’s apparent simplicity and speed. When I install SQLBackupAndFTP and configure backups – all in 1 or 2 minutes, my clients are always impressed. To put it simply, SQLBackupAndFTP is MS SQL Server backup software that performs these tasks: Backup SQL Server Database Zip the backups Encrypt the backups FTP the backups to remote FTP server Move... - [SQL SERVER - CE - List of Information_Schema System Tables](https://blog.sqlauthority.com/2011/10/02/sql-server-ce-list-of-information_schema-system-tables/): Yesterday I wrote  blog post that I downloaded WebMatrix and it was very easy to install, after installing I noticed it has default database as SQL CE. I started to play with SQL CE and I was glad that it supports many of the Information_Schema. There is one important thing I need to mention. Yesterday I shared Sample Database of the SQL CE. Few of the readers tried to install that database in other versions and it give them error. Please note that SQL CE will only and will not work with any other version of the database. Here are few... - [SQL SERVER - CE - Samples Database for SQL CE 4.0](https://blog.sqlauthority.com/2011/10/01/sql-server-ce-samples-database-for-sql-ce-4-0/): I recently installed WebMatrix Version Next. I found it very neat and easy to install. You can download it for FREE. After installing it I download when I checked the about page, it displayed following result. ————————— About WebMatrix ————————— Version 2 Beta WebMatrix: 7.1.1307.1 IIS 7.5 Express: 7.1.1307.1 .NET Framework: 4.0.30319.235 (RTMGDR.030319-2300) Web Deploy: 7.1.1307.1 SQL Server Compact: 4.0.8482.1 Web Platform Installer: 7.1.1307.1 ASP.NET Web Pages: 1.0.20105.407 ASP.NET Web Pages: 2.0.10906.0 What got my attention was that when I noticed SQL Server Compact version 4 installed with WebMatrix. As soon as I see this SQL Server CE, I decided to... - [SQL SERVER - Denali - DMV - sys.dm_os_windows_info - Information about Operating System](https://blog.sqlauthority.com/2011/09/30/sql-server-denali-dmv-sys-dm_os_windows_info-information-about-operating-system/): One more quick introduction to DMV for Denali. Following DMV provides information about Windows Operating System. Here is the quick example of the same. This DMV returns information about the operating system volume (directory) on which the specified databases and files are stored. Here is the quick example I have created for the same. SELECT * FROM sys.dm_os_windows_info; Here is the screenshot of the same: Here is my question back to you – where would you use this stored procedure in your application? What is your preferred method to know details about Windows? One last question – what is 1033 in... - [SQL SERVER - Denali - DMV - sys.dm_os_volume_stats - Information about operating system volume](https://blog.sqlauthority.com/2011/09/30/sql-server-denali-dmv-sys-dm_os_volume_stats-information-about-operating-system-volume/): SQL Server Denali has many new interesting feature – one of the interesting feature is New DMVs. This DMV returns information about the operating system volume (directory) on which the specified databases and files are stored. Here is the quick example I have created for the same. SELECT DB_NAME(f.database_id) DatabaseName, f.FILE_ID, size DBSize, file_system_type, volume_mount_point, total_bytes, available_bytes FROM sys.master_files AS f CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.FILE_ID); Here is the screenshot of the same: In the result set we can see the file system and volume database is mounted on as well database size. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Various Ways to Stay in Touch with SQLAuthority.com - Best Practices](https://blog.sqlauthority.com/2011/09/29/sqlauthority-news-various-ways-to-stay-in-touch-with-sqlauthority-com-best-practices/): Social Media is growing and quite commonly we reach to the point where we have confusion about the various aspects of the same. I have written a previous article on this subject SQLAuthority News – Social Media Confusion – Twitter, FaceBook, LinkedIn and Me. I am present and active at so many spots that many wonder on how to approach me. I have decided to create this blog post, which will serve as a quick guide for others regarding how to stay in touch with SQLAuthority.com My Personal Coordinates Twitter: https://mobile.twitter.com/pinaldave Facebook: LinkedIn: https://www.linkedin.com/in/pinaldave Email: pinal ‘at’ SQLAuthority.com Blog Coordinates Facebook:... - [SQL SERVER - Denali - DMV Enhancement - sys.dm_exec_query_stats - New Columns](https://blog.sqlauthority.com/2011/09/28/sql-server-denali-dmv-enhancement-sys-dm_exec_query_stats-new-columns/): SQL Server version next Denali has lots of enhancements. Some of the enhancements are just game changing and overcomes needs of more coding to do the same thing. Similar function DMV is sys.dm_exec_query_stats. There are four new columns added to this DMV. I have often used this DMV to check recently ran query, their execution plan by joining more DMVs to it. However, there was also need of knowing how many rows my queries have returned. This DMV is enhanced with four more queries. total_rows – Total number of rows returned by query last_rows – Number of the rows return by... - [SQLAuthority News - Tomorrow Online Session - Ancient Trade of Performance Tuning - Index, Beyond Index and No Index](https://blog.sqlauthority.com/2011/09/28/sqlauthority-news-tomorrow-online-session-ancient-trade-of-performance-tuning-index-beyond-index-and-no-index/): Today in few hours I am going to present on my very favorite subject of performance tuning. You can read more about this sessions over here. This presentation is based on the famous book ‘The Art of War’ written in sixth century BC by Sun Tzu. Index is usually a favorite tool of many when it is about performance tuning. However, Index is not everything. Performance tuning is much very deep subject and one needs to understand various aspect of the performance tuning. In today’s session I will cover performance tuning beyond indexes. I have created some real interesting demos. Sessions... - [SQLAuthority News - 31 Millions Views - Free 5 Print Copy of SQL Wait Types and Queues](https://blog.sqlauthority.com/2011/09/27/sqlauthority-news-31-millions-views-free-5-print-copy-of-sql-wait-types-and-queues/): Earlier this year in February, I wrote a 30-day series on Wait Types and Queue. This series was very popular and I have received a number of good and encouraging comments on various parts of the series. The no.1 request was to compile the concept in an eBook. This idea really appealed to me. Talking about personal preferences, I do not like eBooks as I spend lots of time on the computer, and if I have to read books, I prefer to read printed ones my way. Driven with the same idea, I published SQL Wait Types and Queues in print... - [SQLAuthority News - Online Session - Ancient Trade of Performance Tuning - Index, Beyond Index and No Index](https://blog.sqlauthority.com/2011/09/26/sqlauthority-news-online-session-ancient-trade-of-performance-tuning-index-beyond-index-and-no-index/): Performance Tuning has been my favorite subject always. I love this subject the most. I personally have enjoyed every aspect of performance tuning. Quite often I have seen that when it is about performance, people end up talking about Indexes. Index for sure can help performance, but it is like secret weapon and it must be used carefully as the same thing can be dangerous. I have personally attended many sessions that are related to Indexes as well as how to identify the correct index and remove useless indexes. I always wanted Indexing presentation to bring much more than these usual... - [SQL SERVER - Denali - Startup Parameters Easy to Configure](https://blog.sqlauthority.com/2011/09/26/sql-server-denali-startup-parameters-easy-to-configure/): If you are regular reader of this blog, you must be aware that I have written about SQL Server Denali recently. I just finished a writing about various functions of Denali SQL SERVER – Denali – 14 New Functions – A Quick Guide. While working with Denali, at one point, I wanted to change the startup limits of the Denali. While working with Denali, I saw a very convenient method of changing the startup parameters. I just loved this clear way of changing the start up parameters. Here is the quick way to reach to the screen where we can change... - [SQLAuthority News - Learn SQL Azure at Microsoft Virtual Academy](https://blog.sqlauthority.com/2011/09/25/sqlauthority-news-learn-sql-azure-at-microsoft-virtual-academy/): The Microsoft Virtual Academy offers no-cost, easy-access training for IT professionals who want to get ahead in cloud computing. Developed by leading experts in this field, these modules ensure that you acquire essential skills and gain credibility as the cloud computing specialist in your organization. MVA guides you through real-life deployment scenarios and the latest cloud computing technologies and tools. By selecting the training modules that match your needs, you can use valuable new skills that help take your career to the next level. - [SQL SERVER - Denali - Download CTP3 Demo VHD Including Fully Configured Services and Integration with SharePoint 2010 and Office 2010](https://blog.sqlauthority.com/2011/09/24/sql-server-denali-download-ctp3-demo-vhd-including-fully-configured-services-and-integration-with-sharepoint-2010-and-office-2010/): During my office hours observed, a very common question is”What is Denali?” once I answer that Denali is the next version of the SQL Server, the follow up question is where can I download it. I have explained the installation and download part over here: SQL SERVER – Denali CTP3 – Step by Step Installation Video – 200 Seconds . Most of the feature of the Denali can be just experienced as it is on native T-SQL. However, to experience all the features of the SQL Server Denali CTP3, one needs SharePoint 2010 and Office 2010. Microsoft has build VHD which... - [Puzzle - Usage of New Index Hints - ForceSeek and ForceScan](https://blog.sqlauthority.com/2011/09/23/puzzle-usage-of-new-index-hints-forceseek-and-forcescan/): Tomorrow is the weekend. I just thought, let us explore something new but a quick puzzle to explore about index hints. SQL Server Denali has new Query Hint - FORCESCAN. In earlier version of SQL Server we already have Query Hint FORCESEEK but now the counter part also exists. The quick understanding is there will be cases when FORCESEEK or FORCESCAN will be helpful and improve the performance of the query. - [SQL SERVER - Learning SSAS (SQL Server Analysis Services) Online in 6 Hours - Top Down Designing and Bottom Up Designing](https://blog.sqlauthority.com/2011/09/22/sql-server-learning-ssas-sql-server-analysis-services-online-in-6-hours-top-down-designing-and-bottom-up-designing/): Those who are following me on Twitter and Facebook know that recently I am reenforcing my own concept for SQL Server Analysis Services (SSAS). Like many of us, I worked with Analysis Services in early years. In an earlier job, I got many projects for relational database performance tuning and over time, I lost touch with SSAS. This does not mean that I forgot all of the concepts but the ‘real’ hands-on experience was gathering dust. Looking back at the last five years, I realized that I have deep experience with relational performance tuning but there are a few new things which I have yet to explore and learn. - [SQLAuthority News - Latest expressor Data Integration Platform Posts](https://blog.sqlauthority.com/2011/09/22/sqlauthority-news-latest-expressor-data-integration-platform-posts/): Here is the quick summary of my recent blog post which I have written while I am experimenting expressor data Integration platform. SQL SERVER – Introduction to expressor 3.4 Lookup Tables In this blog post, I am going to take a closer look at expressor’s new and extremely versatile implementation of lookup tables, which they are releasing as part of the upcoming expressor 3.4 product release. SQL SERVER – Introduction to expressor Datascript Modules With the release of expressor 3.3, expressor software has added a significant new feature to the expressor Studio tool – the ability to easily extend functionality through... - [SQL SERVER 2012 Functions - 14 New Functions - A Quick Guide](https://blog.sqlauthority.com/2011/09/21/sql-server-denali-14-new-functions-a-quick-guide/): Last two weeks I wrote various blog posts on new functions introduced in SQL Server 2012. So many comments and request I have received from various readers that they would like to see everything together. I have put up a quick guide here where I am writing all the 14 new SQL Server 2012 Functions linking them to my blog post as well Book On-Line for a quick reference. - [SQL SERVER - Denali - Date and Time Functions - EOMONTH() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/20/sql-server-denali-date-and-time-functions-eomonth-a-quick-introduction/): In SQL Server Denali, seven new datetime functions have been introduced, namely, DATEFROMPARTS (year, month, day) DATETIME2FROMPARTS (year, month, day, hour, minute, seconds, fractions, precision) DATETIMEFROMPARTS (year, month, day, hour, minute, seconds, milliseconds) DATETIMEOFFSETFROMPARTS (year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision) SMALLDATETIMEFROMPARTS (year, month, day, hour, minute) TIMEFROMPARTS (hour, minute, seconds, fractions, precision) EOMONTH (start_date) EOMONTH() is a very interesting function. It is a very common requirement in many major applications where the user needs the last day of the month. It is very easy to figure out what is the first day of the month because obviously,... - [SQL SERVER 2012 - DateTime Functions - DATEFROMPARTS() - DATETIMEFROMPARTS() - DATETIME2FROMPARTS()](https://blog.sqlauthority.com/2011/09/19/sql-server-2012-datetime-functions-datefromparts-datetimefromparts-datetime2fromparts-timefromparts-smalldatetimefromparts/): In SQL Server 2012, there are seven new datetime functions being introduced, namely: DATEFROMPARTS ( year, month, day) DATETIME2FROMPARTS ( year, month, day, hour, minute, seconds, fractions, precision ) DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds ) DATETIMEOFFSETFROMPARTS ( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision ) SMALLDATETIMEFROMPARTS ( year, month, day, hour, minute ) TIMEFROMPARTS ( hour, minute, seconds, fractions, precision ) EOMONTH () - [SQLAuthority News - Implementing a Microsoft SQL Server Parallel Data Warehouse Using the Kimball Approach](https://blog.sqlauthority.com/2011/09/18/sqlauthority-news-implementing-a-microsoft-sql-server-parallel-data-warehouse-using-the-kimball-approach/): This white paper explores how the Kimball approach to architecting and building a data warehouse/business intelligence (DW/BI) system works with Microsoft’s Parallel Data Warehouse, and how you would incorporate this new product as the cornerstone of your DW/BI system. For readers who are not familiar with the Kimball approach, we begin with a brief overview of the approach and its key principles. We then explore the Parallel Data Warehouse (PDW) system architecture and discuss its alignment with the Kimball approach. In the last section, we identify key best practices and pitfalls to avoid when building or migrating a large data warehouse... - [SQLAuthority News - Automation of Data Mining Using Integration Services](https://blog.sqlauthority.com/2011/09/18/sqlauthority-news-automation-of-data-mining-using-integration-services/): This article is a walkthrough that illustrates how to build multiple related data models by using the tools that are provided with Microsoft SQL Server Integration Services. In this walkthrough, you will learn how to automatically build and process multiple data mining models based on a single mining structure, how to create predictions from all related models, and how to save the results to a relational database for further analysis. Finally, you view and compare the predictions, historical trends, and model statistics in SQL Server Reporting Services reports. This solution also introduces the concept of ensemble models for data mining, which... - [SQL SERVER - Denali - String Function - FORMAT() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/17/sql-server-denali-string-function-format-a-quick-introduction/): In SQL Server Denali, there are two new string functions being introduced, namely: CONCAT() FORMAT() Today we will quickly take a look at the FORMAT() function. FORMAT converts the first argument to specified format and returns the string value. This function is locale-aware and it can return the formatting of the datetime and number to as per the locale specified string. This function also uses the server .NET Framework and CLR. I was personally waiting for this function for long time and inclusion of this function made me very happy as this single function will solve lots of formatting issues for... - [SQL SERVER 2012 - String Function CONCAT() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/16/sql-server-denali-string-function-concat-a-quick-introduction/): In SQL Server 2012, there are two new string functions being introduced, namely: CONCAT(), FORMAT(). In this blog post we are going to learn about String Function CONCAT(). CONCAT takes a minimum of two arguments to concatenate them, resulting to a single string. - [SQLAuthority News - Uncut and Unedited - Interview of Pinal Dave on Book Authoring](https://blog.sqlauthority.com/2011/09/15/sqlauthority-news-uncut-and-unedited-interview-of-pinal-dave-on-book-authoring/): I was very happy when books were published and I got a print copy in my hand. In this blog post we will discuss about Book Authoring. - [SQL SERVER - Introduction to expressor 3.4 Lookup Tables](https://blog.sqlauthority.com/2011/09/14/sql-server-introduction-to-expressor-3-4-lookup-tables/): In this blog post, I am going to take a closer look at expressor’s new and extremely versatile implementation of lookup tables, which they are releasing as part of the upcoming expressor 3.4 product release.  As creation and use of the lookup table can be managed completely through simple-to-use graphical interfaces, it is very easy to utilize this feature in expressor data integration applications.  And for developers who want full control over the functionality, an API provides direct access to the table allowing their applications to read, write, update, and delete table content.  Let’s see how this all comes together! The... - [SQL SERVER - Denali - New Functions and Shorthand for CASE Statement](https://blog.sqlauthority.com/2011/09/13/sql-server-denali-new-functions-and-shorthand-for-case-statement-2/): This blog post is written in response to the T-SQL Tuesday post of Data Presentation. This is a very interesting subject. I recently started to write about Denali Logical and Comparison functions. I really enjoyed writing about new functions, but there was one question kept cropping up – is the CASE statement being replaced with this new functions. The answer is NO. New functions that are introduced are just shorthand for the CASE statement, and they are not replacing anything. 1) TRY_PARSE() is not replacing the CASE statement, infect it is not. However, it can be smartly used along with the... - [SQL SERVER - Denali CTP3 - Step by Step Installation Video - 200 Seconds](https://blog.sqlauthority.com/2011/09/12/sql-server-denali-ctp3-step-by-step-installation-video-200-seconds/): My recent article on SQL SERVER – Download Denali CTP3 and Denali CTP 3 Product Guide has inspired today’s post. After reading this blog post, I received a few emails and few comments on facebook page that if I can post a video guide to Denali CTP3 installation. Finally I create this video which is about how one can install SQL Server Denali CTP3. There is no audio in this video as the video is very simple and one can understand it quite easily. [youtube=http://www.youtube.com/watch?v=lb0uVSGjD1w] Click here to watch the Denali CTP3 Installation Video on YouTube. Let me know if you like... - [SQL SERVER - DBA Quiz 2011 - All was well few moments before all went wrong - Reasons and Resolutions](https://blog.sqlauthority.com/2011/09/12/sql-server-dba-quiz-2011-all-was-well-few-moments-before-all-went-wrong-reasons-and-resolutions/): My question just got published at DBA Quiz 2011. This question is inspired from a real life incident, which occurred to me a few years ago. That time, I was a DBA myself and then one fine day, everything went south. When we checked the log, all the logs were fine till few minutes before our server started to face the issue. After working for long hours, we fixed the issue. Our CTO had called us to analyze the situation. Instead of blaming anyone, he adorned an extremely positive attitude. He suggested that we all go out and come back with... - [SQL SERVER 2012 - Logical Function CHOOSE() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/11/sql-server-denali-logical-function-choose-a-quick-introduction/): In SQL Server 2012, there are two new logical functions being introduced, namely: IIF() and CHOOSE(). Today we will quickly take a look at the logical CHOOSE() function. This function is very simple and it returns specified index from a list of values. If Index is numeric, it is converted to integer. On the other hand, if the index is greater than the element in the list, it returns NULL. - [SQL SERVER - Denali - Logical Function - IIF() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/10/sql-server-denali-logical-function-iif-a-quick-introduction/): In SQL Server Denali, there are two new logical functions being introduced, namely: IIF() CHOOSE() Today, we will have a look at the IIF() function. This function does not need any introduction as developers have used this function in various languages from ages. This function is shorthand way for writing CASE statement. These functions take three arguments. If the first argument is true, it will return the second argument as result or it will return the third argument as result. IIF can be nested as well, which makes its usage very interesting. The limit of nesting of IIF is same as... - [SQL SERVER - Denali - Conversion Function - Difference between PARSE(), TRY_PARSE(), TRY_CONVERT()](https://blog.sqlauthority.com/2011/09/09/sql-server-denali-conversion-function-difference-between-parse-try_parse-try_convert/): In SQL Server Denali, three new conversion functions have been introduced, namely, PARSE() TRY_PARSE() TRY_CONVERT() - [SQL SERVER - Denali - Conversion Function - TRY_CONVERT() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/08/sql-server-denali-conversion-function-try_convert-a-quick-introduction/): In SQL Server Denali, there are three new conversion functions being introduced, namely: PARSE() TRY_PARSE() TRY_CONVERT() Today we will quickly take a look at the TRY_CONVERT() function. The TRY_CONVERT() function is very similar to CONVERT function which is avail in SQL Server already. Only difference is that it will attempt to CONVERT the datatype in specified datatype and while doing the same, if it fails (or error occurs) instead of displaying error it will return value NULL. Function CONVERT() is same as in earlier version (as far as I know till CTP3). Now let us examine these examples showing how TRY_CONVERT()... - [SQL SERVER - Few Notes on Fast Track Data Warehouse](https://blog.sqlauthority.com/2010/09/05/sql-server-few-notes-on-fast-track-data-warehouse/): I recently delivered fast track data warehouse training. This training was very challenging as this training requires very specific hardware and extremely different way of looking at data warehousing. While training I have made few notes and I will now share the same notes with you. Please note that this are just notes and not learning material. Fast Track Data Warehouse has a primary emphasis on eliminating potential performance bottlenecks. It supports maximum of 48 TB data at this moment. Currently HP, Dell, Bull, IBM and EMC2 provides necessary hardware for Fast Track Data Warehouse. All the Software and Hardware comes... - [SQLAuthority News - Social Media Confusion - Twitter, FaceBook, LinkedIn and Me](https://blog.sqlauthority.com/2010/09/04/sqlauthority-news-social-media-confusion-twitter-facebook-linkedin-and-me/): No story today – I am sure all of you know what I want to talk today. I am indeed not happy with how social media is evolving. There was a time when every social media has its own style and concept. Today wherever I go, I see the same thing. Same news, same update and same old thing. I see now a days not much difference between Twitter, FaceBook and LinkedIn. They all have lost their meaning. Here is what I see the use of social media. Twitter: For short update of what exactly you are doing right now. Not... - [SQL SERVER - Soft Delete - IsDelete Column - Your Opinion](https://blog.sqlauthority.com/2010/09/03/sql-server-soft-delete-isdelete-column-your-opinion/): Just a day ago, I was reading the blog post of Michale J Swart. If you are a regular reader of this blog, I am sure you will be familiar with him. He is a very interesting blogger for sure. He recently wrote an article about Ten Things I hate to See in T-SQL; it was really fun, but the thing which caught my eyes was the subject of isDeleted Column. First of all, let me say that I totally agree with his view point. Let me re-produce what Michale exactly suggests. “Deleted records aren’t deleted. Look, they’re right there!” You... - [SQLAuthority News – SQL Server Health Check Service – Speed UP SQL Server](https://blog.sqlauthority.com/2010/09/02/sqlauthority-news-sql-server-health-check-service-speed-up-sql-server/): In my earlier article SQLAuthority News – Training and Consultancy and Travel – Story of Last 30 Days I had mentioned that I prefer to do 50% consultation and 50% training. Since then I often receive what do I do consultation for and what is my expertise. I am basically man of the performance tuning. I love to tune servers and I love to speed up queries. I often get queries what do I do when I go to performance tuning. Here I am listing my complete service descriptions. This whole exercise can be done remotely as well on site. The... - [SQLAuthority News - Fathers and Daughters](https://blog.sqlauthority.com/2010/09/01/sqlauthority-news-fathers-and-daughters/): Today I am very happy as my daughter is one year old. I have no words to explain how lucky I am to be father of daughter. She is everything to me and my wife have (sweet) complain that I stopped paying attention to her since our daughter has arrived. Check out here one year old photographs. There is special bond between fathers and daughters. An year ago here is the comment I have received from Solid Quality Mentors Global CEO Fernando G. Guerrero wrote to me in email. “What a wonderful gift. Someone told me once that if I had... - [SQLAuthority News - A Monthly Roundups of SQLAuthority Blog Posts - Updated 2019](https://blog.sqlauthority.com/2010/08/31/sqlauthority-news-a-monthly-roundups-of-sqlauthority-blog-posts-updated-2019/): Monthly roundups are very refreshing as it gives me a chance to go back and see what did I do last month. Let us learn in this blog post. - [SQLAuthority News - SQL Server Performance Optimization - Seminar Series](https://blog.sqlauthority.com/2010/08/30/sqlauthority-news-sql-server-performance-optimization-seminar-series/): I am very glad that I will be presenting my very first seminar training series worldwide. This event is called the Solid Quality DIRECTIONS Seminar Series. I am very fortunate that I am given this opportunity to work under prestigious organizations. I have been with Solid Quality Mentors for more than a year now. I have learned a lot and I have grown a lot through this group. While working for Solid Quality, I have conducted many training events and various consultations projects. I can say that I have collected and kept with me all the wisdom and knowledge related to... - [SQLAuthority News - Download - SQL Server Monitoring Management Pack](https://blog.sqlauthority.com/2010/08/29/sqlauthority-news-download-sql-server-monitoring-management-pack/): The SQL Server Management Pack provides the capabilities for Operations Manager 2007 SP1 and R2 to discover SQL Server 2005, 2008, and 2008 R2. It monitors SQL Server components such as database engine instances, databases, and SQL Server agents. The monitoring provided by this management pack includes performance, availability, and configuration monitoring, performance data collection, and default thresholds. You can integrate the monitoring of SQL Server components into your service-oriented monitoring scenarios. In addition to health monitoring capabilities, this management pack includes dashboard views, extensive knowledge with embedded inline tasks, and views that enable near real-time diagnosis and resolution of detected... - [SQL SERVER - Plan Cache - Retrieve and Remove - A Simple Script](https://blog.sqlauthority.com/2010/08/28/sql-server-plan-cache-retrieve-and-remove-a-simple-script/): I had a very interesting situation at my recent performance tuning project. I realize that the developers there were running very large dataset queries on their production server randomly. I got alarmed so I suggested their developer not to do that on the production server; instead, they could create some alternate scenarios where they could synchronize database and query on the same server. The production server should not be used for development work. It should be queried with proper methods (queries, Stored Procedures, etc.), supporting production application. - [SQL SERVER - Getting Started with Execution Plans](https://blog.sqlauthority.com/2010/08/27/sql-server-getting-started-with-execution-plans/): Execution Plans is one of the most interesting subjects and I often get a question about it. Many people want to know how to get started. - [SQL SERVER – Adding Column is Expensive by Joining Table Outside View – Limitation of the Views Part 2](https://blog.sqlauthority.com/2010/08/26/sql-server-adding-column-is-expensive-limitation-of-the-views-part-2/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Note: I have updated the title based on feedback of Davide Mauri (Solid Quality Mentors). Thank you for your help. Let’s see another reason why I do not like Views. Regular queries or Stored Procedures give us flexibility when we need another column; we can add a column to regular queries right away. If we want to do the same with Views, we will have to modify them first. This means any query that does... - [SQL SERVER - Does Order of Column in WHERE Clause Matter?](https://blog.sqlauthority.com/2010/08/25/sql-server-deos-order-of-column-in-where-clause-matter/): Today is a quick puzzle time. Let us learn about - Does the order of column used in WHERE clause matter for performance? Let us learn today. - [SQLAuthority News - Download Microsoft SQL Server Migration Assistant](https://blog.sqlauthority.com/2010/08/24/sqlauthority-news-download-microsoft-sql-server-migration-assistant/): SSMA for Oracle v4.2 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from Oracle to SQL Server 2005, SQL Server 2008 or SQL Server 2008 R2. SSMA for Access v4.2 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from Access to SQL Server 2005, SQL Server 2008, SQL Server 2008 R2 and SQL Azure. SSMA for MySQL v1.0 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL... - [SQLAuthority News - Feedback Received for Virtual Tech Days Sessions on Spatial Database](https://blog.sqlauthority.com/2010/08/24/sqlauthority-news-feedback-received-for-virtual-tech-days-sessions-on-spatial-database/): I recently got opportunity to speak at Virtual Tech Days on August 18, 2010 on the subject Spatial Database. The event was heavily attended by enthusiasts world wide. I delivered session the on the subject of Spatial Database and it was great fun to deliver the session. I have delivered similar session many times before but delivering online is always wonderful experience and it is indeed fun. I got the feedback right away from the organizers and it is above the average of data track. Session Name: Developing with SQL Server Spatial and Deep Dive into Spatial Indexing Adj. LM Attendance:... - [SQL SERVER – ORDER BY Does Not Work – Limitation of the Views Part 1](https://blog.sqlauthority.com/2010/08/23/sql-server-order-by-does-not-work-limitation-of-the-views-part-1/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Recently, I was about the limitations of views. I started to make a list and realized that there are many limitations of the views. Let us start with the first well-known limitation. Order By clause does not work in View. I agree with all of you  who say that there is no need of using ORDER BY in the View. ORDER BY should be used outside the View and not in the View. This example is... - [SQL SERVER - Computed Columns - Index and Performance](https://blog.sqlauthority.com/2010/08/22/sql-server-computed-columns-index-and-performance/): This is the last article in the series of the computed columns I have been writing. Here are previous articles. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER – Computed Column – PERSISTED and Performance – Part 2 This article talks about how non-persisted columns give better performance than PERSISTED columns. SQL SERVER – Computed Column and Performance... - [SQL SERVER – Computed Column – PERSISTED and Storage – Part 2](https://blog.sqlauthority.com/2010/08/21/sql-server-computed-column-persisted-and-storage-part-2/): I am really enjoying writing about computed column and its effect in terms of storage. Before I go on with this topic, I suggest you read the earlier articles about computed column to get the complete context. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns.... - [SQL SERVER – Function to Retrieve First Word of Sentence – String Operation](https://blog.sqlauthority.com/2010/08/20/sql-server-function-to-retrieve-first-word-of-sentence-string-operation/): I have sent of function library where I store all the UDF I have ever written. Recently I received email from my friend requesting if I have UDF which manipulate string and returns only very first word of the statement. Well, I realize that I do not have such a script at all. I found myself writing down this similar script after long time. Let me know if you know any other better script to do the same task. DECLARE @StringVar VARCHAR(100) SET @StringVar = ' anything ' SELECT CASE CHARINDEX(' ', LTRIM(@StringVar), 1) WHEN 0 THEN LTRIM(@StringVar) ELSE SUBSTRING(LTRIM(@StringVar), 1,... - [SQL SERVER - Negative Identity Seed Value and Negative Increment Interval](https://blog.sqlauthority.com/2010/08/19/sql-server-negative-identity-seed-value-and-negative-increment-interval/): Let us learn today about Negative Identity Seed Value and Negative Increment Interval. I have also included a video in this blog post. - [SQL SERVER - Download SQL Server 2008 Interview Questions and Answers Complete List](https://blog.sqlauthority.com/2010/08/18/sql-server-download-sql-server-2008-interview-questions-and-answers-complete-list/): I was getting many request to update SQL Server Interview Questions and Answers I had written couple of years ago. I have modified the original document a bit and corrected few of the typos and errors. I have really enjoyed going over all the Interview Questions and Answers. It has been the most popular subject always on this blog. I am in process of updating that with few new questions and answers I have received from industry experts. Please provide your feedback on how we can further improve them or what kind of questions and answers would like to include in... - [SQLAuthority News - Speaking Online at Virtual Techdays - Aug 18, 2010 - Spatial Datatypes](https://blog.sqlauthority.com/2010/08/17/sqlauthority-news-speaking-online-at-virtual-techdays-aug-18-2010-spatial-datatypes/): I am honored that I have been invited to speak at Virtual TechDays on Aug 18, 2010 by Microsoft. I will be speaking on my favorite subject of Spatial Datatypes. This exclusive Online event will have 30 deep technical sessions per day – and, attendance is completely FREE. There are dedicated tracks for Architects, Software  Developers / Project Managers, Infrastructure Managers / Professionals and Enterprise Developers. Register for the event over here. Date and Time : August 18, 2010, 4:15pm – 5:15pm Developing with SQL Server Spatial and Deep Dive into Spatial Indexing Microsoft SQL Server 2008 delivers new spatial data... - [SQL SERVER - Finding the Occurrence of Character in String](https://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/): This article is written in response to provide hint to TSQL Beginners Challenge 14. The challenge is about counting the number of occurrences of characters in the string. Here is quick method how you can count occurrence of character in any string. Here is quick example which provides you two different details. How many times the character/word exists in string? How many total characters exists in Occurrence? Let us see following example and it will clearly explain it to you. DECLARE @LongSentence VARCHAR(MAX) DECLARE @FindSubString VARCHAR(MAX) SET @LongSentence = 'My Super Long String With Long Words' SET @FindSubString = 'long' SELECT... - [SQLAuthority News - Bookmark Link for Sync Framework for SQL Azure](https://blog.sqlauthority.com/2010/08/15/sqlauthority-news-bookmark-link-for-sync-framework-for-sql-azure/): I have been looking for good tutorial for Sync Framework for SQL Server. There was quite a bit demand of the product. I have received quite a few request as well. I finally found good list of the link of Sync Framework. The links are listed below. Introduction to Sync Framework Introduction to Sync Framework Database Synchronization Understanding Scopes Microsoft Sync Framework Power Pack for SQL Azure Walkthrough Microsoft Sync Framework Power Pack for SQL Azure Synchronizing Databases I have found above links from the document Sync Framework for SQL Azure. The document talks about sync framework and also included supplemented... - [SQLAuthority News - Why SQL Server is better than any other RDBMS Applications?](https://blog.sqlauthority.com/2010/08/14/sqlauthority-news-why-sql-server-is-better-than-any-other-rdbms-applications/): Earlier I had announced contest on blog where I gave away two MSDN Subscriptions to person who has provided best comment on the subject of “Why SQL Server is better than any other RDBMS Applications?” I have received tremendous response to the contest. I got many responses, it was extremely difficult to announce the winner and I requested help of two SQL Server MVPs to help me out with the results. Here is the winner of the contest. They really spend good time and wrote about their feeling for SQL Server product. Here is their answers. I strongly suggest that you... - [SQL SERVER – Computed Column and Performance – Part 3](https://blog.sqlauthority.com/2010/08/13/sql-server-computed-column-and-performance-part-3/): I am really enjoying writing about computed column and its effect in terms of performance. Before continuing this article, I suggest you read the earlier articles on the same subject to get the complete context. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER... - [SQL SERVER – SHRINKDATABASE For Every Database in the SQL Server](https://blog.sqlauthority.com/2010/08/12/sql-server-shrinkdatabase-for-every-database-in-the-sql-server/): I was recently called to attend the Query Tuning Project. I had a very interesting experience in this event. I would like to share to you what actually happened. Note: If you are just going to say that shrinking database is bad, I agree with you and that is the main point of this blog post. Please read the whole blog post first. The problem definition of the consultation was to improve the performance of the database server. I usually fly to the client’s location a day before, so the next day I am all fresh upon reaching the client’s office... - [SQLAuthority News - MSDN Subscription Giveaway Announced](https://blog.sqlauthority.com/2010/08/11/sqlauthority-news-msdn-subscription-giveaway-announced/): Last Month received following “NOT FOR SALE” subscription of Microsoft Visual Studio 2010 Ultimate with MSDN. As a MVP, MCT I already have free subscription to MSDN and TechNet. I plan to give away this free subscription to someone who is need of the same or can use it the best. I have already given away two of the subscription to someone who can really use them. In fact, they have reported me where and how they are using the subscription. This gives me great satisfaction. I have announced one subscription for all of you my reader to win. Top SQL... - [SQL SERVER - Best Practices for DBA Before Taking Vacation](https://blog.sqlauthority.com/2010/08/10/sql-server-best-practices-for-dba-before-taking-vacation/): This blog post is written in response to T-SQL Tuesday hosted by Jason Brimhall. Everybody wants to take a vacation. Who does not love vacation, anyway? However, it seems that it has been getting more and more difficult to take vacation recently. There are two reasons why a person is not able to enjoy his vacation. First is due to company policies (bad boss!), and second is your responsibilities. Well, I cannot guide you much about company policy issues simply because I cannot do something about it. I have a wonderful boss and I have been taking many vacations, doing a... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool New v1.2](https://blog.sqlauthority.com/2010/08/09/sqlauthority-news-risk-health-assessment-program-microsoft-sql-server-scoping-tool-new-v1-2/): Risk and Health Assessment Program for Microsoft SQL Server helps reduce business risks associated with downtime, performance bottlenecks, and the complexities of deploying and managing an enterprise-level, data management solution. You can read more about Risk and Health Assessment Program for Microsoft SQL Server in the datasheet over  here. Microsoft has released recently the tool for its Premier Customers. This tool provides all the necessary details to prepare and qualify any environment to receive a risk and health assessment Program for Microsoft SQL Server. You can download Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2 from... - [SQLAuthority News - SQL Server Monitoring Management Pack Download](https://blog.sqlauthority.com/2010/08/09/sqlauthority-news-sql-server-monitoring-management-pack-download/): Microsoft has SQL Server Health monitoring tool, which I have noticed that many of us do not give it a try. Microsoft has released Monitoring management pack download recently and it does plenty of the task, which normally one would like to do. Instead of going for third party tool, I suggest you give it a try. Following text is produced directly from original MSDN page from here. The SQL Server Management Pack provides the capabilities for Operations Manager 2007 SP1 and R2 to discover SQL Server 2005, 2008, and 2008 R2. It monitors SQL Server components such as database engine... - [SQLAuthority News - Microsoft SQL Server 2008 R2 Report Builder 3.0](https://blog.sqlauthority.com/2010/08/08/sqlauthority-news-microsoft-sql-server-2008-r2-report-builder-3-0/): Microsoft has recently released Microsoft SQL Server 2008 R2 Report Builder 3.0. This version is enhancement to earlier versions by adding many new features. It provides an intuitive report authoring environment for business and power users. It supports the full capabilities of SQL Server 2008 R2 Reporting Services. The download provides a stand-alone installer for Report Builder 3.0. Report Builder 3.0 introduces additional visualizations including maps, sparklines and databars which can help produce new insights well beyond what can be achieved with standard tables and charts. The Report Part Gallery is also included in this release – taking self-service reporting to... - [SQLAuthority News – Community Tech Days, Ahmedabad – July 24, 2010](https://blog.sqlauthority.com/2010/08/07/sqlauthority-news-community-tech-days-ahmedabad-july-24-2010/): Community Tech Days are a series of events in my city. Ahmedabad Community is one of the best communities I have ever come across in this world. People are genius, very kind and very patient. They are not shy to ask any questions and I could see their keen desire to learn and absorb new technology. My special thanks to the Community because without them, this event series would not be possible. - [SQL SERVER - Parallelism Query in Database](https://blog.sqlauthority.com/2010/08/06/sql-server-parallelism-query-in-database/): I recently came across two interesting questions asked by Feodor over here. He has asked very interesting questions. Please check them as follows: If I have a dual core computer and I would like to get a query executed with parallelism in order to test it, how would I do that? You can use the AdventureWorks database and let me know if you can get a query to execute in parallel. I am running machine which has 2 different cores. I was able to reproduce the parallel query using following T-SQL Script. USE AdventureWorks GO SELECT * FROM Sales.SalesOrderDetail sod INNER... - [SQLAuthority News – SQL Data Camp, Chennai, July 17, 2010 – A Huge Success](https://blog.sqlauthority.com/2010/08/05/sqlauthority-news-sql-data-camp-chennai-july-17-2010-a-huge-success/): I had great pleasure to attend very first SQL Data Camp at Chennai on July 17, 2010. This event was very unique as this was very first one-day SQL Event in whole Indian Subcontinent. The event was blast as there were so many back–to-back SQL Sessions with SQL Server MVPs. I was fortunate to present two different sessions at the SQL Data Camp in Chennai. I must express my special thanks to event organizers Sugesh, Deepak and Vidyasagar for organizing such a wonderful event. Every participant who was attending the event had a great time and expressed their passion for SQL... - [SQL SERVER - Computed Column - PERSISTED and Performance - Part 2](https://blog.sqlauthority.com/2010/08/04/sql-server-computed-column-persisted-and-performance-part-2/): This is the third article in the series which I am writing on Persisted Columns. I suggest you read following two article first before continuing on this article. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER – Computed Column – PERSISTED and Performance... - [SQL SERVER - Computed Column - PERSISTED and Performance](https://blog.sqlauthority.com/2010/08/03/sql-server-computed-column-persisted-and-performance/): This is the list of the all the articles in the series of computed column. - [SQLAuthority News - T-SQL Challenges and Hints and Suggestions](https://blog.sqlauthority.com/2010/08/02/sqlauthority-news-t-sql-challenges-and-hints-and-suggestions/): Those who read my blog are for sure know my very good friend Jacob Sebastian. He is SQL Server MVP and founder of wonderful site T-SQL Challenges. No matter how expert we are, challenges are made to make us think and try to go to next level. There are certain people who writes always challenging code, however there are many who are yet not expert but the passion of T-SQL is on them. Jacob has many wonderful ideas and T-SQL challenge is his contribution to community, where he helps community to think, help them to mentor and help them to become one better coder. - [SQL SERVER – Introduction to BINARY_CHECKSUM and Working Example](https://blog.sqlauthority.com/2010/08/01/sql-server-introduction-to-binary_checksum-and-working-example/): In one of the recent consultancy, I was asked if I can give working example of BINARY_CHECKSUM. This is usually used to detect changes in a row. If any row has any value changed, this function can be used to figure out if the values are changed in the rows. However, if the row is changed from A to B and once again changed back to A, the BINARY_CHECKSUM cannot be used to detect the changes. Let us see quick example of the of same. Following example is modified from the original example taken from BOL. USE AdventureWorks; GO -- Create... - [SQLAuthority News - A Monthly Round Up of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/07/31/sqlauthority-news-a-monthly-round-up-of-sqlauthority-blog-posts-2/): This month was very interesting month for me. I visited 2 different countries – Malaysia and Sri Lanka. I had great time attending 3 community sessions – Chennai, Kuala Lumpur and Ahmedabad. Though, I was at home only 5 nights, I was fortunate enough to spend good amount of the time with family as well. My family traveled along with me to different countries as well few of my business trips.I also have few good news in this week. SQLAuthority News – I am a MVP and I Love SQL Server SQLAuthority News – I am Microsoft Certified Trainer (MCT) SQLAuthority... - [SQL Tips - 5 SQL Server Best Practices](https://blog.sqlauthority.com/2010/07/30/sqlauthority-news-authors-birthday-5-sql-server-best-practices/): In this blog post we will see 5 SQL Server Best Practices. Backup Master. I am going to have a backup of the database using script; however, the backup script has not been updated for a long time now. - [SQL SERVER - Check Advanced Server Configuration](https://blog.sqlauthority.com/2010/07/29/sql-server-check-advanced-server-configuration/): I was recently asked following question about how to Check Advanced Server Configuration. - [SQLAuthority News - 2 Sessions at TechInsight 2010 - June 29 - July 1, 2010](https://blog.sqlauthority.com/2010/07/28/sqlauthority-news-2-sessions-at-techinsight-2010-june-29-july-1-2010/): Earlier this month, I got the opportunity to visit Malaysia for community sessions on June 29 – July 1, 2010 at Kuala Lumpur, Malaysia, which I would consider as valuable experience. I presented two different sessions at the event. The event was extremely popular in local community, and I had great time meeting people in Malaysia. I must say that the best thing about Kuala Lumpur is the people and their response. Techinsights is a major technology conference to network with like-minded peers and also up-skill your knowledge on latest technologies. An event that offers opportunity to dabble in hardcore technologies... - [SQL SERVER - Computed Column - PERSISTED and Storage](https://blog.sqlauthority.com/2010/07/27/sql-server-computed-column-persisted-and-storage/): This is the list of the all the articles in the series of computed column. - [SQL SERVER – FIX: ERROR: 8170 Insufficient result space to convert uniqueidentifier value to char](https://blog.sqlauthority.com/2010/07/26/sql-server-fix-error-8170-insufficient-result-space-to-convert-uniqueidentifier-value-to-char/): I just came across very simple error and the solution was even simpler. While concatenating NEWID to another varchar string, I had to CONVERT/CAST it to VARCHAR and I accidentally put length of VARCHAR to 10 instead of 36. It displayed following error. Msg 8170, Level 16, State 2, Line 1 Insufficient result space to convert uniqueidentifier value to char. - [SQLAuthority News - Last 2 Day to Win MSDN Subscription - Total 2 to Win](https://blog.sqlauthority.com/2010/07/25/sqlauthority-news-last-2-day-to-win-msdn-subscription-total-2-to-win/): Today is the last day to win MSDN subscription on this blog. SQL Server MVP Madhivanan is known name. As there are more than 150 comments, I had requested him to help me out with deciding the winner. After looking at the quality responses, he has for sure accepted to hep me out with the deciding the winner but also added one more subscription from his side. This leads to total 2 of the subscription to win. Today is the last day to participate in the content. However, as we have added one more subscription on very last day, we have... - [SQLAuthority News - The story of the world - Spatial Data types - July 24, 2010](https://blog.sqlauthority.com/2010/07/24/sqlauthority-news-the-story-of-the-world-spatial-data-types-july-24-2010/): Today I will be speaking on the subject of Spatial Database at Community Tech Days at Ahmedabad. The event is absolutely FREE. We have so far received 500+ RSVP but there are only limited 250 seats are available. We are doing our best to inform everybody about their registration status. If you have received confirmation email, I suggest that you come in early enough to reserve the place. - [SQL SERVER - Find Queries using Parallelism from Cached Plan](https://blog.sqlauthority.com/2010/07/24/sql-server-find-queries-using-parallelism-from-cached-plan/): I recently came across wonderful blog post of Feodor Georgiev. He is one fine developer and like to dwell in the subject of performance tuning and query optimizations. He is one real genius and original blogger. Recently I came across his wonderful script, which I was in fact writing myself and I found out that he has already posted the same query over here. After getting his permission I am reproducing the same query on this blog. Note to not run the following script on busy transactional production environment as well, it does not get all historical results as it only... - [SQLAuthority News - Funny Technology Quotes - Humor](https://blog.sqlauthority.com/2010/07/23/sqlauthority-news-guest-post-walkthrough-on-creating-wcf-data-service-odata-and-consuming-in-windows-7-mobile-application/): I am including a few of the interesting quotes today. Let us see Funny Technology Quotes. Here are few interesting new lessons. - [SQLAuthority News - SolidQ Journal Released - A Must Read for All](https://blog.sqlauthority.com/2010/07/22/sqlauthority-news-solidq-journal-released-a-must-read-for-all/): SQL Server is one of the most popular products of Microsoft and a large amount of quality content is available online. Solid Quality Mentors have together built a superior quality journal, which contains the best of the best authentic articles from renowned experts of SQL Server. When I downloaded SolidQ Journal, the very first feeling I got was like that of old days of reading technology magazines online. Very soon, I was busy reading the articles one by one and did not realize that I spend nearly 3 hours on single sitting reading the entire journal. After reading it completely, I... - [SQL SERVER - Win USD 11,899 worth MSDN Subscription 5 Days to go](https://blog.sqlauthority.com/2010/07/21/sql-server-win-usd-11899-worth-msdn-subscription-5-days-to-go/): Few days ago, I had posted content SQLAuthority News – FREE Microsoft Visual Studio 2010 Ultimate with MSDN. It has received tremendous response to them. This competition is still open for 5 more days. I am sure you can win the subscription if you leave the best comment. Win $ 11,899 worth Price You need to answer one simple question: You need to answer one simple question: Why SQL Server is better than any other RDBMS applications? Please do not leave comments in this thread, leave at original thread over here. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SELECT * FROM dual - Dual Equivalent](https://blog.sqlauthority.com/2010/07/20/sql-server-select-from-dual-dual-equivalent/): This blog post is for all the Oracle developers who keep on asking for the lack of “dual” table in SQL Server. Here is a quick note about DUAL table, in an easy question-and-answer format. What is DUAL in Oracle? Dual is a table that is created by Oracle together with data dictionary. It consists of exactly one column named “dummy”, and one record. The value of that record is X. You can check the content of the DUAL table using the following syntax. SELECT * FROM dual It will return only one record with the value ‘X’. What is the... - [SQL SERVER - Identifying Statistics Used by Query](https://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/): “Can I know which statistics were used by my query?” Recently, someone asked this question in my training class of query optimization and performance tuning. I really liked the question. The answer for me is very simple. “No.” Well, if I stop here suggesting only “No,” it will be an incomplete answer. Let us continue a bit more. There is no direct method or DVM or any tool which can tell us which statistics were used by any query. In fact, it looks like there is no way one can know if the any created statistics was ever used or not.... - [SQLAuthority News - SQL Server Quickstart Downloads from Microsoft](https://blog.sqlauthority.com/2010/07/18/sqlauthority-news-sql-server-quickstart-downloads-from-microsoft/): Here are few recent published by Microsoft. Application Platform Optimization SQL Server Migration QuickStart The SQL Server Migration QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to help you get details about how to approach your customers who want to improve the return on investment from their data platforms by migrating to SQL Server from their existing Oracle or Sybase platforms. Application Platform Optimization SQL Server Consolidation QuickStart The SQL Server Consolidation QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to present to customers who... - [SQLAuthority News - Community TechDays, Ahmedabad - July 24, 2010](https://blog.sqlauthority.com/2010/07/17/sqlauthority-news-community-techdays-ahmedabad-july-24-2010/): Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Build real connections with Microsoft experts and community members, and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. What more… you can watch some of these sessions LIVE online from the comfort of your workstation as well. The event registration site is here. I will be speaking on the subject. SQL Server – The story of the world – Spatial Data types Speaker: Pinal Dave Event Date: 24th July 2010 Session Time:... - [SQL SERVER - Datetime Function TODATETIMEOFFSET Example](https://blog.sqlauthority.com/2010/07/16/sql-server-datetime-function-todatetimeoffset-example/): Earlier I wrote about SQL SERVER – Datetime Function SWITCHOFFSET Example. After reading this blog post, I got another quick reply that if I can explain the usage of TODATETIMEOFFSET as well. - [SQL SERVER - Datetime Function SWITCHOFFSET Example](https://blog.sqlauthority.com/2010/07/15/sql-server-datetime-function-switchoffset-example/): I was recently asked if I know how SWITCHOFFSET works. This feature only works in SQL Server 2008. Here is quick definition of the same from BOL: Returns a datetimeoffset value that is changed from the stored time zone offset to a specified new time zone offset. What essentially it does is that changes the current offset of the time to any other offset which we defined. Let us see the example of the same. SELECT SYSDATETIMEOFFSET() GetCurrentOffSet; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '-04:00') 'GetCurrentOffSet-4'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '-02:00') 'GetCurrentOffSet-2'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+00:00') 'GetCurrentOffSet+0'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+02:00') 'GetCurrentOffSet+2'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+04:00') 'GetCurrentOffSet+4'; Now let us... - [SQLAuthority News - Two SQL Sessions at SQL Data Camp at Chennai - July 17, 2010](https://blog.sqlauthority.com/2010/07/14/sqlauthority-news-two-sql-sessions-at-sql-data-camp-at-chennai-july-17-2010/): I will be presenting two SQL Server advance level sessions at SQL Data Camp @ Chennai. I am very excited for this event as I am going to meet my friends Sugesh, Deepak, Vidhya and Madhivanan at this event. All of them are SQL Server MVPs. I have come to know that there are two other SQL Server MVPs – Madhu andVenkatesh are also joining the event as speaker. This is going to be one mega fest as so many of SQL Server MVPs are going to be present at same place. The event is going to be world-class event and... - [SQL SERVER - How do I Learn and How do I Teach](https://blog.sqlauthority.com/2010/07/13/sql-server-how-do-i-learn-and-how-do-i-teach/): This blog post is written in response to T-SQL Tuesday hosted by Robert L Davis (aka SQLSoldier). The blog post has raised three very interesting questions. How do you learn? How do you teach? What are you learning or teaching? Let me try to answer the same. How do I learn? This question is very interesting. I have written a blog post on the very same subject few days ago when I completed my 1400th blog post. Learning is a continuous process and it never ends. There are many different ways through which one can learn. Looking back, when I was... - [SQLAuthority News - FREE Microsoft Visual Studio 2010 Ultimate with MSDN](https://blog.sqlauthority.com/2010/07/12/sqlauthority-news-free-microsoft-visual-studio-2010-ultimate-with-msdn/): I just received following “NOT FOR SALE” subscription of Microsoft Visual Studio 2010 Ultimate with MSDN. As a MVP, MCT I already have free subscription to MSDN and TechNet. I plan to give away this free subscription to someone who is need of the same or can use it the best. You can win the subscription. I will pick the winner of the subscription on 25th of the July. Which means you have 10 days to take part. I will decide the winner with the help of fellow MVPs and subject matter experts. You need to answer one simple question: Why... - [SQL SERVER - Parallelism - Row per Processor - Row per Thread - Thread 0](https://blog.sqlauthority.com/2010/07/11/sql-server-parallelism-row-per-processor-row-per-thread-thread-0/): Earlier I had posted article answering question. “When SQL Server executes any query on multiple processors, do all processors process equal numbers of rows?” Read the answer over SQL SERVER – Parallelism – Row per Processor – Row per Thread. In the same article, I had asked back to readers as well. “If you look carefully in the Properties window or XML Plan, there is “Thread 0″. What does this “Thread 0” indicate?” Here is the answer of the question, many thanks to all of you and special mention to Marko Parkkola, who has answered first and the answer is very detailed.... - [SQLAuthority News - Milestone - 1400th Post and Why do I blog](https://blog.sqlauthority.com/2010/07/10/sqlauthority-news-milestone-1400th-post-and-why-do-i-blog/): I am very glad today that I have reached milestone of 1400th post. I was looking back to my journey which I started on Nov 1, 2006 and I feel that it has been long way. I have noticed a lot of changes in myself too. Earlier, I used to write a milestone post every time I reach either 1 million views or when I am writing the 100th post. I noticed that such “milestones” started happening quite often; so I decided to write about such milestones on every 100th post. Well, this limited the number of such milestone posts to... - [SQLAuthority News - I am a MVP and I Love SQL Server](https://blog.sqlauthority.com/2010/07/09/sqlauthority-news-i-am-a-mvp-and-i-love-sql-server/): I am very glad that I received this prestigious award for the third time in a row. I am very thankful to Microsoft for introducing this wonderful technology of SQL Server. I enjoy getting involved with the community, which also helps in my self-improvement as well. I would like to take this moment to thank all my friends, readers, session attendees, MS Product Teams, MVP Program and my Organization for the constant support and encouragement. There are few questions that I often receive about the MVP program. Today, I will answer them in brief. Microsoft MVP Logo Question: How can I become a... - [SQL SERVER - The Self Join - Inner Join and Outer Join ](https://blog.sqlauthority.com/2010/07/08/sql-server-the-self-join-inner-join-and-outer-join/): Self Join has always been an note-worthy case. It is interesting to ask questions on self join in a room full of developers. I often ask – if there are three kind of joins, i.e.- Inner Join, Outer Join and Cross Join; what type of join is Self Join? The usual answer is that it is an Inner Join. In fact, it can be classified under any type of join. I have previously written about this in my interview questions and answers series. I have also mentioned this subject when I explained the joins in detail over SQL SERVER – Introduction... - [SQL SERVER - Upper Case Shortcut SQL Server Management Studio](https://blog.sqlauthority.com/2010/07/07/sql-server-upper-case-shortcut-sql-server-management-studio/): Few days ago, I received code which is very similar to code shown below. select * from Sales.SalesOrderDetail where ProductID > 777 I am not the guy who go crazy for formatting but I do appreciate proper coding. I like if the code was formatted like below. SELECT * FROM Sales.SalesOrderDetail WHERE ProductID > 777 The fastest way one can do this in SSMS is either search and replace or using SSMS short cut to covert keywords to upper case. What I do is I select the word and hit CTRL+SHIFT+U and it SSMS immediately changes the case of the selected... - [SQLAuthority News - I am Microsoft Certified Trainer (MCT) ](https://blog.sqlauthority.com/2010/07/06/sqlauthority-news-i-am-microsoft-certified-trainer-mct/): I am a Microsoft Certified Trainer and I am very much proud of it. Because I am a MCT, I have the support of great community leaders and trainers who help me constantly to improve in what I do. I have many Microsoft Certifications and I constantly try to take more of these. Every time, a new certification is announced, I make sure to add it to my list of existing ones. This post is written to make the community aware that how sometimes strict bureaucracy guidelines can create issues and a very well-confirmed project can crash. Those who know me... - [SQL SERVER – PowerShell Version Info](https://blog.sqlauthority.com/2010/07/05/sql-server-powershell-version-info/): I have multiple computer systems at home. I have previously taken a picture of my home office and published it here. Also, I recently had a scenario where I was listing a PowerShell version installed in my computer systems. While searching online, I found two different commands that can determine the version of PowerShell. One of them worked fine in Version 1, while both worked on Version 2. The commands are: $PSVersionTable and $host I have run both the commands on different PowerShell versions and found the following output. This is a call to all PowerShell experts to help me out... - [SQL SERVER - Index Levels, Page Count, Record Count and DMV - sys.dm_db_index_physical_stats](https://blog.sqlauthority.com/2010/07/04/sql-server-index-levels-page-count-record-count-and-dmv-%c2%a0sys-dm_db_index_physical_stats/): In the recent Query Tuning project, one of the developers who were helping me out in the project asked me if there is any way that he could know how many pages are used by any Index,  and if there is any way I could demonstrate the different levels of B-Tree. The following is the diagram on Clustered Index that I have quickly drawn using MS Word for the said developer. Clustered Index B-Tree Let us quickly see the diagram of B-Tree and how the levels are set up. The leaf level is always considered as Level 0. There can be... - [SQL SERVER - View XML Query Plans in SSMS as Graphical Execution Plan](https://blog.sqlauthority.com/2010/07/03/sql-server-view-xml-query-plans-in-ssms-as-graphical-execution-plan/): Earlier I wrote a blog post on SQL SERVER – Parallelism – Row per Processor – Row per Thread, where I mentioned the XML Plan. As a follow up on the blog post, I received the request to send the same execution plan so that the blog readers can also use the same and reproduce it on their machine. I realized that I have actually never written on how one can send a graphical execution plan to another user so that they can reproduce the same exact details without all the actual tables, indexes and objects. Here is very simple method... - [SQL SERVER - Parallelism - Row per Processor - Row per Thread](https://blog.sqlauthority.com/2010/07/02/sql-server-parallelism-row-per-processor-row-per-thread/): Here is a question I received via email: “When SQL Server executes any query on multiple processors, do all processors process equal numbers of rows?” I find this one very interesting. I quickly wrote down a query which can run on multiple CPU in my machine. My laptop has a Core 2 Duo processor and has two CPUs. When I ran the query, I found out from the execution plan that there is a parallelism operator, which runs my query in both CPUs. I pressed F4 to see the Properties of the execution plan. You can open the Properties window by... - [SQL SERVER - Introduction to Best Practices Analyzer - Quick Tutorial](https://blog.sqlauthority.com/2010/07/01/sql-server-introduction-to-best-practices-analyzer-quick-tutorial/): I previously wrote about SQLAuthority News – Download – Microsoft SQL Server 2008 R2 Best Practices Analyzer earlier and since then I have received many emails requesting to explain how it works. I assume that you can download and install the tool successfully. Once done just follow the steps listed below. You will be successfully able to test multiple instances of SQL Server using this tool. Once the tool is launched, select the product you wish to analysis. Click on Start Scan will take few minutes to analysis the server. Select the appropriate features to include the analysis in report. I... - [SQLAuthority News - A Monthly Round Up of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/06/30/sqlauthority-news-a-monthly-round-up-of-sqlauthority-blog-posts/): Last month I wrote monthly round up and I was very well received. For the same here it goes this months wrote up for all the SQLAuthority.com blogs. The month started very interesting subject of SQL SERVER – Precision of SMALLDATETIME – A 1 Minute Precision which lead to few datetime related blog posts. I find them very interesting and hopefully you will too. SQL SERVER – Difference Between GETDATE and SYSDATETIME SQL SERVER – Difference Between DATETIME and DATETIME2 SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE Another interesting blog post series was on the subject how SQL... - [SQL SERVER - Outer Join Not Allowed in Indexed Views](https://blog.sqlauthority.com/2010/06/29/sql-server-outer-join-not-allowed-in-indexed-views/): I recently received an email that contains a question from one of my readers. I have already replied the answer to his email, but I would still like to bring it to your attention and ask if you think I could have done any better with the example I gave. The question was raised when the email sender read the white paper, Improving Performance with SQL Server 2008 Indexed Views. If you scroll all the way down through the said white paper, there are several questions and answers. Q: Why can’t I use OUTER JOIN in an Indexed view? A: Rows... - [SQLAuthority News - Exam 70-433 - MCTS - Microsoft SQL Server 2008, Database Development](https://blog.sqlauthority.com/2010/06/29/sqlauthority-news-exam-70-433-mcts-microsoft-sql-server-2008-database-development/): I often receive lots of questions regarding how to pass SQL Server Certification exams. I have previously written about the road map over SQL SERVER – Roadmap of Microsoft Certifications – SQL Server Certifications. I have tremendous respect for Microsoft Certification and I enjoy the preparation phase as well as attending the real exam. The real value is after passing the exams as I am always sure that during the whole process, I have learned something new and my knowledge has been updated. Prometric Testing Center Experience: I had a Prometric voucher for one free exam, which was expiring on June... - [SQL SERVER - Default Statistics on Column - Automatic Statistics on Column](https://blog.sqlauthority.com/2010/06/28/sql-server-default-statistics-on-column-automatic-statistics-on-column/): During the SQL Server Training, I frequently noticed confusion in people in terms of Statistics. Many people have no idea on how Statistics works. There are so many misconceptions with respect to Statistics. I recently had an interesting conversation with one attendee who believed that Statistics only exists on Column if there is an Index on the Column, or if we explicitly create Statistics on it. - [SQLAuthority News – Announcing Winners of the Office 2010 Giveaway](https://blog.sqlauthority.com/2010/06/27/sqlauthority-news-announcing-winners-of-the-office-2010-giveaway/): Thank you all for participating in Office 2010 giveaway. After carefully evaluation following user is announced as the winner. The question was as following. Choose best option: With which Microsoft Office Product Powerpivot is associated? Options: 1) PowerPoint 2) Excel 3) Word The answer was suppose to be most creative and informative. Many congratulations to the winner of the Office Giveaway. Winning comment by Sagar. PowerPivot refers to a collection of applications and services that provide an end-to-end solution for creating and sharing business intelligence using Excel and SharePoint. As SharePoint is not the option answer is ‘EXCEL’. PowerPivot for Excel... - [SQL SERVER - Fast Track Data Warehouse for SQL Server 2008](https://blog.sqlauthority.com/2010/06/26/sql-server-fast-track-data-warehouse-for-sql-server-2008/): I recently attended a wonderful training session organized by Microsoft on Fast Track Data Warehouse Reference Architectures. If you are regular reader of my blog, you will be well aware of the fact that I am more of the Relational guy than a Business Intelligence professional. I was initially a bit skeptic about this training. However, once I start learning about it, to my surprise, I thought that I am the perfect guy to learn this. In fact, I realized that few of the tricks which this course is suggesting have already been implemented in my earlier consulting assignments. Fast Track... - [SQLAuthority News – Download – Microsoft SQL Server 2008 R2 Best Practices Analyzer](https://blog.sqlauthority.com/2010/06/25/sqlauthority-news-download-microsoft-sql-server-2008-r2-best-practices-analyzer/): Microsoft has released wonderful tool SQL Server 2008 R2 Best Practices Analyzer. I have previously used this tool and found it quite helpful. Here is the latest version which you can download from MS site. Microsoft SQL Server 2008 R2 Best Practices Analyzer However, I received quite a few emails that users are not able to install it after downloading this tool. There is nothing wrong with this tool but there are two prerequisites which are needed. I am additionally listing the download link to all of them here with. Microsoft Baseline Configuration Analyzer 2.0 Microsoft PowerShell 2.0 Reference: Pinal Dave... - [SQLAuthority News – Meeting Bryan Oliver and Learning Wisdom of Life](https://blog.sqlauthority.com/2010/06/24/sqlauthority-news-meeting-bryan-oliver-and-learning-wisdom-of-life/): During my most recent travel outside India, I was fortunate enough to meet Bryan Oliver. I have heard a lot about him but never had chance to meet him in person. Just like we all do for someone we never met before, I had already some preconceived notions about him. I assumed that he might be someone who will be quite proud about his knowledge with 20+ years of experience in the industry. I was also not expecting a very friendly approach as he was quite older than me. I am sure by now that all of you might have guessed... - [SQLAuthority News - Guest Post - SELECT * FROM XML - Jacob Sebastian](https://blog.sqlauthority.com/2010/06/23/sqlauthority-news-guest-post-select-from-xml-jacob-sebastian/): One of the most common problem SQL Server developers face while dealing with XML is related to writing the correct XPath expression to read a specific value from an XML document. I usually get a lot of questions by email, on my blog or in the forums which looks like the following: - [SQLAuthority News - Price List - Oracle vs SQL Server](https://blog.sqlauthority.com/2010/06/22/sqlauthority-news-price-list-oracle-vs-sql-server/): During one of the consulting project, I was asked to prove that the SQL Server is a more economical choice than Oracle. Well, I do not want to start again the battle, which has been clearly won by SQL Server. Summary: SQL Server is a feature-rich and economical choice compared to Oracle. The base product of Oracle is expensive and to add all the features that are offered by the SQL Server, it requires many more different add-ons. These extra add-ons further increase the price to make SQL Server much more affordable than Oracle, which is ridiculously expensive. I suggest that... - [SQL SERVER - TRANSACTION, DML and Schema Locks](https://blog.sqlauthority.com/2010/06/21/sql-server-transaction-dml-and%c2%a0schema%c2%a0locks/): Today we will be going over a simple but interesting concept. Many a time, I have come across the lack of understanding on how the transactions work in SQL Server. Today we will go over a small but interesting observation. One of my clients had recently invited me to help them out with an interview for their senior developers. I had interviewed nearly 50+ candidates in a single day. There were many different questions, but the following question was incorrectly answered most of the time. The question was to create a scenario where you can see the SCHEMA LOCK. The interview... - [SQL SERVER - Free Download - SQL Server 2008 R2 Update for Developers Training Kit](https://blog.sqlauthority.com/2010/06/20/sql-server-free-download-sql-server-2008-r2-update-for-developers-training-kit/): SQL Server 2008 R2 is released and have been a stable product since the day it is released. I have not received any complains or rants from any of my customers who has upgraded to this version. The number one request is how one can learn about the new features of SQL Server or how one can get going in using SQL Server 2008. Microsoft has released SQL Server 2008 R2 Developers Training Kit. This is awesome kit and I just suggest to have a look at the content one time. Here is what MS say for this kit: SQL Server... - [SQLAuthority News - Delivering Two SQL Sessions at SQL Data Camp at Chennai - July 17, 2010](https://blog.sqlauthority.com/2010/06/19/sqlauthority-news-delivering-two-sql-sessions-at-sql-data-camp-at-chennai-july-17-2010/): SQL Server Community is very strong community world-wide. In India SQL is considered as one of the most popular technology. Chennai is the only city in India where there are more than 3 SQL Server MVPs are from. My MVP friends has arranged one of the very first whole day SQL event in India at Chennai. At this event all the speakers are MVPs as well there will be more than 6 SQL Server MVP present at this single event. You can register for this event by going to the site and clicking on link Register. I am very much looking... - [SQLAuthority News - Interview with SQL Server MVP Madhivanan - A Real Problem Solver](https://blog.sqlauthority.com/2010/06/18/sqlauthority-news-interview-with-sql-server-mvp-madhivanan-a-real-problem-solver/): Madhivanan (SQL Server MVP) is a real community hero. He is known for his two skills – 1) Help Community and 2) Help Community. I have met him many times and every time I feel if anybody in online world needs help Madhivanan does his best to reach them out and solve problem. His name is not new if you are reading this blog or have ever asked a question in any online SQL forum. He is always there to help. When Madhivanan has time he even helps people on this blog as well. He spends his valuable time to help... - [SQL SERVER - Data Pages in Buffer Pool - Data Stored in Memory Cache](https://blog.sqlauthority.com/2010/06/17/sql-server-data-pages-in-buffer-pool-data-stored-in-memory-cache/): This will drop all the clean buffers so we will be able to start again from there. Now, run the following script and check the execution plan of the query. Have you ever wondered what types of data are there in your cache? During SQL Server Trainings, I am usually asked if there is any way one can know how much data in a table is stored in the memory cache? The more detailed question I usually get is if there are multiple indexes on table (and used in a query), were the data of the single table stored multiple times... - [SQL SERVER - Find Largest Supported DML Operation - Question to You](https://blog.sqlauthority.com/2010/06/16/sql-server-find-largest-supported-dml-operation-question-to-you/): SQL Server is very big and it is not possible to know everything in SQL Server but we all keep learning. Recently I was going over the best practices of transactions log and I come across following statement. The log size must be at least twice the size of largest supported DML operation (using uncompressed data volumes). First of all I totally agree with this statement. However, here is my question – How do we measure the size of the largest supported DML operation? I welcome all the opinion and suggestions. I will combine the list and will share that with... - [SQL SERVER - Shrinking Database NDF and MDF Files](https://blog.sqlauthority.com/2010/06/15/sql-server-shrinking-ndf-and-mdf-files-readers-opinion/): Previously, I had written a blog post about SQL SERVER. I am posting this blog post here about Shrinking Database. - [SQLAuthority News - Author Visit - SQL Server 2008 R2 Launch](https://blog.sqlauthority.com/2010/06/14/sqlauthority-news-author-visit-sql-server-2008-r2-launch/): June 11, 2010 was a wonderful day because I attended the very first SQL Server 2008 R2 Launch event held by Microsoft at Mumbai. I traveled to Mumbai from my home town, Ahmedabad. The event was located at one of the best hotels in Mumbai,”The Leela”. SQL Server R2 Launch was an evening event that had a few interesting talks. SQL PASS is associated with this event as one of the partners and its goal is to increase the awareness of the Community about SQL Server. I met many interesting people and had a great networking opportunity at the event. This... - [SQL SERVER - What is Denali?](https://blog.sqlauthority.com/2010/06/13/sql-server-what-is-denali/): I see following question quite common on Twitter or in my email box. “What is Denali?” Denali is code name of SQL Server 2011. Here is the list of the code name of other versions of SQL Server. In 1988, Microsoft released its first version of SQL Server. It was developed jointly by Microsoft and Sybase for the OS/2 platform. 1993 – SQL Server 4.21 for Windows NT 1995 – SQL Server 6.0, codenamed SQL95 1996 – SQL Server 6.5, codenamed Hydra 1999 – SQL Server 7.0, codenamed Sphinx 1999 – SQL Server 7.0 OLAP, codenamed Plato 2000 – SQL Server... - [SQL SERVER - Difference Between DATETIME and DATETIME2 - WITH GETDATE](https://blog.sqlauthority.com/2010/06/12/sql-server-difference-between-datetime-and-datetime2-with-getdate/): Earlier I wrote blog post SQL SERVER – Difference Between GETDATE and SYSDATETIME which inspired me to write SQL SERVER – Difference Between DATETIME and DATETIME2. Now earlier two blog post inspired me to write this blog post (and 4 emails and 3 reads from readers). I previously populated DATETIME and DATETIME2 field with SYSDATETIME, which gave me very different behavior as SYSDATETIME was rounded up/down for the DATETIME datatype. I just ran the same experiment but instead of populating SYSDATETIME in this script I will be using GETDATE function. DECLARE @Intveral INT SET @Intveral = 10000 CREATE TABLE #TimeTable (FirstDate DATETIME, LastDate DATETIME2)... - [SQL SERVER - Difference Between DATETIME and DATETIME2](https://blog.sqlauthority.com/2010/06/11/sql-server-difference-between-datetime-and-datetime2/): Yesterday I have written a very quick blog post on SQL SERVER – Difference Between GETDATE and SYSDATETIME and I got tremendous response for the same. I suggest you read that blog post before continuing with this blog post today. I had asked people to honestly take part and share their view about the above two system functions. There are few emails as well as few comments on the blog post asking a question on how did I come to know the difference between the same. The answer is from real world issues. I was called in for performance tuning consultancy,... - [SQL SERVER - Difference Between GETDATE and SYSDATETIME](https://blog.sqlauthority.com/2010/06/10/sql-server-difference-between-getdate-and-sysdatetime/): Sometime something so simple skips our mind. I never knew the difference between GETDATE and SYSDATETIME. I just ran simple query as following and realized the difference. SELECT GETDATE() fn_GetDate, SYSDATETIME() fn_SysDateTime In case of GETDATE the precision is till miliseconds and in case of SYSDATETIME the precision is till nanoseconds. Now the questions is to you – did you know this? Be honest and please share your views. I already accepted that I did not know this in very first line. This applies to SQL Server 2008 only. Reference: Pinal Dave (http://www.SQLAuthority.com), - [SQL SERVER - Fastest Way to Restore Database](https://blog.sqlauthority.com/2010/06/09/sql-server-fastest-way-to-restore-the-database/): A few days ago, I received following email from blog reader where the question was about the fastest way to restore database. - [SQL SERVER - Merge Operations - Insert, Update, Delete in Single Execution](https://blog.sqlauthority.com/2010/06/08/sql-server-merge-operations-insert-update-delete-in-single-execution/): This blog post is written in response to T-SQL Tuesday hosted by Jorge Segarra. I have been very active using these Merge operations in my development. However, I have found out from my consulting work and friends that these amazing operations are not utilized by them most of the time. Here is my attempt to bring the necessity of using the Merge Operation to surface one more time. - [SQL SERVER - Subquery or Join - Various Options - SQL Server Engine Knows the Best - Part 2](https://blog.sqlauthority.com/2010/06/07/sql-server-subquery-or-join-various-options-sql-server-engine-knows-the-best-part-2/): This blog post is part 2 of the earlier written article SQL SERVER – Subquery or Join – Various Options – SQL Server Engine knows the Best by Paulo R. Pereira. Paulo has left excellent comment to earlier article once again proving the point that SQL Server Engine is smart enough to figure out the best plan itself and uses the same for the query. Let us go over his comment as he has posted. “I think IN or EXISTS is the best choice, because there is a little difference between ‘Merge Join’ of query with JOIN (Inner Join) and the... - [SQL SERVER - Subquery or Join - Various Options - SQL Server Engine knows the Best](https://blog.sqlauthority.com/2010/06/06/sql-server-subquery-or-join-various-options-sql-server-engine-knows-the-best/): This is followup post of my earlier article SQL SERVER – Convert IN to EXISTS – Performance Talk, after reading all the comments I have received I felt that I could write more on the same subject to clear few things out. First let us run following four queries, all of them are giving exactly same resultset. USE AdventureWorks GO -- use of = SELECT * FROM HumanResources.Employee E WHERE E.EmployeeID = ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- use of in SELECT * FROM HumanResources.Employee E WHERE E.EmployeeID IN ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- use of exists SELECT * FROM HumanResources.Employee E... - [SQL SERVER - Convert IN to EXISTS - Performance Talk](https://blog.sqlauthority.com/2010/06/05/sql-server-convert-in-to-exists-performance-talk/): In recent training one of the attendee asked if I can show a simple method to convert IN clause to EXISTS clause so it impacts performance. Here is the simple example. - [SQL SERVER - Generate Database Script for SQL Azure](https://blog.sqlauthority.com/2010/06/04/sql-server-generate-database-script-for-sql-azure/): When talking about SQL Azure the common complaint I hear is that the script generated from stand-along SQL Server database is not compatible with SQL Azure. This was true for some time for sure, but not any more. If you have SQL Server 2008 R2 installed you can follow the guideline below to generate a script which is compatible with SQL Azure. - [SQLAuthority News - Training and Consultancy and Travel - Story of Last 30 Days](https://blog.sqlauthority.com/2010/06/03/sqlauthority-news-training-and-consultancy-and-travel-story-of-30-last-30-days/): Today’s blog post is not technical as usual. Here, I present a real story, and I also invite you all to share your thoughts or opinions on this post. I am a professional SQL Server Trainer; I also do consultation in the area of the Performance Tuning and Query Optimizations. In any month, I like the mix of both in my schedule. I prefer to do training for one week, and then commit the next week for some consultation work. Due to the advancement in technology, for most of the consultation works, there is no client location visit or first time... - [SQL SERVER - Stored Procedure and Transactions](https://blog.sqlauthority.com/2010/06/02/sql-server-stored-procedure-and-transactions/): I just overheard the following statement – “I do not use Transactions in SQL as I use Stored Procedure“. I just realized that there are so many misconceptions about this subject. Transactions has nothing to do with Stored Procedures. Let me demonstrate that with a simple example. USE tempdb GO -- Create 3 Test Tables CREATE TABLE TABLE1 (ID INT); CREATE TABLE TABLE2 (ID INT); CREATE TABLE TABLE3 (ID INT); GO -- Create SP CREATE PROCEDURE TestSP AS INSERT INTO TABLE1 (ID) VALUES (1) INSERT INTO TABLE2 (ID) VALUES ('a') INSERT INTO TABLE3 (ID) VALUES (3) GO -- Execute SP --... - [SQL SERVER - Introduction to Force Index Query Hints - Index Hint - Part2](https://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/): In my previous article SQL SERVER – Introduction to Force Index Query Hints – Index Hint I have discussed regarding how we can use Index Hints with any query. I just received email from one of my regular reader that are there any another methods for the same as it will be difficult to read the syntax of join.Yes, there is alternate way to do the same using OPTION clause however, as OPTION clause is specified at the end of the query we have to specify which table the index hint is put on. Example 1: Using Inline Query Hint USE... - [SQL SERVER - Introduction to Force Index Query Hints - Index Hint](https://blog.sqlauthority.com/2009/02/07/sql-server-introduction-to-force-index-query-hints-index-hint/): This article, I will start with disclaimer instead of having it at the end of article. “SQL Server query optimizer selects the best execution plan for a query, it is recommended to use query hints by experienced developers and database administrators in case of special circumstances.” When any query is ran SQL Server Engine determines which index has to be used. SQL Server makes uses Index which has lowest cost based on performance. Index which is the best for performance is automatically used. There are some instances when Database Developer is best judge of the index used. DBA can direct SQL... - [SQL SERVER - Quickest Way to - Kill All Threads - Kill All User Session - Kill All Processes](https://blog.sqlauthority.com/2009/02/06/sql-server-quickest-way-to-kill-all-threads-kill-all-user-session-kill-all-processes/): More than a year ago, I wrote how to kill all the processes running in SQL Server. Just a day ago, I found the quickest way to kill the processes of SQL Server. While searching online I found very similar methods to my previous method everywhere. Today in this article, I will write the quickest way to achieve the same goal. Read here for older method of using cursor – SQL SERVER – Cursor to Kill All Process in Database. USE master; GO ALTER DATABASE AdventureWorks SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE AdventureWorks SET MULTI_USER; GO Running above script will give following result.... - [SQLAuthority News - Two Promotion to Help Community](https://blog.sqlauthority.com/2009/02/05/sqlauthority-news-two-promotion-to-help-community/): In this difficult time of recession I have two promotion to share with SQL Server community. 1) Discount on Microsoft Exams and Free Second Retake Due to bad job market, the ratio to available jobs to available candidates is lower than usual. Microsoft exams are key to stand up in mass and prove your potential. Click Here to Get Discount Code and Read more about this subject 2) Post your Tech Job and Get 10% Discount Jobs @ SQLAuthority.com has come up as prominent job portal and have been getting very high traffic. I receive lots of email and comments from... - [SQL SERVER - Observation - Effect of Clustered Index over Nonclustered Index](https://blog.sqlauthority.com/2009/02/04/sql-server-observation-effect-of-clustered-index-over-nonclustered-index/): Today I came across very interesting observation while I was working on query optimization. Let us run the example first. Make sure to to enable Execution Plan (Using CTRL + M) before running comparison queries. USE [AdventureWorks] GO /* */ CREATE TABLE [dbo].[MyTable]( [ID] [int] NOT NULL, [First] [nchar](10) NULL, [Second] [nchar](10) NULL ) ON [PRIMARY] GO /* Create Sample Table */ INSERT INTO [AdventureWorks].[dbo].[MyTable] ([ID],[First],[Second]) SELECT 1,'First1','Second1' UNION ALL SELECT 2,'First2','Second2' UNION ALL SELECT 3,'First3','Second3' UNION ALL SELECT 4,'First4','Second4' UNION ALL SELECT 5,'First5','Second5' GO Now let us create nonclustered index over this table. /* Create Nonclustered Index over Table */... - [SQLAuthority News - Download SQL Server 2008 System Views Poster - PDF - A Wall Poster](https://blog.sqlauthority.com/2009/02/03/sqlauthority-news-download-sql-server-2008-system-views-poster-pdf-a-wall-poster/): Microsoft has published SQL Server 2008 System Views Poster. This poster should be must have poster for any SQL Server Developer. I have this poster on my wall. If you have extra copy of this postered in print. Do send it to me and I will forward it to developer who are very good but can not afford to get this poster printed in glossy pages. The Microsoft SQL Server 2008 System Views Map shows the key system views included in SQL Server 2008, and the relationships between them. The map is similar to the Microsoft SQL Server 2005 version and... - [SQL SERVER - T-SQL Script for FizzBuzz Logic](https://blog.sqlauthority.com/2009/02/02/sql-server-t-sql-script-for-fizzbuzz-logic/): Following is quite common Interview Question asked in many interview questions. FizzBuzz is popular but very simple puzzle and have been very popular to solve. FizzBuzz problem can be attempted in any programming language. Let us attempt it in T-SQL. Definition of FizzBuzz Puzzle : Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. DECLARE @counter INT DECLARE @output VARCHAR(8) SET @counter = 1 WHILE @counter < 101... - [SQLAuthority News - Download Microsoft SQL Server 2008 Books Online (January 2009)](https://blog.sqlauthority.com/2009/02/01/sqlauthority-news-download-microsoft-sql-server-2008-books-online-january-2009/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - FIX : ERROR : Msg 5834, Level 16, State 1, Line 1 The affinity mask specified conflicts with the IO affinity mask specified. Use the override option to force this configuration](https://blog.sqlauthority.com/2009/01/31/sql-server-fix-error-msg-5834-level-16-state-1-line-1-the-affinity-mask-specified-conflicts-with-the-io-affinity-mask-specified-use-the-override-option-to-force-this-configuration/): Yesterday I came across following error while enabling fill factor for my database server, when I was trying to write article SQL SERVER – 2008 – 2005 – Rebuild Every Index of All Tables of Database – Rebuild Index with FillFactor. I ran following T-SQL script and it gave me error. sp_configure 'show advanced options', 1 GO RECONFIGURE GO sp_configure 'fill factor', 90 GO RECONFIGURE GO In result pan following error showed up. Msg 5834, Level 16, State 1, Line 1 The affinity mask specified conflicts with the IO affinity mask specified. Use the override option to force this configuration. Fix/Solution/Workaround:... - [SQL SERVER - 2008 - 2005 - Rebuild Every Index of All Tables of Database - Rebuild Index with FillFactor](https://blog.sqlauthority.com/2009/01/30/sql-server-2008-2005-rebuild-every-index-of-all-tables-of-database-rebuild-index-with-fillfactor/): I just wrote down following script very quickly for one of the project which I am working on. The requirement of the project was that every index existed in database should be rebuilt with fillfactor of  80. One common question I receive why fillfactor 80, answer is I just think having it 80 will do the job.Fillfactor determines how much percentage of the space on each leaf-level page are filled with data. The space which is left empty on leaf-level page is not at end of the page but the empty space is reserved between rows of data. This ensures that... - [SQLAuthority News - Microsoft Certification Exam - Discount Code - Free Second Chance - MCTS, MCITP, MCPD](https://blog.sqlauthority.com/2009/01/29/sqlauthority-news-microsoft-certification-exam-discount-code-free-second-chance-mcts-mcitp-mcpd/): Please note down this important code or share with your colleagues who are keen to take Microsoft Certification Exam. This unique code is only available through Microsoft MVP’s and only published here to help community and no other intention. In this challenging economic climate, upgrading your IT skills becomes crucial to staying ahead. Invest in a Microsoft Certification to get the right IT skills. Register today with your MVP Certification Promotion Code:  and enjoy 2 chances to pass a Microsoft Certification Examination plus a 10% discount! If you fail on your first attempt, you will receive a free retake of the... - [SQL SERVER - Generate A Single Random Number for Range of Rows of Any Table - Very interesting Question from Reader](https://blog.sqlauthority.com/2009/01/28/sql-server-generate-a-single-random-number-for-range-of-rows-of-any-table-very-interesting-question-from-reader/): Just a day ago I received email from reader how to get single random number for range of rows of any table. The question was not very clear to me so I had asked him to send me question in simpler words. He sent me question back in simple words. Let us understand this problem using database AdventureWorks. In AdventureWorks database we have table called Person.Address. How to get single random number generated for PostalCode ‘98011’ and another single random number for PostalCode ‘98033’. So far I have never received scenario like this. I had previously faced situation where I had... - [SQLAuthority News - Download Cumulative update package 3 for SQL Server 2008](https://blog.sqlauthority.com/2009/01/27/sqlauthority-news-download-cumulative-update-package-3-for-sql-server-2008/): For almost one year I have been using SQL Server 2008 and I keep watch on its update. Cumulative Update Package 3 has been made available now. Latest SQL Server 2008 version is 10.0.1787.0. Download Cumulative update package 3 for SQL Server 2008 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Microsoft SQL Server JDBC Driver 2.0 Community Technology Preview](https://blog.sqlauthority.com/2009/01/27/sqlauthority-news-download-microsoft-sql-server-jdbc-driver-20-community-technology-preview/): Note:  Download Microsoft SQL Server JDBC Driver 2.0 Community Technology Preview by Microsoft In its continued commitment to interoperability, Microsoft has released a new Java Database Connectivity (JDBC) driver. The SQL Server JDBC Driver 2.0 download is available to all SQL Server users at no additional charge, and provides access to SQL Server 2000, SQL Server 2005, and SQL Server 2008 from any Java application, application server, or Java-enabled applet. This is a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform, Enterprise Edition 5. This Community Technology Preview (CTP)... - [SQLAuthority News - Happy 60th Republic Day to India - Database Tip](https://blog.sqlauthority.com/2009/01/26/sqlauthority-news-happy-60th-republic-day-to-india-database-tip/): Kaleidoscopic images of India’s rich cultural diversity and the might of its military were on full display on the magnificent Rajpath Republic Day celebrations as the nation celebrated its 60th Republic Day amid an unprecedented security cover. An impressive and colourful parade, a traditional attraction of the national event, marched down the thoroughfare connecting the Rashtrapati Bhawan and the historic India Gate as President Pratibha Patil took the salute from marching contingents. (PTI) Database Tip of Today: Always check your execution plan first if your query is running slower and identify the part of query which is taking the highest execution... - [SQL SERVER - Shrinking NDF and MDF Files - A Safe Operation](https://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/): Just a day ago I have received following email from Siddhi and I found it interesting so I am sharing with all of you. Hello Pinal, I have seen many blogs from you on SQL server and i have always found them useful and easy to understand. Thanks for all the information you provide. I have one query about shrinking NDF and MDF files. Can we shrink NDF and MDF files?? If you do so is there any data loss? I have been shrinking the .LDF files every now and then but I am not too sure about NDF and MDF... - [SQLAuthority News - Download Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007](https://blog.sqlauthority.com/2009/01/24/sqlauthority-news-download-microsoft-sql-server-2005-data-mining-add-ins-for-microsoft-office-2007/): Note:  Download Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007 by Microsoft Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007 (Data Mining Add-ins) allow you take advantage of SQL Server 2005 predictive analytics in Office Excel 2007 and Office Visio 2007. The download includes the following components: Table Analysis Tools for Excel: This add-in provides easy-to-use tasks that leverage SQL Server 2005 Data Mining to perform powerful analytics on your spreadsheet data. Data Mining Client for Excel: This add-in allows you to go through the full data mining model development lifecycle within Excel 2007 using... - [SQL SERVER - 2008 - 2005 - Find Longest Running Query - TSQL - Part 2](https://blog.sqlauthority.com/2009/01/23/sql-server-2008-2005-find-longest-running-query-tsql-part-2/): Just another day I was playing with my query which I posted earlier SQL SERVER – 2008 – 2005 – Find Longest Running Query – TSQL and I found that I got error devide by zero. I have fixed this error in following query as well I have updated query to return time in millisecond instead of microsecond. Jerry Hung has also posted similar solution in comments of original article. I strongly suggest to read original article to now more about introduction and learn about DBCC command which clears cache. SELECT DISTINCT TOP 10 t.TEXT QueryName, s.execution_count AS ExecutionCount, s.max_elapsed_time AS MaxElapsedTime, ISNULL(s.total_elapsed_time... - [SQLAuthority News - Milestone of 6 Million Visits - 60 Lak Visits - Search and Job](https://blog.sqlauthority.com/2009/01/22/sqlauthority-news-milestone-of-6-million-visits-60-lak-visits-search-and-job/): Today SQLAuthority.com has completed 6 Million Visits. In 2 years 3 months miles stone of 6 million visits has been crossed. I want to thank all of my readers for their continuous support and help. On milestone of 6 million visits I want to announce small gratitude towards my readers who are continuously participating on this blog. I will be sending small surprise to all the readers who have been consistently participating on this blog. Those who have occasional participated with comments, suggestion or articles, I suggest them to participate more to get the surprise. Additionally, on this occasion I want... - [SQLAuthority News - SQLAuthority News - Ahmedabad User Group Meeting January 17 2009 - Review](https://blog.sqlauthority.com/2009/01/21/sqlauthority-news-sqlauthority-news-ahmedabad-user-group-meeting-january-17-2009-review/): User Group Meeting is the the event I always wait during whole month. User Group meetings are the place where we can meet various people from all around the city and expand our networking. Meeting new people and exchanging new tips and tricks is always interesting. For year 2009 we had our first User Group Meeting held on January 17, 2009. You can read the announcement here SQLAuthority News – Ahmedabad User Group Meeting January 17 2009. As this was first UG Meet of the year it was full of action with 3 back to back Performance Tuning related sessions. If... - [SQL SERVER - Rules for Optimizining Any Query - Best Practices for Query Optimization](https://blog.sqlauthority.com/2009/01/20/sql-server-rules-for-optimizining-any-query-best-practices-for-query-optimization/): This subject is very deep subject but today we will see it very quickly and most important points. May be following up on few of the points of this point will help users to right away improve the performance of query. In this article I am not focusing on in depth analysis of database but simple tricks which DBA can apply to gain immediate performance gain. Table should have primary key Table should have minimum of one clustered index Table should have appropriate amount of non-clustered index Non-clustered index should be created on columns of table based on query which is... - [SQLAuthority News - CWE/SANS TOP 25 Most Dangerous Programming Errors](https://blog.sqlauthority.com/2009/01/19/sqlauthority-news-cwesans-top-25-most-dangerous-programming-errors/): I just came across very interesting article from SANS Institute. Experts from more than 30 US and international cyber security organizations have released list of 25 most dangerous programming errors and their resolution. It may be possible that many of the programmers may not understand what this errors are and how to implement their solution. As said this are 25 most dangerous errors and all the developers should atleast know what they are so they do not are prevented from origin. Here are four major advantages listed by SANS. Software buyers will be able to buy much safer software. Programmers will... - [SQL SERVER - Difference Between Index Scan and Index Seek](https://blog.sqlauthority.com/2009/01/18/sql-server-difference-between-index-scan-and-index-seek/): I have explained the concept of Index Scan and Index Seek earlier but I keep on receiving the same question again and again. Let us today look into it with little more depth. Before we go over the concept of scan and seek we need to understand what SQL Server does before applying any kind of index on query. When any query is ran SQL Server has to determine that if any particular index can be applied on that particular query or not. SQL Server uses search predicates to make decision right before applying indexes to any given query. Let us... - [SQLAuthority News - Download Microsoft SQL Server Protocol Documentation](https://blog.sqlauthority.com/2009/01/17/sqlauthority-news-download-microsoft-sql-server-protocol-documentation/): he Microsoft SQL Server protocol documentation provides detailed technical specifications for Microsoft proprietary protocols (including extensions to industry-standard or other published protocols) that are implemented and used in Microsoft SQL Server to interoperate or communicate with Microsoft products. The documentation includes a set of companion overview and reference documents that supplement the technical specifications with conceptual background, overviews of inter-protocol relationships and interactions, and technical reference information. Download Microsoft SQL Server Protocol Documentation Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad User Group Meeting January 17 2009](https://blog.sqlauthority.com/2009/01/16/sqlauthority-news-ahmedabad-user-group-meeting-january-17-2009/): It is my pleasure to announce that SQL Server User Group Meeting is held on January 17, 2009. This is the first meeting of year 2009 and will be one interesting meeting as we will have back to back three presentation from SQL Experts. The agenda of meeting will be as following. Query Optimization Part 3 – Jacob Sebastian (SQL Server MVP) Understanding of Index Usage and Order By – Pinal Dave (SQL Server MVP) MERGE statement in SQL Server 2008 – Imran Bhadelia (MCTS) I encourage every SQL enthusiastic in city to attend this meeting as this will be one... - [SQL SERVER - Remove Duplicate Entry from Comma Delimited String - UDF](https://blog.sqlauthority.com/2009/01/15/sql-server-remove-duplicate-entry-from-comma-delimited-string-udf/): I love reader’s contribution this blog as that brings variety in articles. I encourage my readers to provide their contribution and I will publish then with their name. Blog Reader Ashish Jain has posted very simple script which will remove duplicate entry from comma delimited string. User Defined Function has very simple logic behind it. It takes comma delimited string and then converts it to table and runs DISTINCT operation on the table. DISTINCT operation removes duplicate value. After that it converts the table again into the string and it can be used. I have modified original contribution from Ashish so... - [SQL SERVER - Find Number of Rows and Disk Space Reserved - Using sp_spaceused Interesting Observation](https://blog.sqlauthority.com/2009/01/14/sql-server-find-number-of-rows-and-disk-space-reserved-using-sp_spaceused-interesting-observation/): Previously I posted SQL SERVER – Find Row Count in Table – Find Largest Table in Database – T-SQL. Today we will look into the same issue but with some additional interesting detail. We can find the row count using another system SP sp_spaceused. This SP gives additional information regarding disk space reserved on database as well. Well, when I ran the SP on AdventureWorks first time, I suspected that database SP is not providing me correct results. After a bit investigating I found that it may be possible that due to any reason may be the usage on AdventureWorks database... - [SQL SERVER - Find Row Count in Table - Find Largest Table in Database - T-SQL](https://blog.sqlauthority.com/2009/01/13/sql-server-find-row-count-in-table-find-largest-table-in-database-t-sql/): I have written following script every time when I am asked by our team leaders or managers that how many rows are there in any particular table or sometime I am even asked which table has highest number of rows. Being Sr. Project Manager, sometime I just write down following script myself rather than asking my developers. This script will gives row number for every table in database. USE AdventureWorks GO SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count FROM sys.dm_db_partition_stats st WHERE index_id < 2 ORDER BY st.row_count DESC GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Humor - Favorite Website - Funny Image](https://blog.sqlauthority.com/2009/01/12/sqlauthority-news-humor-favorite-website-funny-image/): I just received this image in email and I found it really funny. I do not know the source of the image or is it photoshopped. Thanks David Marsee for the image and email. If you have something really funny like this, please send them to me. Please do not leave comment regarding grammatical mistake in image as I am sure David (who send email) did not mean it. Reference : Pinal Dave https://blog.sqlauthority.com/ ) - [SQL SERVER - Top Five Articles of Year 2008](https://blog.sqlauthority.com/2009/01/11/sql-server-top-five-articles-of-year-2008/): Year 2008 was great year for me. I got plenty of request from readers asking for Top 10 or Top 5 articles of the year 2008. I am including Top 5 Articles of Year 2008 in two different categories. First is my blog SQLAuthority.com and another one is my home page pinaldave.com TOP 5 Articles at SQLAuthority.com This section has six links as very first link is repeated again in top 5 pages at pinaldave.com SQL SERVER – 2008 – Interview Questions and Answers Complete List Download Most popular and most visited page. Very first and compilation of SQL Server Interview... - [SQLAuthority News - Security White Papers](https://blog.sqlauthority.com/2009/01/10/sqlauthority-news-security-white-papers/): Microsoft Dynamics AX 2009 White Paper: Configuring Kerberos Authentication with Role Centers This document describes how to configure Kerberos authentication with Enterprise Portal and Role Centers. Kerberos authentication is required to display reports created using Microsoft SQL Server Reporting Services and Microsoft SQL Server Analysis Services on Role Center pages. Microsoft Dynamics AX 2009 White Paper: Configuring Enterprise Portal and Role Centers with SQL Reporting This document contains checklists and information to help administrators set up and configure Microsoft Dynamics AX 2009 Enterprise Portal and Role Centers with Microsoft SQL Server® Reporting Services® and Microsoft SQL Server Analysis Services. Reference :... - [SQL SERVER - sqlcmd - Using a Dedicated Administrator Connection to Kill Currently Running Query](https://blog.sqlauthority.com/2009/01/09/sql-server-sqlcmd-using-a-dedicated-administrator-connection-to-kill-currently-running-query/): People are judged from their questions and not their answers. I received wonderful question the other day. How sqlcmd can be used along with currently running query script posted on your blog? Please read following two posts before continuing this article as they cover background of this article. SQL SERVER – Interesting Observation – Using sqlcmd From SSMS Query Editor SQL SERVER – Find Currently Running Query – T-SQL If due to a long running query or any resource hogging query SQL Server is not responding sqlcmd can be used to connect to the server from another computer and kill the... - [SQLAuthority News - Author Visit - Mumbai, India - From January 8, 2008 to January 11, 2008](https://blog.sqlauthority.com/2009/01/08/sqlauthority-news-author-visit-mumbai-india-from-january-8-2008-to-january-11-2008/): I will be traveling to Mumbai from From January 8, 2008 to January 11, 2008. If any of readers wants to meet up for cup of coffee in evening leave a comment or send me email and we can arrange something. I will be visiting various places and my access to emails are limited. Regular readers, those who have my phone number can call me at any time. I will post review of my trip to Mumbai once I am back from trip. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Currently Running Query - T-SQL](https://blog.sqlauthority.com/2009/01/07/sql-server-find-currently-running-query-t-sql/): This is the script which I always had in my archive. Following script find out which are the queries running currently on your server. SELECT sqltext.TEXT, req.session_id, req.status, req.command, req.cpu_time, req.total_elapsed_time FROM sys.dm_exec_requests req CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext While running above query if you find any query which is running for long time it can be killed using following command. KILL [session_id] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interesting Observation - Using sqlcmd From SSMS Query Editor](https://blog.sqlauthority.com/2009/01/06/sql-server-interesting-observation-using-sqlcmd-from-ssms-query-editor/): A day before I wrote article SQL SERVER – sqlcmd vs osql – Basic Comparison. Today while I was displaying how sqlcmd can be used instead of osql to one of my companies team leader, I found another neat feature of SSMS Query Editor. sqlcmd can be used from Query Editor but it has to be enabled first. - [SQL SERVER - sqlcmd vs osql - Basic Comparison](https://blog.sqlauthority.com/2009/01/05/sql-server-sqlcmd-vs-osql-basic-comparison/): Today we will go over very simple but to the point comparison of two SQL Server utilities or SQL Server tools. This comes often to users which one to use sqlcmd or osql, when in need of running SQL Server queries from command prompt. Answer to this is very simple use “sqlcmd”. sqlcmd has all the feature which osql has to offer, additionally sqlcmd has many added feature than osql. isql was introduced in earlier versions of SQL Server. osql was introduced in SQL Server 2000 version. sqlcmd is newly added in SQL Server 2005 and offers additionally functionality which SQL... - [SQL SERVER - 2008 - Change Color of Status Bar of SSMS Query Editor](https://blog.sqlauthority.com/2009/01/04/sql-server-2008-change-color-of-status-bar-of-ssms-query-editor/): This is one very interesting issue which I have started to follow recently. Just like any other organization my company has many servers. Some are production and some are development. It is very much necessary that query which are written for developer environment does not run for production environment accidentally. In SQL Server 2008 there is special feature which can change the color of the task bar. This will alert developer to run query on server. Let us see quick tutorial with images which explains how the color of the status bar in SQL Server management studio can be changed. Another... - [SQL SERVER - Time Delay While Running T-SQL Query - WAITFOR Introduction](https://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/): Today we will look at one very small but interesting feature of SQL Server. Please note that this is not much known feature of SQL Server. In SQL Server sometime there are requirement when T-SQL script has to wait for some time before executing next statement. It is quite common that developers depends on application to take over this delay issue. However, SQL Server itself has very strong time management function of WAITFOR. Let us see two usage of WAITFOR clause. Official explanation of WAITFOR clause from Book Online is “Blocks the execution of a batch, stored procedure, or transaction until... - [SQL SERVER - 2008 - 2005 - Find Longest Running Query - TSQL](https://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/): UPDATE : Updated this query with bug fixed with one more enhancement SERVER – 2008 – 2005 – Find Longest Running Query – TSQL – Part 2. Recently my company owner asked me to find which query is running longest. It was very interesting that I was not able to find any T-SQL script online which can give me this data directly. Finally, I wrote down very quick script which gives me T-SQL which has ran on server along with average time and maximum time of that T-SQL execution. As I keep on writing I needed to know when exactly logging was started for the same T-SQL so I had added Logging start time in the query as well. - [SQLAuthority News - Happy New Year - 5 SQL New Year Resolutions](https://blog.sqlauthority.com/2009/01/01/sqlauthority-news-happy-new-year-5-sql-new-year-resolutions/): Happy New Year to All of YOU! Let us start year 2009 with word of wisdom from Albert Einstein. I feel that you are justified in looking into the future with true assurance, because you have a mode of living in which we find the joy of life and the joy of work harmoniously combined. Added to this is the spirit of ambition which pervades your very being, and seems to make the day’s work like a happy child at play. – Albert Einstein “May this new year all your dreams turn into reality and all your efforts into great achievements.”... - [SQLAuthority News - Recap Year 2008 - Two Most Important Event of My Life](https://blog.sqlauthority.com/2008/12/31/sqlauthority-news-recap-year-2008-two-most-important-event-of-my-life/): Year 2008 is about to complete in next few hours. It was one of the most interesting year for me in my life. There were so many things happened and fortunately all of them are good. If I have to list events special to me in year 2008 there can be many, I will list two most important events of my life in year 2008. I am awarded as SQL Server MVP by Microsoft I am very thankful to Microsoft to recognize my talent as SQL Server Expert and Community Leader. I had great fun this year when I visited MVP... - [SQLAuthority Author Visit Report - Tech Meetings - Recession - Job Market - Consolidation of Servers](https://blog.sqlauthority.com/2008/12/30/sqlauthority-author-visit-report-tech-meetings-recession-job-market-consolidation-of-servers/): In this blog post, I will discuss various topics which are related to various DBAs and Developers discussed in the recent market. - [SQL SERVER - 2008 - Certification Path Complete Download PDF](https://blog.sqlauthority.com/2008/12/29/sql-server-2008-certification-path-complete-download-pdf/): Microsoft Certification are very important for any developer’s career. I personally have acquired MS certification before and while practicing for MS Certification I learned a lot personally. Developers who are interesting in upgrading themselves with Microsoft Certification must download certification path PDF. - [SQL SERVER - Fix : Msg 15151, Level 16, State 1, Line 3 Cannot drop the login 'test', because it does not exist or you do not have permission](https://blog.sqlauthority.com/2008/12/28/sql-server-fix-msg-15151-level-16-state-1-line-3-cannot-drop-the-login-test-because-it-does-not-exist-or-you-do-not-have-permission/): I got following error when I was trying to delete user ‘test’ with ‘SA’ login. I was little surprised but then I tried to delete with the windows authenticated systemadmin account. Once again I got the same error. Msg 15151, Level 16, State 1, Line 3 Cannot drop the login ‘test’, because it does not exist or you do not have permission. The reason I was surprised that I was systemadmin and I should be allowed to delete the login. I am including the script which I used to delete the account here. IF EXISTS (SELECT * FROM sys.server_principals WHERE name =... - [SQL SERVER - Add Any User to SysAdmin Role - Add Users to System Roles](https://blog.sqlauthority.com/2008/12/27/sql-server-add-any-user-to-sysadmin-role-add-users-to-system-roles/): The reason I like blogging is follow up questions. I have wrote following two articles earlier this week. I just received question based on both of them. Before I go on questions, I recommend to read both of the article first. Both of them are very small article so they are quick to read. - [SQL SERVER - Fix : Error : Msg 15151, Level 16, State 1, Line 2 Cannot alter the login 'sa', because it does not exist or you do not have permission](https://blog.sqlauthority.com/2008/12/26/sql-server-fix-error-msg-15151-level-16-state-1-line-2-cannot-alter-the-login-sa-because-it-does-not-exist-or-you-do-not-have-permission/): Few days ago, I have wrote about SQL SERVER – DISABLE and ENABLE user SA I received following email from one of the user who received following error. Msg 15151, Level 16, State 1, Line 2 Cannot alter the login ‘sa’, because it does not exist or you do not have permission. Fix/Workaround/Solution: This error had occurred because of insufficient rights. Please read my previous post here before reading further article. SA is system admin user and it is the highest level of user in system. If any user have to modify the permissions of SA that user needs to have... - [SQLAuthority Author Visit - Valsad, Daman, Silvassa, Vapi - Tech Meetings](https://blog.sqlauthority.com/2008/12/25/sqlauthority-author-visit-valsad-daman-silvassa-vapi-tech-meetings/): I am currently traveling to South Gujarat doing Tech Meetings with leading organizations. Following is my tour schedule. Valsad – December 25, 2008 Daman – December 26, 2008 Silvassa – December 27, 2008 Vapi – December 28, 2008 I will be visiting some of the local IT industries and User Groups. If any of the readers who wants to meet me there can contact me by email. I will be bringing my new DELL XPS 1530 (wireless enabled) along with me so I will reply quickly. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Merry Christmas - Search SQLAuthority](https://blog.sqlauthority.com/2008/12/25/sqlauthority-news-merry-christmas-search-sqlauthority/): Merry Christmas and a prosperous New Year. Thanks for the love and support you give me. I pray to the god that recession will be over soon around the world and everybody is happy. I have been receiving increasing emails for asking question about where is the Search on SQLAuthority.com blog. I have created custom search engine using Google which exclusively searches into SQLAuthority and if needed in the web. If you have not tried SQLAuthority.com search before I suggest you give it a show as this surely improves the experience with this blog. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DISABLE and ENABLE user SA](https://blog.sqlauthority.com/2008/12/24/sql-server-disable-and-enable-user-sa/): Just a day ago, I received question from blog reader Mike McDonald. “How can I modify permissions for SA user? I tried to modify dbo users permission but now I am having problems.” First of all, there may be no relation between dbo user and SA user. They are different and should be left separate. Modifying the permission of SA user is not possible. However, SA can be disable or enabled using following script. Make sure that you are logged in using windows authentication account. /* Disable SA Login */ ALTER LOGIN [sa] DISABLE GO /* Enable SA Login */ ALTER LOGIN [sa] ENABLE GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Download Copy of Developer Edition for Free Is Myth](https://blog.sqlauthority.com/2008/12/23/sql-server-2008-download-copy-of-developer-edition-for-free-is-myth/): It is quite common myth that SQL Server 2008 Developer Edition is FREE. SQL Server 2008 developer edition has same code base and same features which are available in SQL Server 2008 enterprise edition. Only difference between them is licensing terms. Developer Edition can not be used in production environment and it can be used on development server only. I have received quite a lots of emails how this can be downloaded for free. First of this version is not free. It is available for $50 to download. However, those developer who are really looking for free edition of SQL Server... - [SQL SERVER - Find Next Running Time of Scheduled Job Using T-SQL](https://blog.sqlauthority.com/2008/12/22/sql-server-find-next-running-time-of-scheduled-job-using-t-sql/): I often receive a good question on the blog, however, I do not always receive a good answer for the questions. Recently someone asked on a blog about Finding next run time for Schedule Job using T-SQL. My friend came up with a nice script. I have modified it a bit to adjust needs. This blog post is about finding the next running time of scheduled job using T-SQL.  - [SQLAuthority News - SQL Server Related Downloads from Microsoft](https://blog.sqlauthority.com/2008/12/21/sqlauthority-news-sql-server-related-downloads-from-microsoft/): Feature Pack for SQL Server 2005 December 2008 Download the December 2008 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. Microsoft SQL Server Protocol Documentation The Microsoft SQL Server protocol documentation provides technical specifications for Microsoft proprietary protocols that are implemented and used in Microsoft SQL Server 2008. SQL Server 2005 Express Edition with Advanced Services SP3 Microsoft SQL Server 2005 Express Edition with Advanced Services is a free, easy-to use version of SQL Server Express that includes more features and makes it easier than ever to start... - [SQL SERVER - Change Collation of Database Column - T-SQL Script](https://blog.sqlauthority.com/2008/12/20/sql-server-change-collation-of-database-column-t-sql-script/): Just a day before I wrote about SQL SERVER – Find Collation of Database and Table Column Using T-SQL and I have received some good comments and one particular question was about how to change collation of database. It is quite simple do so. Let us see following example. USE AdventureWorks GO /* Create Test Table */ CREATE TABLE TestTable (FirstCol VARCHAR(10)) GO /* Check Database Column Collation */ SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN ( SELECT OBJECT_ID FROM sys.objects WHERE type = 'U' AND name = 'TestTable') GO /* Change the database collation */ ALTER TABLE TestTable ALTER COLUMN FirstCol VARCHAR(10) COLLATE SQL_Latin1_General_CP1_CS_AS NULL GO /* Check Database Column Collation */ SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN ( SELECT... - [SQLAuthority News - Download - SQL Server 2005 Books Online (December 2008)](https://blog.sqlauthority.com/2008/12/19/sqlauthority-news-download-sql-server-2005-books-online-december-2008/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The December 2008 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the December 2008 update, SQL Server 2005 Books Online includes documentation updates for... - [SQLAuthority News - Download Microsoft SQL Server 2005 Service Pack 3](https://blog.sqlauthority.com/2008/12/18/sqlauthority-news-download-microsoft-sql-server-2005-service-pack-3/): Service Pack 3 for Microsoft SQL Server 2005 is now available. SQL Server 2005 service packs are cumulative, and this service pack upgrades all service levels of SQL Server 2005 to SP3. You can use these packages to upgrade any of the following SQL Server 2005 editions: Enterprise Enterprise Evaluation Developer Standard Workgroup Download Service Pack 3 for Microsoft SQL Server 2005 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interesting Interview Questions - Revisited](https://blog.sqlauthority.com/2008/12/17/sql-server-interesting-interview-questions-revisited/): I really enjoyed users participation in my previous question. Read SQL SERVER – Interesting Interview Questions before continuing reading this article. This interview question was about user participation and about how good and how different you can come with your T-SQL script. What I really liked is that many users took this test seriously and did their best to answer. I really want to congratulate all the readers who have attempted to answer this question. As I have said earlier it did not matter what is the database structure, but it mattered what should be the good database architecture design. Here... - [SQL SERVER - Find Collation of Database and Table Column Using T-SQL](https://blog.sqlauthority.com/2008/12/16/sql-server-find-collation-of-database-and-table-column-using-t-sql/): Today we will go over very quick tip about finding out collation of database and table column. Collations specify the rules for how strings of character data are sorted and compared, based on the norms of particular languages and locales Today’s script are self explanatory so I will not explain it much. /* Find Collation of SQL Server Database */ SELECT DATABASEPROPERTYEX('AdventureWorks', 'Collation') GO /* Find Collation of SQL Server Database Table Column */ USE AdventureWorks GO SELECT name, collation_name FROM sys.columns WHERE OBJECT_ID IN (SELECT OBJECT_ID FROM sys.objects WHERE type = 'U' AND name = 'Address') AND name = 'City' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Wedding Day of Author - Photographs - Mr. and Mrs. SQLAuthority](https://blog.sqlauthority.com/2008/12/15/sqlauthority-news-wedding-day-of-author-photographs/): On December 12, 2008 I had posted a note on blog when I completed 800th Article on this blog. The same day was also my wedding day. Read more about the same here SQLAuthority News – Wedding Day of Author. Thank you very much for your wishes and wonderful emails. I have received many emails and I have replied almost all of them with thank you note. Almost all of them have requested to send photographs of my wedding day. I have shared few of the photographs here. Those who were present at the occasion and want their own personal copy... - [SQL SERVER - Connect using Enterprise Manager to SQL Server 2005/2008](https://blog.sqlauthority.com/2008/12/14/sql-server-connect-using-enterprise-manager-to-sql-server-20052008/): I received the following email from Mike Bikinis. about enterprise manager. "How can I connect to SQL Server 2005 or SQL Server 2008 using SQL Server 2000's Enterprise Manager?" - [SQL SERVER - Email from Blog Reader - Not a Potential Bug in SQL - Puzzle](https://blog.sqlauthority.com/2008/12/13/sql-server-interesting-email-from-blog-reader-puzzle/): Few days ago, I received wonderful email from blog reader and it was like good puzzle. I enjoyed solving this puzzle. I did not write the name of the blog reader because I am not sure if he wants his name here or not. Please read this article and run the script described in email. You can download the SQL Script here. Also can any of you help this reader why SQL Server is behaving like this. I have already replied him with correct answer where I suggest that it is not bug and have explained him the reason for the... - [SQLAuthority News - Wedding Day of Author - 800th Article of Blog](https://blog.sqlauthority.com/2008/12/12/sqlauthority-news-wedding-day-of-author-800th-article-of-blog/): Today is big day for me. I am getting married today. Wedding is just one hour away and I am writing this article. I will post more information tomorrow about this event of my life. While assigning categories to this article, I laughed when I selected “SQLAuthority Author Visit” tag. The way I receive one question repetitively “What are the differences between SQL Server 2008 Standard and Enterprise Edition?”, I think Microsoft receives the same question again and again so they have created PDF answering the same question. Download SQL Server 2008 Enterprise and Standard Feature Compare. In November 2008 I... - [SQL SERVER - Interesting Interview Questions - Part 2 - Puzzle - Solution](https://blog.sqlauthority.com/2008/12/11/sql-server-interesting-interview-questions-part-2-puzzle-solution/): Yesterday we looked at Puzzle and I did got great response to this question. Very interestingly not many got it right. First go through the puzzle first and then come back here and read answer. Read Original Interview Question and Puzzle. Question: Select all the person from table PersonColor who have same color as ColorCode or have more colors than table ColorCode. UPDATE: Following solution is written with assumption that in SelectedColors table Name and ColorCode are Primary Key. This requirement was not specified in original question. /*Answer to Interview Question*/ SELECT Name FROM PersonColors pc INNER JOIN SelectedColors sc ON sc.ColorCode = pc.ColorCode GROUP BY pc.Name HAVING... - [SQLAuthority News - SQL SERVER 2008 Upgrade Technical Reference Guide Download](https://blog.sqlauthority.com/2008/12/11/sqlauthority-news-sql-server-2008-upgrade-technical-reference-guide-download/): Note:   SQL SERVER 2008 Upgrade Technical Reference Guide Download by Microsoft This 490-page document covers the essential phases and steps to upgrade existing instances of SQL Server 2000 and 2005 to SQL Server 2008 by using best practices. These include preparation tasks, upgrade tasks, and post-upgrade tasks. It is intended to be a supplement to SQL Server 2008 Books Online. A successful upgrade to SQL Server 2008 should be smooth and trouble-free. To achieve that smooth transition, you must devote plan sufficiently for the upgrade, and match the complexity of your database application. Otherwise, you risk costly and stressful errors and... - [SQL SERVER - Top 10 SQL Server 2008 Features for Independent Software Vendor Applications](https://blog.sqlauthority.com/2008/12/10/sql-server-2008-top-10-sql-server-2008-features-for-independent-software-vendor-applications/): Microsoft SQL Server 2008 has hundreds of new and improved features, many of which are specifically designed for large scale independent software vendor (ISV) applications, which need to leverage the power of the underlying database while keeping their code database agnostic. This article presents details of the top 10 features that we believe are most applicable to such applications based on our work with strategic ISV partners. Along with the description of each feature, the main pain-points the feature helps resolve and some of the important limitations that need to be considered are also presented. - [SQL SERVER - Interesting Interview Questions - Part 2 - Puzzle](https://blog.sqlauthority.com/2008/12/10/sql-server-interesting-interview-questions-part-2-puzzle/): In the recent time of recession my company is able to continue its progress and we are hiring. It is very surprising to me that many developers who have experience with SQL Server could not get following simple question right. There were nearly 40 candidates I interviewed but none of the candidate was able to solve this problem. When I displayed final answer they could not believe that it is that simple. When I asked some of the MCITP or Oracle certified candidate about why they can not get this simple question, they smiled and answered that I did not have... - [SQL SERVER - Find Table Row Count Without Using T-SQL and Without Opening Table](https://blog.sqlauthority.com/2008/12/09/sql-server-find-table-rowcount-without-using-t-sql-and-without-opening-table/): Recently I have been busy with interviewing many candidates for my organization. We are looking for some smart and experienced developers for some senior positions. I have wrote this previously SQL SERVER - Interesting Interview Questions. This blog post is about finding a table row count without using T-SQL. - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2008/12/08/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-2/): Note:   Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Note: Scripts in the SQL Server 2008 management pack rely on SQL Data Management Objects (SQL-DMO) to query information from the SQL Server. SQL-DMO is now deprecated and is not shipped as a part of... - [SQLAuthority News - Author Photographs Updated](https://blog.sqlauthority.com/2008/12/08/sqlauthority-news-author-photographs-updated/): I have received many emails about one of page in on personal site – Photos. I have updated all but one photo on my photo web page. There are new photos of my User Group Presentation and MVP activities. Visit my new photos page Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interview Questions - Difficult SQL Puzzle](https://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/): Today at my organization, we had nearly 30 interviews scheduled of DBA and .NET developers. Let us see a difficult SQL puzzle. - [SQLAuthority News - 10 Motivational Quotes from Technologiest of the Past](https://blog.sqlauthority.com/2008/12/06/sqlauthority-news-10-motivational-quotes-technologiest-past/): Once in a while it is a good idea to read what the greatest technologies of the past said about their time as well as the future. This is the running list of the motivational quotes which I have liked so far from various technologies. Please feel free to add yours as well. One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. – Elbert Hubbard - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/12/05/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008-2/): Ahmedabad SQL Server User Group Meeting was organized on November 29, 2008 at famous C.G. Road in Ahmedabad. We had great response and wonderful back to back technical sessions. The highlight of whole meeting was participation of UG President Jacob Sebastian – SQL MVP from New York. Meeting started with introduction and welcome to all the members from SQL Server MVP – Pinal Daveand followed by technical session of “SQL Server 2008 – Backup and Compression” by Pinal Dave. This session was very special because not every database user is aware of the special feature of SQL Server 2008 and how... - [SQL SERVER - Microsoft SQL Server 2008 Enterprise Evaluation: Trial Experience for IT Professionals / Developers](https://blog.sqlauthority.com/2008/12/04/sql-server-microsoft-sql-server-2008-enterprise-evaluation-trial-experience-for-it-professionals-developers/): Download SQL Server 2008 180-day Trial Software. Microsoft SQL Server 2008 is a database platform for large-scale online transaction processing (OLTP), data warehousing, and e-commerce applications; it is also a business intelligence platform for data analysis and reporting solutions. SQL Server 2008 is a trusted, productive, and intelligent data platform for all your data needs. SQL Server 2008 delivers on Microsoft’s Data Platform vision by helping your organization manage any data, any place, any time. It enables you to store structured, semi-structured, and unstructured data, such as documents, images and music, directly in the database. SQL Server 2008 delivers a rich... - [SQL SERVER - Default Collation of SQL Server 2008](https://blog.sqlauthority.com/2008/12/03/sql-server-default-collation-of-sql-server-2008/): Recently I wrote article about SQL SERVER – 2008 – Install SQL Server 2008 – How to Upgrade to SQL Server 2008 – Installation Tutorial, I received couple of comment suggesting that I did not talk about SQL Server default collation setting or how to change default collation when installing SQL Server 2008. While installing SQL Server 2008 on Server Configuration setting select “Collation” tab. It will bring up setting displayed in following image. You can check the default collation of SQL Server as well can change it from the same. SQL Server offers the SQL_Latin1_General_CP1_CI_AS collation as the default collation... - [SQL SERVER - 2008 - Install SQL Server 2008 - How to Upgrade to SQL Server 2008 - Installation Tutorial](https://blog.sqlauthority.com/2008/12/02/sql-server-2008-install-sql-server-2008-how-to-upgrade-to-sql-server-2008-installation-tutorial/): SQL SERVER 2008 RTM has been released for some time and I have got numerous request about how to install SQL Server 2008. I have created this step by step guide Installation Guide. Images are used to explain the process easier. I had previously written the same article earlier. It seemed necessary to re post it again as request of me posting Step by Step tutorial has increased for quite some time. - [SQL SERVER - Roadmap of Microsoft Certifications - SQL Server Certifications](https://blog.sqlauthority.com/2008/12/01/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications/): In these times of economical slowdown, more and more IT professionals are concerned about their jobs and their qualifications. It is a common trend for developers to start looking for ways to update their skills when jobs are not secure. Pure knowledge and real world work experience are always a good way to help secure your future. One way to demonstrate knowledge is by having a certification in the technology one claims to be expert in. Microsoft offers a series of certifications for IT professional and developers. In this article we will cover the following topics. Importance of Certificates Certification Structure... - [SQL SERVER - Interesting Observation - Use of Index and Execution Plan](https://blog.sqlauthority.com/2008/11/30/sql-server-interesting-observation-use-of-index-and-execution-plan/): Previously I wrote article about SQL SERVER – Interesting Observation about Order of Resultset without ORDER BY and I have received tremendous response from my readers by emails and comments. Readers demanded that I should have written little more for the same subject. As I really liked the subject myself very much, I have decided to write more about the same again. Those readers who have not read my previous article, I request them to go over my previous article one time before reading this article as that will give them history. Read my previous article here. Let us see three... - [SQLAuthority News - Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/11/29/sqlauthority-news-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008/): Today is special day for SQL Server enthusiastic as we will have SQL Server User Group Meeting today in Ahmedabad. Today in User Group we will have UG President Jacob Sebastian (MVP) participating from New York and UG Vice President Pinal Dave (MVP) will talk about “How to become MVP?” Agenda for today’s meeting is as following: Agenda: 1) Introduction by Pinal Dave 2) Direct from New York – Live Meeting by Jacob Sebastian– SQL Pass Roundup and Other News 3) Technical Session by Pinal Dave – Compressed Backup and Restore Techniques 4) Technical Session by Tejas Shah – What is... - [SQL Server - Switch Between Result Pan and Query Pan - SQL Shortcut](https://blog.sqlauthority.com/2008/11/28/sql-server-switch-between-result-pan-and-query-pan-sql-shortcut/): Many times when I am writing query I have to scroll the result displayed in the result set. Let us learn about the shortcut today. - [SQLAuthority News - Download Tools and Documentation for SQL SERVER](https://blog.sqlauthority.com/2008/11/27/sqlauthority-news-download-tools-and-documentation-for-sql-server/): SQL Server 2008 Report Definition Language Specification The goal of Report Definition Language (RDL) is to promote the interoperability of commercial reporting products by defining a common schema that allows interchange of report definitions. An important aspect to understand is that RDL is a schema definition, not a programmatic interface or protocol like HTTP or ODBC. RDL does not specify how report definitions are passed between applications or how reports are processed. Also, RDL is meant to be fully encapsulated; meaning that successfully interpreting an RDL document should not require any understanding of the source application. Microsoft Visual Studio Team System... - [SQLAuthority News - Help to Find Recession Proof Job](https://blog.sqlauthority.com/2008/11/26/sqlauthority-news-help-to-find-recession-proof-job/): Recently I have been receiving a lot of emails from employees asking where they can find good employee. I was under impression that due to global recession job market is down but from looking at recent increase in emails for looking for right candidate I have to say that there are good jobs still out there. There are few jobs in market which are recession proof. There are few decisions one has to make when their job is at risk. Use the website created by SQLAuthority.com for finding right job and right candidate. Click here to go to find right job... - [SQLAuthority Author Visit - Ahmedabad SQL Server User Group Meeting - November 2008](https://blog.sqlauthority.com/2008/11/25/sqlauthority-author-visit-ahmedabad-sql-server-user-group-meeting-november-2008/): It is time again to announce SQL Hour – SQL Server User Group Meeting for November 2008. This time it is going to be one really interesting event. Our User Group is growing and getting more interesting. Lots of new SQL Server enthusiastic have contacted me recently for User Group meeting. It is the time for all the SQL Server developers to meet again for SQL Hour. User group is place to meet fellow developers like us and learn something new at no cost. User groups are free and there is no fee. I suggest you read my article here where... - [SQL SERVER - Interesting Observation about Order of Resultset without ORDER BY](https://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/): Today I observed very interesting little thing about SQL Server and I felt that I should share this with my readers. I ran following two queries and found that I am getting different result-set. When I carefully observed I found that actually the result was same but order of the records returned is different. USE AdventureWorks GO SELECT ContactID FROM Person.Contact GO SELECT * FROM Person.Contact GO This particular thing interested me. I knew that when “ORDER BY” is not used order of the table is not guaranteed but I was not able to reproduce simple example for the same. Every... - [SQL SERVER - 2008 - Download and Install Sample Database AdventureWorks 2008](https://blog.sqlauthority.com/2008/11/23/sql-server-2008-download-and-install-samples-database-adventureworks-2008/): The following sample database is currently available for Microsoft SQL Server 2005 and Microsoft SQL Server 2008: - [SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database Including Schema](https://blog.sqlauthority.com/2008/11/22/sql-server-simple-use-of-cursor-to-print-all-stored-procedures-of-database-including-schema/): I love active participation from my readers. Just a day ago I wrote article about SQL SERVER – Simple Use of Cursor to Print All Stored Procedures of Database. I just received comment from Jerry Hung who have improved on previously written article of generating text of Stored Procedure. DECLARE @procName VARCHAR(100) DECLARE @getprocName CURSOR SET @getprocName = CURSOR FOR SELECT Name = '[' + SCHEMA_NAME(SCHEMA_ID) + '].[' + Name + ']' FROM sys.all_objects WHERE TYPE = 'P' AND is_ms_shipped 1 OPEN @getprocName FETCH NEXT FROM @getprocName INTO @procName WHILE @@FETCH_STATUS = 0 BEGIN PRINT 'sp_HelpText ' + @procName EXEC sp_HelpText @procName FETCH NEXT FROM @getprocName... - [SQLAuthority News - SQL Server White Paper: SQL Server 2008 Compliance Guide](https://blog.sqlauthority.com/2008/11/21/sqlauthority-news-sql-server-white-paper-sql-server-2008-compliance-guide/): Note: Download White Paper by Microsoft Organizations across the globe are being inundated with regulatory requirements. They also have a strong need to better manage their IT systems to ensure they are operating efficiently and staying secure. Microsoft is often asked to provide guidance and technology to assist organizations struggling with compliance. The SQL Server 2008 Compliance Guidance white paper was written to help organizations and individuals understand how to use the features of the Microsoft SQL Server 2008 database software to address their compliance needs. This paper serves as an accompaniment to the SQL Server 2008 compliance software development kit... - [SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database](https://blog.sqlauthority.com/2008/11/20/sql-server-simple-use-of-cursor-to-print-all-stored-procedures-of-database/): SQLAuthority Blog reader YordanGeorgiev has submitted very interesting SP, which uses cursor to generate text of all the Stored Procedure of current Database. This task can be done many ways, however, this is also interesting method. USE AdventureWorks GO DECLARE @procName VARCHAR(100) DECLARE @getprocName CURSOR SET @getprocName = CURSOR FOR SELECT s.name FROM sysobjects s WHERE type = 'P' OPEN @getprocName FETCH NEXT FROM @getprocName INTO @procName WHILE @@FETCH_STATUS = 0 BEGIN EXEC sp_HelpText @procName FETCH NEXT FROM @getprocName INTO @procName END CLOSE @getprocName DEALLOCATE @getprocName GO Just give this script a try and it will print text of all the SP in your... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Group Photo](https://blog.sqlauthority.com/2008/11/19/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-group-photo/): MVP Open day 2008 is one of the best event happened so far. I have previously written about this event in detail on this blog. - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 3](https://blog.sqlauthority.com/2008/11/18/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-3/): Yesterday was our last day at South Asia MVP Open Day. For three days continuously we are having great time along with fellow MVP. Every MVP was having great time because the way whole event was planned. We had plenty of time for networking as well lots of interesting sessions were going on. Most of the MVPs had slept late the day before because everybody was preparing their presentation for community buzz. The day before we had wonderful Open Space sessions at Midnight. The most avaited sessions was Nitin Paranjape – Do’s and Dont’s of being an entrepreneur (Monetizing your expertise).... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 2](https://blog.sqlauthority.com/2008/11/17/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-2/): At MVP Open Day we were promised that we will have 8 to 8 action packed day but we all observed much longer hours where we all MVP’s were busy with activity. I will say instead of 8 AM to 8 PM we actually had fun from 8 AM to 2 AM (next day). Day 2 at MVP Open day was filled with technical sessions followed by River Cruise and Dance party at Casino. On day 2 we had team photo, as I was part of team photo I could not take this photo myself. I will request Abhishek Kant to... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 1](https://blog.sqlauthority.com/2008/11/16/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-day-1/): It is great fun! Perfect Event and Great start. Yesterday I wrote about agenda of South Asia MVP Open Day 2008 which is at Hotel Kenilworth Resorts, Goa. November 15 – Day 1 of Open Day started with plain journey and ended with Goan Team Party at beach with fellow MVP. I have more than hundreds of the photos of this event. I will share few of the them with you. First of all let me thank three four people, without their support this event might have not possible. Howard Lo – Microsoft, Singapore – Regional Manager, Asia Pacific and Greater... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Link List](https://blog.sqlauthority.com/2008/11/15/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa-link-list/): Today is very exciting day as I will start my trip to South Asia MVP Open Day 2008 – Goa. Yesterday I wrote about my visit. I will be attending South Asia MVP Open Day 2008 on November 15 – 17, 2008 at Hotel Kenilworth Resorts, Goa. Those who have asked how can they meet me in Goa is that you will have to send me email and I will respond to them. At this moment I have reached goa and writing using my new USB Data Card internet. I will post more photos and event details as I receive them.... - [SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa](https://blog.sqlauthority.com/2008/11/14/sqlauthority-news-author-visit-south-asia-mvp-open-day-2008-goa/): I will be attending South Asia MVP Open Day 2008 on November 15 – 17, 2008 at Hotel Kenilworth Resorts, Goa. I am very excited as this will be my first Open Day event after being MVP. Microsoft Most Valuable Professionals (MVPs) are exceptional technical community leaders from around the world who are awarded for voluntarily sharing their high quality, real world expertise in offline and online technical communities. Microsoft MVPs are a highly select group of experts that represents the technical community’s best and brightest, and they share a deep commitment to community and a willingness to help others. There... - [SQLAuthority News - RML Utilities - Usage and Additional Help](https://blog.sqlauthority.com/2008/11/13/sqlauthority-news-rml-utilities-usage-and-additional-help/): Yesterday I wrote about SQLAuthority News – Download RML Utilities for SQL Server. I received many emails where different developers requested how to find additional help regarding RML Utilities. Few users reported that they are not able to install RML Utilities because of some reporting service pre-requisite. If RML Utilities are not being installed due to pre-requisite, install Microsoft Report Viewer 2008 SP1 Redistributable and then try to install RML Utilities. If there is need of additional help once RML Utilities are installed click on Start >> All Programs >> RML Utilities for SQL Server >> Help >> RML Help. Once... - [SQLAuthority News - Download RML Utilities for SQL Server](https://blog.sqlauthority.com/2008/11/12/sqlauthority-news-download-rml-utilities-for-sql-server/): Note:   Download RML Utilities for SQL Server by Microsoft The RML utilities allow you to process SQL Server trace files and view reports showing how SQL Server is performing. For example, you can quickly see: Which application, database or login is using the most resources, and which queries are responsible for that Whether there were any plan changes for a batch during the time when the trace was captured and how each of those plans performed What queries are running slower in today’s data compared to a previous set of data You can also test how the system will behave with... - [SQL SERVER - Delete Backup History - Cleanup Backup History](https://blog.sqlauthority.com/2008/11/11/sql-server-delete-backup-history-cleanup-backup-history/): SQL Server stores history of all the taken backup forever. History of all the backup is stored in msdb database. Many times older history is no more required. Following Stored Procedure can be executed with parameter which takes days of history to keep. In following example 30 is passed to keep history of month. USE msdb GO DECLARE @DaysToKeepHistory DATETIME SET @DaysToKeepHistory = CONVERT(VARCHAR(10), DATEADD(dd, -30, GETDATE()), 101) EXEC sp_delete_backuphistory @DaysToKeepHistory GO Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Check Database Integrity for All Databases of Server - DBCC CHECKDB](https://blog.sqlauthority.com/2008/11/10/sql-server-check-database-integrity-for-all-databases-of-server/): Today we will see quick script which will check integrity of all the databases of SQL Server. We will learn about DBCC CHECKDB in this blog post.  - [SQLAuthority News - SQL Server 2008 Book Online Updated in October 2008](https://blog.sqlauthority.com/2008/11/09/sqlauthority-news-sql-server-2008-book-online-updated-in-october-2008/): SQL Server 2008 Books Online is updated on 31 October 2008. I always bookmark latest BOL for my easy reference. Getting Started: New and Updated Topics (31 October 2008) Analysis Services – Multidimensional Data: New and Updated Topics (31 October 2008) Database Engine: New and Updated Topics (31 October 2008) Integration Services: New and Updated Topics (31 October 2008) Analysis Services – Data Mining: New and Updated Topics (31 October 2008) Reporting Services: New and Updated Topics (31 October 2008) Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER 2008 - Connect Visual Studio 2005 Patch Download](https://blog.sqlauthority.com/2008/11/08/sql-server-2008-connect-visual-studio-2005-patch-download/): It was not possible to connect SQL Server 2008 to Visual Studio 2005 so far. Microsoft has released Service Pack once it is installed SQL Server 2008. - [SQL SERVER - Refresh Database Using T-SQL](https://blog.sqlauthority.com/2008/11/07/sql-server-refresh-database-using-t-sql/): Yesterday I received following questions on blog. Ashish Agarwal asked following question. Hi Pinal, Can we refresh a database (like we do by right clicking database node in object explorer and clicking on refresh) thru SQL Query? If yes, can you please tell me the query? Thanks, Ashish Agarwal Answer to above question is NO. It is not possible to do the same task using SQL Query. However, if you have changed some SP or any other object and if they are cached in the database, database can be refreshed using DBCC commands. Read my previous article about SQL SERVER –... - [SQLAuthority News - 5 Millions Visitors - 2 Anniversary - Authors Note on Economy Slow Down and Job Opportunity - SQL Server](https://blog.sqlauthority.com/2008/11/06/sqlauthority-news-5-millions-visitors-2-anniversary-authors-note-on-economy-slow-down-and-job-opportunity-sql-server/): I just received the following screen shot from one of the regular readers of the SQLAuthority.com blog. He pointed out important milestone for our blog. We have crossed 5 million visitors. In less than 2 years SQLAuthority.com blog has been visited by 5 million visitors. I even missed the anniversary our blog. On November 1st, 2008 SQLAuthority.com has completed 2 years of its existence and now continuing in 3rd year. - [SQL SERVER - T-SQL Errors and Reactions - Demo - SQL in Sixty Seconds #005 - Video](https://blog.sqlauthority.com/2012/03/07/sql-server-t-sql-errors-and-reactions-demo-sql-in-sixty-seconds-005-video/): We got tremendous response to video of Error and Reaction of SQL in Sixty Seconds #002. We all have idea how SQL Server reacts when it encounters T-SQL Error. Today Rick explains the same in quick seconds. After watching this I felt confident to answer talk about SQL Server’s reaction to Error. We received many request to follow up video of the earlier video. Many requested T-SQL demo of the concept. In today’s SQL in Sixty Seconds Rick Morelan has presented T-SQL demo of very visual reach concept of SQL Server Errors and Reaction. [youtube=http://www.youtube.com/watch?v=X19KQgxEt7g] More on Errors: Explanation of TRY…CATCH and... - [SQLAuthority News - TechED India 2012 - Bangalore - March 21-23, 2012](https://blog.sqlauthority.com/2012/03/06/sqlauthority-news-teched-india-2012-bangalore-march-21-23-2012/): TechEd is one event which every developers and IT professionals are looking forward to attend. It is opportunity of life time and no matter how many time one gets chance to engage with it, it is never enough. I still remember every single moment of every TechEd I have attended so far. This year TechEd India 2012 will be held in Bangalore between March 21 and 23. There will be three 3 days of lots of learning and fun. If you are data professional, you are going to find yourself very very fortunate as every single day we will have data... - [Data Integration - Top 10 "Ease of Use" Features of expressor Studio](https://blog.sqlauthority.com/2012/03/05/data-integration-top-10-ease-use-features-expressor-studio/): expressor Studio is a new data integration platform that is being marketed as the most easy to use tools of its kind. But “easy to use” can be a relative term – an expert can find a very complex system easier, but a beginner might be stumped. A recent article online discussed exactly what makes expressor Studio so easy use, and here is my view on this subject. - [SQL SERVER - Technical Reference Guides for Designing Mission-Critical Solutions](https://blog.sqlauthority.com/2012/03/04/sql-server-technical-reference-guides-for-designing-mission-critical-solutions-a-must-read/): Yesterday I was reading architecture reference material helping my friend who was looking for material in this respect. While working together we were searching twitter, facebook and search engines to find relevant material.While searching online we end up on very interactive reference point. Once I send the same to him, he replied he may not need anything more after referencing this material. Let's learn about Designing Mission-Critical Solutions in this blog post. - [SQL SERVER - Various Leap Year Logics](https://blog.sqlauthority.com/2012/03/03/sql-server-various-leap-year-logics/): Earlier I wrote one article on Leap Year and created one video about Leap Year. My point of view was to demonstrate how we can use SQL Server 2012 features to identify Leap year. How ever during the conversation I had some really good conversation. Here are updates for those who have missed reading the excellent comments on the blog. Incorrect Logic There are so many people still think Leap Year is the event which is consistently happening at every four year and the way to find it is divide the year with 4 and if the remainder is 0. That... - [SQL SERVER - Logon Trigger Feature for Managing Data Access](https://blog.sqlauthority.com/2012/03/02/sql-server-safepeak-logon-trigger-feature-for-managing-data-access/): This blog post is about SafePeak "Logon Trigger” Feature for Managing Data Access. Just a quick update the product is no longer available. - [SQLAuthority News - The Best Quotes of "Who Wrote This?" Contest](https://blog.sqlauthority.com/2012/03/01/sqlauthority-news-the-best-quotes-of-who-wrote-this-contest/): I am a frequent reader of Brent Ozar PLF, it is one of my favorite blogs. A recent post announced a “Who Wrote This?” contest to see if readers could tell their three contributors apart based on some writing samples. Here are my favorite lines from the sample paragraphs, from each of the three “mystery authors.” Topic 1: Working with Bad Managers Mystery Author A – “Working with bad managers means working against my own happiness, and I’ve come to learn that there’s no changing bad managers.” I love this line because, as anyone who has had a bad manager knows,... - [SQL SERVER - Function: Is Function - SQL in Sixty Seconds #004 - Video](https://blog.sqlauthority.com/2012/02/29/sql-server-function-is-function-sql-in-sixty-seconds-004-video/): Today is February 29th. An unique date which we only get to observe once every four year. Year 2012 is leap year and SQL Server 2012 is also releasing this year. Yesterday I wrote an article where we have seen observed how using four different function we can create another function which can accurately validate if any year is leap year or not. We will use three functions newly introduced in SQL Server 2012 and demonstrate how we can find if any year is leap year or not. This function uses three of the SQL Server 2012 functions – IIF, EOMONTH and... - [SQL SERVER - Detecting Leap Year in T-SQL using SQL Server 2012 - IIF, EOMONTH and CONCAT Function](https://blog.sqlauthority.com/2012/02/28/sql-server-detecting-leap-year-in-t-sql-using-sql-server-2012-iif-eomonth-and-concat-function/): Note: Tomorrow is February 29th. This blog post is dedicated to coming tomorrow – a special day :) Subu: “How can I find leap year in using SQL Server 2012?“ Pinal: “Are you asking me how to year 2012 is leap year using T-SQL – search online and you will find many example of the same.” Subu: “No. I am asking – How can I find leap year in using SQL Server 2012?“ Pinal: “Oh so you are asking – How can I find leap year in using SQL Server 2012?“ Subu: “Yeah – How can I find leap year in using SQL... - [SQL SERVER - Identifying Guest User using Policy Based Management](https://blog.sqlauthority.com/2012/02/27/sql-server-identifying-guest-user-using-policy-based-management/): If you are following my recent blog posts, you may have noticed that I’ve written a lot about Guest User in SQL Server. Here are all the blog posts which I have written on Policy Based Management subject. One of the requests I received was whether we could create a policy that would prevent users unable guest user in user databases. Well, here is a quick tutorial to answer this. Let us see how quickly we can do it. - [SQL SERVER - Standards Support, Protocol, Data Portability](https://blog.sqlauthority.com/2012/02/26/sql-server-standards-support-protocol-data-portability-3-important-sql-server-documentations-for-downloads/): Let us read more about Standards Support, Protocol, Data Portability. Sometimes I read easy things and sometimes not so easy. - [SQL SERVER - A Cool Trick - Restoring the Default SQL Server Management Studio - SSMS](https://blog.sqlauthority.com/2012/02/25/sql-server-a-cool-trick-restoring-the-default-sql-server-management-studio-ssms/): “I do not know where my windows went!” “I just closed my object explorer and now I cannot find it.” “How do I get my original windows layout back in SQL Server Management Studio?” “How do I get the window which was there in left side back again?” Since last 2-3 years, every single day I receive more than 5 emails on SSMS and its layout. For the beginners it is very common to get confused when they attempt to change SQL Server Management Studio’s windows layout. They often change the layout and are not able to get the original layout... - [SQL SERVER - guest User and MSDB Database - Enable guest User on MSDB Database](https://blog.sqlauthority.com/2012/02/24/sql-server-guest-user-and-msdb-database-enable-guest-user-on-msdb-database/): I have written a few articles recently on the subject of guest account and MSDB Database. Here’s a quick list of these articles: SQL SERVER – Disable Guest Account – Serious Security Issue SQL SERVER – Force Removing User from Database – Fix: Error: Could not drop login ‘test’ as the user is currently logged in. SQL SERVER – Detecting guest User Permissions – guest User Access Status - [SQL SERVER - Detecting guest User Permissions - guest User Access Status](https://blog.sqlauthority.com/2012/02/23/sql-server-detecting-guest-user-permissions-guest-user-access-status/): Earlier I wrote the blog post SQL SERVER – Disable Guest Account – Serious Security Issue, and I got many comments asking questions related to the guest user. Here are the comments of Manoj: 1) How do we know if the uest user is enabled or disabled? 2) What is the default for guest user in SQL Server? Default settings for guest user When SQL Server is installed by default, the guest user is disabled for security reasons. If the guest user is not properly configured, it can create a major security issue. You can read more about this here. Identify guest user status There... - [SQL SERVER - T-SQL Constructs - Declaration and Initialization - SQL in Sixty Seconds #003 - Video](https://blog.sqlauthority.com/2012/02/22/sql-server-t-sql-constructs-declaration-and-initialization-sql-in-sixty-seconds-003-video/): We got tremendous response to our very first video of SQL in Sixty Seconds #001 and SQL in Sixty Seconds #002. We talked about how to convert Subquery to CTE and Error and Reaction. My co-authors Vinod Kumar and Rick Morelan, we often came across very interesting and useful tips which we believe would be helpful to readers. In today’s SQL in Sixty Seconds Vinod Kumar has presented very visual reach concept of SQL Server. T-SQL has many enhancements which are less explored. In this quick video we learn how T-SQL Constructions works. We will explore Declaration and Initialization of T-SQL Constructions. We can... - [SQL SERVER - Force Removing User from Database - Fix: Error: Could not drop login 'test'](https://blog.sqlauthority.com/2012/02/21/sql-server-force-removing-user-from-database-fix-error-could-not-drop-login-test-as-the-user-is-currently-logged-in/): Yesterday I wrote a blog post discussing how the guest user can become a security threat. The script which was demonstrated in the example had a small T-SQL query which creates a new user. Later, I got an email from a user who had created this scenario on his production environment. It makes me sad that I had clearly talked multiple times about how to execute this as a trial on a development server or a test server, but NOT on a production server. Anyway, here is the email about the Force Removing User. - [SQL SERVER - Disable Guest Account - Serious Security Issue](https://blog.sqlauthority.com/2012/02/20/sql-server-disable-guest-account-serious-security-issue/): “No Guests PLEASE!” “Doesn’t your Indian tradition suggest welcoming guests and treating them in the best way possible?” “Yes, but I am talking about the Guest user in SQL Server.” “Oh!” This was a real conversation that happened a couple of years ago. I welcome guests as much as any other Indian does; however, I am strongly opinionated about guest user in SQL Server. I like to keep it disabled unless there is a special need of it. If there is some persistent need of a guest user, I suggest to create separate account. Again, there are always special cases where there is a need... - [SQL SERVER - Migration Assistant for Oracle, MySQL, Sybase and Access v5.2](https://blog.sqlauthority.com/2012/02/19/sql-server-migration-assistant-for-oracle-mysql-sybase-and-access-v5-2/): Migration is always the challenge, it does not matter if people are migrating from one country to another country or birds are migrating from one continent to another continent or database is migrating from one platform to another platform. I remember years ago when I had to migrate our database from another platform to SQL Server, I was extremely scared but as time passed by I learned that migration is not difficult as it seems. Of course there are challenges but there are tools available to make the migration much easier than it seems. SQL Server Migration Assistant (SSMA) is a free supported tool... - [SQL SERVER - Case Sensitive Database and Database User - Fix: Error: 15151 - Cannot find the user , because it does not exist or you do not have permission.](https://blog.sqlauthority.com/2012/02/18/sql-server-case-sensitive-database-and-database-user-fix-error-15151-cannot-find-the-user-because-it-does-not-exist-or-you-do-not-have-permission/): Jeff asked me another question! If you do not know Jeff, you may read the following blog posts. You will get the idea of Jeff’s personality and who Jeff really is. SQL SERVER – Installation Log Summary File Location – 2012 – 2008 R2 SQL SERVER – INNER JOIN Returning More Records than Exists in Table This time, he sent me a screenshot. He was facing a very strange error. As his screenshot had confidential details, I created my own images which exactly simulate his issue for demonstration’s sake. Here are the partial details of his email. Please note that I... - [SQL SERVER - Solution Part 2 - A Quick Puzzle on SQL JOIN and NULL - SQL Brain Teaser](https://blog.sqlauthority.com/2012/02/17/sql-server-solution-part-2-a-quick-puzzle-on-join-and-null-sql-brain-teaser/): Some questions are timeless and they never grow old; no matter how much they grow old their interest never dies. Earlier, I asked a simple puzzle based on a conversation on SQLAuthority Page, and have received an overwhelming response from readers. I still get emails related to this puzzle every day. Let us see a quick puzzle between SQL Join and SQL Null. - [SQL SERVER - Be Different - Be Leader - An Interactive Journey - Questions and Answers - Book and Video](https://blog.sqlauthority.com/2012/02/16/sql-server-be-different-be-leader-an-interactive-journey-questions-and-answers-book-and-video/): This is a true story. My wife and my daughter were playing in the play area in our resident complex. I was sitting a ways off and was watching them play various games. My daughter likes the slides a lot. Suddenly, one kid started to climb the slide from the slide instead of the stairs. There were a few kids on the slide already and naturally a collision happened. Kids are kids and they moved on (I wish adults could be like that more often). After a few minutes the same routine repeated. The kid was attempting to go from the... - [SQL SERVER - T-SQL Errors and Reactions - SQL in Sixty Seconds #002 - Video](https://blog.sqlauthority.com/2012/02/15/sql-server-t-sql-errors-and-reactions-sql-in-sixty-seconds-002-video/): We got tremendous response to our very first video of SQL in Sixty Seconds #001. We talked about how to convert Subquery to CTE very quickly. My co-authors Vinod Kumar and Rick Morelan, we often came across very interesting and useful tips which we believe would be helpful to readers. In today’s SQL in Sixty Seconds Rick Morelan has presented very visual reach concept of SQL Server. We all have idea how SQL Server reacts when it encounters T-SQL Error. Today Rick explains the same in quick seconds. When I personally watched this video, I suddenly felt that this is great... - [SQL SERVER - What is Big Data - An Explanation in Simple Words](https://blog.sqlauthority.com/2012/02/14/sql-server-what-is-big-data-an-explanation-in-simple-words/): Let us start with a very interesting quote for Big Data. Decoding the human genome originally took 10 years to process; now it can be achieved in one week - The Economist. This blog post is written in response to the T-SQL Tuesday post of The Big Data. This is a very interesting subject. Data is growing every single day. I remember my first computer which had 1 GB of the Hard Drive. I had told my dad that I will never need any more hard drive, we are good for next 10 years. I bought much larger Harddrive over 2 years and today I have a NAS at home, which can hold 2 TB and have few file hosting in the cloud as well. Well the point is, the amount of the data any individual deals with has increased significantly. - [SQL SERVER - Building Interactive Reports in Quick Moments - From CSV to Excel Pivot Table - A Conversation turned to Webinar](https://blog.sqlauthority.com/2012/02/13/sql-server-building-interactive-reports-in-quick-moments-from-csv-to-excel-pivot-table-a-conversation-turned-to-webinar/): “I have text files and I need to create interactive reports for my boss – do you have few minutes of time right now? Let us discuss.” I often get questions from people who are new to technology and struggling to get something done. However, this time it was not a question from any beginner. This question was from an expert – a friend and an excellent technologist. Wiqar and I have known each other for a long time and often discuss various technologies. He works at expressor Technologies  as a product manager and has built the complete product using .NET... - [SQLAuthority News - Business Intelligence features of SQL Server 2012 RC0 - Download Virtual Machine](https://blog.sqlauthority.com/2012/02/12/sqlauthority-news-business-intelligence-features-of-sql-server-2012-rc0-download-virtual-machine/): I am in front of computer 16+ hours of the day. However, I accept that I am bit lazy when it is about doing installation etc. I always prefer that IT department help me to install my computer and I use it right away. Same feeling I get when I have to install Beta, RC or any other version in my computer. I prefer virtual machines for the same. Again, I do not like to prepare virtual machines. Now following news is very exciting. As I Microsoft has prepared virtual machine for all of us using all essential Business Intelligence features... - [SQL SERVER - Solution - A Quick Puzzle on JOIN and NULL - SQL Brain Teaser](https://blog.sqlauthority.com/2012/02/11/sql-server-solution-a-quick-puzzle-on-join-and-null-sql-brain-teaser/): Yesterday was really fun. I asked a simple Brain Teaser and we had excellent conversation on SQLAuthority Page as well SQL SERVER – A Quick Puzzle on JOIN and NULL – SQL Brain Teaser. That was an easy puzzle for those who have attended the SQL Server Questions and Answers online course. Here is a quick recap of the puzzle. Lots of people said it is a very easy puzzle, but the correct answer was provided by only a few readers. There were lots of conversation on Facebook page and lots of emails I received, many saying that there was some sort of an error in the... - [SQL SERVER - A Quick Puzzle on JOIN and NULL - SQL Brain Teaser](https://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/): It seems that we all love to solve puzzles. On SQLAuthority Page, we have been playing the number game and those who are playing with us know how much fun we are having. Sometimes, the answers are so innovative and informative that they open up those aspects of the technology which I have not thought of. Today, I have a very relaxing puzzle and a SQL Brain Teaser for all of you. It is based on my earlier blog post on INNER JOIN and NULL, so I suggest reading the said post first if you want to get the complete idea. - [SQL SERVER - INNER JOIN Returning More Records than Exists in Table](https://blog.sqlauthority.com/2012/02/09/sql-server-inner-join-returning-more-records-than-exists-in-table/): I blog and engage with the community because it gives me satisfaction when someone resolves an issue. A few days ago, I blogged about a DBA who began his first day at a new company and could not find out where the installation summary file was. He was very happy when I featured his story on our blog. Today he asked me another question and when I received his question my first reaction was – not possible. Later I said, may be possible, and when he shared more information, I said of course it is possible and natural. Let us go... - [SQL SERVER - Convert Subquery to CTE - SQL in Sixty Seconds #001 - Video](https://blog.sqlauthority.com/2012/02/08/sql-server-convert-subquery-to-cte-sql-in-sixty-seconds-001-video/): SQL Server is an ocean of information. I believe if one starts learning today, after 60 years he/she may still be learning the subject (there are always a few exceptions)! Recently, I published the SQL Server Questions and Answers video tutorial, and since the course came out, I have been receiving lots of request to share SQL Tips which are small and easy to digest. While writing the SQL books with my co-authors Vinod Kumar and Rick Morelan, we often came across very interesting and useful tips which we believe would be helpful to readers. Sometimes the tips are so small... - [SQL SERVER - Installation Log Summary File Location - 2012 - 2008 R2](https://blog.sqlauthority.com/2012/02/07/sql-server-installation-log-summary-file-location-2012-2008-r2/): Here is email received from user: “Pinal, I am new DBA in my organization and I have to manage SQL Server 2005, 2008 and 2008 R2. Today is my first day at job and my manager has asked me to install all these different edition on our test environment. I have finished installing them. Later he has asked me provide him Installation Log Summary. I searched on internet and I could not find it, would you send me format of the installation log summary?” I like this question, even though it is very simple, it demonstrates how new job can be... - [SQL SERVER - ERROR: FIX - Database diagram support objects cannot be installed](https://blog.sqlauthority.com/2012/02/06/sql-server-error-fix-database-diagram-support-objects-cannot-be-installed-because-this-database-does-not-have-a-valid-owner/): Recently, one of my friends sent me email that he is having some problem with his very small database. We talked for a few minutes and we agreed that to further investigation, I will need access to the whole database. As the database was very big he dropped it in a common location. Let us learn about error Database diagram support objects cannot be installed because this database does not have a valid owner. - [SQLAuthority News - Microsoft SQL Server AlwaysOn Solutions Guide for High Availability and Disaster Recovery](https://blog.sqlauthority.com/2012/02/05/sqlauthority-news-microsoft-sql-server-alwayson-solutions-guide-for-high-availability-and-disaster-recovery/): SQL Server 2012 is has very exciting new feature of SQL Server AlwaysOn. This new feature reduces planned and unplanned downtime and maximize application available. Additionally it provides data protection keeping database always available. Microsoft has released a whitepaper on this subject where it discusses common context business stakeholders, technical decision makers, system architects, infrastructure engineers, and database administrators. This whitepaper discusses two major points. Following is the abstract from book online: High Availability and Disaster Recovery Concepts. Provide a brief discussion of the drivers and challenges of planning, managing, and measuring the business objectives of a highly available database environment.... - [SQL SERVER - Finding Count of Logical CPU using T-SQL Script - Identify Virtual Processors](https://blog.sqlauthority.com/2012/02/04/sql-server-finding-count-of-logical-cpu-using-t-sql-script-identify-virtual-processors/): I recently received email from one of my very close friend from California. His question was very interesting. He wanted to know how many virtual processors are there available for SQL Server. He already had script for SQL Server 2008 but was mainly looking for SQL Server 2000. He made me go to my past. I found following script from my old emails (I have no reference listed along with it, so not sure the original source). - [SQLAuthority News - An Incredible Successful SQL Saturday #116 Event - First SQL Saturday in India](https://blog.sqlauthority.com/2012/02/03/sqlauthority-news-an-incredible-successful-sql-saturday-116-event-first-sql-saturday-in-india/): We have recently wrapped up our most recent event, SQL Saturday #116, and I am I am sure I am not alone in reporting that it was a huge success!  We had a full crowd – every seat taken, plus standing-room-only in the back.  We also had a lot of good feedback and the crowd was definitely involved and engaged, so I think it was an all-around success. Given the success of our UG meetings in Bangalore, this year we tried to accommodate even more people by hosting two technical tracks at the same event.  I think this plan worked out... - [SQL SERVER - An Inspiring Personal Story - Movie from The Book - Video Course - SQL Server Questions and Answers - Pluralsight](https://blog.sqlauthority.com/2012/02/02/sql-server-an-inspiring-personal-story-movie-from-the-book-video-course-sql-server-questions-and-answers-pluralsight/): Nov 3, 2011 – Visit to Grandma When our SQL Server Interview Questions and Answers book got published I ran to my grandma with a copy of the book for her blessings. Well, just like every grandma, she loves me, her grandson, unconditionally. She is not into the technology domain (obviously), but she loved the book. She read the first few pages where I was mentioned and read about my co-author Vinod Kumar. After reading the introduction she looked at me and said “When I was young we used to read books, now all those good books are converted into the movies, when do you... - [SQL SERVER - What is Slowly Changing Dimension - Quiz - Puzzle - 31 of 31](https://blog.sqlauthority.com/2012/02/01/sql-server-what-is-slowly-changing-dimension-quiz-puzzle-31-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Advantages of Partitioning - Quiz - Puzzle - 30 of 31](https://blog.sqlauthority.com/2012/01/31/sql-server-advantages-of-partitioning-quiz-puzzle-30-of-31/): The year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author's Perspective. Let us see the puzzle of Advantages of Partitioning.  - [SQL SERVER - Data Collector Usage - Quiz - Puzzle - 29 of 31](https://blog.sqlauthority.com/2012/01/30/sql-server-data-collector-usage-quiz-puzzle-29-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Reclaiming Space Back from Database - Quiz - Puzzle - 28 of 31](https://blog.sqlauthority.com/2012/01/29/sql-server-reclaiming-space-back-from-database-quiz-puzzle-28-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Lots of Date Functions - Find Right One to Use - Quiz - Puzzle - 27 of 31](https://blog.sqlauthority.com/2012/01/28/sql-server-lots-of-date-functions-find-right-one-to-use-quiz-puzzle-27-of-31/): The year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author's Perspective. Let us see a puzzle on date functions. - [SQL SERVER - Common Gotcha's Associated with Common Table Expressions (CTE) - Quiz - Puzzle - 26 of 31](https://blog.sqlauthority.com/2012/01/27/sql-server-common-gotchas-associated-with-common-table-expressions-cte-quiz-puzzle-26-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQLAuthority News - Interview with Book Authors after 2 Months of Book Released](https://blog.sqlauthority.com/2012/01/26/sqlauthority-news-interview-with-book-authors-after-2-months-of-book-released/): Community is the most motivating force for me. I have often found situations where I have done more and better things because there was community around me. My latest book SQL Server Interview Questions and Answers is the result of the community’s support and love. Without the wide acceptance of the community I would have never reached where I am. Thank you! Recently, the kind folks of INETA APAC – Sanjay Shetty and Raj Chaudhuri – conducted an interview with myself and Vinod Kumar (co-author of my book). We had lots of fun during the interview. Sanjay asks questions which, even... - [SQL SERVER - Different Aspect of Policy Based Management - Quiz - Puzzle - 25 of 31](https://blog.sqlauthority.com/2012/01/26/sql-server-different-aspect-of-policy-based-management-quiz-puzzle-25-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Correct Value for Fillfactor - Quiz - Puzzle - 24 of 31](https://blog.sqlauthority.com/2012/01/25/sql-server-correct-value-for-fillfactor-quiz-puzzle-24-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Database Mirroring and Fine-Prints - Quiz - Puzzle - 23 of 31](https://blog.sqlauthority.com/2012/01/24/sql-server-database-mirroring-and-fine-prints-quiz-puzzle-23-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - What is Piecemeal Restore - Quiz - Puzzle - 22 of 31](https://blog.sqlauthority.com/2012/01/23/sql-server-what-is-piecemeal-restore-quiz-puzzle-22-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Difference between Create Index - Drop Index - Rebuild Index - Quiz - Puzzle - 21 of 31](https://blog.sqlauthority.com/2012/01/22/sql-server-difference-between-create-index-drop-index-rebuild-index-quiz-puzzle-21-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Methods for Accessing SQL Server XML Datatype - Quiz - Puzzle - 20 of 31](https://blog.sqlauthority.com/2012/01/21/sql-server-methods-for-accessing-sql-server-xml-datatype-quiz-puzzle-20-of-31/): In this blog post, we will learn about methods for accessing SQL Server XML DataType. Here is an article which discusses the Author's Perspective. - [SQL SERVER - MERGE or INSERT, UPDATE, DELETE - Quiz - Puzzle - 19 of 31](https://blog.sqlauthority.com/2012/01/20/sql-server-merge-or-insert-update-delete-quiz-puzzle-19-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Importance of Resource Database - Quiz - Puzzle - 18 of 31](https://blog.sqlauthority.com/2012/01/19/sql-server-importance-of-resource-database-quiz-puzzle-18-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Various Ways to Create Constraints - Quiz - Puzzle - 17 of 31](https://blog.sqlauthority.com/2012/01/18/sql-server-various-ways-to-create-constraints-quiz-puzzle-17-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - CHECKPOINT Behavior and Database Recovery Models - Quiz - Puzzle - 16 of 31](https://blog.sqlauthority.com/2012/01/17/sql-server-checkpoint-behavior-and-database-recovery-models-quiz-puzzle-16-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Difference between CHAR, VARCHAR, NVARCHAR and VARCHAR(MAX) - Quiz - Puzzle - 15 of 31](https://blog.sqlauthority.com/2012/01/16/sql-server-difference-between-char-varchar-nvarchar-and-varcharmax-quiz-puzzle-15-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Using SafePeak to Accelerate Performance of 3rd Party Applications](https://blog.sqlauthority.com/2012/01/16/sql-server-using-safepeak-to-accelerate-performance-of-3rd-party-applications/): An exciting solution I found last year (2011) for SQL Server performance acceleration is SafePeak. Designed to specifically to accelerate and tune performance of cases where you have minimum control on the applications, like 3rd party line of business applications. SafePeak performs automated caching of queries and procedures results, returning with very high speed results from memory and reducing the SQL load by factor of 10. No code changes needed. And that is make it very interesting and appealing! One of the questions I hear many times concern performance acceleration of 3rd party applications applications that are critical to business function,... - [SQL SERVER - Cases When Stored Procedure RECOMPILE - Quiz - Puzzle - 14 of 31](https://blog.sqlauthority.com/2012/01/15/sql-server-cases-when-stored-procedure-recompile-quiz-puzzle-14-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Debate - Table Variables vs Temporary Tables - Quiz - Puzzle - 13 of 31](https://blog.sqlauthority.com/2012/01/14/sql-server-debate-table-variables-vs-temporary-tables-quiz-puzzle-13-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - DACPAC and SQL Azure - Quiz - Puzzle - 12 of 31](https://blog.sqlauthority.com/2012/01/13/sql-server-dacpac-and-sql-azure-quiz-puzzle-12-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Non-Clustered Index and Automatic Rebuild - Quiz - Puzzle - 11 of 31](https://blog.sqlauthority.com/2012/01/12/sql-server-non-clustered-index-and-automatic-rebuild-quiz-puzzle-11-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - A Quick Look at expressor Data Quality Solutions](https://blog.sqlauthority.com/2012/01/11/sql-server-a-quick-look-at-expressor-data-quality-solutions/): Last month I described the extension framework that allows one to easily add functionality to an expressor Studio installation.  I then used this added functionality – the input and output operators to SalesForce.com – to develop an example application.  But expressor has a second mechanism that allows you to easily enhance the functionality of your installation – reusable templates.  The idea behind this approach is that once you develop an operator that performs processing that could have value in other applications you convert this operator into a template that can be easily integrated into additional projects.  This is the approach expressor has followed... - [SQL SERVER - Reasons for Using Output Clause - Quiz - Puzzle - 10 of 31](https://blog.sqlauthority.com/2012/01/11/sql-server-reasons-for-using-output-clause-quiz-puzzle-10-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Locking, Blocking and Deadlock - Quiz - Puzzle - 9 of 31](https://blog.sqlauthority.com/2012/01/10/sql-server-locking-blocking-and-deadlock-quiz-puzzle-9-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Using RANKING Functions Instead of SQL Looping Logic of Cursor - Quiz - Puzzle - 8 of 31](https://blog.sqlauthority.com/2012/01/09/sql-server-using-ranking-functions-instead-of-sql-looping-logic-of-cursor-quiz-puzzle-8-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Indexed Views and Restrictions - Quiz - Puzzle - 7 of 31](https://blog.sqlauthority.com/2012/01/08/sql-server-indexed-views-and-restrictions-quiz-puzzle-7-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Collation and Collation Sensitivity - Quiz - Puzzle - 6 of 31](https://blog.sqlauthority.com/2012/01/07/sql-server-collation-and-collation-sensitivity-quiz-puzzle-6-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Locking and Blocking - Important Aspect of Database and Effect on Performance - Quiz - Puzzle - 5 of 31](https://blog.sqlauthority.com/2012/01/06/sql-server-locking-and-blocking-important-aspect-of-database-and-effect-on-performance-quiz-puzzle-5-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - An Important Part of Most SELECT statement - WHERE clause - Quiz - Puzzle - 4 of 31](https://blog.sqlauthority.com/2012/01/05/sql-server-an-important-part-of-most-select-statement-where-clause-quiz-puzzle-4-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQLAuthority News - I am Speaking at SQL Saturday 116 - Bangalore, India on January 7, 2012 - First SQL Saturday in India](https://blog.sqlauthority.com/2012/01/05/sqlauthority-news-i-am-speaking-at-sql-saturday-116-bangalore-india-on-january-7-2012-first-sql-saturday-in-india/): SQLSaturday 116 is now only 3 days away. SQL Saturday is FREE event all the attendees and 100% SQL community driven. This is very first SQL Saturday in India and I am very much excited that I will be speaking at this event on my favorite subject of SQL Server Performance Tuning. I have so far delivered 100s of presentation on this subject but this subject never gets old and I never ran out of new tips and tricks. I suggest you mark your calender right now and present at the hall before time to secure your seat. Session Details SQL... - [SQL SERVER - Understanding Identity Beyond its Every Increasing Nature - Quiz - Puzzle - 3 of 31](https://blog.sqlauthority.com/2012/01/04/sql-server-understanding-identity-beyond-its-every-increasing-nature-quiz-puzzle-3-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQLAuthority News - To Err is Human; to Forgive, Divine - Errata of SQL Server Interview Book](https://blog.sqlauthority.com/2012/01/04/sqlauthority-news-to-err-is-human-to-forgive-divine-errata-of-sql-server-interview-book/): Regular readers of my blog will know that I have written three books this year.  We are currently reviewing readers comments about SQL Server Interview Questions and Answers.  I am sorry to announce that we made a mistake but happy to add that we have corrected it. We will pay closer attention to the error and make sure that it does not happen again. Writing a book is a lengthy very interesting process. I have had an excellent experience in writing my recent book SQL Server Interview Questions and Answers; we had so much fun and few moments of stress, too.... - [SQL SERVER - Significance of Various Kinds of Triggers- Quiz - Puzzle - 2 of 31](https://blog.sqlauthority.com/2012/01/03/sql-server-significance-of-various-kinds-of-triggers-quiz-puzzle-2-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. Here is an article which discusses the Author’s Perspective. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Importance of ANSI ISOLATION Levels in SQL Server Database - Quiz - Puzzle - 1 of 31](https://blog.sqlauthority.com/2012/01/02/sql-server-importance-of-ansi-isolation-levels-in-sql-server-database-quiz-puzzle-1-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is the article which discusses Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz.... - [SQL SERVER - Interview Questions and Answers - Perspectives of an Author](https://blog.sqlauthority.com/2012/01/01/sql-server-interview-questions-and-answers-perspectives-of-an-author/): Today is the first day of year 2012 - Happy New Year!. This blog post is written by my co-author of SQL Server Interview Questions. - [SQLAuthority News - An Year Worth Remembering and Looking Forward to Better Next Year](https://blog.sqlauthority.com/2011/12/31/sqlauthority-news-an-year-worth-remembering-and-looking-forward-to-better-next-year/): Year 2011 will be my favorite year for long time. I have achieved many personal milestones this year. I will list few things here today, which should keep me inspired next year to do even better. Here is my blog post which I have written for January 1, 2011 SQLAuthority News – Resolution for New Year 2011. Reduced Travel Last year I traveled to six new countries and traveled internationally 11 times. This year I traveled internationally only two times and to a single country – the USA. Additionally, I traveled much less domestically. The effect of less travel is spending... - [SQLAuthority News - A Quick History of Writing Three Books in Year 2011](https://blog.sqlauthority.com/2011/12/30/sqlauthority-news-a-quick-history-of-writing-three-books-in-year-2011/): This has been an eventful year for me. I write in various formats online and offline but becoming a published author of printed book was always my dream. Every day I write continuously. Here are few of the writing tasks I do in my everyday routine. I write – Emails I write nearly 400+ emails every day. I get about 1000 emails and 10s of thousands of spam e-mails. I am thankful that 99.99% of the spam is caught by spam filters. The remaining spam I report to my email provider. However, I still get over 1000 valid emails. I do... - [SQL SERVER - Year End Brain Teaser - Disabled Login and Associated User Without Disabled User Red Arrow](https://blog.sqlauthority.com/2011/12/29/sql-server-year-end-brain-teaser-disabled-login-and-associated-user-without-disabled-user-red-arrow/): I have received lots of good responses to the puzzles, quizzes and brain teasers posted on this blog post. As the year is ending, I have decided to give two interesting puzzles for you. The first one is easy and the second one is equally uncomplicated, but let us see if any of you can come up with a logical answer to it. Puzzle 1: Find “The Hidden Tiger” Find “The Hidden Tiger” in the following image created by American wildlife artist Rusty Rust. Just to give you a hint – there is already one tiger standing and looking at us.... - [SQL SERVER - Effect of Compressed Backup Setting at Server Level on Database Backup](https://blog.sqlauthority.com/2011/12/28/sql-server-effect-of-compressed-backup-setting-at-server-level-on-database-backup/): I recently received following question from reader. I would like to share the complete story in few short sentences with you to give you complete idea. Let us call the reader Margie. Our long email conversation is converted into chat like conversation Margie: Hi Pinal – I am seeing strange behavior with regards to my database backup. Pinal: What is the exact issue? Margie: I am taking database backup with following script for more than an year and my database is of always certain size. From last six days the size of the database backup is reduced big times. There is... - [SQL SERVER - Target Recovery Time of a Database - Advance Option in SQL Server 2012](https://blog.sqlauthority.com/2011/12/27/sql-server-target-recovery-time-of-a-database-advance-option-in-sql-server-2012/): Recently I was going over few advanced options of SQL Server 2012 in database properties and I found a new option in the property screen. Properties screen of SQL Server 2008 R2 Properties screen of SQL Server 2012 I got little curious and decided to learn what does this new feature indicates. When I started to learn more about this subject, I had excellent learning experience. The default value of this option is 0. This value is directly related to Checkpoint. When it is set to greater than 0 (zero) it uses indirect-checkpoints and establishes an upper-bound on recovery time for... - [SQL SERVER - Fix: Error: 15138 - The database principal owns a schema in the database, and cannot be dropped](https://blog.sqlauthority.com/2011/12/26/sql-server-fix-error-15138-the-database-principal-owns-a-schema-in-the-database-and-cannot-be-dropped/): Last day I had excellent fun asking puzzle on SQL Server Login SQL SERVER – Merry Christmas and Happy Holidays – Database Properties – Number of Users. One of the user sent me email asking urgent question about how to resolve following error. Reader was trying to remove the login from database but every single time he was getting error and was not able to remove the user. The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138) As per him it was very urgent and he was not able to solve the same.... - [SQL SERVER - Merry Christmas and Happy Holidays - Database Properties - Number of Users](https://blog.sqlauthority.com/2011/12/25/sql-server-merry-christmas-and-happy-holidays-database-properties-number-of-users/): First of all Merry Christmas and Happy Holidays to everybody. I wish you best holiday season. In today’s blog post – I am sharing very small question received by one of the reader. Though simple sometime a small question make people think. He sent me very similar to following image and asked few questions. As his image represented his server’s information, I am reproducing very similar image using AdventureWorks database. Question: What does the number of users signifies in database properties? Does this mean current connected users or total active users or total enabled users or what exactly?” Answer: Database Properties... - [SQL SERVER - A Simple Puzzle and Simple Solution of Datatype and Computed Column](https://blog.sqlauthority.com/2011/12/24/sql-server-a-simple-puzzle-and-simple-solution-of-datatype-and-computed-column/): Christmas is just near and happy holidays to all of you. Today is Christmas eve and I decided to share something very simple but interesting with you. Recently some one reading my SQL Server Interview Questions and Answers book asked me following question. “Pinal, Instead of puzzle, or difficult interview question, I was asked following riddle in my interview. I could not answer it, do you have any idea. Riddle: Create a table with two columns but you are allowed to specify datatypes only once. Additionally, write a mechanism that your data is copied from first column to second column without... - [SQL SERVER - A Quick Script for Point in Time Recovery - Back Up and Restore](https://blog.sqlauthority.com/2011/12/23/sql-server-a-quick-script-for-point-in-time-recovery-back-up-and-restore/): Blogging is like writing a big novel in parts. It has its own mood and it has its own colors. Someday I feel like writing philosophy and some day I like writing theory and some day just a script. Today is one of the day when I just feel like providing working script for user requested frequently. Here is one of the script which I refer whenever I faced situation about restoring the database at point in time. In this demo we will see three step operations: Set up script and backup database Restore the database in point in time Clean... - [SQL SERVER - Mastering the Basics - Igniting Learning - A Unique Learning Experience](https://blog.sqlauthority.com/2011/12/22/sql-server-mastering-the-basics-igniting-learning-a-unique-learning-experience/): I had very clear idea what my goals were in the book. I believed in unique learning experience. Let us talk about it in today's blog. - [SQL SERVER - A Quick Trick about SQL Server 2012 CONCAT Function - PRINT](https://blog.sqlauthority.com/2011/12/21/sql-server-a-quick-trick-about-sql-server-2012-concat-function-print/): Yesterday I posted A Quick Trick about SQL Server 2012 CONCAT function and the very first comment in few minutes of Vinod Kumar. He suggested that this function should be also used with the PRINT statement as well. While I was having conversation with him – Jacob Sebastian sent me message suggesting the same. As I got feedback in first 10 minutes of publishing the blog post – I decided to update the blog post. While I started to write there was an email from Rick Morelan suggesting that this function can be used along with PRINT statement. Alright – 3 SQL... - [SQL SERVER - A Quick Trick about SQL Server CONCAT function](https://blog.sqlauthority.com/2011/12/20/sql-server-a-quick-trick-about-sql-server-2012-concat-function/): Just a day before I was presenting at Virtual Tech Days and I wanted to demonstrate the current time to audience using SQL Server Management Studio, I ended up a quick error. If any of you ever tried to concat multiple values of different datatype this should not be surprise to you. - [SQLAuthority News - Introduction to expressor Connectivity to Salesforce - expressor Data Integration Applications](https://blog.sqlauthority.com/2011/12/19/sql-server-introduction-to-expressor-connectivity-to-salesforce-expressor-data-integration-applications/): This month, expressor software is releasing the newest version of their data integration product – expressor 3.5.  This release includes three significant enhancements to this powerful and adaptable product: an extensibility framework, integration with Melissa Data’s data quality tools, and operators to read from and write to Salesforce.com databases. As a proof of the usability of the extensibility framework, expressor implemented their Salesforce support through an extensibility library.  In the future, as this framework is used to implement more functionality, you will be able to add new features to your expressor deployment without needing to install a newer version of the... - [SQL SERVER - AdventureWorks for SQL Server 2012 RC0 - Samples Database for SQL Server 2012 RC0](https://blog.sqlauthority.com/2011/12/18/sql-server-adventure-works-for-sql-server-2012-rc0-samples-database-for-sql-server-2012-rc0/): Microsoft has just released AdventureWorks database for SQL Server 2012 RC0. I am very happy that now I will be able to play with this new sample database and base my various demo script around the same. Here is the link to download AdventureWorks 2012 RC0 database. - [SQL SERVER - FIX - ERROR : Msg 3201, Level 16 Cannot open backup device.Operating system error 3 (The system cannot find the path specified.)](https://blog.sqlauthority.com/2011/12/17/sql-server-fix-error-msg-3201-level-16-cannot-open-backup-device-operating-system-error-3-the-system-cannot-find-the-path-specified/): I had very interesting and frustrating experience. Recently I was attempting to backup one of my database and I end up on following error. Msg 3201, Level 16, State 1, Line 1 Cannot open backup device ‘D:\Backup\SQLAuthority.bak’. Operating system error 3(The system cannot find the path specified.). Msg 3013, Level 16, State 1, Line 1 BACKUP DATABASE is terminating abnormally. Solution: Go to your drive and create the missing folder. In my case I went to Drive D and created Backup Folder there. Additional Story: If you read the first line of the blog post you will read there that I... - [SQL SERVER - 2012 Auditing Enhancement - On Audit Log Failure Options - Maximum Rollover Files](https://blog.sqlauthority.com/2011/12/16/sql-server-2012-auditing-enhancement-on-audit-log-failure-options-maximum-rollover-files/): Recently I was exploring SQL Server Audit and found something very interesting. I found two enhancements in the SQL Server 2008 Create Audit Screen. SQL Server 2012 Create Audit Screen SQL Server 2008 Create Audit Screen On Audit Log Failure Options You can see that in SQL Server 2012 they have added two more options for audit log failure. In earlier version the only option was to shut down the server when there was audit log failure. Now you can fail the operation as well continue on log failure. This new options now give finer control on the behavior of the... - [SQLAuthority News - Online Session Practical Tricks and Tips to Speed up Database Queries Today](https://blog.sqlauthority.com/2011/12/15/sqlauthority-news-online-session-practical-tricks-and-tips-to-speed-up-database-queries-today/): I am presenting on performance tuning topic again today at Virtual Tech Days. This time I am going to talk about lots of practical tips and will focus on what we can do immediately right after the session is over. During the session I have two things for you to spot. How many times, I say word “performance”? How many times, I use the phrase “It is interesting to …”? Let us see if you can tell me after the session the count. Trust me, I am not going to count there as I will be presenting so I let you... - [SQL SERVER - Explain Error:166 : does not allow specifying the database name as a prefix to the object name - Puzzle to Win SQL Server Interview Questions and Answers Book](https://blog.sqlauthority.com/2011/12/14/sql-server-explain-error166-does-not-allow-specifying-the-database-name-as-a-prefix-to-the-object-name-puzzle-to-win-sql-server-interview-questions-and-answers-book/): I was recently reading excellent Just Learned Tip regarding 3 part naming Cannot be used when dropping Views,Functions or Procedures. This is quite a well known tip however, every developer and DBA learns at sometime in their career with ‘hm…’ moment. To illustrate this further here is a simple case scenario. Setup environment CREATE DATABASE TestDB GO USE TestDB GO CREATE TABLE TestTable (ID INT) GO CREATE PROCEDURE TestSP AS SELECT 1 Col GO Drop Table The drop table will works and gives success message. DROP TABLE TestDB.dbo.TestTable GO Drop Procedure The drop procedure will give following error. DROP PROCEDURE TestDB.dbo.TestSP... - [SQL SERVER - A Quick Look at Performance - A Quick Look at Configuration](https://blog.sqlauthority.com/2011/12/13/sql-server-a-quick-look-at-performance-a-quick-look-at-configuration/): This blog post is written in response to the T-SQL Tuesday post of Tips and Tricks. For me, this is a very interesting subject. I perfectly enjoy a discussion when it is about performance tuning. I commonly get follow-up questions regarding this subject, but most of them do not give the complete information about their environment. Whenever I get a question which does not have complete information but is obviously requesting for my help, my initial reaction is to ask more questions. When I ask more details, I usually get more questions from them rather than the details I was asking... - [SQLAuthority News - Virtual Presentation on Practical Tricks and Tips to Speed up Database Queries - December 15, 2011](https://blog.sqlauthority.com/2011/12/12/sqlauthority-news-virtual-presentation-on-practical-tricks-and-tips-to-speed-up-database-queries-december-15-2011/): Performance tuning has been my favorite subject and any time when I have to present on this subject, this itself gives me tremendous pleasure as well. I am always excited to present something new on this topic. Virtual Tech Days is just here around the corner and I am going to present about performance tuning subject once again. However, I am going to focus that instead of theory, I will talk about the practical aspect of the performance tuning and share tips which one can use right away. Sessions Details Title: Practical Tricks and Tips to Speed up Database Queries Timing:... - [SQL SERVER - Fix: Error: Msg 1904, Level 16 The statistics on table has 33 column names in statistics key list. The maximum limit for index or statistics key column list is 32](https://blog.sqlauthority.com/2011/12/11/sql-server-fix-error-msg-1904-level-16-the-statistics-on-table-has-33-column-names-in-statistics-key-list-the-maximum-limit-for-index-or-statistics-key-column-list-is-32/): Earlier I wrote an article where I demonstrated that an index with more than 16 column is not possible. Here is the link to the article. After reading the same article I received email from user suggesting does it mean that statistics can be only created on only 16 columns. Well, answer is NO. One can create statistics on total of 32 columns, where as the limit of creating index is only 16 columns (and 900 bytes). Here is the quick example where when attempted to create statistics on 33 columns is generating error but when statistics are created on 32... - [SQLAuthority News - SQL Saturday 116 - SQL Saturday in Bangalore, India on January 7, 2012 - 4 Saturdays to Go](https://blog.sqlauthority.com/2011/12/10/sqlauthority-news-sql-saturday-116-sql-saturday-in-bangalore-india-on-january-7-2012-4-saturdays-to-go/): SQLSaturday 116 is now only 4 weeks away. SQL Saturday is FREE event all the attendees and 100% SQL community driven. Schedule and Venue Event Date: January 7, 2012 Event Time: 10 AM to 6 PM Event Venue: Microsoft Singature Building, Domlur, Bangalore , Bangalore, India Important Links: Register for the event – We are 100% over capacity. Please put your name on waiting list, we are working on various options. Submit your session title and abstract by December 10, 2011. Today is last day! Call to Action – Spread the words Blog, tweet, facebook it – spread the word. Use... - [SQL SERVER - 2012 RC0: Fix Setup Error: File format is not valid](https://blog.sqlauthority.com/2011/12/10/sql-server-2012-rc0-fix-setup-error-file-format-is-not-valid/): I recently had long email conversation with one of the blog reader who was struggling with installing SQL Server 2012 RC0 installation. I just thought I will publish what we have done and how we solved problem so if you are facing the same issue, you can avoid the same. In this blog post we will see how to fix setup error. - [SQL SERVER - Bad Practice of Using Keywords as an Object Name - Avoid Using Keywords as an Object](https://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/): Madhivanan is SQL Server MVP and very talented SQL expert. Here is one of the nugget he shared on Just Learned. He shared a tip where there were two interesting point to learn. Do not use keywords as an object name [read DHall’s excellent comment below] He has given excellent example how GO can be executed as stored procedure. Here is the extension of the tip. Create a small table and now just hit EXEC GO; and you will notice that there is row in the table. Create Stored Procedure CREATE PROCEDURE GO AS SELECT 1 AS NUMBER Create Table CREATE... - [SQL SERVER - Error: Deleting Offline Database and Creating the Same Name](https://blog.sqlauthority.com/2011/12/08/sql-server-error-deleting-offline-database-and-creating-the-same-name/): Offline database is very interesting subject, and there are a couple of interesting details associated with it, which one must know. There are two common queries related to offline database: 1)      My hard drive is getting full and I deleted my ‘offline’ databases. After deleting my offline databases, my hard drive is still full and there is no empty space. 2)      I recently deleted the ‘offline’ database, and now, when I am attempting to create database with the same name, it is giving me error that the database file already exists. I can see why these questions are coming up frequently.... - [SQL SERVER - Plenty of SQL Community Updates](https://blog.sqlauthority.com/2011/12/07/sql-server-plenty-of-sql-community-updates/): Every day we learn something new and we come across something which we like to read. I had decided to keep a log of things what I do during whole day. Here are few updates which I think you will find it interesting. This updates are in no specific order. Comment by David Bridge on SQL SERVER – Effect of SET NOCOUNT on @@ROWCOUNT David has written comment and clarified the message which I wanted to pass while writing blog post. I wish I had written the statement “NOCOUNT statement only affects the information messages and not the DML statement results ”... - [SQLAuthority News - SQL Server Interview Questions and Answers Available on Kindle Format as eBook to Download](https://blog.sqlauthority.com/2011/12/06/sqlauthority-news-sql-server-interview-questions-and-answers-available-on-kindle-format-as-ebook-to-download/): Reading the books on Kindle seems to be very popular. Since our new book released a month ago, we have received so many request from users regarding making it available on Kindle. Well, today we have acknowledge the request. Our new book is available to purchase on kindle. SQL Server Interview Questions and Answers on Kindle I am really impressed how kindle ebook format works. If I find any errata or make changes in the kindle format book now and re-publish the book in kindle format again, if you have purchased the eBook earlier, you will get updated version automatically and... - [SQLAuthority News - SQL Saturday 116 - SQL Saturday in Bangalore, India on January 7, 2012](https://blog.sqlauthority.com/2011/12/05/sqlauthority-news-sql-saturday-116-sql-saturday-in-bangalore-india-on-january-7-2012/): This is the biggest news for SQL Enthusiast in India. SQL Saturday is here in India. PASS SQLSaturday’s are free 1-day training events for SQL Server professionals that focus on local speakers, providing a variety of high-quality technical sessions, and making it all happen through the efforts of volunteers. We think you’ll find it’s a great way to spend a Saturday – or any day. SQL Saturday is FREE event all the attendees and 100% SQL community driven. Schedule and Venue Event Date: January 7, 2012 Event Time: 10 AM to 6 PM Event Venue: Microsoft Singature Building, Domlur, Bangalore ,... - [SQL SERVER - What is Page Life Expectancy (PLE) Counter](https://blog.sqlauthority.com/2010/12/13/sql-server-what-is-page-life-expectancy-ple-counter/): During performance tuning consultationconsultation, there are plenty of counters and values, I often come across. Today we will quickly talk about Page Life Expectancy counter, which is commonly known as PLE as well. You can find the value of the PLE by running the following query. SELECT [object_name], [counter_name], [cntr_value] FROM sys.dm_os_performance_counters WHERE [object_name] LIKE '%Manager%' AND [counter_name] = 'Page life expectancy' The recommended value of the PLE counter is (updated: minimum of) 300 seconds. I have seen on busy system this value to be as low as even 45 seconds and on unused system as high as 1250 seconds. Page... - [SQL SERVER - Activity Monitor and Performance Issue](https://blog.sqlauthority.com/2010/12/12/sql-server-activity-monitor-and-performance-issue/): We had a wonderful SQLAuthority News – Community Tech Days – December 11, 2010 event yesterday. During this event SQL Expert Jacob shared a very interesting story related to activity monitor. - [SQLAuthority News - SQL Server 2008 R2 System Views Map](https://blog.sqlauthority.com/2010/12/11/sqlauthority-news-sql-server-2008-r2-system-views-map/): SQL Server 2008 R2 System Views Map is released. I am very proud that my organization (Solid Quality Mentors) is part of making this possible. This map shows the key system views included in SQL Server 2008 and 2008 R2, and the relationships between them. SQL Server 2008 R2 System Views Map Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SEVER - Finding Memory Pressure - External and Internal](https://blog.sqlauthority.com/2010/12/10/sql-sever-finding-memory-pressure-external-and-internal/): The following query will provide details of external and internal memory pressure. It will return the data how much portion in the existing memory is assigned to what kind of memory type. - [SQLAuthority News - Community Tech Days - SharePoint Server](https://blog.sqlauthority.com/2010/12/09/sqlauthority-news-community-tech-days-sharepoint-server/): Community Tech Days are very close on December 11. I will be speaking in the following session. Best Database Practice for SharePoint Server. - [SQL SERVER - Installing AdventureWorks for SQL Server](https://blog.sqlauthority.com/2010/12/08/sql-server-installing-adventureworks-for-sql-server-2011/): I just began with SQL Server 2012. The very first thing, I realized that there is no AdventureWorks Sample Database available for Denali. I quickly searched online and reached to Microsoft documentation where it provides information on the how to install (restore) AdventureWorks for SQL Server . - [SQLAuthority News - A Successful Performance Tuning Seminar at Pune - Dec 4-5, 2010](https://blog.sqlauthority.com/2010/12/07/sqlauthority-news-a-successful-performance-tuning-seminar-at-pune-dec-4-5-2010/): This is report to my third of very successful seminar event on SQL Server Performance Tuning. SQL Server Performance Tuning Seminar in Colombo was oversubscribed with total of 35 attendees. You can read the details over hereSQLAuthority News – SQL Server Performance Optimizations Seminar – Grand Success – Colombo, Sri Lanka – Oct 4 – 5, 2010. SQL Server Performance Tuning Seminar in Hyderabad was oversubscribed with total of 25 attendees. You can read the details over here SQL SERVER – A Successful Performance Tuning Seminar – Hyderabad – Nov 27-28, 2010. The same Seminar was offered in Pune on December... - [SQL SERVER - Solution - Challenge - Puzzle - Usage of FAST Hint](https://blog.sqlauthority.com/2010/12/06/sql-server-solution-challenge-puzzle-usage-of-fast-hint/): Earlier I had posted quick puzzle and I had received wonderful response to the same from Brad Schulz. Today we will go over the solution. The puzzle was posted here: SQL SERVER – Challenge – Puzzle – Usage of FAST Hint The question was in what condition the hint FAST will be useful. In the response to this puzzle blog post here is what SQL Server Expert Brad Schulz has pointed me to his blog post where he explain how FAST hint can be useful. I strongly recommend to read his blog post over here. With the permission of the Brad,... - [SQL SERVER - Puzzle - Error While Converting Money to Decimal](https://blog.sqlauthority.com/2010/12/05/sql-server-solution-puzzle-challenge-error-while-converting-money-to-decimal/): Earlier I had posted quick puzzle about Converting Money and I had received a wonderful response to the same. Let us go over the solution. The puzzle was posted here: SQL SERVER – Puzzle – Challenge – Error While Converting Money to Decimal - [SQLAuthority News - Statistics Used by the Query Optimizer in Microsoft SQL Server 2008 - Microsoft Whitepaper](https://blog.sqlauthority.com/2010/12/04/sqlauthority-news-statistics-used-by-the-query-optimizer-in-microsoft-sql-server-2008-microsoft-whitepaper/): I recently presented session on Statistics and Best Practices in Virtual Tech Days on Nov 22, 2010. The sessions was very popular and I got many questions right after the sessions. The number question I had received was where everybody can get the further information. I am very much happy that my sessions created some curiosity for one of the most important feature of the SQL Server. Statistics are the heart of the SQL Server. Let us read about Statistics Used by the Query Optimizer in Microsoft SQL Server 2008. - [SQL SERVER - A Successful Performance Tuning Seminar - Hyderabad - Nov 27-28, 2010 - Next Pune](https://blog.sqlauthority.com/2010/12/03/sql-server-a-successful-performance-tuning-seminar-hyderabad-nov-27-28-2010-next-pune/): My recent SQL Server Performance Tuning Seminar in Colombo was oversubscribed with total of 35 attendees. You can read the details over here SQLAuthority News – SQL Server Performance Optimizations Seminar – Grand Success – Colombo, Sri Lanka – Oct 4 – 5, 2010. I had recently completed another seminar in Hyderabad which was again blazing success. We had 25 attendees to the seminar and had wonderful time together. There is one thing very different between usual class room training and this seminar series. In this seminar series we go 100% demo oriented and real world scenario deep down. We do not... - [SQLAuthority News - Community Tech Days - A SQL Legends in Ahmedabad - December 11, 2010](https://blog.sqlauthority.com/2010/12/02/sqlauthority-news-community-tech-days-a-sql-legends-in-ahmedabad-december-11-2010/): Ahmedabad is going to be fortunate city again on December 11. We are going to have SQL Server Legends present at the prestigious event of Community Tech Days in Ahmedabad. The venue details are as following: H K Hall, H K College Campus, Near Handloom House, Opp. Natraj Cinema, Ashram Road, Ahmedabad – 380009 Click here to Registration for the event. Agenda of the event is as following. 10:15am – 10:30am     Welcome – Pinal Dave 10:30am – 11:15am     SQL Tips and Tricks for .NET Developers by Jacob Sebastian 11:15am – 11:30am     Tea Break 11:30am – 12:15pm     Best... - [SQL SERVER - 3 Simple Puzzles - Need Your Suggestions](https://blog.sqlauthority.com/2010/12/01/sql-server-3-simple-puzzles-need-your-suggestions/): Last Month, I have posted three Simple Puzzles and I got very good response. I think there can be many interesting answers there. I would like to request all of you to take part the puzzles and provide your answer. I plant to consolidate answers and publish all the valid answers on this blog with due credit. SQL SERVER – Challenge – Puzzle – Usage of FAST Hint SQL SERVER – Puzzle – Challenge – Error While Converting Money to Decimal SQL SERVER – Challenge – Puzzle – Why does RIGHT JOIN Exists I am also thinking that after such a... - [SQL SERVER - Automated Type Conversion using Expressor Studio](https://blog.sqlauthority.com/2010/11/30/sql-server-automated-type-conversion-using-expressor-studio/): Recently I had an interesting situation during my consultation project. Let me share to you how I solved the problem using Expressor Studio. Consider a situation in which you need to read a field, such as customer_identifier, from a text file and pass that field into a database table. In the source file’s metadata structure, customer_identifier is described as a string; however, in the target database table, customer_identifier is described as an integer. Legitimately, all the source values for customer_identifier are valid numbers, such as “109380”. To implement this in an ETL application, you probably would have hard-coded a type conversion... - [SQL SERVER - DBA or DBD? - Database Administrator or Database Developer](https://blog.sqlauthority.com/2010/11/29/sql-server-dba-or-dbd-database-administrator-or-database-developer/): Earlier this month, I had poll on this blog where I asked question – Are you a Database Administrator or Database Developer? The word DBA (Database Administrator) is very common but DBD (Database Developer) is not common at all. This made me think – what is the ratio of the same. Here the result of the poll: Database Administrator 36.6% (254 votes) Database Developer 63.4% (440 votes) Total Votes: 694 This is open poll, if you want you can still participate here. Vote your Voice – DBD or DBA? I think it is the time when DBD word for Database Developer... - [SQL SERVER - Challenge - Puzzle - Why does RIGHT JOIN Exists](https://blog.sqlauthority.com/2010/11/28/sql-server-challenge-puzzle-why-does-right-join-exists/): I had interesting conversation with the attendees of the my SQL Server Performance Tuning course. I was asked if LEFT JOIN can do the same task as RIGHT JOIN by reserving the order of the tables in join, why does RIGHT JOIN exists? The definitions are as following: Left Join – select all the records from the LEFT table and then pick up any matching records from the RIGHT table   Right Join – select all the records from the RIGHT table and then pick up any matching records from the LEFT table Most of us read from LEFT to RIGHT... - [SQL SERVER - Puzzle - Challenge - Error While Converting Money to Decimal](https://blog.sqlauthority.com/2010/11/27/sql-server-puzzle-challenge-error-while-converting-money-to-decimal/): Earlier I wrote SQL SERVER – Challenge – Puzzle – Usage of FAST Hint and I did receive some good comments. Here is another question to tease your mind. Run following script and you will see that it will thrown an error. DECLARE @mymoney MONEY; SET @mymoney = 12345.67; SELECT CAST(@mymoney AS DECIMAL(5,2)) MoneyInt; GO The datatype of money is also visually look similar to the decimal, why it would throw following error: Msg 8115, Level 16, State 8, Line 3 Arithmetic overflow error converting money to data type numeric. Please leave a comment with explanation and I will post a your... - [SQL SERVER - Challenge - Puzzle - Usage of FAST Hint](https://blog.sqlauthority.com/2010/11/26/sql-server-challenge-puzzle-usage-of-fast-hint/): I was recently working with various SQL Server Hints. After working for a day on various hints, I realize that for one hint, I am not able to come up with good example. The hint is FAST. Let us look at the definition of the FAST hint from the Book On-Line. FAST number_rows Specifies that the query is optimized for fast retrieval of the first number_rows. This is a nonnegative integer. After the first number_rows are returned, the query continues execution and produces its full result set. Now the question is in what condition this hint can be useful. I have... - [SQL SERVER - Concat Function in SQL Server - SQL Concatenation](https://blog.sqlauthority.com/2010/11/25/sql-server-concat-function-in-sql-server-sql-concatenation/): Earlier this week, I was delivering Advanced BI training on the subject of “SQL Server 2008 R2”. I had a great time delivering the session. During the session, we talked about SQL Server 2012 Denali. Suddenly one of the attendees suggested his displeasure for the product. He said, even though, SQL Server is now in moving very fast and have proved many times a better enterprise solution, it does not have some basic functions. I naturally asked him for an example and he suggested CONCAT() which exists in MySQL and Oracle. The answer is very simple – the equivalent function in... - [SQLAuthority News - What's New in SQL Server "Denali"](https://blog.sqlauthority.com/2010/11/24/sqlauthority-news-whats-new-in-sql-server-denali/): I was today doing SQL Server Advanced Training at Bangalore and I had few attendees asked me if I can give them review of the SQL Server Denali. I had not downloaded Denali on my work computer so I could not do demonstration of the same. However, I promised to blog about with additional details very next day. Denali is also known as SQL 11 and the compatibility mode number is 110. Here are few details about it. What is new in SQL Server “Denali” Download CTP1 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQLPASS Nov 8-11, 2010-Seattle - An Alternative Look at Experience](https://blog.sqlauthority.com/2010/11/23/sqlauthority-news-sqlpass-nov-8-11-2010-seattle-an-alternative-look-at-experience/): I recently attended most prestigious SQL Server event SQLPASS between Nov 8-11, 2010 at Seattle. I have only one expression for the event – Best Summit Ever This year the summit was at its best. Instead of writing about my usual routine or the event, I am going to write about the interesting things I did and how I felt about it! Trip to Seattle! This was my second trip to Seattle this year and the journey is always long. Here is the travel stats on how long it takes to get to Seattle: 24 hours official air time 36 hours... - [SQLAuthority News - Statistics and Best Practices - Virtual Tech Days - Nov 22, 2010](https://blog.sqlauthority.com/2010/11/22/sqlauthority-news-statistics-and-best-practices-virtual-tech-days-nov-22-2010/): I am honored that I have been invited to speak at Virtual TechDays on Nov 22, 2010 by Microsoft. I will be speaking on my favorite subject of Statistics and Best Practices. This exclusive online event will have 80 deep technical sessions across 3 days – and, attendance is completely FREE. There are dedicated tracks for Architects, Software Developers/Project Managers, Infrastructure Managers/Professionals and Enterprise Developers. So, REGISTER for this exclusive online event TODAY. Statistics and Best Practices Timing: 11:45am-12:45pm Statistics are a key part of getting solid performance. In this session we will go over the basics of the statistics and... - [SQL SERVER - Change Database Access to Single User Mode Using SSMS](https://blog.sqlauthority.com/2010/11/21/sql-server-change-database-access-to-single-user-mode-using-ssms/): I have previously written about how using T-SQL Script we can convert the database access to single user mode before backup. I was recently asked if the same can be done using SQL Server Management Studio. Yes! You can do it from database property (Write click on database and select database property) and follow image. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Beginning T-SQL 2008 by Kathi Kellenberger](https://blog.sqlauthority.com/2010/11/20/sqlauthority-news-book-review-beginning-t-sql-2008-by-kathi-kellenberger/): Beginning T-SQL 2008 by Kathi Kellenberger Amazon Link Detail Review: Beginning T-SQL 2008 is one of the best books on the market if you are just beginning to work with Microsoft SQL, or have a little bit of experience and need to learn more quickly. Each chapter of the book introduces a new subject, and builds upon topics covered in previous chapters.  The author of the book, Kathi Kellenberger understands that you need to form a solid foundation of knowledge before moving on to new topics, and sets up each subject nicely.  Because the chapters move in an orderly progression, you... - [SQLAuthority News - Blog Stats Revealed ](https://blog.sqlauthority.com/2010/11/19/sqlauthority-news-blog-stats-revealed/): I often receive praises, questions, suggestions and skeptical emails regarding my blog stats. Let me put everything aside and open up my stats page for all. I use wordpress.com and stats are maintained by them. Every month, I will put the blog stats on the following page for every one’s consumption. View SQLAuthority Stats If you still have question – do ask me :) Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server Performance Series Hyderabad / Pune - Nov/Dec 2010](https://blog.sqlauthority.com/2010/11/18/sqlauthority-news-sql-server-performance-series-hyderabad-pune-novdec-2010/): Just a quick note that SQL Server Performance Tuning and Optimizations Seminar series which I am offering at Hyderabad and Pune are almost all sold out. Read the details of the earlier successful seminar conducted at Colombo, Sri Lanka over here. Hyderabad Nov 27-28, 2010 (Last 3 Seats Left) Best Western Amrutha Castle 5-9-16, Opp. Secretriat, Saifabad, Khairatabad Hyderabad, Andhra Pradesh Pune Dec 04-05, 2010 (Last 6 Seats Left) Location TBA as we are looking for larger capacity room. I promise that this is going to be great fun as this sessions are very different then any usual sessions you have... - [SQL SERVER - History of SQL Server Database Encryption](https://blog.sqlauthority.com/2010/11/17/sql-server-history-of-sql-server-database-encryption/): I recently met Michael Coles and Rodeney Landrum the author of one of the kind book Expert SQL Server 2008 Encryption at SQLPASS in Seattle. During the conversation we ended up how Microsoft is evolving encryption technology. The same discussion lead to talking about history of encryption tools in SQL Server. Michale pointed me to page 18 of his book of encryption. He explicitly give me permission to re-produce relevant part of history from his book. Encryption in SQL Server 2000 Built-in cryptographic encryption functionality was nonexistent in SQL Server 2000 and prior versions. In order to get server-side encryption in... - [SQLAuthority News - Download Whitepaper - Understanding and Controlling Parallel Query Processing in SQL Server](https://blog.sqlauthority.com/2010/11/16/sqlauthority-news-download-whitepaper-understanding-and-controlling-parallel-query-processing-in-sql-server/): My recently article SQL SERVER – Reducing CXPACKET Wait Stats for High Transactional Database has received many good comments regarding MAXDOP 1 and MAXDOP 0. I really enjoyed reading the comments as the comments are received from industry leaders and gurus. I was further researching on the subject and I end up on following white paper written by Microsoft. Understanding and Controlling Parallel Query Processing in SQL Server Data warehousing and general reporting applications tend to be CPU intensive because they need to read and process a large number of rows. To facilitate quick data processing for queries that touch a large... - [SQL SERVER - Information Related to DATETIME and DATETIME2](https://blog.sqlauthority.com/2010/11/15/sql-server-information-related-to-datetime-and-datetime2/): I recently received interesting comment on the blog regarding workaround to overcome the precision issue while dealing with DATETIME and DATETIME2. I have written over this subject earlier over here. SQL SERVER – Difference Between GETDATE and SYSDATETIME SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE SQL SERVER – Difference Between DATETIME and DATETIME2 SQL Expert Jing Sheng Zhong has left following comment: The issue you found in SQL server new datetime type is related time source function precision. Folks have found the root reason of the problem – when data time values are converted (implicit or explicit)... - [SQL SERVER – FIX ERROR 3702 Cannot drop database “MyDBName” because it is currently in use](https://blog.sqlauthority.com/2010/11/14/sql-server-error-fix-msg-3702-level-16-state-3-line-1-cannot-drop-database-mydbname-because-it-is-currently-in-use/): I often go to do various seminars and presentations at various organizations. During presentations I often create and drop various databases for the demonstration's purpose. Recently in one of the presentations, I tried to remove my recently created database, I got following error 3702 which is related to user cannot drop database. - [SQL SERVER - Reducing CXPACKET Wait Stats for High Transactional Database](https://blog.sqlauthority.com/2010/11/13/sql-server-reducing-cxpacket-wait-stats-for-high-transactional-database/): While engaging in a performance tuning consultation for a client, a situation occurred where they were facing a lot of CXPACKET Waits Stats. The client asked me if I could help them reduce this huge number of wait stats. I usually receive this kind of request from other client as well, but the important thing to understand is whether this question has any merits or benefits, or not. Before we continue the resolution, let us understand what CXPACKET Wait Stats are. The official definition suggests that CXPACKET Wait Stats occurs when trying to synchronize the query processor exchange iterator. You may... - [SQL SERVER - Get All the Information of Database using sys.databases](https://blog.sqlauthority.com/2010/11/12/sql-server-get-all-the-information-of-database-using-sys-databases/): Earlier I wrote blog article SQL SERVER – Finding Last Backup Time for All Database. In the response of this article I have received very interesting script from SQL Server Expert Matteo as a comment in the blog. He has written script using sys.databases which provides plenty of the information about database. I suggest you can run this on your database and know unknown of your databases as well. SELECT database_id, CONVERT(VARCHAR(25), DB.name) AS dbName, CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, 'status')) AS [Status], state_desc, (SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'rows') AS DataFiles, (SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id)... - [SQLAuthority News - SQL Server Denali CTP1 - Release Date November 9, 2010](https://blog.sqlauthority.com/2010/11/11/sqlauthority-news-sql-server-2011-release-date-november-9-2010/): I am very excited as I was about to witness SQL Server 2011 – Code Named “Denali” is released on November 11, 2010 at SQLPASS. I will write a detail report for the same in future. You can download CTP1 right away right now and install on your machine. The major features of the new products are as following: Enhanced Mission-Critical Platform: an enhanced highly available and scalable platform. Developer and IT Productivity: new innovative productivity tools and features. Pervasive Insight: expanding the reach of BI to business users and end-to-end data integration and management. I am going to download the... - [SQL SERVER - Get Database Backup History for a Single Database](https://blog.sqlauthority.com/2010/11/10/sql-server-get-database-backup-history-for-a-single-database/): I recently wrote article SQL SERVER – Finding Last Backup Time for All Database and requested blog readers to respond with their own script which they use it Database Backup. Here is the script suggested by SQL Expert aasim abdullah, who has written excellent script which goes back and retrieves the history of any single database. USE AdventureWorks GO -- Get Backup History for required database SELECT TOP 100 s.database_name, m.physical_device_name, CAST(CAST(s.backup_size / 1000000 AS INT) AS VARCHAR(14)) + ' ' + 'MB' AS bkSize, CAST(DATEDIFF(second, s.backup_start_date, s.backup_finish_date) AS VARCHAR(4)) + ' ' + 'Seconds' TimeTaken, s.backup_start_date, CAST(s.first_lsn AS VARCHAR(50)) AS... - [SQL SERVER - Recycle Error Log - Create New Log file without Server Restart](https://blog.sqlauthority.com/2010/11/09/sql-server-recycle-error-log-create-new-log-file-without-server-restart/): The job of a consultant is always interesting – sometimes one becomes very busy and at times, over busy. I have been overwhelmed with recent performance tuning engagements. In one of the recent engagements, a large number of errors were found in the server. I noticed that their error log filled up very quickly. I also noticed a very interesting action by their DBA. I observed that after we make some changes in the server to avoid the errors, the DBA restarted the server. I asked him the reason for doing so. He explained every time that when he restarts the server, a new error log file is created. The current log file is renamed as errorlog.1; errorlog.1 becomes errorlog.2, and in a similar way, it continues. This way, after making some change, we can watch the error file from the beginning. - [SQLAuthority News – Why I am Going to Attend PASS Summit Unite 2010 – Seattle](https://blog.sqlauthority.com/2010/11/08/sqlauthority-news-why-i-am-going-to-attend-pass-summit-unite-2010-seattle/): I am once again attending SQLPASS this year.When I told this to my friend that I am going to SQL PASS again, he has the same question, which quite often many people ask. WHY? I had earlier wrote article on this subject. I am writing it again the same. The reason is simple – I love it! Why should I attend PASS Summit There is not one or two but a number of reasons regarding why I should be a part of PASS Summit. First, it is a good platform to learn the latest skills and strategies through over 160 expert-led... - [SQLAuthority News – Presenting at South East Asia SharePoint Conference – Oct 26, 27, 2010 – Singapore](https://blog.sqlauthority.com/2010/11/07/sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference/): Every SharePoint site runs on SQL Server and most of the SharePoint sites face issues with performance due to suboptimal configuration of underlying SQL Server. Recently, I presented a session on SharePoint and SQL Server Performance at Singapore on Oct 26-27, 2010. It was South East Asia SharePoint Conference, and I must say, the event was a blast! Pinal Dave presenting at SharePoint Conference at Singapore This was very a unique event in Asian Sub-Continent and also one of the best managed conferences that I have attended thus far. The location of the event was very good, and the rooms were... - [SQLAuthority News - Last Day to Participate in my Questions at SQL Quiz](https://blog.sqlauthority.com/2010/11/06/sqlauthority-news-last-day-to-participate-in-my-questions-at-sql-quiz/): My very good friend, Jacob Sebastian, is running a month-long SQL Quiz Series where the best-of-the-best experts from around the globe would be the quiz masters. They will ask one question every day, and users are expected to answer them correctly. The winning prizes include cool gadgets like iPAD, Kindle and many more. I am one of the quiz masters, and my question is published here: The View, The Table and The Clustered Index Confusion. I have asked there three questions. Q1. Does the table use an index created on itself? Q2. Does the view use an index created on itself?... - [SQLAuthority News - Happy Deepavali and Happy News Year](https://blog.sqlauthority.com/2010/11/05/sqlauthority-news-happy-deepavali-and-happy-news-year/): Diwali (also spelled Divali in other countries) or Deepavali is popularly known as the festival of lights. It literally means “array of light”. Diwali is the most important festival of the year and is celebrated with families performing traditional activities together in their homes. Deepavali is an official holiday in India. I pretty much work every day except today. I dedicate this day to my family. This is their day. Every year on Deepavali I share a database tips with all of my blog readers. I quite often get ask if I can help people with their systems performance. I am... - [SQL SERVER - Finding Last Backup Time for All Database](https://blog.sqlauthority.com/2010/11/04/sql-server-finding-last-backup-time-for-all-database/): Here is the quick script I use find last backup time for all the database in my server instance. - [SQL SERVER - Fix: Error: MS Jet OLEDB 4.0 cannot be used for distributed queries because the provider is used to run in apartment mode.](https://blog.sqlauthority.com/2010/11/03/sql-server-fix-error-ms-jet-oledb-4-0-cannot-be-used-for-distributed-queries-because-the-provider-is-used-to-run-in-apartment-mode/): I recently got email from blog reader with following error. MS Jet OLEDB 4.0 cannot be used for distributed queries because the provider is used to run in apartment mode. The fix of the same is very easy. Fix/Workaround/Resolution: sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ad Hoc Distributed Queries', 1; GO RECONFIGURE; GO If you are still facing the error after running above statement please leave a comment here and I will do my best to help you out. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Are you a Database Administrator or a Database Developer?](https://blog.sqlauthority.com/2010/11/02/sql-server-are-you-a-database-administrator-or-a-database-developer/): This blog post is written in response to T-SQL Tuesday hosted by Paul Randal. I think following questions has been always very interesting question for everybody who is working with SQL Server. Are you a Database Administrator or Database Developer? The answer of this question varies from organizations to organizations and to countries to countries. Quite often I see people call them developer and doing tasks of backup and restore of the database. Often I see Administrator writing efficient code in application development. I totally understand that it is almost impossible to draw a line and quite often we are comfortable... - [SQLAuthority News - 4th Birthday of Blog - 20 Million Views - Blog Anniversary - A Milestone](https://blog.sqlauthority.com/2010/11/01/sqlauthority-news-4th-birthday-of-blog-blog-anniversary-a-milestone/): Today is Nov 1, 2010. Four years ago, on the same day of the year 2006,  I wrote my first blog without thinking or even understanding where this blog was going to. The reason I started blogging was very simple- I just wanted to keep a note of what I learn every day. It was really that simple. This blog also have completed 20 Million Views! I will post a detail statistics very soon in separate post. Today is this blog’s 4th birthday. It has completed the long journey of 4 years. I previously explained the reason of the origin of... - [SQLAuthority News – New Banner of Blog](https://blog.sqlauthority.com/2010/10/31/sqlauthority-news-new-banner-of-blog/): As this blog is approaching 4th anniversary, I have decided to change few things in this blog. I have finally decided to change the blog banner and I have created internal poll for the blog banner. I have uploaded the winning banner as the title of the blog and I liked it a lot. I would like to know your opinion about the same. The changes I have done from the previous banners are Bigger Images Bigger Logo A cleaning up edges Please visit the site https://blog.sqlauthority.com/ and give me your opinion about banner. Reference: Pinal Dave (https://blog.sqlauthority.com)   - [SQL SERVER - Minimum Maximum Memory - Server Memory Options](https://blog.sqlauthority.com/2010/10/30/sql-server-minimum-maximum-memory-server-memory-options/): I was recently reading about SQL Server Memory Options over here. While reading this one line really caught my attention is minimum value allowed for maximum memory options. The default setting for min server memory is 0, and the default setting for max server memory is 2147483647. The minimum amount of memory you can specify for max server memory is 16 megabytes (MB). This was very interesting to me as I was not familiar with this details. This was one interesting detail for me. In reality I will never set up my max server memory to 16 MB, it will be right... - [SQL SERVER - List of all the Views from Database](https://blog.sqlauthority.com/2010/10/29/sql-server-list-of-all-the-views-from-database/): My earlier article SQL SERVER – The Limitations of the Views – Eleven and more… has lots of popularity and I have been asked many questions on the view. Many emails I received suggesting that they have hundreds of the view and now have no clue what is going on and how many of them have indexes and how many does not have an index. Some even asked me if there is any way they can get a list of the views with the property of Index along with it. - [SQLAuthority News – Blog of Nupur Dave on Windows Live](https://blog.sqlauthority.com/2010/10/28/sqlauthority-news-blog-of-nupur-dave-on-windows-live/): Blog are way to express ourselves; Blogs are bookmarks of my learning process and blogs reflects us. My Wife Nupur, an avid user of Windows Live, has decided to start blogging on the subject. There was lots of discussion between us regarding if she really wants to blog or keep her learning offline. One of the discussions we had was regarding what new she can add to the world which is already populated and overloaded with information. Her answer was very simple: “My perspective“. I respect her for the same and that is why she is blogging now. The blog is just... - [SQL SERVER - SQL Challenge - SQL Puzzle - Query Creating Most TempDB IO Usage](https://blog.sqlauthority.com/2010/10/27/sql-server-sql-challenge-sql-puzzle-query-creating-most-tempdb-io-usage/): Recently, there have been a lot of interesting concepts in various challenges. My friend Jacob Sebastian is running the SQLQuiz for the entire month, and it has been very popular and going just great. So here I thought I would put something very similar to the quiz bee. The award here is simple, all valid answers will be published on this blog with due credit to you, plus the credit would link back to your desired profile. Now the question is: What are the queries which are creating lots of IO operations in TempDB? You can use any DMV to answer... - [SQLAuthority News - Database Performance for SharePoint Sites - Session Tomorrow in Singapore](https://blog.sqlauthority.com/2010/10/26/sqlauthority-news-database-performance-for-sharepoint-sites-session-tomorrow-in-singapore/): I am all excited to present my very first session on Database Performance for SharePoint Sites. Here is the details for my session which is planned for tomorrow. Grand Copthorne Waterfront Hotel Singapore 392 Havelock Road Singapore 169663 My Sessions details: Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site! Date: Oct 27, 2010 Time: 1:30 PM Venue: Grand Copthorne Waterfront Hotel (Waterfront Conference Centre) During the session I will be presenting three demos. I have worked hard to come up with this demos. Here is the details for the same. SQLAuthority News – SQLAuthority News – Presenting at... - [SQL SERVER – A Brief Introduction to DW 2.0](https://blog.sqlauthority.com/2010/10/25/sql-server-a-brief-introduction-to-dw-2-0/): The traditional form of storing digital data has been disk storage.  However, the huge advances in technology means that there has been a huge need for data storage to evolve to keep up with the fast-changing times.  Microsoft SQL Server has gone through a huge overhaul in order to keep up with the amount of data storage that is necessary, and that is where data warehousing comes into play. For many online applications, there is a need to not only access small amount of information from disk storage, but large amounts in the forms of sets.  SQL Server allows access to... - [SQL SERVER - Corrupted Backup File and Unsuccessful Restore](https://blog.sqlauthority.com/2010/10/24/sql-server-corrupted-backup-file-and-unsuccessful-restore/): If you are an SQL Server Consultant, there is never a single dull moment in your life. Quite often you are called in for fixing something, but then you always end up fixing something else! I was recently working on an offshore project where I was called in to tune high transaction OLTP server. During work, I demanded that I should have a server which is very similar to live database so I could inspect all the settings and data. I may end up running a few queries which may or may not change the server settings. The Sr. DBA agreed... - [SQL SERVER - Taking Multiple Backup of Database in Single Command - Mirrored Database Backup](https://blog.sqlauthority.com/2010/10/23/sql-server-taking-multiple-backup-of-database-in-single-command-mirrored-database-backup/): I recently had a very interesting experience. In one of my recent consultancy works, I was told by our client that they are going to take the backup of the database and will also a copy of it at the same time. I expressed that it was surely possible if they were going to use a mirror command. In addition, they told me that whenever they take two copies of the database, the size of the database, is always reduced. Now this was something not clear to me, I said it was not possible and so I asked them to show... - [SQLAuthority News – SQLAuthority News – Presenting at South East Asia SharePoint Conference – Demo Details](https://blog.sqlauthority.com/2010/10/22/sqlauthority-news-sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference-demo-details/): I will be Presenting at South East Asia SharePoint Conference – Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site. I am very excited beuse this is going to be my very first series of presentations at SharePoint Conference. Since I posted details about the event, I have been asked many times about the kind of demo I will be having in the session. If you are a regular reader of this blog, you know that my core area is performance tuning. I am going to focus on the same subject when I present at the SharePoint Conference. I... - [SQLAuthority News - Book Review - Beginning SQL Joes 2 Pros: The SQL Hands-On Guide for Beginners](https://blog.sqlauthority.com/2010/10/21/sqlauthority-news-book-review-beginning-sql-joes-2-pros-the-sql-hands-on-guide-for-beginners/): Beginning SQL Joes 2 Pros: The SQL Hands-On Guide for Beginners Rick A Morelan, Doug Fritz Link to Amazon Short Review: This is one book that provides a solid fundamental to the reader along with hands-on experience  and in-depth learning. Right now, an error-free book that is closer to real world scenarios is very much in need. This one fundamental book can take the reader for a wonderful ride, where he/she can learn the advanced aspects of the subject very quickly. Instead of pure theory, this book focuses on real diagrams, examples or just a pure old–school-style exercise, which appeals the... - [SQL SERVER – Could not connect to TCP error code 10061: No connection could be made because the target machine actively refused it](https://blog.sqlauthority.com/2010/10/20/sql-server-could-not-connect-to-tcp-error-code-10061-no-connection-could-be-made-because-the-target-machine-actively-refused-it/): I was recently getting following error in my StreamInsight Application. Could not connect to  TCP error code 10061: No connection could be made because the target machine actively refused it. The solution was very simple, I had to enable exception of the my port in my windows firewall. The way I figured it out  was by quickly disabling the firewall (it was not a production server). Once I disabled it, the application just worked fine; this was a sign that the firewall was the cause of the issue, I right away enabled firewall and added my port as exception. So many... - [SQLAuthority News - SQL Server Performance Optimizations Seminar - Grand Success - Colombo, Sri Lanka - Oct 4 - 5, 2010](https://blog.sqlauthority.com/2010/10/19/sqlauthority-news-sql-server-performance-optimizations-seminar-grand-success-colombo-sri-lanka-oct-4-5-2010/): I have been on world tour on SQL Server Performance Optimizations Seminar. The latest seminar was conducted in Colombo, Sri Lanka on Oct 4 – Oct 5. I had previously written about this event over SQLAuthority News – SQL Server Seminar at Colombo Full. This event was oversubscribed and we could not accommodate the last few nominations due to the restrictions of the place. We had total of 35 attendees and the event offered lots of fun. The attendees were a perfect combination – all had few years of experience and many of them were responsible for performance for their server.... - [SQL SERVER - Change Column DataTypes](https://blog.sqlauthority.com/2010/10/18/sql-server-change-column-datatypes/): There are times when I feel like writing that I am a day older in SQL Server. In fact, there are many who are looking for a solution that is simple enough. Have you ever searched online for something very simple. I often do and enjoy doing things which are straight forward and easy for change. In this blog post, we will see to Change Column DataTypes - [SQL SERVER - System Stored Procedure sys.sp_tables](https://blog.sqlauthority.com/2010/10/17/sql-server-system-stored-procedure-sys-sp_tables/): I have seen people running the following script quite often, to know the list of the tables from the database: SELECT * FROM sys.tables GO The script above provides various information from create date to file stream, and many other important information. If you need all those information, that script is the one for you. However, if you do not need all those information, I suggest that you run the following script: EXEC sys.sp_tables GO The script above will give all the tables in the table with schema name and qualifiers. Additionally, this will return all the system catalog views together... - [SQL SERVER - StreamInsight and SQL Server 2008 R2](https://blog.sqlauthority.com/2010/10/16/sql-server-streaminsight-and-sql-server-2008-r2/): I was recently called into create POC (Proof of Concept) for a project which was being planned for use StreamInsight. When I was there, I was also asked to give overview of the this feature to their CTO (who had only 15 minutes to spare). Usually I do not like sudden change of plans but the dynamic nature of consultation always gives me motivation to work more. I quickly talked few things in the session. In the evening, I had received the minutes of the meeting and had brief note regarding my discussion on StreamInsight. I am copy pasting the same brief note over here. - [SQLAuthority News – Microsoft WhitePaper on PowerPivot Data Refresh](https://blog.sqlauthority.com/2010/10/15/sqlauthority-news-microsoft-whitepaper-on-powerpivot-data-refresh/): I was recently working at customer location on PowerPivot project. It was quite complected as this is relatively new technology and we all are exploring what this technology can do and what it can bring to us on table in real life experience. During this implementation the project design document needed specification regarding Data Refresh rates. It was a bit complected as there were various components and modules to the project and selecting the refresh rates means understand all of the requirement as well understanding our implementation in and out. I referred following white paper from Microsoft before I move further... - [SQL SERVER - 1500 Posts - A MileStone - Origin of Blog Name Revealed](https://blog.sqlauthority.com/2010/10/14/sql-server-1500-posts-a-milestone-original-of-blog-name-revealed/): This is my 1500th blog post. I am very happy. In my earlier 1400th blog post mile stone, I made a promise that I would explain why I have chosen SQLAuthority.com as my blog’s name. Let me share with you the story about how I came up with the name. In my earlier career days, I was used to code in ColdFusion programming language, and there was a site called Fusion Authority. I was always referring to it whenever I had to get any latest details of the subject. The name inspired me so I started checking out if there were... - [SQL SERVER - Visiting Alma Mater - Delivering Session on Database Performance and Career - Nirma Institute of Technology](https://blog.sqlauthority.com/2010/10/13/sql-server-visiting-alma-mater-delivering-session-on-database-performance-and-career-nirma-institute-of-technology/): Everyone always dream of visiting their school and college, where they have had studied once. It is a great feeling to see the college once again – where you have spent the wonderful golden years of your time. College time is filled with studies, education, emotions and several plans to build future. I consider myself fortunate as I got the opportunity to study at some of the best places in the world. I have earned my Bachelors in Engineering in Electronics and Communication from Nirma Institute of the Technology (NIT), Ahmedabad, India. I must say that this is one of the... - [SQL SERVER - Indexed View always Use Index on Table](https://blog.sqlauthority.com/2010/10/12/sql-server-indexed-view-always-use-index-on-index/): This blog post is written in response to T-SQL Tuesday hosted by Shankar Reddy. I have been recently writing about Views and their Limitations. While writing this article series, I got inspired to write about SQL Server Quiz Questions. You can view the Quiz Question posted over here. In SQL Server 2005, a single table can have maximum 249 non clustered indexes and 1 clustered index. In SQL Server 2008, a single table can have maximum 999 non clustered indexes and 1 clustered index. It is widely believed that a table can have only 1 clustered index, and this belief is... - [SQLAuthority News - Presenting at South East Asia SharePoint Conference - Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site](https://blog.sqlauthority.com/2010/10/11/sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference-maintaining-sql-server-at-optimal-performance-for-blazing-fast-sharepoint-site/): I am delighted and very excited as I am going to attend very first time SharePoint Conference. Even though I will be attending SP conference, I will be presenting on my favorite subject – SQL Server Performance. Every SharePoint site runs on SQL Server and most of the SharePoint sites face issues with performance due to suboptimal configuration of underlying SQL Server. This session will be very unique. I will be starting with a bit pessimistic talk about how one cannot many things in SQL Server when SharePoint Server is installed. I will go over in the details for the reasons... - [SQL SERVER - Encrypted Stored Procedure and Activity Monitor](https://blog.sqlauthority.com/2010/10/10/sql-server-encrypted-stored-procedure-and-activity-monitor/): I recently had received question if any stored procedure is encrypted can we see its definition in Activity Monitor. - [SQLAuthority News - SQL Server 2008 Add-ins and Feature Pack Downloads](https://blog.sqlauthority.com/2010/10/09/sqlauthority-news-sql-server-2008-add-ins-and-feature-pack-downloads/): Here are few of the latest Microsoft Add-ins and downloads recently announced. SQL Server Reporting Services Add-in for SharePoint Technologies The Microsoft SQL Server 2008 SP2 Reporting Services Add-in for Microsoft SharePoint Technologies is a Web download that provides features for running a report server within a larger deployment of Windows SharePoint Services 3.0 or Microsoft Office SharePoint Server 2007. SQL Server Data Mining Add-ins for Office 2007 Download SQL Server 2008 Data Mining Add-ins for Office 2007. This package includes two add-ins for Microsoft Office Excel 2007 (Table Analysis Tools and Data Mining Client) and one add-in for Microsoft Office... - [SQL SERVER - Simple Explanation of Data Type Precedence](https://blog.sqlauthority.com/2010/10/08/sql-server-simple-explanation-of-data-type-precedence/): While I was working on creating a question for SQL SERVER – SQL Quiz – The View, The Table and The Clustered Index Confusion, I had actually created yet another question along with this question. However, I felt that the one which is posted on the SQL Quiz is much better than this one because what makes that question more challenging is that it has a multiple answer. Here is the question regarding Simple Explanation of Data Type Precedence: Run the following example first and then observe the query execution plan. USE tempdb GO CREATE TABLE FirstTable (ID INT, Col VARCHAR(100))... - [SQL SERVER - SQL Quiz - The View, The Table and The Clustered Index Confusion](https://blog.sqlauthority.com/2010/10/07/sql-server-sql-quiz-the-view-the-table-and-the-clustered-index-confusion/): My very good friend, Jacob Sebastian, is running a month-long SQL Quiz Series where the best-of-the-best experts from around the globe would be the quiz masters. They will ask one question every day, and users are expected to answer them correctly. The winning prizes include cool gadgets like iPAD, Kindle and many more. I am one of the quiz masters, and my question is published here: The View, The Table and The Clustered Index Confusion. I have asked there three questions. However, the real important question is: Bonus Question: Does this mean that my table has two effective clustered indexes now?... - [SQL SERVER – Quickest Way to Identify Blocking Query and Resolution – Dirty Solution](https://blog.sqlauthority.com/2010/10/06/sql-server-quickest-way-to-identify-blocking-query-and-resolution-dirty-solution/): As the title suggests, this is quite a dirty solution; it’s not as elegant as you expect. The Story: I got a phone call at night (11 PM) from one of my old friends, requesting a hand. He asked me if I could help him with a very strange situation. He was facing a condition where he was not able to delete data from a table. He already tried to TRUNCATE, DELETE and DROP on the table, but still no luck. I demanded him to let me access it; however, he had to say “No” due to security reasons. Even though... - [SQL SERVER - Error : Fix : Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file failed with the operating system error 2(The system cannot find the file specified.)](https://blog.sqlauthority.com/2010/10/05/sql-server-error-fix-msg-5133-level-16-state-1-line-2-directory-lookup-for-the-file-failed-with-the-operating-system-error-2the-system-cannot-find-the-file-specified/): I recently got email from friend who had suffered from following error. Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.). Msg 1802, Level 16, State 1, Line 2 CREATE DATABASE failed. Some file names listed could not be created. Check related errors. Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.). Msg 1802, Level 16, State 1, Line 2 CREATE DATABASE failed. Some file... - [SQL SERVER - Find Total Number of Transactions on Interval](https://blog.sqlauthority.com/2010/10/04/sql-server-find-total-number-of-transaction-on-interval/): In one of my recent Performance Tuning assignment I was asked how do someone know how many transactions are happening on server during certain interval. I had handy script for the same. Following script displays transactions happened on server at the interval of one minute. You can change the WAITFOR DELAY to any other interval and it should work. - [SQL SERVER - The Limitations of the Views - Eleven and more...](https://blog.sqlauthority.com/2010/10/03/sql-server-the-limitations-of-the-views-eleven-and-more/): I had earlier written, interesting article series on the limitations of the views. I had a great time writing this series. I got many many requests. - [SQLAuthority News - SQL Server Seminar at Colombo Full - Hyderabad Few Seats Available](https://blog.sqlauthority.com/2010/10/02/sqlauthority-news-sql-server-seminar-at-colombo-full-hyderabad-few-seats-available/): If you are familiar with my blog, you might be aware of that I am doing world-wide seminar on SQL Server Seminars. I have lots of request to do the event in various cities, now our plan is very simple and to do this in very few cities. Our current seminar at Colombo is sold out and we have 40 confirmed registrations over 35 available spaces. We have also waiting list of the 10 students and we will see if we can accommodate the same. I have received many request from India for the same seminar, here is the quick update... - [SQL SERVER – Get Query Running in Session](https://blog.sqlauthority.com/2010/10/01/sql-server-get-query-running-in-session/): I was recently looking for syntax where I needed a query running in any particular session. I always remembered the syntax and ha d actually written it down before, but somehow it was not coming to mind quickly this time. I searched online and I ended up on my own article written last year SQL SERVER – Get Last Running Query Based on SPID. I felt that I am getting old because I forgot this really simple syntax. This post is a refresher to me. I knew it was something so familiar since I have used this syntax so many times... - [SQL SERVER - Microsoft SQL Server 2008 Service Pack 2 Download](https://blog.sqlauthority.com/2010/09/30/sql-server-microsoft-sql-server-2008-service-pack-2-download/): Microsoft SQL Server 2008 Service Pack 2 (SP2) is now available for download. You can download your preferred version from link here. The major enhancements are as following: 15K partitioning Improvement. Reporting Services in SharePoint Integrated Mode. SQL Server 2008 R2 Application and Multi-Server Management Compatibility with SQL Server 2008. SQL Server 2008 Instance Management. Data-tier Application (DAC) Support. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Monthly Roundup of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/09/30/sqlauthority-news-monthly-roundup-of-sqlauthority-blog-posts/): Since I started the monthly round up of the blog post, I have received many positive feedback. I plan to continue doing this month refresher every month now. This rounds ups are my mirror and informs me what I have been doing whole month. Here is quick look at the last month. The month started very interesting with my daughter’s birthday SQLAuthority News – Fathers and Daughters. As this was very first birthday it was very special for me. I had great time enjoying with her quality time and it was all fun. I am an MVP and I am one... - [SQL SERVER - View Over the View Not Possible with Index View - Limitations of the View 11](https://blog.sqlauthority.com/2010/09/29/sql-server-view-over-the-view-not-possible-with-index-view-limitations-of-the-view-11/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… When I wrote the article about SQL SERVER – Adding Column is Expensive by Joining Table Outside View – Limitation of the Views Part 2, I had received a comment that said: “If joining column is expensive to the view, why can’t I create a view over the view and create an index on it?” The answer is simple: It’s actually another limitation of the View. You cannot create an Index on a nested View situation. The following example where... - [SQLAuthority News - SQL Health Check and SQL Seminars](https://blog.sqlauthority.com/2010/09/28/sqlauthority-news-sql-health-check-and-sql-seminars/): After announcing the SQL Seminar series and SQL Health Check series, there has been a great response from them. I already have signed up assignments until December 2010 Mid Week for doing various health checks for different organizations. One thing that I noticed is that there’s something common and popular in many  health check services– the Wait Stats. SQL Server Resource Wait Stats Analysis Wait Stat Analysis is very crucial for optimizing databases, but it is often overlooked due to lack of understanding. We perform advanced resource Wait Statistics Analysis and provide you with suggestions to optimize your database server. We... - [SQL SERVER - Keywords View Definition Must Not Contain for Indexed View - Limitation of the View 10](https://blog.sqlauthority.com/2010/09/27/sql-server-keywords-view-definition-must-not-contain-for-indexed-view-limitation-of-the-view-10/): I have recently written many articles on the limitation of the views. I have tried to sum up all the keywords which are not allowed in the indexed view. - [SQL SERVER – SELF JOIN Not Allowed in Indexed View – Limitation of the View 9](https://blog.sqlauthority.com/2010/09/26/sql-server-self-join-not-allowed-in-indexed-view-limitation-of-the-view-9/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Previously, I wrote an article about SQL SERVER – The Self Join – Inner Join and Outer Join, and that blog post seems very popular because of its interesting points. It is quite common to think that Self Join is also only Inner Join, but the reality is that it can be anything. The concept of Self Join is very useful that we use it quite often in our coding. However, this is not allowed... - [SQL SERVER – Get Numeric Value From Alpha Numeric String – Get Numbers Only](https://blog.sqlauthority.com/2010/09/25/sql-server-get-numeric-value-from-alpha-numeric-string-get-numbers-only/): I have earlier wrote article about SQL SERVER – Get Numeric Value From Alpha Numeric String – UDF for Get Numeric Numbers Only and it was very handy tool for me. Recently blog reader and SQL Expert Christofer has left excellent improvement to this logic. Here is his contribution. He has provided Stored Procedure and the same can be easily converted to Function. CREATE PROCEDURE [dbo].[CleanDataFromAlpha] @alpha VARCHAR(50), @decimal DECIMAL(14, 5) OUTPUT AS BEGIN SET NOCOUNT ON; DECLARE @ErrorMsg VARCHAR(50) DECLARE @Pos INT DECLARE @CommaPos INT DECLARE @ZeroExists INT DECLARE @alphaReverse VARCHAR(50) DECLARE @NumPos INT DECLARE @Len INT -- 1 Reverse... - [SQL SERVER - Outer Join Not Allowed in Indexed Views - Limitation of the View 8](https://blog.sqlauthority.com/2010/09/24/sql-server-outer-join-not-allowed-in-indexed-views-limitation-of-the-view-8/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… This blog post was previously published over here. I am republishing it in the series Limitation of the Views with a few modifications. While reading the white paper Improving Performance with SQL Server 2008 Indexed Views, I noticed that it says outer joins are NOT allowed in the indexed views. Here, I have created an example to demonstrate why this is so. Rows can logically disappear from an Indexed View based on OUTER JOIN when... - [SQL SERVER - Cross Database Queries Not Allowed in Indexed View - Limitation of the View 7](https://blog.sqlauthority.com/2010/09/23/sql-server-cross-database-queries-not-allowed-in-indexed-view-limitation-of-the-view-7/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… One of the requirements of Indexed View is that it has to be created ‘WITH SCHEMABINDING’. If the View is not created with that clause, it would not let you create an index on that View. Moreover, if you try to create a View with schemabinding, it would not allow you to create the database. -- Create DB USE MASTER GO CREATE DATABASE TEST1 CREATE DATABASE TEST2 GO -- Table1 USE Test1 GO CREATE TABLE... - [SQL SERVER - UNION Not Allowed but OR Allowed in Index View - Limitation of the View 6](https://blog.sqlauthority.com/2010/09/22/sql-server-union-not-allowed-but-or-allowed-in-index-view-limitation-of-the-view-6/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… If you want to create an Indexed View, you ought to know that UNION Operation is not allowed in Indexed View. It is quite surprising at times when the UNION operation looks very innocent and seems that it cannot be used in the View. Before an in-depth understanding this subject, let me show you a script where UNION is not allowed in Indexed View: USE tempdb GO IF EXISTS (SELECT * FROM sys.views WHERE OBJECT_ID =... - [SQL SERVER - COUNT(*) Not Allowed but COUNT_BIG(*) Allowed - Limitation of the View 5](https://blog.sqlauthority.com/2010/09/21/sql-server-count-not-allowed-but-count_big-allowed-limitation-of-the-view-5/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… One of the most prominent limitations of the View it is that it does not support COUNT(*); however, it can support COUNT_BIG(*) operator. In the following case, you see that if View has COUNT (*) in it already, it cannot have a clustered index on it. On the other hand, a similar index would be created if we change the COUNT (*) to COUNT_BIG (*).For an easier understanding of this topic, let us see the... - [SQL SERVER - How to Stop Growing Log File Too Big](https://blog.sqlauthority.com/2010/09/20/sql-server-how-to-stop-growing-log-file-too-big/): I was recently engaged in Performance Tuning Engagement in Singapore. The organization had a huge database and had more than a million transactions every hour. During the assignment, I noticed that they were truncating the transactions log. This really alarmed me so I informed them this should not be continued anymore because there’s really no need of truncating or shortening the database log. The reason why they were truncating the database log was that it was growing too big and they wanted to manage its large size. I provided two different solutions for them. Now let’s venture more on these solutions.... - [SQL SERVER - SSRS 2008 R2 - MapGallery - World Map](https://blog.sqlauthority.com/2010/09/19/sql-server/): SQL Server 2008 R2 has negatively integrated ability to work with maps. There are few ways how one can select map and use them in their projects. The one I recently came across was MapGallery. By default SQL Server 2008 R2 is enabled for USA maps. This is quite a common request from developers around the globe that they want the same feature available in their own country. - [SQL SERVER - 2008 R2 - PowerPivot for Microsoft Excel 2010 - RTM](https://blog.sqlauthority.com/2010/09/18/sql-server-2008-r2-powerpivot-for-microsoft-excel-2010-rtm/): Microsoft PowerPivot for Microsoft Excel 2010 provides ground-breaking technology, such as fast manipulation of large data sets (often millions of rows), streamlined integration of data, and the ability to effortlessly share your analysis through Microsoft SharePoint 2010. I have recently started to work with SQL Server 2008 R2 and find the product extremely stable and feature complete. I have installed PowerPivot and I am finding it to be also integrating very well with the product. I recently did one presentations using this two technology and worked very well. Let me know if you are using PowerPivot for your power BI users.... - [SQLAuthority News - How to Subscribe to this Blog?](https://blog.sqlauthority.com/2010/09/17/sqlauthority-news-how-to-subscribe-to-this-blog/): How do I subscribe to this blog? I have received this question quite a few times, and have answered them accordingly. As we all know, blogs are part of a social network, and the whole social networking thing is very interesting as everything in it is interwoven together. Let us see in how many different ways you can stay connected with this blog. 1. Email Subscription. If you go to the home page of this blog and scroll down a bit, you will see the following image. Simply enter your email address where you wish to receive notifications of new blog... - [SQLAuthority News - What is an MVP? - How to become an MVP?](https://blog.sqlauthority.com/2010/09/16/sqlauthority-news-what-is-an-mvp-how-to-become-an-mvp/): There are a lot of basic questions I get that inquires about being an MVP. - [SQL SERVER – SELECT * and Adding Column Issue in View – Limitation of the View 4](https://blog.sqlauthority.com/2010/09/15/sql-server-select-and-adding-column-issue-in-view-limitation-of-the-view%c2%a04/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… - [SQL SERVER - Disabled Index and Index Levels and B-Tree](https://blog.sqlauthority.com/2010/09/14/sql-server-disabled-index-and-index-levels-and-b-tree/): This blog post is written in response to T-SQL Tuesday hosted by Michael J. Swart. Recently, I presented a session at the Microsoft Bangalore office. Everybody eagerly wanted to learn more, to the extent that they wanted a mentor to train each of them in order to move on to the next level. I have many mentors worldwide as I keep on traveling, in addition to being already a part of Solid Quality Mentors. However, if I have to take one name in India, I will take the name of Vinod Kumar, who has given me many insights and helped me... - [SQL SERVER - What are Wait Types, Wait Stats and its Importance](https://blog.sqlauthority.com/2010/09/13/sql-server-what-are-wait-types-wait-stats-and-its-importance/): Earlier last month Solid Quality India announced SQL Server Health Check Service and since then, it has got very good response from the industry. However, the only question we are be asked all the time is: “What is “SQL Server Resource Wait Stats Analysis” and how can it be useful?”What caught my attention is that it seems everyone understood what the other details on the page mean, but most of them have a query regarding Wait Stats and their importance. For such a long time, even I wasn’t sure what Wait Stats are. Later on, I learned Wait Stats from Andrew... - [SQL SERVER - Soft Delete Conversation - Your Opinion Needed](https://blog.sqlauthority.com/2010/09/12/sql-server-soft-delete-conversation-your-opinion-needed/): Last Week I wrote article about SQL SERVER – Soft Delete – IsDelete Column – Your Opinion and this article has got excellent community response. There have been some very interesting feedback on both the side. There are few opinions where expert have explained the conversation very balanced way. I am listing today here few of the conversations. You are welcome to provide further input on the same subject. I am listening here only abstract of the comment, click on the name to read the complete comment. jonmcrawford – She has very first very good explanation and votes for no, suggesting... - [SQLAuthority News - Download - Microsoft SQL Server 2008 R2 Best Practices Analyzer Whitepaper](https://blog.sqlauthority.com/2010/09/11/sqlauthority-news-download-microsoft-sql-server-2008-r2-best-practices-analyzer-whitepaper/): I had previously written article on SQL SERVER – Introduction to Best Practices Analyzer – Quick Tutorial. Microsoft has come up with white paper regarding same Best Practice Analyzer. In the new R2 version the SQL BPA introduces advanced capabilities in conjunction with the PowerShell architecture and also raises the bar for prerequisites and cross dependencies. Microsoft has just released white paper which discuses the best practices to use Best Practices Analyzer. This white paper covers very important aspects of the tools. They talk about Installations, Usage and Troubleshooting. Additionally this white paper covers Engine Rules and Powershell methodology. I suggest... - [SQL SERVER - Find Automatically Created Statistics - T-SQL](https://blog.sqlauthority.com/2010/09/10/sql-server-find-automatically-created-statistics-t-sql/): Earlier, I wrote about my experience at an organization here: SQL SERVER – Plan Cache – Retrieve and Remove – A Simple Script. This blog post briefly narrates another experience I had at the same organization. When I was there, I also looked at the statistics and found something that I would like to bring into the limelight. As the developers ran many non-production queries on the production server, many statistics were automatically created on the table. These stats were not useful as they were created by several queries which ran one-time or ad-hoc. Because of this, we really had to... - [SQL SERVER - Quickly Upgrade Your SQL Server](https://blog.sqlauthority.com/2010/09/09/sql-server-quickly-upgrade-your-sql-server/): In this blog post, I will talk about how you can use Docker to quickly upgrade your SQL Server. I discuss docker in this blog post. - [SQL SERVER – Find Row Count in Table – Find Largest Table in Database – Part 2](https://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/): Last Year I wrote article on the subject SQL SERVER – Find Row Count in Table – Find Largest Table in Database – T-SQL. It is very good to see excellent participation there. In my script I had not taken care of table schema. SQL Server Expert Ameena has modified the same script to include the schema. Here is the new modified script. SELECT sc.name +'.'+ ta.name TableName ,SUM(pa.rows) RowCnt FROM sys.tables ta INNER JOIN sys.partitions pa ON pa.OBJECT_ID = ta.OBJECT_ID INNER JOIN sys.schemas sc ON ta.schema_id = sc.schema_id WHERE ta.is_ms_shipped = 0 AND pa.index_id IN (1,0) GROUP BY sc.name,ta.name ORDER... - [SQL SERVER - Index Levels and Delete Operations - Page Level Observation](https://blog.sqlauthority.com/2010/09/07/sql-server-index-levels-and-delete-operations-page-level-observation/): I wrote an article before on SQL SERVER – Index Levels, Page Count, Record Count and DMV – sys.dm_db_index_physical_stats. In that article, I promised that I would give a follow up post with a few more interesting details. I suggest that you go over the earlier article first to understand the details on B-Tree and Index Level. Today we will see one of the fascinating aspects of Delete Operations. Update: This blog post contained few factual errors and they were clearly pointed out by Hrvoje Piasevoli over here. Based on his comment, I have modified this blog post. I will include... - [SQL SERVER - Index Created on View not Used Often - Limitation of the View 3](https://blog.sqlauthority.com/2010/09/06/sql-server-index-created-on-view-not-used-often-limitation-of-the-view-3/): Update: Please read the summary post of all the 11 Limitation of the view SQL SERVER – The Limitations of the Views – Eleven and more… Let us learn about Index Created on View not Used Often. - [SQL SERVER - Find Last Date Time Updated for Any Table](https://blog.sqlauthority.com/2009/05/09/sql-server-find-last-date-time-updated-for-any-table/): I just received an email from one of my regular readers who is curious to know if there is any way to find out when a table is recently updated (or last date time updated). I was ready with my answer! I promptly suggested him that if a table contains UpdatedDate or ModifiedDate date column with default together with value GETDATE(), he should make use of it. On close observation, the table is not required to keep history when any row is inserted. However, the sole prerequisite is to be aware of when any table has been updated. That’s it! - [SQLAuthority News - Future of Business Intelligence and Databases - Article by Nupur Dave](https://blog.sqlauthority.com/2009/05/08/sqlauthority-news-future-of-business-intelligence-and-databases-article-by-nupur-dave/): This article is submitted by Nupur Dave Future of Business Intelligence and Databases The term business intelligence (BI) was coined by Howard Dresner in the early 1990s. He defined Business Intelligence as “a set of concepts and methodologies to improve decision making in business through use of facts and fact-based systems.” In a time when data warehousing was considered leading-edge he created the vision that led to the development of business intelligence, as it is known today.  The once visionary BI is now commonplace and in near future a momentous transformation is about to take place. BI is all set to... - [SQL SERVER - FIX : Error : Windows Update; Error Code 8000FFFF ](https://blog.sqlauthority.com/2009/05/07/sql-server-fix-error-windows-update-error-code-8000ffff/): At present, I am running Windows Vista Ultimate as OS in my computer. I have installed SQL Server 2008 developer’s version in my computer. A couple of months back, I learnt that SQL Server Book On-Line (BOL) update has been released. I usually depend on my Windows Update of SQL Server to install all updates in my OS, so I do not have to  bother myself with installing updates manually. However, this time I was quite taken aback to find that my computer was not updated with the latest updates released by Microsoft. Further, I noticed that my SQL Server Book... - [SQLAuthority News - Book Review - SQL Server 2008 Management and Administration by Ross Mistry](https://blog.sqlauthority.com/2009/05/06/sqlauthority-news-book-review-sql-server-2008-management-and-administration-by-ross-mistry/): SQL Server 2008 Management and Administration (Paperback) - [SQLAuthority News - Author Visit - TechEd India 2009 - Hyderabad](https://blog.sqlauthority.com/2009/05/05/sqlauthority-news-author-visit-teched-india-2009-hyderabad/): I am sure most of you have already heard the good news -Microsoft TechEd India 2009 finally arrives! Tech.Ed-India is a great opportunity to gear yourself up to keep pace with the latest technology innovations and trends.  This event offers you the platform to get comprehensive hands-on-training and free certifications in some of the most sought after technologies of today. In fact, it is a must-attend event for all developers and IT Professionals. Tech.Ed-India will see Steve Balmer, CEO of Microsoft, giving the Keynote and the presence of some renowned speakers. The event will offer you the opportunity to interact with... - [SQL SERVER - Roadmap of Microsoft Certifications - SQL Server Certifications](https://blog.sqlauthority.com/2009/05/04/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications-2/): Introduction In these times of economic slowdown and uncertainties, more and more IT professionals are concerned about their job security and their qualifications. With job insecurity looming on their minds, it is a common trend for developers to start hunting for ways to update their skills. Sound knowledge and real world work experience are always a good way to help secure your future. However, a great way to demonstrate knowledge and competence is by having a certification in the technology one claims to be proficient in. Download Roadmap of Microsoft Certifications – SQL Server Certifications Microsoft offers a series of certifications... - [SQL SERVER - Add or Remove Identity Property on Column](https://blog.sqlauthority.com/2009/05/03/sql-server-add-or-remove-identity-property-on-column/): This article contribution from one of my favorite SQL Expert Imran Mohammed. He is one man who has lots of ideas and helps people from all over the world with passion using this community as platform. His constant zeal to learn more about SQL Server keeps him engaging him to do new SQL Server related activity every time. 1. Adding Identity Property to an existing column in a table. How difficult is it to add an Identity property to an existing column in a table? Is there any T-SQL that can perform this action? For most, the answer to the above... - [SQL SERVER - Example of DDL, DML, DCL and TCL Commands](https://blog.sqlauthority.com/2009/05/02/sql-server-example-of-ddl-dml-dcl-and-tcl-commands/): DML DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. SELECT – Retrieves data from a table INSERT –  Inserts data into a table UPDATE – Updates existing data into a table DELETE – Deletes all records from a table DDL DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. CREATE – Creates objects in the database ALTER – Alters objects of the database DROP – Deletes objects of the database TRUNCATE – Deletes all records from... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting April 24, 2009](https://blog.sqlauthority.com/2009/05/01/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-april-24-2009-2/): We had another successful Gandhinagar SQL Server User Group Meeting on April 24, 2009. In spite of our User Group being just two months old, it received overwhelming warm response from the audience! The meeting once again saw around 50 SQL Server enthusiasts eagerly looking forward to brush up their knowledge and gain some vital tips. The agenda of the meeting was as follows: 6:30 PM – 6:45 PM – Query Optimization Tricks – Jacob Sebastian 6:45 PM – 7:10 PM – Back to Basics – Pinal Dave 7:10 PM – 7:20 PM – Questions and Answers 7:20 PM – 7:30... - [SQL SERVER - FIX : ERROR : is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)](https://blog.sqlauthority.com/2009/04/30/sql-server-fix-error-is-not-a-valid-win32-application-exception-from-hresult-0x800700c1/): Just a day ago, one of my friend sent me email requesting help with following error: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) In fact this is not SQL Server error but it is of .NET application. The solution of this error is just changing configuration of IIS7. Fix/Solution/Workaround: Go to IIS. Click on Application Pool. Look for your web application in application pool. Go to Advanced Settings by right clicking on previously selected application pool. Enable 32-Bit Applications by checking it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Solution to Puzzle - Shortest Code to Perform SSN Validation](https://blog.sqlauthority.com/2009/04/29/sql-server-solution-to-puzzle-shortest-code-to-perform-ssn-validation/): One of my friends – a SQL Server MVP- Jacob Sebastian has a knack for coming up with interesting ideas and stuffs, the latest example being SQL Server Puzzles on his blog. Jacob is a regular blogger and a talented writer. I enjoy reading his blogs and books. He has recently published his new book – The Art of XSD – SQL Server XML Schema Collections. I have based my present article on his most recent brainteaser – Write the shortest T-SQL Code that removes invalid SSN values and returns a result set with only valid SSN values. There are few... - [SQL SERVER - Introduction to SQL Server Encryption and Symmetric Key Encryption Tutorial with Script](https://blog.sqlauthority.com/2009/04/28/sql-server-introduction-to-sql-server-encryption-and-symmetric-key-encryption-tutorial-with-script/): SQL Server 2005 and SQL Server 2008 provide encryption as a new feature to protect data against hackers’ attacks. Hackers might be able to penetrate the database or tables, but owing to encryption they would not be able to understand the data or make use of it. Nowadays, it has become imperative to encrypt crucial security-related data while storing in the database as well as during transmission across a network between the client and the server. - [SQLAuthority News - Starting the SQL Journey - How Did I Get Started With SQL?](https://blog.sqlauthority.com/2009/04/27/sqlauthority-news-starting-the-sql-journey-how-did-i-get-started-with-sql/): This is the very first time I am answering any online tag. SQL Expert Jorge Segarra (a.k.a @SQLChicken) recently tagged me with a very simple yet significant question related to my journey on the path of SQL Server. Let me introduce you all to Jorge first before moving on to his question. Jorge lives in Tampa, Florida, with his beautiful wife, an adorable dog and two naughty cats. He is currently working as a SQL DBA and system administrator for the University Community Hospital. His in-depth knowledge of SQL Server and comprehensive understanding of the subject has gained him incredible popularity... - [SQL SERVER - List All the Tables for All Databases Using System Tables](https://blog.sqlauthority.com/2009/04/26/sql-server-list-all-the-tables-for-all-databases-using-system-tables/): Today we will go over very simple script which will list all the tables for all the database. sp_msforeachdb 'select "?" AS db, * from [?].sys.tables' Update: Based on comments received below I have updated this article. Thank you to all the readers. This is good example where something small like this have good participation from readers. Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQLAuthority News - Interview of Author on 60 Seconds with Pinal Dave](https://blog.sqlauthority.com/2009/04/25/sqlauthority-news-interview-of-author-on-60-seconds-with-pinal-dave/): Vijaya Kadiyala is my fellow .NET and SQL Expert and very respected member of the technology community in India. He is known for his easy but to the point attitude for technology. He regularly writes on his blog : DotNetVJ. I happen to meet him at MVP Summit in Seattle and have learned a lot about him. In my recent travel to South India, I have learned a great deal about his community services and enthusiasm about cutting edge technology. Vijaya has started interview series on his blog where he takes very quick interviews of community leaders. He asked following five... - [SQL SERVER - Leading Zero to Number ](https://blog.sqlauthority.com/2009/04/24/sql-server-leading-zero-to-number/): I have received few emails asking how to prefix any number with zero. I have previously written two articles for the same subject. Please refer to my previous articles. SQL SERVER – Pad Ride Side of Number with 0 – Fixed Width Number Display SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display Let me know if you are aware of any other method. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Introduction to SQL Server 2008 Profiler - Summary](https://blog.sqlauthority.com/2009/04/24/sql-server-introduction-to-sql-server-2008-profiler/): Introduction SQL Server Profiler is a powerful tool that is available with SQL Server since a long time; however, it has mostly been underutilized by DBAs. SQL Server Profiler can perform various significant functions such as tracing what is running under the SQL Server Engine’s hood, and finding out how queries are resolved internally and what scripts are running to accomplish any T-SQL command. The major functions this tool can perform have been listed below: Creating trace Watching trace Storing trace Replaying trace Trace includes all the T-SQL scripts that run simultaneously on SQL Server. As trace contains all the T-SQL... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting April 24, 2009](https://blog.sqlauthority.com/2009/04/23/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-april-24-2009/): Gandhinagar SQL Server User Group launch event was held on March 27, 2009. This successful, well-attended event received very positive and warm community response. Visit Gandhinagar SQL Server User Group Portal and register yourself now! We are going to meet again this month on April 24, 2009 Friday from 6:30PM to 7:30 PM. We will be very fortunate that we will have outside guest and another SQL Server MVP visiting us. Jacob Sebastian is president of Ahmedabad SQL Server User Group and fellow MVP. He has taken many technical sessions in meetings and famous speaker in SQL Server arena. The agenda... - [SQL SERVER - FIX : Error: 18486 Login failed for user 'sa' because the account is currently locked out. The system administrator can unlock it. - Unlock SA Login](https://blog.sqlauthority.com/2009/04/23/sql-server-fix-error-18486-login-failed-for-user-sa-because-the-account-is-currently-locked-out-the-system-administrator-can-unlock-it-unlock-sa-login/): Today, we will riffle through a very simple, yet common issue – How to unlock a locked “sa” login? It is quite a common practice that SQL Server is hosted on a separate server than application server. In most cases, SQL Server ports or IP are exposed to the web, which makes them risk prone. For hackers, System Admin login “sa” is the preferred account which they use for hacking. In fact, a majority of hackers try to hack into SQL Server by attempting to login using “sa” account. Once hackers gain access to server using “sa” login, they get a... - [SQL SERVER - Difference Between SQL Server Compact Edition (CE) and SQL Server Express Edition](https://blog.sqlauthority.com/2009/04/22/sql-server-difference-between-sql-server-compact-edition-ce-and-sql-server-express-edition/): I often received question regarding what are difference between SQL Server Compact Edition (CE) and SQL Server Express Edition. In one line – SQL Server CE is for mobile application and embaded systems where as SQL Server Express Edition is limited feature light version of SQL Server Standard. SQL Server Compact Edition SQL Server Express Edition ClickOnce Deployment ClickOnce Deployment Installed centrally with an MSI Installed centrally with an MSI XML storage XML storage Transact-SQL Transact-SQL Subscriber for merge replication Subscriber for merge replication Simple transactions Simple transactions Database size support – 4GB Database size support – 4GB Number of concurrent... - [SQL SERVER - What is Cloud Computing - Introduction to Cloud Computing](https://blog.sqlauthority.com/2009/04/21/sql-server-what-is-cloud-computing-introduction-to-cloud-computing/): “Cloud Computing,” to put it simply, means “Internet Computing.” The Internet is commonly visualized as clouds; hence the term “cloud computing” for computation done through the Internet. With Cloud Computing users can access database resources via the Internet from anywhere, for as long as they need, without worrying about any maintenance or management of actual resources. Besides, databases in cloud are very dynamic and scalable. Cloud computing is unlike grid computing, utility computing, or autonomic computing. In fact, it is a very independent platform in terms of computing. The best example of cloud computing is Google Apps where any application can... - [SQLAuthority Book Review - Pro T-SQL 2008 Programmer’s Guide by Michael Coles](https://blog.sqlauthority.com/2009/04/20/sqlauthority-book-review-pro-t-sql-2008-programmers-guide-by-michael-coles/): Pro T-SQL 2008 Programmer’s Guide by Michael Coles Link to Amazon Short Summary: Pro T-SQL 2008 Programmer’s Guide examines SQL Server 2008 T-SQL from a developer’s perspective. This information-rich book covers a wide array of developer-specific topics in SQL Server 2008. In addition, it provides in-depth knowledge of various newly introduced topics. This book is written as a practical guide to help database developers who mainly deal with T-SQL. It has really hit the spot with appropriate .NET code at a few places where required. The book assumes a basic knowledge of SQL, but it is very easy to understand for... - [SQL SERVER - Fix : SQL Server 2008 Developer Edition Install fail due to .NET Framework 3.5 missing](https://blog.sqlauthority.com/2009/04/19/sql-server-fix-sql-server-2008-developer-edition-install-fail-due-to-net-framework-35-missing/): It goes without saying that computer running slow is a common problem we all face, a pestering one indeed! Last week, I had to format my computer as it was running at an annoyingly tortoise pace. After formatting it, I installed Visual Studio 2008. When tested Visual Studio 2008 worked all fine. However, when I attempted to install SQL Server 2008, I was confronted with an error about NET Framework 3.5 missing. - [SQLAuthority News - Troubleshooting Performance Problems in SQL Server 2008](https://blog.sqlauthority.com/2009/04/18/sqlauthority-news-troubleshooting-performance-problems-in-sql-server-2008/): Troubleshooting Performance Problems in SQL Server 2008 SQL Server Technical Article Writers: Sunil Agarwal, Boris Baryshnikov, Keith Elmore, Juergen Thomas, Kun Cheng, Burzin Patel Technical Reviewers: Jerome Halmans, Fabricio Voznika, George Reynya Published: March 2009 - [SQLAuthority News - Authors Website Redesigned - http://www.pinaldave.com - Feedback Requested](https://blog.sqlauthority.com/2009/04/17/sqlauthority-news-authors-website-redesigned-httpwwwpinaldavecom-feedback-requested/): I’m pleased to inform you all that I’ve recently launched my personal website. It’s been a long time since I’ve been writing on my blog https://blog.sqlauthority.com, but I’ve been keeping my personal notes at my homepage http://www.pinaldave.com. I’ve completely rehauled the website to give it the much-needed makeover, right from redesigning the layout to writing fresh content. But, I would be extremely happy to have your feedback so that I can enhance my website further. I’ve always been a people’s person who believes in sharing his knowledge. Also, I want to see myself growing as an individual and as a professional.... - [SQLAuthority News - Microsoft Certification Exam - Discount Code](https://blog.sqlauthority.com/2009/04/16/sqlauthority-news-microsoft-certification-exam-discount-code/): Note: I am republishing this blog post as the offer of this code is extended to April 30, 2009. Please note down this important code or share with your colleagues who are keen to take Microsoft Certification Exam. This unique code is only available through Microsoft MVP’s and only published here to help community and no other intention. In this challenging economic climate, upgrading your IT skills becomes crucial to staying ahead. Invest in a Microsoft Certification to get the right IT skills. Register today with your MVP Certification Promotion Code:  and enjoy 2 chances to pass a Microsoft Certification Examination... - [SQL SERVER - Poll Result - What is Your Favorite Database?](https://blog.sqlauthority.com/2009/04/15/sql-server-poll-result-what-is-your-favorite-database/): I previously posted a Poll about What is Your Favorite Database? I got great response from users. In fact, I received some of the best poll-related comments on this blog  and they are worth reading. Let us check the result first. Here are the votes I received on different database. Total votes received are 1,697. SQL Server – 1,121 – 64% Oracle – 432 – 25% MySQL – 144 – 8% Other – 64 – 4% SQL Server is a clear winner with  1,121 votes, which is an astounding 64% of the total votes. As a matter of fact, it is... - [SQL SERVER - Check if Current Login is Part of Server Role Member](https://blog.sqlauthority.com/2009/04/14/sql-server-check-if-current-login-is-part-of-server-role-member/): I often work on consulting projects with umpteen clients from across the globe. The nature of the works I usually receive necessitates me to take on the role of a system admin. Now, this role is trailed by come common issues. This article revolves around one such concern. Let us learn about Server Role Member. - [SQL SERVER - Introduction to JOINs - Basic of JOINs](https://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/): The launch of Gandhinagar SQL Server User Group was a tremendous, astonishing success! It was overwhelming to see a large gathering of enthusiasts looking up to me (I was the Key Speaker) eager to enhance their knowledge and participate in some brainstorming discussions. Some members of User Group had requested me to write a simple article on JOINS elucidating its different types. INNER JOIN This join returns rows when there is at least one match in both the tables. OUTER JOIN There are three different Outer Join methods. LEFT OUTER JOIN This join returns all the rows from the left table... - [SQL SERVER - FIX : ERROR : The SQL Server System Configuration Checker cannot be executed due to WMI configuration on the machine Error:2147749896 (0×80041008)](https://blog.sqlauthority.com/2009/04/12/sql-server-fix-error-the-sql-server-system-configuration-checker-cannot-be-executed-due-to-wmi-configuration-on-the-machine-error2147749896-0%c3%9780041008/): A couple of days back I  had my computer formatted. I reinstalled it with Vista SP1 32bit. Subsequent to installing other indispensable software  I tried to install SQL Server 2005 .  However, it instantly displayed the following error message. The SQL Server System Configuration Checker cannot be executed due to WMI configuration on the machine Error:2147749896 (0×80041008). It was a bit frustrating for me as it was pretty late and I ardently wanted to install SQL Server 2008 right after I was done  with installing SQL Server 2005. I pinged my friend James Locazicoski with the above error message. James came... - [SQL SERVER - Interesting Observation of DMV of Active Transactions and DMV of Current Transactions](https://blog.sqlauthority.com/2009/04/11/sql-server-interesting-observation-of-dmv-of-active-transactions-and-dmv-of-current-transactions/): This post is about a riveting observation I made a few days back. While playing with transactions I came across two DMVs  that are associated with Transactions. 1) sys.dm_tran_active_transactions – Returns information about transactions for the instance of SQL Server. 2) sys.dm_tran_current_transaction – Returns a single row that displays the state information of the transaction in the current session. Now, what really interests me is the following observation. These two DMVs , in actual fact, display the distinction between active transactions and current transactions. Current transaction can be active transaction at the time of execution, but not all active transactions are... - [SQL SERVER - Restore or Attach Database Without .NDF or .MDF is Not Possible](https://blog.sqlauthority.com/2009/04/10/sql-server-restore-or-attach-database-without-ndf-or-mdf-is-not-possible/): This article revolves around a trivial yet common issue. There might be a set of people for whom the current topic might appear to be insignificant. But I have been asked this question innumerable times, particularly from   people who are frequenting using forums or have blog related to storage and highly availability, which instigated me to write this article. Here goes this frequently asked question. Question: Is it possible to restore database if one of the files of .mdf (primary data file) or .ndf (secondary data file) is missing? Answer: In one word the answer is NO. All the .mdf and... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2009/04/10/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-3/): Note: Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. Scripts in the SQL Server 2008 management pack rely on SQL Data Management Objects (SQL-DMO) to query information from the SQL Server. SQL-DMO is now deprecated and is not shipped as a part of SQL Server... - [SQLAuthority News - Download SQL Server 2005 Report Packs - SQL Server Sample Reports - Report Templates](https://blog.sqlauthority.com/2009/04/10/sqlauthority-news-download-sql-server-2005-report-packs-sql-server-sample-reports-report-templates/): Note:   Download SQL Server 2005 Report Packs by Microsoft SQL Server 2005 Reporting Services is a comprehensive, server-based reporting solution designed to help you author, manage, and deliver both paper-based, ad hoc, and interactive Web-based reports. Each report pack consists of a set of predefined reports, a sample database, a readme file, and an End User License Agreement (EULA). You can use these sample reports as templates to quickly author and distribute new interactive reports. Report Pack contains following sample reports SQL Server 2005 Integration Services Log Reports SQL Server 2005 Report Pack for Microsoft Dynamics Axapta 3.0 SQL Server 2005... - [SQL SERVER - Fix Error 9803. Invalid data for type "numeric" - Data Type Mapping](https://blog.sqlauthority.com/2009/04/09/sql-server-fix-error-msg-9803-level-16-invalid-data-for-type-numeric-data-type-mapping-for-oracle-publishers/): My present article talks about an error that you will encounter when connecting to Oracle database using OPENQUERY. Let us learn about how to fix error 9803. - [SQL SERVER - Maximum Columns per Primary Key - Fix : Error : Msg 1904, Level 16, The index on table has column names in index key list. The maximum limit for index or statistics key column list is 16](https://blog.sqlauthority.com/2009/04/08/sql-server-maximum-columns-per-primary-key-fix-error-msg-1904-level-16-the-index-on-table-has-column-names-in-index-key-list-the-maximum-limit-for-index-or-statistics-key-column-list-is-16/): My present article covers two fundamental questions. 1) What is the maximum number of columns included in Primary Key Index/Constraint? 2) What is fix/solution for the following error: Msg 1904, Level 16, State 1, Line 1 The index ” on table ‘dbo.Table_2’ has 17 column names in index key list. The maximum limit for index or statistics key column list is 16. The same error surfaces when example is created using SSMS. Fix/Solution/Workaround: Maximum columns per Primary Key Index is 16. In fact, 16 is the limit for columns per Foreign Key and Index Key. You cannot have more than 16... - [SQLAuthority News - SQL Server 2008 Service Pack 1 Released - Available for Download](https://blog.sqlauthority.com/2009/04/08/sqlauthority-news-sql-server-2008-service-pack-1-released-available-for-download/): SQL Server 2008 Service Pack 1 (SP1) is now available. You can use these packages to upgrade any SQL Server 2008 edition. Download SQL Server 2008 Service Pack 1 Build of SP1 is SP1 is build 10.00.2531.00. Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Server Type and File Extention](https://blog.sqlauthority.com/2009/04/07/sql-server-server-type-and-file-extention/): Owing to my personal experience so far, I can undeniably say that Microsoft Windows products are outstanding. One of the reasons that make them exceptional is their little nifty tricks. For instance, every time I double click myfilename.sql it opens Microsoft SQL Server Management Studio (SSMS). The reason how Windows discerns that it has to open SSMS is because the extension of file I had clicked is .sql. I explored and found that SQL Server has few more filetypes associated with it, which are as follows. SQL Server – .sql SQL Server Compact 3.5 SP1 – .sqlce SQL Server Analysis Service... - [SQL SERVER - Logical Query Processing Phases - Order of Statement Execution](https://blog.sqlauthority.com/2009/04/06/sql-server-logical-query-processing-phases-order-of-statement-execution/): Of late, I penned down an article – SQL SERVER – Interesting Observation of ON Clause on LEFT JOIN – How ON Clause Effects Resultset in LEFT JOIN – which received a very intriguing comment from one of my regular blog readers Craig. According to him this phenomenon happens due to Logical Query Processing. His comment instigated a question in my mind. I have put forth this question to all my readers at the end of the article. Let me first give you an introduction to Logical Query Processing Phase. What actually sets SQL Server apart from other programming languages is... - [SQL SERVER - 2008 - Management Studio New Features](https://blog.sqlauthority.com/2009/04/05/sql-server-2008-management-studio-new-features/): Pinalkumar Dave describes the top 5 features of SQL Server Management Studio 2008. This article describes the top 5 features of SQL Server Management Studio 2008. With the release of SQL Server 2008 Microsoft has upgraded SSMS with many new features as well as added tons of new functionalities requested by DBAs for long time. SQL Server 2008 has been released for a year now. In SQL Server 2000, DBA had to use two different tools to maintain the database as well as the query database, specifically SQL Server Enterprise Manager and SQL Server Query Analyzer. With the release of SQL... - [SQL SERVER - Mirrored Backup and Restore and Split File Backup](https://blog.sqlauthority.com/2009/04/05/sql-server-mirrored-backup-and-restore-and-split-file-backup/): Introduction This article is based on a real life experience of the author while working with database backup and restore during his consultancy work for various organizations. We will go over the following important concepts of database backup and restore. Conventional Backup and Restore Spilt File Backup and Restore Mirror File Backup Understanding FORMAT Clause Miscellaneous details about Backup and Restore Conventional and Split File Backup and Restore Just a day before working on one of the projects, I had to take a backup of one database of 14 GB. My hard drive lacked sufficient space at that moment. Fortunately, I... - [SQL SERVER - Automated Index Defragmentation Script](https://blog.sqlauthority.com/2009/04/04/sql-server-automated-index-defragmentation-script/): Index Defragmentation is one of the key processes to significantly improve performance of any database. Index fragments occur when any transaction takes place in database table.  Fragmentation typically happens owing to insert, update and delete transactions. Having said that, fragmented data can produce unnecessary reads thereby reducing performance of heavy fragmented tables. I have often been asked to share my personal Index Defragmentation Script. Well, I use Automated Index Defragmentation Script created by my friend – a SQL Expert – Michelle Ufford (a.k.a SQLFool). Michelle is a SQL Server Developer, DBA, a humble blogger, and an absolute geek! She is also... - [SQLAuthority News - Launch of Gandhinagar SQL Server User Group](https://blog.sqlauthority.com/2009/04/03/sqlauthority-news-launch-of-gandhinagar-sql-server-user-group/): Gandhinagar SQL Server User Group launch event was held on March 27, 2009. This successful, well-attended event received very positive and warm community response. This launch event, unexpectedly, saw over 50 database enthusiasts participating. It was really a moment of pleasant surprise when we ran out of chairs. The otherwise spacious room started getting smaller as more and more people joined in, and unquestionably, we felt ecstatic about it! Visit Gandhinagar SQL Server User Group Portal and register yourself now! We commenced Gandhinagar SQL Server User Group launch event sharp at 6:30 and completed it precisely at 7:30. During these 60... - [SQL SERVER - Very Powerful and Feature-Rich Backup, Zip and FTP Utility SQLBackupAndFTP](https://blog.sqlauthority.com/2009/04/02/sql-server-very-powerful-and-feature-rich-backup-zip-and-ftp-utility-sqlbackupandftp/): It goes without saying that Database Backup is the most important task for any Database Administrator (DBA). Naturally, large organizations always have a team of DBAs who execute Database Backup tasks. No matter how big or small an organization is, the importance of database backup remains the same across the board. It’s a common practice in several organizations to upload the backup to their remote location for additional safety. I totally vouch for this safety measure of having their additional backup on remote/satellite location. This redundancy comes in handy whenever a catastrophe of not having proper backup surfaces abruptly. While I... - [SQL SERVER - Reseed Identity of Table - Table Missing Identity Values - Gap in Identity Column](https://blog.sqlauthority.com/2009/04/01/sql-server-reseed-identity-of-table-table-missing-identity-values-gap-in-identity-column/): Some time ago I was helping one of my Junior Developers who presented me with an interesting situation. He had a table with Identity Column. Because of some reasons he was compelled to delete few rows from the table. On inserting new rows in the table he noticed that the rows started from the next identity value which created gap in the identity value. His application required all the identities to be in sequence, so this was certainly not a small issue for him. The solution to this issue regarding gap in identity column is very simple. Let us first take... - [SQL SERVER - IntelliSense Does Not Work - Enable IntelliSense](https://blog.sqlauthority.com/2009/03/31/sql-server-2008-intellisense-does-not-work-enable-intellisense/): While I was working with SQL Server 2008 IntelliSense, I realized that it was not functioning as I expected. Even after I had enabled IntelliSense it was still not opening any suggestions at all. After a while, I figured out some vital information regarding how to make sure IntelliSense smoothly works all the time without you giving any trouble. Let us learn how we can Enable IntelliSense. - [SQLAuthority News - Top 10 Strategic Technologies for 2009](https://blog.sqlauthority.com/2009/03/30/sqlauthority-news-top-10-strategic-technologies-for-2009/): Gartner, Inc. analysts highlighted the top 10 technologies and trends that will be strategic for most organizations. Factors that denote significant impact include a high potential for disruption to IT or the business, the need for a major dollar investment, or the risk of being late to adopt. The top 10 strategic technologies for 2009 include: Virtualization. Much of the current buzz is focused on server virtualization, but virtualization in storage and client devices is also moving rapidly. Cloud Computing. Cloud computing is a style of computing that characterizes a model in which providers deliver a variety of IT-enabled capabilities to... - [SQL SERVER - Fix : Error : Msg 2714, Level 16, State 6 - There is already an object named '#temp' in the database](https://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/): Recently, one of my regular blog readers emailed me with a question concerning the following error: Msg 2714, Level 16, State 6, Line 4 There is already an object named ‘#temp’ in the database. This reader has been encountering the above-mentioned error, and he is curious to know the reason behind this. Here’s Rakesh’s email. Hi Pinal, I’m a  regular visitor to your blog and I thoroughly enjoy your articles and especially the way you solve your readers’ queries. I work as a junior SQL developer in Austin. Today, when I started to create a TSQL application, I detected an interesting... - [SQLAuthority News - SQL SERVER 2008 - Updated Brochure Available for Download](https://blog.sqlauthority.com/2009/03/28/sqlauthority-news-sql-server-2008-updated-brochure-available-for-download/): SQL Server 2008 new brochure is available for download. Microsoft® SQL Server® 2008 provides a trusted, productive, and intelligent data platform that enables you to: Run your most demanding mission-critical applications. Reduce time and cost of development and management of applications. Deliver actionable insight to your entire organization. Your Data, Any Place, Any Time. Download SQL Server 2008 Brochure Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Database Poll and Gandhinagar SQL Server User Group Launch Today](https://blog.sqlauthority.com/2009/03/27/sqlauthority-news-database-poll-and-gandhinagar-sql-server-user-group-launch-today/): I have published a poll on website few days ago for favorite database of SQLAuthority.com readers. The best comment will win USB drive. The poll will close on April 1, 2009. Looking at the poll result, it seems that Oracle has gained a lot over SQL Server from last time when I checked. Please share this poll with your friends, your UG and community to get better sample. If you are not interested in poll there are many interesting comments, please read them. Additionally, Gandhinagar SQL Server User Group has launch event today. I suggest all of you from surrounding area... - [SQLAuthority News - Author Video Interview Published Online - Microsoft MVP Summit 2009](https://blog.sqlauthority.com/2009/03/27/sqlauthority-news-author-video-interview-published-online-microsoft-mvp-summit-2009/): Microsoft MVP Award Blog and Microsoft South Asian MVP Blog has published my video interview online. My interview was conducted by Abhishek Kant – Microsoft MVP Lead and Technology Blogger. I am thankful to Abhishek Kant for conducting my interview, Abhishek Baxi for publishing on South Asian Blog and Jas Dhaliwal for producing the video. Above All I am very thankful to Microsoft for awarding me MVP Award. This video was shot at Microsoft MVP Summit 2009 at Seattle. Watch my Video on Microsoft MVP Award Blog Watch my Video on Microsoft South Asian MVP Blog Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error: Msg 15123, Level 16 - The configuration option 'advance option' does not exist, or it may be an advanced option.](https://blog.sqlauthority.com/2009/03/26/sql-server-fix-error-msg-15123-level-16-the-configuration-option-advance-option-does-not-exist-or-it-may-be-an-advanced-option/): I received another email describing error received due to my executing script from my previous article . Error : Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51 The configuration option ‘optimize for ad hoc workloads’ does not exist, or it may be an advanced option. Let us quickly see the reproduction of this error in following image. Fix/Workaround/Solution: The reason this error is happening because of not enabling advance option. Run complete following script and it should fix the problem. sp_CONFIGURE 'show advanced options',1 RECONFIGURE GO sp_CONFIGURE ‘optimize for ad hoc workloads’,1 RECONFIGURE GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 4621, Level 16, State 10 : Permissions at the server scope can only be granted when the current database is master](https://blog.sqlauthority.com/2009/03/26/sql-server-fix-error-msg-4621-level-16-state-10-permissions-at-the-server-scope-can-only-be-granted-when-the-current-database-is-master/): I have received comment from Radha Goswami on my previous blog article SQL SERVER – 2008 – Activity Monitor is Empty – Fix Activity Monitor for All Users. Radha is facing following error when she is tring to grant permission to login. Error: Msg 4621, Level 16, State 10, Line 1 Permissions at the server scope can only be granted when the current database is master Following image is I have recreated based on the above error message. Fix/Workaround/Solution: If you look at the database in use is AdventureWorks and when any server level persmission has to be granted the database... - [SQLAuthority News - Announcement - Gandhinagar SQL Server User Group - March 27, 2009](https://blog.sqlauthority.com/2009/03/25/sqlauthority-news-announcement-gandhinagar-sql-server-user-group-march-27-2009/): It is my pleasure to announce new SQL Server User Group – Gandhinagar SQL Server User Group. We will be meeting every 2nd and 4th Friday of the month. Here is the detail for this months meeting. We will be having one gift for best participant in the meeting. I request all the SQL enthusiast to attend this meeting and do not miss it. You can be member at sqlpass @ . Meeting Date Time: March 27, 2009 6:30 PM -7:30 PM Friday Meeting Agenda: 6:30 PM – 7:00 PM – Introduction to Joins and Real Life Scenario 7:00 PM –... - [SQLAuthority News - Ahmedabad SQL Server User Group Meeting Review - March 21, 2009](https://blog.sqlauthority.com/2009/03/25/sqlauthority-news-ahmedabad-sql-server-user-group-meeting-review-march-21-2009/): We had fun session with Ahmedabad SQL Server Usre Group last week on March 21, 2009. It was short session but one interesting one. We discussed about how query profiler works and how to find most popular query from SQL Server instance. We had also prepared Trace Template as well query which can ran to identify longest running query along with popular query. I received nearly 10 questions after my session and lots of time was spent answering them. The whole session was very interactive. I want to congratulate everybody who attended it, if you need my Profiler Template and Query... - [SQL SERVER - 2008 - SCOPE_IDENTITY Bug with Multi Processor Parallel Plan and Solution](https://blog.sqlauthority.com/2009/03/24/sql-server-2008-scope_identity-bug-with-multi-processor-parallel-plan-and-solution/): This article is very serious and I would like to explain this as simple as I can. SCOPE_IDENTITY() which is commonly used in place of @@Identity has bug when run in Parallel Plan. You can read my explanation of @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT in earlier article. The bug is listed here in connect site SCOPE_IDENTITY() sometimes returns incorrect value. Additionally, the bug is also listed in Book Online on last line of the SCOPE_IDENTITY() documentation. When parallel plan is executed SCOPE_IDENTITY or IDENTITY may produce inconsistent results. The bug will be fixed in future versions of SQL Server. For SQL... - [SQL SERVER - 2008 - Location of Activity Monitor - Where is SQL Serve Activity Monitor Located](https://blog.sqlauthority.com/2009/03/23/sql-server-2008-location-of-activity-monitor-where-is-sql-serve-activity-monitor-located/): I received question from Aloke Sinha after reading my article SQL SERVER – 2008 – Activity Monitor is Empty – Fix Activity Monitor for All Users. Hello Pinalbhai, Thank you for your post about activity monitor, but I can not find activity monitor under Menu — Tools. How to activate it? [Other unrelated information removed] Take care, Aloke Sinha The reason I decided to write about this subject is because I totally understand why Aloke is confused here. Activity Monitor can not be activated from any menu from top menu bar. There are two different methods to activate Activity Monitors. From... - [SQL SERVER - 2008 - Activity Monitor is Empty - Fix Activity Monitor for All Users](https://blog.sqlauthority.com/2009/03/22/sql-server-2008-activity-monitor-is-empty-fix-activity-monitor-for-all-users/): This article is an outcome of the technical discussion of activity monitor and its behavior with my friend and SQL Expert Tejas Shah. Tejas told me that he does not like to re-write content from MSDN, but rather prefer to write real life scenarios, as that prepares him to become a better SQL Expert. While discussing about Activity Monitor he informed that it throws an error when there is a permissions issue. He has even blogged about how to give permissions to user to launch activity monitor on his blog . Tejas asked me to write on the same subject for SQL Server 2008. Here is the article covering the discussion I had with Tejas. - [SQL SERVER - 2008 - Optimize for Ad hoc Workloads - Advance Performance Optimization](https://blog.sqlauthority.com/2009/03/21/sql-server-2008-optimize-for-ad-hoc-workloads-advance-performance-optimization/): Every batch (T-SQL, SP etc) when ran creates execution plan which is stored in system for re-use. Due to this reason large number of query plans are stored in system. However, there are plenty of plans which are only used once and have never re-used again. One time ran batch plans wastes memory and resources. SQL Server 2008 has feature of optimizing ad hoc workloads. Before we move to it, let us understand the behavior of SQL Server without optimizing ad hoc workload. Please run following script for testing. Make sure to not to run whole batch together. Just run each... - [SQL SERVER - AWE (Address Windowing Extensions) Explained in Simple Words](https://blog.sqlauthority.com/2009/03/20/sql-server-awe-address-windowing-extensions-explained-in-simple-words/): I was asked question by Jr. DBA that “What is AWE?”. For those who do know what is AWE or where is it located, it can be found at SQL Server Level properties. AWE is properly explained in BOL so we will just have our simple explanation. Address Windowing Extensions API is commonly known as AWE.  AWE is used by SQL Server when it has to support very large amounts of physical memory. AWE feature is only available in SQL Server Enterprise, Standard, and Developer editions with of SQL Server 32 bit version. Microsoft Windows 2000/2003 server supports maximum of 64GB... - [SQLAuthority News - 900th Article - 9 Best Practices - Important Milestones](https://blog.sqlauthority.com/2009/03/19/sqlauthority-news-900th-article-9-best-practices-important-milestones/): Today is my 900th article on this blog. You can see list of all the 900 articles here. I suggest you go over the list and read any article you like. - [SQL SERVER - Find All Servers From Local Network - Using sqlcmd - Detect Installed SQL Server on Network](https://blog.sqlauthority.com/2009/03/18/sql-server-find-all-servers-from-local-network-using-sqlcmd/): I recently had requirement to create list of all the SQL Server on local network. I remembered that I had written similar script a year ago SQL SERVER – Script to Find SQL Server on Network. When I looked at it, I realize that I had written it for SQL Server 2000 and used “isql” utility, which is deprecated now. I quickly wrote down updated script using “sqlcmd”. Command “osql” still works in SQL Server 2008. Go to command prompt and type in “osql -L” or “sqlcmd -L”. Note one change between osql and sqlcmd is that osql has additional server... - [SQL SERVER - Practical SQL Server XML: Part One - Query Plan Cache and Cost of Operations in the Cache](https://blog.sqlauthority.com/2009/03/17/sql-server-practical-sql-server-xml-part-one-query-plan-cache-and-cost-of-operations-in-the-cache/): I am very fortunate that I have friends like Michael Coles. Michael Coles is SQL Server and XML expert and have written many books on SQL Server as well XML. He has previously written book which I have reviewed on this blog SQLAuthority News – Book Review – Pro T-SQL 2005 Programmer’s Guide (Paperback). I am currently reading his latest book Pro SQL Server 2008 XML (Hardcover) which can be found on amazon. I will be writing review of the book once I am done reading it. Michael Coles and I met last at Microsoft MVP Summit 2009 at Seattle and... - [SQL SERVER - UDF - Pad Ride Side of Number with 0 - Fixed Width Number Display](https://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/): SQL SERVER - UDF - Pad Ride Side of Number with 0 - Fixed Width Number Display. Let us learn more about this blog. - [SQL SERVER - Interesting Observation of ON Clause on LEFT JOIN - How ON Clause affects Resultset in LEFT JOIN ](https://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/): Today I received email from Yoel from Israel. He is one smart man always bringing up interesting questions. Let us see his latest email first. Hi Pinal, I am subscribed to your blog and enjoy reading it. I have a question which has been bothering me for some time now. When I want to filter records in a query, I usually put the condition in the WHERE clause. When I make an inner join, I can put the condition in the ON clause instead, giving the same result. But with left joins this is not the case. Here is a quote... - [SQLAuthority News - Lots of SQL Server News - Tip of the Article](https://blog.sqlauthority.com/2009/03/14/sqlauthority-news-lots-of-sql-server-news/): I have been reeving lots of feedback from blog readers and what I have learned that they all wanted me to write about SQL Server Community news at least once a week. I am not sure if I can write every week what are happening in SQL Server world but I promise to write about news when I have collected few important news. Let me try this time how it goes and we will see in future how do you like it based on on your feedback. IPD Guide: Let me start with what has been keeping me busy recently. I... - [SQL SERVER - Profiler - Adding Filters - Observation on CPU Load](https://blog.sqlauthority.com/2009/03/13/sql-server-profiler-adding-filters-observation-on-cpu-load/): Today I am blog about something which I found recently while working with SQL Server Profiler. Profiler can be invoked just typing profiler in command prompt. I am using Windows Vista Ultimate 32 bit (License Version) and SQL Server 2008 Development (License Version). The reason I have put “License Version” because I encourage everybody to use only licensed software. SQL Server Profiler gives feature where we can specify which column filter. Column filter can have value which can be validated with atucal data and based on it, it will store information in profiler stress. I was always under impression that adding... - [SQL SERVER - What is Your Favorite Database? - Poll Continuous](https://blog.sqlauthority.com/2009/03/12/sql-server-what-is-your-favorite-database-poll-continuous/): I have published SQL Server Poll about What is Your Favorite Database? to get feedback from readers of this blog about what is their favorite database. I have received so far tremendous response. This poll will continue through out this month and will close on 1st of April. I will post all the statistic once the poll is over. I encourage all of you to spread the word about it to different channels, blogs, linked list and emails. It is not only important to vote for your favorite database but it is equally important to leave comment justifying why and which... - [SQL SERVER - Difference Between Union vs. Union All - Optimal Performance Comparison](https://blog.sqlauthority.com/2009/03/11/sql-server-difference-between-union-vs-union-all-optimal-performance-comparison/): More than a year ago I had written article SQL SERVER – Union vs. Union All – Which is better for performance? I have got many request to update this article. It is not fair to update already written article so I am rewriting it again with additional information. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the... - [SQL SERVER - Pad Ride Side of Number with 0 - Fixed Width Number Display](https://blog.sqlauthority.com/2009/03/10/sql-server-pad-ride-side-of-number-with-0-fixed-width-number-display/): Today we will look something which is very quick and but quite frequently useful string operation over numeric datatype. This article is written based on a question asked by one of the users (name not disclosed as per request). Let us see how to show a fixed width number display.  - [SQLAuthority News - Author Visit - Complete Wrapup of Microsoft MVP Summit 2009 Trip](https://blog.sqlauthority.com/2009/03/09/sqlauthority-news-author-visit-complete-wrapup-of-microsoft-mvp-summit-2009-trip/): Today I have arrived in India and back to Ahmedabad. I have left my home on 27th February and arrived back at my home on 9th March. I was traveling for total of 10 days out of 2 days were just technically included as they were very little occupied. I was traveling for 3 days out of remaining 8 days. This leaves me with total of 5 business day. This five days I worked for nearly 16 hours everyday attending Microsoft MVP summit technical sessions, having meetings with industry leaders and learning new things. I have posted my complete tour details... - [SQLAuthority News - Author Visit - South Asian MVPs at Global MVP Summit 2009](https://blog.sqlauthority.com/2009/03/08/sqlauthority-news-author-visit-south-asian-mvps-at-global-mvp-summit-2009/): I am currently at Mumbai Airport and waiting for my flight to Ahmedabad. I am little exhausted but had great time at Global MVP Summit 2009. There were lots of South Asian MVPs present at global event as well. We all had great time to network with each other and few of the MVPs who had arrived day before summit had great time touring Seattle together. We all MVPs had learned so many things about each other and shared some internal tips with each other. One thing we all decided is guest blogging, where we will write blog article for each... - [SQLAuthority News - Author Visit - Tech User Group Meeting, Markham, Canada and Toronto CA Solutions](https://blog.sqlauthority.com/2009/03/07/sqlauthority-news-author-visit-tech-user-group-meeting-markham-canada-and-toronto-ca-solutions/): I can talk about database almost all the day. Yesterday I had two technical meetings. One with Tech User Group of Markham and another with TorontoCASolutions. Let us go over my summary of both the meetings. Tech User Group of Markham, Canada Steve Jagadishan is very enthusiastic leader of the Tech User Group. This user group is very new UG and learning all the tricks and treads. UG is still very small and it has only 6 members so far. There are lots of challenges they are facing and we had interesting discussion at Timothy’s Coffee (a famous Canadian coffee chain).... - [SQLAuthority News - Author Visit - Toronto, Canada - Insert Image in Database](https://blog.sqlauthority.com/2009/03/06/sqlauthority-news-author-visit-toronto-canada-insert-image-in-database/): I am traveling to Toronto from Microsoft MVP Sumeet. I will be very tired as I am continuously working very hard from last 27th Feb. I am still Jet Legged from my trip from India to USA and now I am again changing time zones by visiting Canada. I get all my energy from feeling that what I am doing is helping community and I am working hard to help people who are looking for help. Interestingly Steven Biggins, a reader of this blog was with me in same flight to Canada. He recognized me and asked me following question. As... - [SQLAuthority News - MVP Summit 2009 - Day 4 - Keynote of Steve Ballmer](https://blog.sqlauthority.com/2009/03/05/sqlauthority-news-mvp-summit-2009-day-4-keynote-of-steve-ballmer/): An action pack day with lots of tech session and 4 back to back Keynote sessions is over. Steve Ballmer presented one of the keynote where all attendees really felt energetic. Steve is the person who has so much energy that may be 16 year old kid feel older in front of him. Just like his style, he came in and took over complete session under his charm. I really wish, I could have shared more information but due to NDA I can not share it. It was explicitly expressed that photographs are allowed to take and publish so I am... - [SQLAuthority News - MVP Summit 2009 - Day 3 - Party Day and SQL Celebrity Photos](https://blog.sqlauthority.com/2009/03/04/sqlauthority-news-mvp-summit-2009-day-3-party-day-and-sql-celebrity-photos/): Today was the third day of MVP Summit 2009 and it was wonderful. I had my dream come true as I was able to meet Kalen Delaney – a legendary author of SQL Server and truly living SQL God. If I had not met her today, my trip to USA would have not been complete. I am awaiting for famous book Microsoft SQL Server 2008 Internals (Pro – Developer) to release and I will be the first one to purchase for sure. I really wish if I can get early copy of the book as I just can not wait for... - [SQLAuthority News - MVP Summit 2009 - Day 2 - Most Contributing MVP of Year](https://blog.sqlauthority.com/2009/03/03/sqlauthority-news-mvp-summit-2009-day-2-most-contributing-mvp-of-year/): Day 2 of MVP Summit 2009 was filled with Back to Back Technical session. However, due to NDA I will be not able to share the details about the session. I even verified that I can not even post the title of the session which I have attended. I can only talk general details about the event. In one line – “It is one GREAT event!” Interested readers can read about MVP event schedule here : Agenda of Microsoft MVP Summit 2009. It was the best day for me as I was chosen to have honor by fellow MVP for one... - [SQLAuthority News - MVP Summit 2009 - Day 1 - Summit Welcome and Keynotes](https://blog.sqlauthority.com/2009/03/02/sqlauthority-news-mvp-summit-2009-day-1-summit-welcome-and-keynotes/): My regular blog readers must be aware of my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today was day 1 of MVP Summit and we had started it with big gala event. In morning few of Indian MVP visited Seattle Space Needle and had too much fun there. The Space Needle is a tower in Seattle, Washington, but similar to the one in tokyo, Japan, and is a major landmark of the Pacific Northwest region of the United States and a symbol of Seattle. Located at the Seattle Center, it was built for... - [SQLAuthority News - MVP Summit 2009 - Day 0 - About Pinal Dave](https://blog.sqlauthority.com/2009/03/01/sqlauthority-news-mvp-summit-2009-day-0-about-pinal-dave/): Today is first day of MVP Summit 2009 in Seattle and I am very excited to attend it. This is first time I am in Seattle and I am really liking it. I am planning to visit Seattle Needle and Starbucks coffee shops. One question I have received many times so far is Where am I am from? and once I answer that question I get follow up question about Why I did so? Let me answer this question on my blog today so my readers know about it. I am currently located in Ahmedabad, Gujarat, India and working as SQL... - [SQLAuthority News - MVP Summit 2009 - Database Industry Discussion - Live From London Airport and Sheraton Seattle](https://blog.sqlauthority.com/2009/02/28/sqlauthority-news-mvp-summit-2009-database-industry-discussion-live-from-london-airport-and-sheraton-seattle/): My regular blog readers must be aware of my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today I have very interesting day and my tour has converted to technical discussion from the airport itself. I accidentally met my friend and fellow MVP as well SQL Server Expert Suprotim Agarwal at Mumbai Airport. We will be traveling all the way to Seattle together in same flights. Suprotim is wonderful person to meet as a top notch tech geek of India. We both have same interest and love for technologies. We discussed many tech related... - [SQLAuthority News - MVP Summit 2009 - Journey Begins](https://blog.sqlauthority.com/2009/02/27/sqlauthority-news-mvp-summit-2009-journey-begins/): I will be blogging actively about my tour SQLAuthority News – Author Visit – MVP Global Summit 2009 – Seattle and Redmond. Today I will be leaving for Mumbai. I will be at Mumbai International Airport between 10 PM to 2 AM. If you are traveling and in Mumbai during this four hours, let us meet and talk about Microsoft and SQL Server. I already have received couple of email from SQL Enthusiastics who will be coming to Airport to meet me, so look for 3-4 people sitting gather looking at Dell XPS and having fun. While I am traveling to... - [SQL SERVER - 2008 - Find Relationship of Foreign Key and Primary Key using T-SQL - Find Tables With Foreign Key Constraint in Database](https://blog.sqlauthority.com/2009/02/26/sql-server-2008-find-relationship-of-foreign-key-and-primary-key-using-t-sql-find-tables-with-foreign-key-constraint-in-database/): While searching for how to find Primary Key and Foreign Key relationship using T-SQL, I came across my own blog article written earlier SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database. It is really handy script and not found written on line anywhere. This is one really unique script and must be bookmarked. There may be situations when there is need to find out on relationship between Primary Key and Foreign Key. I have modified my previous script to add schema name along with table name. It would be really great if any of you can... - [The Poll - What is Your Favorite Database?](https://blog.sqlauthority.com/2009/02/25/the-poll-what-is-your-favorite-database/): What is Your Favorite Database? - [SQLAuthority News - Author Visit - MVP Global Summit 2009 - Seattle and Redmond](https://blog.sqlauthority.com/2009/02/24/sqlauthority-news-author-visit-mvp-global-summit-2009-seattle-and-redmond/): MVP Global Summit 2009 is just a less than a week away and I am very all ready for attending my first MVP Global Summit. Microsoft Most Valuable Professionals (MVPs) are invited to attend the MVP Global Summit at the Washington State Convention & Trade Center in Seattle and at Microsoft headquarters in Redmond, Washington, from March 1 through 4. This year’s event promises to provide opportunities for MVPs to network and socialize with their technical peers, build stronger relationships with Microsoft product teams, and represent their communities by sharing real world insight and feedback. Following is my travel itinerary: Feb... - [SQL SERVER - Disable Windows Authentication - Remove Windows Authentication Login Account](https://blog.sqlauthority.com/2009/02/24/sql-server-disable-windows-authentication-remove-windows-authentication-login-account/): I just received following email from one of the blog reader. Question : “How to disable Windows Authentication?” Answer : It can not be disabled. Windows Authentication is the most secure way to login in system. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad User Group Meeting February 21 2009](https://blog.sqlauthority.com/2009/02/23/sqlauthority-news-ahmedabad-user-group-meeting-february-21-2009-2/): We had Ahmedabad SQL Server User Group meeting on February 21, 2009 and it was wonderful to see so many people showing up for meeting. Gradually our group is growing and more and more developers and DBA are showing up. We had two session in this meeting. From the feedback which we have received I can say that it went excellent and developer loved it. In fact there was request to repeat similar kind of sessions to continue. We had started the session little earlier based on attendee’s feedback at 6:15. The agenda of our meeting today was as following. Interesting... - [SQL SERVER - Download - Microsoft SQL Server 2008 Management Studio Express](https://blog.sqlauthority.com/2009/02/22/sql-server-download-microsoft-sql-server-2008-management-studio-express/): Microsoft SQL Server 2008 Management Studio Express is a free, integrated environment for accessing, configuring, managing, administering, and developing all components of SQL Server. SQL Server 2008 Management Studio Express combines a broad group of graphical tools with a number of rich script editors to provide access to SQL Server to developers and administrators of all skill levels. Download – Microsoft SQL Server 2008 Management Studio Express Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - My Observation - Effect of Clustered Index over Nonclustered Index](https://blog.sqlauthority.com/2009/02/21/sql-server-observation-effect-clustered-index-nonclustered-index/): Note: This article is re-write of my previous article SQL SERVER – Observation – Effect of Clustered Index over Nonclustered Index. I have received so many request that re-write it as it is little confusing. I am going to re-write this with simpler words. Query optimization is one art which is difficult to master. Just like any other art this requires creativity and imagination as well understanding of subject matter. Let us look at interesting observation which I came across. First of all download the script from here and run it in SSMS. Now enable Execution Plan (Using CTRL + M)... - [SQLAuthority News - Ahmedabad User Group Meeting February 21 2009](https://blog.sqlauthority.com/2009/02/20/sqlauthority-news-ahmedabad-user-group-meeting-february-21-2009/): It is my pleasure to announce that SQL Server User Group Meeting is held on February 21, 2009. This is the second meeting of year 2009 and will be one interesting meeting as we will have back to back two presentation from SQL Experts. The agenda of meeting will be as following. Working with IDENTITY values in SQL Server – Jacob Sebastian (SQL Server MVP) Interesting Observation – SQL Server Index Usage – Pinal Dave (SQL Server MVP) I encourage every SQL enthusiastic in city to attend this meeting as this will be one memorable event. From this month onwards we... - [SQL SERVER - Disabling Indexes - Non Clustered Indexes](https://blog.sqlauthority.com/2009/02/19/sql-server-disabling-indexes-non-clustered-indexes/): I came across a fantastic T-SQL script that offers an additional feature for changing the recovery mode while enabling and disabling indexes. - [SQLAuthority Author Visit - A True Outsourcing Giant and Technology Leader DigiCorp in Ahmedabad India](https://blog.sqlauthority.com/2009/02/18/sqlauthority-author-visit-a-true-outsourcing-giant-and-technology-leader-digicorp-in-ahmedabad-india/): Last week, I happen to visit one of the tech company in Ahmedabad, India. I visit different IT organization for two purpose – learn more about technology advancement in different organization and help them with any issues if they are facing with Microsoft technology and in particular SQL Server. I visited DigiCorp Information Systems Pvt. Ltd. and I was impressed by its technological advancement and exposure to cutting edge technology. DigiCorp was founded in Jan 2004 and now maintains between 60 and 70 employees in bustling Ahmedabad, India. The company specializes in customized application development in .NET, PHP, Windows Mobile, iPhone... - [SQL SERVER - Find Current Location of Data and Log File of All the Database](https://blog.sqlauthority.com/2009/02/17/sql-server-find-current-location-of-data-and-log-file-of-all-the-database/): As I am doing lots of experiments on my SQL Server test box, I sometime gets too many files in SQL Server data installation folder – the place where I have all the .mdf and .ldf files are stored. I often go to that folder and clean up all unnecessary files I have left there taking up my hard drive space. I run following query to find out which .mdf and .ldf files are used and delete all other files. If your SQL Server is up and running OS will not let you delete .mdf and .ldf files any way giving... - [SQL SERVER - List All Server Wide Configurations Values](https://blog.sqlauthority.com/2009/02/16/sql-server-list-all-server-wide-configurations-values/): Just a day ago, while working on one of the project, I needed to see what is the two digit year cutoff of my current SQL Server. I did not remember what was the exact syntax to search for the same so I ran following query to list all server wide configurations. While looking at quickly I found out value of two digit year cutoff on line 19th. A small but very important script to save for getting server information. - [SQL SERVER - Reasons to Backup Master Database - Why Should Master Database Backedup](https://blog.sqlauthority.com/2009/02/15/sql-server-reasons-to-backup-master-database-why-should-master-database-backedup/): The most interesting thing about writing blog at SQLAuthority.com is follow up question. Just a day before I wrote article about SQL SERVER – Restore Master Database – An Easy Solution, right following it, I received email from user requesting reason for importance of backing up master database. Master database contains all the system level information of server. Information about all the login account, system configurations and information required to access all the other database are stored in master database. If master database is damaged, it will be difficult to use any other database in SQL Server and that makes it... - [SQL SERVER - Restore Master Database - An Easy Solution](https://blog.sqlauthority.com/2009/02/14/sql-server-restore-master-database-an-easy-solution/): Today we will go over two step easy method to restore ‘master’ database. It is really unusal to have need of restoring the master database. In very rare situation this need should arises. It is important to have full backup of master database, without full backup file of master database it can not be restored. It is necessary to start SQL Server in single user mode before master database can be restored. It is very easy to start SQL Server server in single user mode. Follow the tutorial SQL SERVER – Start SQL Server Instance in Single User Mode. Once SQL... - [SQL SERVER - Simple Example of Reading XML File Using T-SQL](https://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/): In one of the previous article we have seen how we can create XML file using SELECT statement SQL SERVER – Simple Example of Creating XML File Using T-SQL. Today we will see how we can read the XML file using the SELECT statement. Following is the XML which we will read using T-SQL: Following is the T-SQL script which we will be used to read the XML: DECLARE @MyXML XML SET @MyXML = '<SampleXML> <Colors> <Color1>White</Color1> <Color2>Blue</Color2> <Color3>Black</Color3> <Color4 Special="Light">Green</Color4> <Color5>Red</Color5> </Colors> <Fruits> <Fruits1>Apple</Fruits1> <Fruits2>Pineapple</Fruits2> <Fruits3>Grapes</Fruits3> <Fruits4>Melon</Fruits4> </Fruits> </SampleXML>' SELECT a.b.value(‘Colors[1]/Color1[1]’,‘varchar(10)’) AS Color1, a.b.value(‘Colors[1]/Color2[1]’,‘varchar(10)’) AS Color2, a.b.value(‘Colors[1]/Color3[1]’,‘varchar(10)’) AS Color3, a.b.value(‘Colors[1]/Color4[1]/@Special’,‘varchar(10)’)+‘ ‘+ +a.b.value(‘Colors[1]/Color4[1]’,‘varchar(10)’)... - [SQL SERVER - Simple Example of Creating XML File Using T-SQL](https://blog.sqlauthority.com/2009/02/12/sql-server-simple-example-of-creating-xml-file-using-t-sql/): I always want to learn SQL Server and XML file. Let us go over a very simple example, today about how to create XML using SQL Server. - [SQL SERVER - Technical Articles - Performance Optimizations for the XML Data Type in SQL Server 2005](https://blog.sqlauthority.com/2009/02/11/sql-server-technical-articles-performance-optimizations-for-the-xml-data-type-in-sql-server-2005/): I always wanted to learn XML and its usage. My friend and fellow MVP Jacob Sebastian is expert in XML, so if you are interested in XML please visit his blog here. If you are interested in performance optimization for XML Data type in SQL Server following article is must read for you. Performance Optimizations for the XML Data Type in SQL Server 2005 by  Shankar Pal, Babu Krishnaswamy, Vasili Zolotov, and Leo Giakoumakis – Microsoft Corporation Articles covers following subjects. Introduction Data Modeling with the XML Data Type Bulk Loading XML Data Indexing XML Data Query and Data Modification Conclusion... - [SQL SERVER - Start SQL Server Instance in Single User Mode](https://blog.sqlauthority.com/2009/02/10/sql-server-start-sql-server-instance-in-single-user-mode/): There are certain situation when user wants to start SQL Server Engine in “single user” mode from the start up. To start SQL Server in single user mode is very simple procedure as displayed below. Go to SQL Server Configuration Manager and click on  SQL Server 2005 Services. Click on desired SQL Server instance and right click go to properties. On the Advance table enter param ‘-m;‘ before existing params in Startup Parameters box. Make sure that you entered semi-comma after -m. Once that is completed, restart SQL Server services to take this in effect. Once this is done, now you... - [SQL SERVER - 2008 - Download Microsoft SQL Server 2008 Express with Tools Free](https://blog.sqlauthority.com/2009/02/09/sql-server-2008-download-microsoft-sql-server-2008-express-with-tools-free/): Note: Download Microsoft SQL Server 2008 Express with Tools Free by Microsoft SQL Server 2008 Express Edition was much awaited version of SQL Server 2008. It is FREE and available to download from web. Microsoft SQL Server 2008 Express with Tools (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes graphical management tools. SQL Server 2008 Express provides powerful and reliable data management tools and rich features, data protection, and fast performance. It is ideal for small server applications and local data stores. SQL Server 2008 Express with Tools has all of the features in... - [SQL SERVER - Free eBook Download - EPUB, MOBI, PDF Format](https://blog.sqlauthority.com/2012/06/15/sql-server-free-ebook-download-epub-mobi-pdf-format/): Microsoft has released recently free eBooks on various Microsoft Technology. The best part is that all these books are available in ePub, Mobi and PDF. You can download them to your local machine or eBook reader and read them. This is a great start as many important subjects are now covered and converted into an eBook. I personally read through a few of the books and found they are very comprehensive and and detailed. The goal is not to cover complete technology in a single book but rather pick a single topic and discuss it in detail. The source of the... - [SQL SERVER - Solution of Puzzle - Swap Value of Column Without Case Statement](https://blog.sqlauthority.com/2012/06/14/sql-server-solution-of-puzzle-swap-value-of-column-without-case-statement/): Earlier this week I asked a question where I asked how to Swap Values of the column without using CASE Statement. Read here: SQL SERVER – A Puzzle – Swap Value of Column Without Case Statement. I have proposed 3 different solutions in the blog posts itself. I had requested the help of the community to come up with alternate solutions and honestly I am stunned and amazed by the qualified entries. I will be not able to cover every single solution which is posted as a comment, however, I would like to for sure cover few interesting entries. However, I am selecting... - [SQL SERVER - Video - Beginning Performance Tuning with SQL Server Execution Plan](https://blog.sqlauthority.com/2012/06/13/sql-server-video-beginning-performance-tuning-with-sql-server-execution-plan/): Traveling can be most interesting or most exhausting experience. However, traveling is always the most enlightening experience one can have. While going to long journey one has to prepare a lot of things. Pack necessary travel gears, clothes and medicines. However, the most essential part of travel is the journey to the destination. There are many variations one prefer but the ultimate goal is to have a delightful experience during the journey. Let us learn about Performance Tuning with SQL Server Execution Plan. - [SQL SERVER - A Quick Look at Logging and Ideas around Logging](https://blog.sqlauthority.com/2012/06/12/sql-server-a-quick-look-at-logging-and-ideas-around-logging/): This blog post is written in response to the T-SQL Tuesday post on Logging. When someone talks about logging, personally I get lots of ideas about it. I have seen logging as a very generic term. Let me ask you this question first before I continue writing about logging. What is the first thing comes to your mind when you hear word “Logging”? Now ask the same question to the guy standing next to you. I am pretty confident that you will get  a different answer from different people. I decided to do this activity and asked 5 SQL Server person... - [SQL SERVER - Developer Training Resources and Summary Roundup](https://blog.sqlauthority.com/2012/06/11/sql-server-developer-training-resources-and-summary-roundup/): It is always pleasure for any author when other renowned authors in the industry write about you. Earlier I wrote a five part blog series on Developer Training and I have received a phenomenal response to the series. I have received plenty of comments, questions and feedback. I thought it would be nice to sum up the whole series as well answer a few of the questions received. Quick Recap Developer Training – Importance and Significance – Part 1 In this part we discussed the importance of training in the real world. The most important and valuable resource any company is its employee.... - [SQL SERVER - Finding Size of a Columnstore Index Using DMVs](https://blog.sqlauthority.com/2012/06/10/sql-server-finding-size-of-a-columnstore-index-using-dmvs/): Columnstore Index is one of my favorite enhancement in SQL Server 2012. A columnstore index stores each column in a separate set of disk pages, rather than storing multiple rows per page as data traditionally has been stored. In case of the row store indexes multiple pages will contain multiple rows of the columns spanning across multiple pages. Whereas in case of column store indexes multiple pages will contain (multiple) single columns.  Columnstore Indexes are compressed by default and occupies much lesser space than regular row store index by default. One of the very common question I often see is need of the... - [SQL SERVER - Service Broker and CAP_CPU_PERCENT - Limiting SQL Server Instances to CPU Usage](https://blog.sqlauthority.com/2012/06/09/sql-server-service-broker-and-cap_cpu_percent-limiting-sql-server-instances-to-cpu-usage/): I have mentioned several times on this blog that the best part of blogging is the questions I receive from readers. They are often very interesting. The questions from readers give me a good idea what other readers might be thinking as well. After reading my earlier article Simple Example to Configure Resource Governor – Introduction to Resource Governor – I received an email from a reader and we exchanged a few emails. After exchanging emails we both figured out what is going on. It was indeed interesting and reader suggested to that I should blog about it.  I asked for... - [SQL SERVER - A Puzzle - Swap Value of Column Without Case Statement](https://blog.sqlauthority.com/2012/06/08/sql-server-a-puzzle-swap-value-of-column-without-case-statement/): For the last few weeks, I have been doing Friday Puzzles and I am really loving it. Yesterday I received a very interesting question by Navneet Chaurasia on Facebook Page. He was asked this question in one of the interview questions for job. Please read the original thread for a complete idea of the conversation. I am presenting the same question here. Puzzle Let us assume there is a single column in the table called Gender. The challenge is to write a single update statement which will flip or swap the value in the column. For example if the value in the... - [SQL SERVER - Load Generator - Free Tool](https://blog.sqlauthority.com/2012/06/07/sql-server-load-generator-free-tool-from-codeplex/): One of the most common questions I receive is if there any tool available to generate load on SQL Server. Absolutely there is a fabulous free tool available to generate load on SQL Server. - [SQL SERVER - Tricks to Replace SELECT * with Column Names - SQL in Sixty Seconds #017 - Video](https://blog.sqlauthority.com/2012/06/06/sql-server-tricks-to-replace-select-with-column-names-sql-in-sixty-seconds-017-video/): You might have heard many times that one should not use SELECT * as there are many disadvantages to the usage of the SELECT *. I also believe that there are always rare occasion when we need every single column of the query. In most of the cases, we only need a few columns of the query and we should retrieve only those columns. SELECT * has many disadvantages. Let me list a few and remaining you can add as a comment.  Retrieves unnecessary columns and increases network traffic When a new columns are added views needs to be refreshed manually... - [SQL SERVER - Fix: Error: 10920 Cannot drop user-defined function. It is being used as a resource governor classifier](https://blog.sqlauthority.com/2012/06/05/sql-server-fix-error-10920-cannot-drop-user-defined-function-it-is-being-used-as-a-resource-governor-classifier/): If you have not read my SQL SERVER – Simple Example to Configure Resource Governor – Introduction to Resource Governor yesterday’s detailed primer on Resource Governor, I suggest you go ahead and read it before continuing this article. After reading the article the very first email I received was as follows: “Pinal, I configured resource governor on my development server and it worked fine with tests I ran. After doing some tests, I decided to remove the resource governor and as a first step I disabled it however, I was not able to drop the classification function during the process of the clean... - [SQL SERVER - Simple Example to Configure Resource Governor - Introduction to Resource Governor](https://blog.sqlauthority.com/2012/06/04/sql-server-simple-example-to-configure-resource-governor-introduction-to-resource-governor/): Let us jump right away with question and answer mode. What is resource governor? Resource Governor is a feature which can manage SQL Server Workload and System Resource Consumption. We can limit the amount of CPU and memory consumption by limiting /governing /throttling on the SQL Server. - [SQL SERVER - Fix: Error 147 An aggregate may not appear in the WHERE clause](https://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/): Everybody was a beginner once and I always like to get involved in the questions from beginners. There is a big difference between the question for beginner and question from advanced user. I have noticed that if an advanced user gets an error, they usually need just a small hint to resolve the problem. Let us learn about how to fix Error 147 in this blog post. - [SQL SERVER - A Puzzle Part 4 - Fun with SEQUENCE in SQL Server 2012 - Guess the Next Value](https://blog.sqlauthority.com/2012/06/02/sql-server-a-puzzle-part-4-fun-with-sequence-in-sql-server-2012-guess-the-next-value/): It seems like every weekend I get a new puzzle in my mind. Before continuing I suggest you read my previous posts here where I have shared earlier puzzles. A Puzzle – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value  A Puzzle Part 2 – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value A Puzzle Part 3 – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value After reading above three posts, I am very confident that you all will be ready for the next set of puzzles now. First execute the script which... - [Developer Training - A Conclusive Summary- Part 5](https://blog.sqlauthority.com/2012/06/01/developer-training-a-conclusive-summary-part-5/): We have now reached the end of our series about developer training. I hope you have come away thinking that training is the best way to advance in your company and that you are looking for training opportunities right now. If you’re still not convinced here are a few things to keep in mind: Training benefits the employer and the employee. A well trained employee is a happy employee, and a happy employee is more efficient and productive. Training an employee might be expensive, but it is less expensive than hiring a new person. - [Developer Training - Various Options for Maximum Benefit - Part 4](https://blog.sqlauthority.com/2012/05/31/developer-training-various-options-for-maximum-benefit-part-4/): If you have been reading this series, by now you are aware of all the pros and cons that can come along with training. We’ve asked and answered hard questions, and investigated them “whys” and “hows” of training. Now it is time to talk about all the different kinds of developer training that are out there! - [Developer Training - Difficult Questions and Alternative Perspective - Part 3](https://blog.sqlauthority.com/2012/05/30/developer-training-difficult-questions-and-alternative-perspective-part-3/): Congratulations! You are now a fully trained developer! You spent hours in a classroom, watching webinars, and reading materials. You are now more educated and more prepared than ever before. Now what? Let us learn more about Developer Training - Difficult Questions and Alternative Perspective. - [Developer Training - Employee Morals and Ethics - Part 2](https://blog.sqlauthority.com/2012/05/29/developer-training-employee-morals-and-ethics-part-2/): If you have been reading this series of posts about Developer Training, you can probably determine where my mind lies in the matter – firmly “pro.” There are many reasons to think that training is an excellent idea for the company. In the end, it may seem like the company gets all the benefits and the employee has just wasted a few hours in a dark, stuffy room. However, don’t let yourself be fooled, this is not the case! - [Developer Training - Importance and Significance - Part 1](https://blog.sqlauthority.com/2012/05/28/developer-training-importance-and-significance-part-1/): Can anyone remember their final day of schooling? This is probably a silly question because – of course you can! Many people mark this as the most exciting, happiest day of their life. It marks the end of testing, the end of following rules set by teachers, and the beginning of finally being able to earn money and work in your chosen field. Let us read more about Developer Training Importance and Significance. - [SQL SERVER - A Puzzle Part 3 - Fun with SEQUENCE in SQL Server 2012 - Guess the Next Value](https://blog.sqlauthority.com/2012/05/27/sql-server-a-puzzle-part-3-fun-with-sequence-in-sql-server-2012-guess-the-next-value/): Before continuing this blog post – please read the two part of the SEQUENCE Puzzle here A Puzzle – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value and A Puzzle Part 2 – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value Where we played a simple guessing game about predicting next value. The answers the of puzzle is shared on the blog posts as a comment. Now here is the next puzzle based on yesterday’s puzzle. I recently shared the puzzle of the blog post on local user group and it was appreciated by attendees. First execute the script which... - [SQL SERVER - A Puzzle Part 2 - Fun with SEQUENCE in SQL Server 2012 - Guess the Next Value](https://blog.sqlauthority.com/2012/05/26/sql-server-a-puzzle-part-2-fun-with-sequence-in-sql-server-2012-guess-the-next-value/): Before continuing this blog post – please read the first part of the SEQUENCE Puzzle here A Puzzle – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value. Where we played a simple guessing game about predicting next value. The answers the of puzzle is shared on the blog posts as a comment. Now here is the next puzzle based on yesterday’s puzzle. First execute the script which I have written here. The only difference between yesterday’s script is that I have removed the MINVALUE as 1 from the syntax. Now guess what will be the next value as requested... - [SQL SERVER - A Puzzle - Fun with SEQUENCE in SQL Server 2012 - Guess the Next Value](https://blog.sqlauthority.com/2012/05/25/sql-server-a-puzzle-fun-with-sequence-in-sql-server-2012-guess-the-next-value/): Yesterday my friend Vinod Kumar wrote excellent blog post on SQL Server 2012: Using SEQUENCE. I personally enjoyed reading the content on this subject. While I was reading the blog post, I thought of very simple new puzzle. Let us see if we can try to solve it and learn a bit more about Sequence. Here is the script, which I executed. USE TempDB GO -- Create sequence CREATE SEQUENCE dbo.SequenceID AS BIGINT START WITH 3 INCREMENT BY 1 MINVALUE 1 MAXVALUE 5 CYCLE NO CACHE; GO -- Following will return 3 SELECT next value FOR dbo.SequenceID; -- Following will return 4 SELECT next... - [SQL SERVER - A Puzzle - Fun with NULL - Fix Error 8117](https://blog.sqlauthority.com/2012/05/24/sql-server-a-puzzle-fun-with-null-fix-error-8117/): During my 8 years of career, I have been involved in many interviews. Quite often, I act as the interview. If I am the interviewer, I ask many questions - from easy questions to difficult ones. When I am the interviewee, I frequently get an opportunity to ask the interviewer some questions back. Regardless of the my capacity in attending the interview, I always make it a point to ask the interviewer at least one question. Let's learn how to fix Error 8117. - [SQL SERVER - Standard Reports from SQL Server Management Studio - SQL in Sixty Seconds #016 - Video](https://blog.sqlauthority.com/2012/05/23/sql-server-standard-reports-from-sql-server-management-studio-sql-in-sixty-seconds-016-video/): SQL Server management Studio 2012 is wonderful tool and has many different features. Many times, an average user does not use them as they are not aware about these features. Today, we will learn one such feature. SSMS comes with many inbuilt performance and activity reports, but we do not use it to the full potential. Connect to SQL Server Node >> Right Click on it >> Go to Reports >> Click on Standard Reports >> Pick Any Report. [youtube=http://www.youtube.com/watch?v=ORtv29rxXJI] Please note that some of the reports can be IO intensive and not suggested to run during business hours! More on... - [SQL SERVER - SmallDateTime and Precision - A Continuous Confusion](https://blog.sqlauthority.com/2012/05/22/sql-server-smalldatetime-and-precision-a-continuous-confusion/): Some kinds of confusion never go away. Here is one of the ancient confusing things in SQL. The precision of the SmallDateTime is one concept that confuses a lot of people, proven by the many messages I receive everyday relating to this subject. Let me start with the question: What is the precision of the SMALLDATETIME datatypes? What is your answer? Write it down on your notepad. Now if you do not want to continue reading the blog post, head to my previous blog post over here: SQL SERVER – Precision of SMALLDATETIME. A Social Media Question Since the increase of social media conversations,... - [SQL SERVER - Renaming Index - Index Naming Conventions](https://blog.sqlauthority.com/2012/05/21/sql-server-renaming-index-index-naming-conventions/): If you are regular reader of this blog, you must be aware of that there are two kinds of blog posts 1) I share what I learn recently 2) I share what I learn and request your participation. Today’s blog post is where I need your opinion to make this blog post a good reference for future. Background Story Recently I came across system where users have changed the name of the few of the table to match their new standard naming convention. The name of the table should be self explanatory and they should have explain their purpose without either opening it... - [SQL SERVER - New Look for CodePlex Project - Hosting for Open Source Software](https://blog.sqlauthority.com/2012/05/20/sql-server-new-look-for-codeplexproject-hosting-for-open-source-software/): Codeplex is my favorite site. CodePlex is Microsoft's free open source project hosting site. You can create projects to share with the world, collaborate with others on their projects, and download open source software. It is a great place to find so many open source project available to explore. All the software are the free and open source. I often go there at intervals to check what is new in SQL Server field as well on other technologies. Yesterday when I visited it, I had a nice surprise as it has a total makeover and looks very decent as well elegant at the same time. - [SQL SERVER - Saturday Fun Puzzle with SQL Server DATETIME2 and CAST](https://blog.sqlauthority.com/2012/05/19/sql-server-saturday-fun-puzzle-with-sql-server-datetime2-and-cast/): Note: I have used SQL Server 2012 for this small fun experiment. Here is what we are going to do. We will run the script one at time instead of running them all together and try to guess the answer. I am confident that many will get it correct but if you do not get correct, you learn something new. Let us create database and sample table. CREATE DATABASE DB2012 GO USE DB2012 GO CREATE TABLE TableDT (DT1 VARCHAR(100), DT2 DATETIME2, DT1C AS DT1, DT2C AS DT2); INSERT INTO TableDT (DT1, DT2) SELECT GETDATE(), GETDATE() GO There are four columns in... - [SQL SERVER - Thinking about Deprecated, Discontinued Features and Breaking Changes while Upgrading to SQL Server](https://blog.sqlauthority.com/2012/05/18/sql-server-thinking-about-deprecated-discontinued-features-and-breaking-changes-while-upgrading-to-sql-server-2012-guest-post-by-nakul-vachhrajani/): In this blog post we Nakul will talk about Thinking about Deprecated, Discontinued Features and Breaking Changes while Upgrading to SQL Server. - [SQLAuthority News - SQL Server 2012 Upgrade Technical Guide - A Comprehensive Whitepaper - (454 pages - 9 MB)](https://blog.sqlauthority.com/2012/05/17/sqlauthority-news-sql-server-2012-upgrade-technical-guide-a-comprehensive-whitepaper-454-pages-9-mb/): Microsoft has just released SQL Server 2012 Upgrade Technical Guide. This guide is very comprehensive and covers the subject of upgrade in-depth. This is indeed a helpful detailed white paper. Even writing a summary of this white paper would take over 100 pages. This further proves that SQL Server 2012 is quite an important release from Microsoft. This white paper discusses how to upgrade from SQL Server 2008/R2 to SQL Server 2012. I love how it starts with the most interesting and basic discussion of upgrade strategies: 1) In-place upgrades, 2) Side by side upgrade, 3) One-server, and 4) Two-server. This whitepaper is... - [SQL SERVER - SQL in Sixty Seconds - 5 Videos from Joes 2 Pros Series - SQL Exam Prep Series 70-433](https://blog.sqlauthority.com/2012/05/16/sql-server-sql-in-sixty-seconds-5-videos-from-joes-2-pros-series-sql-exam-prep-series-70-433/): Joes 2 Pros SQL Server Learning series is indeed fun. Joes 2 Pros series is written for beginners and who wants to build expertise for SQL Server programming and development from fundamental. In the beginning of the series author Rick Morelan is not shy to explain the simplest concept of how to open SQL Server Management Studio. Honestly the book starts with that much basic but as it progresses further Rick discussing about various advanced concepts from query tuning to Core Architecture. This five part series is written with keeping SQL Server Exam 70-433. Instead of just focusing on what will... - [SQL SERVER - Get Schema Name from Object ID using OBJECT_SCHEMA_NAME](https://blog.sqlauthority.com/2012/05/15/sql-server-get-schema-name-from-object-id-using-object_schema_name/): Sometime a simple solution have even simpler solutions but we often do not practice it as we do not see value in it or find it useful. Well, today’s blog post is also about something which I have seen not practiced much in codes. We are so much comfortable with alternative usage that we do not feel like switching how we query the data. I was going over forums and I noticed that at one place user has used following code to get Schema Name from ObjectID. USE AdventureWorks2012 GO SELECT s.name AS SchemaName, t.name AS TableName, s.schema_id, t.OBJECT_ID FROM sys.Tables... - [SQL SERVER - Columnstore Index and sys.dm_db_index_usage_stats](https://blog.sqlauthority.com/2012/05/14/sql-server-columnstore-index-and-sys-dm_db_index_usage_stats/): As you know I have been writing on Columnstore Index for quite a while. Recently my friend Vinod Kumar wrote about SQL Server 2012: ColumnStore Characteristics. A fantastic read on the subject if you have yet not caught up on that subject. After the blog post I called him and asked what should I write next on this subject. He suggested that I should write on DMV script which I have prepared related to Columnstore when I was writing our SQL Server Questions and Answers book. When we were writing this book SQL Server 2012 CTP versions were available. I had written few scripts related to SQL Server columnstore Index. I like Vinod’s idea and I decided to write about DMV, which we did not cover in the book as SQL Server 2012 was not released yet. We did not want to talk about the product which was not yet released. - [SQLAuthority News - Download Whitepaper - Choosing a Tabular or Multidimensional Modeling Experience in SQL Server 2012 Analysis Services](https://blog.sqlauthority.com/2012/05/13/sqlauthority-news-download-whitepaper-choosing-a-tabular-or-multidimensional-modeling-experience-in-sql-server-2012-analysis-services/): Data modeling is the most important task for any BI professional. Matter of the fact, the biggest challenge is to organizing disparate data into an analytic model that effectively and efficiently supports the reporting and analysis. SQL Server 2012 introduces BI Semantic Model (BISM), a single model that can support a broad range of reporting and analysis while blending two Analysis Services modeling experiences behind the scenes. Multidimensional modeling – enables BI professionals to create sophisticated multidimensional cubes using traditional online analytical processing (OLAP). Tabular modeling – provides self-service data modeling capabilities to business and data analysts. As data modeling is evolving and business needs... - [SQL SERVER - Developer Training Kit for SQL Server 2012](https://blog.sqlauthority.com/2012/05/12/sql-server-developer-training-kit-for-sql-server-2012/): Developer Training Kit is my favorite part of any product. The reason behind is very simple because it give the single resource which gives complete overview of the product in nutshell. A developer can learn from many places – books, webcasts, tutorials, blogs, etc. However, I have found that developer training kits are the best starting point for any product. Start with them first, see what are the new features as well what is the new message a product is coming up with. Once it is learned the very next step should be to identify the right learning material to explore... - [SQL SERVER - Quiz and Video - Introduction to Discovering XML Data Type Methods](https://blog.sqlauthority.com/2012/05/11/sql-server-quiz-and-video-introduction-to-discovering-xml-data-type-methods/): This blog post is inspired from SQL Interoperability Joes 2 Pros: A Guide to Integrating SQL Server with XML, C#, and PowerShell – SQL Exam Prep Series 70-433 – Volume 5. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] This is follow up blog post of my earlier blog post on the same subject – SQL SERVER – Introduction to Discovering XML Data Type Methods – A Primer. In the article we discussed various basics terminology of the XML. The article further covers following important concepts of XML. What are XML Data Type Methods The query() Method The value() Method The exist() Method The modify()... - [SQL SERVER - Quiz and Video - Introduction to SQL Error Actions](https://blog.sqlauthority.com/2012/05/10/sql-server-quiz-and-video-introduction-to-sql-error-actions/): This blog post is inspired from SQL Programming Joes 2 Pros: Programming and Development for Microsoft SQL Server 2008 – SQL Exam Prep Series 70-433 – Volume 4. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] This is follow up blog post of my earlier blog post on the same subject – SQL SERVER – Introduction to SQL Error Actions – A Primer. In the article we discussed various basics terminology of the error handling. The article further covers following important concepts of error handling. Introduction to SQL Error Actions Statement Termination Scope Abortion Batch Termination Above three are the most important concepts related to error handling and SQL... - [SQL SERVER - Quiz and Video - Introduction to Basics of a Query Hint](https://blog.sqlauthority.com/2012/05/09/sql-server-quiz-and-video-introduction-to-basics-of-a-query-hint/): This blog post is inspired from SQL Architecture Basics Joes 2 Pros: Core Architecture concepts – SQL Exam Prep Series 70-433 – Volume 3. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] This is follow up blog post of my earlier blog post on the same subject – SQL SERVER – Introduction to Basics of a Query Hint – A Primer. In the article we discussed various basics terminology of the query hints. The article further covers following important concepts of query hints. Expecting Seek and getting a Scan Creating an index for improved optimization Implementing the query hint Above three are the most important concepts... - [SQL SERVER - Quiz and Video - Introduction to Hierarchical Query using a Recursive CTE](https://blog.sqlauthority.com/2012/05/08/sql-server-quiz-and-video-introduction-to-hierarchical-query-using-a-recursive-cte/): This is followed up a blog post of my earlier blog post on the same subject - Introduction to Hierarchical Query using a Recursive CTE – A Primer. In the article we discussed various basic terminology of the CTE. The article further covers following important concepts of common table expression. Let us learn in this video how to do Hierarchical Query using a Recursive CTE. What is a Common Table Expression (CTE) Building a Recursive CTE Identify the Anchor and Recursive Query Add the Anchor and Recursive query to a CTE Add an expression to track hierarchical level Add a self-referencing INNER JOIN statement - [SQL SERVER - Quiz and Video - Introduction to SQL Server Security](https://blog.sqlauthority.com/2012/05/07/sql-server-quiz-and-video-introduction-to-sql-server-security/): This blog post is inspired from Beginning SQL Joes 2 Pros: The SQL Hands-On Guide for Beginners – SQL Exam Prep Series 70-433 – Volume 1. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] This is follow up blog post of my earlier blog post on the same subject – SQL SERVER – Introduction to SQL Server Security – A Primer. In the article we discussed various basics terminology of the security. The article further covers following important concepts of security. Granting Permissions Denying Permissions Revoking Permissions Above three are the most important concepts related to security and SQL Server.  There are many more things one... - [SQL SERVER - Four Tutorial for SQL Server 2012 New Features](https://blog.sqlauthority.com/2012/05/06/sql-server-four-tutorial-for-sql-server-2012-new-features/): One of the very common question I receive on my facebook is that if there is any tutorial for SQL Server 2012 new enhanced features and solutions. I see this demand a bit increasing as the SQL Server 2012 is more and more being adopted. Here is the list of four tutorial which is specifically created for SQL Server 2012 by Microsoft. - [SQL SERVER - Migrate a SQL Server Reports from one server to another server](https://blog.sqlauthority.com/2012/05/05/sql-server-migrate-a-sql-server-reports-from-one-server-to-another-server/): How many time you have felt that there should be need of the tool which help you to migrate SQL Server Reports from one server to another server. Well, I am glad to see this migration tool for migrating reports from SQL Server 2008 R2 and later version. This tool uses powershell for migration  script. Here is the requirement of source server and target server. Source server must be native mode using Windows authentication. Target server must be SharePoint integrated mode. The web application must be using Windows classic authentication mode. You can migrate it using any of the following methods. Command-line tool (RSMigrationTool.exe)... - [SQL SERVER - Identify Columnstore Index Usage from Execution Plan](https://blog.sqlauthority.com/2012/05/04/sql-server-identify-columnstore-index-usage-from-execution-plan/): I think there was a time when lots of questions were coming via either email or blog comments. Nowadays, the trend seems to change. Most of the question I receive is through social media. Here is the latest question I received through Twitter. The best or worst part of Twitter is that it allows only 140 characters, so I’ve noticed that a question is easy to ask on Twitter, but an answer is difficult to provide using this social network. The question I received at https://mobile.twitter.com/pinaldave is as follows: “How do I know if columnstore index is used by query through execution... - [SQL SERVER - A Tricky Question and Even Trickier Answer - Index Intersection - Partition Function](https://blog.sqlauthority.com/2012/05/03/sql-server-a-tricky-question-and-even-trickier-answer-index-intersection-partition-function/): During yesterday’s evening, I asked a very simple question on my Facebook Page. The question was written in a jiffy and in a very light mood. While writing the question, I left a few things out, and the question did miss a few details about setup. However, as the question was not complete, it created an extremely interesting conversation in the following thread. Here is the question: Write a select statement using a single table, using single table single time only without using join keywords, which generate execution plan with 2 join operators. Use AdventureWorks as a sample database. I got many interesting... - [SQL SERVER - Video - Step by Step Installation of SQL Server 2012](https://blog.sqlauthority.com/2012/05/02/sql-server-video-step-by-step-installation-of-sql-server-2012/): SQL Server 2012 launched on March 7, 2012. SQL Server 2012 was available on April 1, 2012 for General Availability. Recently I have received quite a few queries that they are facing issues with SQL Server 2012 installation. I have tried to solve quite a few problems and I figured out really there is no big problem but most of the problem are faced by people who are attempting to install it first time and have no previous experience about installing SQL Server. I decided to create a quick video with voice instruction regarding how to install SQL Server 2012. It... - [SQL SERVER - Maximum Allowable Length of Characters for Temp Objects is 116 - Guest Post by Balmukund Lakhani](https://blog.sqlauthority.com/2012/05/01/sql-server-maximum-allowable-length-of-characters-for-temp-objects-is-116-guest-post-by-balmukund-lakhani/): Balmukund Lakhani (B | T | S) is currently working as Technical Lead in SQL Support team with Microsoft India GTSC. In past 7+ years with Microsoft he was also a part of the Premier Field Engineering Team for 18 months. During that time he was a part of rapid on-site support (ROSS) team. Prior to joining Microsoft in 2005, he worked as SQL developer, SQL DBA and also got a chance to wear his other hat as an ERP Consultant. Let us learn about Maximum Allowable Length of Characters for Temp Objects is 116. - [SQL SERVER - A Brief Introduction to expressor Studio 3.6](https://blog.sqlauthority.com/2012/04/30/sql-server-a-brief-introduction-to-expressor-studio-3-6/): Data is powerful. Data drives businesses. Data supports decision making and fuels progress. But managing data—making data work for us—isn’t inherently easy. And if there is one thing that is certain, it’s change—meaning that data systems created yesterday will need to be adapted to fit ever evolving needs. Since we can’t design our databases, data warehouses, and BI systems with every possible contingency in mind, we need data integration software that is smart enough to simplify the process and allow us to build more flexible solutions that can adapt to change and can let us focus on the value of our... - [SQL SERVER - Microsoft Certification - SQL Server 2012](https://blog.sqlauthority.com/2012/04/29/sql-server-microsoft-certification-sql-server-2012/): Microsoft has recently introduced a few changes in how the certification works. I have tried to simplify the same thing over here. The new certification line is called Microsoft cloud-built Certifications. Let us read more about Microsoft Certification. The mapping of the certifications is here. Exam 70-461: Querying Microsoft SQL Server 2012 Exam 70-462: Administering Microsoft SQL Server 2012 Databases Exam 70-463: Implementing a Data Warehouse with Microsoft SQL Server 2012 - [SQLAuthority News - Migration Guide: Migrating to SQL Server 2012 Failover Clustering and Availability Groups from Prior Clustering and Mirroring Deployments - Part 1](https://blog.sqlauthority.com/2012/04/28/sqlauthority-news-migration-guide-migrating-to-sql-server-2012-failover-clustering-and-availability-groups-from-prior-clustering-and-mirroring-deployments-part-1/): Migration is always a challenge. How many times we have stayed away from migrating product to another server or next version because we are worried what will happen once we migrate. There are two main reasons we stay away from migration 1) Everything is working fine at this moment. 2) Fear of everything will not work fine after migration. Let us address two of this fear in brief words. 1) Everything is working fine Even though everything is working fine there are need to upgrade to next version because new version often brings improved features as well new enhancement which can help in... - [SQL SERVER - Introduction to Discovering XML Data Type Methods - A Primer](https://blog.sqlauthority.com/2012/04/27/sql-server-introduction-to-discovering-xml-data-type-methods-a-primer/): This blog post is inspired from SQL Interoperability Joes 2 Pros: A Guide to Integrating SQL Server with XML, C#, and PowerShell – SQL Exam Prep Series 70-433 – Volume 5. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] What are XML Data Type Methods The XML data type was first introduced with SQL Server 2005. This data type continues with SQL Server 2008 where expanded XML features are available, most notably is the power of the XQuery language to analyze and query the values contained in your XML instance. There are five XML data type methods available in SQL Server 2008: query() – Used... - [SQL SERVER - Introduction to SQL Error Actions - A Primer](https://blog.sqlauthority.com/2012/04/26/sql-server-introduction-to-sql-error-actions-a-primer/): This blog post is inspired from SQL Programming Joes 2 Pros: Programming and Development for Microsoft SQL Server 2008 – SQL Exam Prep Series 70-433 – Volume 4. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] Introduction to SQL Error Actions Most people believe that when SQL Server encounters an error severity level 11 or higher the remaining SQL statements will not get executed. In addition, people also believe that if any error severity level of 11 or higher is hit inside an explicit transaction, then the whole statement will fail as a unit. While both of these beliefs are true 99% of the... - [SQL SERVER - Introduction to Basics of a Query Hint - A Primer](https://blog.sqlauthority.com/2012/04/25/sql-server-introduction-to-basics-of-a-query-hint-a-primer/): This blog post is inspired from SQL Architecture Basics Joes 2 Pros: Core Architecture concepts – SQL Exam Prep Series 70-433 – Volume 3. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] Basics of a Query Hint Query hints specify that the indicated hints should be used throughout the query. Query hints affect all operators in the statement and are implemented using the OPTION clause. The basic syntax structure for a Query Hint is shown below: DECLARE @Type VARCHAR ( 50 ) SET @Type = 'Business' SELECT * FROM Customer WHERE CustomerType = @Type OPTION ( OPTIMIZE FOR ( @Type = 'Business' )); Cautionary... - [SQL SERVER - Introduction to Hierarchical Query using a Recursive CTE - A Primer](https://blog.sqlauthority.com/2012/04/24/sql-server-introduction-to-hierarchical-query-using-a-recursive-cte-a-primer/): This blog post is inspired from SQL Queries Joes 2 Pros: SQL Query Techniques For Microsoft SQL Server 2008 – SQL Exam Prep Series 70-433 – Volume 2. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] What is a Common Table Expression (CTE) A CTE can be thought of as a temporary result set and are similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. A CTE is generally considered to be more readable than a derived table and does not require the extra effort of declaring a Temp Table... - [SQL SERVER - Introduction to SQL Server Security - A Primer](https://blog.sqlauthority.com/2012/04/23/sql-server-introduction-to-sql-server-security-a-primer/): Let’s get some basic definitions down first about SQL Server Security. Take the workplace example where “Tom” needs “Read” access to the “Financial Folder”. What are the Securable, Principal, and Permissions from that last sentence? A Securable is a resource that someone might want to access (like the Financial Folder). A Principal is anything that might want to gain access to the securable (like Tom). A Permission is the level of access a principal has to a securable (like Read). - [Fast Track Data Warehouse Reference Guide for SQL Server - SQLAuthority News](https://blog.sqlauthority.com/2012/04/22/sqlauthority-news-fast-track-data-warehouse-reference-guide-for-sql-server-2012/): The goal of a Fast Track Data Warehouse reference architecture is to achieve an efficient resource balance between SQL Server data processing. - [SQL SERVER - Working with FileTables in SQL Server 2012 - Part 3 - Retrieving Various FileTable Properties](https://blog.sqlauthority.com/2012/04/21/sql-server-working-with-filetables-in-sql-server-2012-part-3-retrieving-various-filetable-properties/): Read Part 1 Working with FileTables in SQL Server 2012 – Part 1 – Setting Up Environment Read Part 2 Working with FileTables in SQL Server 2012 – Part 2 – Methods to Insert Data Into Table In this third part of the series, we will see how we can retrieve various information from the FileTable database. - [SQL SERVER - Performance Tuning - Part 2 of 2 - Analysis, Detection, Tuning and Optimizing](https://blog.sqlauthority.com/2012/04/20/sql-server-performance-tuning-part-2-of-2-analysis-detection-tuning-and-optimizing/): This second part of Performance Tuning – Part 1 of 2 – Getting Started and Configuration. I suggest you read the first part before continuing on this second part. Analysis and Detection If you have noticed that configuration of the data source and profile is a very easy task and if you are familiar with the tool, this can be done in less than 2 minutes. However, while configuration is an important aspect, appropriate analysis of the data is more important since that is what leads us to appropriate results. Once configuration is over, the screen shows the results of the profiling session.... - [SQL SERVER - Performance Tuning - Part 1 of 2 - Getting Started and Configuration](https://blog.sqlauthority.com/2012/04/19/sql-server-performance-tuning-part-1-of-2-getting-started-and-configuration/): Performance tuning is always a complex subject whenever one has to deal with it. When I was beginning with SQL Server, this was the most difficult area for me. However, there is a saying that if one has to overcome their fear one has to face the fear first. So I did exactly this. I started to practice performance tuning. Early in my career I often failed when I had to deal with performance tuning tasks. However, each failure taught me something. It took a quite a while and about 100+ various projects before I started to consider myself a guy... - [SQLAuthority News - Select the Best SQL in Sixty Seconds Episode - Help us Improve](https://blog.sqlauthority.com/2012/04/18/sqlauthority-news-select-the-best-sql-in-sixty-seconds-episode-help-us-improve/): It has been more than 3 months since we have started experimenting with a new concept in  SQL in Sixty Seconds. Every Wednesday, we putt a fresh new interesting concept out via video. Rick Morelan, Vinod Kumar and myself – the three of us decided to do something new and something exciting. We decided to create a short video which will consider the attention span of the viewer, keep them focused and help them learn something new through our teaching. We all liked the idea of SQL in Sixty Seconds. As the name suggests, you will not watch content for more than a minute. We did... - [SQL SERVER Cheatsheet - Released for SQL Server 2012 Edition](https://blog.sqlauthority.com/2012/04/17/sql-server-cheatsheet-released-for-sql-server-2012-edition/): SQL Server Cheatsheet has been extremely popular download from my blog. There are plenty of request for me to update it with SQL Server 2012 features. I have finally upgraded the cheatsheet with SQL Server 2012 features. The new cheatsheet has following updates - [SQLAuthority News - Presenting at Great Indian Developer Summit 2012 - SQL Server Misconception and Resolutions](https://blog.sqlauthority.com/2012/04/16/sqlauthority-news-presenting-at-great-indian-developer-summit-2012-sql-server-misconception-and-resolutions/): Earlier during TechEd 2012, I presented a session on SQL Server Misconception and Resolutions. It was a pleasure to present this session with Vinod Kumar during the event. Great Indian Developer Summit is around the corner and I will be presenting there once again with the same topic. We had an excellent response during the last event; the hall was so filled, but there were plenty who were not able to get into the session as there was no place for them to sit or stand inside. Well, here is another chance for all who missed the presentation. New Additions During... - [SQL SERVER - Working with FileTables in SQL Server 2012 - Part 2 - Methods to Insert Data Into Table ](https://blog.sqlauthority.com/2012/04/15/sql-server-working-with-filetables-in-sql-server-2012-part-2-methods-to-insert-data-into-table/): Read Part 1 Working with FileTables in SQL Server 2012 – Part 1 – Setting Up Environment In this second part of the series, we will see how we can insert the files into the FileTables. There are two methods to insert the data into FileTables: Method 1: Copy Paste data into the FileTables folder First, find the folder where FileTable will be storing the files. Go to Databases >> Newly Created Database (FileTableDB) >> Expand Tables. Here you will see a new folder which says “FileTables”. When expanded, it gives the name of the newly created “FileTableTb”. Right click on the newly created table,... - [SQL SERVER - Working with FileTables in SQL Server 2012 - Part 1 - Setting Up Environment](https://blog.sqlauthority.com/2012/04/14/sql-server-working-with-filetables-in-sql-server-2012-part-1-setting-up-environment/): Filestream is a very interesting feature, and an enhancement of FileTable with Filestream is equally exciting. Today in this post, we will learn how to set up the FileTable Environment in SQL Server. The major advantage of FileTable is it has Windows API compatibility for file data stored within an SQL Server database. In simpler words, FileTables remove a barrier so that SQL Server can be used for the storage and management of unstructured data that are currently residing as files on file servers. Another advantage is that the Windows Application Compatibility for their existing Windows applications enables to see these data as files in... - [SQLAuthority News - Social Media Series - LinkedIn and Professional Profile](https://blog.sqlauthority.com/2012/04/13/sqlauthority-news-social-media-series-linkedin-and-professional-profile/): Pinal Dave on LinkedIn! It seems like a few year ago, there was a big “boom” in social media websites.  All of a sudden there were so many sites to choose from.  MySpace or Orkut?  Blogging websites for your business or a LinkedIn account?  The nature of the internet is to always be changing, but I believe that out of this huge growth of websites, a few have come to stay.  Facebook is obviously the leader in social media networking, especially for your personal life.  Blogging is great, but it can be more of a way to get your ideas out... - [SQLAuthority News - Social Media Series - YouTube and Movies](https://blog.sqlauthority.com/2012/04/12/sqlauthority-news-social-media-series-youtube-and-movies/): Pinal Dave on Youtube! Some people might not know it, but YouTube is actually more than a place to watch funny cat videos and people singing their favorite pop songs – it’s actually a social media site.  When you are a member of YouTube you can follow people who regularly post videos, post video responses of your own, and even gain a following for your own videos.  I myself was not aware of YouTube’s potential until recently, when I started to make SQL Server in Sixty Seconds videos. YouTube is very different than other types of social media, and a big... - [SQL SERVER - Installing AdventureWorks Sample Database - SQL in Sixty Seconds #010 - Video](https://blog.sqlauthority.com/2012/04/11/sql-server-installing-adventureworks-sample-database-sql-in-sixty-seconds-010-video/): SQL Server has so many enhancements and features that quite often I feel like playing with various features and try out new things. I often come across situation where I want to try something new but I do not have sample data to experiment with. Also just like any sane developer I do not try any of my new experiments on production server. Additionally, when it is about new version of the SQL Server, there are cases when there is no relevant sample data even available on development server. In this kind of scenario sample database can be very much handy. Additionally, in many SQL Books and online blogs... - [SQLAuthority News - Social Media Series - Facebook and Google+](https://blog.sqlauthority.com/2012/04/10/sqlauthority-news-social-media-series-facebook-and-google/): Unless you have been living under a rock for the last few years, you know that Facebook is the first and last word in social networking. Everyone has a Facebook account – from your local store with the 10-year old school child. Because of this ability to be completely connected to everyone in your entire life, keeping a Facebook page for a professional business can be tricky. Let us learn a bit more about social media. - [SQLAuthority News - Social Media Series - Twitter and Myself](https://blog.sqlauthority.com/2012/04/09/sqlauthority-news-social-media-series-twitter-and-myself/): Pinal Dave on Twitter! Frequent readers of my blog might know that I am trying to get more involved in all social media sites, both professionally and personally.  Readers might also know that I have often struggled with finding the purpose of some social media sites – Twitter especially.  One of the great uses of social media is to stay connected and updated with followers.  Twitter’s 140 character limit means that Twitter is a great place to get quick updates from the world, but not a lot of deep information.  In fact, I have the feeling that Twitter’s form might actually... - [SQLAuthority News - Download SQL Azure Labs Codename "Data Explorer" Client](https://blog.sqlauthority.com/2012/04/08/sqlauthority-news-download-sql-azure-labs-codename-data-explorer-client/): Microsoft SQL Azure labs has recently released Data Explorer client. I was looking forward to visualizing tool for quite a while and I am delighted to see this tool. I will be trying out this tool in coming week and will post here my experience. I have listed few of the resources which are related to Data Explorer at the end. Please let me know if I have missed any and I will add the same. With “Data Explorer” you can: Identify the data you care about from the sources you work with (e.g. Excel spreadsheets, files, SQL Server databases). Discover relevant data... - [SQL SERVER - DMV sys.dm_exec_describe_first_result_set_for_object - Describes the First Result Metadata for the Module](https://blog.sqlauthority.com/2012/04/07/sql-server-dmv-sys-dm_exec_describe_first_result_set_for_object-describes-the-first-result-metadata-for-the-module/): Here is another interesting follow up blog post of SQL SERVER – sp_describe_first_result_set New System Stored Procedure in SQL Server 2012. While I was writing earlier blog post I had come across DMV sys.dm_exec_describe_first_result_set_for_object as well. I found that SQL Server 2012 is providing all this quick and new features which quite often we miss  to learn it and when in future someone demonstrates the same to us, we express our surprise on the subject. DMV sys.dm_exec_describe_first_result_set_for_object returns result set which describes the columns used in the stored procedure. Here is the quick example. Let us first create stored procedure. USE [AdventureWorks] GO ALTER PROCEDURE [dbo].[CompSP] AS... - [SQLAuthority News - Reliving TechEd at Bangalore User Groups](https://blog.sqlauthority.com/2012/04/06/sqlauthority-news-reliving-teched-bangalore-user-groups/): TechEd India 2012 was held in Bangalore last March 21 to 23, 2012. Just like every year, this event is bigger, grander and inspiring. Here is my blog post reviewing the event SQLAuthority News – #TechEdIn – TechEd India 2012 Memories and Photos. For me this is a family event - I get to meet my friends who are dear as my family. I like to call User Groups as family too. Family shares life's personal happiness and experience - the same way User Group shares professional experiences and quite often UG members become just like a family member. - [SQLAuthority News - #TechEdIn - TechEd India 2012 Memories and Photos](https://blog.sqlauthority.com/2012/04/05/sqlauthority-news-techedin-teched-india-2012-memories-and-photos/): TechEd India 2012 was held in Bangalore last March 21 to 23, 2012. Just like every year, this event is bigger, grander and inspiring. Family Event Every single year, TechEd is a special affair for my entire family.  Four months before the start of TechEd, I usually start to build the mental image of the event. I start to think  about various things. For the most part, what excites me most is presenting a session and meeting friends. Seriously, I start thinking about presenting my session 4 months earlier than the event!  I work on my presentation day and night. I... - [SQL SERVER - Cleaning Up SQL Server Indexes - Defragmentation, Fillfactor - Video](https://blog.sqlauthority.com/2012/04/04/sql-server-cleaning-up-sql-server-indexes-defragmentation-fillfactor-video/): Storing data non-contiguously on disk is known as fragmentation. Before learning to eliminate fragmentation, you should have a clear understanding of the types of fragmentation. When records are stored non-contiguously inside the page, then it is called internal fragmentation. When on disk, the physical storage of pages and extents is not contiguous. We can get both types of fragmentation using the DMV: sys.dm_db_index_physical_stats. Here is the generic advice for reducing the fragmentation. If avg_fragmentation_in_percent > 5% and < 30%, then use ALTER INDEX REORGANIZE: This statement is replacement for DBCC INDEXDEFRAG to reorder the leaf level pages of the index in a logical order.... - [SQL SERVER - FIX: ERROR Msg 5169, Level 16: FILEGROWTH cannot be greater than MAXSIZE for file](https://blog.sqlauthority.com/2012/04/03/sql-server-fix-error-msg-5169-level-16-filegrowth-cannot-be-greater-than-maxsize-for-file/): I am writing this blog post right after I resolve this error for one of the system. Recently one of the my friend who is expert in infrastructure as well private cloud was working on SQL Server installation. Please note he is seriously expert in what he does but he has never worked SQL Server before and have absolutely no experience with its installation. He was modifying database file and keep on getting following error. As soon as he saw me he asked me where is the maxfile size setting so he can change. Let us quickly re-create the scenario he was facing.... - [SQL SERVER - Use ROLL UP Clause instead of COMPUTE BY](https://blog.sqlauthority.com/2012/04/02/sql-server-use-roll-up-clause-instead-of-compute-by/): Note: This upgrade was test performed on development server with using bits of SQL Server 2012 RC0 (which was available at in public) when this test was performed. However, SQL Server RTM (GA on April 1) is expected to behave similarly. I recently observed an upgrade from SQL Server 2005 to SQL Server 2012 with compatibility keeping at SQL Server 2012 (110). After upgrading the system and testing the various modules of the application, we quickly observed that few of the reports were not working. They were throwing error. When looked at carefully I noticed that it was using COMPUTE BY clause,... - [SQL SERVER - A Puzzle - Illusion - Confusion - April Fools' Day](https://blog.sqlauthority.com/2012/04/01/sql-server-a-puzzle-illusion-confusion-april-fools-day/): Today is April 1st and just like every other year, I like to bring something interesting and light for the day. Atleast there should be days in every one’s life when they should feel easy. Here is a quick puzzle for you and I believe it will make you feel extremely smart if you can figure out the result behind the same. Run following in SQL Server Management Studio and observe the output: SELECT 30.0/(-2.0)/5.0; SELECT 30.0/-2.0/5.0; Here are few questions for you: 1) What will be the result of above two queries? 2) Why? If you think you can figure... - [SQL SERVER - sp_describe_first_result_set New System Stored Procedure in SQL Server 2012](https://blog.sqlauthority.com/2012/03/31/sql-server-sp_describe_first_result_set-new-system-stored-procedure-in-sql-server-2012/): I might have said this earlier many times but I will say it again – SQL Server never stops to amaze me. Here is the example of it sp_describe_first_result_set. I stumbled upon it when I was looking for something else on BOL. This new system stored procedure did attract me to experiment with it. This SP does exactly what its names suggests – describes the first result set. Let us see very simple example of the same. Please note that this will work on only SQL Server 2012. EXEC sp_describe_first_result_set N'SELECT * FROM AdventureWorks.Sales.SalesOrderDetail', NULL, 1 GO Here is the partial... - [SQL SERVER - Online Index Rebuilding Index Improvement in SQL Server 2012](https://blog.sqlauthority.com/2012/03/30/sql-server-online-index-rebuilding-index-improvement-in-sql-server-2012/): Have you ever faced a situation where you see something working but you feel it should not be working? Well, I had similar moments a few days ago. I knew that SQL Server 2008 supports online indexing. However, I also knew that I could not rebuild index ONLINE if I used VARCHAR(MAX), NVARCHAR(MAX) or a few other data types. While I was strongly holding on to my belief, I came across with that situation where I had to go online and do a little bit of reading at Book Online.  Here is an example showing the situation I’ve gone through: First... - [SQL SERVER - Difference between DATABASEPROPERTY and DATABASEPROPERTYEX](https://blog.sqlauthority.com/2012/03/29/sql-server-difference-between-databaseproperty-and-databasepropertyex/): Earlier I asked a simple question on Facebook regarding difference between DATABASEPROPERTY and DATABASEPROPERTYEX in SQL Server. You can view the original conversation there over here. The conversion immediately became very interesting and lots of healthy discussion happened on facebook page. The best part of having conversation on facebook page is the comfort it provides and leaner commenting interface. Question Question from SQLAuthority.com: What is the difference between DATABASEPROPERTY and DATABASEPROPERTYEX in SQL Server? Answer Answer from Rakesh Kumar: DATABASEPROPERTY is supported for backward compatibility but does not provide information about the properties added in this release. Also, many properties supported by DATABASEPROPERTY... - [SQL SERVER - T-SQL Constructs - *= and += - SQL in Sixty Seconds #009 - Video](https://blog.sqlauthority.com/2012/03/28/sql-server-t-sql-constructs-and-sql-in-sixty-seconds-009-video/): There were plenty of request for Vinod Kumar to come back with SQL in Sixty Seconds with T-SQL constructs after his very first well received construct video T-SQL Constructs – Declaration and Initialization – SQL in Sixty Seconds #003 – Video. Vinod finally comes up with this new episode where he demonstrates how dot net developer can write familiar syntax using T-SQL constructs. T-SQL has many enhancements which are less explored. In this quick video we learn how T-SQL Constructions works. We will explore Declaration and Initialization of T-SQL Constructions. We can indeed improve our efficiency using this kind of simple tricks. I strongly suggest... - [SQL SERVER - Right Aligning Numerics in SQL Server Management Studio (SSMS)](https://blog.sqlauthority.com/2012/03/27/sql-server-right-aligning-numerics-in-sql-server-management-studio-ssms/): SQL Server Management Studio is my most favorite tool and the comfort it provides to user is sometime very amazing. Recently I was retrieving numeric data in SSMS and I found it is very difficult to read them as they were all right aligned. Please pay attention to following image, you will notice that it is not easier to read the digits as we are used to read the numbers which are right aligned. I immediately thought before I go for any other tricks I should check the query properties. I right clicked on query properties and I found following option.... - [SQL SERVER - Partition Parallelism Support in expressor 3.6](https://blog.sqlauthority.com/2012/03/26/sql-server-partition-parallelism-support-in-expressor-3-6/): I am very excited to learn that there is a new version of expressor’s data integration platform coming out in March of this year. It includes Partition Parallelism Support. It will be version 3.6, and I look forward to using it and telling everyone about it. Let me describe a little bit more about what will be so great in expressor 3.6: Greatly enhanced user interface Parallel Processing Bulk Artifact Upgrading - [SQL SERVER - Download Free eBook - Introducing Microsoft SQL Server 2012](https://blog.sqlauthority.com/2012/03/25/sql-server-download-free-ebook-introducing-microsoft-sql-server-2012/): Database Administration and Business Intelligence is indeed very key area of the SQL Server. My very good friend Ross Mistry and Stacia Misner has recently wrote book which is for SQL Server 2012. The best part of the book is it is totally FREE! Well, this book assumes that you have certain level of SQL Server Administration as well Business Intelligence understanding. So if you are absolutely beginner I suggest you read other books of Ross as well attend Pluralsight course of Stacia Misner. Personally I read this book in last 10 days and I find it very easy to read... - [SQL SERVER - Transcript of Learning SQL Server Performance: Indexing Basics - Interview of Vinod Kumar by Pinal Dave](https://blog.sqlauthority.com/2012/03/24/sql-server-transcript-of-learning-sql-server-performance-indexing-basics-interview-of-vinod-kumar-by-pinal-dave/): Recently I just wrote a blog post on about Learning SQL Server Performance: Indexing Basics and I received lots of request that if we can share some insight into the course. Here is 200 seconds interview of Vinod Kumar I took right after completing the course. We have few free codes to watch the course, please your comment at and we will few of first ones, we will send the code. [youtube=http://www.youtube.com/watch?v=EdLaN9bYdDU] There are many people who said they would like to read the transcript of the video. Here I have generated the same. Pinal: Vinod, we recently released this course, SQL Server... - [SQL SERVER - Using MAXDOP 1 for Single Processor Query - SQL in Sixty Seconds #008 - Video](https://blog.sqlauthority.com/2012/03/23/sql-server-using-maxdop-1-for-single-processor-query-sql-in-sixty-seconds-008-video/): Today’s SQL in Sixty Seconds video is inspired from my presentation at TechEd India 2012 on Speed up! – Parallel Processes and Unparalleled Performance. There are always special cases when it is about SQL Server. There are always few queries which gives optimal performance when they are executed on single processor and there are always queries which gives optimal performance when they are executed on multiple processors. I will be presenting the how to identify such queries as well what are the best practices related to the same. In this quick video I am going to demonstrate if the query is... - [SQL SERVER - #TechEdIn - Presenting Tomorrow on Speed Up! - Parallel Processes and Unparalleled Performance at TechEd India 2012](https://blog.sqlauthority.com/2012/03/22/sql-server-techedin-presenting-tomorrow-on-speed-up-parallel-processes-and-unparalleled-performance-at-teched-india-2012/): Performance tuning is always a very hot topic when it is about SQL Server. SQL Server Performance Tuning is a very challenging subject that requires expertise in Database Administration and Database Development. I always have enjoyed talking about SQL Server Performance tuning subject. However, in India, it’s actually the very first time someone is presenting on this interesting subject, so this time I had the biggest challenge to present this session. Frequently enough, we get these two kind of questions: How to turn off parallelism as it is reducing performance? How to turn on parallelism as I want more performance? The... - [SQL SERVER - Table Variables and Transactions - SQL in Sixty Seconds #007 - Video](https://blog.sqlauthority.com/2012/03/21/sql-server-table-variables-and-transactions-sql-in-sixty-seconds-007-video/): Today’s SQL in Sixty Seconds video is inspired from my presentation at TechEd India 2012 on Misconception and Resolution. Quite often I have seen people getting confused with certain behavior of the T-SQL. They expect SQL to behave certain way and SQL Server behave differently. This kind of issue often creates confusion and frustration. Sometime I have seen them also confusing it with bug and submitting the bug, where reality is totally different. Similar concept which are going to see today. I have seen quite commonly developer assuming that table various will be rolled back when transaction is rolled back. This... - [SQL SERVER - #TechEdIn - Presenting Tomorrow on SQL Server Misconception and Resolution with Vinod Kumar at TechEd India 2012](https://blog.sqlauthority.com/2012/03/20/sql-server-techedin-presenting-tomorrow-on-sql-server-misconception-and-resolution-with-vinod-kumar-at-teched-india-2012/): I am excited AND nervous at the same time. I am going to present a very interesting topic tomorrow at an SQL Server track in India. This will be my fourth time presenting at TechEd India. So far, I have received so much feedback about this one session. It seems like every single person out there has their own wishes and requests. I am sure that it is going to very challenging experience to satisfy everyone who attends the event through my presentation. Surprise Element Here is the good news: I am going to co-present this session with Vinod Kumar, my... - [SQLAuthority News - #TechEDIn - TechEd India 2012 - Things to Do and Explore for SQL Enthusiast](https://blog.sqlauthority.com/2012/03/19/sqlauthority-news-techedin-teched-india-2012-things-to-do-and-explore-for-sql-enthusiast/): TechEd India 2012 is just 48 hours away and I have been receiving lots of requests regarding how SQL enthusiasts can maximize their time they’ll be spending at TechEd India 2012. Trust me – TechEd is the biggest Tech Event in India and it is much larger in magnitude than we can imagine. There are plenty of tracks there and lots of things to do. Honestly, we need clone ourselves multiple times to completely cover the event. However, I am going to talk about SQL enthusiasts only right now. In this post, I’ll share a few things they can do in this big... - [SQL SERVER - Finding Shortest Distance between Two Shapes using Spatial Data Classes - Ramsetu or Adam's Bridge](https://blog.sqlauthority.com/2012/03/18/sql-server-finding-shortest-distance-between-two-shapes-using-spatial-data-classes-ramsetu-or-adams-bridge/): Recently I was reading excellent blog post by Lenni Lobel on Spatial Database. He has written very interesting function ShortestLineTo in Spatial Data Classes. I really loved this new feature of the finding shortest distance between two shapes in SQL Server. Following is the example which is same as Lenni talk on his blog article . DECLARE @Shape1 geometry = 'POLYGON ((-20 -30, -3 -26, 14 -28, 20 -40, -20 -30))' DECLARE @Shape2 geometry = 'POLYGON ((-18 -20, 0 -10, 4 -12, 10 -20, 2 -22, -18 -20))' SELECT @Shape1 UNION ALL SELECT @Shape2 UNION ALL SELECT @Shape1.ShortestLineTo(@Shape2).STBuffer(.25) GO When you run this... - [SQL SERVER - TechEd India 2012 - Content, Speakers and a Lots of Fun](https://blog.sqlauthority.com/2012/03/17/sql-server-teched-india-2012-content-speakers-and-a-lots-of-fun/): TechEd is one event which every developers and IT professionals are looking forward to attend. It is opportunity of life time and no matter how many time one gets chance to engage with it, it is never enough. I still remember every single moment of every TechEd I have attended so far. We are less than 100 hours away from TechEd India 2012 event.This event is the one must attend event for every Technology Enthusiast. Fourth time in the row I am going to attend this event and I am equally excited as the first time of the event. There are... - [SQL SERVER - SQL Server Misconceptions and Resolution - A Practical Perspective - TechEd 2012 India](https://blog.sqlauthority.com/2012/03/16/sql-server-sql-server-misconceptions-and-resolution-a-practical-perspective-teched-2012-india/): TechEd India 2012 is just around the corner and I will be presenting there in two different sessions. On the very first day of this event, my presentation will be all about SQL Server Misconceptions and Resolution – A Practical Perspective. The dictionary tells us that a “misconception” means a view or opinion that is incorrect and is based on faulty thinking or understanding. In SQL Server, there are so many misconceptions. In fact, when I hear some of these misconceptions, I feel like fainting at that very moment! Seriously, at one time, I came across the scenario where instead of using INSERT INTO…SELECT, the... - [SQL SERVER - Install Samples Database AdventureWorks for SQL Server](https://blog.sqlauthority.com/2012/03/15/sql-server-install-samples-database-adventure-works-for-sql-server-2012/): AdventureWorks is a Sample Database shipped with SQL Server and it can be downloaded from GitHub site. AdventureWorks has replaced Northwind and Pubs from the sample database in SQL Server 2005. The Microsoft team keeps updating the sample database as they release new versions. - [SQL SERVER - SQL Server Performance: Indexing Basics - SQL in Sixty Seconds #006 - Video](https://blog.sqlauthority.com/2012/03/14/sql-server-sql-server-performance-indexing-basics-sql-in-sixty-seconds-006-video/): A DBA’s role is critical, because a production environment has to run 24×7, hence maintenance, trouble shooting, and quick resolutions are the need of the hour.  The first baby step into any performance tuning exercise in SQL Server involves creating, analyzing, and maintaining indexes. Though we have learnt indexing concepts from our college days, indexing implementation inside SQL Server can vary.  Understanding this behavior and designing our applications appropriately will make sure the application is performed to its highest potential. Vinod Kumar and myself we often thought about this and realized that practical understanding of the indexes is very important. One can... - [SQL SERVER - Speed Up! - Parallel Processes and Unparalleled Performance - TechEd 2012 India](https://blog.sqlauthority.com/2012/03/13/sql-server-speed-up-parallel-processes-and-unparalleled-performance-teched-2012-india/): TechEd India 2012 is just around the corner and I will be presenting there on two different session. SQL Server Performance Tuning is a very challenging subject that requires expertise in Database Administration and Database Development. I always have enjoyed talking about SQL Server Performance tuning subject. Just like doctors I like to call my every attempt to improve the performance of SQL Server queries and database server as a practice too. I have been working with SQL Server for more than 8 years and I believe that many of the performance tuning concept I have mastered. However, performance tuning is not a simple... - [SQL Server - Learning SQL Server Performance: Indexing Basics - Interview of Vinod Kumar by Pinal Dave](https://blog.sqlauthority.com/2012/03/12/sql-server-learning-sql-server-performance-indexing-basics-interview-of-vinod-kumar-by-pinal-dave/): Recently I just wrote a blog post on about Learning SQL Server Performance: Indexing Basics and I received lots of request that if we can share some insight into the course. Every single time when Performance is discussed, Indexes are mentioned along with it. In recent times, data and application complexity is continuously growing.  The demand for faster query response, performance, and scalability by organizations is increasing and developers and DBAs need to now write efficient code to achieve this. When we developed the course – we made sure that this course remains practical and demo heavy instead of just theories on this... - [SQL SERVER - All Download Links in Single Page - SQL Server 2012](https://blog.sqlauthority.com/2012/03/11/sql-server-2012-all-download-links-in-single-page-sql-server-2012/): As feedback, I received suggestions to have a single page where everything about SQL Server 2012 is listed. Let us learn. - [SQLAuthority News - SQL Server 2012 - Microsoft Learning Training and Certification](https://blog.sqlauthority.com/2012/03/10/sqlauthority-news-sql-server-2012-microsoft-learning-training-and-certification/): Here is the conversion I had right after I had posted my earlier blog post about Download Microsoft SQL Server 2012 RTM Now. Rajesh: So SQL Server is available for me to download? Pinal: Yes, sure check the link here. Rajesh: It is trial do you know when it will be available for everybody? Pinal: I think you mean General Availability (GA) which is on April 1st, 2012. Rajesh: I want to have head start with SQL Server 2012 examination and I want to know every single Exam 70-461: Querying Microsoft SQL Server 2012 This exam is intended for SQL Server database administrators,... - [SQLAuthority News - Download Microsoft SQL Server 2012 RTM Now](https://blog.sqlauthority.com/2012/03/09/sqlauthority-news-download-microsoft-sql-server-2012-rtm-now/): SQL Server 2012 enables a cloud-ready information platform that will help organizations unlock breakthrough insights across the organization as well as quickly build solutions and extend data across on-premises and public cloud backed by capabilities for mission critical confidence: Deliver required uptime and data protection with AlwaysOn Gain breakthrough & predictable performance with ColumnStore Index Help enable security and compliance with new User-defined Roles and Default Schema for Groups Enable rapid data discovery for deeper insights across the organization with ColumnStore Index Ensure more credible, consistent data with SSIS improvements, a Master Data Services add-in for Excel, and new Data Quality... - [SQL Server - Learning SQL Server Performance: Indexing Basics - Video](https://blog.sqlauthority.com/2012/03/08/sql-server-learning-sql-server-performance-indexing-basics-video/): Today I remember one of my older cartoon years ago created for Indexing and Performance. Every single time when Performance is discussed, Indexes are mentioned along with it. In recent times, data and application complexity is continuously growing.  The demand for faster query response, performance, and scalability by organizations is increasing and developers and DBAs need to now write efficient code to achieve this. DBA and Developers A DBA’s role is critical, because a production environment has to run 24×7, hence maintenance, trouble shooting, and quick resolutions are the need of the hour.  The first baby step into any performance tuning... - [SQL SERVER - Tell me What You Want to Listen - My 2 TechED 2011 Sessions](https://blog.sqlauthority.com/2011/03/17/sql-server-tell-me-what-you-want-to-listen-my-2-teched-2011-sessions/): I am going to present two sessions at TechEd India on March 25th, 2011. I would like to know what do you want me to cover in this session. Watch the video taken by my wife when I was preparing for the session. Sessions Date: March 25, 2011 Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Date and Time: March 25, 2011 12:00 PM to 01:00 PM SQL Server Waits and Queues – Your Gateway to Perf. Troubleshooting Date and Time: March 25, 2011 04:15 PM to 05:15 PM I promise following for both of my sessions: I will... - [SQLAuthority News - I am Presenting 2 Sessions at TechEd India](https://blog.sqlauthority.com/2011/03/16/sqlauthority-news-i-am-presenting-2-sessions-at-teched-india/): TechED is the event which I am always excited about. It is one of the largest technology in India. Microsoft Tech Ed India 2011 is the premier technical education and networking event for tech professionals interested in learning, connecting and exploring a broad set of current and soon-to-be released Microsoft technologies, tools, platforms and services. I am going to speak at the TechED on two very interesting and advanced subjects. Venue: The LaLiT Ashok Kumara Krupa High Grounds Bangalore – 560001, Karnataka, India Sessions Date: March 25, 2011 Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Date and Time:... - [SQL SERVER - SQLServer Quiz 2011 - Do you know your execution plan - Two questions - One Answer](https://blog.sqlauthority.com/2011/03/15/sql-server-sqlserver-quiz-2011-do-you-know-your-execution-plan-two-questions-one-answer/): My friend Jacob Sebastian has SQL Server Quiz 2011 launched. This time when he asked me to come up with quiz question – I wanted to come up with something which is new and make participant to think about it. After carefully thinking I come with question which I really like to solve myself. Here is the details: 1) Using Single table only Once in Single SELECT statement generate execution plan which have JOIN operator. Explain the reason for the same. 2) Using Single table only Once in Single SELECT statement generate execution plan which have parallelism operator. Explain the reason... - [SQL SERVER - Guest Post - Architecting Data Warehouse - Niraj Bhatt](https://blog.sqlauthority.com/2011/03/14/sql-server-guest-post-architecting-data-warehouse-niraj-bhatt/): Niraj Bhatt works as an Enterprise Architect for a Fortune 500 company and has an innate passion for building / studying software systems. He is a top rated speaker at various technical forums including Tech·Ed, MCT Summit, Developer Summit, and Virtual Tech Days, among others. Having run a successful startup for four years Niraj enjoys working on – IT innovations that can impact an enterprise bottom line, streamlining IT budgets through IT consolidation, architecture and integration of systems, performance tuning, and review of enterprise applications. He has received Microsoft MVP award for ASP.NET, Connected Systems and most recently on Windows Azure.... - [SQL SERVER - Pending IO request in SQL Server - DMV](https://blog.sqlauthority.com/2011/03/13/sql-server-pending-io-request-in-sql-server-dmv/): I received following question: “How do we know how many pending IO requests are there for database files (.mdf, .ldf) individually?” Very interesting question and indeed answer is very interesting as well. Here is the quick script which I use to find the same. It has to be run in the context of the database for which you want to know pending IO statistics. USE DATABASE GO SELECT vfs.database_id, df.name, df.physical_name ,vfs.FILE_ID, ior.io_pending FROM sys.dm_io_pending_io_requests ior INNER JOIN sys.dm_io_virtual_file_stats (DB_ID(), NULL) vfs ON (vfs.file_handle = ior.io_handle) INNER JOIN sys.database_files df ON (df.FILE_ID = vfs.FILE_ID) I keep this script handy as it... - [SQLAuthority News - Download - Microsoft SQL Server Compact 4.0](https://blog.sqlauthority.com/2011/03/12/sqlauthority-news-download-microsoft-sql-server-compact-4-0/): Microsoft SQL Server Compact 4.0 is a free, embedded database that software developers can use for building ASP.NET websites and Windows desktop applications. SQL Server Compact 4.0 has a small footprint and supports private deployment of its binaries within the application folder, easy application development in Visual Studio and WebMatrix, and seamless migration of schema and data to SQL Server. You can download very small file of SQL Server CE from here. Books Online is the primary documentation for SQL Server Compact 4.0. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward... - [SQL SERVER - Finding Latch Statistics](https://blog.sqlauthority.com/2011/03/11/sql-server-finding-latch-statistics/): Last month I wrote SQL Server Wait Types and Queues series SQL SERVER – Summary of Month – Wait Type – Day 28 of 28. I had great fun to write the series. I learned a lot and I felt this has created some deep interest on the subject with others. I recently received very interesting question from one of the reader after reading SQL SERVER – PAGELATCH_DT, PAGELATCH_EX, PAGELATCH_KP, PAGELATCH_SH, PAGELATCH_UP – Wait Type – Day 12 of 28 that if they can know what kind of latches are waiting and what is their count. Absolutely! SQL Server team has... - [SQL SERVER - Sharing your ETL Resources Across Applications with Ease](https://blog.sqlauthority.com/2011/03/10/sql-server-sharing-your-etl-resources-across-applications-with-ease/): Frequently an organization will find that the same resources are used in multiple ETL applications, for example, the same database, general purpose processing logic, or file system locations. Creating an easy way to reuse these resources across multiple applications would increase efficiency and reduce errors. Moreover, not every ETL developer has the same skill set, and it is likely that one developer will be more adept at writing code while another is more comfortable configuring database connections. Real productivity gains will come when these developers are able to work independently while still making their work available to others assigned to the same project. These are the benefits of a centralized version control system. - [SQLAuthority News - Stay Connected and Social Media](https://blog.sqlauthority.com/2011/03/09/sqlauthority-news-stay-connected-and-social-media/): I think I have finally gotten back my faith in social media. If you are following my blog I am sure you are aware of my views on social media – SQLAuthority News – Social Media Confusion – Twitter, FaceBook, LinkedIn and Me. I was not happy about how social media was evolving. Whenever I go to Twitter, LinkedIn or Facebook, I noticed the same updates everywhere. I just thought I was wasting my time doing the same thing everywhere. I strongly believe that there is no dictator on internet. Nobody has authority over others, everybody can express their ideas as... - [SQL SERVER - Difference between COUNT(DISTINCT) vs COUNT(ALL)](https://blog.sqlauthority.com/2011/03/08/sql-server-difference-between-countdistinct-vs-countall/): This blog post is written in response to the T-SQL Tuesday hosted by Jes Schultz Borland. Earlier today, I was presenting a 45-minute session at the Community College about “The Beginning SQL Server Database”. One of the students asked me the following question. What is the difference between COUNT(DISTINCT) vs COUNT(ALL)? I found this question from the student very interesting. He seems to have read the documentation (Book Online) and was then asking me this question. I always carry laptop which has SQL Server installed. I quickly opened it and ran the following script. After looking at the result, I think... - [SQL SERVER - Enable PowerPivot Plugin in Excel](https://blog.sqlauthority.com/2011/03/07/sql-server-enable-powerpivot-plugin-in-excel/): Recently I had interesting experience at one conference. My PowerPivot plugin got disabled and I had no clue how to enable the same. After while, I figured out how to enable the same. Once I got back from the event, I searched online and realize that many other people online are facing the same problem. Here is how I solved the problem. When I started Excel it did not load PowerPivot plugin. I found in option>> Add in the plug in to be disabled. I enabled the plugin and it worked very well. Let us see that with images. Reference: Pinal... - [SQL SERVER - Running Multiple Batch Files Together in Parallel](https://blog.sqlauthority.com/2011/03/06/sql-server-running-multiple-batch-files-together-in-parallel/): Recently I was preparing a demo for my next technical session, I had to do run a SQL code in parallel. I decided to use Batch File to run the code. I am not the best guy to with command shell so I did it with following setup. Code of tsql.sql SELECT 1 ColumnName Code of command.bat sqlcmd -S . -i tsql.sql timeout 100 Code of  AllBatch.bat start cmd.exe /C “command.bat” start cmd.exe /C “command.bat” start cmd.exe /C “command.bat” Now I ran AllBatch.bat and it run all the three files in parallel and simulated my needed scenario. I believe there should... - [SQLAuthority News - Fast Track Data Warehouse 3.0 Reference Guide](https://blog.sqlauthority.com/2011/03/05/sqlauthority-news-fast-track-data-warehouse-3-0-reference-guide/): https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/gg605238(v=msdn.10)?redirectedfrom=MSDN I am very excited that Fast Track Data Warehouse 3.0 reference guide has been announced. As a consultant, I have always enjoyed working with Fast Track Data Warehouse project as it truly expresses the potential of the SQL Server Engine. Here are a few details of the enhancement of the Fast Track Data Warehouse 3.0 reference architecture. - [SQL SERVER - Concurrency Problems and their Relationship with Isolation Level](https://blog.sqlauthority.com/2011/03/04/sql-server-concurrancy-problems-and-their-relationship-with-isolation-level/): Concurrency is simply put capability of the machine to support two or more transactions working with the same data at the same time. This usually comes up with data is being modified, as during the retrieval of the data this is not the issue. Most of the concurrency problems can be avoided by SQL Locks. There are four types of concurrency problems visible in the normal programming. 1)      Lost Update – This problem occurs when there are two transactions involved and both are unaware of each other. The transaction which occurs later overwrites the transactions created by the earlier update. 2)     ... - [SQL SERVER - Demo Script - Keeping CPU Busy](https://blog.sqlauthority.com/2011/03/03/sql-server-demo-script-keeping-cpu-busy/): Recently face very interesting situation, during presentations at event, I was asked very famous questions: “My CPU is very high all the time, how can I reduce it?” This is very interesting question and there are many answers and a single blog post is not good enough to justify this subject. I presented few situation to the person who asked the question. The member of the audience who asked question came to me afterwords and asked me few detailed questions. To answer him, I quickly wrote query which simulate high CPU. Here is the script which I wrote which increased CPU... - [SQLAuthority News - Uncut and Unedited Video Interview of Pinal Dave](https://blog.sqlauthority.com/2011/03/02/sqlauthority-news-uncut-and-unedited-video-interview-of-pinal-dave/): Earlier this year Lohith (@kashyapa) from Bangalore took my ‘Uncut and Unedited’ video interview. It was really fun to answer his questions as it was very different from regular interview. He asked few personal details few technical details and made me show few secrets. [youtube=http://www.youtube.com/watch?v=k3yLkPt2LIc] I think if you want to see me Uncut and Unedited I urge you to watch the video. He has previously interviewed few celebrities as well. I think I am the only one in the list who is not celebrity. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Pinal Dave: Blogger, MVP and now Interviewee by Michael J Swart](https://blog.sqlauthority.com/2011/03/01/sqlauthority-news-pinal-dave-blogger-mvp-and-now-interviewee-by-michael-j-swart/): Michael J. Swart is a very unique person. I have often exchanged emails with him and also used a couple of his scripts in my presentations (with his permission). Every time I conduct spatial database presentation, I always start with his script where he has drawn the wonderful image of Botticelli’s Birth of Venus. I often think he is more of a creative artist than IT professional. However, if you read his blog posts and articles, they are top notch and each article is as creative as his caricatures. He is wonderful, inspiring, creative and most importantly, very humble. He recently... - [SQL SERVER - Summary of Month - Wait Stats and Wait Type - Day 28 of 28](https://blog.sqlauthority.com/2011/02/28/sql-server-summary-of-month-wait-type-day-28-of-28/): I am glad to announce that the month of Wait Types, Wait Stats and Queues is very successful. I am glad that it was very well received and there was a great amount of participation from the community. - [SQL SERVER - Best Reference - Wait Type - Day 27 of 28](https://blog.sqlauthority.com/2011/02/27/sql-server-best-reference-wait-type-day-27-of-28/): I have great learning experience to write my article series on Extended Event. This was truly learning experience where I have learned way more than I would have learned otherwise. Besides my blog series there was excellent quality reference available on internet which one can use to learn this subject further. Here is the list of resources (in no particular order): sys.dm_os_wait_stats (Book OnLine) – This is excellent beginning point and official documentations on the wait types description. SQL Server Best Practices Article by Tom Davidson – I think this document goes without saying the BEST reference available on this subject.... - [SQL SERVER - Guest Post - Glenn Berry - Wait Type - Day 26 of 28](https://blog.sqlauthority.com/2011/02/26/sql-server-guest-post-glenn-berry-wait-type-day-26-of-28/): Glenn Berry works as a Database Architect at NewsGator Technologies in Denver, CO. He is a SQL Server MVP, and has a whole collection of Microsoft certifications, including MCITP, MCDBA, MCSE, MCSD, MCAD, and MCTS. He is also an Adjunct Faculty member at University College – University of Denver, where he has been teaching since 2000. He is one wonderful blogger and often blogs at here. I am big fan of the Dynamic Management Views (DMV) scripts of Glenn. His script are extremely popular and the reality is that he has inspired me to start this series with his famous DMV... - [SQL SERVER - 2011 - Wait Type - Day 25 of 28](https://blog.sqlauthority.com/2011/02/25/sql-server-2011-wait-type-day-25-of-28/): Since the beginning of the series, I have been getting the following question again and again: “What are the changes in SQL Server 2011 – Denali with respect to Wait Types?” SQL Server 2011 – Denali is yet to be released, and making statements on the subject will be inappropriate. Denali CTP1 has been released so I suggest that all of you download the same and experiment on it. I quickly compared the wait stats of SQL Server 2008 R2 and Denali (CTP1) and found the following changes: Wait Types Exists in SQL Server 2008 R2 and Not Exists in SQL... - [SQL SERVER - 2000 - DBCC SQLPERF(waitstats) - Wait Type - Day 24 of 28](https://blog.sqlauthority.com/2011/02/24/sql-server-2000-dbcc-sqlperfwaitstats-wait-type-day-24-of-28/): I have received many comments, email, suggestions and motivations for my current series of wait types and wait statistics. One of the questions which I keep on receiving almost every other day is whether all of the discussions I have presented so far are also applicable to SQL Server 2000. Additionally, I receive another question asking me if wait statistics matters in SQL Server 2000. If it is, then the asker wants to know how to measure wait types for SQL Server 2000. In SQL Server, you can run the following command to get a list of all the wait types:... - [SQL SERVER - OLEDB - Link Server - Wait Type - Day 23 of 28](https://blog.sqlauthority.com/2011/02/23/sql-server-oledb-link-server-wait-type-day-23-of-28/): When I decided to start writing about this wait type, the very first question that came to my mind was, “What does ‘OLEDB’ stand for?” A quick search on Wikipedia tells me that OLEDB means Object Linking and Embedding Database. (How many of you knew this?) Anyway, I found it very interesting that this wait type was in one of the top 10 wait types in many of the systems I have come across in my performance tuning experience. Books On-Line: OLEDB occurs when SQL Server calls the SQL Server Native Client OLE DB Provider. This wait type is not used... - [SQL SERVER - Guest Post - Jacob Sebastian - Filestream - Wait Types - Wait Queues - Day 22 of 28](https://blog.sqlauthority.com/2011/02/22/sql-server-filestream-wait-types-wait-queues-day-22-of-28/): Jacob Sebastian is a SQL Server MVP, Author, Speaker and Trainer. Jacob is one of the top rated expert community. Jacob wrote the book The Art of XSD – SQL Server XML Schema Collections and wrote the XML Chapter in SQL Server 2008 Bible. See his Blog | Profile. He is currently researching on the subject of Filestream and have submitted this interesting article on the very subject. What is FILESTREAM? FILESTREAM is a new feature introduced in SQL Server 2008 which provides an efficient storage and management option for BLOB data. Many applications that deal with BLOB data today stores... - [SQL SERVER - Guest Posts - Feodor Georgiev - The Context of Our Database Environment - Going Beyond the Internal SQL Server Waits - Wait Type - Day 21 of 28](https://blog.sqlauthority.com/2011/02/21/sql-server-the-context-of-our-database-environment-going-beyond-the-internal-sql-server-waits-wait-type-day-21-of-28/): This guest post is submitted by Feodor. Feodor Georgiev is a SQL Server database specialist with extensive experience of thinking both within and outside the box. He has wide experience of different systems and solutions in the fields of architecture, scalability, performance, etc. Feodor has experience with SQL Server 2000 and later versions, and is certified in SQL Server 2008. In this article Feodor explains the server-client-server process, and concentrated on the mutual waits between client and SQL Server. This is essential in grasping the concept of waits in a ‘global’ application plan. Recently I was asked to write a blog... - [SQL SERVER - MSQL_XP - Wait Type - Day 20 of 28](https://blog.sqlauthority.com/2011/02/20/sql-server-msql_xp-wait-type-day-20-of-28/): In this blog post, I am going to discuss something from my field experience. While consultation, I have seen various wait typed, but one of my customers who has been using SQL Server for all his operations had an interesting issue with a particular wait type. Our customer had more than 100+ SQL Server instances running and the whole server had MSSQL_XP wait type as the most number of wait types. While running sp_who2 and other diagnosis queries, I could not immediately figure out what the issue was because the query with that kind of wait type was nowhere to be... - [SQL SERVER - PREEMPTIVE and Non-PREEMPTIVE - Wait Type - Day 19 of 28](https://blog.sqlauthority.com/2011/02/19/sql-server-preemptive-and-non-preemptive-wait-type-day-19-of-28/): In this blog post, we are going to talk about a very interesting subject. I often get questions related to SQL Server 2008 Book-Online about various Preemptive wait types. I got a few questions asking what these wait types are and how they could be interpreted. To get current wait types of the system, you can read this article and run the script: SQL SERVER – DMV – sys.dm_os_waiting_tasks and sys.dm_exec_requests – Wait Type – Day 4 of 28. Before we continue understanding them, let us study first what PREEMPTIVE and Non-PREEMPTIVE waits in SQL Server mean. PREEMPTIVE: Simply put, this wait... - [SQL SERVER - LOGBUFFER - Wait Type - Day 18 of 28](https://blog.sqlauthority.com/2011/02/18/sql-server-logbuffer-wait-type-day-18-of-28/): At first, I was not planning to write about this wait type. The reason was simple- I have faced this only once in my lifetime so far maybe because it is one of the top 5 wait types. I am not sure if it is a common wait type or not, but in the samples I had it really looks rare to me. From Book On-Line: LOGBUFFER Occurs when a task is waiting for space in the log buffer to store a log record. Consistently high values may indicate that the log devices cannot keep up with the amount of log... - [SQL SERVER - Introduction to Adaptive ETL Tool - How adaptive is your ETL?](https://blog.sqlauthority.com/2011/02/17/sql-server-introduction-to-adaptive-etl-tool-how-adaptive-is-your-etl/): I am often reminded by the fact that BI/data warehousing infrastructure is very brittle and not very adaptive to change. There are lots of basic use cases where data needs to be frequently loaded into SQL Server or another database. What I have found is that as long as the sources and targets stay the same, SSIS or any other ETL tool for that matter does a pretty good job handling these types of scenarios. But what happens when you are faced with more challenging scenarios, where the data formats and possibly the data types of the source data are changing from... - [SQL SERVER - WRITELOG - Wait Type - Day 17 of 28](https://blog.sqlauthority.com/2011/02/17/sql-server-writelog-wait-type-day-17-of-28/): WRITELOG is one of the most interesting wait types. So far we have seen a lot of different wait types, but this log type is associated with log file which makes it interesting to deal with. - [SQL SERVER - Guest Post - Jonathan Kehayias - Wait Type - Day 16 of 28](https://blog.sqlauthority.com/2011/02/16/sql-server-guest-post-jonathan-kehayias-wait-type-day-16-of-28/): Jonathan Kehayias (Blog | Twitter) is a MCITP Database Administrator and Developer, who got started in SQL Server in 2004 as a database developer and report writer in the natural gas industry. After spending two and a half years working in TSQL, in late 2006, he transitioned to the role of SQL Database Administrator. His primary passion is performance tuning, where he frequently rewrites queries for better performance and performs in depth analysis of index implementation and usage. Jonathan blogs regularly on SQLBlog, and was a coauthor of Professional SQL Server 2008 Internals and Troubleshooting. On a personal note, I think... - [SQL SERVER - LCK_M_XXX - Wait Type - Day 15 of 28](https://blog.sqlauthority.com/2011/02/15/sql-server-lck_m_xxx-wait-type-day-15-of-28/): Locking is a mechanism used by the SQL Server Database Engine to synchronize access by multiple users to the same piece of data, at the same time. In simpler words, it maintains the integrity of data by protecting (or preventing) access to the database object. From Book On-Line: LCK_M_BU Occurs when a task is waiting to acquire a Bulk Update (BU) lock. LCK_M_IS Occurs when a task is waiting to acquire an Intent Shared (IS) lock. LCK_M_IU Occurs when a task is waiting to acquire an Intent Update (IU) lock. LCK_M_IX Occurs when a task is waiting to acquire an Intent... - [SQL SERVER - BACKUPIO, BACKUPBUFFER - Wait Type - Day 14 of 28](https://blog.sqlauthority.com/2011/02/14/sql-server-backupio-backupbuffer-wait-type-day-14-of-28/): Backup is the most important task for any database admin. Your data is at risk if you are not performing database backup. Honestly, I have seen many DBAs who know how to take backups but do not know how to restore it. (Sigh!) In this blog post we are going to discuss about one of my real experiences with one of my clients – BACKUPIO. When I started to deal with it, I really had no idea how to fix the issue. However, after fixing it at two places, I think I know why this is happening but at the same... - [SQL SERVER - FT_IFTS_SCHEDULER_IDLE_WAIT - Full Text - Wait Type - Day 13 of 28](https://blog.sqlauthority.com/2011/02/13/sql-server-ft_ifts_scheduler_idle_wait-full-text-wait-type-day-13-of-28/): In the last few days during this series, I got many question about this Wait type. It would be great if you read my original related wait stats query in the first post because I have filtered it out in WHERE clause. However, I still get questions about this being one of the most wait types they encounter. The truth is, this is a background task processing and it really does not matter and it should be filtered out. There are many new Wait types related to Full Text Search that are introduced in SQL Server 2008. If you run the... - [SQL SERVER - PAGELATCH_DT, PAGELATCH_EX, PAGELATCH_KP, PAGELATCH_SH, PAGELATCH_UP - Wait Type - Day 12 of 28](https://blog.sqlauthority.com/2011/02/12/sql-server-pagelatch_dt-pagelatch_ex-pagelatch_kp-pagelatch_sh-pagelatch_up-wait-type-day-12-of-28/): This is another common wait type. However, I still frequently see people getting confused with PAGEIOLATCH_X and PAGELATCH_X wait types. Actually, there is a big difference between the two. PAGEIOLATCH is related to IO issues, while PAGELATCH is not related to IO issues but is oftentimes linked to a buffer issue. Before we delve deeper in this interesting topic, first let us understand what Latch is. Latches are internal SQL Server locks which can be described as very lightweight and short-term synchronization objects. Latches are not primarily to protect pages being read from disk into memory. It’s a synchronization object for... - [SQL SERVER - ASYNC_IO_COMPLETION - Wait Type - Day 11 of 28](https://blog.sqlauthority.com/2011/02/11/sql-server-async_io_completion-wait-type-day-11-of-28/): For any good system three things are vital: CPU, Memory and IO (disk). Among these three, IO is the most crucial factor of SQL Server. Looking at real-world cases, I do not see IT people upgrading CPU and Memory frequently. However, the disk is often upgraded for either improving the space, speed or throughput. Today we will look at another IO-related wait type. From Book On-Line: Occurs when a task is waiting for I/Os to finish. ASYNC_IO_COMPLETION Explanation: Any tasks are waiting for I/O to finish. If by any means your application that’s connected to SQL Server is processing the data... - [SQL SERVER - IO_COMPLETION - Wait Type - Day 10 of 28](https://blog.sqlauthority.com/2011/02/10/sql-server-io_completion-wait-type-day-10-of-28/): For any good system three things are vital: CPU, Memory and IO (disk). Among these three, IO is the most crucial factor of SQL Server. Looking at real-world cases, I do not see IT people upgrading CPU and Memory frequently. However, the disk is often upgraded for either improving the space, speed or throughput. Today we will look at an IO-related wait types. From Book On-Line: Occurs while waiting for I/O operations to complete. This wait type generally represents non-data page I/Os. Data page I/O completion waits appear as PAGEIOLATCH_* waits. IO_COMPLETION Explanation: Any tasks are waiting for I/O to finish.... - [SQLAuthority News - DotNET Challenge of Sorting Generic List](https://blog.sqlauthority.com/2011/02/10/sqlauthority-news-dotnet-challenge-of-sorting-generic-list/): This is a quick announcement of .NET challenge posted by Nupur Dave. She has asked very interesting question. If you are interested in learning .NET and winning iPAD by Red-Gate. I strongly suggest that all of you should attempt the quiz. Here is the question: How to insert an item in sorted generic list such that after insertion list would be sorted? You can visit .NET Challenge to answer the question. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - PAGEIOLATCH_DT, PAGEIOLATCH_EX, PAGEIOLATCH_KP, PAGEIOLATCH_SH, PAGEIOLATCH_UP - Wait Type - Day 9 of 28](https://blog.sqlauthority.com/2011/02/09/sql-server-pageiolatch_dt-pageiolatch_ex-pageiolatch_kp-pageiolatch_sh-pageiolatch_up-wait-type-day-9-of-28/): It is very easy to say that you replace your hardware as that is not up to the mark. In reality, it is very difficult to implement. It is really hard to convince an infrastructure team to change any hardware because they are not performing at their best. I had a nightmare related to this issue in a deal with an infrastructure team as I suggested that they replace their faulty hardware. This is because they were initially not accepting the fact that it is the fault of their hardware. But it is really easy to say “Trust me, I am... - [SQL SERVER - SOS_SCHEDULER_YIELD - Wait Type - Day 8 of 28](https://blog.sqlauthority.com/2011/02/08/sql-server-sos_scheduler_yield-wait-type-day-8-of-28/): This is a very interesting wait type and quite often seen as one of the top wait types. Let us discuss this today. From Book On-Line: Occurs when a task voluntarily yields the scheduler for other tasks to execute. During this wait the task is waiting for its quantum to be renewed. SOS_SCHEDULER_YIELD Explanation: SQL Server has multiple threads, and the basic working methodology for SQL Server is that SQL Server does not let any “runnable” thread to starve. Now let us assume SQL Server OS is very busy running threads on all the scheduler. There are always new threads coming... - [SQL SERVER - Automation Process Good or Ugly](https://blog.sqlauthority.com/2011/02/08/sql-server-automation-process-good-or-ugly/): This blog post is written in response to T-SQL Tuesday hosted by SQL Server Insane Asylum. The idea of this post really caught my attention. Automation – something getting itself done after the initial programming, is my understanding of the subject. The very next thought was – is it good or evil? The reality is there is no right answer. However, what if we quickly note a few things, then I would like to request your help to complete this post. We will start with the positive parts in SQL Server where automation happens. The Good If I start thinking of... - [SQL SERVER - CXPACKET - Parallelism - Advanced Solution - Wait Type - Day 7 of 28](https://blog.sqlauthority.com/2011/02/07/sql-server-cxpacket-parallelism-advanced-solution-wait-type-day-7-of-28/): Earlier we discussed about the what is the common solution to solve the issue with CXPACKET wait time. Today I am going to talk about few of the other suggestions which can help to reduce the CXPACKET wait. If you are going to suggest that I should focus on MAXDOP and COST THRESHOLD – I totally agree. I have covered them in details in yesterday’s blog post. Today we are going to discuss few other way CXPACKET can be reduced. Potential Reasons: If data is heavily skewed, there are chances that query optimizer may estimate the correct amount of the data... - [SQLAuthority News - Presenting at Virtual Tech Days TechEd Pre-Con - February 9, 2011](https://blog.sqlauthority.com/2011/02/07/sqlauthority-news-presenting-at-virtual-tech-days-teched-pre-con-february-9-2011/): I will be presenting on following subject on Virtual Tech Days TechEd Pre-Con – February 9, 2011. Auditing Made Easy: Change Tracking and Change Data Capture Date and Time: February 9, 2011 11:45am-12:45pm Location: Online In this fast paced demo oriented session we will go over few of concept which are related to real life problem at customers. We often see developers and DBA looking for details like who has dropped the table, who has last modified any object as well what was actually modified. SQL Server 2008 has all the answers. It has various new methods for Auditing where not... - [SQL SERVER - CXPACKET - Parallelism - Usual Solution - Wait Type - Day 6 of 28](https://blog.sqlauthority.com/2011/02/06/sql-server-cxpacket-parallelism-usual-solution-wait-type-day-6-of-28/): CXPACKET has to be most popular one of all wait stats. I have commonly seen this wait stat as one of the top 5 wait stats in most of the systems with more than one CPU. Books On-Line: Occurs when trying to synchronize the query processor exchange iterator. You may consider lowering the degree of parallelism if contention on this wait type becomes a problem. CXPACKET Explanation: When a parallel operation is created for SQL Query, there are multiple threads for a single query. Each query deals with a different set of the data (or rows). Due to some reasons, one... - [SQL SERVER - Capturing Wait Types and Wait Stats Information at Interval - Wait Type - Day 5 of 28](https://blog.sqlauthority.com/2011/02/05/sql-server-capturing-wait-types-and-wait-stats-information-at-interval-wait-type-day-5-of-28/): Earlier, I have tried to cover some important points about wait stats in detail. Here are some points that we had covered earlier. DMV related to wait stats reset when we reset SQL Server services DMV related to wait stats reset when we manually reset the wait types However, at times, there is a need of making this data persistent so that we can take a look at them later on. Sometimes, performance tuning experts do some modifications to the server and try to measure the wait stats at that point of time and after some duration. I use the following... - [SQL SERVER - DMV - sys.dm_os_waiting_tasks and sys.dm_exec_requests - Wait Type - Day 4 of 28](https://blog.sqlauthority.com/2011/02/04/sql-server-dmv-sys-dm_os_waiting_tasks-and-sys-dm_exec_requests-wait-type-day-4-of-28/): Previously, we covered the DMV sys.dm_os_wait_stats, and also saw how it can be useful to identify the major resource bottleneck. However, at the same time, we discussed that this is only useful when we are looking at an instance-level picture. Quite often we want to know about the processes going in our server at the given instant. Here is the query for the same. This DMV is written taking the following into consideration: we want to analyze the queries that are currently running or which have recently ran and their plan is still in the cache. SELECT dm_ws.wait_duration_ms, dm_ws.wait_type, dm_es.status, dm_t.TEXT, dm_qp.query_plan,... - [SQL SERVER - DMV - sys.dm_os_wait_stats Explanation - Wait Type - Day 3 of 28](https://blog.sqlauthority.com/2011/02/03/sql-server-dmv-sys-dm_os_wait_stats-explanation-wait-type-day-3-of-28/): The key Dynamic Management View (DMV) that helps us to understand wait stats is sys.dm_os_wait_stats; this DMV gives us all the information that we need to know regarding wait stats. However, the interpretation is left to us. This is a challenge as understanding wait stats can often be quite tricky. Anyway, we will cover few wait stats in one of the future articles. Today we will go over the basic understanding of the DMV. The Official Book OnLine Reference for DMV is over here: sys.dm_os_wait_stats. I suggest you all to refer this for all the accuracy. Following is a statement from the online book: “Specific... - [SQL SERVER - Signal Wait Time Introduction with Simple Example - Wait Type - Day 2 of 28](https://blog.sqlauthority.com/2011/02/02/sql-server-signal-wait-time-introduction-with-simple-example-day-2-of-28/): In this post, let’s delve a bit more in depth regarding wait stats. The very first question: when do the wait stats occur? Here is the simple answer. When SQL Server is executing any task, and if for any reason it has to wait for resources to execute the task, this wait is recorded by SQL Server with the reason for the delay. Later on we can analyze these wait stats to understand the reason the task was delayed and maybe we can eliminate the wait for SQL Server. It is not always possible to remove the wait type 100%, but there are... - [SQL SERVER - Wait Stats - Wait Types - Wait Queues - Day 0 of 28](https://blog.sqlauthority.com/2011/02/01/sql-server-wait-stats-wait-types-wait-queues-day-0-of-28-2/): This blog post will have running account of the all the blog post I will be doing in this month related to SQL Server Wait Types and Wait Queues. SQL SERVER – Introduction to Wait Stats and Wait Types – Wait Type – Day 1 of 28 SQL SERVER – Signal Wait Time Introduction with Simple Example – Wait Type – Day 2 of 28 SQL SERVER – DMV – sys.dm_os_wait_stats Explanation – Wait Type – Day 3 of 28 SQL SERVER – DMV – sys.dm_os_waiting_tasks and sys.dm_exec_requests – Wait Type – Day 4 of 28 SQL SERVER – Capturing Wait Types and Wait Stats... - [SQL SERVER - Introduction to Wait Stats and Wait Types - Wait Type - Day 1 of 28](https://blog.sqlauthority.com/2011/02/01/sql-server-introduction-to-wait-stats-and-wait-types-wait-type-day-1-of-28/): I have been working a lot on Wait Stats and Wait Types recently. Last Year, I requested blog readers to send me their respective server’s wait stats. I appreciate their kind response as I have received  Wait stats from my readers. I took each of the results and carefully analyzed them. I provided necessary feedback to the person who sent me his wait stats and wait types. Based on the feedbacks I got, many of the readers have tuned their server. After a while I got further feedbacks on my recommendations and again, I collected wait stats. I recorded the wait stats and my recommendations and did... - [SQL SERVER - What is Fill Factor and What is the Best Value for Fill Factor](https://blog.sqlauthority.com/2011/01/31/sql-server-what-is-fill-factor-and-what-is-the-best-value-for-fill-factor/): Working in performance tuning area, one has to know about Index and Index Maintenance. For any Index the most important property is Fill Factor. Fill factor is the value that determines the percentage of space on each leaf-level page to be filled with data. In an SQL Server, the smallest unit is a page, which is made of  Page with size 8K. Every page can store one or more rows based on the size of the row. The default value of the Fill Factor is 100, which is same as value 0. The default Fill Factor (100 or 0) will allow... - [SQL SERVER - Denali - SEQUENCE is not IDENTITY](https://blog.sqlauthority.com/2011/01/30/sql-server-2011-sequence-is-not-identity/): Yesterday I posted blog post on the subject SQL SERVER – 2011 – Introduction to SEQUENCE – Simple Example of SEQUENCE and I received comment where user was not clear about difference between SEQUENCE and IDENTITY. The reality is that SEQUENCE not like IDENTITY. There is very clear difference between them. Identity is about single column. Sequence is always incrementing and it is not dependent on any table. Here is the quick example of the same. USE AdventureWorks2008R2 GO CREATE SEQUENCE [Seq] AS [int] START WITH 1 INCREMENT BY 1 MAXVALUE 20000 GO -- Run five times SELECT NEXT VALUE FOR... - [SQL SERVER - Denali - Introduction to SEQUENCE - Simple Example of SEQUENCE](https://blog.sqlauthority.com/2011/01/29/sql-server-2011-introduction-to-sequence-simple-example-of-sequence/): SQL Server 2011 will contain one of the very interesting feature called SEQUENCE. I have waited for this feature for really long time. I am glad it is here finally. SEQUENCE allows you to define a single point of repository where SQL Server will maintain in memory counter. USE AdventureWorks2008R2 GO CREATE SEQUENCE [Seq] AS [int] START WITH 1 INCREMENT BY 1 MAXVALUE 20000 GO SEQUENCE is very interesting concept and I will write few blog post on this subject in future. Today we will see only working example of the same. Let us create a sequence. We can specify various... - [SQLAuthority News - Deployment guide for Microsoft SharePoint Foundation 2010](https://blog.sqlauthority.com/2011/01/28/sqlauthority-news-deployment-guide-for-microsoft-sharepoint-foundation-2010/): SharePoint and SQL Server both goes together – hands to hand. SharePoint installation is very interesting. At various organizations, the installation is very different and have various needs. SQL Server installation with SharePoint is equally important and I have often seen that it is being neglected. Microsoft has published the Deployment Guide for SharePoint Foundation. It talks about various database aspects as well. For optimal sharepoint installation the required version of SQL Server, including service packs and cumulative updates must be installed on the database server. The installation must include any additional features, such as SQL Analysis Services, and the appropriate... - [SQL SERVER - What is a Technology Evangelist?](https://blog.sqlauthority.com/2011/01/27/sql-server-what-is-a-technology-evangelist/): When you hear that someone is an “evangelist” the first thing that might pop into your mind is the Christian church.  In fact, the term did come from Christianity, and basically means someone who spreads the news about their faith.  In the technology world, the same definition is true. Technology evangelists are individuals who, professionally or in their spare time, spread the news about the latest new products.  Sounds like a salesperson, right?  No they are absolutely different. Salespeople also keep up to date with a large number of people, and like to convince others to buy their product – and... - [SQL SERVER - Reducing Page Contention on TempDB](https://blog.sqlauthority.com/2011/01/26/sql-server-reducing-page-contention-on-tempdb/): I have recently received following email asking about how to reduce page contention on TempDB. "We are using Trace Flag 1118 to reduce the tempDB contention on our servers (2000 and 2005). What is your opinion? We have read lots of material, would you please answer me in single line." - [SQL SERVER - Denali - Clipboard Ring - CTRL+SHIFT+V](https://blog.sqlauthority.com/2011/01/25/sql-server-2011-clipboard-ring-ctrlshiftv/): While I was writing my earlier post SQL SERVER – 2011 – Multi-Monitor SSMS Windows, I found out that there is one more similar feature which existed in Visual Studio is also now part of SQL Server 2011 (Denali). The feature is called clipboard ring feature. This is how it works. Select Multiple object one by one using regular CTRL + X. Now instead of pasting using CTRL+V use CTRL+SHIFT+V. Well, you will see that that pasted value is rotating based on what you have earlier selected in CTRL+V. I was really happy as I think this is one of the feature... - [SQL SERVER - Denali - Multi-Monitor SSMS Windows](https://blog.sqlauthority.com/2011/01/24/sql-server-2011-multi-monitor-ssms-windows/): I have a dual screen arrangement at my home system. I love it because it’s very convenient. When I am working with SQL Server 2008 R2 or any earlier versions, I would want to use both of the Monitor so I open two separate SQL Server Management Studio and work along with it. I have no complaints with my system, at all. I am totally fine with it. However, sometimes I face small issues, like when I just want a small code open in a separate window but I do not want the windows to take over the whole of another window.... - [SQLAuthority News - Download Whitepaper - Enabling and Securing Data Entry with Analysis Services Writeback](https://blog.sqlauthority.com/2011/01/23/sqlauthority-news-download-whitepaper-enabling-and-securing-data-entry-with-analysis-services-writeback/): SQL Server Analysis Service have many features which are commonly requested and many already exists in the system. Security Data Entry is very important feature and SSAS supports writeback feature.  Analysis Services is a tool for aggregating information and providing business users with the ability to analyze and support decision making in their business. By using the built-in writeback feature in Analysis Services, business users can also modify their data points to perform what-if analysis or supplement any existing data. The techniques described in this article derive from the author’s professional experience in the design and development of complex financial analysis applications used... - [SQL SERVER- Differences Between Left Join and Left Outer Join](https://blog.sqlauthority.com/2011/01/22/sql-server-differences-between-left-join-and-left-outer-join/): There are a few questions that I had decided not to discuss on this blog because I think they are very simple and many of us know it. Many times, I even receive not-so positive notes from several readers when I am writing something simple. However, assuming that we know all and beginners should know everything is not the right attitude. Since day 1, I have been keeping a small journal regarding questions that I receive in this blog. There are around 200+ questions I receive every day through emails, comments and occasional phone calls. Yesterday, I received a comment with... - [SQLAuthority News - 1600 Blog Post Articles - A Milestone](https://blog.sqlauthority.com/2011/01/21/sqlauthority-news-1600-blog-post-articles-a-milestone/): It was really a very interesting moment for me when I was writing my 1600th milestone blog post. Now it`s a lot more exciting because this time it`s my 1600th blog post. Every time I write a milestone blog post such as this, I have the same excitement as when I was writing my very first blog post. Today I want to write about a few statistics of the blog. Statistics I am frequently asked about my blog stats, so I have already published my blog stats which are measured by WordPress.com. Currently, I have more than 22 Million+ Views on... - [SQLAuthority News - Scaling Up Your Data Warehouse with SQL Server 2008 R2](https://blog.sqlauthority.com/2011/01/20/sqlauthority-news-scaling-up-your-data-warehouse-with-sql-server-2008-r2/): Data Warehouses are suppose to be containing huge amount of the data from the beginning. However, there are cases when too big is not enough. Every Data Warehouse Admin will agree that they have faced situation where they will need to scale up their data warehouse. Microsoft has released white paper discussing the same. Here is the abstract from the Microsoft Official site: SQL Server 2008 introduced many new functional and performance improvements for data warehousing, and SQL Server 2008 R2 includes all these and more. This paper discusses how to use SQL Server 2008 R2 to get great performance as your... - [SQL SERVER - Shrinking Database is Bad - Increases Fragmentation - Reduces Performance](https://blog.sqlauthority.com/2011/01/19/sql-server-shrinking-database-is-bad-increases-fragmentation-reduces-performance/): Earlier, I had written two articles related to Shrinking Database. I wrote about why Shrinking Database is not good. - [SQL SERVER - 4 Tips for ETL Software IDE Developers](https://blog.sqlauthority.com/2011/01/18/sql-server-4-tips-for-etl-software-ide-developers/): In a previous blog, I introduced the notion of Semantic Types. To an end-user, a seamlessly integrated semantic typing engine significantly increases the ease of use of an ETL IDE (integrated development environment, or developer studio). This led me to think about other ease-of-use issues I have encountered while building ETL applications. When I get stumped while programming, I find myself asking the variations on these questions: “How do I…?” “Now what?” “Why isn’t this working?” “Why do I have to redo the work I just did?” It seems to me that a good ETL IDE will anticipate these questions and seek... - [SQL SERVER - A Funny Cartoon on Index](https://blog.sqlauthority.com/2011/01/17/sql-server-a-funny-cartoon-on-index/): Performance Tuning has been my favorite subject and I have done it for many years now. Today I will list one of the most common conversations about Index I have heard in my life. Let us see a funny cartoon on the Index and Performance Tuning. - [SQLAuthority News - Whitepaper Download - Using Star Join and Few-Outer-Row Optimizations to Improve Data Warehousing Queries](https://blog.sqlauthority.com/2011/01/16/sqlauthority-news-whitepaper-download-using-star-join-and-few-outer-row-optimizations-to-improve-data-warehousing-queries/): Size of the database is growing every day. Many organizations now a days have more than TB of the Data in their system. Performance is always part of the issue. Microsoft is really paying attention to the same and also focusing on improving performance for Data Warehousing. Microsoft has recently released whitepaper on the performance tuning subject of Data Warehousing. Here is the abstract about the whitepaper from official site: In this white paper we discuss two of the new features introduced in SQL Server 2008, Star Join and Few-Outer-Row optimizations. These two features are in SQL Server 2008 R2 as... - [SQLAuthority News - Best Practices for Data Warehousing with SQL Server 2008 R2](https://blog.sqlauthority.com/2011/01/15/sqlauthority-news-best-practices-for-data-warehousing-with-sql-server-2008-r2/): An integral part of any BI system is the data warehouse—a central repository of data that is regularly refreshed from the source systems. The new data is transferred at regular intervals  by extract, transform, and load (ETL) processes. This whitepaper talks about what are best practices for Data Warehousing. This whitepaper discusses ETL, Analysis, Reporting as well relational database. The main focus of this whitepaper is on mainly ‘architecture’ and ‘performance’. Download Best Practices for Data Warehousing with SQL Server 2008 R2 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Quick Look at SQL Server Configuration for Performance Indications](https://blog.sqlauthority.com/2011/01/14/sql-server-quick-look-at-sql-server-configuration-for-performance-indications/): Earlier I wrote SQL SERVER – Beginning SQL Server: One Step at a Time – SQL Server Magazine. That was the first article on the series of my real world experience of Performance Tuning experience. I have written second part the same series over here. Read second part over here: Quick Look at SQL Server Configuration for Performance Indications.[Articles are relocated so links are disabled] In this second part I talk about two types of my clients. 1) Those who want instant results 2) Those who want the right results It is really fun to work with both the clients. I talk... - [SQL SERVER - A Quick Note on DB_ID() and DB_NAME() - Get Current Database ID - Get Current Database Name](https://blog.sqlauthority.com/2011/01/13/sql-server-a-quick-note-on-db_id-and-db_name-get-current-database-id-get-current-database-name/): Quite often a simple things makes experienced DBA to look for simple thing. Here are few things which I used to get confused couple of years ago. Now I know it well and have no issue but recently I see one of the DBA getting confused when looking at the DBID from one of the DMV and not able to related that directly to Database Name. -- Get Current DatabaseID SELECT DB_ID() DatabaseID; -- Get Current DatabaseName SELECT DB_NAME() DatabaseName; -- Get DatabaseName from DatabaseID SELECT DB_NAME(4) DatabaseName; -- Get DatabaseID from DatabaseName SELECT DB_ID('tempdb') DatabaseID; -- Get all DatabaseName and... - [SQLAuthority News - Download SQL Server 2008 R2 Upgrade Technical Reference Guide](https://blog.sqlauthority.com/2011/01/12/sqlauthority-news-download-sql-server-2008-r2-upgrade-technical-reference-guide/): I recently come across very interesting white paper written for Microsoft by Solid Quality Mentors. A successful upgrade to SQL Server 2008 R2 should be smooth and trouble-free. To do that smooth transition, you must plan sufficiently for the upgrade and match the complexity of your database application. Otherwise, you risk costly and stressful errors and upgrade problems. SQL Server 2008 R2 Upgrade Technical Reference Guide is one of the best and comprehensive reference guide I have seen on the subject of SQL Server 2008 R2 upgrade. There are so many various subjects discussed about upgrade which one would always wanted... - [SQL SERVER - Performance Tuning Resolution](https://blog.sqlauthority.com/2011/01/11/sql-server-performance-tuning-resolution/): This blog post is written in response to T-SQL Tuesday hosted by MidnightDBAs. Taking resolutions is such an interesting subject. I think just like records, these are broken way more often. I find this is the funniest thing as we all take resolutions every year but not every year, we can manage to keep them. Well, does it mean we should not take resolutions? In fact I support resolutions. Every year, I take a resolution that I will strive reduce my body weight and I usually manage to keep eating healthy till the end of January. When February begins, I begin... - [SQLAuthority News - Free Trip on SQL Cruise](https://blog.sqlauthority.com/2011/01/10/sqlauthority-news-free-trip-on-sql-cruise/): Everybody wants to go cruising.  I want to relax in a cruise as well, of course! (Anybody who wants to be my sponsor? Just kidding!) My family wants to go to a cruise, too. Even though I really want go to a cruise, I always wonder about one thing: what happens if I get bored on the cruise because I’d just look at the water most of the time? The best recommendation to avoid boredom on board is to travel with friends. How many friends usually accompany you when travelling? I have several good friends going on a cruise, and this is the... - [SQL SERVER - master Database Log File Grew Too Big](https://blog.sqlauthority.com/2011/01/09/sql-server-master-database-log-file-grew-too-big/): Couple of the days ago, I received following email and I find this email very interesting and I feel like sharing with all of you. Note: Please read the whole email before providing your suggestions. “Hi Pinal, If you can share these details on your blog, it will help many. We understand the value of the master database and we take its regular back up (everyday midnight). Yesterday we noticed that our master database log file has grown very large. This is very first time that we have encountered such an issue. The master database is in simple recovery mode; so... - [SQL SERVER - Get File Statistics Using fn_virtualfilestats](https://blog.sqlauthority.com/2011/01/08/sql-server-get-file-statistics-using-fn_virtualfilestats/): Quite often when I am staring at my SSMS I wonder what is going on under the hood in my SQL Server. I often want to know which database is very busy and which database is bit slow because of IO issue. Sometime, I think at the file level as well. I want to know which MDF or NDF is busiest and doing most of the work. Following query gets the same results very quickly. SELECT DB_NAME(vfs.DbId) DatabaseName, mf.name, mf.physical_name, vfs.BytesRead, vfs.BytesWritten, vfs.IoStallMS, vfs.IoStallReadMS, vfs.IoStallWriteMS, vfs.NumberReads, vfs.NumberWrites, (Size*8)/1024 Size_MB FROM ::fn_virtualfilestats(NULL,NULL) vfs INNER JOIN sys.master_files mf ON mf.database_id = vfs.DbId AND... - [SQL SERVER - DMV - sys.dm_exec_query_optimizer_info - Statistics of Optimizer](https://blog.sqlauthority.com/2011/01/07/sql-server-dmv-sys-dm_exec_query_optimizer_info-statistics-of-optimizer/): Incredibly, SQL Server has so much information to share with us. Every single day, I am amazed with this SQL Server technology. Sometimes I find several interesting information by just querying few of the DMV. And when I present this info in front of my client during performance tuning consultancy, they are surprised with my findings. Today, I am going to share one of the hidden gems of DMV with you, the one which I frequently use to understand what’s going on under the hood of SQL Server. SQL Server keeps the record of most of the operations of the Query Optimizer. We can... - [SQL SERVER - Beginning SQL Server: One Step at a Time - SQL Server Magazine](https://blog.sqlauthority.com/2011/01/06/sql-server-beginning-sql-server-one-step-at-a-time-sql-server-magazine/): I am glad to announce that along with SQLAuthority.com, I will be blogging on the prominent site of SQL Server Magazine. My association with SQL Server Magazine has been quite long, I have written nearly 7 to 8 SQL Server articles for the print magazine and it has been a great experience. I used to stay in the United States at that time. I moved back to India for good, and during this process, I had put everything on hold for a while. Just like many things, “temporary” things become “permanent” – coming back to SQLMag was on hold for long... - [SQL SERVER - Copy Statistics from One Server to Another Server](https://blog.sqlauthority.com/2011/01/05/sql-server-copy-statistics-from-one-server-to-another-server/): I was recently working on a performance tuning project in Dubai (yeah I was able to see the tallest tower from the window of my work place). I had a very interesting learning experience there. There was a situation where we wanted to receive the schema of original database from a certain client. However, the client was not able to provide us any data due to privacy issues. The schema was very important because without having an access to underlying data, it was a bit difficult to judge the queries etc. For example, without any primary data, all the queries are... - [SQL SERVER - Unused Index Script - Download](https://blog.sqlauthority.com/2011/01/04/sql-server-2008-unused-index-script-download/): Performance Tuning is quite interesting and Index plays a vital role in it. A proper index can improve the performance and a bad index can hamper the performance. Here is the script from my script bank, which I use to identify unused indexes on any database. Let us see script for unused index. - [SQL SERVER - Missing Index Script - Download](https://blog.sqlauthority.com/2011/01/03/sql-server-2008-missing-index-script-download/): Performance Tuning is quite interesting and Index plays a vital role in it. A proper index can improve the performance and a bad index can hamper the performance. In this blog post we will discuss about Missing Index. - [SQL SERVER - Reduce the Virtual Log Files (VLFs) from LDF file](https://blog.sqlauthority.com/2011/01/02/sql-server-reduce-the-virtual-log-files-vlfs-from-ldf-file/): Earlier, I wrote a quite note on SQL SERVER – Detect Virtual Log Files (VLF) in LDF. Because of this I got responses suggesting too many VLFs are bad for log file. This prompts to a simple question: “How many is ‘too many’ VLFs?” I suggest that you go and read an article written by Kimberly over here. I am sure that you are going to have a clear understanding of what a good number for your VLFs is from that article. If you have lots of VLFs, you can reduce them right away using the following method: (I am just attempting to... - [SQLAuthority News - Resolution for New Year 2011](https://blog.sqlauthority.com/2011/01/01/sqlauthority-news-resolution-for-new-year-2011/): Today is the first day of the year so I want to write something very light. Last Year: 2010 Last Year was a blast; really traveled a lot. My family and I went on vacation. There I enjoyed being father, rolling on the floor and playing with my daughter. Here is the list of the countries I visited throughout 2010: Singapore (twice) Malaysia (twice) Sri Lanka (thrice) Nepal (once) United States of America (twice) United Arab Emirates (UAE) (once) My daughter who just completed 1 year on September 1, 2010 has so far visited three countries: Singapore, Malaysia and Sri Lanka,... - [SQLAuthority News - Community Service and Public Speaking Engagements](https://blog.sqlauthority.com/2010/12/31/sqlauthority-news-community-service-and-public-speaking-engagements/): Today is the last day of the year and I was going over my memories for year 2010. Almost all of them are good and I feel for sure better person in terms of knowledge, nature and overall human being. Looking back at the year, it is very satisfying as I was able to go out in public and help community out at various capacity. Thought, most of the time my contribution was as speaker, many times, I have reached out and helped organized event and worked at any capacity to get the event out. I have taken parts in many... - [SQL SERVER - Detect Virtual Log Files (VLF) in LDF](https://blog.sqlauthority.com/2010/12/30/sql-server-detect-virtual-log-files-vlf-in-ldf/): In one of the recent training engagements, I was asked if it true that there are multiple small log files in the large log file (LDF). I found this question very interesting as the answer is yes. Multiple small Virtual Log Files commonly known as VLFs together make an LDF file. The writing of the VLF is sequential and resulting in the writing of the LDF file is sequential as well. This leads to another talk that one does not need more than one log file in most cases. However, in short, you can use following DBCC command to know how many... - [SQLAuthority News - My Evaluation of Singapore SharePoint Conference ](https://blog.sqlauthority.com/2010/12/29/sqlauthority-news-my-evaluation-of-singapore-sharepoint-conference/): Earlier this year, I presented at SQLAuthority News – Presenting at South East Asia SharePoint Conference – Oct 26, 27, 2010 – Singapore. It was an unforgettable experience to present at Singapore SharePoint Conference as I was the only SQL Speaker at the event. The event was filled with SharePoint enthusiasts and many other experts from all around the globe. The event was indeed one of the best organized events I have attended in subcontinent. I just received my feedback score of the event. I was very much surprised and stunned and at the same time humbled. My rating are very high and also my... - [SQL SERVER - Plan Cache and Data Cache in Memory](https://blog.sqlauthority.com/2010/12/28/sql-server-plan-cache-and-data-cache-in-memory/): I get following question almost all the time when I go for consultations or training. I often end up providing the scripts to my clients and attendees. Instead of writing new blog post, today in this single blog post, I am going to cover both the script and going to link to original blog posts where I have mentioned about this blog post. Plan Cache in Memory USE AdventureWorks GO SELECT [text], cp.size_in_bytes, plan_handle FROM sys.dm_exec_cached_plans AS cp CROSS APPLY sys.dm_exec_sql_text(plan_handle) WHERE cp.cacheobjtype = N'Compiled Plan' ORDER BY cp.size_in_bytes DESC GO Further explanation of this script is over here: SQL SERVER... - [SQL SERVER - ORDER BY ColumnName vs ORDER BY ColumnNumber](https://blog.sqlauthority.com/2010/12/27/sql-server-order-by-columnname-vs-order-by-columnnumber/): I strongly favor ORDER BY ColumnName. I read one of the blog post where blogger compared the performance of the two SELECT statement and come to conclusion that ColumnNumber has no harm to use it. Let us understand the point made by first that there is no performance difference. Run following two scripts together: USE AdventureWorks GO -- ColumnName (Recommended) SELECT * FROM HumanResources.Department ORDER BY GroupName, Name GO -- ColumnNumber (Strongly Not Recommended) SELECT * FROM HumanResources.Department ORDER BY 3,2 GO If you look at the result and see the execution plan you will see that both of the query... - [SQL SERVER - Server Side Paging in SQL Server Denali - Part2](https://blog.sqlauthority.com/2010/12/26/sql-server-server-side-paging-in-sql-server-2011-part2/): The best part of the having blog is that SQL Community helps to keep it running with new ideas. Earlier I wrote about SQL SERVER – Server Side Paging in SQL Server Denali – A Better Alternative. A very popular article on that subject. I had used variables for “number of the rows” and “number of the pages”. Blog reader send me email asking in their organizations these values are stored in the table. Is there any the new syntax can read the data from the table. Absolutely YES! USE AdventureWorks2008R2 GO CREATE TABLE PagingSetting (RowsPerPage INT, PageNumber INT) INSERT INTO... - [SQLAuthority News - 18 Seconds of Fame - My PASS Experience](https://blog.sqlauthority.com/2010/12/25/sqlauthority-news-18-seconds-of-fame-my-pass-experience/): Happy Holidays to All of YOU! Life is full of little and happy surprises. I think Christmas and Santa are based on it. I just received very interesting email earlier today, I had no idea about it. Earlier this year, I had visited Seattle to attend SQLPASS – read the complete summary over here: SQLAuthority News – SQLPASS Nov 8-11, 2010-Seattle – An Alternative Look at Experience. While I was walking down, someone has stopped me and asked if they can talk to me for 15 seconds, I said yes and they had shot quick movie with mobile. The conversation was... - [SQLAuthority News - Feature Pack for Microsoft SQL Server 2005 SP4](https://blog.sqlauthority.com/2010/12/24/sqlauthority-news-feature-pack-for-microsoft-sql-server-2005-sp4/): If you are still using SQL Server 2005 – I suggest that you consider migrating to later version of the SQL Server 2008/2008 R2. Due to any reason, you wanted to continue using SQL Server 2005, I suggest that you take a look at the Feature Pack for Microsoft SQL Server 2005 SP4. There are many different tools and features available in pack, which can be very handy and can solve issues. Microsoft ADOMD.NET Microsoft Core XML Services (MSXML) 6.0 Microsoft OLEDB Provider for DB2 Microsoft SQL Server Management Pack for MOM 2005 Microsoft SQL Server 2000 PivotTable Services Microsoft SQL... - [SQL SERVER - Index Created on View not Used Often - Observation of the View - Part 2](https://blog.sqlauthority.com/2010/12/23/sql-server-index-created-on-view-not-used-often-observation-of-the-view-part-2/): Earlier, I have written an article about SQL SERVER – Index Created on View not Used Often – Observation of the View. I received an email from one of the readers, asking if there would no problems when we create the Index on the base table. Well, we need to discuss this situation in two different cases. Before proceeding to the discussion, I strongly suggest you read my earlier articles. To avoid the duplication, I am not going to repeat the code and explanation over here. In all the earlier cases, I have explained in detail how Index created on the... - [SQL SERVER - Public Training and Private Training - Differences and Similarities - Public Training vs Private Training](https://blog.sqlauthority.com/2010/12/22/sql-server-public-training-and-private-training-differences-and-similarities/): Earlier this year, I was on Road SQL Server Seminars. I did many SQL Server Performance Trainings and SQL Server Performance Consultations throughout the year but I feel the most rewarding exercise is always the one when instructor learns something from students, too. I was just talking to my wife, Nupur – she manages my logistics and administration related activities – and she pointed out that this year I have done 62% consultations and 38% trainings. I was bit surprised as I thought the numbers would be reversed. Every time I review the year, I think of training done at organizations. Well, I... - [SQL SERVER - Index Created on View not Used Often - Observation of the View](https://blog.sqlauthority.com/2010/12/21/sql-server-index-created-on-view-not-used-often-observation-of-the-view/): I always enjoy writing about concepts on Views. Views are frequently used concepts, and so it’s not surprising that I have seen so many misconceptions about this subject. To clear such misconceptions, I have previously written the article SQL SERVER – The Limitations of the Views – Eleven and more…. I also wrote a follow up article wherein I demonstrated that without even creating index on the basic table, the query on the View will not use the View. You can read about this demonstration over here: SQL SERVER – Index Created on View not Used Often – Limitation of the... - [SQL SERVER - Securing TRUNCATE Permissions in SQL Server](https://blog.sqlauthority.com/2010/12/20/sql-server-securing-truncate-permissions-in-sql-server/): Download the Script of this article from here. On December 11, 2010, Vinod Kumar, a Databases & BI technology evangelist from Microsoft Corporation, graced Ahmedabad by spending some time with the Community during the Community Tech Days (CTD) event. As he was running through a few demos, Vinod asked the audience one of the most fundamental and common interview questions – “What is the difference between a DELETE and TRUNCATE?“ Ahmedabad SQL Server User Group Expert Nakul Vachhrajani has come up with excellent solutions of the same. I must congratulate Nakul for this excellent solution and as a encouragement to User... - [SQLAuthority News - Microsoft SQL Server 2005 Service Pack 4 RTM](https://blog.sqlauthority.com/2010/12/19/sqlauthority-news-microsoft-sql-server-2005-service-pack-4-rtm/): Service Pack 4 (SP4) for Microsoft SQL Server 2005 is now available for download. SQL Server 2005 service packs are cumulative, and this service pack upgrades all service levels of SQL Server 2005 with SP4. Download Microsoft SQL Server 2005 Service Pack 4 RTM - [SQLAuthority News - Final Service Pack of SQL Server 2008 R2](https://blog.sqlauthority.com/2010/12/19/sqlauthority-news-final-service-pack-of-sql-server-2008-r2/): In this blog post, we will see the list of the final service pack of SQL Server 2008 and SQL Server 2008 R2. Comprehensive Database Performance Health Check - [SQL SERVER - Index Created on View not Used Often - Limitation of the View 12](https://blog.sqlauthority.com/2010/12/18/sql-server-index-created-on-view-not-used-often-limitation-of-the-view-12/): I have previously written on the subject SQL SERVER – The Limitations of the Views – Eleven and more…. This was indeed a very popular series and I had received lots of feedback on that topic. Today we are going to discuss something very interesting as well. Let us learn about the issue of index created on view on used often. - [SQLAuthority News - A Successful Community Tech Days in Ahmedabad - December 11, 2010](https://blog.sqlauthority.com/2010/12/17/sqlauthority-news-a-successful-community-techdays-at-ahmedabad-december-11-2010/): We recently had one of the best community events in Ahmedabad. We were fortunate that we had SQL Experts from around the world to have presented at this event. This gathering was very special because besides Jacob Sebastian and myself, we had two other speakers traveling all the way from Florida (Rushabh Mehta) and Bangalore (Vinod Kumar).There were a total of nearly 170 attendees and the event was a blast. Here are the details of the Tech Days event. - [SQL SERVER - Server Side Paging in SQL Server 2012 Performance Comparison](https://blog.sqlauthority.com/2010/12/16/sql-server-server-side-paging-in-sql-server-2011-performance-comparison/): Earlier, I have written about SQL SERVER – Server Side Paging in SQL Server 2012 – A Better Alternative. I got many emails asking for performance analysis of paging. Here is the quick analysis of it. The real challenge of paging is all the unnecessary IO reads from the database. Network traffic was one of the reasons why paging has become a very expensive operation. I have seen many legacy applications where a complete resultset is brought back to the application and paging has been done. As what you have read earlier, SQL Server 2011 offers a better alternative to an... - [SQL SERVER - Server Side Paging in SQL Server 2012 - A Better Alternative](https://blog.sqlauthority.com/2010/12/15/sql-server-server-side-paging-in-sql-server-2011-a-better-alternative/): Ranking has improvement considerably from SQL Server 2000 to SQL Server 2005/2008 to SQL Server 2012. Here is the blog article where I wrote about SQL Server 2005/2008 paging method SQL SERVER – 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) – CTE vs. Derived Table. One can achieve this using OVER clause and ROW_NUMBER() function. Now SQL Server 2011 has come up with the new Syntax for paging. Here is how one can easily achieve it. USE AdventureWorks2008R2 GO DECLARE @RowsPerPage INT = 10, @PageNumber INT = 5 SELECT * FROM Sales.SalesOrderDetail ORDER BY SalesOrderDetailID OFFSET @PageNumber*@RowsPerPage ROWS FETCH... - [SQL SERVER - What the Business Says Is Not What the Business Wants](https://blog.sqlauthority.com/2010/12/14/sql-server-what-the-business-says-is-not-what-the-business-wants/): Let us discuss about What the Business Says Is Not What the Business Wants. Steve raised a very interesting question. - [SQLAuthority News - USB Drive Fails to Copy Large File](https://blog.sqlauthority.com/2009/08/14/sqlauthority-news-usb-drive-fails-to-copy-large-file/): I am currently traveling on a month-long training assignment for Business Intelligence. For demonstration purposes, I use Virtual PC files and hands-on lab examples for attendees of the training. The size of my VPC file is about 15 GB. Initially, I copy this file to a USB Drive and then move it to other computers, as needed. Recently, while trying to copy my VPC file to my USB drive I received the following error: Error Copying File or Folder. Cannot Copy. There is not enough free disk space. I had never experienced this problem before. I tried copying it a few... - [SQL SERVER - Reason for SQL Server Agent Starting Before SQL Server Engine Service](https://blog.sqlauthority.com/2009/08/13/sql-server-reason-for-sql-server-agent-starting-before-sql-server-engine-service/): Nakul, a dedicated member of the Gandhinagar SQL Server User Group, recently emailed me with a very interesting, but quick question. He asked me why the SQL Server Agent starts before SQL Server Engine does? He made the very valid point that as the SQL Server Engine is the core service, it should start first, and there is little point to running the SQL Server Agent without it. Off the top of my head, I can offer the following quick reasons for this sequence: The SQL Server Engine does not only run jobs for SQL Server Engine itself. It also runs... - [SQL SERVER - Backup master Database Interval - master Database Best Practices](https://blog.sqlauthority.com/2009/08/12/sql-server-backup-master-database-interval-master-database-best-practices/): During a recent consultancy project, I was asked to review a Database Backup plan. While going through the plan, I noticed that there was no backup for the master database. When I questioned this, the DBA informed me that it was not necessary. I was startled and couldn’t resist explaining to him that the master database contains all the logon accounts details, as well as all the system-level database configuration. He was a little astounded and asked me to tell him at what intervals he should backup the master database. The discussion that followed was very thought provoking and I would... - [SQL SERVER - Discussion - Effect of Missing Identity on System - Real World Scenario](https://blog.sqlauthority.com/2009/08/11/sql-server-discussion-effect-of-missing-identity-on-system-real-world-scenario/): About a week ago, SQL Server Expert, Imran Mohammed, provided a script, which will list all the missing identity values of a table in a database. In this post, I asked my readers if any could write a similar or better script. The results were interesting. While no one provided a new script, my question sparked a very active discussion that is still ongoing. When providing the script, Imran asked me if I knew of any specific circumstances in which this kind of query could be useful, as he could not think of an instance where it would be necessary to... - [SQLAuthority News - A Quick Guide to Twitter](https://blog.sqlauthority.com/2009/08/10/sqlauthority-news-a-quick-guide-to-twitter/): I am a very big fan of Twitter. I have been using it for quite sometime now and I think it is a very convenient way to stay connected with friends, families, and even the world. You can share or connect with them in real-time and tell them what you are doing currently. The best part about it is micro-blogging; you are not required to type a whole blog but just a statement of not more than 140 characters. Another advantage is that if you want to put a link then Twitter truncates the url to a tinyurl.com link, thus you... - [SQLAuthority News - Interview with SQL Server MVP Glenn Berry](https://blog.sqlauthority.com/2009/08/09/sqlauthority-news-interview-with-sql-server-mvp-glenn-berry/): Glenn Berry works as a Database Architect at NewsGator Technologies in Denver, CO. He is a SQL Server MVP, and has a whole collection of Microsoft certifications, including MCITP, MCDBA, MCSE, MCSD, MCAD, and MCTS. He is also an Adjunct Faculty member at University College – University of Denver, where he has been teaching since 2000. He is one wonderful blogger and often blogs at here. 1) Please tell us something about yourself. I have been working as a Database Architect at NewsGator Technologies for about 3.5 years. Before that, I worked as a Performance Architect at a company called Mortgage... - [SQL Server - Multiple CTE in One SELECT Statement Query](https://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/): I have previously written many articles on CTE. One question I get often is how to use multiple CTE in one query or multiple CTE in SELECT statement. Let us see quickly two examples for the same. I had done my best to take simplest examples in this subject. Option 1 : /* Method 1 */ ;WITH CTE1 AS (SELECT 1 AS Col1), CTE2 AS (SELECT 2 AS Col2) SELECT CTE1.Col1,CTE2.Col2 FROM CTE1 CROSS JOIN CTE2 GO Option 2: /* Method 2 */ ;WITH CTE1 AS (SELECT 1 AS Col1), CTE2 AS (SELECT COL1+1 AS Col2 FROM CTE1) SELECT CTE1.Col1,CTE2.Col2 FROM CTE1 CROSS JOIN CTE2 GO Please... - [SQLAuthority News - Humorous SQL Cake - Funny SQL Cake](https://blog.sqlauthority.com/2009/08/07/sqlauthority-news-humorous-sql-cake-funny-sql-cake/): I  received the following interesting images in email during the past 2 months. I think they are superbly hilarious! I received them from various people at different times, so their is unknown. Let me know which of the following images you find the most interesting. Hope you enjoyed watching them! Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Get Time in Hour:Minute Format from a Datetime - Get Date Part Only from Datetime](https://blog.sqlauthority.com/2009/08/06/sql-server-get-time-in-hourminute-format-from-a-datetime-get-date-part-only-from-datetime/): I have seen scores of expert developers getting perplexed with SQL Server in finding time only from datetime datatype. Let us have a quick glance look at the solution. Let us learn about how to get Time in Hour:Minute Format from a Datetime as well as to get Date Part Only from Datetime. - [SQL SERVER - Get a List of Fixed Hard Drive and Free Space on Server](https://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/): When I am not blogging, I am typically working on SQL Server Optimization projects. Time and again, I only have access to SQL Server Management Studio that I can remotely connect to server but do not have access to Operating System, and it works just fine. At one point in optimization project, I have to decide on index filegroup placement as well TempDB files (.ldf and .mdf) placement. It is commonly known that system gives enhanced performance when index and tempdb are on separate drives than where the main database is placed. As I do not have access to OS I... - [SQL SERVER - Forgot the Password of Username SA](https://blog.sqlauthority.com/2009/08/04/sql-server-forgot-the-password-of-username-sa/): I just received a call from an old friend with whom I used to work in Las Vegas. He told me about a password-related issue he faced in his organization. They had changed the password of username SA and now they are not able to recall the new password. I am sure that he is not the first person who has faced this issue. There may be many more similar situations where employees who have sysamin password leaves the job or a hacker disables the SA account. Resetting the password of SA is a breeze! Option 1 : If there is... - [SQLAuthority News - Author Visit - Virtual Tech Days August 2009](https://blog.sqlauthority.com/2009/08/04/sqlauthority-news-author-visit-virtual-tech-days-august-2009/): Microsoft India has organized a premier online technical event Microsoft Virtual TechDays between August 19-21, 2009. I had presented two technical sessions and they were greatly received by audience. I had received 50+ request for providing PPT for all the attendees. It was great FREE event and I suggest that everybody should have attended the event. While I was at Bangalore, I had great time meeting fellow experts and top evangelist from Microsoft. Presenting online event is totally different experience than presenting in front of real people in User Groups. In user group meeting  it is very easy to get feedback... - [SQL SERVER - Introduction to SQL Server 2008 Profiler - Complete](https://blog.sqlauthority.com/2009/08/03/sql-server-introduction-sql-server-2008-profiler-complete/): Introduction SQL Server Profiler is a powerful tool that is available with SQL Server since a long time; however, it has mostly been underutilized by DBAs. SQL Server Profiler can perform various significant functions such as tracing what is running under the SQL Server Engine’s hood, and finding out how queries are resolved internally and what scripts are running to accomplish any T-SQL command. The major functions this tool can perform have been listed below: Creating trace Watching trace Storing trace Replaying trace Trace includes all the T-SQL scripts that run simultaneously on SQL Server. As trace contains all the T-SQL... - [SQLAuthority News - Proposed eGov Standards Policy - Benefit for All or Only A Chosen Few](https://blog.sqlauthority.com/2009/08/02/sqlauthority-news-proposed-egov-standards-policy-benefit-for-all-or-only-a-chosen-few/): Does the proposed eGov Standards Policy benefit all or only a chosen few? As a wider audience comes to accept new technology, so the technology itself grows. The recent debate in India on the eGov Standards policy has been a point of contention for some time. I would like to start our discussion on this topic by posing two questions: Question 1: Should government mandate single standards for a given technology domain? The obvious answer would appear to be “Yes”, but the considered answer is actually “No”. The stipulation of a “single standard” would unnecessarily restrict the technology choices for the... - [SQLAuthority News - Download Microsoft SQL Server Management Pack for Operations Manager 2007](https://blog.sqlauthority.com/2009/08/01/sqlauthority-news-download-microsoft-sql-server-management-pack-for-operations-manager-2007-4/): Note : Download Microsoft SQL Server Management Pack for Operations Manager 2007 by Microsoft The SQL Server Management Pack provides the capabilities for Operations Manager 2007 to discover SQL Server 2000, 2005 and 2008 installations and components and to monitor them, primarily from the perspective of availability and performance. The availability and performance monitoring is done using a combination of scripts and native Operations Manager capabilities. The following list gives an overview of the features of the SQL Server management pack. Support for Enterprise, Standard and Express editions of SQL Server 2000, 2005 and 2008 and 32bit, 64bit and ia64 architectures.... - [SQL SERVER - Introduction to Cloud Computing](https://blog.sqlauthority.com/2009/07/31/sql-server-introduction-to-cloud-computing/): Introduction “Cloud Computing,” to put it simply, means “Internet Computing.” The Internet is commonly visualized as clouds; hence the term “cloud computing” for computation done through the Internet. With Cloud Computing users can access database resources via the Internet from anywhere, for as long as they need, without worrying about any maintenance or management of actual resources. Besides, databases in cloud are very dynamic and scalable. Cloud computing is unlike grid computing, utility computing, or autonomic computing. In fact, it is a very independent platform in terms of computing. The best example of cloud computing is Google Apps where any application... - [SQLAuthority News - Author's Birthday - Top 7 Commenters - Volunteers](https://blog.sqlauthority.com/2009/07/30/sqlauthority-news-authors-birthday-top-7-commenters-volunteers/): Today is July 30 and I am very happy; it’s my Birthday, celebration time!!! The most common question I receive on my every birthday is -what are my plans for birthday. Let me share my plans here today. Additionally, if you are interested to know when SQL Server was born read my post SQLAuthority News – Author BirthDay – SQL Server Birthday. My first plan is that I am going to take a break from blogging on anything technical today and spend more time with my family. Let me tell you about my second plan. I am very much pleased and... - [SQL SERVER - 2008 - Copy Database With Data - Generate T-SQL For Inserting Data From One Table to Another Table](https://blog.sqlauthority.com/2009/07/29/sql-server-2008-copy-database-with-data-generate-t-sql-for-inserting-data-from-one-table-to-another-table/): Just about a year ago, I had written on the subject of how to insert data from one table to another table without generating any script or using wizard in my article SQL SERVER – Insert Data From One Table to Another Table – INSERT INTO SELECT – SELECT INTO TABLE. Today, we will go over a similar question regarding how to generate script for data from database as well as table. SQL Server 2008 has simplified everything. Let us take a look at an example where we will generate script database. In our example, we will just take one table... - [SQL SERVER - 2008 - Design Process Decision Flow](https://blog.sqlauthority.com/2009/07/28/sql-server-2008-design-process-decision-flow/): I was recently invited by a company that is primarily using other RDBMS as their primary database for solutions. It was a different experience for me, as I am used to having pretty good SQL Server Smart crowd in my presentations, but this time there were smart people but no SQL Server experts in front of me. I was asked to elucidate the basics of SQL Server as well as how it works. Now, this was nothing short of a challenge for me; I had never done this kind of high level presentation. I used presentation from Infrastructure Planning and Design... - [SQL SERVER - List All Missing Identity Values of Table in Database](https://blog.sqlauthority.com/2009/07/27/sql-server-list-all-missing-identity-values-of-table-in-database/): The best part of any blog is when readers ask each other questions. Better still, is when a reader takes the time to provide a detailed response. A few days ago, one of my readers, Yasmin, asked a very interesting question: How we can find the list of tables whose identity was missed (not is sequential order) within the entire database? A big thank you to SQL Server Expert, Imran Mohammed, for his excellent response to this question. He also provided an extremely impressive script, which is well described and contains inline comments. We will now see the same example with... - [SQLAuthority News - Search SQL Server Solutions](https://blog.sqlauthority.com/2009/07/26/sqlauthority-news-search-sql-server-solutions/): So far, I have written over 1030 articles on my blog, and I have  received  an astounding  12,000+ comments. Undoubtedly, it has acquired the status of a  huge database now! I nearly receive 200+ emails  and lots of comments on this blog every day. I do maintain a log of all the comments and emails received. As per my observation, I have already answered 90% of the questions asked via email in this blog earlier. I do my best to respond to each email and comment of my readers. Quite often, the question asked in email is very urgent and  by... - [SQLAuthority News - Download - Cumulative Update Package for SQL Server 2008](https://blog.sqlauthority.com/2009/07/25/sqlauthority-news-download-cumulative-update-package-for-sql-server-2008/): SQL Server 2008 has been out for over two years and now a very significant Cumulative Update has been released. If you are using SQL Server 2008 then you must certainly install it to fix the various bugs. Cumulative Update 3 for SP1: http://support.microsoft.com/kb/971491 Cumulative Update 6 for RTM: I heavily recommend this update. Feel free to talk to me if you want more information on it. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Maximizing View of SQL Server Management Studio - Full Screen - New Screen](https://blog.sqlauthority.com/2009/07/24/sql-server-maximizing-view-of-sql-server-management-studio-full-screen-new-screen/): I had a great, unforgettable time at Teched India 2009 in Hyderabad. I had delivered a successful session on SQL Server Management Studio Best Practices, which created a lot of interest in community. I was truly amazed at the tremendous response I got. I received countless different questions on this subject as soon as the event was over. One of the most frequently asked questions was about my demo on how to increase real estate of SSMS (SQL Server Management Studio). I had explained the following two different methods: 1) Open Results in Separate Tab This is a very interesting method... - [SQL SERVER - Puzzle - Write Script to Generate Primary Key and Foreign Key](https://blog.sqlauthority.com/2009/07/23/sql-server-puzzle-write-script-to-generate-primary-key-and-foreign-key/): In one of my recent projects, a large database migration project, I confronted a peculiar situation. SQL Server tables were already moved from Database_Old to Database_New. However, all the Primary Key and Foreign Keys were yet to be moved from the old server to the new server. Please note that this puzzle is to be solved for SQL Server 2005 or SQL Server 2008. As noted by Kuldip it is possible to do this in SQL Server 2000. In SQL Server Management Studio (SSMS), there is no option to script all the keys. If one is required to script keys they... - [SQLAuthority News - SQL Server Value Calculator](https://blog.sqlauthority.com/2009/07/22/sqlauthority-news-sql-server-value-calculator/): I have been using twitter for quite some time now (follow me at @pinaldave). In twitter world very often I find something interesting shared by my friends there. SQL Server Expert and Microsoft Evanglist Vinod Kumar has twitted very interesting detail linking to SQL Server Value Calculator. The web version of this tool is created in Silver Light and looks very cool and gives impression of PC Game Sims at first moment. This tool calculates Total Estimate Saving if SQL Server is used in any organization. It takes into consideration Total IT team members, Bandwidth, Servers, Security, Reports, Audits, Supports Calls... - [SQLAuthority News - SQL Azure - Microsoft SQL Data Services - Introduction and Pricing](https://blog.sqlauthority.com/2009/07/21/sqlauthority-news-sql-azure-microsoft-sql-data-services-introduction-and-pricing/): Microsoft has updated the branding for SQL Services and SQL Data Services. SQL Services will be called Microsoft SQL Azure, and SQL Data Services will be Microsoft SQL Azure Database. Changing the name does not change product but it demonstrates tight integration between the components of the service platforms. As a part of the Windows Azure platform, SQL Azure Database will deliver traditional relational database service in the cloud, supporting T-SQL over Tabular Data Stream (TDS) protocol. SQL Azure Database will be available in two editions: the Web Edition Database and the Business Edition Database. Web Edition – 2GB of T-SQL... - [SQLAuthority News - Authors Visit - DelhiBuzz TechEd on July 11, 2009](https://blog.sqlauthority.com/2009/07/20/sqlauthority-news-authors-visit-delhibuzz-teched-on-july-11-2009/): SQLBuzzDelhi organized TechEd Delhi on July 11, 2009. They even launched an official PASS Chapter in Delhi. The complete report of this event is here. This event like TechEd in Ahmedabad,  was a huge success and saw a huge number of attendees from all over India. Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. The event saw many wonderful speakers.I really appreciate the facility at DelhiBuzz and the amazing crowd brimming with enthusiasm. I really want to thank two people in particular for making the SQL PASS Delhi a grand success... - [SQL SERVER - Get Last Running Query Based on SPID](https://blog.sqlauthority.com/2009/07/19/sql-server-get-last-running-query-based-on-spid/): We often need to find the last running query or based on SPID need to know which query was executed. SPID is returns sessions ID of the current user process. The acronym SPID comes from the name of its earlier version, Server Process ID. To know which sessions are running currently, run the following command: SELECT @@SPID GO In our case, we got SPID 57, which means the session that is running this command has ID of 57. Now, let us open another session and run the same command. Here we get different IDs for different sessions. In our case, we... - [SQLAuthority News - Whitepaper - Using the Resource Governor](https://blog.sqlauthority.com/2009/07/18/sqlauthority-news-whitepaper-using-the-resource-governor/): Using the Resource Governor SQL Server Technical Article Writer: Aaron Bertrand, Boris Baryshnikov Technical Reviewers: Louis Davidson, Mark Pohto, Jay (In-Jerng) Choe Published: June 2009 SQL Server 2008 introduces a new feature, the Resource Governor, which provides enterprise customers the ability to both monitor and control the way different workloads use CPU and memory resources on their SQL Server instances. This paper explains several practical usage scenarios and gives guidance on best practices. The Resource Governor is a new feature in the Microsoft SQL Server 2008 Enterprise. It provides very powerful and flexible controls to dictate and monitor how a SQL... - [SQL SERVER - Two Methods to Retrieve List of Primary Keys and Foreign Keys of Database](https://blog.sqlauthority.com/2009/07/17/sql-server-two-methods-to-retrieve-list-of-primary-keys-and-foreign-keys-of-database/): There are two different methods to retrieve the list of Primary Keys and Foreign Keys from the database. - [SQL SERVER - Four Different Ways to Find Recovery Model for Database](https://blog.sqlauthority.com/2009/07/16/sql-server-four-different-ways-to-find-recovery-model-for-database/): Perhaps, the best thing about technical domain is that most of the things can be executed in more than one ways. It is always useful to know about the various methods of performing a single task. Today, we will observe four different ways to find out recovery model for any database. Method 1 Right Click on Database >> Go to Properties >> Go to Option. On the Right side you can find recovery model. Method 2 Click on the Database Node in Object Explorer. In Object Explorer Details, you can see the column Recovery Model. Method 3 This is a very... - [SQL SERVER - Restore Sequence and Understanding NORECOVERY and RECOVERY](https://blog.sqlauthority.com/2009/07/15/sql-server-restore-sequence-and-understanding-norecovery-and-recovery/): I maintain a spreadsheet of questions sent by users and from that I single out a topic to write and share my knowledge and opinion. Unless and until I find an issue appealing, I do not prefer to write about it, till the issue crosses the threshold. Today the question that crossed the threshold is - what is the difference between NORECOVERY and RECOVERY when restoring database and what is the restore sequence. - [SQL SERVER - Backup Timeline and Understanding of Database Restore Process in Full Recovery Model](https://blog.sqlauthority.com/2009/07/14/sql-server-backup-timeline-and-understanding-of-database-restore-process-in-full-recovery-model/): I assume you all know that there are three types of Database Backup Models, so we will not discuss on this commonly known topic today. In fact, we will just talk about how to restore database that is in full recovery model. Let us learn about backup timeline. - [SQL SERVER - BLOB - Pointer to Image, Image in Database, FILESTREAM Storage](https://blog.sqlauthority.com/2009/07/13/sql-server-blob-pointer-to-image-image-in-database-filestream-storage/): When it comes to storing images in database there are two common methods. I had previously blogged about the same subject on my visit to Toronto. With SQL Server 2008, we have a new method of FILESTREAM storage. However, the answer on when to use FILESTREAM and when to use other methods is still vague in community. Let us look into two traditional methods first along with their advantage and disadvantages. Method 1) Store image in filesystem and store pointer in database This is quite an old method and you can find this implemented in many places, even though SQL Server... - [SQLAuthority News - Big Thinkers - Robert Cain](https://blog.sqlauthority.com/2009/07/12/sqlauthority-news-big-thinkers-robert-cain/): I am exceedingly impressed and inspired by an on-going series of Big Thinkers by Robert Cain – A SQL Server MVP and a genial, whole-souled person. On meeting Robert Cain earlier this year at SQL Server MVP Summit in Seattle I asked him a question – Where do you get so many innovative ideas to write on blog and create presentations? He replied, “I do not try to get ideas, my experience inspires me.” Well, it is true that Robert has more than 10 years of experience as one of the TOP experts in SQL Server. Unlike most of the SQL... - [SQL SERVER - Standby Servers and Types of Standby Servers](https://blog.sqlauthority.com/2009/07/11/sql-server-standby-servers-and-types-of-standby-servers/): Standby servers – Standby Server is a type of server that can be brought online in a situation when Primary Server goes offline and application needs continuous (high) availability of the server. There is always a need to set up a mechanism where data and objects from primary server are moved to secondary (standby) server. This mechanism usually involves the process of moving backup from the primary server to the secondary server using T-SQL scripts. Often, database wizards are used to set up this process. We will now glance at the various types of standby servers. Hot Standby – Hot Standby... - [SQLAuthority News - Request SQLAuthority.com Stickers and SQL Server Cheat Sheet](https://blog.sqlauthority.com/2009/07/10/sqlauthority-news-request-sqlauthority-com-stickers-and-sql-server-cheat-sheet/): I have been overwhelmed with the request for SQL Server Cheat Sheet recently. I absolutely think it is tremendously useful; its hand written form is adorning my wall since a long time. Having realized its usefulness I got it done professionally and distributed it at TechEd in Hyderabad, TechEd in Ahmedabad, and TechEd on Road in Trivendrum. Now, they are very much in demand. - [SQLAuthority News - Authors Visit - K-MUG TechEd Trivandrum on June 27, 2009](https://blog.sqlauthority.com/2009/07/09/sqlauthority-news-authors-visit-k-mug-teched-trivandrum-on-june-27-2009-2/): K-MUG organized TechEd Trivandrum on 27th June, 2009. They even launched an official PASS Chapter in Trivandrum. The complete report of this event is here. This event like TechEd in Ahmedabad,  was a huge success and saw a huge number of attendees from all over India. Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. The event saw many wonderful speakers.I really appreciate the state-of-the-art facility at K-Mug and the amazing crowd brimming with enthusiasm. You can check out K-MUG event page for further information. I really want to thank two people... - [SQLAuthority News - Book Review - Murach's SQL Server 2008 for Developers](https://blog.sqlauthority.com/2009/07/08/sqlauthority-news-book-review-murachs-sql-server-2008-for-developers/): Murach’s SQL Server 2008 for Developers (Murach: Training & Reference) (Paperback) by Bryan Syverson, Joel Murach Link to Amazon Short Summary: Murach’s SQL Server 2008 for developers is an ideal book for all developers, and particularly, it is an excellent book for training and reference. If you are new to SQL, no problem! This book is the best reading material to start with. Long Summary: SQL Server has emerged as the leading database and nowadays there are a number of books available on this subject. However, it is important to select the right book to imbibe proper, thorough understanding. Murach’s SQL... - [SQLAuthority News - Authors Visit - DotNet Buzz Delhi TechEd Delhi on July 11, 2009](https://blog.sqlauthority.com/2009/07/07/sqlauthority-news-authors-visit-dotnet-buzz-delhi-teched-delhi-on-july-11-2009/): DotNet Buzz Delhi is organizing TechEd Delhi on July 11, 2009. Not just this, they are launching an official PASS Chapter in Delhi. The Agenda of the event is here and if you are around Delhi do not miss the opportunity to be a part of this upcoming great event. If you are keen to know what this event holds in store for you then read about TechEd in Ahmedabad, which saw a huge number of attendees and was a grand success.  Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. I... - [SQL SERVER - Languages for BI - MDX, DMX, XMLA](https://blog.sqlauthority.com/2009/07/06/sql-server-languages-for-bi-mdx-dmx-xmla/): Today, we have a very basic thing to go over. Few days back, I was discussing with one of my friends regarding BI. He told me that he knows that BI stands for Business Intelligence but he would like to know what languages BI uses to achieve the goal. The reason I found this question very interesting was because I was asked the same question two weeks back at TechEd on Road Ahmedabad. I had promised one of the attendees that I will reply to his question soon. This question, which my friend asked recently, reminded me of the same. Let us go over the languages of BI very quickly. Again, these are just definitions and there is much more to learn. Moreover, to master each language it may take years. - [SQLAuthority News - FIX : Error : HP OfficeJet Scanning and Printing Gray or Pink Shades](https://blog.sqlauthority.com/2009/07/05/sqlauthority-news-fix-error-hp-officejet-scanning-and-printing-gray-or-pink-shades/): Unlike my usual articles today’s article is not at all related to SQL Server but something drove me to include it on my blog. This issue snatched away my precious few hours. It took me over 2 hours to resolve it yesterday, which barred me from doing research on SQL Server. I am sure many people must have faced this issue and the sad part is no solution has been proposed so far. Let us understand the problem first. I got a brand new printer HP Officejet J4580 All-in-One printer. Support Engineer came along to install it. Fax, Printing, Photocopy –... - [SQL SERVER - Disk Partition Alignment Best Practices](https://blog.sqlauthority.com/2009/07/04/sql-server-disk-partition-alignment-best-practices/): Note :  Download Disk Partition Alignment Best Practices for SQL Serverby Microsoft Disk partition alignment is a powerful tool for improving SQL Server performance. Configuring optimal disk performance is often viewed as much art as science. A best practice that is essential yet often overlooked is disk partition alignment. Windows Server 2008 attempts to align new partitions out-of-the-box, yet disk partition alignment remains a relevant technology for partitions created on prior versions of Windows. This paper documents performance for aligned and nonaligned storage and why nonaligned partitions can negatively impact I/O performance; it explains disk partition alignment for storage configured on... - [SQLAuthority News - Book Review - The Rational Guide to Building Technical User Communities (Rational Guides)](https://blog.sqlauthority.com/2009/07/03/sqlauthority-news-book-review-the-rational-guide-to-building-technical-user-communities-rational-guides/): The Rational Guide to Building Technical User Communities (Rational Guides) (Paperback) by Greg Low Short Review : A Great, one-of-its-kind book for everybody who is interested in building technical user community. There is no other book written on this subject but after this comprehensive book no further reading will be required. Link to Amazon Detailed Review : This is for the first time in my book review, instead of talking about the book or author, I will introduce myself in a couple of lines to explain why and how this book is helpful to those interested in building community. I am... - [SQLAuthority News - MVP Award Renewed](https://blog.sqlauthority.com/2009/07/02/sqlauthority-news-mvp-award-renewed/): Year ago, it was a great, perhaps the proudest moment of my professional life. I was awarded Most Valuable Professional (MVP) for SQL Server by Microsoft. Today, I received an email informing me that I have been re-awarded SQL Server MVP status by Microsoft in recognition of my community contributions. It’s yet another proud moment for me. I’m very happy and excited that my hard work is being recognized.  I hope to work even harder and serve my community better! Microsoft Thank You! There’s a huge list of people I would like to thank for this award. However, instead of listing... - [SQL SERVER - Difference between Line Feed (\n) and Carriage Return (\r) - T-SQL New Line Char](https://blog.sqlauthority.com/2009/07/01/sql-server-difference-between-line-feed-n-and-carriage-return-r-t-sql-new-line-char/): Today, we will examine something very simple and very generic that can apply to hordes of programming languages. Let’s take a common question that is frequently discussed – What is difference between Line Feed (\n) and Carriage Return (\r)? Prior to continuing with this article let us first look into few synonyms for LF and CR. Line Feed – LF – \n – 0x0a – 10 (decimal) Carriage Return – CR – \r – 0x0D – 13 (decimal) Now that we have understood that we have two different options to get new line, the question that arises is – why is... - [SQL SERVER - 2008 - Policy-Based Management - Create, Evaluate and Fix Policies](https://blog.sqlauthority.com/2009/06/30/sql-server-2008-policy-based-management-create-evaluate-and-fix-policies/): This article will cover the most spectacular feature of SQL 2008 – Policy-based management and how the configuration of SQL Server with policy-based management architecture can make a powerful difference. Policy based management is loaded with several advantages. It can help you implement various policies for reliable configuration of the system. It also provides additional administration assistance to DBAs and helps them effortlessly manage various tasks of SQL Server across the enterprise. 1 Introduction 2 Basics of Policy Management 3 Policy Management Terms 4 Practical Example of Policy Management 4.1 Exploring of Facets 4.2 Create a Condition 4.3 Create a Policy... - [SQL SERVER - Maximum Number of Index per Table](https://blog.sqlauthority.com/2009/06/29/sql-server-maximum-number-of-index-per-table/): TechEd on Road Ahmedabad, June 20, 2009, was a huge success. This grand event saw over 200 attendees actively participating in the sessions. We had attendees traveling from far and wide, including Delhi, Mumbai, Jaipur, Kerala, Baroda, Himmatnagar, Rajkot, among other cities from India. This enthusiastic participation made the event truly grand. It was a moment of bliss for me as I had not anticipated such tremendous positive response! Although the Official time to commence the event was at 1:45 PM we were really excited to see the attendees entering the hall before the official time. We were more than happy... - [SQL SERVER - SQL Server Management Studio New Features](https://blog.sqlauthority.com/2009/06/28/sql-server-2008-management-studio-new-features-2/): This article describes the top 5 features of SQL Server Management Studio 2008. With the release of SQL Server 2008 Microsoft has upgraded SSMS with many new features as well as added tons of new functionalities requested by DBAs for long time. - [SQL SERVER - Fix : Error : 17892 Logon failed for login due to trigger execution. Changed database context to 'master'.](https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context-to-master/): I had previously written two articles about an intriguing observation of triggers online. SQL SERVER – Interesting Observation of Logon Trigger On All Servers SQL SERVER – Interesting Observation of Logon Trigger On All Servers – Solution If you are wondering what made me write yet another article on logon trigger then let me tell you the story behind it. One of my readers encountered a situation where he dropped the database created in the above two articles and he was unable to logon to the system after that. Let us recreate the scenario first and attempt to solve the problem.... - [SQL SERVER - Interesting Observation of Logon Trigger On All Servers - Solution](https://blog.sqlauthority.com/2009/06/26/sql-server-interesting-observation-of-logon-trigger-on-all-servers-solution/): Does the title of this post trigger your mind? If you all remember, a few days back I had written an article on my interesting observation regarding logon triggers. I would advise you to first read SQL SERVER – Interesting Observation of Logon Trigger On All Servers before continuing with this article further to have a complete idea of the subject. The question I put forth in my previous article was – In single login why the trigger fires multiple times; it should be fired only once. I received numerous answers in thread as well as in my MVP private news... - [SQLAuthority News - Authors Visit - K-MUG TechEd Trivandrum on June 27, 2009](https://blog.sqlauthority.com/2009/06/25/sqlauthority-news-authors-visit-k-mug-teched-trivandrum-on-june-27-2009/): K-MUG is organizing TechEd Trivandrum on 27th June, 2009. Not just this, they are launching an official PASS Chapter in Trivandrum. The Agenda of the event is here and if you are around Trivandrum do not miss the opportunity to be a part of this upcoming great event. If you are keen to know what this event holds in store for you then read about TechEd in Ahmedabad, which saw a huge number of attendees and was a grand success.  Jacob Sebastian and Pinal Dave had presented two solid SQL Sessions and created lots of buzz about Microsoft. Click here for... - [SQLAuthority News - Update on pinaldave.com and SQLAuthority.com](https://blog.sqlauthority.com/2009/06/24/sqlauthority-news-update-on-pinaldave-com-and-sqlauthority-com/): Problem: SQLAuthority.com site was not allowed in some browsers as pinaldave.com site was marked as malware or badware distributing third party site. Status: SQLAuthority.com and pinaldave.com both the sites are safe now and there is no threat to your computer. Feel free to click on the links. Since the last two mornings I have received over 200 emails querying about the error my sites were generating. I encountered countless questions and worst of all I was thrown verbal abuse for not getting my own site up right away and for being careless. I’m much relieved today as everything is back to... - [SQL SERVER - Delete Duplicate Rows](https://blog.sqlauthority.com/2009/06/23/sql-server-2005-2008-delete-duplicate-rows/): I had previously penned down two popular snippets regarding deleting duplicate rows and counting duplicate rows. Today, we will examine another very quick code snippet where we will delete duplicate rows using CTE and ROW_NUMBER() feature of SQL Server 2005 and SQL Server 2008. - [SQLAuthority News - TechEd on Road Ahmedabad June 20, 2009 - An Astounding Success](https://blog.sqlauthority.com/2009/06/22/sqlauthority-news-teched-on-road-ahmedabad-june-20-2009-an-astounding-success/): TechEd on Road Ahmedabad In India, TechEd was held in Hyderabad in the month of May. You can read myTechEd summary article here. A similar event will be organized in 10 major cities in India. Ahmedabad saw its first TechEd on Road and it was wholeheartedly welcomed by technology enthusiasts. The event was held at Rock regency, in the heart of Ahmedabad on June 20, 2009. We had attendees traveling over 500 miles to attend the event. We had attendees from Delhi, Mumbai, Jaipur, Kerala, Baroda, Himmatnagar, Rajkot, among other cities from India. It was a joyous and overwhelming experience for... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.1](https://blog.sqlauthority.com/2009/06/21/sqlauthority-news-risk-and-health-assessment-program-for-microsoft-sql-server-scoping-tool-v1-1/): Note :   Download Risk and Health Assessment Utility by Microsoft Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.1 is a practical download package intended exclusively for Microsoft Premier Customers. This package paraphernalia includes all the scoping tools required to prepare and qualify your environment to receive a Risk and Health Assessment Program for Microsoft SQL Server. Getting started with it is very easy. First, extract the Scoping Tool zip package to the tools server that will be used during the RAP engagement. Next, refer to Instructions.txt in the Scoping Tool folder for exhaustive instructions on executing... - [SQL Server - Understanding Table Hints with Examples](https://blog.sqlauthority.com/2009/06/20/sql-server-understanding-table-hints-with-examples-2/): Today we have a very interesting subject to look at. I tried to look for help online but have not found any other documentation besides what we have from the Book Online. Let us try to understand what are the different kinds of hints available in SQL Server and how they are helpful. What is a Hint? Hints are options and strong suggestions specified for enforcement by the SQL Server query processor on DML statements. The hints override any execution plan the query optimizer might select for a query. Before we continue to explore this subject, we need to consider one... - [SQL SERVER - Why You Should Attend PASS Summit Unite 2009- Seattle](https://blog.sqlauthority.com/2009/06/19/sql-server-why-you-should-attend-pass-summit-unite-2009-seattle/): PASS Summit Unite 2009 – the premier event for SQL Server professionals – will be held in Seattle from November 2 to November 5. It is the largest and the most intensive Microsoft SQL Server conference in the world organized by SQL Server users for SQL Server users. This year marks the 10th Anniversary of PASS Community Summit, making the event even more special. Every year, this event sees a huge number of attendees, as apart from high quality technical sessions it provides unparalleled access to the Microsoft SQL Server development, SQL CAT, and Customer Service and Support teams. PASS Summit... - [SQL SERVER - Clustered Index on Separate Drive From Table Location](https://blog.sqlauthority.com/2009/06/18/sql-server-clustered-index-on-separate-drive-from-table-location/): How to improve performance of SQL Server Queries is a common topic of discussion among many of us. Much has been said, much has been discussed. Few days back, I had an interesting discussion with one of the Junior developers regarding performance improvement of SQL Server Queries. We discussed on how by using a separate hard drive for several database objects can right away improve performance. I suggested him that non clustered index and tempdb can be created on a separate disk to improve performance. - [SQL SERVER - List Schema Name and Table Name for Database](https://blog.sqlauthority.com/2009/06/17/sql-server-list-schema-name-and-table-name-for-database/): Just a day ago, I was looking for script which generates all the tables in database along with its schema name. I tried to Search@SQLAuthority.com but got too many results. For the same reason, I am going to write down today’s quick and small blog post and I will remember that I had written I wrote it after my 1000th article. SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']' AS SchemaTable FROM sys.tables Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 1000th Article Milestone - 8 Millions Views - Solid Quality Mentors](https://blog.sqlauthority.com/2009/06/16/sqlauthority-news-1000th-article-milestone-8-millions-views-solid-quality-mentors/): Achieving a milestone gives a great sense of accomplishment! Today, I am writing my 1000th Article on this blog. I am extremely happy and gratified.  It is indeed a long journey since I started a few years back and at that time I had no idea that within a short period I would attain so much appreciation and popularity.  I intend to continue my journey further and attain more milestones. I have always enjoyed learning, sharing and helping my community. Through this blog, I have met many wonderful people, made great friends and interacted with diverse readers from across the globe.... - [SQL SERVER - Query Optimizer Hint ROBUST PLAN - Question to You](https://blog.sqlauthority.com/2009/06/15/sql-server-query-optimizer-hint-robust-plan-question-to-you/): While cleaning up my bookmarks this week, I stumbled upon a very small interesting thing. I can proudly call myself a pro at finding stuffs, but after continuously hunting online I could not gather comprehensive information about this topic. I was actually looking for a practical example for Query Optimizer Hint “ROBUST PLAN”. Before I seek help from you, let us first try to understand what query optimizer hints is and then we will move on to the concept of “ROBUST PLAN”. To put it simply, Query hints is a T-SQL clause which on running directs T-SQL query to run in... - [SQL SERVER - 2008 - SSMS Feature - Multi-server Queries](https://blog.sqlauthority.com/2009/06/14/sql-server-2008-ssms-feature-multi-server-queries/): In my recent visit to TechEd India 2009 at Hyderabad, I had taken a technical session on SQL Server Management Studio 2008 New Features, which was attended by a huge number of participants and was very successful. I got loads of requests from my readers for posting the session online. My presentation involved several videos and demos, so practically it is not possible for me to post my original session online. But as I do not want to disappoint my readers I have one solution; what I can do is that I can share some valuable tips from the session with... - [SQL SERVER - Effect of Normalization on Index and Performance](https://blog.sqlauthority.com/2009/06/13/sql-server-effect-of-normalization-on-index-and-performance/): Of late, I have been using Twitter quite frequently, and I am gradually discovering its usefulness. I received a Direct Message (or DM in terms of twitter) asking if I can comment on the effect of normalization on the Index and its performance in one twit! Now honestly speaking, this was new for me. I never expected to be quizzed like this. If you are using Twitter, then you must be aware that one twit contains only 140 characters. I was supposed to give answer on such a big subject in just 140 letters. An interesting fact is that normalization and the Index are not really closely related. The right question should have been – what is the effect of normalization on performance? - [SQL SERVER - 2008 - Customize Toolbar - Remove Debug Button from Toolbar](https://blog.sqlauthority.com/2009/06/12/sql-server-2008-customize-toolbar-remove-debug-button-from-toolbar/): In today’s article I have combined two different questions. I was fond of SQL Server Debugger feature in SQL Server 2000. To my utter disappointment, this feature was withdrawn from SQL Server 2005. However, because of loads of requests from developers it was re-introduced in SQL Server 2008. Let us learn about how to customize toolbars.  - [SQLAuthority News - Registration and Competition - TechEd on Road - Ahmedabad - June 20, 2009 Saturday](https://blog.sqlauthority.com/2009/06/11/sqlauthority-news-registration-and-competition-teched-on-road-ahmedabad-june-20-2009-saturday/): We have an upcoming grand event of TechEd on Road organized in Ahmedabad. This is a FREE event and ANYBODY who loves technology can attend it. This event will provide a precious opportunity to learn, interact and network with tech enthusiasts. I encourage you all to be a part of it and experience the joy of learning in a healthy and fun environment. - [SQL SERVER - Performance Counters from System Views - By Kevin Mckenna](https://blog.sqlauthority.com/2009/06/10/sql-server-performance-counters-from-system-views-by-kevin-mckenna/): I just love social media and all the new concepts of Web 2.0. There are bloggers who are overwhelmed by the new concepts of technology and are not able to keep pace with it. But I like taking such challenges. Twitter has acquired tremendous popularity nowadays and just like everybody else I am also fond of this latest vogue. You can follow me at Twitter here. Through twitter I am getting to meet people like me and it’s a great experience interacting with them. I met SQL and .NET expert Kevin Mckenna on twitter itself. Kevin is originally from Liverpool, England,... - [SQLAuthority News - TechEd On Road Ahmedabad, India is Announced - June 20, 2009 Saturday](https://blog.sqlauthority.com/2009/06/09/sqlauthority-news-teched-on-road-ahmedabad-india-is-announced-june-20-2009-saturday/): If you are regretting for missing TechEd India 2009 at Hyderabad here’s your chance of catching up with a similar kind of technology event in Ahmedabad, India on Saturday June 20, 2009. TechEd on Road will be held in Ahmedabad at Rock Regency, a prime location in the heart of the city. - [SQL SERVER - Fix: Error 15372 Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance - The connection will be closed](https://blog.sqlauthority.com/2009/06/08/sql-server-fix-error-15372-failed-to-generate-a-ser-instance-od-sql-server-due-to-a-failure-in-starting-the-process-for-the-user-instance-the-connection-will-be-closed/): Just a day ago, I was installing SQL Server Express on the backup computer. I found the solution for Error 15372. - [SQLAuthority News - Using SQL Server 2008 Extended Events - White paper By Jonathan Kehayias](https://blog.sqlauthority.com/2009/06/07/sqlauthority-news-using-sql-server-2008-extended-events-white-paper-by-jonathan-kehayias/): Strange it may sound but being a SQL Server pro has its downside too. Common information on SQL does not interest me, while a good document is hard to find. So the reader in me is mostly discontented and constantly keeps looking for interesting documents.  Recently, I chanced upon a really good white paper by Jonathan Keyhayias on SQL Serve r2008 extended events. I have known Jonathan through forums but have not met him in person yet. But I hope to meet him soon. The white paper starts with introduction to the extended event and then elaborates on its architecture, system... - [SQL SERVER - Order of Hotfix and Service Pack](https://blog.sqlauthority.com/2009/06/06/sql-server-order-of-hotfix-and-service-pack/): On an average once a week I receive a question from my readers regarding what should be the sequence of hotfix and service pack. Not long ago, one of my regular readers who is using SQL Server 2000 asked me how can he improve the installation speed as he has to install 4 Service Packs to upgrade his server to SQL Server SP4 version. All these questions from my readers have prompted me to write down this small note.  I hope this will clear some of the common doubts they have about this subject and they no longer would have to... - [SQLAuthority News - Rambling of Author and Technology Musing - Bing, Google, Windows 7, Books, Blogs, Twitter and Life](https://blog.sqlauthority.com/2009/06/05/sqlauthority-news-rambling-of-author-and-technology-musing-bing-google-windows-7-books-blogs-twitter-and-life/): I have been planning to write a general post on the latest technology for a long time but SQL keeps me so busy that I hardly get time. I know being busy is no excuse as everybody is busy with something. A manager is equally busy managing people as much as a peon busy doing errands. Now, coming back to my topic, I have lots of news to share with you all. Anyway, number one news is that Bing has been finally released a couple of days back. I am very much excited as something is finally challenging Google – The... - [SQL SERVER - What is Interim Table - Simple Definition of Interim Table](https://blog.sqlauthority.com/2009/06/04/sql-server-what-is-interim-table-simple-definition-of-interim-table/): Sometimes a simple question like “What is interim table?” can initiate a never-ending discussion between developers. I experienced this recently while I was on phone helping my friends working in Los Angeles. In a conference call, one of the developers kept on talking about “first interim table” and “second interim table” and so forth, while another developer was of the opinion that that there cannot be more than one interim table. Well, as this was not enough a third developer interrupted the debate and said that all the tables are interim tables. The heated discussion seemed never ending. To put the... - [SQL SERVER - Connect Item - Vote for Feature Request Function TRIM](https://blog.sqlauthority.com/2009/06/03/sql-server-connect-item-vote-for-feature-request-function-trim/): Till date, I have met the SQL Server Product Team twice: first time at SQL Server MVP Meet, Seattle, and second time at TechEd India 2009, Hyderabad. At both the times, I have put forth one request to the product team regarding implementing of function Trim(). As per my opinion, this is the most demanded feature of SQL Server. Almost all the programming languages have function TRIM() which removes space leading and any word that follows. However, SQL Server does not have TRIM() function. It has LTRIM() and RTRIM() functions, which when combined together LTRIM(RTRIM()) works like the expected TRIM() function... - [SQLAuthority News - Summary of TechEd India 2009 - A Grand Event](https://blog.sqlauthority.com/2009/06/02/sqlauthority-news-summary-of-teched-india-2009-a-grand-event/): TechEd India 2009 was undeniably a magnificent success! The 3-day grand event was adorned by delegates, sponsors, partners, customers, media as well as celebrities from cross the world. The event was marked by the CEO of Microsoft Steve Ballmer‘s keynote, Academy Award Winner Film Sound Designer of Slumdog Millioner Resool Pookutt‘s talk, not to forget the numerous technical sessions, Community Lounge, Partner Stalls, Demo Extravaganza, and the gaming zone. TechEd India 2009 was one event where community involvement was at its zenith. Organizations such as INETA APAC, Culminis, PASS and Microsoft India came together to bring all user group leaders together... - [SQL SERVER - List All Objects Created on All Filegroups in Database](https://blog.sqlauthority.com/2009/06/01/sql-server-list-all-objects-created-on-all-filegroups-in-database/): When I pen down any article I always keep my readers in my mind. With every topic of SQL server I cover, I try to bring readers closer to this technology. So, whenever I receive follow up questions from my readers I am exhilarated! Sometime back I had covered a topic – SQL SERVER – Create Multiple Filegroup For Single Database, for which I received a number of follow up questions. In this post I would like to discuss on a question from one of the readers Joginder “Jogi” Padiyala. “How can I find which object belongs to which filegroup. Is... - [SQL SERVER - Create Multiple Filegroup For Single Database](https://blog.sqlauthority.com/2009/05/31/sql-server-create-multiple-filegroup-for-single-database/): I am elated to receive hundreds of emails every day from my readers. My tight work schedule refrains me from answering all your questions, but I do try my best to entertain them whenever I can. Today’s post revolves around a question I received a number of times last year but never blogged on it. On positive side, you are reading about that interesting subject today. The question is – How to create multiple filegroup for any database? To find solution to this query, we will go through the following four cases. 1) Creating New Database a) Using T-SQL b) Using... - [SQL SERVER - Difference Between Candidate Keys and Primary Key](https://blog.sqlauthority.com/2009/05/30/sql-server-difference-between-candidate-keys-and-primary-key/): Let us first try to grasp the definition of the two keys. Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key. One needs to be very careful in selecting the Primary Key as an incorrect selection can adversely impact the database architect and... - [SQLAuthority News - Blog Makeover - New Banner - New Color](https://blog.sqlauthority.com/2009/05/29/sqlauthority-news-blog-makeover-new-banner-new-color/): Just a month back I had previously changed my personal homepage and had requested for feedback from my readers here SQLAuthority News – Authors Website Redesigned – https://www.pinaldave.com/ – Feedback Requested. To my astonishment, I received a huge number of emails. But I received only one comment. This time, I would like to request my readers to leave your comments on my blog instead of emailing it to me. This will allow everyone to know about others feedbacks and the actions I take towards incorporating the feedbacks on my blog and a new banner. - [SQL SERVER - Fix : Error : SQLDUMPER library failed initialization. Your installation is either corrupt or has been tampered with. Please uninstall then re-run setup to correct to correct this problem. in a modal dialog with the title SQL Writer](https://blog.sqlauthority.com/2009/05/28/sql-server-fix-error-sqldumper-library-failed-initialization-your-installation-is-either-corrupt-or-has-been-tampered-with-please-uninstall-then-re-run-setup-to-correct-to-correct-this-problem/): I often receive emails from reader requesting solution to following error: “SQLDUMPER library failed initialization. Your installation is either corrupt or has been tampered with. Please uninstall then re-run setup to correct to correct this problem.” in a modal dialog with the title “SQL Writer” While searching online there are so many different solution and many time the solution is to reinstall SQL Server. There is no need to reinstall SQL Server or do any complex process. It is very simple to fix this issue. Fix/Workaround/Solution: Go to Add/Remove Program in windows Control Panel Remove “microsoft SQL server vss writer” program... - [SQL SERVER - Interesting Observation of Logon Trigger On All Servers](https://blog.sqlauthority.com/2009/05/27/sql-server-interesting-observation-of-logon-trigger-on-all-servers/): I was recently working on security auditing for one of my clients. In this project, there was a requirement that all successful logins in the servers should be recorded. The solution for this requirement is a breeze! Just create logon triggers. I created logon trigger on server to catch all successful windows authentication as well SQL authenticated solutions. When I was done with this project, I made an interesting observation of executing a logon trigger multiple times. It was absolutely unexpected for me! As I was logging only once, naturally, I was expecting the entry only once. However, it did it multiple times on different threads – indeed an eccentric phenomenon at first sight! - [SQL SERVER - Find Hostname and Current Logged In User Name](https://blog.sqlauthority.com/2009/05/26/sql-server-find-hostname-and-current-logged-in-user-name/): I work in an environment wherein I connect to multiple servers across the world. Time and again, my SSMS is connected to a myriad of servers that kindles a lot of confusion. I frequently use the following trick to separate different connections, which I mentioned in my blog sometime back SQL SERVER – 2008 – Change Color of Status Bar of SSMS Query Editor. However, this trick does not help when a huge number of different connections are open. In such a case, I use the following handy script. Do not go by the length of the script; it might be... - [SQLAuthority News - Download Microsoft SQL Server 2008 Books Online (May 2009)](https://blog.sqlauthority.com/2009/05/25/sqlauthority-news-download-microsoft-sql-server-2008-books-online-may-2009/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - Introduction to Business Intelligence - Important Terms and Definitions](https://blog.sqlauthority.com/2009/05/24/sql-server-introduction-to-business-intelligence-important-terms-and-definitions/): What is Business Intelligence Business intelligence (BI) is a broad category of application programs and technologies for gathering, storing, analyzing, and providing access to data from various data sources, thus providing enterprise users with reliable and timely information and analysis for improved decision making. To put it simply, BI is an umbrella term that refers to an assortment of software applications for analyzing an organization’s raw data for intelligent decision making for business success. BI as a discipline includes a number of related activities, including decision support, data mining, online analytical processing (OLAP), querying and reporting, statistical analysis and forecasting. 1... - [SQLAuthority News - SQL Server Energy Event with Rushabh Mehta - May 20, 2009](https://blog.sqlauthority.com/2009/05/23/sqlauthority-news-sql-server-energy-event-with-rushabh-mehta-may-20-2009/): The much-awaited SQL Server Energy Event was successfully held on May 20, 2009 in Ahmedabad. It was jointly organized by Gandhinagar SQL Server User Group (President Pinal Dave – SQL MVP) and Ahmedabad SQL Server User Group (President Jacob Sebastian – SQL MVP). This vibrant event was one of the most interactive, remarkable and enriching events of this year in Ahmedabad. Several factors make this event unique. The main attraction of this outstanding event was Rushabh Mehta (SolidQ Mentor – SQL MVP), an eminent expert in the field of Business Intelligence. Technical session from a legend like Rushabh was an opportunity... - [SQLAuthority News - Download - SQL Server 2008 Developer Training Kit](https://blog.sqlauthority.com/2009/05/22/sqlauthority-news-download-sql-server-2008-developer-training-kit/): Note : Download SQL Server 2008 Developer Training Kit by Microsoft SQL Server 2008 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2005. The SQL Server 2008 Developer Training Kit will help you understand how to build web applications which deeply exploit the rich data types, programming models and new development paradigms in SQL Server 2008. The training kit is brought to you by Microsoft Developer and Platform Evangelism. - [SQL SERVER - FIX : ERROR : (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: )](https://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/): Regular readers of my blog are aware of the fact that I have written about this subject umpteen times earlier, and every time I have spoken about a new issue related to it. Few days ago, I had redone my local home network. I have LAN setup with wireless router connected with my four computers, two mobile devices, one printer and one VOIP solution. I had also formatted my primary computer and clean installed SQL Server 2008 into it. Yesterday, incidentally, I was sitting in my yard trying to connect SQL Server located in home office and suddenly I stumbled upon... - [SQL Server - Download PDF SQL Server Cheat Sheet](https://blog.sqlauthority.com/2009/05/20/sql-server-download-pdf-sql-server-cheat-sheet/): I had a gala time at TechEd India 2009 event! Meeting with great people is an experience of a lifetime. My session was well attended and well appreciated, which also gives me another reason to feel happy.  Moreover, my SQL Server Cheat Sheet gained unpredicted popularity at the event. Let me share with you all a little story behind this cheat sheet. For my personal use, I created one handy SQL Cheat Sheet, which I hang on my desk always. Even though I have a sound knowledge of SQL Syntax there are many occasions when I need to quickly refer to... - [SQLAuthority News - SQL Server Energy Event - Mark Your Calendar - May 20, 2009](https://blog.sqlauthority.com/2009/05/19/sqlauthority-news-sql-server-energy-event-mark-your-calender-may-20-2009/): I am very excited to share this news with all my readers. If you all remember I had already given a hint on my blog just two days back; I mentioned that we are going to host a grand event for Gandhinagar SQL Server User Group. In the past, Gandhinagar SQL Server User Group events have been more successful than we expected. Now, this event will grow even bigger as both Gandhinagar SQL Server User Group (President Pinal Dave – SQL MVP) and Ahmedabad SQL Server User Group (President Jacob Sebastian – SQL MVP) will come together for the event. This... - [SQL SERVER - Fix : Management Studio Error : Saving Changes in not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created](https://blog.sqlauthority.com/2009/05/18/sql-server-fix-management-studio-error-saving-changes-in-not-permitted-the-changes-you-have-made-require-the-following-tables-to-be-dropped-and-re-created-you-have-either-made-changes-to-a-tab/): Today, we will delve into a very simple issue that one of the Jr. Developers at my organization confronted. I have a preference for T-SQL. According to me, all the developers should always use T-SQL instead of Design feature of SQL Server Management Studio (SSMS). In fact, sound knowledge of T-SQL has the potential to make a huge difference in the development of the developer. One issue with using design mode of SSMS is that it sometimes adds too much overhead to the actual code and locks up the complete database. In the earlier version of SSMS, it was quite common... - [SQLAuthority News - Gandhinagar SQL Server User Group Meeting - International Speaker Visiting](https://blog.sqlauthority.com/2009/05/17/sqlauthority-news-gandhinagar-sql-server-user-group-meeting-international-speaker-visiting/): It is my pleasure to announce Gandhinagar SQL Server User Group Meeting on May 20, 2009 Wednesday. Mark this date as we will be having international speaker Rushabh Mehta of SolidQ attending our session. Rushabh Mehta is a Mentor for Solid Quality Mentors’ global Business Intelligence division, based in USA, and is also the Managing Director for Solid Quality India Pvt. Ltd. I will have more information about his technical session, location and meeting time tomorrow. This will be once in a life time opportunity. If you are in Gujarat state, India and you do not attend this session, you will... - [SQL SERVER - How to Drop Temp Table - Check Existence of Temp Table](https://blog.sqlauthority.com/2009/05/17/sql-server-how-to-drop-temp-table-check-existence-of-temp-table/): I have received following questions numerous times: “How to check existence of Temp Table in SQL Server Database?” “How to drop Temp Table from TempDB?” “When I try to drop Temp Table I get following error. Msg 2714, Level 16, State 6, Line 4 There is already an object named ‘#temp’ in the database. How can I fix it?” “Can we have only one Temp Table or we can have multiple Temp Table?” “I have SP using Temp Table, when it will run simultaneously, will it overwrite data of temp table?” In fact I have already answer this question earlier in... - [SQLAuthority News - TechEd India 2009 - Day 3 - Product Group Meeting - Final Presentations - Meeting Friends](https://blog.sqlauthority.com/2009/05/16/sqlauthority-news-teched-india-2009-day-3-product-group-meeting-final-presentations-meeting-friends/): TechEd India 2009 has ended today and I’ve already started missing it! This three-day event was one of the best events of this year so far. I got the platform to meet best of the best people in the industry today. If I have to rate my days at TechEd I will assign the highest rating to day 3 as it was the most significant day. However, in today’s article I will not be writing in detail about the last day because most of the things that I want to discuss have been covered by NDA. Besides, I learnt some vital... - [SQLAuthority News - TechEd India 2009 - Day 2 - In-Person Meeting with Industry Leaders - Community Party](https://blog.sqlauthority.com/2009/05/15/sqlauthority-news-teched-india-2009-day-2-in-person-meeting-with-industry-leaders-community-party/): Action-packed day 2 of TechEd India is over, and I feel that today was even better day than day 1. So many things were going on simultaneously and keeping track of them is a hard task. Even today I got the chance to meet some renowned industry leaders. Apart from having real time conversation with Industry Leaders, I had a great time attending the various Tech Sessions. Highlight of the day was Vinod Kumar’s session on “Reducing the size of your database using Data Compression/Binary Compression in SQL Server 2008“. Vinod commenced this session by bringing forth some causal questions to... - [SQLAuthority News - TechEd India 2009 - Day 1 - Authors Tech Session - SQL Server Cheat Sheet - Meeting Great People](https://blog.sqlauthority.com/2009/05/14/sqlauthority-news-teched-india-2009-day-1-authors-tech-session-sql-server-cheat-sheet-meeting-great-people/): First day of TechEd India 2009 is over and when I recall the day I can say that it was truly a blast! This immensely huge and grand event was conducted successfully. I am having a tough time trying to recapitulate the first day as there were several different activities worth covering. Let me start with the three most important events of day. Steve Ballmer – Microsoft CEO – was the Keynote speaker at TechEd India. He is really an enthusiastic person. As soon as he showed up on stage, the entire auditorium was charged with energy. People were extremely keen... - [SQLAuthority News - TechEd India 2009 - Day 0 - Day 1 - Authors Tech Session - SQL Server Cheat Sheet - Catch Me Live](https://blog.sqlauthority.com/2009/05/13/sqlauthority-news-teched-india-2009-day-0-day-1-authors-tech-session-sql-server-cheat-sheet-catch-me-live/): Presently, I am at TechEd India 2009 in Hyderabad as one of the participants of this prestigious event. I will be heading a session on SQL Server Management Studio 2008 New Features. I had recently blogged about TechEd 2009 India here. Excerpt from the previous article “Tech.Ed-India is a great opportunity to gear yourself up to keep pace with the latest technology innovations and trends.  This event offers you the platform to get comprehensive hands-on-training and free certifications in some of the most sought after technologies of today. In fact, it is a must-attend event for all developers and IT Professionals.”... - [SQLAuthority News - Release of SQL Server 2008 R2 Announced](https://blog.sqlauthority.com/2009/05/12/sqlauthority-news-release-of-sql-server-2008-r2-announced/): SQL Server 2008 R2 expands on the value delivered in SQL Server 2008 by providinga wealth of new features and capabilities that can benefit your entire organization. This release will further improve IT Efficiency with new and enhanced management capabilities and empower business users to access, integrate, analyze and share information using business intelligence tools they already know. Capitalize on Hardware Innovation Optimize Hardware Resources Manage Efficiently at Scale Enhance Collaboration Across Development and IT Improve the Quality of Your Data Manage User-Generated Analytical Applications Report with Ease Get More Out of Your Data Build Robust Analytical Applications Consolidate Your Data... - [SQL SERVER - How to Drop Primary Key Contraint ](https://blog.sqlauthority.com/2009/05/12/sql-server-how-to-drop-primary-key-contraint/): One area that always, unfailingly pulls my interest is SQL Server Errors and their solution. I enjoy the challenging task of passing through the maze of error to find a way out with a perfect solution. However, when I received the following error from one of my regular readers, I was a little stumped at first! After some online probing, I figured out that it was actually syntax from MySql and not SQL Server. The reader encountered error when he ran the following query. ALTER TABLE Table1 DROP PRIMARY KEY GO Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword... - [SQL SERVER - Questions and Answers with Database Administrators](https://blog.sqlauthority.com/2009/05/11/sql-server-questions-and-answers-with-database-administrators/): I have been in India for long time now, and at present, I am managing a very large outsourcing project. Recently, we conducted few interviews since the project required more Database Administrators and Senior Developers, and I must say it was an enthralling experience for me! I got the opportunity to meet some very talented and competent programmers from all over the country. Scores of interesting questions were discussed between the interviewers and the candidates, which made the whole interview process nothing short of an enriching occasion! I am listing some of the interesting questions discussed during the interviews. Some are... - [SQL SERVER - 10 Reasons for Database Outsourcing](https://blog.sqlauthority.com/2009/05/10/sql-server-10-reasons-for-database-outsourcing/): 10 Reasons for Database Outsourcing While you may feel that your IT material is safe and handled effectively within your own company, these reasons may give you some perspective on why you may want to consider other options. Cost Reduction – Perhaps the most popular reason to outsource your database is the overall reduction in cost that would benefit your company.  No longer do you have to pay people to check up and maintain your servers, verify that they have uninterrupted power supplies, and ensure their security from hackers.  By going with an IT company that does this exclusively, you can... - [SQL SERVER - Script to Find SQL Server on Network](https://blog.sqlauthority.com/2007/04/13/sql-server-script-to-find-sql-server-on-network/): I manage lots of SQL Servers. Many times I forget how many server I have and what are their names. New servers are added frequently and old servers are replaced with powerful servers. I run following script to check if server is properly set up and announcing itself. This script requires execute permissions on XP_CMDShell. CREATE TABLE #servers(sname VARCHAR(255)) INSERT #servers (sname) EXEC master..xp_CMDShell 'ISQL -L' DELETE FROM #servers WHERE sname='Servers:' OR sname IS NULL SELECT LTRIM(sname) FROM #servers DROP TABLE #servers Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Disable Triggers - Drop Triggers](https://blog.sqlauthority.com/2007/04/13/sql-server-2005-disable-triggers-drop-triggers/): There are two ways to prevent trigger from firing. 1) Drop Trigger Example: DROP TRIGGER TriggerName GO 2) Disable Trigger DML trigger can be disabled two ways. Using ALETER TABLE statement or use DISABLE TRIGGER. I prefer DISABLE TRIGGER statement. Syntax: DISABLE TRIGGER { [ schema . ] trigger_name [ ,...n ] | ALL } ON { OBJECT_NAME | DATABASE | ALL SERVER } [ ; ] Example: DISABLE TRIGGER TriggerName ON TableName Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-1702-create-table-failed-because-column-in-table-exceeds-the-maximum-of-columns/): Error Received: Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns SQL Server 2000 supports table with maximum 1024 columns. This errors happens when we try to create table with 1024 columns or try to add columns to table which exceeds more than 1024. Fix/Solution/WorkAround: Reduce the number of columns in the table to 1,024 or less. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error: 3902, Severity: 16; State: 1 : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-3902-severity-16-state-1-the-commit-transaction-request-has-no-corresponding-begin-transaction/): SQL Server Integration Services Error : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. (Microsoft OLE DB Provider for SQL Server) Fix/Workaround/Solution: Option 1: To work around this problem, do not call the stored procedure by using ODBC Call syntax. You can call the stored procedure in may ways by using ADO. One of the methods is to call a stored procedure by using a command object. (View Example) Option 2: If the sql statements are like BEGIN TRAN SQL Statements END TRAN SET “RetainSameConnection” property on the connection manager to true. This will fix the problem. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Running 64 bit SQL SERVER 2005 on 32 bit Operating System](https://blog.sqlauthority.com/2007/04/12/sql-server-running-64-bit-sql-server-2005-on-32-bit-operating-system/): Few days ago, I have received email from users asking question :How to run 64 bit SQL SERVER 2005 on 32 bit operating system? - [SQL SERVER - UDF - User Defined Function to Extract Only Numbers From String](https://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/): Following SQL User Defined Function will extract/parse numbers from the string. CREATE FUNCTION ExtractInteger(@String VARCHAR(2000)) RETURNS VARCHAR(1000) AS BEGIN DECLARE @Count INT DECLARE @IntNumbers VARCHAR(1000) SET @Count = 0 SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1) END SET @Count = @Count + 1 END RETURN @IntNumbers END GO Run following script in query analyzer. SELECT dbo.ExtractInteger('My 3rd Phone Number is 323-111-CALL') GO It will return following values. 3323111 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Explanation of TRY...CATCH and ERROR Handling](https://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/): SQL Server 2005 offers a more robust set of tools for handling errors than in previous versions of SQL Server. Deadlocks, which are virtually impossible to handle at the database level in SQL Server 2000, can now be handled with ease. By taking advantage of these new features, you can focus more on IT business strategy development and less on what needs to happen when errors occur. In SQL Server 2005, @@ERROR variable is no longer needed after every statement executed, as was the case in SQL Server 2000. SQL Server 2005 provides the TRY…CATCH construct, which is already present in... - [SQL SERVER - 2005 - Silent Installation - Unattended Installation](https://blog.sqlauthority.com/2007/04/10/sql-server-2005-silent-installation-unattended-installation/): Silent SQL Server 2005 Installation is possible in two steps. 1) Creating an .ini file The SQL Server CD contains a template file called template.ini . Based on that create another required .ini file which includes a single [Options] section containing multiple parameters, each relating to a different feature or configuration setting. 2) Run Setup on command prompt On command prompt type following script setup.exe /settings <path TO .ini FILE> If location of sqlinstall.ini file is at C:\SQLSetup folder. The command to initiate silent installation is: setup.exe /settings C:SQLSetup sqlinstall.ini Specify the /qn switch to perform a silent installation (with no... - [SQL SERVER - SP Performance Improvement without changing T-SQL](https://blog.sqlauthority.com/2007/04/10/sql-server-sp-performance-improvement-without-changing-t-sql/): There are two ways, which can be used to improve the performance of Stored Procedure (SP) without making T-SQL changes in SP. Do not prefix your Stored Procedure with sp_. In SQL Server, all system SPs are prefixed with sp_. When any SP is called which begins sp_ it is looked into masters database first before it is looked into the database it is called in. Call your Stored Procedure prefixed with dbo.SPName – fully qualified name. When SP are called prefixed with dbo. or database.dbo. it will prevent SQL Server from placing a COMPILE lock on the procedure. While SP... - [SQL SERVER - 2005 Reserved Keywords](https://blog.sqlauthority.com/2007/04/09/sql-server-2005-reserved-keywords/): Microsoft SQL Server 2005 uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language that is used by SQL Server to parse and understand Transact-SQL statements and batches. It is not legal to include the reserved keywords in a Transact-SQL statement in any location except that defined by SQL Server. No objects in the database should be given a name that matches a reserved keyword. Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using... - [SQL SERVER - Search Text Field - CHARINDEX vs PATINDEX](https://blog.sqlauthority.com/2007/04/08/sql-server-search-text-field-charindex-vs-patindex/): We can use either CHARINDEX or PATINDEX to search in TEXT field in SQL SERVER. The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. Both functions take two arguments. With PATINDEX, you must include percent signs before and after the pattern, unless you are looking for the pattern as the first (omit the first %) or last (omit the last %) characters in a column. For CHARINDEX, the pattern cannot include wildcard characters. The second argument is a character expression, usually a column name, in which Adaptive Server searches for the specified pattern. Example of CHARINDEX:... - [SQL SERVER - DBCC Commands Introduced in SQL Server 2005](https://blog.sqlauthority.com/2007/04/07/sql-server-dbcc-commands-introduced-in-sql-server-2005/): SQL Server 2005 has introduced following two documented and five undocumented DBCC Commands. I was able to find documentation for only first one online. If you find any documentation of any other DBCC Commands please add comments. It will be helpful to all of us. Documented: freesessioncache () — no parameters Flushes the distributed query connection cache used by distributed queries against an instance of Microsoft SQL Server. View Details requeststats ({clear} | {setfastdecayrate, rate} | {setslowdecayrate, rate}) UnDocumented: mapallocunit (I8AllocUnitId | {I4part, I2part}) metadata ({‘print’ [, printopt = {0 |1}] | ‘drop’ | ‘clone’ [, ” | ….]}, {‘object’ [,... - [SQL SERVER - Fix: Server: Msg 7391, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/06/sql-server-fix-server-msg-7391-level-16-state-1-line-1/): I have received this error many times on different servers in my careers. There is no single fix for this Error. Server: Msg 7391, Level 16, State 1, Line 1 can happen due to many reasons. I have used various of this reasons with few of my servers. Please refer them and try them one by one. One of them should be applicable to your problem. You may receive a 7391 error message in SQLOLEDB when you run a distributed transaction against a linked server after you install Windows XP Service Pack 2 or Windows XP Tablet PC Edition 200. View... - [SQL SERVER - Performance Optimization of SQL Query and FileGroups](https://blog.sqlauthority.com/2007/04/05/sql-server-performance-optimization-of-sql-query-and-filegroups/): It is suggested to place transaction logs on separate physical hard drives. In this manner, data can be recovered up to the second in the event of a media failure. In SQL 2005 When database is created without specifying a transaction log size, the transaction log will be re-sized to 25 percent of the size of data files. Tables and their non-clustered indexes separated into separate file groups can improve performance, because modifications to the table can be written to both the table and the index at the same time. If tables and their corresponding indexes in a different file group,... - [SQL SERVER - Fix: HResult 0x274D, SQLCMD Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired](https://blog.sqlauthority.com/2007/04/04/sql-server-fix-hresult-0x274d-level-16-state-1-error-microsoft-sql-native-client-login-timeout-expired/): While Working with SQLCMD in SQL Server 2005 I encountered following error. Let us learn in this blog post how we can solve Fix: HResult 0x274D, Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired. - [SQL SERVER - T-SQL Paging Query Technique Comparison - SQL 2000 vs SQL 2005](https://blog.sqlauthority.com/2007/04/03/sql-server-t-sql-paging-query-technique-comparison-sql-2000-vs-sql-2005/): I was doing paging in SQL Server 2000 using Temp Table or Derived Tables. I decided to checkout new function ROW_NUMBER() in SQL Server 2005. ROW_NUMBER() returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. I have compared both the following query on SQL Server 2005. SQL 2005 Paging Method USE AdventureWorks GO DECLARE @StartRow INT DECLARE @EndRow INT SET @StartRow = 120 SET @EndRow = 140 SELECT FirstName, LastName, EmailAddress FROM ( SELECT PC.FirstName, PC.LastName, PC.EmailAddress, ROW_NUMBER() OVER( ORDER BY PC.FirstName, PC.LastName,PC.ContactID) AS RowNumber FROM... - [SQL SERVER - 2005 - Performance Dashboard Reports](https://blog.sqlauthority.com/2007/04/02/sql-server-2005-performance-dashboard-reports/): The Microsoft SQL Server 2005 Performance Dashboard Reports are used to monitor and resolve performance problems on your SQL Server 2005 database server. The SQL Server instance being monitored and the Management Studio client used to run the reports must both be running SP2 or later. Common performance problems that the dashboard reports may help to resolve include: – CPU bottlenecks (and what queries are consuming the most CPU) – IO bottlenecks (and what queries are performing the most IO). – Index recommendations generated by the query optimizer (missing indexes) – Blocking – Latch contention The SQL Server 2005 Performance Dashboard... - [SQL SERVER - TempDB is Full. Move TempDB from one drive to another drive.](https://blog.sqlauthority.com/2007/04/01/sql-server-tempdb-is-full-move-tempdb-from-one-drive-to-another-drive/): If you ever find your TEmpDB to be full and if you want to move TempDB, you will find this blog post very helpful. Here is the error message which may come across. Event ID: 17052 Description: The LOG FILE FOR DATABASE 'tempdb' IS FULL. Back up the TRANSACTION LOG FOR the DATABASE TO free Up SOME LOG SPACE - [SQL SERVER - 2005 Best Practices Analyzer (February 2007 CTP)](https://blog.sqlauthority.com/2007/03/31/sql-server-2005-best-practices-analyzer-february-2007-ctp/): Microsoft has released a tool called the Microsoft SQL Server Best Practices Analyzer. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. Download SQL Server 2005 Best Practices Analyzer (February 2007 Community Technology Preview) Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Index Seek Vs. Index Scan (Table Scan)](https://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/): Index Scan retrieves all the rows from the table. Index Seek retrieves selective rows from the table. - [SQL SERVER - Difference between DISTINCT and GROUP BY - Distinct vs Group By](https://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/): This question is asked many times to me. What is difference between DISTINCT and GROUP BY? A DISTINCT and GROUP BY usually generate the same query plan, so performance should be the same across both query constructs. GROUP BY should be used to apply aggregate operators to each group. If all you need is to remove duplicates then use DISTINCT. If you are using sub-queries execution plan for that query varies so in that case you need to check the execution plan before making decision of which is faster. Example of DISTINCT: SELECT DISTINCT Employee, Rank FROM Employees Example of GROUP... - [SQL SERVER - Fix : Error 8101 An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON](https://blog.sqlauthority.com/2007/03/28/sql-server-fix-error-8101-an-explicit-value-for-the-identity-column-in-table-can-only-be-specified-when-a-column-list-is-used-and-identity_insert-is-on/): This error occurs when the user has attempted to insert a row containing a specific identity value into a table that contains an identity column. Run following commands according to your SQL Statement. Let us learn about the IDENTITY_INSERT. - [SQL SERVER - Fix : Error 701 There is insufficient system memory to run this query](https://blog.sqlauthority.com/2007/03/27/sql-server-fix-error-701-there-is-insufficient-system-memory-to-run-this-query/): Generic Solution: Check the settings for both min server memory (MB) and max server memory (MB). If max server memory (MB) is a value close to the value of min server memory (MB), then increase the max server memory (MB) value. Check the size of the virtual memory paging file. If possible, increase the size of the file. For SQL Server 2005: Install following HotFix and Restart Server. Additionally following DBCC Commands can be ran to free memory: DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT - Retrieve Last Inserted Identity of Record](https://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/): SELECT @@IDENTITY It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value. @@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it. SELECT SCOPE_IDENTITY()... - [SQL SERVER - Stored Procedure - Clean Cache and Clean Buffer](https://blog.sqlauthority.com/2007/03/23/sql-server-stored-procedure-clean-cache-and-clean-buffer/): DBCC FREEPROCCACHE will invalidate all stored procedure plans that the optimizer has cached in memory. Let us learn how to clean cache.  - [SQL SERVER - Fix: Error Msg 128 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.](https://blog.sqlauthority.com/2007/03/22/sql-server-fix-error-msg-128-the-name-is-not-permitted-in-this-context-only-constants-expressions-or-variables-allowed-here-column-names-are-not-permitted/): Error Message: Server: Msg 128, Level 15, State 1, Line 3 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Causes: This error occurs when using a column as the DEFAULT value of another column when a table is created. CREATE TABLE [dbo].[Items] ( [OrderCount] INT, [ProductAmount] INT, [TotalAmount] DEFAULT ([OrderCount] + [ProductAmount]) ) Executing this CREATE TABLE statement will generate the following error message: Server: Msg 128, Level 15, State 1, Line 5 The name ‘TotalAmount’ is not permitted in this context. Only constants, expressions, or variables allowed here.... - [SQL SERVER - 2005 Security Best Practices - Operational and Administrative Tasks](https://blog.sqlauthority.com/2007/03/21/sql-server-2005-security-best-practices-operational-and-administrative-tasks/): This white paper covers some of the operational and administrative tasks associated with SQL Server 2005 security and enumerates best practices and operational and administrative tasks that will result in a more secure SQL Server system. - [SQL SERVER - SQL Commandments - Suggestions, Tips, Tricks](https://blog.sqlauthority.com/2007/03/20/sql-server-sql-commandments-suggestions-tips-tricks/): Few days ago, while searching for something on web site, I came across a very good article of 25 SQL Commandments. I really enjoyed reading it. It was for Oracle, I re-wrote it for SQL Server. First 18 points are taken from original article and last 2 I added to complete total of 20 Commandments. Many more rules and suggestions can be added to this list, this list is just a beginning. 1. Know your data and business application well. Familiarize yourself with these sources; you must be aware of the data volume and distribution in your database. 2. Test your... - [SQL SERVER - Fix: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17](https://blog.sqlauthority.com/2007/03/16/sql-server-fix-sqllib-error-oledb-error-encountered-calling-idbinitializeinitialize-hr-0x80004005-sqlstate-08001-native-error-17/): Error received: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17 Error state: 1, Severity: 16 Source: Microsoft OLE DB Provider for SQL Server Error message: [DBNETLIB]SQL Server does not exist or access denied The simple fix: Microsoft SQL Server 2005 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server 2005 Network Configuration >> Enable TCP-IP. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC command to RESEED Table Identity Value - Reset Table Identity](https://blog.sqlauthority.com/2007/03/15/sql-server-dbcc-reseed-table-identity-value-reset-table-identity/): DBCC CHECKIDENT can reseed (reset) the identity value of the table. For example, YourTable has 25 rows with 25 as last identity. If we want next record to have identity as 35 we need to run following T SQL script in Query Analyzer. DBCC CHECKIDENT (yourtable, reseed, 34) If table has to start with an identity of 1 with the next insert then the table should be reseeded with the identity to 0. If identity seed is set below values that currently are in table, it will violate the uniqueness constraint as soon as the values start to duplicate and will... - [SQL SERVER - Union vs. Union All - Which is better for performance?](https://blog.sqlauthority.com/2007/03/10/sql-server-union-vs-union-all-which-is-better-for-performance/): This article is completely re-written with better example SQL SERVER – Difference Between Union vs. Union All – Optimal Performance Comparison. I suggest all of my readers to go here for update article. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values. The difference between Union and Union all... - [SQL SERVER - Download 2005 SP2a](https://blog.sqlauthority.com/2007/03/07/sql-server-2005-sp2a/): Microsoft released an updated SQL Server 2005 SP2 on March 5th, 2007. The build number is 9.00.3042.01. The previous build number was 9.00.3042.00.Microsoft released a SP2a patch for the second service pack for SQL Server 2005 to fix the issues with the maintenance plans.If you have upgraded to SP2, use the download from here to patch the system. KB 933508 has more information on this patch. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Script to Determine Which Version of SQL Server 2000-2005 is Running](https://blog.sqlauthority.com/2007/03/07/sql-server-script-to-determine-which-version-of-sql-server-2000-2005-is-running/): To determine which version of SQL Server 2000/2005 is running, connect to SQL Server 2000/2005 by using Query Analyzer, and then run the following code: SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') The results are: The product version (for example, 8.00.534). The product level (for example, “RTM” or “SP2”). The edition (for example, “Standard Edition”). For example, the result looks similar to: 8.00.534 RTM Standard Edition Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation](https://blog.sqlauthority.com/2007/03/05/sql-server-quoted_identifier-onoff-and-ansi_null-onoff-explanation/): When create or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF? SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO--SQL PROCEDURE, SQL FUNCTIONS, SQL OBJECTGO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO ANSI NULL ON/OFF: This option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares a value with a null returns a 0. When off, any query that compares a value with a null returns a null value. QUOTED IDENTIFIER ON/OFF:... - [SQL SERVER - Delete Duplicate Records - Rows](https://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/): Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3. DELETE FROM MyTable WHERE ID NOT IN ( SELECT MAX(ID) FROM MyTable GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3) Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to find the CD key from Registry](https://blog.sqlauthority.com/2007/02/28/sql-server-t-sql-script-to-find-the-cd-key-from-registry/): Here is the way to find SQL Server CD key, which was used to install it on machine. If user do not have permission on the SP, please login using SA username. Expended stored procedure xp_regread can read any registry values. I have used this XP to read CD_KEY. This is undocumented Stroed Procedure and may not be supported in Future Version of SQL Server. USE master GO EXEC xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Microsoft SQL Server\80\Registration','CD_KEY' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - What is New in SQL Server Agent for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/02/26/sql-server-whats-new-in-sql-server-agent-for-microsoft-sql-server-2005/): I came across this interesting and detailed article ‘What’s New in SQL Server Agent for Microsoft SQL Server 2005’ on Microsoft TechNet. This article describes Security Improvements, New Roles in the msdb Database, Multiple Proxy Accounts, Performance Improvements, Performance Counters, New SQL Server Agent Subsystems, Shared Schedules, WMI Event Alerts, SQL Server Agent Sessions, Database Mail Support, Stored Procedure Changes in depth. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Restore Database Backup using SQL Script (T-SQL)](https://blog.sqlauthority.com/2007/02/25/sql-server-restore-database-backup-using-sql-script-t-sql/): In this blog post we are going to learn how to restore database backup using T-SQL script. We have already database which we will use to take a backup first and right after that we will use it to restore to the server. Taking backup is an easy thing, but I have seen many times when a user tries to restore the database, it throws an error. - [SQL SERVER - Download SQL Server 2005 Books Online (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-download-sql-server-2005-books-online-february-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The February 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - SQL Server 2005 Samples and Sample Databases (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-sql-server-2005-samples-and-sample-databases-february-2007/): The samples download provides over 100 samples for SQL Server 2005, demonstrating the following components: Database Engine, including administration, data access, Full-Text Search, Common Language Runtime (CLR) integration, Server Management Objects (SMO), Service Broker, and XML Analysis Services Integration Services Notification Services Reporting Services Replication The samples databases downloads include the AdventureWorks sample online transaction processing (OLTP) database, the AdventureWorksDW sample data warehouse, and the AdventureWorksAS sample projects which you can use to build the AdventureWorksAS BI database. These databases are used in the samples and in the code examples in the SQL Server 2005 Books Online. There is also a... - [SQL SERVER - Creating Comma Separate List From Table](https://blog.sqlauthority.com/2007/02/20/deprecate-dec-2007-creating-comma-separate-list-from-table/): Update : (5/5/2007) I have updated the script to support SQL SERVER 2005. Visit :SQL SERVER – Creating Comma Separate Values List from Table – UDF – SP Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 15023: User already exists in current database.](https://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/): Error 15023: User already exists in current database. 1) This is the best Solution. First of all run following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan. USE YourDB GO EXEC sp_change_users_login 'Report' GO Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist. In following example ‘ColdFusion’ is UserName, ‘cf’ is Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in... - [SQL SERVER - Function to Convert List to Table](https://blog.sqlauthority.com/2007/02/10/sql-server-function-to-convert-list-to-table/): Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005. Visit :SQL SERVER – UDF – Function to Convert List to Table Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Constraints and Unique Key Constraints](https://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/): Primary Key: Primary Key enforces uniqueness of the column on which they are defined. Primary Key creates a clustered index on the column. Primary Key does not allow Nulls. Create table with Primary Key: CREATE TABLE Authors ( AuthorID INT NOT NULL PRIMARY KEY, Name VARCHAR(100) NOT NULL ) GO Alter table with Primary Key: ALTER TABLE Authors ADD CONSTRAINT pk_authors PRIMARY KEY (AuthorID) GO Unique Key: Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value. Alter table to add unique constraint... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case](https://blog.sqlauthority.com/2007/02/01/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case/): Following function will convert any string to Title Case. I have this function for long time. I do not remember that if I wrote it myself or I modified from original source. Run Following T-SQL statement in query analyzer: SELECT dbo.udf_TitleCase('This function will convert this string to title case!') The output will be displayed in Results pan as follows: This Function Will Convert This String To Title Case! T-SQL code of the function is: CREATE FUNCTION udf_TitleCase (@InputString VARCHAR(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(1) DECLARE @OutputString VARCHAR(255) SET @OutputString = LOWER(@InputString) SET @Index = 2... - [SQL SERVER - ReIndexing Database Tables and Update Statistics on Tables](https://blog.sqlauthority.com/2007/01/31/sql-server-reindexing-database-tables-and-update-statistics-on-tables/): SQL SERVER 2005 uses ALTER INDEX syntax to reindex database. SQL SERVER 2005 supports DBREINDEX but it will be deprecated in future versions. Let us learn how to do ReIndexing Database Tables and Update Statistics on Tables. - [SQL SERVER - Query Analyzer Short Cut to display the text of Stored Procedure](https://blog.sqlauthority.com/2007/01/30/query-analyzer-short-cut-to-display-the-text-of-stored-procedure/): This is quick but interesting trick to display the text of Stored Procedure in the result window. Open SQL Query Analyzer >> Tools >> Customize >> Custom Tab type sp_helptext against Ctrl+3 (or shortcut key of your choice) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2007/01/26/sql-server-sql-joke-sql-humor-sql-laugh/): I have heard this joke from my friend. I always wanted to write it but I was not able to find the source of the joke. This joke I have located on DavidM’s Blog on SQLTeam. It is March 1st and the first day of DBMS school The teacher starts off with a role call.. Teacher: Oracle? “Present sir” Teacher: DB2? “Present sir” Teacher: SQL Server? “Present sir” Teacher: MySQL? [Silence] Teacher: MySQL? [Silence] Teacher: Where the hell is MySQL [In rushes MySQL, unshaven, hair a mess] Teacher: Where have you been MySQL “Sorry sir I thought it was February 31st”... - [SQL SERVER - Query Analyzer Shortcuts](https://blog.sqlauthority.com/2007/01/20/sql-server-query-analyzer-shortcuts/): Download Query Analyzer Shortcuts (PDF) Shortcut Function Shortcut Function ALT+BREAK Cancel a query CTRL+SHIFT+F2 Clear all bookmarks ALT+F1 Database object information CTRL+SHIFT+INSERT Insert a template ALT+F4 Exit CTRL+SHIFT+L Make selection lowercase CTRL+A Select all CTRL+SHIFT+M Replace template parameters CTRL+B Move the splitter CTRL+SHIFT+P Open CTRL+C Copy CTRL+SHIFT+R Remove comment CTRL+D Display results in grid format CTRL+SHIFT+S Show client statistics CTRL+Delete Delete through the end of the line CTRL+SHIFT+T Show server trace CTRL+E Execute query CTRL+SHIFT+U Make selection uppercase CTRL+F Find CTRL+T Display results in text format CTRL+F2 Insert/remove bookmark CTRL+U Change database CTRL+F4 Disconnect CTRL+V Paste CTRL+F5 Parse query and check... - [SQL SERVER - Query to find number Rows, Columns, ByteSize for each table in the current database - Find Biggest Table in Database](https://blog.sqlauthority.com/2007/01/10/sql-server-query-to-find-number-rows-columns-bytesize-for-each-table-in-the-current-database-find-biggest-table-in-database/): USE DatabaseName GO CREATE TABLE #temp ( table_name sysname , row_count INT, reserved_size VARCHAR(50), data_size VARCHAR(50), index_size VARCHAR(50), unused_size VARCHAR(50)) SET NOCOUNT ON INSERT #temp EXEC sp_msforeachtable 'sp_spaceused ''?''' SELECT a.table_name, a.row_count, COUNT(*) AS col_count, a.data_size FROM #temp a INNER JOIN information_schema.columns b ON a.table_name collate database_default = b.table_name collate database_default GROUP BY a.table_name, a.row_count, a.data_size ORDER BY CAST(REPLACE(a.data_size, ' KB', '') AS integer) DESC DROP TABLE #temp Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Simple Example of Cursor](https://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/): UPDATE: For working example using AdventureWorks visit : SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2 This is the simplest example of the SQL Server Cursor. I have used this all the time for any use of Cursor in my T-SQL. DECLARE @AccountID INT DECLARE @getAccountID CURSOR SET @getAccountID = CURSOR FOR SELECT Account_ID FROM Accounts OPEN @getAccountID FETCH NEXT FROM @getAccountID INTO @AccountID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @AccountID FETCH NEXT FROM @getAccountID INTO @AccountID END CLOSE @getAccountID DEALLOCATE @getAccountID Reference: Pinal Dave (http://www.SQLAuthority.com), BOL - [SQL SERVER - Shrinking Truncate Log File - Log Full](https://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/): UPDATE: Please follow link for SQL SERVER – SHRINKFILE and TRUNCATE Log File in SQL Server 2008. Sometime, it looks impossible to shrink the Truncated Log file. Following code always shrinks the Truncated Log File to minimum size possible. USE DatabaseName GO DBCC SHRINKFILE(<TransactionLogName>, 1) BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY DBCC SHRINKFILE(<TransactionLogName>, 1) GO [Update: Please note, there are much more to this subject, read my more recent blogs. This breaks the chain of the logs and in future you will not be able to restore point in time. If you have followed this advise, you are recommended to take full... - [SQL SERVER - Fix : Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved.](https://blog.sqlauthority.com/2006/12/20/sql-server-fix-error-14274-cannot-add-update-or-delete-a-job-or-its-steps-or-schedules-that-originated-from-an-msx-server-the-job-was-not-saved/): To fix the error which occurs after the Windows server name been changed, when trying to update or delete the jobs previously created in a SQL Server 2000 instance, or attaching msdb database. Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved. Reason: SQL Server 2000 supports multi-instances, the originating_server field contains the instance name in the format ‘server\instance’. Even for the default instance of the server, the actual server name is used instead of ‘(local)’. Therefore, after the Windows server is renamed, these jobs... - [SQL SERVER - Find Stored Procedure Related to Table in Database - Search in All Stored Procedure](https://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/): Following code will help to find all the Stored Procedures (SP) which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results. ----Option 1 SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so ON sc.id=so.id WHERE sc.TEXT LIKE '%tablename%' ----Option 2 SELECT DISTINCT o.name, o.xtype FROM syscomments c INNER JOIN sysobjects o ON c.id=o.id WHERE c.TEXT LIKE '%tablename%' Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Cursor to Kill All Process in Database](https://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/): When you run the script please make sure that you run it in different database then the one you want all the processes to be killed. CREATE TABLE #TmpWho (spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150), hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150)) INSERT INTO #TmpWho EXEC sp_who DECLARE @spid INT DECLARE @tString VARCHAR(15) DECLARE @getspid CURSOR SET @getspid =   CURSOR FOR SELECT spid FROM #TmpWho WHERE dbname = 'mydb'OPEN @getspid FETCH NEXT FROM @getspid INTO @spid WHILE @@FETCH_STATUS = 0 BEGIN SET @tString = 'KILL ' + CAST(@spid AS VARCHAR(5)) EXEC(@tString) FETCH NEXT FROM @getspid INTO @spid END CLOSE @getspid DEALLOCATE @getspid DROP TABLE #TmpWho... - [SQL SERVER - Simple Cursor to Select Tables in Database with Static Prefix and Date Created](https://blog.sqlauthority.com/2006/11/30/sql-server-cursor-to-process-tables-in-database-with-static-prefix-and-date-created/): Following cursor query runs through the database and find all the table with certain prefixed ('b_','delete_'). It also checks if the Table is more than certain days old or created before certain days, it will delete it. We can have any other operation on that table like to delete, print or index. - [SQL SERVER - Auto Generate Script to Delete Deprecated Fields in Current Database](https://blog.sqlauthority.com/2006/11/20/sql-server-auto-generate-script-to-delete-deprecated-fields-in-current-database/): I always mark fields to be deprecated with “dep_” as prefix. In this way, after few days, when I am sure that I do not need the field any more I run the query to auto generate the deprecation script. The script also checks for any constraint in the system and auto generate the script to drop it also. SELECT 'ALTER TABLE ['+po.name+'] DROP CONSTRAINT [' + so.name + ']' FROM sysobjects so INNER JOIN sysconstraints sc ON so.id = sc.constid INNER JOIN syscolumns col ON sc.colid = col.colid AND so.parent_obj = col.id AND col.name LIKE 'dep[_]%' INNER JOIN sysobjects po ON so.parent_obj = po.id WHERE so.xtype = 'D' ORDER BY po.name, col.name SELECT... - [SQL SERVER - Query to Find ByteSize of All the Tables in Database](https://blog.sqlauthority.com/2006/11/10/sql-server-query-to-find-byte-size/): SELECT CASE WHEN (GROUPING(sob.name)=1) THEN 'All_Tables'    ELSE ISNULL(sob.name, 'unknown') END AS Table_name,    SUM(sys.length) AS Byte_Length FROM sysobjects sob, syscolumns sys WHERE sob.xtype='u' AND sys.id=sob.id GROUP BY sob.name WITH CUBE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database](https://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/): UPDATE : SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database This is very long query. Optionally, we can limit the query to return results for one or more than one table. SELECT K_Table = FK.TABLE_NAME, FK_Column = CU.COLUMN_NAME, PK_Table = PK.TABLE_NAME, PK_Column = PT.COLUMN_NAME, Constraint_Name = C.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME INNER JOIN ( SELECT i1.TABLE_NAME, i2.COLUMN_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1 INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME WHERE i1.CONSTRAINT_TYPE = 'PRIMARY KEY' ) PT ON PT.TABLE_NAME = PK.TABLE_NAME ---- optional: ORDER BY 1,2,3,4 WHERE PK.TABLE_NAME='something'WHERE FK.TABLE_NAME='something'... - [SQL SERVER - Validating Unique Column Name Across Whole Database](https://blog.sqlauthority.com/2012/09/22/sql-server-validating-unique-column-name-across-whole-database/): I sometimes come across very strange requirements and often I do not receive a proper explanation of the same. Validating Unique Column Name - [SQL SERVER - Replace a Column Name in Multiple Stored Procedure All Together](https://blog.sqlauthority.com/2012/09/21/sql-server-replace-a-column-name-in-multiple-stored-procedure-all-together/): I receive a lot of emails every day. I try to answer each and every email and comments on Facebook and Twitter. I prefer communication on social media as this gives opportunities to others to read the questions and participate along with me. There is always some question which everyone likes to read and remember. Here is one of the questions which I received in email. How to replace a column name in multiple stored procedure efficiently and quickly? I believe the same question will be there any many developers who are beginning with SQL Server. I decided to blog about it so everyone can read it and participate. - [SQL SERVER - 2 T-SQL Puzzles and Win USD 50 worth Amazon Gift Card and 25 Other Prizes](https://blog.sqlauthority.com/2012/09/20/sql-server-2-t-sql-puzzles-and-win-usd-50-worth-amazon-gift-card-and-25-other-prizes/): We all love brain teasers and interesting puzzles. Today I decided to come up with 2 interesting puzzles and winner of the contest will get USD 50 worth Amazon Gift Card. The puzzles are sponsored by NuoDB. Additionally, The first 25 individuals who download NuoDB Beta 8 by midnight Friday, Sept. 21 (EST) will automatically receive a $10 Amazon gift card. Puzzle 1: Why following code when executed in SSMS displays result as a * (Star)? SELECT CAST(634 AS VARCHAR(2)) Puzzle 2: Write the shortest code that produces results as 1 without using any numbers in the select statement. Bonus Q: How... - [SQL SERVER - Effect of Collation on Resultset - SQL in Sixty Seconds #026 - Video](https://blog.sqlauthority.com/2012/09/19/sql-server-effect-of-collation-on-resultset-sql-in-sixty-seconds-026-video/): Collation is a very important concept but often ignored. I have often seen developers either not understanding this or ignored it – this is plain wrong. In simple word we can say Collation is the language or interpreting done by SQL Server. Well, in today’s SQL in Sixty Seconds we are going to observe how collation affects the resultset. Today’s blog post is inspired from my earlier blog post SQL SERVER – Effect of Case Sensitive Collation on Resultset. I strongly encourage you to read this earlier blog post for sample code as well additional explanation related to the concept shared... - [SQL SERVER - SSMS Automatically Generates TOP (100) PERCENT in Query Designer](https://blog.sqlauthority.com/2012/09/18/sql-server-ssms-automatically-generates-top-100-percent-in-query-designer/): Earlier this week, I was surfing various SQL forums to see what kind of help developer need in the SQL Server world. One of the question indeed caught my attention. I am here regenerating complete question as well scenario to illustrate the point in a precise manner. Additionally, I have added added second part of the question to give completeness. Question: I am trying to create a view in Query Designer (not in the New Query Window). Every time I am trying to create a view it always adds  TOP (100) PERCENT automatically on the T-SQL script. No matter what I do,... - [SQL SERVER - SQL Server Statistics Name and Index Creation](https://blog.sqlauthority.com/2012/09/17/sql-server-sql-server-statistics-name-index-creation/): Sometimes something very small or a common error which we observe in daily life teaches us new things. SQL Server Expert Sandip (winner of Joes 2 Pros Contests) has come across similar experience. Sandip has written a guest post on an error he faced in his daily work. Sandip is working for QSI Healthcare as an Associate Technical Specialist and have more than 5 years of total experience. Let's see SQL Server Statistics Name and Index Creation here. - [SQLAuthority News - Download Whitepaper - Power View Infrastructure Configuration and Installation: Step-by-Step and Scripts](https://blog.sqlauthority.com/2012/09/16/sqlauthority-news-download-whitepaper-power-view-infrastructure-configuration-and-installation-step-by-step-and-scripts/): Power View, a feature of SQL Server 2012 Reporting Services Add-in for Microsoft SharePoint Server 2010 Enterprise Edition, is an interactive data exploration, visualization, and presentation experience. It provides intuitive ad-hoc reporting for business users such as data analysts, business decision makers, and information workers. Microsoft has recently released very interesting whitepaper which covers a sample scenario that validates the connectivity of the Power View reports to both PowerPivot workbooks and tabular models. This white paper talks about following important concepts about Power View: Understanding the hardware and software requirements and their download locations Installing and configuring the required infrastructure when Power View... - [SQL SERVER - Download Microsoft SQL Server Compact 4.0 SP1](https://blog.sqlauthority.com/2012/09/15/sql-server-download-microsoft-sql-server-compact-4-0-sp1/): Microsoft SQL Server Compact 4.0 is a free, embedded database that software developers can use for building ASP.NET websites and Windows desktop applications. SQL Server Compact 4.0 is the default database for Microsoft WebMatrix. For enhanced development and debugging capabilities, including designer support, Visual Studio can be used to develop ASP.NET web applications and websites using SQL Server Compact 4.0. Enabled to work in the medium or partial trust environments in the web servers, and can be easily deployed along with the website to the third party website hosting service providers. SQL Server CE 4.0 also provides stronger data security with the use of the SHA2 encryption algorithms for encrypting the databases. Latest version also supports T-SQL syntax enhancement by adding support for OFFSET and FETCH that can be used to write paging queries. Used with ADO.NET Entity Framework, SQL Server Compact now supports the columns that have server generated keys like identity, rowguid etc. and the code-first programming model. SQL Server Compact 4.0 is freely redistributable under a redistribution license agreement. SQL Server Compact 3.5 and SQL Server Compact 4.0 can be installed and work side by side on a desktop. - [SQL SERVER - Grouping by Multiple Columns to Single Column as A String](https://blog.sqlauthority.com/2012/09/14/sql-server-grouping-by-multiple-columns-to-single-column-as-a-string/): One of the most common questions I receive in email is how to group multiple columns data in comma separate values in a single row grouping by another column. I have previously blogged about it in following two blog posts. - [SQL SERVER - Core Concepts - Elasticity, Scalability and ACID Properties - Exploring NuoDB an Elastically Scalable Database System](https://blog.sqlauthority.com/2012/09/13/sql-server-core-concepts-elasticity-scalability-and-acid-properties-exploring-nuodb-an-elastically-scalable-database-system/): I have been recently exploring Elasticity and Scalability attributes of databases. You can see that in my earlier blog posts about NuoDB where I wanted to look at Elasticity and Scalability concepts. The concepts are very interesting, and intriguing as well. I have discussed these concepts with my friend Joyti M and together we have come up with this interesting read. The goal of this article is to answer following simple questions What is Elasticity? What is Scalability? How ACID properties vary from NOSQL Concepts? What are the prevailing problems in the current database system architectures? Why is NuoDB  an innovative and welcome change in database paradigm? Elasticity... - [SQL SERVER - Get Date and Time From Current DateTime - SQL in Sixty Seconds #025 - Video](https://blog.sqlauthority.com/2012/09/12/sql-server-get-date-and-time-from-current-datetime-sql-in-sixty-seconds-025-video/): This is 25th video of series SQL in Sixty Seconds we started a few months ago. Even though this is 25th video it seems like we have just started this few days ago. The best part of this SQL in Sixty Seconds is that one can learn something new in less than sixty seconds. There are many concepts which are not new for many but just we all have 60 seconds to refresh our memories. In this video I have touched a very simple question which I receive very frequently on this blog. Q1) How to get current date time? Q2)... - [SQL SERVER - Why Do We Need Master Data Management - Importance and Significance of Master Data Management (MDM)](https://blog.sqlauthority.com/2012/09/11/sql-server-why-do-we-need-master-data-management-importance-and-significance-of-master-data-management-mdm/): Let me paint a picture of everyday life for you.  Let’s say you and your wife both have address books for your groups of friends.  There is definitely overlap between them, so that you both have the addresses for your mutual friends, and there are addresses that only you know, and some only she knows.  They also might be organized differently.  You might list your friend under “J” for “Joe” or even under “W” for “Work,” while she might list him under “S” for “Joe Smith” or under your name because he is your friend.  If you happened to trade, neither... - [SQL SERVER - Why Do We Need Data Quality Services - Importance and Significance of Data Quality Services (DQS)](https://blog.sqlauthority.com/2012/09/10/sql-server-why-do-we-need-data-quality-services-importance-and-significance-of-data-quality-services-dqs/): Databases are awesome.  I’m sure my readers know my opinion about this – I have made SQL Server my life’s work after all!  I love technology and all things computer-related.  Of course, even with my love for technology, I have to admit that it has its limits.  For example, it takes a human brain to notice that data has been input incorrectly.  Computer “brains” might be faster than humans, but human brains are still better at pattern recognition.  For example, a human brain will notice that “300” is a ridiculous age for a human to be, but to a computer it... - [SQL SERVER - Configuring Interactive Cleansing Suggestion Min Score for Suggestions in Data Quality Services (DQS) - Sensitivity of Suggestion](https://blog.sqlauthority.com/2012/09/09/sql-server-configuring-interactive-cleansing-suggestion-min-score-for-suggestions-in-data-quality-services-dqs-sensitivity-of-suggestion/): Earlier I talked about what kind of questions, I do not like when I get asked. Today we will go over the question which I like when I get asked the same. One of the reader practices various steps in my earlier blog post Step by Step Guide to Beginning Data Quality Services in SQL Server 2012 – Introduction to DQS. While reading the blog post he noticed that Data Quality Services is not providing very helpful suggestions. He wrote an email to me about it. Let us go over his email. “Pinal, I noticed in one of your images that DQS... - [SQL SERVER - Unable to DELETE Project in Data Quality Projects (DQS)](https://blog.sqlauthority.com/2012/09/08/sql-server-unable-to-delete-project-in-data-quality-projects-dqs/): Here is the email which made me write this blog post. When I write a blog post I write keeping in mind that if the developer is not familiar with the concept he will attempt this on the development server. If due to any reason you attempt it on any other server than your personal server, developer should make sure to have complete confidence on his own expertise and understand the risk behind it.  Well, let us read the email which I received. I have modified it a bit to remove information related to organizational and individual. “I just read your... - [SQL SERVER - Fun Post - Connecting Same SQL Server using Different Methods](https://blog.sqlauthority.com/2012/09/07/sql-server-fun-post-connecting-same-sql-server-using-different-methods/): Yesterday I had faced error when I was connecting SQL Server using 127.0.0.1. I had immediately checked if SQL Server is working perfectly by connecting to it by specifiing my local box computer. While I was doing this suddenly I realize that it is indeed interesting to know how many different way we can connect to SQL Server which is installed in the local box. I created list of 5 different way but I am sure there are many more ways and I would like to document there here. Here is my setup. I am attempting to connect to the default... - [SQL SERVER - FIX ERROR - Cannot connect to . Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452)](https://blog.sqlauthority.com/2012/09/06/sql-server-fix-error-cannot-connect-to-login-failed-the-login-is-from-an-untrusted-domain-and-cannot-be-used-with-windows-authentication-microsoft-sql-server-error-18452/): Just a day ago, I was doing small attempt to connect to my local SQL Server using IP 127.0.0.1. The IP is of my local machine and SQL Server is installed on the local box as well. However, whenever I try to connect to the server it gave me following strange error. Cannot connect to 127.0.0.1. Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. (Microsoft SQL Server, Error: 18452) The reason was indeed strange as I was trying to connect from local box to local box and it said my login was from an... - [SQLAuthority News - A Quick Note on @Pluralsight Video - Call Me Maybe Developer Way](https://blog.sqlauthority.com/2012/09/05/sqlauthority-news-a-quick-note-on-pluralsight-video-call-me-maybe-developer-way/): I write a lot about how important learning and training is.  Any of my readers will know that I think the key to success is staying current with your education and taking very opportunity to increase your “tool kit” of skills.  I hope that I have not made the impression that it is all in the employees hands to make sure they are happy and satisfied at their jobs. I also firmly believe that a good boss will make good employees.  A boss who is good at communicating,  and leading, who knows how to nip problem in the bud and allocate... - [SQL SERVER - Step by Step Guide to Beginning Data Quality Services in SQL Server 2012 - Introduction to DQS](https://blog.sqlauthority.com/2012/09/04/sql-server-step-by-step-guide-to-beginning-data-quality-services-in-sql-server-2012-introduction-to-dqs/): Data Quality Services is a very important concept of SQL Server. I have recently started to explore the same and I am really learning some good concepts. Here are two very important blog posts which one should go over before continuing this blog post about Data Quality Services. - [SQL SERVER - DQS Error - Cannot connect to server - A .NET Framework error occurred during execution](https://blog.sqlauthority.com/2012/09/03/sql-server-dqs-error-cannot-connect-to-server-a-net-framework-error-occurred-during-execution-of-user-defined-routine-or-aggregate-setdataqualitysessions-setdataqualitysessionphasetwo/): Earlier I wrote a blog post about how to install DQS in SQL Server 2012. Today I decided to write a second part of this series where I explain how to use DQS, however, as soon as I started the DQS client, I encountered an error that will not let me pass through and connect with DQS client. It was a bit strange to me as everything was functioning very well when I left it last time. The error of DQS Error was very big but here are the first few words of it. Cannot connect to server. A .NET Framework error occurred during execution of user-defined routine or aggregate "SetDataQualitySessions": System.Data.SqlClient.SqlException (0x80131904): A .NET Framework error occurred during execution of user-defined routine or aggregate "SetDataQualitySessionPhaseTwo": The error continues - here is the quick screenshot of the error. - [SQLAuthority News - Weekend Experiment with NuoDB - Points to Pondor and Whitepaper](https://blog.sqlauthority.com/2012/09/02/sqlauthority-news-weekend-experiment-with-nuodb-points-to-pondor-and-whitepaper/): This weekend I have downloaded the latest beta version of NuoDB. I found it much improved and better UI. I was very much impressed as the installation was very smooth and I was up and running in less than 5 minutes with the product. The tools which are related to the Administration of the NuoDB seems to get makeover during this beta release. As per the claim they support now Solaris platform and have improved the native MacOS installation. I neither have Mac nor Solaris – I wish I would have experimented with the same. I will appreciate if anyone out... - [SQLAuthority News - Memories at Anniversary of SQL Wait Stats Book](https://blog.sqlauthority.com/2012/09/01/sqlauthority-news-memories-at-anniversary-of-sql-wait-stats-book/): About a year ago, I experienced a very proud moment. I published my second book, SQL Server Wait Stats, also acting as its primary author. It has been a long journey since then. The book received a generally great response and it has been widely accepted in the Community ever since its release. It was actually a first-of-its-kind book written to concentrate on the subject of Wait Stats and Performance. The book was based from my month-long blog series about the same subject, SQL Server Wait Stats. Today’s the first anniversary of the book, and lots of things come to my mind. Let me... - [SQL SERVER - Error: Fix - Msg 208 - Invalid object name 'dbo.backupset' - Invalid object name 'dbo.backupfile'](https://blog.sqlauthority.com/2012/08/31/sql-server-error-fix-msg-208-invalid-object-name-dbo-backupset-invalid-object-name-dbo-backupfile/): Just a day before I got a very interesting email. Here is the email (modified a bit to make it relevant to this blog post). “Pinal, We are facing a very strange issue. One of our query  related to backup files and backup set has stopped working suddenly in SSMS. It works fine in application where we have and in the stored procedure but when we have it in our SSMS it gives following error. Msg 208, Level 16, State 1, Line 1 Invalid object name ‘dbo.backupfile’. Here are our queries which we are trying to execute. SELECT name, database_name, backup_size, TYPE,... - [SQL SERVER - Beginning of SQL Server Architecture - Terminology](https://blog.sqlauthority.com/2012/08/30/sql-server-beginning-sql-server-architecture-terminology/): SQL Server Architecture is a very deep subject. Covering it in a single post is an almost impossible task. However, this subject is very popular topic among beginners and advanced users. I have requested my friend Anil Kumar, who is expert in SQL Domain to help me write a simple post about Beginning SQL Server Architecture. As stated earlier, this subject is very deep subject and in this first article series he has covered basic terminologies. In future article he will explore the subject further down. - [SQL SERVER - Three Methods to Insert Multiple Rows into Single Table - SQL in Sixty Seconds #024 - Video](https://blog.sqlauthority.com/2012/08/29/sql-server-three-methods-to-insert-multiple-rows-into-single-table-sql-in-sixty-seconds-024-video/): One of the biggest ask I have always received from developers is that if there is any way to insert multiple rows into a single table in a single statement. Currently when developers have to insert any value into the table they have to write multiple insert statements. First of all this is not only boring it is also very much time consuming as well. Additionally, one has to repeat the same syntax so many times that the word boring becomes an understatement. In the following quick video we have demonstrated three different methods to insert multiple values into a single... - [SQL SERVER - A Brief Note on SET TEXTSIZE](https://blog.sqlauthority.com/2012/08/28/sql-server-a-brief-note-on-set-textsize/): Here is a small conversation I received. I thought, though an old topic, indeed a thought provoking for the moment. Question: Is there any difference between LEFT function and SET TEXTSIZE? - [SQL SERVER - Answer - Value of Identity Column after TRUNCATE command](https://blog.sqlauthority.com/2012/08/27/sql-server-answer-value-of-identity-column-after-truncate-command/): Earlier I had one conversation with reader where I almost got a headache. I suggest all of you to read it before continuing this blog post SQL SERVER – Reseting Identity Values for All Tables. I believed that he faced this situation because he did not understand the difference between SQL SERVER – DELETE, TRUNCATE and RESEED Identity. I wrote a follow up blog post explaining the difference between them. I asked a small question in the second blog post and I received many interesting comments. Let us go over the question and its answer here one more time. Here is the scenario to set... - [SQL SERVER - Download PSSDIAG Data Collection Utility](https://blog.sqlauthority.com/2012/08/26/sql-server-download-pssdiag-data-collection-utility/): During an early career of mine as a database consultant – when I was dealing with SQL Server 2000, I often needed to collect various data related to SQL Server. My favorite tool to collect the data is PSSDIAG tool. It is a general purpose diagnostic collection utility that Microsoft Product Support Services uses to collect various logs and data files. It collects Performance Monitor logs, SQL Profiler traces, SQL Server blocking script output, Windows Event Logs, and SQLDIAG output. The data collected can be used by SQL Nexus tool which help you troubleshoot SQL Server performance problems. PSSDIAG is a wrapper around other data collection... - [SQLAuthority News - Featuring in Call Me Maybe The Developer Way - Pluralsight Video](https://blog.sqlauthority.com/2012/08/25/sqlauthority-news-featuring-in-call-me-maybe-the-developer-way-pluralsight-video/): Is SQL boring? Not at all. SQL is fun – one has to know how to maximize the fun while working with SQL Server. Earlier I was invited to participate in the video Pluralsight. I am sure all of you know that I have authored 3 SQL Server Learning courses with Pluralsight – 1) SQL Server Q and A 2) SQL Server Performance Tuning and 3) SQL Server Indexing. Before I say anything I suggest all of you watch the following video. Make sure that you pay special attention after 0 minute and 36 seconds. [youtube=http://www.youtube.com/watch?v=35U2yIG5oJg] What I can say about... - [SQL SERVER - DELETE, TRUNCATE and RESEED Identity](https://blog.sqlauthority.com/2012/08/24/sql-server-delete-truncate-and-reseed-identity/): Yesterday I had a headache answering questions to one of the DBA on the subject of Reseting Identity Values for All Tables. After talking to the DBA I realized that he has no clue about how the identity column behaves when there is DELETE, TRUNCATE or RESEED Identity is used. Let us run a small T-SQL Script. Create a temp table with Identity column beginning with value 11. The seed value is 11. USE [TempDB] GO -- Create Table CREATE TABLE [dbo].[TestTable]( [ID] [int] IDENTITY(11,1) NOT NULL, [var] [nchar](10) NULL ) ON [PRIMARY] GO -- Build sample data INSERT INTO [TestTable] VALUES... - [SQL SERVER - Reseting Identity Values for All Tables](https://blog.sqlauthority.com/2012/08/23/sql-server-reseting-identity-values-for-all-tables/): Sometime email requesting help generates more questions than the motivation to answer them. Let us go over one of the such examples. I have converted the complete email conversation to chat format for easy consumption. I almost got a headache after around 20 email exchange. I am sure if you can read it and feel my pain. DBA: “I deleted all of the data from my database and now it contains table structure only. However, when I tried to insert new data in my tables I noticed that my identity values starts from the same number where they actually were before... - [SQL SERVER - Color Coding SQL Server Management Studio Status Bar - SQL in Sixty Seconds #023 - Video](https://blog.sqlauthority.com/2012/08/22/sql-server-color-coding-sql-server-management-studio-status-bar-sql-in-sixty-seconds-023-video/): I often see developers executing the unplanned code on production server when they actually want to execute on the development server. Developers and DBAs get confused because when they use SQL Server Management Studio (SSMS) they forget to pay attention to the server they are connecting. It is very easy to fix this problem. You can select different color for a different server. Once you have different color for different server in the status bar, it will be easier for developer easily notice the server against which they are about to execute the script. - [SQL SERVER - Installing Data Quality Services (DQS) on SQL Server 2012](https://blog.sqlauthority.com/2012/08/21/sql-server-installing-data-quality-services-dqs-on-sql-server-2012/): Data Quality Services is very interesting enhancements in SQL Server 2012. My friend and SQL Server Expert Govind Kanshi have written an excellent article on this subject earlier on his blog. Yesterday I stumbled upon his blog one more time and decided to experiment myself with DQS. I have basic understanding of DQS and MDS so I knew I need to start with DQS Client. However, when I tried to find DQS Client I was not able to find it under SQL Server 2012 installation. I quickly realized that I needed to separately install the DQS client. You will find the... - [SQL SERVER - Winners - Contest Win Joes 2 Pros Combo (USD 198)](https://blog.sqlauthority.com/2012/08/20/sql-server-winners-contest-win-joes-2-pros-combo-usd-198/): Earlier this week we had contest ran over the blog where we are giving away USD 198 worth books of Joes 2 Pros. We had over 500+ responses during the five days of the contest. After removing duplicate and incorrect responses we had a total of 416 valid responses combined total 5 days. We got maximum correct answer on day 2 and minimum correct answer on day 5. Well, enough of the statistics. Let us go over the winners’ names. The winners have been selected randomly by one of the book editors of Joes 2 Pros. SQL Server Joes 2 Pros... - [SQLAuthority News - 2 Security Updates for SQL Server 2000 SP 4 Users](https://blog.sqlauthority.com/2012/08/19/sqlauthority-news-2-security-updates-for-sql-server-2000-sp-4-users/): If you are using SQL Server 2000 still today my very first recommendation to you is to upgrade to SQL Server 2012. SQL Server 2000 is now 12 years old product and since then many new enhancements as well features which are relevant to current growth and progress in Informational Industry. Now is the time to catch up with the latest trends. Here is one more point for you to notice if this helps you consider to upgrade to the latest version. One can’t upgrade directly from SQL Server 2000 to SQL Server 2012. You need to first upgrade to either SQL... - [SQLAuthority News - Presented at Bangalore DevCon August 4, 2012](https://blog.sqlauthority.com/2012/08/18/sqlauthority-news-presented-at-bangalore-devcon-august-4-2012/): Bangalore Devcon 2012 was a great fun. Earlier this month I was fortunate to be invited to present at Dev Con. The event was very well planned and had excellent response. There were more than 140 attendees at any time in the sessions. There were two tracks and both tracks were running parallel to each other in the Microsoft Bangalore building. The venue is fantastic and the enthusiasm of the community is impeccable. We had a total of 12 sessions during the day. I had decided to attend each session if I can. We have so many fantastic speakers and I... - [SQL SERVER - Curious Case of Disappearing Rows - ON UPDATE CASCADE and ON DELETE CASCADE - T-SQL Example - Part 2 of 2](https://blog.sqlauthority.com/2012/08/17/sql-server-curious-case-of-disappearing-rows-on-update-cascade-and-on-delete-cascade-t-sql-example-part-2-of-2/): Yesterday I wrote a real world story of how a friend who thought they have an issue with intrusion or virus whereas the issue was really in the code. I strongly suggest you read my earlier blog post Curious Case of Disappearing Rows – ON UPDATE CASCADE and ON DELETE CASCADE – Part 1 of 2 before continuing this blog post as this is second part of the first blog post. Let me reproduce the simple scenario in T-SQL. Building Sample Data USE [TestDB] GO -- Creating Table Products CREATE TABLE [dbo].[Products]( [ProductID] [int] NOT NULL, [ProductDesc] [varchar](50) NOT NULL, CONSTRAINT [PK_Products] PRIMARY KEY... - [SQL SERVER - Curious Case of Disappearing Rows - ON UPDATE CASCADE and ON DELETE CASCADE - Part 1 of 2](https://blog.sqlauthority.com/2012/08/16/sql-server-curious-case-of-disappearing-rows-on-update-cascade-and-on-delete-cascade-part-1-of-2/): Social media has created an Always Connected World for us. On the second day of the event after the learning was over, I noticed lots of notification from my friend on my various social media handle. He had connected with me on Twitter, Facebook, Google+, LinkedIn, YouTube as well SMS, WhatsApp on the phone, Skype messages and not to forget with a few emails. I right away called him up. Let us learn about ON UPDATE CASCADE and ON DELETE CASCADE. - [SQLAuthority News - Technical Review of Learning](https://blog.sqlauthority.com/2012/08/15/sqlauthority-news-technical-review-learning/): I had enrolled for three days training so my routine each of the three days was very much same. However, the content every day was different as I was learning something new every day. Let me describe a few of the interesting details of my daily routine. Let us see a technical review of learning. - [SQLAuthority News - Learning Trip - Learning Quotes](https://blog.sqlauthority.com/2012/08/14/sqlauthority-news-learning-trip-learning-quotes/): I am currently traveling to Delhi to learn SQL Server in person from my friend. In simple words I am on learning trip and here are few of the learning quotes. Learning is extremely important and here are few of the quotes which are related to learning. - [SQLAuthority News - Getting Ready to Learn SQL Server](https://blog.sqlauthority.com/2012/08/13/sqlauthority-news-getting-ready-to-learn-sql-server/): Well, the belief is incorrect that I know a lot. I think there are plenty of things which I have been dreaming to learn SQL Server. - [SQL SERVER - ERROR: FIX using Compatibility Level - Database diagram support objects cannot be installed because this database does not have a valid owner - Part 2](https://blog.sqlauthority.com/2012/08/12/sql-server-error-fix-using-compatibility-level-database-diagram-support-objects-cannot-be-installed-because-this-database-does-not-have-a-valid-owner-part-2/): Earlier I wrote a blog post about how to resolve the error with database diagram. Today I faced the same error when I was dealing with a database which is upgraded from SQL Server 2005 to SQL Server 2008 R2. When I was searching for the solution online I ended up on my own earlier solution SQL SERVER – ERROR: FIX – Database diagram support objects cannot be installed because this database does not have a valid owner. I really found it interesting that I ended up on my own solution. However, the solution to the problem this time was a... - [SQL SERVER - Contest - Summary of 5 Day and Additional Information](https://blog.sqlauthority.com/2012/08/11/sql-server-contest-summary-of-5-day-and-additional-information/):   I am overwhelmed with the response of our contest ran earlier this week. Every day we are giving away USD 198 worth give aways to readers in USA and India. If you have not participated so far, I encourage you to participate today itself. Here are links to our 5 day contest. The winner of the contest will be announced on August 20th. Query Hint – Contest Win Joes 2 Pros Combo (USD 198) – Day 1 of 5 Identity Fields – Contest Win Joes 2 Pros Combo (USD 198) – Day 2 of 5 Clustered Index and Primary Key – Contest... - [SQL SERVER - Understanding XML - Contest Win Joes 2 Pros Combo (USD 198) - Day 5 of 5](https://blog.sqlauthority.com/2012/08/10/sql-server-understanding-xml-contest-win-joes-2-pros-combo-usd-198-day-5-of-5/): August 2011 we ran a contest where every day we give away one book for an entire month. The contest had extreme success. Lots of people participated and lots of give away. I have received lots of questions if we are doing something similar this month. Absolutely, instead of running a contest a month long we are doing something more interesting. We are giving away USD 198 worth gift every day for this week. We are giving away Joes 2 Pros 5 Volumes (BOOK) SQL 2008 Development Certification Training Kit every day. One copy in India and One in USA. Total 2... - [SQL SERVER - Expanding Views - Contest Win Joes 2 Pros Combo (USD 198) - Day 4 of 5](https://blog.sqlauthority.com/2012/08/09/sql-server-expanding-views-contest-win-joes-2-pros-combo-usd-198-day-4-of-5/): August 2011 we ran a contest where every day we give away one book for an entire month. The contest had extreme success. Lots of people participated and lots of give away. I have received lots of questions if we are doing something similar this month. Absolutely, instead of running a contest a month long we are doing something more interesting. We are giving away USD 198 worth gift every day for this week. We are giving away Joes 2 Pros 5 Volumes (BOOK) SQL 2008 Development Certification Training Kit every day. One copy in India and One in USA. Total 2... - [SQL SERVER - Clustered Index and Primary Key - Contest Win Joes 2 Pros Combo (USD 198) - Day 3 of 5](https://blog.sqlauthority.com/2012/08/08/sql-server-clustered-index-and-primary-key-contest-win-joes-2-pros-combo-usd-198-day-3-of-5/): August 2011 we ran a contest where every day we give away one book for an entire month. The contest had extreme success. Lots of people participated and lots of give away. I have received lots of questions if we are doing something similar this month. Absolutely, instead of running a contest a month long we are doing something more interesting. We are giving away USD 198 worth gift every day for this week. We are giving away Joes 2 Pros 5 Volumes (BOOK) SQL 2008 Development Certification Training Kit every day. One copy in India and One in USA. Total 2... - [SQL SERVER - Identity Fields - Contest Win Joes 2 Pros Combo (USD 198) - Day 2 of 5](https://blog.sqlauthority.com/2012/08/07/sql-server-identity-fields-contest-win-joes-2-pros-combo-usd-198-day-2-of-5/): August 2011 we ran a contest where every day we give away one book for an entire month. The contest had extreme success. Lots of people participated and lots of give away. I have received lots of questions if we are doing something similar this month. Absolutely, instead of running a contest a month long we are doing something more interesting. We are giving away USD 198 worth gift every day for this week. We are giving away Joes 2 Pros 5 Volumes (BOOK) SQL 2008 Development Certification Training Kit every day. One copy in India and One in USA. Total 2... - [SQL SERVER - Query Hint - Contest Win Joes 2 Pros Combo (USD 198) - Day 1 of 5](https://blog.sqlauthority.com/2012/08/06/sql-server-query-hint-contest-win-joes-2-pros-combo-usd-198-day-1-of-5/): August 2011 we ran a contest where every day we give away one book for an entire month. The contest had extreme success. Lots of people participated and lots of give away. I have received lots of questions if we are doing something similar this month. Absolutely, instead of running a contest a month long we are doing something more interesting. We are giving away USD 198 worth gift every day for this week. We are giving away Joes 2 Pros 5 Volumes (BOOK) SQL 2008 Development Certification Training Kit every day. One copy in India and One in USA. Total 2... - [SQLAuthority News - Microsoft Whitepaper - AlwaysOn Solution Guide: Offloading Read-Only Workloads to Secondary Replicas](https://blog.sqlauthority.com/2012/08/05/sqlauthority-news-microsoft-whitepaper-alwayson-solution-guide-offloading-read-only-workloads-to-secondary-replicas/): SQL Server 2012 has many interesting features but the most talked feature is AlwaysOn. Performance tuning is always a hot topic. I see lots of need of the same and lots of business around it. However, many times when people talk about performance tuning they think of it as a either query tuning, performance tuning, or server tuning. All are valid points, but performance tuning expert usually understands the business workload and business logic before making suggestions. For example, if performance tuning expert analysis workload and realize that there are plenty of reports as well read only queries on the server... - [SQL SERVER - Fix: Error: 8117: Operand data type bit is invalid for sum operator](https://blog.sqlauthority.com/2012/08/04/sql-server-fix-error-8117-operand-data-type-bit-is-invalid-for-sum-operator/): Here is the very interesting error I received from a reader. He has very interesting question. He attempted to use BIT filed in the SUM aggregation function and he got following error. He went ahead with various different datatype (i.e. INT, TINYINT etc) and he was able to do the SUM but with BIT he faced the problem. Error Received: Msg 8117, Level 16, State 1, Line 1 Operand data type bit is invalid for sum operator. Reproduction of the error: Set up the environment USE tempdb GO -- Preparing Sample Data CREATE TABLE TestTable (ID INT, Flag BIT) GO INSERT INTO... - [SQLAuthority News - Learning Never Ends - Becoming Student Again](https://blog.sqlauthority.com/2012/08/03/sqlauthority-news-learning-never-ends-becoming-student-again/): From my past few blog posts you may see a pattern – learning. I finished my own college education a few years ago, but I firmly believe that learning should never stop. We can learn on the job, or from outside reading, but we should always try to be learning new things. It keeps the brain sharp! In fact, I often find myself learning new things from reviewing old material. This blog post is about becoming student again. - [SQL SERVER - Beginning of SQL Server Security](https://blog.sqlauthority.com/2012/08/02/sql-server-beginning-sql-server-security/): Security is a very important concept and no matter how many times we discuss this it is never enough. I have requested my friend Bharti who is expert in SQL Domain to help me write a simple post about beginning SQL Server security. - [SQL SERVER - 5 Videos from Joes 2 Pros Series Exam Prep Series 70-433 - SQL in Sixty Seconds](https://blog.sqlauthority.com/2012/08/01/sql-server-5-videos-from-joes-2-pros-series-exam-prep-series-70-433-sql-in-sixty-seconds/): Joes 2 Pros SQL Server series is a five part series is written with keeping SQL Server Exam 70-433. It is written with the focus on beginners and who wants to build expertise for SQL Server programming and development from fundamental. Exam is major focus but this series goes beyond exams and keep on focusing on learning the important concepts thoroughly. This book no way takes the short cut to explain any concepts and at times. The best part is that all the books have many companion videos explaining the concepts and videos. Introduction to SQL Server Security Let’s get some basic... - [SQL SERVER - Follow up on Beginning NuoDB - Who will Benefit and How to Start - Part 2](https://blog.sqlauthority.com/2012/08/01/sql-server-follow-up-on-beginning-nuodb-who-will-benefit-and-how-to-start-part-2/): Earlier I blogged about Beginning NuoDB – Who will Benefit and How to Start, I received a few follow up questions about it so I decided to write a short article as a follow up. One of the questions I received was why I started with this product. Well, the reason is that I decided to learn more in the database field. This product got my attention and would like to explore more. I started to play with the NuoDB beta 7 and I am finding it very interesting. There were a few more questions as well and I decided to write... - [SQL SERVER - Beginning NuoDB - Who will Benefit and How to Start](https://blog.sqlauthority.com/2012/07/31/sql-server-beginning-nuodb-who-will-benefit-and-how-to-start/): I finally got some time to play around with the beta 7 release of NuoDB that I downloaded a few weeks ago.  Personally I don’t think NuoDB yet gives downloaders enough information on how to get started so I decided to tackle that here myself. Before I get into the details, why bother?  Who will benefit from this beta? IMHO, if you are working on developing a web-scale app that will require the supporting database to scale a lot, both out and in, then you should try this software.  In working with the NuoDB team, I haven’t had any issues pushing... - [SQLAuthority News - A Year Older and 3 SQL Server Books and 3 Video Courses - 33](https://blog.sqlauthority.com/2012/07/30/sqlauthority-news-an-year-older-and-3-sql-server-books-and-3-video-courses-33/): Today is my birthday. I am 33 today. 33 is an interesting number. There are two 3’s in this number. Curiously, I looked it up in Wikipedia and found out that there is plenty of information about this number. Let me quote a few statements from Wikipedia here. “33 is the largest positive integer that cannot be expressed as a sum of different triangular numbers.” “The sum of the first four positive factorials is 33.” When I was a kid , I had a dream of becoming an author. I attempted to achieve my dream in a variety of ways – I wrote poems, short stories, technical... - [SQL SERVER - Services Pack 2 for SQL Server 2008 R2 - Microsoft SQL Server 2008 R2 Service Pack 2](https://blog.sqlauthority.com/2012/07/29/sql-server-services-pack-2-for-sql-server-2008-r2-microsoft-sql-server-2008-r2-service-pack-2/): Service packs are very critical and important. In the industry I have seen many people waiting for the first service pack to arrive before moving to opting the product. I often see it as a good practice because there are some unknown bugs or missed enhancements in original product which are later covered in the SP2. I believe it is not limited to SQL Server but pretty much true across most of the softwares. Here is a single suggestion, you may delay adopting the product but must not delay in adopting service packs. As soon as they are released, grab them, test... - [SQL SERVER - Difference Between ORIGINAL_LOGIN() and SUSER_SNAME()](https://blog.sqlauthority.com/2012/07/28/sql-server-difference-between-original_login-and-suser_sname/): Today let us start today’s blog post with a simple start question which I was asked by reader of my latest book SQL Server Interview Questions and Answers. Indeed a good question warrants a good answer with a script associated with the same. Question: What is the difference between ORIGINAL_LOGIN() and SUSER_SNAME() and when will I use it? Function ORIGINAL_LOGIN() returns the name of the original or very first login that connected to the instance of SQL Server and it is used to identity of the original login in sessions. If there is an application or database where context switching is happening quite often... - [SQL SERVER - Query to Get Unique Distinct Data Based on Condition - Eliminate Duplicate Data from Resultset](https://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/): Seems like in T-SQL world the issue with Duplicate Records never an old topic. Today lets  quickly go over another question which made it to my mailbox 3 times this week. Question: How do I display only unique records from my table? The natural reaction will be to suggest DISTINCT or GROUP BY. However, not all the questions can be solved by DISTINCT or GROUP BY. Let us see the following example, where a user wanted only latest records to be displayed. Let us see the example to understand further. What the user wanted was not to display every duplicate records... - [SQL SERVER - Answer - How to Convert Hex to Decimal or INT](https://blog.sqlauthority.com/2012/07/26/sql-server-answer-how-to-convert-hex-to-decimal-or-int/): Has it ever happened to you that you say something but forget to follow up due to any reason? It usually does not happen to me as I try to remember everything in my task list but there is always an exception. Last year I asked a question regarding about how to convert Hex to Decimal. I promised that I will post an answer with Due Credit to the author but never got around to post a blog post around it. Read the original post over here SQL SERVER – Question – How to Convert Hex to Decimal. The matter of... - [SQL SERVER - How do I Record Video and Webcast - Milestone - 2200th Blog Post - SQL in Sixty Seconds #022 - Video](https://blog.sqlauthority.com/2012/07/25/sql-server-how-do-i-record-video-and-webcast-milestone-2200th-blog-post-sql-in-sixty-seconds-022-video/): Earlier I used to do Milestone blog posts where at the interval I used to celebrate achievements. However, as time passed the achievements changes their value and importance. We all grow more and more and our priorities are different. However, today I have come across a very interesting milestone! This is my 2200th blog post as well today is our 22nd Episode of SQL in Sixty Seconds Series. SQL in Sixty Seconds series was started with the a very simple concept. Learn something in a very short period of the time. Our life is very busy, we move pretty fast now... - [SQLAuthority Guest Post - Lessons from Life and Work - Power in the Workplace - Srini Chandra (Author of 3 Lives, in search of bliss)](https://blog.sqlauthority.com/2012/07/24/sqlauthority-guest-post-lessons-from-life-and-work-power-in-the-workplace-srini-chandra-author-of-3-lives-in-search-of-bliss/): Power, Fear, and Vulnerability are all part of office politics. I often see the best developers loosing their focus and ability to write beautiful code when they let themselves involve with a power struggle. Power is the interesting factor which everybody want often, but when they have it they are often not trained to use it wisely. In my career I have often seen very few leaders using the power to make a better eco-system. I honestly believe the relationship build on fear will never last. I requested Srini Chandra (renowned author of Amazon Best Seller 3 Lives, in search of bliss... - [SQL SERVER - Observation of Top with Index and Order of Resultset](https://blog.sqlauthority.com/2012/07/23/sql-server-observation-of-top-with-index-and-order-of-resultset/): SQL Server has lots of things to learn and share. It is amazing to see how people evaluate and understand different techniques and styles differently when implementing. There are three different instances where I have come across a situation where I felt that proper understanding is important and something which looks evil may not be evil as suggested. The real reason may be absolutely different but we may blame something totally different for the incorrect results. Scenario 1: Database Tuning Advisor and Incorrect Results One of my friends called me he was stressed out. He just ran a few of Database Tuning... - [SQLAuthority News - 2 SQL Server Documentations Updates](https://blog.sqlauthority.com/2012/07/22/sqlauthority-news-2-sql-server-documentations-updates/): SQL Server is a very fine product and the best part of it is documentation. What I do in weekend is just read the documentation or some weekend project. This weekend I decided to spend on reading documentation. Earlier I downloaded and installed SQL Server 2012 Install Kit during this weekend. Honestly, quite a lot I do not understand as the documentation is quite heavy on terminologies and but that is the best part as it gives us lots of learning! Microsoft SQL Server Data Portability Documentation The SQL Server data portability documentation explains the various mechanisms by which user-created data in SQL Server... - [SQL SERVER - Download SQL Server 2012 Developer Training Kit - Update July 2012](https://blog.sqlauthority.com/2012/07/21/sql-server-download-sql-server-2012-developer-training-kit-update-july-2012/): I just came across newly updated SQL Server 2012 Developer Kit Setup. It is quite convenient and there are many prefers to download setup kit instead of web installer. Developer kit is my favorite feature because it it is a single resource which gives a complete overview of the product in a nutshell. A developer can learn from many places – books, webcasts, tutorials, blogs, etc. However, I have found that developer training kits are the best starting point for any product. Start with them first, see what are the new features as well what is the new message a product is... - [SQL SERVER - INFORMATION_SCHEMA.COLUMNS and Value Character Maximum Length -1 ](https://blog.sqlauthority.com/2012/07/20/sql-server-information_schema-columns-and-value-character-maximum-length-1/): I personally use the sys schema and DMV to retrieve most of the information. However, I am not surprised see usage of Information_Schema. It has been very popular and works in most of the time. Though, I do not use any feature it does not mean everybody else should stop using the same feature. The matter of the fact, when I receive questions about features which I have not used frequently I feel refreshed to come across new concepts. Just a few days ago, I received a simple question about INFORMATION_SCHEMA.COLUMNS table. The question was as follows: Question: I often see the... - [SQL SERVER - Find Column Used in Stored Procedure - Search Stored Procedure for Column Name - Part 2](https://blog.sqlauthority.com/2012/07/19/sql-server-find-column-used-in-stored-procedure-search-stored-procedure-for-column-name-part-2/): Earlier this week I wrote a blog about Find Column Used in Stored Procedure – Search Stored Procedure for Column Name. I received plenty of comments on the subject. One of the statements which I used in the story (Time: Any Day – usually right before developer wants to go home) was very much liked by many developers. I guess this is because we are all like the same. We often get more work, when we are ready to go home. After reading the blog post many readers and SQL Server Experts have posted an enhanced T-SQL script to find column used in a stored procedure. - [SQL SERVER - Generate Script for Schema and Data - SQL in Sixty Seconds #021 - Video](https://blog.sqlauthority.com/2012/07/18/sql-server-generate-script-for-schema-and-data-sql-in-sixty-seconds-021-video/): The biggest request we keep on getting in SQL in Sixty Seconds is tricks with SQL Server Management Studio. It seems like SSMS is our favorite tool and we all want to share our neat tricks with everybody. Today I am going to share very popular and most requested SQL Server Tip. Sample data and test database is very common when working in a development environment. A developer often creates interesting samples as well challenging objects in their database. The architects work on databases and hand it over to developers, later developer hand it over to DBA. In simple words, in many cases the database move from one place to another place. It is not always possible to back up and restore databases. There are possibilities when only part of the database (with schema and data) has to be moved. - [SQLAuthority Guest Post - Lessons from Life - Practice Let Go - Srini Chandra (Author of 3 Lives, in search of bliss)](https://blog.sqlauthority.com/2012/07/17/sqlauthority-guest-post-lessons-from-life-practice-let-go-srini-chandra-author-of-3-lives-in-search-of-bliss/): I often see developers working hard on project, personal development and professional development. The ultimate goal is to progress and achieve something. The definition of progress and growth is very complex and the journey to achieve that is more complex than solving Fermat’s Last Theorem ( x3 + y3 = z3). The question is now how we solve the life’s problem but how we attempt to solve the unknowns. The most complex situation is when we did our best but we get results which we did not expect. I requested Srini Chandra (renowned author of Amazon Best Seller 3 Lives, in search of bliss (Amazon | Flipkart)... - [SQL SERVER - 2012 Functions - FORMAT() and CONCAT() - An Interesting Usage](https://blog.sqlauthority.com/2012/07/16/sql-server-2012-functions-format-and-concat-an-interesting-usage/): Before continuing this blog post I would like to bring your attention to two of my earlier blog post where I have written in depth about FORMAT and CONCAT function. String Function – FORMAT() – A Quick Introduction String Function – CONCAT() – A Quick Introduction Read the above two blog posts if you are interested in learning about the function in depth. Now recently I had need where I have to demonstrate a string on screen like as following: Current Time is Sunday July 16, 2012 This was indeed not difficult for me to do in SQL Server 2012 as I wrote... - [SQL SERVER - Find Column Used in Stored Procedure - Search Stored Procedure for Column Name ](https://blog.sqlauthority.com/2012/07/15/sql-server-find-column-used-in-stored-procedure-search-stored-procedure-for-column-name/): Place: Any Developer Shop Scenario: A developer wants to drop a column from a table Time: Any Day – usually right before developer wants to go home The developer rushes to the manager and following conversation begins: Developer: I want to drop  a column from one of the tables. Manager: Sure, just document it where all the places it is used in our application and come back to me. Developer: We only use stored procedures. Manager: Sure, then documented how many stored procedures are there which are using your column and justify the modification. I will approve it once I see... - [SQL SERVER - Example of Width Sensitive and Width Insensitive Collation](https://blog.sqlauthority.com/2012/07/14/sql-server-example-of-width-sensitive-and-width-insensitive-collation/): I had a great time writing blog post SQL SERVER – Effect of Case Sensitive Collation on Resultset. It was interesting to see lots of questions related to collation based on this blog post. However, one of the question, I find very interesting and though to share today here. Question: What is a width sensitive collation? Can you explain it with an example? I indeed found this question interesting as I see very little awareness of the subject of collation.  I have talked with many and seen very little awareness on width sensitive collation. Let me explain the same with a very simple... - [SQL SERVER - Switch Between Two Parenthesis using Shortcut CTRL+]](https://blog.sqlauthority.com/2012/07/13/sql-server-switch-between-two-parenthesis-using-shortcut-ctrl/): Earlier this week I wrote a blog post about SQL SERVER – CTRL+SHIFT+] Shortcut to Select Code Between Two Parenthesis, I received quite a lot of positive feedback from readers. If you are a regular reader of the blog post, you must be aware that I appreciate the learning shared by readers. Here is another interesting shortcut shared by another SQL Server Expert – Suvendu. He has suggested that using shortcut CTRL+] one can jump between two parenthesis in the code. This is indeed interesting. You can try it out using the following script. SELECT * FROM (SELECT * FROM (SELECT *... - [SQL SERVER - Effect of Case Sensitive Collation on Resultset](https://blog.sqlauthority.com/2012/07/12/sql-server-effect-of-case-sensitive-collation-on-resultset/): Collation is a very interesting concept but I quite often see it is heavily neglected. I have seen developer and DBA looking for a workaround to fix collation error rather than understanding if the side effect of the workaround. Collation is a very deep subject. Earlier I wrote an article how one can resolve the collation error when different collation values are compared. Today in most simple way I would like to explain that different collation can return different result. Without understanding business needs (and sensitivity) one should not change the collation of the columns or database. Let us see a... - [SQL SERVER - Remove Debug Button in SSMS - SQL in Sixty Seconds #020 - Video](https://blog.sqlauthority.com/2012/07/11/sql-server-remove-debug-button-in-ssms-sql-in-sixty-seconds-020-video/): SQL in Sixty Seconds is indeed tremendous fun to do. Every week, we try to come up with some new learning which we can share in Sixty Seconds. In this busy world, we all have sixty seconds to learn something new – no matter how much busy we are. In this episode of the series, we talk about another interesting feature of SQL Server Management Studio. In SQL Server Management Studio (SSMS) we have two button side by side. 1) Execute (!) and 2) Debug (>). It is quite confusing to a few developers. The debug button which looks like a... - [SQLAuthority News - Lessons from Life and Work by Srini Chandra (Author of 3 Lives, In search of Bliss)](https://blog.sqlauthority.com/2012/07/10/sqlauthority-guest-post-lessons-from-life-and-work-by-srini-chandra-author-of-3-lives-in-search-of-bliss/): I requested Srini Chandra (renowned author of Amazon Best Seller 3 Lives, in search of bliss to write a guest post on this subject which developer can read and appreciate. - [SQL SERVER - Monday Morning Puzzle - Query Returns Results Sometimes but Not Always](https://blog.sqlauthority.com/2012/07/09/sql-server-monday-morning-puzzle-query-returns-results-sometimes-but-not-always/): The amount of email I receive sometime it is impossible for me to answer every email. Nonetheless I try to answer pretty much every email I receive. However, quite often I receive such questions in email that I have no answer to them because either emails are not complete or they are out of my domain expertise. In recent times I received one email which had only one or two lines but indeed attracted my attention to it. The question was bit vague but it indeed made me think. The answer was not straightforward so I had to keep on writing the... - [SQLAuthority News - 2 Whitepapers Announced - AlwaysOn Architecture Guide: Building a High Availability and Disaster Recovery Solution](https://blog.sqlauthority.com/2012/07/08/sqlauthority-news-2-whitepapers-announced-alwayson-architecture-guide-building-a-high-availability-and-disaster-recovery-solution/): Understanding AlwaysOn Architecture is extremely important when building a solution with failover clusters and availability groups. Microsoft has just released two very important white papers related to this subject. Both the white papers are written by top experts in industry and have been reviewed by excellent panel of experts. Every time I talk with various organizations who are adopting the SQL Server 2012 they are always excited with the concept of the new feature AlwaysOn. One of the requests I often here is the related to detailed documentations which can help enterprises to build a robust high availability and disaster recovery solution.... - [SQL SERVER - CTRL+SHIFT+] Shortcut to Select Code Between Two Parenthesis](https://blog.sqlauthority.com/2012/07/07/sql-server-ctrlshift-shortcut-to-select-code-between-two-parenthesis/): Every weekend brings creative ideas and accidents brings best unknown secrets in front of us. Just a day while working with complex SQL Server code in SSMS I came across very interesting shortcut which I have never used before and instantly fell in love with it. It is totally possible that you are familiar with this but for me it was the first time and I was surprised that I did know know this short cut so far. - [SQL SERVER - NTFS File System Performance for SQL Server](https://blog.sqlauthority.com/2012/07/06/sql-server-ntfs-file-system-performance-for-sql-server/): Note: Before practicing any of the suggestion of this article, consult your IT Infrastructural Admin, applying the suggestion without proper testing can only damage your system. Question: “Pinal, we have 80 GB of data including all the database files, we have our data in NTFS file system. We have proper backups are set up. Any suggestion for our NTFS file system performance improvement. Our SQL Server box is running only SQL Server and nothing else. Please advise.” - [SQL SERVER - Retrieve SQL Server Installation Date Time](https://blog.sqlauthority.com/2012/07/05/sql-server-retrieve-sql-server-installation-date-time/): I have been asked this question a number of times and my answer always has been “Search online and you will find the answer.” Every single time someone follows my answer, he finds the accurate answer in just a few clicks. However, this question is getting very popular nowadays, so I decided to answer this question through a blog post. Let us learn about how to retrieve SQL Server installation date time. - [SQL SERVER - Tricks to Comment T-SQL in SSMS - SQL in Sixty Seconds #019 - Video](https://blog.sqlauthority.com/2012/07/04/sql-server-tricks-to-comment-t-sql-in-ssms-sql-in-sixty-seconds-019-video/): Code commeting is the one of the most common tasks developers perform. There are two major reasons why developer comment code. 1) During Debug 2) Documenting the code. While debugging the T-SQL code I have often seen developers struggling to comment code.  They spend (or waste) more time in commenting and uncommenting  than doing actual debugging of the procedure.  When I see developer struggling to comment the code I feel little uncomfortable as commenting should be a very easy task over. Today we will see three quick method to comment T-SQL code in Query Editor. There are three different method to... - [SQL SERVER - Monitoring SQL Server Database Transaction Log Space Growth - DBCC SQLPERF(logspace) - Puzzle for You](https://blog.sqlauthority.com/2012/07/03/sql-server-monitoring-sql-server-database-transaction-log-space-growth-dbcc-sqlperflogspace-puzzle-for-you/): First of all – if you are going to say this is very old subject, I agree this is very (very) old subject. I believe in earlier time we used to have this only option to monitor Log Space. As new version of SQL Server released we all equipped with DMV, Performance Counters, Extended Events and much more new enhancements. However, during all this year, I have always used DBCC SQLPERF(logspace) to get the details of the logs. It may be because when I started my career I remember this command and it did what I wanted all the time. - [SQL Authority News - Weekend Project - Visiting Friend's Company](https://blog.sqlauthority.com/2012/07/02/sql-authority-news-weekend-project-visiting-friends-company/): I have decided to do some interesting experiments every weekend and share it next week as a weekend project on the blog. Many times in our business lives and personal lives are very separate, however, this post will talk about one instance where my two lives connect. - [SQL SERVER - Discard Results After Query Execution - SSMS](https://blog.sqlauthority.com/2012/07/01/sql-server-discard-results-after-query-execution-ssms/): The first thing I do any day is to turn on the computer. Today I woke up and as soon as I turned on the computer I saw a chat message from a friend. He was a bit confused and wanted me to help him. Just as usual I am keeping the relevant conversation in focus and documenting our conversation as chat. Let us call him Ajit. Ajit: Pinal, every time I run a query there is no result displayed in the SSMS but when I run the query in my application it works and returns an appropriate result. Pinal:  Have you... - [SQL SERVER - Validating Spatial Object as NULL using IsNULL](https://blog.sqlauthority.com/2012/06/30/sql-server-validating-spatial-object-as-null-using-isnull/): Follow up questions are the most fun part of writing a blog post. Earlier I wrote about SQL SERVER – Validating Spatial Object with IsValidDetailed Function and today I received a follow up question on the same subject. The question was mainly about how NULL is handled by spatial functions. Well, NULL is NULL. It is very easy to work with NULL. There are two different ways to validate if the passed in the value is NULL or not. 1) Using IsNULL Function IsNULL function validates if the object is null or not, if object is not null it will return you value 0... - [SQL SERVER - Validating Spatial Object with IsValidDetailed Function](https://blog.sqlauthority.com/2012/06/29/sql-server-validating-spatial-object-with-isvaliddetailed-function/): What do you prefer – error or warning indicating error may happen with the reason for the error. While writing the previous statement I remember the movie “Minory Report”. This blog post is not about minority report but I will still cover the concept in a single statement “Let us predict the future and prevent the crime which is about to happen in future”. (Please feel free to correct me if I am wrong about the movie concept, I really do not want to hurt your sentiment if you are dedicated fan). Let us switch to the SQL Server world. Spatial... - [SQL SERVER - Fix : Error 3623 - An invalid floating point operation occurred](https://blog.sqlauthority.com/2012/06/28/sql-server-fix-error-3623-an-invalid-floating-point-operation-occurred/): Going back in time, I always had a problem with mathematics. It was a great subject and I loved it a lot but I only mastered it after practices a lot. I learned that mathematics problems should be addressed systematically and being verbose is not a trick, I learned to solve any problem. Recently one of reader sent me an email with the title “Mathematics problem – please help!” and I was a bit scared. I was good at mathematics but not the best. When I opened the email I was relieved as it was Mathematics problem with SQL Server. My friend... - [SQL SERVER - Powershell - Importing CSV File Into Database - Video](https://blog.sqlauthority.com/2012/06/27/sql-server-powershell-importing-csv-file-into-database-video/): Laerte Junior is my very dear friend and Powershell Expert. On my request he has agreed to share Powershell knowledge with us. Laerte Junior is a SQL Server MVP and, through his technology blog and simple-talk articles, an active member of the Microsoft community in Brasil. He is a skilled Principal Database Architect, Developer, and Administrator, specializing in SQL Server and Powershell Programming with over 8 years of hands-on experience. He holds a degree in Computer Science, has been awarded a number of certifications (including MCDBA), and is an expert in SQL Server 2000 / SQL Server 2005 / SQL Server 2008 technologies. Let us read the blog post in his own words. - [SQL SERVER - Weekend Project - Experimenting with ACID Transactions, SQL Compliant, Elastically Scalable Database](https://blog.sqlauthority.com/2012/06/26/sql-server-weekend-project-experimenting-with-acid-transactions-sql-compliant-elastically-scalable-database/): Database technology is huge and big world. I like to explore always beyond what I know and share the learning. Weekend is the best time when I sit around download random software on my machine which I like to call as a lab machine (it is a pretty old laptop, hardly a quality as lab machine) and experiment it. There are so many free betas available for download that it’s hard to keep track and even harder to find the time to play with very many of them.  This blog is about one you shouldn’t miss if you are interested in the... - [SQL SERVER - Template Browser - A Very Important and Useful Feature of SSMS](https://blog.sqlauthority.com/2012/06/25/sql-server-template-browser-a-very-important-and-useful-feature-of-ssms/): Let me start today’s blog post with a direction question. How many of you have ever used Template Browser? Template Browser is a very important and useful feature of SQL Server Management Studio (SSMS). Every time when I am talking about SQL Server there is always someone comes up with the question, why there is no step by step procedure included in SSMS for features. Honestly every time I get this question, the question I ask back is How many of you have ever used Template Browser? I think the answer to this question is most of the time either no or... - [SQL SERVER - Download SQL Server Product Documentation](https://blog.sqlauthority.com/2012/06/24/sql-server-download-sql-server-product-documentation/): Today I just returned from Bangalore User Group Meeting. Attending User Group meeting is indeed fun and really great experience. The best part of the User Group is meeting like minded people and have a great conversation with them. During the meeting I was asked why one has to go online to access SQL Server Product Documentation. I can clearly see there can be many reasons for why one wants the documentation to be available offline. The reasons can be anything but not limited to Company Firewall No Internet (power failure, on road or disaster) Internet Bandwidth Limitatoin Company Proxy Issues... - [SQL SERVER - Introduction to Function SIGN](https://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/): Yesterday I received an email from a friend asking how do SIGN function works. Well SIGN Function is very fundamental function. It will return the value 1, -1 or 0. If your value is negative it will return you negative -1 and if it is positive it will return you positive +1. Let us start with a simple small example. DECLARE @IntVal1 INT, @IntVal2 INT,@IntVal3 INT DECLARE @NumVal1 DECIMAL(4,2), @NumVal2 DECIMAL(4,2),@NumVal3 DECIMAL(4,2) SET @IntVal1 = 9; SET @IntVal2 = -9; SET @IntVal3 = 0; SET @NumVal1 = 9.0; SET @NumVal2 = -9.0; SET @NumVal3 = 0.0; SELECT SIGN(@IntVal1) IntVal1,SIGN(@IntVal2) IntVal2,SIGN(@IntVal3) IntVal3... - [SQL SERVER - Follow up - Usage of $rowguid and $IDENTITY](https://blog.sqlauthority.com/2012/06/22/sql-server-follow-up-usage-of-rowguid-and-identity/): The most common question I often receive is why do I blog? The answer is even simpler – I blog because I get an extremely constructive comment and conversation from people like DHall and Kumar Harsh. Earlier this week, I shared a conversation between Madhivanan and myself regarding how to find out if a table uses ROWGUID or not? I encourage all of you to read the conversation here: SQL SERVER – Identifying Column Data Type of uniqueidentifier without Querying System Tables. In simple words the conversation between Madhivanan and myself brought out a simple query which returns the values of the UNIQUEIDENTIFIER  without... - [SQL SERVER - ColumnStore Index - Batch Mode vs Row Mode](https://blog.sqlauthority.com/2012/06/21/sql-server-columnstore-index-batch-mode-vs-row-mode/): What do you do when you are in a hurry and hear someone say things which you do not agree or is wrong? Well, let me tell you what I do or what I recently did. I was walking by and heard someone mentioning “Columnstore Index are really great as they are using Batch Mode which makes them seriously fast.” While I was passing by and I heard this statement my first reaction was I thought Columnstore Index can use both – Batch Mode and Row Mode. I stopped by even though I was in a hurry and asked the person... - [SQL SERVER - Importing CSV File Into Database - SQL in Sixty Seconds #018 - Video](https://blog.sqlauthority.com/2012/06/20/sql-server-importing-csv-file-into-database-sql-in-sixty-seconds-018-video/): Importing data into database is one of the most important tasks. I often receive questions regarding what is the quickest way to insert CSV data or how to import CSV Data into SQL Server Table. Honestly the process is very simple and the script is even simpler. In today’s SQL in Sixty Seconds Video we will learn how quickly we can insert CSV data into SQL Server. [youtube=http://www.youtube.com/watch?v=ZeCKVwFKXQo] The steps to import CSV are very simple. Create Table Use Bulk Insert to import the data Verify the data Done! Absolutely it is that simple. More on Importing CSV Data: SQL SERVER... - [SQL SERVER - Solution - User Not Able to See Any User Created Object in Tables - Security and Permissions Issue](https://blog.sqlauthority.com/2012/06/19/sql-server-solution-user-not-able-to-see-any-user-created-object-in-tables-security-and-permissions-issue/): There is an old quote “A Picture is Worth a Thousand Words”. I believe this quote immensely. Quite often I get phone calls that something is not working if I can help. My reaction is in most of the cases, I need to know more, send me exact error or a screenshot. Until and unless I see the error or reproduce the scenario myself I prefer not to comment. Yesterday I got a similar phone call from an old friend, where he was not sure what is going on. Here is what he said. “When I try to connect to SQL... - [SQL SERVER - Identifying Column Data Type of uniqueidentifier without Querying System Tables](https://blog.sqlauthority.com/2012/06/18/sql-server-identifying-column-data-type-of-uniqueidentifier-without-querying-system-tables/): I love interesting conversations with related to SQL Server. One of my friends Madhivanan always comes up with an interesting point of conversation. Here is one of the conversation between us. I am very confident this blog post will for sure enable you with some new knowledge. Madhi: How do I know if any table has a uniqueidentifier column used in it? Pinal:  I am sure you know that you can do it through some DMV or catalogue views. Madhi: I know that but how can we do that without using DMV or catalogue views? Pinal: Hm… what can I use? Madhi:... - [SQL SERVER - Read Only Files and SQL Server Management Studio (SSMS)](https://blog.sqlauthority.com/2012/06/17/sql-server-read-only-files-and-sql-server-management-studio-ssms/): Just like any other Developer or DBA SQL Server Management Studio is my favorite application. Any any moment of the time I have multiple instances of the same application are open and I am working on it. Recently, I have come across a very interesting feature in SSMS related to “Read Only” files. I believe it is a little unknown feature as well so decided to write a blog about the same. First create a read only SQL file. You can make any file read by Right Click >> Properties >> Select Attribute Read Only. Now open the same file in... - [SQL SERVER - Simple Explanation and Puzzle with SOUNDEX Function and DIFFERENCE Function](https://blog.sqlauthority.com/2012/06/16/sql-server-simple-explanation-and-puzzle-with-soundex-function-and-difference-function/): Earlier this week I asked a question where I asked how to Swap Values of the column without using CASE Statement. Read here: A Puzzle – Swap Value of Column Without Case Statement,there were more than 50 solutions proposed in the comment. There were many creative solutions. I have mentioned my personal favorite (different ones) here: Solution of Puzzle – Swap Value of Column Without Case Statement. However, I received lots of questions regarding one of the Solution by SIJIN KUMAR V P. He has used the function SOUNDEX in his solution. The request was to explain how SOUNDEX and DIFFERENCE works. Well, there are pretty decent... - [SQLAuthority News - Download Whitepaper Using SharePoint List Data in PowerPivot](https://blog.sqlauthority.com/2011/06/19/sqlauthority-news-download-whitepaper-using-sharepoint-list-data-in-powerpivot/): One of the many features of Microsoft SQL Server PowerPivot is the range of data sources that can be used to import data. Anything, from Microsoft SQL Server relational databases, Oracle databases, and Microsoft Access databases, to text documents, can be used as data sources in PowerPivot. In this paper, I explain one of the new and upcoming data sources that people are excited about – SharePoint list data in the form of Atom feeds. This white paper goes on to explain the different ways you can import SharePoint list data into PowerPivot, what types of lists are supported, various components... - [SQL SERVER - Selecting Domain from Email Address](https://blog.sqlauthority.com/2011/06/18/sql-server-selecting-domain-from-email-address/): Recently I came across a quick need where I needed to retrieve domain of the email address. The email address is in the database table. I quickly wrote following script which will extract the domain and will also count how many email addresses are there with the same domain address. SELECT RIGHT(Email, LEN(Email) - CHARINDEX('@', email)) Domain , COUNT(Email) EmailCount FROM   dbo.email WHERE  LEN(Email) > 0 GROUP BY RIGHT(Email, LEN(Email) - CHARINDEX('@', email)) ORDER BY EmailCount DESC Above script will select the domain after @ character. Please note, if there is more than one @ character in the email, this script will... - [SQL SERVER - Solution - Puzzle - Statistics are not Updated but are Created Once](https://blog.sqlauthority.com/2011/06/17/sql-server-solution-puzzle-statistics-are-not-updated-but-are-created-once/): Earlier I asked puzzle why statistics are not updated. Read the complete details over here: Statistics are not Updated but are Created Once In the question I have demonstrated even though statistics should have been updated after lots of insert in the table are not updated.(Read the details SQL SERVER – When are Statistics Updated – What triggers Statistics to Update) In this example I have created following situation: Create Table Insert 1000 Records Check the Statistics Now insert 10 times more 10,000 indexes Check the Statistics – it will be NOT updated Auto Update Statistics and Auto Create Statistics for database... - [SQL SERVER - Free Online Training on .net and SQL](https://blog.sqlauthority.com/2011/06/16/sql-server-free-online-training-on-net-and-sql/): I around 10 Free Online Training Codes available of .NET and SQL Training from Pluralsight. I am willing to give it to someone who wants learn technology this weekend. You just have to go to my Facebook page and leave a comment explaining in one line – what course will you learn during weekend. I will send all this codes to 10 winners whom I will randomly select using Facebook. Meanwhile do you know how can you generate Zero without using any numbers in T-SQL. My friend Madhivanan has done that and I find it very interesting.Run following T-SQL code –... - [SQL SERVER - Solution - Puzzle - SELECT * vs SELECT COUNT(*)](https://blog.sqlauthority.com/2011/06/15/sql-server-solution-puzzle-select-vs-select-count/): Earlier I have published Puzzle Why SELECT * throws an error but SELECT COUNT(*) does not. This question have received many interesting comments. Let us go over few of the answers, which are valid. Before I start the same, let me acknowledge Rob Farley who has not only answered correctly very first but also started interesting conversation in the same thread. The usual question will be what is the right answer. I would like to point to official Microsoft Connect Items which discusses the same. RGarvao https://connect.microsoft.com/SQLServer/feedback/details/671475/select-test-where-exists-select tiberiu utan http://connect.microsoft.com/SQLServer/feedback/details/338532/count-returns-a-value-1 Rob Farley count(*) is about counting rows, not a particular column.... - [SQLAuthority News - BI Quiz Question - How to Optimize Cube? - Hints](https://blog.sqlauthority.com/2011/06/14/sqlauthority-news-bi-quiz-question-how-to-optimize-cube-hints/): I earlier wrote about SQL BI Quiz over here. The details of the quiz is as following: Working with huge data is very common when it is about Data Warehousing. It is necessary to create Cubes on the data to make it meaningful and consumable. There are cases when retrieving the data from cube takes lots of the time. Let us assume that your cube is returning you data very quickly. Suddenly on one day it is returning the data very slowly. What are the three things will you to diagnose this. After diagnose what you will do to resolve performance... - [SQL SERVER - Watch Online and Download - Inside of Next Generation SQL Server - Best Practices Analyzer using Microsoft Baseline Configuration Analyzer](https://blog.sqlauthority.com/2011/06/14/sql-server-watch-online-and-download-inside-of-next-generation-sql-server-best-practices-analyzer-using-microsoft-baseline-configuration-analyzer/): I presented on subject Inside of Next Generation SQL Server – Denali online at Zeollar.com. This sessions are really fun as they are online, downloadable, and 100% demo oriented. I used SQL Server ‘Denali’ CTP 1 to present on the subject of What is New in Denali. My earlier session on the Topic of Best Practices Analyzer is also available to watch online here: SQL SERVER – Video – Best Practices Analyzer using Microsoft Baseline Configuration Analyzer I enjoyed presenting a lot on above two subjects. I would like to ask your opinion on the same. You can download the sessions... - [SQL SERVER - First Month as DBA Trainee - Disasters and Recovery](https://blog.sqlauthority.com/2011/06/14/sql-server-first-month-as-dba-trainee-disasters-and-recovery/): This blog post is written in response to the T-SQL Tuesday hosted by Allen Kinsel. He has selected very interesting subject for T-SQL Tuesday – Disaster and Recovery. This subject took me in past – my past. There were various things, I had done or proposed when I started very first month as a DBA trainee. I was tagged along with very senior DBA in my organization who always protected me or correct my mistake. He was great guy and totally understand the young mind of over-enthusiastic Trainee DBA. I respect him very much. Here are few things which I had... - [SQL SERVER - Extending SQL Azure with Azure worker role - Guest Post by Paras Doshi](https://blog.sqlauthority.com/2011/06/13/sql-server-extending-sql-azure-with-azure-worker-role-guest-post-by-paras-doshi/): This is guest post by Paras Doshi. Paras Doshi is a research Intern at SolidQ.com and a Microsoft student partner. He is currently working in the domain of SQL Azure. SQL Azure is nothing but a SQL server in the cloud. SQL Azure provides benefits such as on demand rapid provisioning, cost-effective scalability, high availability and reduced management overhead. To see an introduction on SQL Azure, check out the post by Pinal here In this article, we are going to discuss how to extend SQL Azure with the Azure worker role. In other words, we will attempt to write a custom... - [SQL SERVER - PHP on Windows and SQL Server Training Kit](https://blog.sqlauthority.com/2011/06/12/sql-server-php-on-windows-and-sql-server-training-kit/): The PHP on Windows and SQL Server Training Kit includes a comprehensive set of technical content including demos and hands-on labs to help you understand how to build PHP applications using Windows, IIS 7.5 and SQL Server 2008 R2. This release includes the following: PHP & SQL Server Demos Integrating SQL Server Geo-Spatial with PHP SQL Server Reporting Services and PHP PHP & SQL Server Hands On Labs Introduction to Using SQL Server with PHP Using SQL Server Full-Text Search and FILESTREAM Storage with PHP New: Getting Started with SQL Server Migration Assistant for MySQL Download SQL Server PHP on Windows... - [SQL SERVER - Integration Services Balanced Data Distributor - SSIS Balanced Data Distributor](https://blog.sqlauthority.com/2011/06/11/sql-server-integration-services-balanced-data-distributor-ssis-balanced-data-distributor/): Microsoft SSIS Balanced Data Distributor (BDD) is a new SSIS transform. - [SQLAuthority News - Presenting at Tech-Ed On Road - Ahmedabad - June 11, 2011 - Wait Types and Queues](https://blog.sqlauthority.com/2011/06/10/sqlauthority-news-presenting-at-tech-ed-on-road-ahmedabad-june-11-2011-wait-types-and-queues/): I will be presenting in person on the subject SQL Server Wait Types and Queues at Ahmedabad on June 11, 2011. Here is the quick summary of the session. SQL Server Waits and Queues – Your Gateway to Perf. Troubleshooting Time: 11:15am – 12:15pm – June 11, 2011 Just like a horoscope, SQL Server Waits and Queues can reveal your past, explain your present and predict your future. SQL Server Performance Tuning uses the Waits and Queues as a proven method to identify the best opportunities to improve performance. A glance at Wait Types can tell where there is a bottleneck.... - [SQL SERVER - Online Session on What is New in Denali - Today Online](https://blog.sqlauthority.com/2011/06/09/sql-server-online-session-on-what-is-new-in-denali-today-online/): I will be presenting today on subject Inside of Next Generation SQL Server – Denali online at Zeollar.com. This sessions are really fun as they are online, downloadable, and 100% demo oriented. I will be using SQL Server ‘Denali’ CTP 1 to present on the subject of What is New in Denali. The webcast will start at 12:30 PM sharp and will end at 1 PM India Time. It will be 100% demo oriented and no slides. I will be covering following topics in the session. SQL SERVER – Denali Feature – Zoom Query Editor SQL SERVER – Denali – Improvement... - [SQL SERVER - 5 Tips for Improving Your Data with expressor Studio](https://blog.sqlauthority.com/2011/06/08/sql-server-5-tips-for-improving-your-data-with-expressor-studio/): It’s no secret that bad data leads to bad decisions and poor results.  However, how do you prevent dirty data from taking up residency in your data store?  Some might argue that it’s the responsibility of the person sending you the data.  While that may be true, in practice that will rarely hold up.  It doesn’t matter how many times you ask, you will get the data however they decide to provide it. So now you have bad data.  What constitutes bad data?  There are quite a few valid answers, for example: Invalid date values Inappropriate characters Wrong data Values that... - [SQL SERVER - Three Puzzling Questions - Need Your Answer](https://blog.sqlauthority.com/2011/06/07/sql-server-three-puzzling-questions-need-your-answer/): Last week I had asked three questions on my blog. I got very good response to the questions. I am planning to write summary post for each of three questions next week. Before I write summary post and give credit to all the valid answers. I was wondering if I can bring to notice of all of you this week. Why SELECT * throws an error but SELECT COUNT(*) does not This is indeed very interesting question as not quite many realize that this kind of behavior SQL Server demonstrates out of the box. Once you run both the code and... - [SQL SERVER - BI Quiz - Troubleshooting Cube Performance](https://blog.sqlauthority.com/2011/06/06/sql-server-bi-quiz-troubleshooting-cube-performance/): My friend Jacob Sebastian runs SQL BI Quiz competition. Where there are 30 different questions on each day of the month. Winners get opportunity to participate in this Quiz, learn something new and win great awards. Working with huge data is very common when it is about Data Warehousing. It is necessary to create Cubes on the data to make it meaningful and consumable. There are cases when retrieving the data from cube takes lots of the time. Let us assume that your cube is returning you data very quickly. Suddenly on one day it is returning the data very slowly.... - [SQLAuthority News - SQL Server 2008 R2 Update for Developers Training Kit - Download - May Update](https://blog.sqlauthority.com/2011/06/05/sqlauthority-news-sql-server-2008-r2-update-for-developers-training-kit-download-may-update/): I often receive the question what is the quickest way to learn SQL Server 2008 R2. Microsoft have published developers training kit which one can download and learn at your own pace, it has tutorials, videos, and hands-on lab which one can practice. This training kit has been published earlier and has been refreshed in May 2011. The May 2011 update provides support for Windows 7 SP1, Windows Server 2008 R2 SP1 and Visual Studio 2010 SP1. Additionally, any demos or hands-on labs that no longer have a Visual Studio 2008 dependency were updated to Visual Studio 2010. The training kit... - [SQLAuthority News - Download Pre-configured VHD - SQL Server 2008 R2 Standard on Windows Server 2008 R2 SP1 Standard](https://blog.sqlauthority.com/2011/06/05/sqlauthority-news-download-pre-configured-vhd-sql-server-2008-r2-standard-on-windows-server-2008-r2-sp1-standard/): It is extremely simple to test out latest SQL Server 2008 R2. You can even get pre-configured ready to use VHD, which you can download and use it. This becomes very easy as one does not have to do anything besides downloading VHD and installing it on Hyper-V. Download Pre-configured VHD – SQL Server 2008 R2 Standard provides a trusted, productive and intelligent data platform that enables you to run your most demanding mission-critical applications, reduce time and cost of development and management of applications, and deliver actionable insight to your entire organization. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Question to You - When to use Function and When to use Stored Procedure](https://blog.sqlauthority.com/2011/06/04/sql-server-question-to-you-when-to-use-function-and-when-to-use-stored-procedure/): This week has been very interesting week. I have asked few questions to users and have received remarkable participation on the subject. Q1) SQL SERVER – Puzzle – SELECT * vs SELECT COUNT(*) Q2) SQL SERVER – Puzzle – Statistics are not Updated but are Created Once Keeping the same spirit up, I am asking the third question over here. Q3) When to use User Defined Function and when to use Stored Procedure in your development? - [SQLAuthority News - Community Tech Days - TechEd on The Road - Ahmedabad - June 11, 2011](https://blog.sqlauthority.com/2011/06/03/sqlauthority-news-community-tech-days-teched-on-the-road-ahmedabad-june-11-2011/): TechEd on Road is back! In Ahmedabad June 11, 2011! Inviting all Professional Developers, Project Managers, Architects, IT Managers, IT Administrators and Implementers of Ahmedabad to be a part of Tech•Ed on the Road, on 11th June, 2011. We have put together the best sessions from Tech•Ed India 2011 for you in your city. Focal point will be technologies like Database and BI, Windows 7, ASP.NET. REGISTER HERE! Venue: Venue: Ahmedabad Management Association (AMA) Dr. Vikram Sarabhai Marg, University Area, Ahmedabad, Gujarat 380 015 Time: 9:30AM – 5:30PM The biggest attraction of the event is session HTML5 – Future of the... - [SQL SERVER - Puzzle - Statistics are not Updated but are Created Once](https://blog.sqlauthority.com/2011/06/02/sql-server-puzzle-statistics-are-not-updated-but-are-created-once/): After having excellent response to my quiz – Why SELECT * throws an error but SELECT COUNT(*) does not?I have decided to ask another puzzling question to all of you. I am running this test on SQL Server 2008 R2. Here is the quick scenario about my setup. Create Table Insert 1000 Records Check the Statistics Now insert 10 times more 10,000 indexes Check the Statistics – it will be NOT updated Note: Auto Update Statistics and Auto Create Statistics for database is TRUE Expected Result – Statistics should be updated – SQL SERVER – When are Statistics Updated – What... - [SQL SERVER - Creating All New Database with Full Recovery Model](https://blog.sqlauthority.com/2011/06/01/sql-server-creating-all-new-database-with-full-recovery-model/): Sometimes, complex problems have very simple solutions. Let us see the following email which I received recently. “Hi Pinal, In our system when we create new database, by default, they are all created with the Simple Recovery Model. We have to manually change the recovery model after we create the database. We used the following simple T-SQL code: CREATE DATABASE dbname. We are very frustrated with this situation. We want all our databases to have the Full Recovery Model option by default. We are considering the following methods; please suggest the most efficient one among them. 1) Creating a Policy; when... - [SQLAuthority News - Best SQLAuthority Posts of May](https://blog.sqlauthority.com/2011/05/31/sqlauthority-news-best-sqlauthority-posts-of-may/): Month of May is always interesting and full of enthusiasm. Lots of good articles shared and lots of enthusiast communication on technology. This month we had 140 Character Cartoon Challenge Winner. We also had interesting conversation on what kind of lock WITH NOLOCK takes on objects as well. A quick tutorial on how to import CSV files into Database using SSIS started few other related questions. I also had fun time with community activities. I attended MVP Open Day. Vijay Raj also took awesome photos of my daughter – Shaivi. I have gain my faith back in Social Media and have... - [SQL SERVER - Puzzle - SELECT * vs SELECT COUNT(*)](https://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/): Earlier this weekend I have presented at Bangalore User Group on the subject of SQL Server Tips and Tricks. During the presentation I have asked a question to attendees. It was very interesting to see that I have received various different answer to my question. Here is the same puzzle for you and I would like to see what your answer to this question. - [SQL Azure - SQL Azure Throttling and Decoding Reason Codes](https://blog.sqlauthority.com/2011/05/29/sql-azure-sql-azure-throttling-and-decoding-reason-codes/): I was recently reading on the subject SQL Azure Throttling and Decoding Reason Codes and end up reading the article over here. What I really liked is the explanation of the subject with Graphic. I have never seen any better explanation of this subject. I really liked this diagram. However, based on reason code one has to adjust their resource usages. I now wonder do we have any tool available which can directly analysis the reason codes and based on it gives output that what kind of the throttling is happening. One of the idea I immediately got that I can... - [SQL SERVER - A Quick Notes on SQL Azure](https://blog.sqlauthority.com/2011/05/28/sql-server-a-quick-notes-on-sql-azure/): I was recently attending a small meeting where I was asked if I can share few things to be considered when designing SQL Azure database. Today I am sharing the same notes over here. - [SQL SERVER - Copy Database from Instance to Another Instance - Copy Paste in SQL Server](https://blog.sqlauthority.com/2011/05/27/sql-server-copy-database-from-instance-to-another-instance-copy-paste-in-sql-server/): SQL Server has a feature which copy database from one database to another database and it can be automated as well using SSIS. - [SQL SERVER - Getting Columns Headers without Result Data - SET FMTONLY ON](https://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/): I was recently watching a videos online of TechEd 2011 USA (link) and I learned that SET FMTONLY ON is going to be replaced with enhanced DMVs in future versions of SQL Server. I really liked the new direction of the product. However, SET FMTONLY ON is really have done its job so far. I have used it many times so far and always find it useful. SET FMTONLY ON returns only metadata to the client. It can be used to test the format of the response without actually running the query. When this setting is ON the resultset only have... - [SQLAuthority News - Most Valuable Photographer - Vijay Raj](https://blog.sqlauthority.com/2011/05/25/sqlauthority-news-most-valuable-photographer-vijay-raj/): A good snapshot stops a moment from running away.  ~Eudora Welty If I could tell the story in words, I wouldn’t need to lug around a camera.  ~Lewis Hine Vijay Raj is a passionate Technology Evangelist and a Microsoft MVP. He recently took few snaps of my daughter. As soon as he put the images on his album online, it was instant hit and was wallpaper of many desktops. Every praise one does for Vijay is not enough. I personally have no words to express my feeling after looking at the photos he has taken. If you really like the photos,... - [SQL SERVER - What is SQL Azure](https://blog.sqlauthority.com/2011/05/24/sql-server-sql-azure/): A very common question which I often receive is What is SQL Azure? - [SQL SERVER - Running SSIS Package in Scheduled Job](https://blog.sqlauthority.com/2011/05/23/sql-server-running-ssis-package-in-scheduled-job/): I previously wrote article SQL SERVER – Import CSV File into Database Table Using SSIS. I was asked following question by reader that how to run the same SSIS package from command prompt. In response to the same I have written article SQL SERVER – Running SSIS Package From Command Line. Within few minutes of the blog post, I received email from another blog reader asking if this can be scheduled in SQL Server Agent Job. - [SQL SERVER - Download PowerPivot Security Architecture Diagram ](https://blog.sqlauthority.com/2011/05/22/sql-server-download-powerpivot-security-architecture-diagram/): Security Architecture Diagram is very interesting and very important aspect of the database. I am currently attending the MVP Open Day event and one of the attendee asked if I can write about PowerPivot Security Architecture. This subject is very well explained earlier using diagram by Microsoft. Microsoft has published poster which explains this security architecture diagram. Included in this diagram are: Service Accounts SharePoint Databases Security Hardening Automatic Data Refresh User Identity Flow PowerPivot Permissions Levels Download PowerPivot Security Architecture Technical diagram (.pdf) Download PowerPivot Security Architecture Technical diagram (.vsd) Download PowerPivot Security Architecture Technical diagram (.xps) Reference : Pinal... - [SQL SERVER - Running SSIS Package From Command Line](https://blog.sqlauthority.com/2011/05/21/sql-server-running-ssis-package-from-command-line/): I previously wrote article SQL SERVER – Import CSV File into Database Table Using SSIS. I was asked following question by reader that how to run the same SSIS package from command prompt. This is really interesting question and very easy one as well. You can execute SSIS Package using command line utility. C:\>dtexec.exe /F "C:\ImportCSV\Package.dtsx" When you run above command it will give you start time, end time and total progress of the package as well. There are various options of the DTEXEC available you can see that using dtexec.exe /? In future we will see how the SSIS task can... - [SQL SERVER - Management Studio and Browser in Same Application - SSMS Browser](https://blog.sqlauthority.com/2011/05/20/sql-server-management-studio-and-browser-in-same-application/): First of all - I must confess that I was not aware of this feature till I noticed it today. At home, I have multiple monitors, but when I am traveling, I have single laptop along with me. It is often that when I am working with SQL Server I have to refer web for information on the subject I am working on. Let us understand about SSMS Browser in this blog post. - [SQL SERVER - Connecting to Server Using Windows Authentication by SQLCMD](https://blog.sqlauthority.com/2011/05/19/sql-server-connecting-to-server-using-windows-authentication-by-sqlcmd/): Recently I got a call from an old friend I used to call “DJ”. Here is the exact conversation we had about SQLCMD. - [SQL SERVER - FIX - ERROR - Service Logon Failure (ObjectExplorer)](https://blog.sqlauthority.com/2011/05/18/sql-server-fix-error-service-logon-failure-objectexplorer/): Just another day I received following error while starting my agent. As soon as I received following error I felt like Deja Vu. I had similar feeling few days ago. I quickly looked at my blog post history and I found out following article SQL SERVER – Fix : Error : The request failed or the service did not respond in timely fashion. Consult the event log or other applicable error logs for details. TITLE: Microsoft SQL Server Management Studio —————————— Unable to start service SQLSERVERAGENT on server PINALKUMAR. (mscorlib) —————————— ADDITIONAL INFORMATION: Service Logon Failure (ObjectExplorer) Indeed this was again... - [SQLAuthority News - Facebook Page and Twitter - Connect Using Social Media](https://blog.sqlauthority.com/2011/05/17/sqlauthority-news-facebook-page-and-twitter-connect-using-social-media/): I often get question if I am active on social media. I am very much active on social media. I have noticed that we have all are active on Facebook, I have created Facebook page where you can do discussion and follow on my updates. SQLAuthority.com Page I am very active on twitter as well – you can follow me there as well. Twitter: @pinaldave You can subscribe to SQLAuthority.com blog posts using email as well, this way you will get daily doze of SQL in your mail box. Subscribe to SQLAuthority.com Via Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Server Compression Estimator](https://blog.sqlauthority.com/2011/05/16/sql-server-sql-server-compression-estimator/): I recently come across an interesting tool called 'SQL Server Compression Estimator'. I find this tool very interesting. This tool is a pretty decent tool and I used it on a couple of my personal server and it gave me a good estimate. - [SQL SERVER - Attending MVP Open Day - May 2011](https://blog.sqlauthority.com/2011/05/15/sql-server-attending-mvp-open-day-may-2011/): The MVP Open Day is an exclusive event for Asia Pacific & Greater China MVPs. MVPs from the region gather and have great time together. It is mix of education, fun and networking. I have previously written my experience over here. SQLAuthority News – MVP Open Day South Asia – Jan 20, 2010 – Jan 23, 2010 – Review Part Fun SQLAuthority News – MVP Open Day South Asia – Jan 20, 2010 – Jan 23, 2010 – Review Part Business SQLAuthority News – Author Visit – South Asia MVP Open Day 2008 – Goa – Group Photo This year again,... - [SQLAuthority News - Restart Remote Computer - Shutdown Remote Computer](https://blog.sqlauthority.com/2011/05/14/sqlauthority-news-restart-remote-computer-shutdown-remote-computer/): I often work with multiple computer system. This machines are different machines. When I login using remote desktop to different machine, I often want to restart or shutdown the computer. Remote desktop does not let me shutdown computer when I have remote system as Windows 7. At this time, I walk myself to the physical computer and restart the machine. This is not convenient if I am doing it often. I recently searched for command prompt solution for the same and I learned it today. If you are going to say this is so 90s. Well, I am late by 20... - [SQL SERVER - Vote for My Session in SQL PASS](https://blog.sqlauthority.com/2011/05/13/sql-server-vote-for-my-session-in-sql-pass/): Please Vote for My Session in SQL PASS SQL Server Waits and Queues – Your Gateway to Performance Troubleshooting Session Level: 300 Session Category: Regular Session (75 minutes) Session Track: Enterprise Database Administration and Deployment Just like a horoscope, SQL Server Waits and Queues can reveal your past, explain your present and predict your future. SQL Server Performance Tuning uses the Waits and Queues as a proven method to identify the best opportunities to improve performance. A glance at Wait Types can tell where there is a bottleneck. Learn how to identify bottlenecks and potential resolutions in this fast paced, advanced... - [SQL SERVER - Import CSV File into Database Table Using SSIS](https://blog.sqlauthority.com/2011/05/12/sql-server-import-csv-file-into-database-table-using-ssis/): It is very frequent request to upload CSV file to database or Import CSV file into database. I have previously written article how one can do this using T-SQL over here SQL SERVER – Import CSV File Into SQL Server Using Bulk Insert – Load Comma Delimited File Into SQL Server. - [SQL SERVER – expressor 3.2 Release Review](https://blog.sqlauthority.com/2011/05/11/sql-server-expressor-3-2-release-review/): I have been following expressor software for some time now and they have recently released a new version of their expressor Studio desktop ETL application. I am pleased to find out that the download and installation experience of this application has been greatly simplified. expressor Studio no longer requires users to install a license key after they download and install the product. They have also eliminated a Microsoft Visio dependency from their product. Removing the license requirement and Visio dependency has made download and installation much easier. - [SQL SERVER - Resource Database ID - 32767](https://blog.sqlauthority.com/2011/05/10/sql-server-resource-database-id-32767/): Earlier I blogged about SQL SERVER – What Kind of Lock WITH (NOLOCK) Hint Takes on Object?. After reading the post, I got question by one of the blog reader. “Hi Pinal, I see in your blog post you have Database ID which is 32767. Everytime I want to get the name of the database from database_ID I use following function but this time this function returned NULL. SELECT DB_NAME(32767) When I tried to list all the databases uses following script it did not have that database ID as well. SELECT * FROM sys.databases I assume you have created this many database... - [SQL SERVER - Common Table Expression (CTE) and Few Observation](https://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/): This blog post is written in response to the T-SQL Tuesday hosted by Bob Pusateri. He has picked very interesting topic which is related to APPLY clause of the T-SQL. When I read the subject, I really liked the subject. This is very new subject and it is quite a interesting choice by Bob. Common Table Expression (CTE) are introduced in SQL Server 2005 so it is available with us from last 6 years. Over the years I have seen lots of implementation of the same as well lots of misconceptions. Earlier I had presented on this subject many places. Here... - [SQL SERVER - SQL Server Management Pack Guide for System Center Operations Manager 2007](https://blog.sqlauthority.com/2011/05/09/sql-server-sql-server-management-pack-guide-for-system-center-operations-manager-2007/): The SQL Server Management Pack provides the capabilities for Operations Manager 2007 SP1 and R2 to discover SQL Server 2005, 2008, and 2008 R2. It monitors SQL Server components such as database engine instances, databases, and SQL Server agents. The monitoring provided by this management pack includes performance, availability, and configuration monitoring, performance data collection, and default thresholds. You can integrate the monitoring of SQL Server components into your service-oriented monitoring scenarios. In addition to health monitoring capabilities, this management pack includes dashboard views, extensive knowledge with embedded inline tasks, and views that enable near real-time diagnosis and resolution of detected... - [SQL SERVER - What Kind of Lock WITH (NOLOCK) Hint Takes on Object?](https://blog.sqlauthority.com/2011/05/08/sql-server-what-kind-of-lock-with-nolock-hint-takes-on-object/): Recently I was talking with Vinod Kumar regarding NOLOCK. Suddenly he asked me do I know what kind of lock WITH(NOLOCK) hint takes on object. The immediate response of mine was that NOLOCK does not take any lock. He responded suggesting that I should think more and answer. I realized right after his suggestion to think harder and I said Schema Lock. Yes, WITH(NOLOCK) hint takes Schema Lock on the object which is accessed. Here is the script to prove it. Step 1: Run following script with query hint NOLOCK SELECT * FROM sys.all_objects a WITH (NOLOCK) CROSS JOIN sys.all_objects b... - [SQL SERVER - 2008 - 2008 R2 - Create Script to Copy Database Schema and All The Objects - Data, Schema, Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects](https://blog.sqlauthority.com/2011/05/07/sql-server-2008-2008-r2-create-script-to-copy-database-schema-and-all-the-objects-data-schema-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/): Quite often I get the request regarding how to copy all the objects – including schema and data from any database and re-create it on another instance. SQL Server 2008 and SQL Server 2008 R2 has script generator wizard which does it for us. I ask you to pay special attention to image #5. After the script is generated, the next challenge often users face is how to execute this large script as SQL Server Management Studio does not open the file. One can use SQLCMD for the same. See that in the last image of this post. Pay attention to... - [SQL SERVER - Video - Best Practices Analyzer using Microsoft Baseline Configuration Analyzer](https://blog.sqlauthority.com/2011/05/06/sql-server-video-best-practices-analyzer-using-microsoft-baseline-configuration-analyzer/): Yesterday I presented on the subject Check SQL Server Health using Best Practices Analyzer. There was great response to the session. Many asked me if the session is recorded so they can watch it later on. Absolutely, the session is recorded and you can watch it at your convince. Not only you can watch the session online but can also download the same and watch it while traveling or on your Windows Phone. Video of Check SQL Server Health using Best Practices Analyzer If you want to download the resources which I have used in this presentation here is the link... - [SQL SERVER - Presenting on Best Practices Analyzer using Microsoft Baseline Configuration Analyzer](https://blog.sqlauthority.com/2011/05/05/sql-server-presenting-on-best-practices-analyzer-using-microsoft-baseline-configuration-analyzer/): Today (May 5, 2011) I will be presenting on Presenting on Best Practices Analyzer using Microsoft Baseline Configuration Analyzer at . I will be presenting on following subjects. The tools which I will be using in the demonstration are following: Engine – Backups outdated for databases Engine – Database files and backups exist on the same volume Engine – SQL Server tempdb database not configured optimally Engine – Authentication Mode Engine – Database consistency check not current Engine – Databases using simple recovery model Microsoft Baseline Configuration Analyzer 2.0 Microsoft Baseline Configuration Analyzer 2.0 (MBCA 2.0) can help you maintain optimal system... - [SQL SERVER - Cartoon Challenge - 140 Character Winner is Here](https://blog.sqlauthority.com/2011/05/04/sql-server-cartoon-challenge-140-character-winner-is-here/): Earlier Idera has announced contest where participant can win Windows Mobile Phone by writing 140 character. Here is the details of the contest SQLAuthority News – Win Windows Phone from Idera in 140 Characters – A Cartoon Challenge of SQL. We received more than 200 comments on the blog post and more than 250 qualifying entries. It was not possible to pick winner out of all those entries. I reached out to good folks at Idera for helping me select the winner. After going back and forward and with lots of revision we come up with winning entry. Idera has also... - [SQL SERVER - Interview on Wait Types and Wait Queues - SQL Doctor](https://blog.sqlauthority.com/2011/05/04/sql-server-interview-on-wait-types-and-wait-queues/): Earlier this year I have written a whole month on the subject SQL Server Wait Types and Wait Queues SQL SERVER – Summary of Month – Wait Type – Day 28 of 28. The focus of this series was very simple - define a problem and solve it. I learned a lot while I wrote this series. While I am writing this blog, I am very much delighted that SQL Doctor team of Idera software is very kind to implement a few of the tricks from the blog post. - [SQL SERVER - Error: Failed to retrieve data for this request. Microsoft.SqlServer.Management.Sdk.Sfc - 'DATABASEPROPERTY' is not a recognized built-in function name. (Microsoft SQL Server, Error: 195)](https://blog.sqlauthority.com/2011/05/03/sql-server-error-failed-to-retrieve-data-for-this-request-microsoft-sqlserver-management-sdk-sfc-databaseproperty-is-not-a-recognized-built-in-function-name-microsoft-sql-server-error-1/): I have four different machine at home. Office Laptop – Provided by work organization Personal Laptop – My wife uses it Demo Machine – A very old machine – I think I can only do demo of my messenger only – it is 32 bit – single CPU 1 GB RAM I work with SQL Server 2008 (R2) and SQL Server ‘Denali’ and often connect to both the instances. Recently while I was connecting to Denali I encountered following error. Failed to retrieve data for this request. Microsoft.SqlServer.Management.Sdk.Sfc) ‘DATABASEPROPERTY’ is not a recognized built-in function name. (Microsoft SQL Server, Error: 195)... - [SQL SERVER - Performance Improvement with of Executing Stored Procedure with Result Sets in SQL Server 2012](https://blog.sqlauthority.com/2011/05/02/sql-server-performance-improvement-with-of-executing-stored-procedure-with-result-sets-in-denali/): Earlier I posted article SQL SERVER – Denali – Executing Stored Procedure with Result Sets. After reading this SQL Expert Ramdas asked following and very interesting question: This is a nice feature and i am sure would be used a lot. How is the performance of this as compared with using temp tables? I really loved this question, I ran the following code and measured the performance difference using execution plans. USE AdventureWorks2008R2 GO CREATE PROCEDURE mySP (@ShiftID INT) AS SELECT [ShiftID] ,[Name] ,[StartTime] ,[EndTime] ,[ModifiedDate] FROM [HumanResources].[Shift] WHERE [ShiftID] = @ShiftID GO -- Executing Stored Procedure EXEC mySP @ShiftID = 2... - [SQL SERVER - Migration Assistant for Access, MySQL, Oracle, Sybase](https://blog.sqlauthority.com/2011/05/01/sql-server-migration-assistant-for-access-mysql-oracle-sybase/): SQL Server Migration Assistant (SSMA) is a free supported tool from Microsoft that simplifies database migration process from Sybase Adaptive Server Enterprise (ASE) to SQL Server or SQL Azure. SSMA automates all aspects of migration including migration assessment analysis, schema and SQL statement conversion, data migration as well as migration testing. SSMA for Access 5.0 Microsoft SQL Server Migration Assistant (SSMA) for Access is a tool to automate migration from Microsoft Access database(s) to SQL Server or SQL Azure. SSMA for MySQL 5.0 Microsoft SQL Server Migration Assistant (SSMA) for MySQL is a tool to automate migration from MySQL database to... - [SQL SERVER - CTAS - Create Table As SELECT - What is CTAS?](https://blog.sqlauthority.com/2011/04/30/sql-server-ctas-create-table-as-select-what-is-ctas/): I have been working with the database for many years and I am aware of many common terminologies. Recently I was attending training myself and the instructor used the word 'CTAS' in the class. One of the attendees did not know the definition of this abbreviation. From this, I realized that not all of us come from the same background and we all have different levels and areas of expertise. - [SQL SERVER - 2012 - Executing Stored Procedure with Result Sets - New](https://blog.sqlauthority.com/2011/04/29/sql-server-2012-executing-stored-procedure-result-sets-new/): After reading my earlier article SQL SERVER – Denali – Executing Stored Procedure with Result Sets, one of the readers asked if this new feature (syntax) support multiple resultset of the stored procedure? Very interesting question indeed as most of the stored procedures that I usually come across have more than one resultset. I quickly look up the syntax online and realize it can be done quite easily. If you are using the earlier method of the temp table inserting the value of the stored procedure by executing, then the it does not support multiple resultset. This new capability of T-SQL can... - [SQL SERVER - 2012 - Executing Stored Procedure with Result Sets](https://blog.sqlauthority.com/2011/04/28/sql-server-denali-executing-stored-procedure-with-result-sets/): Here is a normal conversation I heard when I saw that the function (UDF) was used instead of the procedure (SP). Q: Why are you using User Defined Function instead of Stored Procedure? A: I cannot SELECT from SP, but I can from UDF. SQL Server’s next version ‘Denali’ is coming up with a very interesting feature called WITH RESULT SET. Using this feature, you can run the stored procedure and rename the columns used in it. The usual procedure of creating TempTable, executing the stored procedure and inserting the data into the TempTable may be time-consuming, that is why Denali... - [SQL SERVER - Introduction to SQL Azure - Creating Database and Connecting Database](https://blog.sqlauthority.com/2011/04/27/sql-server-introduction-to-sql-azure-creating-database-and-connecting-database/): I recently logged into new Azure Portal and I really think the product team has done excellent job to make it user-friendly and self intuitive. Here are the quick steps I have done after I logged into the portal here: Purchased subscription Created Server Created Database Connect using Database Honestly it is that simple. Here is the screen representations of the same.   Here you can specify your current IP address in start and end range. This way only from your IP you can connect to the server. I have noticed that one developer kept the IP Range Start: 0.0.0.0 and... - [SQLAuthority News - Pluralsight On-Demand FREE for SQL Server Course](https://blog.sqlauthority.com/2011/04/26/sqlauthority-news-pluralsight-on-demand-free-for-sql-server-course/): The Moral of Story You can watch the most popular SQL Server – TSQL course on Pluralsight On-Demand for FREE for the next 48 hours. It starts NOW! The Story Learning is always difficult. After learning how to apply your knowledge, learning in real life is even more difficult. Technology is moving faster than the speed of light and new technologies are always emerging – this is now the reality of the new technology world. Between all of this, I personally have very little time to learn new technology. I do not like eBooks (this statement warrants a whole new blog... - [SQLAuthority News - 1700th Blog Posts - Over 25 Millions of Views - A SQL Milestone](https://blog.sqlauthority.com/2011/04/25/sqlauthority-news-1700th-blog-posts-over-25-millions-of-views-a-sql-milestone/): It has been a tradition in this blog to write a “milestone blog post” for every 100th post. I am always looking forward to this because I am given a chance to do only three times a year. This year 2011 has been very nice to me so far- lots of interesting things have been happening. I listed a few here: (in no particular order) SQL SERVER – Summary of Month – Wait Type – Day 28 of 28 My series on wait types and queues has made me a whole different person. I have started to look at the database... - [SQL SERVER - How to ALTER CONSTRAINT](https://blog.sqlauthority.com/2011/04/24/sql-server-how-to-alter-constraint/): After reading my earlier blog post SQL SERVER – Prevent Constraint to Allow NULL. I recently received question from user regarding how to alter the constraint. No. We cannot alter the constraint, only thing we can do is drop and recreate it. Here is the CREATE and DROP script. CREATE DATABASE TestDB GO USE TestDB GO CREATE TABLE TestTable (ID INT, Col1 INT, Col2 INT) GO -- Create Constraint on Col1 ALTER TABLE TestTable ADD CONSTRAINT CK_TestTable_Col1 CHECK (Col1 > 0) GO -- Dropping Constraint on Col1 ALTER TABLE TestTable DROP CONSTRAINT CK_TestTable_Col1 GO -- Clean up USE MASTER GO ALTER... - [SQL SERVER - How to Use Decode in SQL Server?](https://blog.sqlauthority.com/2011/04/23/sql-server-using-decode-in-sql-server/): One of the reader of the blog has sent me question regarding how to use DECODE function in SQL Server. - [SQL SERVER - Potential Bottlenecks for Performance](https://blog.sqlauthority.com/2011/04/22/sql-server-potential-bottlenecks-for-performance/): In recent GIDS presentation, I was asked can I name potential bottlenecks for performance. I was taken back to my collage life with this question. I remember that I have memorized following names as potential bottlenecks. CPU RAM Hard Disk Network Application Code Today when I look back at this, I still think the same reference is correct. It seems very interesting that technology has really moved ahead but the essence and basics of  any subject are still same. Can you think of any other kind of bottleneck, which is not subset of above five topics which I have mentioned. Reference:... - [SQL SERVER - Prevent Constraint to Allow NULL ](https://blog.sqlauthority.com/2011/04/21/sql-server-prevent-constraint-to-allow-null/): With naked eyes, we often spot the evident problems but the specific details are missed many a time. Something similar happened recently. One of the blog readers sent me an email asking about a bug in how CHECK CONSTRAINT works. He suggested that check constraint accepts NULL even though the rule is specified. After looking at the whole script, I found out what he has done and how to prevent this type of error. Let us first reproduce the script where the constraint allows NULL value in the column. CREATE DATABASE TestDB GO USE TestDB GO CREATE TABLE TestTable (ID INT,... - [SQLAuthority News - Last 5 Days to WIN Windows Phone 7 - 140 Words to Win](https://blog.sqlauthority.com/2011/04/20/sqlauthority-news-last-5-days-to-win-windows-phone-7-140-words-to-win/): You can win Windows 7 Phone by writing only 140 Characters. You need to leave a comment over here: SQLAuthority News – Win Windows Phone from Idera in 140 Characters – A Cartoon Challenge of SQL over here. There are so far around 150 comments and I believe that chances of one person to win the contest is pretty decent. I have been personally using Windows 7 Phone for quite a some time and I really love it. Follow me on twitter to keep updated with updates. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Sudden Death of SSD on my Laptop - A Warning for SSD Users](https://blog.sqlauthority.com/2011/04/19/sqlauthority-news-sudden-death-of-ssd-on-my-laptop-a-warning-for-ssd-users/): The solid state drive on my personal laptop just died. Here’s the story. I have a DELL XPS laptop which is now 2.5 years old. The laptop had demonstrated no issues. About 6 months ago, I decided to upgrade the hard drive to solid state drive. There was a lot of hype in the market for SSD and it seemed that everybody is praising it. After thinking about it, I­­ finally chose to upgrade my personal laptop by purchasing SSD it with Rs. 15,000 (~USD 320). The SSD that I bought contains 120 GB and supports TRIM as well. For six... - [SQL SERVER - Speaking on T-SQL Worst Practices at Great Indian Developer Summit 2011 - Bangalore](https://blog.sqlauthority.com/2011/04/18/sql-server-speaking-on-t-sql-worst-practices-at-great-indian-developer-summit-2011-bangalore/): Presenting in front of techies is always fun. I will be speaking at Great Indian Developer Summit 2011 – Bangalore on April 19, 2011. Here is the details of my session: Session Title:“What did I do?” – T-SQL Worst Practices “Oh My God! What did I do?” Chances are you have heard, or even uttered, this expression. This demo-oriented session will have many examples where developers were dumbfounded by their own mistakes. The goal of this session is to learn which small details can be dangerous to the production environment and SQL Server as a whole. We will talk about common... - [SQL SERVER - Applying NOLOCK Hint at Query Level - NOLOCK for whole Transaction](https://blog.sqlauthority.com/2011/04/17/sql-server-applying-nolock-hint-at-query-level-nolock-for-whole-transaction/): Just received very interesting question in email: “How do I apply NOLOCK hint to my whole query. I know that I can use NOLOCK at every table level but I have many tables in my query and I want to apply the same to all the tables. I want to do something like following script. SELECT * FROM AdventureWorks.Sales.SalesOrderDetail sod INNER JOIN AdventureWorks.Sales.SalesOrderHeader soh ON sod.SalesOrderID = soh.SalesOrderID ORDER BY sod.ModifiedDate OPTION (NOLOCK) When I ran it it gives me following error: Msg 102, Level 15, State 1, Line 7 Incorrect syntax near ‘NOLOCK’. Please recommend.” I just never thought of... - [SQL SERVER - Making Database to Read Only - Changing Database to Read/Write](https://blog.sqlauthority.com/2011/04/16/sql-server-making-database-to-read-only-changing-database-to-readwrite/): I recently received the following comments on my earlier blog about Making database to read only. "Today i was trying to attach the (MDF,NDF,LDF ) sql server 2008 database which i have received from my client. After attachment the database status is showing (Read-Only) (Eg.database name (Read-Only). How do i make to normal mode for the data updation. is there any query available to resolve this problem. Your help will be highly helpful." Let's learn Making Database to Read Only and Changing Database to Read/Write. - [SQL SERVER - Finding Location of Log File when Primary Datafile is Crashed](https://blog.sqlauthority.com/2011/04/15/sql-server-finding-location-of-log-file-when-primary-datafile-is-crashed/): My friend and SQL Expert Vinod Kumar asked a very interesting question in his latest blog post. Quick Quiz:Do you need the primary data file available to backup your transaction log after a crash? This question can have multiple answers. While he asked the question on blog, I was sitting very next to him and he asked what do I think about it. We had less than 10 minutes during the lunch break after which we had to get back on work. To simulate Primary Datafile is corrupted (again please note – this is just a quick exercise and not real... - [SQL SERVER - Transaction Log Impact Detection Using DMV - dm_tran_database_transactions ](https://blog.sqlauthority.com/2011/04/14/sql-server-transaction-log-impact-detection-using-dmv-dm_tran_database_transactions/): Just a few days ago before I received the email from blog reader asking if there is any DMV which can provide details about the effect of a transaction on the transaction log file. Absolutely! Here is a quick script which can provide the necessary details: SELECT transaction_id, DB_NAME(database_id) DatabaseName, database_transaction_begin_time TransactionBegin, CASE database_transaction_type WHEN 1 THEN 'Read/Write' WHEN 2 THEN 'Read only' WHEN 3 THEN 'System' END AS TransactionType, CASE database_transaction_state WHEN 1 THEN 'Not Initialized' WHEN 3 THEN 'Transaction No Log' WHEN 4 THEN 'Transaction with Log' WHEN 5 THEN 'Transaction Prepared' WHEN 10 THEN 'Commited' WHEN 11 THEN 'Rolled... - [SQL SERVER - FIX - ERROR : Msg 3201, Level 16 Cannot open backup device . Operating system error 5(Access is denied.)](https://blog.sqlauthority.com/2011/04/13/sql-server-fix-error-msg-3201-level-16-cannot-open-backup-device-operating-system-error-5access-is-denied/): Recently I formatted my computer and installed fresh SQL Server in it. I installed the AdventureWorks database in my database. Once done, I wanted to run few test scripts on my database. Just like every DBA, I decided to take backup of my database - this way I can restore it back to attain an original database state. As soon as I ran the backup command I ended up with the following error. This error is due to a permissions issue on the local disk and user account which is running SQL Server. In this blog post we will talk about the operating system error. - [SQL SERVER - Query to Recent Query on Server with Execution Plan Function to Get SQL](https://blog.sqlauthority.com/2011/04/12/sql-server-query-to-recent-query-on-server-with-execution-plan-function-to-get-sql/): This blog post is written in response to the T-SQL Tuesday hosted by Matt Velic. He has picked very interesting topic which is related to APPLY clause of the T-SQL. When I read the subject, I really liked the subject. This is very new subject and it is quite a interesting choice by Matt. I tried to explain in simpler words regarding APPLY but it is not that easy to explain. Instead Here is the quick theory from BOL: The APPLY operator allows you to invoke a table-valued function for each row returned by an outer table expression of a query.... - [SQL SERVER – expressor Studio Includes Powerful Scripting Capabilities](https://blog.sqlauthority.com/2011/04/11/sql-server-expressor-studio-includes-powerful-scripting-capabilities/): One of the major problems in developing a data integration application is writing transformation code.  Many tools try to meet this need by providing a large number of operators that minimize coding through configuration. Specialized operators are fine for basic transformations, but most ETL transformations require logic specific to the particular application.  For that, tools resort to full featured coding tools such as Microsoft Visual Studio.  expressor software has taken a different approach.  The expressor Studio tool provides a light-weight scripting language called expressor Datascript and integrates an editing environment into each programmable operator. These tools allow development of transformation scripts... - [SQL SERVER - TempDB in RAM for Performance](https://blog.sqlauthority.com/2011/04/10/sql-server-tempdb-in-ram-for-performance/): Performance Tuning is always the most interesting subject when we talk about software application. While I was recently discussing performance tuning with my friend, we started to talk about the best practices for TempDb. I also pointed my friend to the excellent blog post written by Cindy Gross on the subject: Compilation of SQL Server TempDB IO Best Practices. One of the discussion points was that we should put TempDB on the drive which is always giving better performance. - [SQL SERVER - Add New Column With Default Value](https://blog.sqlauthority.com/2011/04/09/sql-server-add-new-column-with-default-value/): SQL Server is a very interesting system, but the people who work in SQL Server are even more remarkable. The amount of communication, the thought process, the brainstorming that they do are always phenomenal. Today I will share a quick conversation I have observed in one of the organizations that I recently visited. While we were heading to the conference room, we passed by some developers and I noticed the following script on the screen of one of the developers. CREATE TABLE TestTable (FirstCol INT NOT NULL) GO ------------------------------ -- Option 1 ------------------------------ -- Adding New Column ALTER TABLE TestTable ADD... - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day Next](https://blog.sqlauthority.com/2011/04/08/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-next/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next Day 4 – March 26, 2011 I woke up again at 5.00 AM. I really had nothing to do. Everything was over the night before, but waking up at this time had become a habit after I... - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day 3](https://blog.sqlauthority.com/2011/04/07/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-3/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next Day 3 – March 25, 2011 My wife woke me up at 5.00 AM. Two hours of power sleep seemed inadequate as I had only less than 6 hours of sleep during the last 3 days. Today... - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day 2](https://blog.sqlauthority.com/2011/04/06/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-2/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next Day 2 – March 24, 2011 I woke up once again at 5.00 AM as I was planning to leave at 6.00 AM. While I was heading towards the venue, I was thinking about the remaining day... - [SQLAuthority News - Win Windows Phone from Idera in 140 Characters - A Cartoon Challenge of SQL](https://blog.sqlauthority.com/2011/04/05/sqlauthority-news-win-windows-phone-from-idera-in-140-characters-a-cartoon-challenge-of-sql/): I personally have Windows Phone and I love it. The user friendliness and integration with social media is remarkable. My wife Nupur is big fan of Windows Live tools and Windows Phone as well. Well, this blog post is not about our preference of Windows Phone but about YOU a unlocked Windows Phone. The Windows Phone will be directly sponsored by Idera. If you want to win Windows Phone. Just do one thing, complete following cartoon. Every day queries go slow and we think it is SQL Server but the reality is that it is us who need to know the... - [SQL SERVER - MondayMeme - 11 Words or Less](https://blog.sqlauthority.com/2011/04/04/sql-server-mondaymeme-11-words-or-less/): My friend Thomas LaRock [Blog | Twitter] started interested tradition of writing a blog post of 11 words of less. Following the same SQL Expert and my fellow friend Amit Banerjee [Blog | Twitter] wrote interesting 11 words statement and tagged me. Here is my contribution: “Use Wait Types and Queues to Get Quick Performance Bottleneck.” I am not going to tag anybody but if you have quick one liner do share over here or blog yourself and link back. Reference: Pinal Dave (https://blog.sqlauthority.com)   - [SQLAuthority News - A Million Hits a Month - A Milestone](https://blog.sqlauthority.com/2011/04/04/sqlauthority-news-a-million-hits-a-month-a-milestone/): March 2011 has been very good month. SQLAuthority Blog got more than 1 Million Hits in a single month. Total hits so far is around 25 Million from the inception of the blog. My statistics are maintained by WordPress.com by themselves. I have shared the same over here. You can see the permanent page of the same over here as well. I am very thankful to all of you for your unconditional support to this blog. You can subscribe to blog by Feed, Email and Twitter. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day 1](https://blog.sqlauthority.com/2011/04/03/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-1/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next Day 1 – March 23, 2011 After my 3 hours of power sleep, I was up before 5.00 AM. I got ready and headed to TechEd Venue. Even though it was pretty early and very dark, it... - [SQLAuthority News - TechED 2011 - Bangalore - An Unforgettable Experience - Day 0](https://blog.sqlauthority.com/2011/04/02/sqlauthority-news-teched-2011-bangalore-an-unforgettable-experience-day-0/): Read my complete experience series of TechEd 2011, Bangalore TechED 2011 – Bangalore – An Unforgettable Experience – Day 0 TechED 2011 – Bangalore – An Unforgettable Experience – Day 1 TechED 2011 – Bangalore – An Unforgettable Experience – Day 2 TechED 2011 – Bangalore – An Unforgettable Experience – Day 3 TechED 2011 – Bangalore – An Unforgettable Experience – Day Next TechEd India is the one of the best Technology Events in India. The event venue was at Hotel Lalit Ashok, Bangalore. This three-day event was from March 23 to March 25, 2011, and this was my third... - [SQLAuthority News - Today is First April - April Fool's Day](https://blog.sqlauthority.com/2011/04/01/sqlauthority-news-today-is-first-april-april-fools-day/): I was planning to write something technical today but I realize that today is April 1st, and it is April Fool’s Day. When I used to be kid, I really enjoyed this day. There was innocent fun to play a small prank on friends. As I grew older it started to fade off. Since couple of years, I am considering this day as more like day for fun and good laugh. I got following images from very good friend through email. I will be stunned and speechless if this happens to me. Kudos to those who worked hard to pull the... - [SQL SERVER - 'Denali' - A Simple Example of Contained Databases](https://blog.sqlauthority.com/2011/03/31/sql-server-denali-a-simple-example-of-contained-databases/): Recently I was asked with the question: What is new for Database Security in SQL Server “Denali”? I think this is a very interesting question as I always wanted to talk about Contained Database, and this question gives me the chance to do so. Let us start with discussing contained database. A Contained Database is a database which contains all the necessary settings and metadata, making database easily portable to another server. This database will contain all the necessary details and will not have to depend on any server where it is installed for anything. You can take this database and... - [SQL SERVER - TechEd 2011 - Random Question and Answers](https://blog.sqlauthority.com/2011/03/30/sql-server-teched-2011-random-question-and-answers/): Three Days of TechED 2011 India was great event and I had so much fun that I can not express. I met around 1000 people during this 3 days and discussed a lot of things. I got few question again and again. I thought about blogging all of those 7 commonly asked question on blog. 1) What is “Denali”? A. Denali is mountain but if you are asking about SQL Server – it is code name of the next version. 2) When is “Denali” releasing? A. It is next version of SQL Server so Microsoft will announce the release date. You... - [SQL SERVER - Fix : Error : The request failed or the service did not respond in a timely fashion](https://blog.sqlauthority.com/2011/03/29/sql-server-fix-error-the-request-failed-or-the-service-did-not-respond-in-timely-fashion-consult-the-event-log-or-other-applicable-error-logs-for-details/): Two days ago, I was participating TechEd India 2011 and I had a great time presenting on various subjects. My computer fortunately behaved very well and I consider myself lucky for it. However, very next day, today, when I went to the office and turned on the machine, it did not start SQL Server. I was a bit confused and very quickly checked SQL Server Services. I noticed that services were OFF. I tried to turn on the services, but it keeps on giving me following error about request failed. - [SQL SERVER - Denali - Improvement in Startup Options](https://blog.sqlauthority.com/2011/03/28/sql-server-denali-improvement-in-startup-options/): I often work with advanced features of the SQL Server and this really led me to change how SQL Server is starting up. Recently I was changing the start up options in SQL Server and I was very delighted when I saw the startup option screen in Denali. It has really improved and is very convenient to use. Now I realized that the more I use Denali, the more I love it. - [SQL SERVER - 32 Bit - 64 Bit - HTML5 - Database Backup Restore](https://blog.sqlauthority.com/2011/03/27/sql-server-32-bit-64-bit-html5-database-backup-restore/): During TechEd India I was attending HTML5 session along with regular Database sessions. Couple of attendees were discussing database there and I find the incidence very interesting. - [SQL SERVER - Related Scripts for TechEd 2011 Presentations](https://blog.sqlauthority.com/2011/03/26/sql-server-related-scripts-for-teched-2011-presentations/): I had great time yesterday presenting at TechEd India 2011 on two subjects – Wait Types and Extended Events. I had shared the links of where all the scripts can be downloaded in the last slide. Here is the same links one more time. Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Scripts: Extended Events SQL Server Waits and Queues – Your Gateway to Perf. Troubleshooting Scripts: SQL SERVER – Summary of Month – Wait Type – Day 28 of 28 Videos, Slide decks are the complete report of the event will be posted on the blog very soon.... - [SQLAuthority News - Win Surprise Gift at TechED 2011 Sessions - Wait Types and Extended Events](https://blog.sqlauthority.com/2011/03/25/sqlauthority-news-win-surprise-gift-at-teched-2011-sessions-wait-types-and-extended-events/): A quick note for all – If you are attending my TechEd sessions today here are few notes for you. Session Time Sessions Date: March 25, 2011 Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Date and Time: March 25, 2011 12:00 PM to 01:00 PM SQL Server Waits and Queues – Your Gateway to Perf. Troubleshooting Date and Time: March 25, 2011 04:15 PM to 05:15 PM Surprise Gifts If you are attending the session – rest assure – few of you are going to get very interesting surprise gift. A good quality one! To win – you... - [SQL SERVER - Tomorrow 2 Sessions on Performance Tuning at TechEd India 2011 - March 25, 2011](https://blog.sqlauthority.com/2011/03/24/sql-server-tomorrow-2-sessions-on-performance-tuning-at-teched-india-2011-march-25-2011/): Tomorrow is the third day of the TechED India 2011 at Bangalore. I will be speaking on two very interesting sessions. If you are developer, database administrator or just want to learn something new and interesting, I suggest you attend my two sessions tomorrow. Here is the details of the session. Sessions Date: March 25, 2011 Here is the abstract of the session: Understanding SQL Server Behavioral Pattern – SQL Server Extended Events Date and Time: March 25, 2011 12:00 PM to 01:00 PM History repeats itself! SQL Server 2008 has introduced a very powerful, yet very minimal reoccurring feature called... - [SQL SERVER - Denali - ObjectID in Negative - Local TempTable has Negative ObjectID](https://blog.sqlauthority.com/2011/03/23/sql-server-denali-objectid-in-negative-local-temptable-has-negative-objectid/): I used to run the following script to generate random large results. However, when I ran this on Denali I noticed a very interesting behavior: SELECT o1.OBJECT_ID,o1.name, o2.OBJECT_ID, o2.name FROM sys.all_objects o1 CROSS JOIN sys.all_objects o2 I noticed lots of negative object_ID’s on Denali, whereas my experience on SQL Server 2008 R2 as well as the earlier versions was it was always giving me a positive number. This whole thing interested me so I decided to find out objects which belonged to the negative object_ID. When I looked at the name of the object, it was very evident that it belonged... - [SQLAuthority News - Solid Quality Journal - Importance of Statistics](https://blog.sqlauthority.com/2011/03/22/sqlauthority-news-solid-quality-journal-importance-of-statistics/): My article on “Important of Statistics” has been published in Solid Quality Journal. Statistics are a key part of getting solid performance. In this article we will go over the basics of the statistics and various best practices related to Statistics. We will go over various frequently asked questions like when to update statistics and difference between sync and async update of statistics. We will also discuss the pros and cons of the statistics update. I have answered one very important questions in this article: Should keep Auto Create Statistics and Auto Update Statistics settings true/on? Download Importance of Statistics Reference:... - [SQL SERVER - SQL Server Migration Assistant (SSMA) - Tools - Video - Download](https://blog.sqlauthority.com/2011/03/21/sql-server-sql-server-migration-assistant-ssma-tools-video-download/): I was recently working on learning various new stuff. I just would like to share very interesting resources here today. Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from any other data platform to SQL Server 2005, SQL Server 2008, SQL Server 2008 R2 and SQL Azure. Here are few important resources links: Microsoft SQL Server Migration Assistant (SSMA) Team’s Blog One very front page of the blog, I noticed very interesting diagram – where it displays four database products. One can click on any of them to go to... - [SQL SERVER - 2012 - Zoom Query Editor](https://blog.sqlauthority.com/2011/03/20/sql-server-denali-feature-zoom-query-editor/): SQL Server next version ‘Denali’ is coming up with very neat feature which can be used while presentations, group discussion or for people who prefers large fonts. - [SQL SERVER - Log File Growing for Model Database - model Database Log File Grew Too Big](https://blog.sqlauthority.com/2011/03/19/sql-server-log-file-growing-for-model-database-model-database-log-file-grew-too-big/): After reading my earlier article SQL SERVER – master Database Log File Grew Too Big, I received an email recently from another reader asking why does the log file of model database grow every day when he is not carrying out any operation in the model database. As per the email, he is absolutely sure that he is doing nothing on his model database; he had used policy management to catch any T-SQL operation in the model database and there were none. This was indeed surprising to me. I sent a request to access to his server, which he happily agreed... - [SQL SERVER 2008 - 2012 - Declare and Assign Variable in Single Statement](https://blog.sqlauthority.com/2011/03/18/sql-server-2008-2011-declare-and-assign-variable-in-single-statement/): Many of us are tend to overlook simple things even if we are capable of doing complex work. In SQL Server 2008, inline variable assignment is available. This feature exists from last 3 years, but I hardly see its utilization. One of the common arguments was that as the project migrated from the earlier version, the feature disappears. I totally accept this argument and acknowledge it. However, my point is that this new feature should be used in all the new coding – what is your opinion? The code which we used in SQL Server 2005 and the earlier version is... - [SQLAuthority News - SQL Server 2008 for Oracle DBA](https://blog.sqlauthority.com/2009/11/21/sqlauthority-news-sql-server-2008-for-oracle-dba/): This 15 modules, level 300 course provides students with the knowledge and skills to capitalize on their skills and experience as an Oracle DBA to manage a Microsoft SQL Server 2008 system. This workshop provides a quick start for the Oracle DBA to map, compare, and contrast the realm of Oracle database management to SQL Server database management. Module 1: Database and Instance Module 2: Database Architecture Module 3: Instance Architecture Module 4: Data Objects Module 5: Data Access Module 6: Data Protection Module 7: Basic Administration Module 8: Server Management Module 9: Managing Schema Objects Module 10: Database Security Module... - [SQLAuthority News - Book Review - Expert SQL Server 2008 Encryption by Michael Coles](https://blog.sqlauthority.com/2009/11/20/sqlauthority-news-book-review-expert-sql-server-2008-encryption-by-michael-coles/): Expert SQL Server 2008 Encryption (Paperback) Michael Coles (Author), Rodney Landrum (Author) Link to Amazon “What is your opinion on encryption? What I mean is: In a world filled with data, how do you see encryption?” This is the precise question Michael Coles posed to me on March 3rd of this year, while we were heading to Starbucks in Seattle. We were both attending the Microsoft MVP Summit there. In the information era, security has become one of the most vital aspects of life. Although the topic may seem a little mundane, its importance cannot be overemphasized. It is the pillar... - [SQL SERVER - Understanding Table Hints with Examples](https://blog.sqlauthority.com/2009/11/19/sql-server-understanding-table-hints-with-examples/): Introduction Today we have a very interesting subject to look at. I tried to look for help online but have not found any other documentation besides what we have from the Book Online. Let us try to understand what are the different kinds of hints available in SQL Server and how they are helpful. What is a Hint? Hints are options and strong suggestions specified for enforcement by the SQL Server query processor on DML statements. The hints override any execution plan the query optimizer might select for a query. Before we continue to explore this subject, we need to consider... - [SQL SERVER - Size of Index Table - A Puzzle to Find Index Size for Each Index on Table](https://blog.sqlauthority.com/2009/11/18/sql-server-size-of-index-table-a-puzzle-to-find-index-size-for-each-index-on-table/): It is very easy to find out some basic details of any table using the following Stored Procedure. USE AdventureWorks GO EXEC sp_spaceused [HumanResources.Shift] GO Above query will return following resultset The above SP provides basic details such as rows, data size in table, and Index size of all the indexes on the table. If we look at this carefully, a total of three indexes can be found on the table HumanResources.Shift. USE AdventureWorks GO SELECT * FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('HumanResources.Shift') GO The above query will give result with query listing all the index on the table. There is... - [SQL SERVER - 2005 2008 - Backup, Integrity Check and Index Optimization By Ola Hallengren](https://blog.sqlauthority.com/2009/11/17/sql-server-2005-2008-backup-integrity-check-and-index-optimization-by-ola-hallengren/): Script of Backup, Integrity Check and Index Optimization are the most important scripts for any developer. SQL Expert and true SQL enthusiast Ola Hallengren is known for his excellent scripts. Please try it out and let me know what you think. The documentation is available on http://ola.hallengren.com/Documentation.html and the script can be downloaded from http://ola.hallengren.com. Here is brief documentation sent by Ola himself for his script in his own words. Backup Maintenance I think that most of you have experienced the error messages “BACKUP LOG cannot be performed because there is no current database backup.” and “Cannot perform a differential backup... - [SQLAuthority News - Notes of Excellent Experience at SQL PASS 2009 Summit, Seattle](https://blog.sqlauthority.com/2009/11/16/sqlauthority-news-notes-of-excellent-experience-at-sql-pass-2009-summit-seattle/): Update: Do not forget to checkout last three photos and follow me on twitter (of course!) I have previously documented my four-day experience of SQL PASS 2009 Summit at Seattle. There were many reasons for SQL enthusiasts to attend the SQL PASS event; I am listing my own reasons here in order of importance to me. Networking with SQL fellows and experts Putting face to the name or avatar Learning and improving my SQL skills Understanding the structure of the largest SQL Server Professional Association Attending my favorite training sessions During these four days, there was so much happening that it... - [SQL SERVER - Whitepaper Consolidation Using SQL Server 2008](https://blog.sqlauthority.com/2009/11/15/sql-server-whitepaper-consolidation-using-sql-server-2008/): Consolidation Using SQL Server 2008 Writer: Allan Hirt, Megahirtz LLC (allan@sqlha.com) Technical Reviewers: Lindsey Allen, Madhan Arumugam, Ben DeBow, Sung Hsueh, Rebecca Laszlo, Claude Lorenson, Prem Mehra, Mark Pohto, Sambit Samal, and Buck Woody Published: October 2009 Many companies are considering or have already implemented consolidation of computing resources, including Microsoft SQL Server instances and databases, in their organization. A consolidation effort is a complex task that requires information, a detailed plan and timeline for success, and a strategy for administering the consolidated environment. This white paper walks through the journey of gathering and analyzing the information to base all planning... - [SQLAuthority News - Disk Partition Alignment Best Practices for SQL Server](https://blog.sqlauthority.com/2009/11/14/sqlauthority-news-disk-partition-alignment-best-practices-for-sql-server/): Disk Partition Alignment Best Practices for SQL Server Writers: Jimmy May, Denny Lee Contributors: Mike Ruthruff, Robert Smith, Bruce Worthington, Jeff Goldner, Mark Licata, Deborah Jones, Michael Thomassy, Michael Epprecht, Frank McBath, Joseph Sack, Matt Landers, Jason McKittrick, Linchi Shea, Juergen Thomas, Emily Wilson, John Otto, Brent Dowling Technical Reviewers: Mike Ruthruff, Robert Smith, Bruce Worthington, Emily Wilson, Lindsey Allen, Stuart Ozer, Thomas Kejser, Kun Cheng, Nicholas Dritsas, Paul Mestemaker, Alexei Khalyako, Mike Anderson, Bong Kang Published: May 2009 Disk partition alignment is a powerful tool for improving SQL Server performance. Configuring optimal disk performance is often viewed as much art... - [SQL SERVER - Policy Based Management - Create, Evaluate and Fix Policies](https://blog.sqlauthority.com/2009/11/13/sql-server-policy-based-management-create-evaluate-and-fix-policies/): Introduction This article will cover the most spectacular feature of SQL 2008 – Policy-based management and how the configuration of SQL Server with policy-based management architecture can make a powerful difference. Policy based management is loaded with several advantages. It can help you implement various policies for reliable configuration of the system. It also provides additional administration assistance to DBAs and helps them effortlessly manage various tasks of SQL Server across the enterprise. Basics of Policy Management SQL server 2008 has introduced policy management framework, which is the latest technique for SQL server database engine. SQL policy administrator uses SQL Server... - [SQL SERVER - Disable CHECK Constraint - Enable CHECK Constraint](https://blog.sqlauthority.com/2009/11/12/sql-server-disable-check-constraint-enable-check-constraint/): Foreign Key and Check Constraints are two types of constraints that can be disabled or enabled when required. This type of operation is needed when bulk loading operations are required or when there is no need to validate the constraint. The T-SQL Script that does the same is very simple. USE AdventureWorks GO -- Disable the constraint ALTER TABLE HumanResources.Employee NOCHECK CONSTRAINT CK_Employee_BirthDate GO -- Enable the constraint ALTER TABLE HumanResources.Employee WITH CHECK CHECK CONSTRAINT CK_Employee_BirthDate GO It is very interesting that when the constraint is enabled, the world CHECK is used twice – WITH CHECK CHECK CONSTRAINT. I often ask those to find the mistake in this script when they claim to... - [SQL SERVER - Sharepoint Resource Available for SQL Server](https://blog.sqlauthority.com/2009/11/11/sql-server-sharepoint-resource-available-for-sql-server/): Here is quick list of the tools which are available for SQL Server and Sharepoint. These are recently updated resources from Microsoft. External Collaboration Toolkit for SharePoint This solution allows users to create collaboration environments that use the familiar SharePoito deploy a SharePoint-based environment for collaboration with people outside your firewall. The accelerator allows users to create collaboration environments that use the familiar SharePoint interface. Because the solution is easy to use, end users are more likely to use it rather than revert to e-mail. SQL Server Reporting Services Add-in for SharePoint Technologies The Microsoft SQL Server 2005 Reporting Services Add-in... - [SQL Authority News - Training MS SQL Server 2005/2008 Query Optimization And Performance Tuning](https://blog.sqlauthority.com/2009/11/10/sql-authority-news-training-ms-sql-server-20052008-query-optimization-and-performance-tuning/): This is very short note announcing details about my course details for 'Training MS SQL Server 2005/2008 Query Optimization And Performance Tuning'. - [SQL SERVER - Removing Key Lookup - Seek Predicate - Predicate - An Interesting Observation Related to Datatypes](https://blog.sqlauthority.com/2009/11/09/sql-server-removing-key-lookup-seek-predicate-predicate-an-interesting-observation-related-to-datatypes/): Recently, I have been working on Query Optimization project. While working on it, I found the following interesting observation. This entire concept may appear very simple, but if you are working in the area of query optimization and server tuning, you will find such useful hints. Before we start, let us understand the difference between Seek Predicate and Predicate. Seek Predicate is the operation that describes the b-tree portion of the Seek. Predicate is the operation that describes the additional filter using non-key columns. Based on the description, it is very clear that Seek Predicate is better than Predicate as it... - [SQL SERVER - Stored Procedure are Compiled on First Run - SP taking Longer to Run First Time](https://blog.sqlauthority.com/2009/11/08/sql-server-stored-procedure-are-compiled-on-first-run-sp-taking-longer-to-run-first-time/): During the PASS summit, one of the attendees asked me the following question. Why the Stored Procedure takes long time to run for first time? The reason for the same is because Stored Procedures are compiled when it runs first time. When I answered the same, he replied that Stored Procedures are pre-compiled, and this should not be the case. In fact, Stored Procedures are not pre-compiled; they compile only during their first time execution. There is a misconception that stored procedures are pre-compiled. They are not pre-compiled, but compiled only during the first run. For every subsequent runs, it is... - [SQLAuthority News - Data Compression Strategy Capacity Planning and Best Practices](https://blog.sqlauthority.com/2009/11/07/sqlauthority-news-data-compression-strategy-capacity-planning-and-best-practices/): Data Compression: Strategy, Capacity Planning and Best Practices SQL Server Technical Article Writer: Sanjay Mishra Contributors: Marcel van der Holst, Peter Carlin, Sunil Agarwal Technical Reviewer: Stuart Ozer, Lindsey Allen, Juergen Thomas, Thomas Kejser, Burzin Patel, Prem Mehra, Joseph Sack, Jimmy May, Cameron Gardiner, Mike Ruthruff, Glenn Berry (SQL Server MVP), Paul S Randal (SQLskills.com), David P Smith (ServiceU Corporation) Published: May 2009 The data compression feature in SQL Server 2008 helps compress the data inside a database, and it can help reduce the size of the database. Apart from the space savings, data compression provides another benefit: Because compressed data... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 4](https://blog.sqlauthority.com/2009/11/06/sqlauthority-news-sql-pass-summit-seattle-2009-day-4/): Fourth day was awesome! I had scheduled nearly 8 meetings with different groups of people today. It was really great fun. Let us see the keypoints for the same. PASS President Wayne Snyder honored and thanked Kevin Kline for his 10 YEARS of service. Kevin then gets a well-deserved standing ovation from the entire audience. Next year’s PASS Summit will be in Seattle from November 8 to 11, 2010. Dell Key note was little flat in delivery. Dell was primary sponsor for the event. Dr. David DeWitt, Technical Fellow, Data & Storage Platform Division at Microsoft starts presentation entitled “From 1... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 3](https://blog.sqlauthority.com/2009/11/05/sqlauthority-news-sql-pass-summit-seattle-2009-day-3/): The third day at SQL PASS Summit was education + entertainment day for me. During the last 10 days, I woke up at 4:00 AM regularly. However, as I had way too much fun yesterday at various parties earlier, I did not get up till 7:30 AM. By the time I woke up, I realized that I was late for my early breakfast meeting with Solid Quality Global Mentors. I somehow managed to reach there at 8:00 AM and we talked for nearly an hour. After the meeting, I headed to Keynote. Keynote is the best time of the day and... - [SQLAuthority News - SQL PASS Summit, Seattle 2009 - Day 2](https://blog.sqlauthority.com/2009/11/04/sqlauthority-news-sql-pass-summit-seattle-2009-day-2/): The second day of PASS started with very engaging and it started with an original game invented by Stuart Ainsworth. This game involves finding twitter people in real life. As I was not one of the square in bingo, I had decided to participate in game myself and try to win if I can. During this process, I felt guilty that I borrowed a pen from Stuart and did not return it back. In fact, after a while someone took the pen from me and never returned it. It is true that karma pays off! I should have returned it right... - [SQLAuthority News - SQLPASS Summit, Seattle 2009 - Day 1](https://blog.sqlauthority.com/2009/11/03/sqlauthority-news-sql-pass-summit-seattle-2009-day-1/): Day 1 at SQLPASS was awesome. I usually write everything in detail when I have to cover any project. This time, I have decided to cover this event little bit different and with lots of images. For day 1, I have more than 90 photos taken with many SQL celebrities and different sessions. I will be not able to cover all the photos taken today in this post. I will gradually post all the photos as I will do follow up posts. In this post, I will cover my activities on day 1 as well few of the photos that give you a visual tour of the spot that I have covered in one day. - [SQLAuthority News - 3 Year Old Blog - PASS Summit 2009 - 10.5 Million Views](https://blog.sqlauthority.com/2009/11/02/sqlauthority-news-3-year-old-blog-pass-summit-2009-10-5-million-views/): This blog has reached a remarkable milestone. It is 3 years old today. So far, there have been more than 10.5 million views on this blog and more than 1140 articles. It is really exciting that on this very important day, I am attending my very first SQL PASS in Seattle. The feeling and excitement to attend the very first summit cannot be put into words. I have been waiting to attend this summit for almost a year now, and today this dream is materializing with my blog’s “birthday.” You can read all of my articles written thus far here. I... - [SQL Authority News - Advanced T-SQL with Itzik Ben-Gan - Solid Quality Mentors](https://blog.sqlauthority.com/2009/11/01/sql-authority-news-advanced-t-sql-with-itzik-ben-gan-solid-quality-mentors/): As mentioned earlier in a blog post SQL SERVER – Advanced T-SQL with Itzik Ben-Gan – A Dream Coming True, I got the wonderful opportunity to attend the course of Itzik Ben-Gan. Itzik is one of the true masters of SQL Server, and his fame had set my expectations quite high. The most interesting aspect is that I have taught a similar course in India several times, and I was quite familiar with all the slides and examples. As I already knew a lot about this course, I was wondering if I would be able to enjoy the class or learn something... - [SQLAuthority News - New PASS President Rushabh Mehta](https://blog.sqlauthority.com/2009/10/31/sqlauthority-news-new-pass-president-rushabh-mehta/): The Professional Association for SQL Server (PASS) is an independent, not-for-profit association, dedicated to supporting, educating, and promoting the Microsoft SQL Server community. From local user groups and special interest groups (Virtual Chapters) to webcasts and the annual PASS Community Summit – the largest gathering of SQL Server professionals in the world – PASS is dedicated to helping its members Connect, Share, and Learn. Today was a big day as PASS announced the executive board members for the term starting on Jan 1, 2010. I would like to express my congratulations to all new executives of PASS. Please read official press... - [SQLAuthority News - India Market and Third Party SQL Server Tools](https://blog.sqlauthority.com/2009/10/30/sqlauthority-news-india-market-and-third-party-sql-server-tools/): Last week, I had wonderful time attending meeting of small ISV (Independent Software Vendors). Several topics were discussed, but the one topic that caught my attention was the adoption of the third party SQL Server tools. There were around 100+ top level managers who take decision regarding what resources are needed for projects. I had a great time talking to them. I have delivered a session on the subject “SQL Server – A Scalable Performance Database Platform“. Whenever I receive the right opportunity, it gives me great pleasure to talk about SQL Server. I have been working with SQL Server, and... - [SQLAuthority News - Birds-of-a-Feather (BOF) Lunch - SQL PASS Summit, Seattle, 2009](https://blog.sqlauthority.com/2009/10/29/sqlauthority-news-birds-of-a-feather-bof-lunch-sql-pass-summit-seattle-2009/): I received few emails regarding where can people meet me at SQL PASS event in Seattle. I am currently in Bellevue attending Itzik Ben-Gan’s class. I am immensely enjoying the class, and I shall post details about the class once it is over. If you are attending SQL PASS and interested to meet me, I will be present at Birds-of-a-Feather (BOF) Lunch. I will be talking on the subject Change Data Capture (CDC). Please note that this lunch is for all of us; moreover, it is not necessary that I will be talking on only subject of Change Data Capture. In... - [SQL SERVER - Tuning the Performance of Change Data Capture in SQL Server 2008](https://blog.sqlauthority.com/2009/10/28/sql-server-tuning-the-performance-of-change-data-capture-in-sql-server-2008/): Change data capture (CDC) is a new feature in SQL Server 2008 designed to capture insert, update, merge, and delete activities applied to SQL Server tables and to avail those changes in an easy-to-understand format. Conventionally, detecting changes in a source database to transfer these changes to a data warehouse required any of the following: Special columns in the source tables (time stamps, row versions). Triggers that capture changes. Comparison of the source and the destination systems. The above methods can have significant disadvantages: special columns require a change in the source database schema, and in many cases, a change in... - [SQL SERVER - How to Enable Index - How to Disable Index - Incorrect syntax near 'ENABLE'](https://blog.sqlauthority.com/2009/10/27/sql-server-how-to-enable-index-how-to-disable-index-incorrect-syntax-near-enable/): Many times I have seen that the index is disabled when there is large update operation on the table. Bulk insert of very large file updates in any table using SSIS is usually preceded by disabling the index and followed by enabling the index. I have seen many developers running the following query to disable the index. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO While enabling the same index, I have seen developers using the following INCORRECT syntax, which results in error. USE AdventureWorks GO ----INCORRECT Syntax Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact ENABLE GO Msg 102, Level 15, State... - [SQL SERVER - Advanced T-SQL with Itzik Ben-Gan - A Dream Coming True](https://blog.sqlauthority.com/2009/10/26/sql-server-advanced-t-sql-with-itzik-ben-gan-a-dream-coming-true/): As from my blog posts, all of you are probably aware that I am very much excited for attending SQL PASS at Seattle from Nov 1, 2009. As the days to the summit were nearing, I could already feel the rush of adrenalin in my veins. May be because of this, I could not wait any longer and so I headed towards Seattle a week earlier! As Robert Cain mentioned on twitter, I finally arrived at Seattle a week earlier than the start date of the summit. I landed in Seattle on the evening of Oct 24, 2009. As I was... - [SQLAuthority News - Best Practices for Integration Services Configurations](https://blog.sqlauthority.com/2009/10/25/sqlauthority-news-best-practices-for-integration-services-configurations/): Best Practices for Integration Services Configurations by Jamie Thomson This article explains what SQL Server Integration Services configurations are used for, why you should use Integration Services configurations, and what options you have for leveraging configurations. It will also make some simple recommendations that are based on my experiences of building Integration Services packages in a real-world environment. An understanding of the terms “package”, “Business Intelligence Development Studio”, and “dtexec.exe” in the context of Integration Services is assumed. There five basic types of Integration Services configurations. XML Configuration File Environment Variable Configuration Parent Package Configuration Registry Configuration SQL Server Configuration Read... - [SQL SERVER - Link to SQL Server Book Online - BOL](https://blog.sqlauthority.com/2009/10/24/sql-server-link-to-sql-server-book-online-bol/): Do you keep following Book Online Links handy? I do and I use them a lot. SQL Server 2008 R2 SQL Server 2008 SQL Server 2005 SQL Server 2000 I do and I use them a lot. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - PASS Sessions - I will be there!](https://blog.sqlauthority.com/2009/10/23/sqlauthority-news-pass-sessions-i-will-be-there/): As PASS is now one week away and I am all excited for the same. I am going to attend following two sessions for sure. I encourage all of you to also visit the same sessions. We can all talk about SQL , SQL Integration as well Beyond Relations. First sessions I will be attending of Rushabh Mehta, he is Managing Director of Solid Quality India. Overcoming SSIS Deployment and Configuration Challenges Presenter: Rushabh Mehta (Solid Quality Learning) Session Details It is no secret that a main deficiency of SSIS is deployment. Have you wanted to punch a wall before when... - [SQL SERVER - Difference Between Candidate Keys and Primary Key In Simple Words](https://blog.sqlauthority.com/2009/10/22/sql-server-difference-candidate-keys-primary-key-simple-words/): Introduction Not long ago, I had an interesting and extended debate with one of my friends regarding which column should be primary key in a table. The debate instigated an in-depth discussion about candidate keys and primary keys. My present article revolves around the two types of keys. Let us first try to grasp the definition of the two keys. Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. Primary... - [SQL SERVER - Introduction to Business Intelligence - Important Terms & Definitions](https://blog.sqlauthority.com/2009/10/21/sql-server-introduction-to-business-intelligence-important-terms-definitions/): What is Business Intelligence Business intelligence (BI) is a broad category of application programs and technologies for gathering, storing, analyzing, and providing access to data from various data sources, thus providing enterprise users with reliable and timely information and analysis for improved decision making. To put it simply, BI is an umbrella term that refers to an assortment of software applications for analyzing an organization’s raw data for intelligent decision making for business success. BI as a discipline includes a number of related activities, including decision support, data mining, online analytical processing (OLAP), querying and reporting, statistical analysis and forecasting. - [SQLAuthority News - PASS 2009 Sessions on Query Optimization and Performance Tuning](https://blog.sqlauthority.com/2009/10/20/sqlauthority-news-pass-2009-sessions-on-query-optimization-and-performance-tuning/): PASS Summit 2009 is now only 10 days away and I am very excited for the same. I can not wait to attend the summit as this is the most awaited conference of SQL Server in world. Everybody will be there and there will be something for everybody. My core expertise is in Query Optimization and Performance Tuning area, and when I see the list of PASS session on the subject, I am totally speechless. There are so many great speaker at PASS who are there to talk on the subject. It is absolutely not possible to attend all of them... - [SQL SERVER - Change Collation of Database Column - T-SQL Script - Consolidating Collations - Extention Script](https://blog.sqlauthority.com/2009/10/19/sql-server-change-collation-of-database-column-t-sql-script-consolidating-collations-extention-script/): This document is created by Brian Cidern, he has written this excellent extension to SQL Expert who SQL SERVER – Change Collation of Database Column – T-SQL Script. His scripts are not only extremely helpful to achieve the task of consolidating collations in quick script. His script not only works perfectly but excellent piece of code and logic. Hats off to you Brian! You can reach Brian at his email address (brians.sql.blog (at) gmail (dot) com) or leave comment here. Download all scripts and explanation here About Collation Consolidation At some time in your DBA career, you may find yourself in... - [SQLAuthority News - Whitepaper - Auditing in SQL Server 2008](https://blog.sqlauthority.com/2009/10/18/sqlauthority-news-whitepaper-auditing-in-sql-server-2008/): Auditing in SQL Server 2008 SQL Server Technical Article Writer: Il-Sung Lee, Art Rask Technical Reviewer: Jack Richins, Rick Byham, Sameer Tejani, Al Comeau, JC Cannon Published: February 2009 With SQL Server Audit, SQL Server 2008 introduces an important new feature that provides a true auditing solution for enterprise customers. While SQL Trace can be used to satisfy many auditing needs, SQL Server Audit offers a number of attractive advantages that may help DBAs more easily achieve their goals such as meeting regulatory compliance requirements. These include the ability to provide centralized storage of audit logs and integration with System Center,... - [SQLAuthority News - Happy Diwali and New Year](https://blog.sqlauthority.com/2009/10/17/sqlauthority-news-happy-diwali-and-new-year/): I wish all of you Happy Diwali and New Year. Dīwali is a significant festival an official holiday in India. While Divali is popularly known as the “festival of lights”, the most significant spiritual meaning is “the awareness of the inner light”. Database tip of the day : Test your backup strategy. Yesterday night I had received call from old client, who lost his live server. When I asked for his backup system, which I helped him to set up, he informed me that as server did not crashed for entire year that did not have it properly. Well, I helped... - [SQL SERVER - Recently Executed T-SQL Query](https://blog.sqlauthority.com/2009/10/16/sql-server-recently-executed-t-sql-query/): About a year ago, I wrote blog post about SQL SERVER – 2005 – Last Ran Query – Recently Ran Query.  Since, then I have received many question regarding how this is better than fn_get_sql() or DBCC INPUTBUFFER. The Short Answer in is both of them will be deprecated. Please refer to following update query to recently executed T-SQL query on database. SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest ORDER BY deqs.last_execution_time DESC Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Enable Automatic Statistic Update on Database](https://blog.sqlauthority.com/2009/10/15/sql-server-enable-automatic-statistic-update-on-database/): In one of the recent projects, I found out that despite putting good indexes and optimizing the query, I could not achieve an optimized performance and I still received an unoptimized response from the SQL Server. On examination, I figured out that the culprit was statistics. The database that I was trying to optimize had auto update of the statistics was disabled. Let us learn about how to Enable Automatic Statistic Update on Database. - [SQLAuthority News - First Editorial - T-SQL Challenges Beginners](https://blog.sqlauthority.com/2009/10/14/sqlauthority-news-first-editorial-t-sql-challenges-beginners/): I would like to welcome all of you to very first editorial for T-SQL Challenges for Beginners. T-SQL Challenges began with the aim to help community to come out of regular mind set of just reading articles online. There is plenty of reading material available online, but there are very few that can make us use our brain cells. T-SQL Challenges are very well received in community, and today, we are receiving more than 200 responses for every challenge in a very short time. The real challenge is how to keep everybody involved. T-SQL Challenges is focused and encourage experts to... - [SQL SERVER - Comic Slow Query - SQL Joke](https://blog.sqlauthority.com/2009/10/13/sql-server-comic-slow-query-sql-joke/): Community TechDays at Ahmedabad was a great successful event. In fact, this can be considered the biggest event held in Ahmedabad thus far along with the community. I have posted a detailed report of the same at Community TechDays in Ahmedabad – A Successful Event. After the event, I received many emails requesting the comic slow query I had shown in my presentation. - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup - Part 3](https://blog.sqlauthority.com/2009/10/12/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup-part-3/): Earlier I have written two different articles on the subject Remove Bookmark Lookup. This article is as part 3 of the original article. Please read the first two articles here before continuing reading this article. - [SQLAuthority News - Accessing SQL Server Databases with PHP](https://blog.sqlauthority.com/2009/10/11/sqlauthority-news-accessing-sql-server-databases-with-php/): Accessing SQL Server Databases with PHP SQL Server Technical Article Writer: Brian Swan Published: August 2008 The SQL Server 2005 Driver for PHP is a Microsoft-supported extension of PHP 5 that provides data access to SQL Server 2005 and SQL Server 2008. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2008. The SQL Server 2005 Driver for PHP API provides a comprehensive data access solution from PHP, and includes support for many features including Windows Authentication, transactions, parameter binding, streaming, metadata access, connection pooling, and error handling. This paper discusses... - [SQL SERVER - Download Logical Query Processing Poster](https://blog.sqlauthority.com/2009/10/10/sql-server-download-logical-query-processing-poster/): You can download the poster from Itzik Ben-Gan’s T-SQL Querying page over here. Earlier this year, I had written article on SQL SERVER – Logical Query Processing Phases – Order of Statement Execution and I had asked one question to readers. I got very good response for this question. Today, I am going to discuss about one of the errata I have made there. I had displayed the Logical Query Processing order, where I had incorrectly listed the last two operations. I have listed the operations as ORDER BY first and TOP afterwards. The fact is that TOP is always executed first and ORDER BY after that. - [SQL SERVER - Queries Waiting for Memory Allocation to Execute](https://blog.sqlauthority.com/2009/10/09/sql-server-queries-waiting-for-memory-allocation-to-execute/): In one of the recent projects, I was asked to create a report of queries that are waiting for memory allocation. The reason was that we were doubtful regarding whether the memory was sufficient for the application. The following query can be useful in similar case. Queries that do not have to wait on a memory grant will not appear in the resultset of following query. SELECT TEXT, query_plan, requested_memory_kb, granted_memory_kb,used_memory_kb, wait_order FROM sys.dm_exec_query_memory_grants MG CROSS APPLY sys.dm_exec_sql_text(sql_handle) CROSS APPLY sys.dm_exec_query_plan(MG.plan_handle) Please note that wait_order will give order of query waiting on memory to execute. This is a very important script, I suggest that you... - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup - Part 2](https://blog.sqlauthority.com/2009/10/08/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup-part-2/): This article is follow up of my previous article SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup. Please do read my previous article before continuing further. I have described there two different methods to reduce query execution cost. Let us compare the performance of the SELECT statement of the previous query. We have created two different indexes on the table. Method 1: Creating covering non-clustered index. In this method, we will create a non-clustered index that contains the columns used in the SELECT statement along with the column used in the WHERE... - [SQL SERVER - Query Optimization - Remove Bookmark Lookup - Remove RID Lookup - Remove Key Lookup](https://blog.sqlauthority.com/2009/10/07/sql-server-query-optimization-remove-bookmark-lookup-remove-rid-lookup-remove-key-lookup/): Today, I would like to share one very quick tip about how to remove bookmark lookup or RID lookup. Let us first understand Bookmark lookup or RID lookup. Please note that from SQL Server 2005 SP1 onwards, Bookmark look up is known as Key look up. When a small number of rows are requested by a query, the SQL Server optimizer will try to use a non-clustered index on the column or columns contained in the WHERE clause to retrieve the data requested by the query. If the query requests data from columns not present in the non-clustered index, SQL Server... - [SQL SERVER - Interesting Observation - Query Hint - FORCE ORDER](https://blog.sqlauthority.com/2009/10/06/sql-server-interesting-observation-query-hint-force-order/): SQL Server never stops to amaze me. As regular readers of this blog already know that besides conducting corporate training, I work on large-scale projects on query optimizations and server tuning projects. In one of the recent projects, I have noticed that a Junior Database Developer used the query hint Force Order; when I asked for details, I found out that the basic concept was not properly understood by him. - [SQLAuthority News - Community TechDays in Ahmedabad - A Successful Event - Oct 3, 2009](https://blog.sqlauthority.com/2009/10/05/sqlauthority-news-community-techdays-in-ahmedabad-a-successful-event/): Community TechDays at Ahmedabad was a great successful event. In fact, this can be considered the biggest event held in Ahmedabad thus far along with community. This event was held by Microsoft and PASS (Professional Association of SQL Server). The goal of this event was to dive deep into the world of Microsoft technologies and get trained on the latest from Microsoft. Well, we could successfully achieve the same and build real connections with Microsoft experts and community members. - [SQL SERVER - Choose Right Edition of SQL Server Express for Your Application](https://blog.sqlauthority.com/2009/10/04/sql-server-choose-right-edition-of-sql-server-express-for-your-application/): SQL Server Express is better alternative of MySQL. I have recently helped quite a few organizations to move to SQL Server Express recently. However, one question keep on coming up quite often regarding which is the right edition for SQL Server Express. SQL Server Express have more than one edition available. Here is the quick guide to select right edition for SQL Server. After reading above guide if you are still not sure which edition you should select, leave a comment here or send me email and I will get back to you. SQL Server 2008 Express with Advanced Services –... - [SQLAuthority News - Database Encryption in SQL Server 2008 Enterprise Edition](https://blog.sqlauthority.com/2009/10/03/sqlauthority-news-database-encryption-in-sql-server-2008-enterprise-edition/): Database Encryption in SQL Server 2008 Enterprise Edition SQL Server Technical Article Writers: Sung Hsueh Technical Reviewers: Raul Garcia, Sameer Tejani, Chas Jeffries, Douglas MacIver, Byron Hynes, Ruslan Ovechkin, Laurentiu Cristofor, Rick Byham, Sethu Kalavakur Published: February 2008 TDE does not replace cell-level encryption, EFS, or BitLocker. This white paper compares TDE with these other encryption methods for application developers and database administrators. While this is not a technical, in-depth review of TDE, technical implementations are explored and a familiarity with concepts such as virtual log files and the buffer pool are assumed. The user is assumed to be familiar with... - [SQLAuthority News - SQL Server 2008 - The Other Side of Index - Community Tech Days](https://blog.sqlauthority.com/2009/10/02/sqlauthority-news-sql-server-2008-the-other-side-of-index-live-presentation-in-ahmedabad/): Community Tech Days are here Tomorrow in Ahmedabad on Oct 3, 2009. I will be presenting the session ‘SQL Server 2008 – The Other Side of Index’. I will be available there whole day if you want to meet and discuss SQL. I will be starting my session with following cartoon. You will have to attend the session in person to see what I am going to cover in the session. - [SQL SERVER - SQL Server Management Studio and Client Statistics](https://blog.sqlauthority.com/2009/10/01/sql-server-sql-server-management-studio-and-client-statistics/): Client Statistics is very important. Many a time, people relate queries execution plan with query cost. This is not a good comparison. Both are different parameters, and they are not always related. It is possible that the query cost of any statement is less, but the amount of the data returned is considerably large, which is causing any query to run slow. How do we know if any query is retrieving a large amount data or very little data? In one way, it is quite easy to figure this out by just looking at the result set; however, this method cannot... - [SQLAuthority News - Community Tech Days - Oct 3, 2009 - SQL Server 2008 - The Other Side of Index](https://blog.sqlauthority.com/2009/09/30/sqlauthority-news-community-tech-days-oct-3-2009-sql-server-2008-the-other-side-of-index/): Microsoft Community Tech Days are here! Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Community Tech Days are coming to Ahmedabad on Oct 3, 2009. I will be presenting the session ‘SQL Server 2008 – The Other Side of Index’. I will be talking about the other side of Index where we will be thinking out of the typical way of creating Indexes. Take a look at the following common conversation. Person 1: My Query is running slow. Person 2: How about create an index on it? Person 1:... - [SQL SERVER - Interesting Observation - Execution Plan and Results of Aggregate Concatenation Queries](https://blog.sqlauthority.com/2009/09/29/sql-server-interesting-observation-execution-plan-and-results-of-aggregate-concatenation-queries/): Working with SQL Server has never seems to be monotonous – no matter how long one has worked with it. Quite often, I come across some excellent comments that I feel like acknowledging them as blog posts. Recently, I wrote an article on SQL SERVER – Execution Plan and Results of Aggregate Concatenation Queries Depend Upon Expression Location, which is well received in community. Before you read this article further, I request you to read original article. I received very interesting comments from Bob on the blog, where he explained why this is happening. Further, he talked about a similar kind... - [SQLAuthority News - Download IIS Database Manager](https://blog.sqlauthority.com/2009/09/28/sqlauthority-news-download-iis-database-manager/): IIS Database Manager allows you to easily manage your local and remote databases from within IIS Manager. IIS Database Manager automatically discovers databases based on the Web server or application configuration and also provides the ability to connect to any database on the network. Once connected, IIS Database Manager provides a full array of management options including managing tables, views, stored procedures and data, as well as running ad hoc queries. Here are a few articles to get you started on using the IIS Database Manager: Basics of the IIS Database Manager Working with Tables Working with Views Working with Stored... - [SQLAuthority News - FILESTREAM Storage in SQL Server 2008](https://blog.sqlauthority.com/2009/09/27/sqlauthority-news-filestream-storage-in-sql-server-2008/): This white paper describes the FILESTREAM feature of SQL Server 2008, which allows storage of and efficient access to BLOB data using a combination of SQL Server 2008 and the NTFS file system. This white paper is Written By: Paul S. Randal (SQLskills.com) Read the white paper here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - FIX : An error occurred while executing this command. If this error persists, please contact your Live Meeting administrator.](https://blog.sqlauthority.com/2009/09/26/sqlauthority-news-fix-an-error-occurred-while-executing-this-command-if-this-error-persists-please-contact-your-live-meeting-administrator/): Recently, while I was scheduling a live meeting for one of my online training sessions, I kept receiving the following error message repeatedly. I had never encountered this type of error before, and despite searching online for a long time, I could not solve this problem. After several failed attempts, I finally managed to fix this error with the help of Solid Quality Mentors IT Support Mentor – Victor. He suggested that instead of just typing my name in the “To” field, I should clear the cache by pressing CTRL + DELETE or perform force lookup by selecting the contact person... - [SQL SERVER - Outer Join in Indexed View - Question to Readers](https://blog.sqlauthority.com/2009/09/25/sql-server-outer-join-in-indexed-view-question-to-readers/): Today I have question for you. Just a day ago I was reading whitepaper Improving Performance with SQL Server 2008 Indexed Views. Following is question and answer I read in the white paper. Q. Why can’t I use OUTER JOIN in an indexed view? A. Rows can logically disappear from an indexed view based on OUTER JOIN when you insert data into a base table. This makes incrementally updating OUTER JOIN views relatively complex to implement, and the performance of the implementation would be slower than for views based on standard (INNER) JOIN. Here I would like to ask you one... - [SQL SERVER - Interesting Observation - Index on Index View Used in Similar Query](https://blog.sqlauthority.com/2009/09/24/sql-server-interesting-observation-index-on-index-view-used-in-similar-query/): Recently, I was working on an optimization project for one of the large organizations. While working on one of the queries, we came across a very interesting observation. We found that there was a query on the base table and when the query was run, it used the index, which did not exist in the base table. On careful examination, we found that the query was using the index that was on another view. This was very interesting as I have personally never experienced a scenario like this. In simple words, “Query on the base table can use the index created... - [SQL SERVER - Insert Values of Stored Procedure in Table - Use Table Valued Function](https://blog.sqlauthority.com/2009/09/23/sql-server-insert-values-of-stored-procedure-in-table-use-table-valued-function/): I recently got many emails requesting to write a simple article. I also got a request to explain different ways to insert the values from a stored procedure into a table. Let us quickly look at the conventional way of doing the same with Table Valued Function. - [SQLAuthority News - Article 1100 and Community Service](https://blog.sqlauthority.com/2009/09/22/sqlauthority-news-article-1100-and-community-service/): This is 1100 the post of on my blog post on this blog. Just looking at the last 100 post of my blog, I have realized besides writing blog posts there are lots of other community events, I have been involved with. Let me quickly list few of the important community events and post, I have been involved with. There are three very important event in my life during last 100 posts. Three Very Important Event SQLAuthority News – 1000th Article Milestone – 8 Millions Views – Solid Quality Mentors SQLAuthority News – MVP Award Renewed SQLAuthority News – Shaivi Dave... - [SQL SERVER - Introduction to Service Broker and Sample Script](https://blog.sqlauthority.com/2009/09/21/sql-server-intorduction-to-service-broker-and-sample-script/): Service Broker in Microsoft SQL Server 2005 is a new technology that provides messaging and queuing functions between instances. The basic functions of sending and receiving messages forms a part of a “conversation.” Each conversation is considered to be a complete channel of communication. Each Service Broker conversation is considered to be a dialog where two participants are involved. Service broker find applications when single or multiple SQL server instances are used. This functionality helps in sending messages to remote databases on different servers and processing of the messages within a single database. In order to send messages between the instances,... - [SQL SERVER - Execution Plan and Results of Aggregate Concatenation Queries Depend Upon Expression Location](https://blog.sqlauthority.com/2009/09/20/sql-server-execution-plan-and-results-of-aggregate-concatenation-queries-depend-upon-expression-location/): I was reading the blog of Ward Pond, and I came across another note of Microsoft. I really found it very interesting. The given explanation was very simple; however, I would like to rewrite it again. Let us execute the following script. This script inserts two values ‘A’ and ‘B’ in the table and outputs a simple code to concatenate each other to produce the result ‘AB’. IF EXISTS( SELECT * FROM sysobjects WHERE name = 'T1' ) DROP TABLE T1 GO CREATE TABLE T1( C1 NCHAR(1)  ) INSERT T1 VALUES( 'A' ) INSERT T1 VALUES( 'B' ) DECLARE @Str0 VARCHAR(4) SET @Str0 =... - [SQLAuthority News - SQL Server Accelerator for Business Intelligence (BI) ](https://blog.sqlauthority.com/2009/09/19/sqlauthority-news-sql-server-accelerator-for-business-intelligence-bi/): I have wonderful experience at my recent Business Intelligence tour. I will write down in detail about my experience at different location. However, today I would like to talk about one particular question which was asked at all the locations. It was about SQL Server Accelerator for Business Intelligence (BI). Many attendee asked me how to use this tool. SQL Server Accelerator for Business Intelligence (BI) is no more supported by Microsoft. Microsoft does not provide any support for this solution accelerator and has no plans to release future versions. Microsoft SQL Server 2005 and later versions include most of the... - [SQLAuthority News - Community Tech Days Oct 3, 2009 - Ahmedabad](https://blog.sqlauthority.com/2009/09/18/sqlauthority-news-community-tech-days-oct-3-2009-ahmedabad/): Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Build real connections with Microsoft experts and community members, and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. What more... You can watch some of these sessions LIVE online, from the comfort of your workstation as well. - [SQL SERVER - Converting Stored Procedure into Table Valued Function](https://blog.sqlauthority.com/2009/09/17/sql-server-converting-stored-procedure-into-table-valued-function/): In one of my recent articles, I mentioned the use of Table Valued Function (TVF) instead of Stored Procedure (SP). I received a follow up email asking what type of SP can be converted into a TVF. This is indeed a very interesting question! In fact, not all the SPs qualify to be converted to a TVF. Please note that I am not encouraging to convert all the SPs to TVFs. Each SPs have their own usage and need. Here, I shall discuss about the type of SP that can be converted to a TVF. First of all, you need to... - [SQLAuthority News - Download Microsoft SQL Server StreamInsight CTP2](https://blog.sqlauthority.com/2009/09/16/sqlauthority-news-download-microsoft-sql-server-streaminsight-ctp2/): Note:   Download Microsoft SQL Server StreamInsight CTP2 by Microsoft Microsoft SQL Server StreamInsight is a platform for the continuous and incremental processing of unending sequences of events (event streams) from multiple sources with near-zero latency. These requirements, shared by vertical markets such as manufacturing, oil and gas, utilities, financial services, health care, web analytics, and IT and data center monitoring, make traditional store and query techniques impractical for timely and relevant processing of data. StreamInsight allows software developers to create innovative solutions in the domain of Complex Event Processing that satisfy these needs. It allows to monitor, mine, and develop insights... - [SQL SERVER - Cryptography in SQL Server 2008](https://blog.sqlauthority.com/2009/09/15/sql-server-cryptography-in-sql-server-2008/): SQL Server, particularly the 2005 and 2008 versions, offers the functionality of cryptography. In the following, this functionality is briefly explained. Introduction Any database professional will support the encryption of data. However, the encryption of data has to be carried out at the database engine level. This is quite tricky as there the database performance can be affected by the process of decryption, data manipulation, and then re-encryption when data is being updated. SQL Server offers robust data security. Further, it is important to have strong knowledge of cryptography in SQL Server in order to avoid many problems that are encountered... - [SQL SERVER - Plan Caching and Schema Change - An Interesting Observation](https://blog.sqlauthority.com/2009/09/14/sql-server-plan-caching-and-schema-change-an-interesting-observation/): Last week, I had published details regarding SQL SERVER – Plan Caching in SQL Server 2008 by Greg Low on this blog. Similar to any other white paper, I have read this paper very carefully and enjoyed reading it. One particular topic in the white paper that caught my attention is definition of schema change. I was well aware of this definition, but I have often found that users are not familiar with what exactly does a schema change mean. Many people assume that a change in the table structure is schema change. In fact, creating or dropping index on any... - [SQL SERVER - Introduction to Spatial Coordinate Systems: Flat Maps for a Round Planet](https://blog.sqlauthority.com/2009/09/13/sql-server-introduction-to-spatial-coordinate-systems-flat-maps-for-a-round-planet/): Introduction to Spatial Coordinate Systems: Flat Maps for a Round Planet SQL Server Technical Article Writers: Isaac Kunen Project Editor: Diana Steinmetz Published: July 2008 I recently read this very interesting white paper. I really found it very interesting as this one was one very easy to read and humourous white paper related to SQL Server. The white paper is starts with very interesting note regarding Columbus. Contrary to popular opinion, Columbus did not prove that the Earth is round. Pythagoras, Plato, and Aristotle claimed a round Earth based on philosophic and observational grounds. More impressively, Eratosthenes measured the Earth’s circumference... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2](https://blog.sqlauthority.com/2009/09/12/sqlauthority-news-risk-and-health-assessment-program-for-microsoft-sql-server-scoping-tool-v1-2/): This download package is intended for Microsoft Premier Customers Only. This package includes all of the scoping tools necessary to prepare and qualify your environment to receive a Risk and Health Assessment Program for Microsoft SQL Server. Download Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2 Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Why I am Going to Attend PASS Summit Unite 2009- Seattle](https://blog.sqlauthority.com/2009/09/11/sqlauthority-news-why-i-am-going-to-attend-pass-summit-unite-2009-seattle/): PASS Summit Unite2009 – the premier event for SQL Server professionals – will be held in Seattle from November 2 to 5. It is the largest and the most intensive Microsoft SQL Server conference in the world organized by SQL Server users for SQL Server users. This year marks the 10th Anniversary of PASS Community Summit, making the event even more special. Every year, this event sees a large number of attendees as apart from high quality technical sessions, it provides unparalleled access to the Microsoft SQL Server development, SQL CAT, and Customer Service and Support teams. PASS Summit is an... - [SQL SERVER - SQL Server Desktop Screen Background](https://blog.sqlauthority.com/2009/09/10/sql-server-sql-server-desktop-screen-background/): Buck Woody (MSFT) has published a blog post about SQL Server Desktop Screen Background. I really like the SQL Server Desktop background and I have replaced that background on my work laptop. I came across this particular post because I am a regular reader of his blog. Few of the other interesting posts written by him are following. - [SQL SERVER - Difference between SQL Server Express and MySQL](https://blog.sqlauthority.com/2009/09/09/sql-server-difference-between-sql-server-express-and-mysql/): Both SQL Server express and MySQL are two of the Relational Database Systems (RDBMS) available today. Both are freely available and meant for running smaller or embedded databases, yet there are also significant differences between them. - [SQLAuthority News - Shaivi Dave - Baby SQLAuthority](https://blog.sqlauthority.com/2009/09/08/sqlauthority-news-shaivi-dave-baby-sqlauthority/): Six days ago, on September 1st, 2009 07:03:40 AM, God blessed us with beautiful baby girl. As per Hindu Namkaran Sanskar (naming ritual), we have decided to name her as Shaivi Dave. Thank you all for all the wonderful suggestions for the baby name. Selecting the right name for the little one is really one of the most challenging tasks. According to Vedas, in Hindu religion, each occasion of a person’s life calls for elaborate rituals. After the birth of a child, naming ceremony or the Namkaran Samskar is considered one of the most important events. - [SQL SERVER - Importance of Database Schemas in SQL Server](https://blog.sqlauthority.com/2009/09/07/sql-server-importance-of-database-schemas-in-sql-server/): Beginning with SQL Server 2005, Microsoft introduced the concept of database schemas. A schema is now an independent entity- a container of objects distinct from the user who created those objects. Previously, the terms ‘user’ and ‘database object owner’ meant one and the same thing, but now the two are separate. This concept of separation of ‘user’ and ‘object owner’ may be a bit puzzling the first time one encounters it. Perhaps an example may better illustrate the concept: In SQL Server 2000, a schema was owned by, and was inextricably linked to, only one database principal (a principal is any... - [SQL SERVER - Find Gaps in The Sequence](https://blog.sqlauthority.com/2009/09/06/sql-server-find-gaps-in-the-sequence/): I have previously written two articles on the subject of missing identity and both are very well received by community. I had great fun to write article as many SQL Server expert participated in both the articles. Expert Imran Mohammed had provided excellent script to find missing identity. Please read both the articles for additional information before reading this article about finding gaps in the sequence. - [SQL SERVER - FIX - ERROR : Cannot drop the database because it is being used for replication. (Microsoft SQL Server, Error: 3724)](https://blog.sqlauthority.com/2009/09/05/sql-server-fix-error-cannot-drop-the-database-because-it-is-being-used-for-replication-microsoft-sql-server-error-3724/): I have set up replication at many different organization. One error I quite commonly face is after I have removed replication I can not remove database. When I try to remove the database it gives me following error. Cannot drop the database because it is being used for replication. (Microsoft SQL Server, Error: 3724) Fix/Workaround/Solution: The solution is very simple. Create the empty database with the same name on another server/instance first. Take full back of the same and forced restore over this database. Do let me know if you have any better idea or suggestion. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Designing SQL Server 2005 Analysis Services Cubes for Excel 2007 PivotTables](https://blog.sqlauthority.com/2009/09/04/sql-server-designing-sql-server-2005-analysis-services-cubes-for-excel-2007-pivottables/): In my recent Business Intelligence Training Roadshow August September 2009 I quite often get request to provide more details about Analysis Service Cubes for Excel 2007 PivotTable. Here is the white paper on the same subject. Microsoft Office Excel 2007 takes advantage of most of the features in Microsoft SQL Server 2005 Analysis Services. To take full advantage of these features, it is important to keep in mind the end-user experience in Office Excel 2007 when you are designing cubes. This document outlines how you can create a good end-user experience by optimizing the cube design for Office Excel 2007 PivotTable... - [SQL SERVER - What is Data Mining - A Simple Introductory Note](https://blog.sqlauthority.com/2009/09/03/sql-server-what-is-data-mining-a-simple-introductory-note/): According to MacLennan et al. (2009), data mining is defined as “the process of analyzing data to find hidden patterns using automatic methodologies.” Consider the following simple example that explains this concept. By analyzing the data on the items purchased from a supermarket or a chain of such stores, information on the products that are sold most can be obtained and accordingly supply of that particular products are increased and vice versa. Data mining, in short, is an analytical activity that studies the hidden patterns in a huge pile of data after appropriately classifying and sorting it. Who all are involved... - [SQL SERVER - Mirrored Backup and Restore and Split File Backup - Introduction](https://blog.sqlauthority.com/2009/09/02/sql-server-mirrored-backup-restore-split-file-backup-introduction/): Introduction - Mirrored Backup This article is based on a real life experience of the author while working with database backup and restore during his consultancy work for various organizations. We will go over the following important concepts of database backup and restore. Conventional Backup and Restore Spilt File Backup and Restore Mirror File Backup Understanding FORMAT Clause Miscellaneous details about Backup and Restore - [SQL SERVER - Download Script of Change Data Capture (CDC)](https://blog.sqlauthority.com/2009/09/01/sql-server-download-script-of-change-data-capture-cdc/): My article written on subject of Introduction to Change Data Capture (CDC) in SQL Server 2008 is quite a popular and I have received many request for uploading the script associated with this subject. - [SQLAuthority News - Baby SQLAuthority is here!](https://blog.sqlauthority.com/2009/09/01/sqlauthority-news-baby-sqlauthority-is-here/): September 1st, 2009 07:03:40 AM was one of the most beautiful moment of my life! God has graced us with baby girl. Nupur (my wife) and I am very happy today. We have no words to express our happiness. Baby girl and mother both are very healthy. We have yet to name our baby girl. Do you have any suggestions for Indian name? Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Effect of Oracle acquiring MySQL - A Delayed Analysis](https://blog.sqlauthority.com/2009/08/31/sqlauthority-news-effect-of-oracle-acquiring-mysql-a-delayed-analysis/): On 20 April 2009, Oracle Corporation announced its acquisition of Sun Microsystems in a deal worth about US$ 6 billion. This would have been just another one of corporate mega-deals that sound interesting in the news but really have no effect on your life. Except for the fact that with the purchase, Oracle acquired the world’s most widely used open-source database engine- MySQL. About 12 million small databases, mainly in websites and small businesses, run on the open-source MySQL platform, since it is stable, easily adaptable and most important of all for cash-strapped small companies, free. Note that ‘free’ here means... - [SQLAuthority News - Application and Multi-Server Management](https://blog.sqlauthority.com/2009/08/30/sqlauthority-news-application-and-multi-server-management/): SQL Server 2008 R2 – Application and Multi-Server Management SQL Server Technical Article Title: SQL Server 2008 R2Application and Multi-Server Management Introduction Writers: Geoff Allix Technical Reviewers: Joanne Hodgins, Omri Bahat, Morgan Oslake Published: February 2010 SQL Server 2008 R2 introduces new management tools to help improve IT efficiency and productivity. Investments in application and multi-server management will help organizations proactively manage database environments efficiently at scale through centralized visibility into resource utilization. Such investments can help streamline consolidation and upgrade initiatives across the application lifecycle—all with tools that make it fast and easy. This paper introduces the new extensions in... - [SQL SERVER - Plan Caching in SQL Server 2008](https://blog.sqlauthority.com/2009/08/29/sql-server-plan-caching-in-sql-server-2008-by-greg-low/): Plan Caching in SQL Server 2008 SQL Server Technical Article Writer:Greg Low, SolidQ Australia Technical Reviewers From Solid Quality Mentors: Andrew Kelly, Eladio Rincón, Itzik Ben-Gan Technical Reviewers From Microsoft: Adam Prout, Campbell Fraser, Xin Zhang Published: August 2009 - [SQL SERVER - Best Practices – Implementation of Database Object Schemas](https://blog.sqlauthority.com/2009/08/28/sql-server-best-practices-implementation-of-database-object-schemas/): SQL Server Best Practices – Implementation of Database Object Schemas SQL Server Technical Article Writer: Michael Redman Technical Reviewers: Sanjay Mishra, Juergen Thomas, Jimmy May, Burzin Patel, Glenn Berry (SQL Server MVP), Prem Mehra, Lindsey Allen, Thomas Kejser, Joseph Sack, Wanda He, Sharon Bjeletich Published: November 2008 - [SQL SERVER - Introduction to SQL Azure](https://blog.sqlauthority.com/2009/08/27/sql-server-introduction-to-sql-azure/): What is SQL Azure? In short, SQL Azure is simply a Microsoft branding change. SQL Services and SQL Data Services are now known as Microsoft SQL Azure and SQL Azure Database. There are a few changes, but fundamentally Microsoft’s plans to extend SQL server capabilities in cloud as web-based services remain intact. SQL Azure will continue to deliver an integrated set of services for relational databases. The reporting, analytics and data synchronization with end-users and partners also remains unchanged. This makes it most appealing to current users of SQL Server. SQL Azure is going to be the Next Big Thing from... - [SQL SERVER - SQL Server Express - A Complete Reference Guide](https://blog.sqlauthority.com/2009/08/26/sql-server-sql-server-express-a-complete-reference-guide/): SQL Server Express is one of the most valuable products of Microsoft. Very often, I face many questions with regard to SQL Server Express. Today, we will be covering some of the most commonly asked questions. - [SQLAuthority News - Business Intelligence Training Roadshow August September 2009](https://blog.sqlauthority.com/2009/08/25/sqlauthority-news-business-intelligence-training-roadshow-august-september-2009/): UPDATE : This is FREE training. I quite often receive request from readers and expert from all over the world if I do any training for SQL Server. Currently I am on Tour of 8 different stats of India and will be training on Business Intelligence Boot Camp. Here is quick image of the topics, which I am going to cover this boot camp. Currently, I am schedule to deliver the same course in many of the cities as described below. Let me know if you are interested in doing similar session at your city or organization and we can arrange... - [SQL SERVER - Index Seek vs. Index Scan - Diffefence and Usage - A Simple Note](https://blog.sqlauthority.com/2009/08/24/sql-server-index-seek-vs-index-scan-diffefence-and-usage-a-simple-note/): In this article we shall examine the two modes of data search and retrieval using indexes- index seek and index scan, and the differences between the two. - [SQLAuthority News - SQL Server 2008 Migration White Papers](https://blog.sqlauthority.com/2009/08/23/sqlauthority-news-sql-server-2008-migration-white-papers/): Quite often I get project when I am asked to migrate different database to SQL Server. Microsoft has excellent white papers written for this series. Guide to Migrating from MySQL to SQL Server 2008 In this migration guide you will learn the differences between the MySQL and SQL Server 2008 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2008 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2008. It describes the implementation differences of database... - [SQLAuthority News - Microsoft SQL Server 2008 Books Online](https://blog.sqlauthority.com/2009/08/22/sqlauthority-news-microsoft-sql-server-2008-books-online/): SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008. Books Online includes the following types of information: Setup and upgrade instructions. Information about new features and backward compatibility. Conceptual descriptions of the technologies and features in SQL Server 2008. Procedural topics describing how to use the various features in SQL Server 2008. Tutorials that guide you through common tasks. Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008. Download Microsoft SQL... - [SQL SERVER - Get Query Plan Along with Query Text and Execution Count](https://blog.sqlauthority.com/2009/08/21/sql-server-get-query-plan-along-with-query-text-and-execution-count/): Quite often, we need to know how many any particular objects have been executed on our server and what their execution plan is. I use the following handy script, which I use when I need to know the details regarding how many times any query has ran on my server along with its execution plan. You can add an additional WHERE condition if you want to learn about any specific object. - [SQL SERVER - FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.](https://blog.sqlauthority.com/2009/08/20/sql-server-fix-error-cannot-open-database-requested-by-the-login-the-login-failed-login-failed-for-user-nt-authoritynetwork-service/): This error is quite common and I have received it few times while I was working on a recent consultation project. Cannot open database requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’. This error occurs when you have configured your application with IIS, and IIS goes to SQL Server and tries to login with credentials that do not have proper permissions. This error can also occur when replication or mirroring is set up. If you search online, there are many different solutions provided to solve this error, and many of these solutions work fine. However,... - [SQLAuthority News - Two Virtual Tech Days Sessions - Watch it Online](https://blog.sqlauthority.com/2009/08/19/sqlauthority-news-two-virtual-tech-days-sessions-watch-it-online/): Indias premier online technical event is back again with the 6th Edition of Microsoft Virtual TechDays, scheduled to be held between August 19 -21, 2009. During these three days, you will have an opportunity to deep-dive into latest Microsoft Technologies and get a resolution to your most puzzling technical problems directly from the Technology Experts. I will be presenting two of the SQL Server Sessions on second day of the event on August 20th, 2009. SQL Server 2008: High Availability with SQL Server 2008 – “When, what where and how? Timing: 10:30am-11:45am Often in implementing High-Availability (HA) options with SQL Server... - [SQLAuthority News - Beyond Relational Interview on SQL Server 2008 Beyond Relational](https://blog.sqlauthority.com/2009/08/18/sqlauthority-news-beyond-relational-interview-on-sql-server-2008-beyond-relational/): SQL Server MVP and my personal friend Jacob Sebastian has published my interview on subject of Beyond Relational on his famous site Beyond Relational. Jacob is quite known for his T-SQL challenges as well. If you have not ever tried one, I suggest you give it a try and you will be addicted to it. Beyond Relational is interesting term. In simple terms, this means that it is beyond relations to traditional RDBMS. There are so many things to talk about when we stop thinking in terms of relationals. When we say “beyond relationals”, this does not mean that we move... - [SQL SERVER - Measure CPU Pressure - Detect CPU Pressure](https://blog.sqlauthority.com/2009/08/17/sql-server-measure-cpu-pressure-detect-cpu-pressure/): The CPU is responsible for not only SQL Server operations but also all the OS tasks related to the CPU. Let us learn about measuring CPU Pressure.  - [SQLAuthority News - Evaluate the Microsoft SQL Server 2008 R2 August Community Technology Preview (CTP)](https://blog.sqlauthority.com/2009/08/16/sqlauthority-news-evaluate-the-microsoft-sql-server-2008-r2-august-community-technology-preview-ctp/): SQL Server 2008 R2 expands on the value delivered in SQL Server 2008 to help your organization scale with confidence and improve IT and developer efficiency with new and enhanced tools for application and multi-server management, master data services and complex event processing. The new Self Service BI capabilities will empower end users to access, integrate, analyze and share information using business intelligence tools they already know – Microsoft Office. The August Customer Technology Preview (CTP) includes Application and Multi-server Management which will help organizations manage database environments efficiently at scale with increased visibility and control across the application lifecycle. The... - [SQL SERVER - Introduction to Change Data Capture (CDC) in SQL Server 2008](https://blog.sqlauthority.com/2009/08/15/sql-server-introduction-to-change-data-capture-cdc-in-sql-server-2008/): Simple-Talk.com has published my very first article on their site. This article is introducing Change Data Capture – the new concept introduced in SQL Server 2008. Change Data Capture records INSERTs, UPDATEs, and DELETEs applied to SQL Server tables, and makes a record available of what changed, where, and when, in simple relational ‘change tables’ rather than in an esoteric chopped salad of XML. These change tables contain columns that reflect the column structure of the source table you have chosen to track, along with the metadata needed to understand the changes that have been made. - [SQL SERVER - User Defined Functions (UDF) Limitations](https://blog.sqlauthority.com/2007/05/29/sql-server-user-defined-functions-udf-limitations/): UDF have its own advantage and usage but in this article we will see the limitation of UDF. Things UDF can not do and why Stored Procedure are considered as more flexible then UDFs. Stored Procedure are more flexibility then User Defined Functions(UDF). UDF has No Access to Structural and Permanent Tables. UDF can call Extended Stored Procedure, which can have access to structural and permanent tables. (No Access to Stored Procedure) UDF Accepts Lesser Numbers of Input Parameters. UDF can have upto 1023 input parameters, Stored Procedure can have upto 21000 input parameters. UDF Prohibit Usage of Non-Deterministic Built-in Functions... - [SQLAuthority News - Author Visit - Meeting with Readers - Top Three Features of SQL SERVER 2005](https://blog.sqlauthority.com/2007/05/28/sqlauthority-news-author-visit-meeting-with-readers-top-three-features-of-sql-server-2005/): Lots of travelers are visiting to Las Vegas due to long weekend of Memorial Day. I was invited to dinner meeting by two of my readers. It was wonderful discussion with them. We primarily discussed about scalability and upgrading issues about SQL Server. I received feedback about SQLAuthority.com site. There were two primarily request for them. I have been working on both of them already as I have received quite a few request for them from other readers as well. Beta testing has been completed, I will announce them on 1st June. While enjoying dinner I was asked interesting question and... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - SP](https://blog.sqlauthority.com/2007/05/28/sql-server-sql-joke-sql-humor-sql-laugh-sp/): One of my Friend send me(in email) following stored procedure. I laughed when I read it. Please enjoy it. It is here for amusement purpose only. Never use on development or production server. This is already dangerous you have been warned. CREATE PROCEDURE MyMarriage @ BrideGroom CHAR(NotBad), @ Bride CHAR(Good) AS BEGIN SELECT Bride FROM india_ Brides WHERE FatherInLaw = 'Millionaire' AND CarCount > 2 AND HouseStatus ='TwoStoreyed' AND BrideEduStatus='PG or Above' AND HavingBrothers='NO' AND HavingSisters ='No' AND AllowRelocate ='YES' SELECT Gold ,Cash,Car,BankBalance FROM FatherInLaw UPDATE MyBankAccout SET MyBal = MyBal + FatherinLawBal UPDATE MyLocker SET MyLockerContents = MyLockerContents + FatherinLawGold... - [SQL SERVER - Download Feature Pack for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/05/27/sql-server-download-feature-pack-for-microsoft-sql-server-2005/): Feature Pack for Microsoft SQL Server 2005 – February 2007 Download the February 2007 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. I have listed all the stand alone packages here. Even though title says February 2007, publication day of this package is 5/25/2007. All DBA should go through following list and see if their organization is using any of the application/feature and update is required for them. Microsoft ADOMD.NET Microsoft Core XML Services (MSXML) 6.0 Microsoft OLEDB Provider for DB2 Microsoft SQL Server Management Pack for MOM... - [SQL SERVER - 2005 Limiting Result Sets by Using TABLESAMPLE - Examples](https://blog.sqlauthority.com/2007/05/27/sql-server-2005-limiting-result-sets-by-using-tablesample-examples/): Introduced in SQL Server 2005, TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set. Example 1: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (10 PERCENT) Example 2: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (1000 ROWS) If you run above script many times you will notice that different numbers of... - [SQL SERVER - 2005 Replace TEXT with VARCHAR(MAX) - Stop using TEXT, NTEXT, IMAGE Data Types](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-replace-text-with-varcharmax-stop-using-text-ntext-image-data-types/): Yesterday, in Friday Afternoon team meeting. I was asked question by one of application developer “I am asked in new coding standards to use VARHCAR(MAX) instead of TEXT. Is VARCHAR(MAX) big enough to store TEXT field?” Well, I realize that I was not clear enough in my coding standard. It is extremely important for coding standards to be clear and have a enough explanation that developer have no doubt about them. I updated coding standards after the meeting. The answer is “Yes, VARCHAR(MAX) is big enough to accommodate TEXT field. TEXT, NTEXT and IMAGE data types of SQL Server 2000 will... - [SQL SERVER - 2005 Find Table without Clustered Index - Find Table with no Primary Key](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-find-table-without-clustered-index-find-table-with-no-primary-key/): One of the basic Database Rule I have is that all the table must Clustered Index. Clustered Index speeds up performance of the query ran on that table. Clustered Index are usually Primary Key but not necessarily. I frequently run following query to verify that all the Jr. DBAs are creating all the tables with no Clustered Index. USE AdventureWorks ----Replace AdventureWorks with your DBName GO SELECT DISTINCT [TABLE] = OBJECT_NAME(OBJECT_ID) FROM SYS.INDEXES WHERE INDEX_ID = 0 AND OBJECTPROPERTY(OBJECT_ID,'IsUserTable') = 1 ORDER BY [TABLE] GO Result set for AdventureWorks: TABLE ——————————————————- DatabaseLog ProductProductPhoto (2 row(s) affected) Related Post: SQL SERVER –... - [SQL SERVER - Change Default Fill Factor For Index](https://blog.sqlauthority.com/2007/05/25/sql-server-change-default-fill-factor-for-index/): SQL Server has default value for fill factor is Zero (0). The fill factor is implemented only when the index is created; it is not maintained after the index is created as data is added, deleted, or updated in the table. When creating an index, you can specify a fill factor to leave extra gaps and reserve a percentage of free space on each leaf level page of the index to accommodate future expansion in the storage of the table's data and reduce the potential for page splits. Let us learn about how to change default fill factor of index. - [SQL SERVER - Stored Procedure to display code (text) of Stored Procedure, Trigger, View or Object](https://blog.sqlauthority.com/2007/05/25/sql-server-stored-procedure-to-display-code-text-of-stored-procedure-trigger-view-or-object/): This is another popular question I receive. How to see text/content/code of Stored Procedure. System stored procedure that prints the text of a rule, a default, or an unencrypted stored procedure, user-defined function, trigger, or view. Syntax sp_helptext @objname = 'name' sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name Displaying the definition of a trigger or stored procedure sp_helptext 'dbo.nameofsp' Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Disadvantages (Problems) of Triggers](https://blog.sqlauthority.com/2007/05/24/sql-server-disadvantages-problems-of-triggers/): One of my team member asked me should I use triggers or stored procedure. Both of them has its usage and needs. I just basically told him few issues with triggers. This is small note about our discussion. Disadvantages(Problems) of Triggers It is easy to view table relationships , constraints, indexes, stored procedure in database but triggers are difficult to view. Triggers execute invisible to client-application application. They are not visible or can be traced in debugging code. It is hard to follow their logic as it they can be fired before or after the database insert/update happens. It is easy... - [SQL SERVER - 2005 Retrieve Configuration of Server](https://blog.sqlauthority.com/2007/05/24/sql-server-2005-retrieve-configuration-of-server/): Few days ago I was asked what is our SQL Server’s configuration. I provided way more information then they requested. Run following script and it will provide all the information about SQL Server . SQL Server provides in detailed information if Advanced Options are turned on. It is very clear from this that maximum number of object SQL Server can have is 2,147,483,647. It is considerably very big number. I am not worried yet about my database reaching its limit. EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure GO EXEC sp_configure 'show advanced options', 0 GO To change... - [SQL SERVER - NorthWind Database or AdventureWorks Database - Samples Databases](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases/): SQL Server 2005 does not install sample databases by default due to security reasons.I have received many questions regarding where is sample database in SQL Server 2005. One can install it afterward. AdventureWorks and AdvetureWorksDS are the new sample databases for SQL Server 2005, they can be download from here. Let us learn how to install NorthWind Database - samples databases.  - [SQL SERVER - 2005 Explanation Left Semi Join Showplan Operator and Other Operator](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-explanation-left-semi-join-showplan-operator-and-other-operator/): I come across very interesting documentation about Joins, while I was researching about article about EXCEPT yesterday. There are few interesting kind of join operations exists when execution plan is displayed in text format. Left Semi Join Showplan Operator The Left Semi Join operator returns each row from the first (top) input when there is a matching row in the second (bottom) input. If no join predicate exists in the Argument column, each row is a matching row. Left Anti Semi Join Showplan Operator The Left Anti Semi Join operator returns each row from the first (top) input when there is... - [SQLAuthority News - Funny One Liners - Humor](https://blog.sqlauthority.com/2007/05/23/sqlauthority-news-funny-one-liners-humor/): Once in a while we should laugh and relax. Here are few of my favorite funny one liners which I often use in my presentations. Let us start- Just read that 4,153,237 people got married last year, not to cause any trouble, but shouldn't that be an even number? - [SQLAuthority News - T-Shirts in Action](https://blog.sqlauthority.com/2007/05/22/sqlauthority-news-t-shirts-in-action/): Thank you All for great response to SQLAuthority T-Shirts. I have ran out of all of them. Please put your request here. I will go over all of them soon and see what I can do. They are made from high quality fiber and very comfortable. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Comparison EXCEPT operator vs. NOT IN](https://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/): The EXCEPT operator returns all of the distinct rows from the query to the left of the EXCEPT operator when there are no matching rows in the right query. The EXCEPT operator is equivalent of the Left Anti Semi Join. EXCEPT operator works the same way NOT IN. EXCEPTS returns any distinct values from the query to the left of the EXCEPT operand that do not also return from the right query. - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - T-Shirt](https://blog.sqlauthority.com/2007/05/21/sql-server-sql-joke-sql-humor-sql-laugh-t-shirt/): My friend sent me this in an email two days ago as he wanted me to have SQLAuthority T-Shirt with this image. I found it funny, I am not sure if I will have this on SQLAuthority T-Shirts. Please pay attention to the options available to select. I spend more than 3 hours to find the original source as my friend did not remember the source. Let's see some SQL Humor here: - [SQL SERVER - Top 15 free SQL Injection Scanners - Link to Security Hacks](https://blog.sqlauthority.com/2007/05/21/sql-server-top-15-free-sql-injection-scanners-link-to-security-hacks/): SQL injection is a technique for exploiting web applications that use client-supplied data in SQL queries, but without first stripping potentially harmful characters. Checking for SQL Injection vulnerabilities involves auditing your web applications and the best way to do it is by using automated SQL Injection Scanners. Security-Hacks.com compiled a list of free SQL Injection Scanners. I really enjoy reading the article. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Build List Link](https://blog.sqlauthority.com/2007/05/21/sql-server-2005-build-list-link/): What is Build List? All SQL Server has build list, this is incremental list of numbers which indicates which version SQL Server is running and what are its compatibility, patches etc. Regular Columnist Steve Jones of SQL Server Central has created build list. It is updated and informative. Microsoft Hot fixes are always cumulative. You can find your build number with: SELECT@@Version Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Code Formatting Tools](https://blog.sqlauthority.com/2007/05/20/sql-server-sql-code-formatter-tools/): SQL Code Formatting is very important. Every SQL Server DBA has its own preference about formatting. I like to format all keywords to uppercase. Following are two online tools, which formats SQL Code very good. I tested following script with those tools and I found two of the tools worth mentioning here. - [SQL SERVER - Script/Function to Find Last Day of Month](https://blog.sqlauthority.com/2007/05/20/sql-server-scriptfunction-to-find-last-day-of-month/): Following query will find the last day of the month. Query also take care of Leap Year. Script: DECLARE @date DATETIME SET @date='2008-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO DECLARE @date DATETIME SET @date='2007-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO ResultSet: LastDayOfMonth ----------------------- 2008-02-29 00:00:00.000 (1 row(s) affected) LastDayOfMonth ----------------------- 2007-02-28 00:00:00.000 (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ASCII to Decimal and Decimal to ASCII Conversion](https://blog.sqlauthority.com/2007/05/19/sql-server-ascii-to-decimal-and-decimal-to-ascii/): In this blog post we will see how we can convert ASCII to Decimal and Decimal to ASCII. In simple words, we will see the decimal and ASCII conversion. - [SQL SERVER - Math Functions Available in SQL Server](https://blog.sqlauthority.com/2007/05/19/sql-server-math-functions-for-2005/): The large majority of math functions is specific to applications using trigonometry, calculus, and geometry. This is very important and it is very difficult to have all of them together at place. - [SQL SERVER - 2005 Understanding Trigger Recursion and Nesting with examples](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-understanding-trigger-recursion-and-nesting-with-examples/): Trigger events can be fired within another trigger action. One Trigger execution can trigger even on another table or same table. This trigger is called NESTED TRIGGER or RECURSIVE TRIGGER. Nested triggers SQL Server supports the nesting of triggers up to a maximum of 32 levels. Nesting means that when a trigger is fired, it will also cause another trigger to be fired. If a trigger creates an infinitive loop, the nesting level of 32 will be exceeded and the trigger will cancel with an error message. Recursive triggers When a trigger fires and performs a statement that will cause the... - [SQL SERVER - 2005 - SSMS Change T-SQL Batch Separator](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-ssms-change-t-sql-batch-separator/): I recently received one big file with many T-SQL batches. It was a very big file and I was asked that this file was tested many times and it can run one transaction. I noticed the separator of the batches is not GO but it was EndBatch. I have followed two options to run the whole batch in one transaction. Let us learn how to change T-SQL Batch Separator. - [SQLAuthority News - Limited Edition T-Shirts Arrived](https://blog.sqlauthority.com/2007/05/17/sqlauthority-news-limited-edition-t-shirts-arrived/): I have received quite a few request for SQLAuthority.com T-shirts. Every day I receive lots of emails and suggestions. Many readers have great suggestions and have helped to improve content. First of all I express my gratitude to all of you. Few of my loyal and enthusiastic readers will receive the T-shirt by tomorrow. T-shirts are very limited. I have kept only two for me and have shipped all other. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Disable Index - Enable Index - ALTER Index](https://blog.sqlauthority.com/2007/05/17/sql-server-disable-index-enable-index-alter-index/): There are few requirements in real world when Index on table needs to be disabled and re-enabled afterwards. e.g. DTS, BCP, BULK INSERT etc. Index can be dropped and recreated. I prefer to disable the Index if I am going to re-enable it again. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO ----Enable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact REBUILD GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-1205-transaction-process-id-was-deadlocked-on-resources-with-another-process-and-has-been-chosen-as-the-deadlock-victim-rerun-the-transaction/): Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction. - [SQL SERVER - Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-130-cannot-perform-an-aggregate-function-on-an-expression-containing-an-aggregate-or-a-subquery/): Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery Following statement will give the following error: “Cannot perform an aggregate function on an expression containing an aggregate or a subquery.” MS SQL Server doesn’t support it. USE PUBS GO SELECT AVG(COUNT(royalty)) RoyaltyAvg FROM dbo.roysched GO You can get around this problem by breaking out the computation of the average in derived tables. USE PUBS GO SELECT AVG(t.RoyaltyCounts) FROM ( SELECT COUNT(royalty) AS RoyaltyCounts FROM dbo.roysched ) T GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL. - [SQL SERVER - Binary Sequence Generator - Truth Table Generator](https://blog.sqlauthority.com/2007/05/15/sql-server-binary-sequence-generator-truth-table-generator/): Run following script in query editor to generate truth table with its decimal value and binary sequence. The truth table is 512 rows long. This can be extended or reduced by adding or removing cross joins respectively. Script: USE AdventureWorks; DECLARE @Binary TABLE ( Digit bit) INSERT @Binary VALUES (0) INSERT @Binary VALUES (1) SELECT ((a.Digit*256) + (b.Digit*128) + (c.Digit*64) + (d.Digit*32) + (e.Digit*16) + (f.Digit*8) + (g.Digit*4) + (h.Digit*2) + (i.Digit*1)) DecimalValue, a.Digit '256', b.Digit '128' , c.Digit '64', d.Digit '32', e.Digit '16', f.Digit '8', g.Digit '4', h.Digit '2', i.Digit '1' FROM @Binary a CROSS JOIN @Binary b CROSS JOIN... - [SQL SERVER - DBCC commands List - documented and undocumented](https://blog.sqlauthority.com/2007/05/15/sql-server-dbcc-commands-list-documented-and-undocumented/): Database Consistency Checker (DBCC) commands can gives valuable insight into what’s going on inside SQL Server system. DBCC commands have powerful documented functions and many undocumented capabilities. Current DBCC commands are most useful for performance and troubleshooting exercises. To learn about all the DBCC commands run following script in query analyzer. DBCC TRACEON(2520) DBCC HELP (‘?’) GO To learn about syntax of an individual DBCC command run following script in query analyzer. DBCC HELP(<command>) GO Following is the list of all the DBCC commands and their syntax. List contains all documented and undocumented DBCC commands. DBCC activecursors [(spid)] DBCC addextendedproc (function_name,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Photo](https://blog.sqlauthority.com/2007/05/14/sql-server-sql-joke-sql-humor-sql-laugh-photo/): Pay attention to the last line of the ingredients. I found this entry at Worse Than Failure. I found it humorous. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - MS TechNet : Storage Top 10 Best Practices](https://blog.sqlauthority.com/2007/05/14/sql-server-ms-technet-storage-top-10-best-practices/): This one of the very interesting article I read regarding SQL Server 2005 Storage. Please refer original article at MS TechNet here. Understand the IO characteristics of SQL Server and the specific IO requirements / characteristics of your application. More / faster spindles are better for performance. Try not to “over” optimize the design of the storage; simpler designs generally offer good performance and more flexibility. Validate configurations prior to deployment. Always place log files on RAID 1+0 (or RAID 1) disks. Isolate log from data at the physical disk level. Consider configuration of TEMPDB database. Lining up the number of... - [SQL SERVER - Query to Find First and Last Day of Current Month - Date Function](https://blog.sqlauthority.com/2007/05/13/sql-server-query-to-find-first-and-last-day-of-current-month/): Following query will run respective on today's date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month. Let us see how we can do this with the help of Date Function in SQL Server. - [SQL SERVER - UDF - Function to Parse AlphaNumeric Characters from String](https://blog.sqlauthority.com/2007/05/13/sql-server-udf-function-to-parse-alphanumeric-characters-from-string/): Following function keeps only Alphanumeric characters in string and removes all the other character from the string. This is very handy function when working with Alphanumeric String only. I have used this many times. CREATE FUNCTION dbo.UDF_ParseAlphaChars ( @string VARCHAR(8000) ) RETURNS VARCHAR(8000) AS BEGIN DECLARE @IncorrectCharLoc SMALLINT SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) WHILE @IncorrectCharLoc > 0 BEGIN SET @string = STUFF(@string, @IncorrectCharLoc, 1, '') SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) END SET @string = @string RETURN @string END GO —-Test SELECT dbo.UDF_ParseAlphaChars('ABC”_I+{D[]}4|:e;””5,<.F>/?6') GO Result Set : ABCID4e5F6 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List all the database](https://blog.sqlauthority.com/2007/05/12/sql-server-2005-list-all-the-database/): List all the database on SQL Servers. All the following Stored Procedure list all the Databases on Server. I personally use EXEC sp_databases because it gives the same results as other but it is self explaining. ----SQL SERVER 2005 System Procedures EXEC sp_databases EXEC sp_helpdb ----SQL 2000 Method still works in SQL Server 2005 SELECT name FROM sys.databases SELECT name FROM sys.sysdatabases ----SQL SERVER Un-Documented Procedure EXEC sp_msForEachDB 'PRINT ''?''' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support](https://blog.sqlauthority.com/2007/05/12/sql-server-fix-error-msg-6263-level-16-state-1-line-2-enabling-sql-server-2005-for-clr-support/): Error: Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support 1) Enable Server for CLR Support. - [SQL SERVER - Explanation SQL Command GO](https://blog.sqlauthority.com/2007/05/11/sql-server-explanation-sql-command-go/): GO is not a Transact-SQL statement; it is often used in T-SQL code. Go causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches. SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is... - [SQL SERVER - Download Microsoft SQL Server 2005 System Views Map](https://blog.sqlauthority.com/2007/05/11/sql-server-download-microsoft-sql-server-2005-system-views-map/): The Microsoft SQL Server 2005 System Views Map shows the key system views included in SQL Server 2005, and the relationships between them. It is available to download from Microsoft Site. It can be printed and mounted at Office Depot or Kinko’s. Download SQL SERVER 2005 System Views Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 Katmai - Download Datasheet Final from Microsoft](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-download-datasheet-final-from-microsoft/): Few interesting thing about Katmai. SQL Server “Katmai” will provide a more secure, reliable and manageable enterprise data platform. SQL Server “Katmai” will enable developers and administrators to save time by allowing them to store and consume any type of data from XML to documents. SQL Server “Katmai” provides a more scalable infrastructure that enables IT to drive business intelligence throughout the organization. SQL Server “Katmai” along with .NET Framework 3.0 will accelerate the development of the next generation of applications. Reference : Pinal Dave (https://blog.sqlauthority.com) MS SQL Server (All the above text) Download Final Datasheet of Katmai from Microsoft - [SQL SERVER - Fix: Error: HResult 0x2, Named Pipes Provider: Could not open a connection](https://blog.sqlauthority.com/2007/05/10/sql-server-fix-error-hresult-0x2-level-16-state-1-named-pipes-provider-could-not-open-a-connection-to-sql-server/): In this blog post we are going to fix the error which is related to Named Pipes Provider. - [SQL SERVER - 2008 Katmai - Your Data, Any Place, Any Time](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-your-data-any-place-any-time/): I was following up on the news of first Microsoft Business Intelligence (BI) Conference held at Seattle. Good news is – SQL Server 2008 code name ‘Katmai’ is announced. I went to the official website I like the catchy line “Your Data, Any Place, Any Time“. As per my opinion the most important thing about Katmai is that it can be used to manage any type of data, including relational data, documents, geographic information and XML. The question I received many times since yesterday is : I am still using SQL Server 2000, I was planning to upgrade to SQL Server... - [SQL SERVER - Fix : Error 2501 : Cannot find a table or object with the name . Check the system catalog.](https://blog.sqlauthority.com/2007/05/09/sql-server-fix-error-2501-cannot-find-a-table-or-object-with-the-name-check-the-system-catalog/): Error 2501 : Cannot find a table or object with the name . Check the system catalog. This is very generic error beginner DBAs or Developers faces. The solution is very simple and easy. Follow the direction below in order. Fix/Workaround/Solution: Make sure that correct Database is selected. If not please run USE YourDatabase. Check the object or table name. They must be spelled correct. If database is case sensitive please use correct case. Use object belongs to other owner use two parts name as scheme_name.object_name. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - MIS2007 Part II - Database Raid Discussion](https://blog.sqlauthority.com/2007/05/09/sqlauthority-news-author-visit-mis2007-part-ii-database-raid-discussion/): MIS2007 is really going good. There are many things going on. As I mentioned in my previous article, It is really pleasure to meet industry leaders. There was discussion about what is good for database RAID 5 configuration or RAID 10. This subject is always very interesting. We were discussing from small databases (5GB) to larger databases(5 TB). The question was which RAID 5 or RAID 10. Surprisingly, everybody who participated in discussion said their experience says RAID 10 is better for this particular application as there are lots of reads and writes in database. One of the expert suggested that... - [SQL SERVER - Index Optimization CheckList](https://blog.sqlauthority.com/2007/05/08/sql-server-index-optimization-checklist/): Index optimization is always interesting subject to me. Every time I receive requests to help optimize query or query on any specific table. I always ask Jr.DBA to go over following list first before I take a look at it. Most of the time the Query Speed is optimized just following basic rules mentioned below. Once following checklist applied interesting optimization part begins which only experiment and experience can resolve. - [SQLAuthority News - Author Visit - The 2007 Marketing Innovation Summit, Las Vegas](https://blog.sqlauthority.com/2007/05/08/sqlauthority-news-author-visit-the-2007-marketing-innovation-summit-las-vegas/): I am attending The 2007 Marketing Innovation Summit“, Las Vegas. It started on 5/6/2007 and will continue till 5/9/2007. Unica Corporation has arranged this conference. The MIS 2007 Agenda includes: Case studies and best practices Sessions focused on Relationship Marketing, Internet Marketing and Marketing Operations Hands on “how to” sessions General sessions from distinguished industry experts A one-day Pre-Summit Affinium New User Workshop and Getting Prepared for Affinium Plan Post-Summit Hands-On Training Evening networking activities In two days so far, I have learned a lot and have met many industry leaders. Talking about cutting edge technology and SQL Server was perfect... - [SQL SERVER - Top 10 Hidden Gems in SQL Server 2005](https://blog.sqlauthority.com/2007/05/07/sql-server-top-10-hidden-gems-in-sql-server-2005/): Top 10 Hidden Gems in SQL Server 2005 By Cihan Biyikoglu SQL Server 2005 has hundreds of new and improved components. Some of these improvements get a lot of the spotlight. However there is another set that are the hidden gems that help us improve performance, availability or greatly simplify some challenging scenarios. This paper lists the top 10 such features in SQL Server 2005 that we have discovered through the implementation with some of our top customers and partners. TableDiff.exe Triggers for Logon Events (New in Service Pack 2) Boosting performance with persisted-computed-columns (pcc). DEFAULT_SCHEMA setting in sys.database_principles Forced Parameterization... - [SQL SERVER - 2005/2000 Examples and Explanation for GOTO](https://blog.sqlauthority.com/2007/05/07/sql-server-20052000-examples-and-explanation-for-goto/): The GOTO statement causes the execution of the T-SQL batch to stop processing the following commands to GOTO and processing continues from the label where GOTO points. GOTO statement can be used anywhere within a procedure, batch, or function. GOTO can be nested as well. GOTO can be executed by any valid user on SQL SERVER. GOTO can co-exists with other control of flow statements (IF…ELSE, WHILE). GOTO can only go(jump) to label in the same batch, it can not go to label out side of the batch. Syntax: Define the label: label: ALTER the execution: GOTO label Notes from MSDN... - [SQL SERVER - Creating Comma Separate Values List from Table - UDF - SP](https://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/): Following script will create common separate values (CSV) or common separate list from tables. convert list to table. Following script is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. There are three ways to do this. 1) Using COALESCE 2) Using SELECT Smartly 3) Using CURSOR. The table is example is: TableName: NumberTable NumberCols first second third fourth fifth Output : first,second,third,fourth,fifth Option 1: This is... - [SQL SERVER - UDF - Function to Convert List to Table](https://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/): Following Users Defined Functions will convert list to table. It also supports user defined delimiter. Following UDF is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. CREATE FUNCTION dbo.udf_List2Table ( @List VARCHAR(MAX), @Delim CHAR ) RETURNS @ParsedList TABLE ( item VARCHAR(MAX) ) AS BEGIN DECLARE @item VARCHAR(MAX), @Pos INT SET @List = LTRIM(RTRIM(@List))+ @Delim SET @Pos = CHARINDEX(@Delim, @List, 1) WHILE @Pos > 0 BEGIN SET... - [SQL SERVER - 2005 Enable CLR using T-SQL script](https://blog.sqlauthority.com/2007/05/05/sql-server-2005-enable-clr-using-t-sql-script/): Before doing any .Net coding in SQL Server you must enable the CLR. In SQL Server 2005, the CLR is OFF by default. This is done in an effort to limit security vulnerabilities. Following is the script which will enable CLR. EXEC sp_CONFIGURE 'show advanced options' , '1'; GO RECONFIGURE; GO EXEC sp_CONFIGURE 'clr enabled' , '1' GO RECONFIGURE; GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - UDF - User Defined Function to Find Weekdays Between Two Dates](https://blog.sqlauthority.com/2007/05/05/sql-server-udf-user-defined-function-to-find-weekdays-between-two-dates/): Following user defined function returns number of weekdays between two dates specified. This function excludes the dates which are passed as input params. It excludes Saturday and Sunday as they are weekends. I always had this function with for reference but after some research I found original source website of the function. This function has been written by Author Alexander Chigrik. CREATE FUNCTION dbo.spDBA_GetWeekDays ( @StartDate datetime, @EndDate datetime ) RETURNS INT AS BEGIN DECLARE @WorkDays INT, @FirstPart INT DECLARE @FirstNum INT, @TotalDays INT DECLARE @LastNum INT, @LastPart INT IF (DATEDIFF(DAY, @StartDate, @EndDate) 0) THEN @LastPart - 1 ELSE 0 END... - [SQL SERVER - Fix : Error : Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset DBSCHEMA_TABLES_INFO for OLE DB provider SQLNCLI for linked server LinkedServerName](https://blog.sqlauthority.com/2007/05/04/sql-server-fix-error-msg-7311-level-16-state-2-line-1-cannot-obtain-the-schema-rowset-dbschema_tables_info-for-ole-db-provider-sqlncli-for-linked-server-linkedservername/): You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server. Error: The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator. Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset “DBSCHEMA_TABLES_INFO” for OLE DB provider “SQLNCLI” for linked server “<LinkedServerName>”. The provider supports the interface, but returns a failure code when it is used. Fix/WorkAround/Solution: Use Windows Authentication mode For a... - [SQL SERVER - Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts)](https://blog.sqlauthority.com/2007/05/04/sql-server-download-sql-server-management-studio-keyboard-shortcuts-ssms-shortcuts/): Download SQL Server Management Studio Keyboard Shortcuts I have received many emails appreciating my article Query Analyzer Shortcuts and requesting same for SQL Server Management Studio Keyboard Shortcuts. I see frequent downloads of the PDF generated by SQLAuthority for the same on server. There is original article on MSDN site. I have combined complete article in one PDF again. It is easy to refer, print and manage. Download SQL Server Management Studio Keyboard Shortcuts Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC Commands to Free SQL Server Memory Caches](https://blog.sqlauthority.com/2007/05/03/sql-server-dbcc-commands-to-free-several-sql-server-memory-caches/): Lots of people do not know that following command can be very helpful to clear your memory caches of SQL Server. I have often seen people restarting their entire system to clear the memory caches. - [SQL SERVER - Enable Login - Disable Login using ALTER LOGIN - Change name of the 'SA'](https://blog.sqlauthority.com/2007/05/03/sql-server-enable-login-disable-login-using-alter-login-change-name-of-the-sa/): Enable Login – Disable Login using ALTER LOGIN – Change name of the ‘SA’ - [SQL SERVER - FIX : ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup](https://blog.sqlauthority.com/2007/05/02/sql-server-fix-error-1101-could-not-allocate-a-new-page-for-database-because-of-insufficient-disk-space-in-filegroup/): ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup . Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. Fix/Workaround/Solution: Make sure there is enough Hard Disk space where database files are stored on server. Turn on AUTOGROW for file groups. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 TOP Improvements/Enhancements](https://blog.sqlauthority.com/2007/05/02/sql-server-2005-top-improvementsenhancements/): SQL Server 2005 introduces two enhancements to the TOP clause. 1) User can specify an expression as an input to the TOP keyword. 2) User can use TOP in modification statements (INSERT, UPDATE, and DELETE). Explanation : User can specify an expression as an input to the TOP keyword. In SQL SERVER 2000 usage of TOP is implemented in following query. SELECT TOP 10 TableColumnID FROM TableName   For ages Developers and DBAs wants to pass parameters to TOP keyword. IN SQL SERVER 2005 it is possible. Example, @iNum is variables set before SELECT statement is ran. DECLARE @iNum INT SET... - [SQL SERVER - User Defined Functions (UDF) to Reverse String - UDF_ReverseString](https://blog.sqlauthority.com/2007/05/01/sql-server-user-defined-functions-udf-to-reverse-string-udf_reversestring/): UDF_ReverseString UDF_ReverseString User Defined Functions returns the Reversed String starting from certain position. First parameters takes the string to be reversed. Second parameters takes the position from where the string starts reversing. Script of UDF_ReverseString function to return Reverse String. CREATE FUNCTION UDF_ReverseString ( @StringToReverse VARCHAR(8000), @StartPosition INT ) RETURNS VARCHAR(8000) AS BEGIN IF (@StartPosition <= 0) OR (@StartPosition > LEN(@StringToReverse)) RETURN (REVERSE(@StringToReverse)) RETURN (STUFF (@StringToReverse, @StartPosition, LEN(@StringToReverse) - @StartPosition + 1, REVERSE(SUBSTRING (@StringToReverse, @StartPosition LEN(@StringToReverse) - @StartPosition + 1)))) END GO Usage of above UDF_ReverseString: Reversing the string from third position SELECT dbo.UDF_ReverseString('forward string',3) Results Set : forgnirts draw Reversing... - [SQL SERVER - Copy Column Headers in Query Analyzers in Result Set](https://blog.sqlauthority.com/2007/05/01/sql-server-copy-column-headers-in-query-analyzers-in-result-set/): Copy Column Headers in Query Analyzers in Result Set. In Query Analyzer go to Menu >> Tools >> Options >> Results Select Default results Target: Results to Text Results output format:(*): Tab Delimited Print column headers(*): Checkbox ON(check) [youtube=http://www.youtube.com/watch?v=BL5GO-jH3HA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com 100th Post - Gratitude Note to Readers](https://blog.sqlauthority.com/2007/05/01/sqlauthoritycom-101st-post-gratitude-note-to-readers/): Hello All, I would like to express my deep gratitude to all of my readers for their emails, comments, suggestions and continuous support on the occasion of 101st post on this blog. I would like to extend my gratitude to my parents. In good times or trying times my parents are there with me always. Mom and Dad thank you for your encouragement, warmth, advise and continuous love. Kind Regards and Best Wishes, Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Collate - Case Sensitive SQL Query Search](https://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/): In this blog post we are going to learn about how to do Case Sensitive SQL Query Search. If Column1 of Table1 has following values ‘CaseSearch, casesearch, CASESEARCH, CaSeSeArCh’, following statement will return you all the four records. - [SQL SERVER - FIX : ERROR : Msg 3159, Level 16, State 1, Line 1 - Msg 3013, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/30/sql-server-fix-error-msg-3159-level-16-state-1-line-1-msg-3013-level-16-state-1-line-1/): While moving some of the script from SQL SERVER 2000 to SQL SERVER 2005 our migration team faced following error. Msg 3159, Level 16, State 1, Line 1 The tail of the log for the database “AdventureWorks” has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. Following is the similar script using AdventureWorks... - [SQL SERVER - SET ROWCOUNT - Retrieving or Limiting the First N Records from a SQL Query](https://blog.sqlauthority.com/2007/04/30/sql-server-set-rowcount-retrieving-or-limiting-the-first-n-records-from-a-sql-query/): A SET ROWCOUNT statement simply limits the number of records returned to the client during a single connection. As soon as the number of rows specified is found, SQL Server stops processing the query. The syntax looks like this: - [SQL SERVER - 2005 Security DataSheet](https://blog.sqlauthority.com/2007/04/29/sql-server-2005-security-datasheet/): Microsoft has implemented strong security features into the Microsoft® SQL Server™ 2005, which provides a security-enabled platform for enterprise-class relational database and analysis solutions. SQL Server 2005 provides cutting edge security technology and addresses several security issues, including automatic secured updates and encryption of sensitive data. Download the SQL Server 2005 Security DataSheet from SQLAuthority.com Download the SQL Server 2005 Security DataSheet from Microsoft.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Random Number Generator Script - SQL Query](https://blog.sqlauthority.com/2007/04/29/sql-server-random-number-generator-script-sql-query/): Random Number Generator. There are many methods to generate random numbers in SQL Server. Method 1: Generate Random Numbers (Int) between Rang - [SQL SERVER - Replication Keywords Explanation and Basic Terms](https://blog.sqlauthority.com/2007/04/29/sql-server-replication-keywords-explanation-and-basic-terms/): While discussing replication with Jr. DBAs at work, I realize some of them have not experienced replication feature of SQL SERVER. Following is quick reference of replication keywords I created for easy conversation. - [SQL SERVER - Explanation SQL SERVER Merge Join](https://blog.sqlauthority.com/2007/04/28/sql-server-explanation-sql-server-merge-join/): The Merge Join transformation provides an output that is generated by joining two sorted data sets using a FULL, LEFT, or INNER join. The Merge Join transformation requires that both inputs be sorted and that the joined columns have matching meta-data. User cannot join a column that has a numeric data type with a column that has a character data type. If the data has a string data type, the length of the column in the second input must be less than or equal to the length of the column in the first input with which it is merged. USE pubs... - [SQL SERVER - Restrictions of Views - T SQL View Limitations](https://blog.sqlauthority.com/2007/04/28/sql-server-restrictions-of-views-t-sql-view-limitations/): UPDATE: (5/15/2007) Thank you Ben Taylor for correcting errors and incorrect information from this post. He is Database Architect and writes Database Articles at www.sswug.org. I have been coding as T-SQL for many years. I never have to use view ever in my career. I do not see in my near future I am using Views. I am able to achieve same database architecture goal using either using Third Normal tables, Replications or other database design work around.SQL Views have many many restrictions. There are few listed below. I love T-SQL but I do not like using Views. - [SQL SERVER - Good, Better and Best Programming Techniques](https://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/): A week ago, I was invited to meeting of programmers. Subject of meeting was “Good, Better and Best Programming Techniques”. I had made small note before I went to meeting, so if I have to talk about or discuss SQL Server it can come handy. Well, I did not get chance to talk on that as it was very causal and just meeting and greetings. Everybody just talked about what they think about their job. I talked very briefly about SQL Server, my current job and some funny incident at work. Everybody laughed big when I talked about funny bug ticket... - [SQL SERVER - Query to Retrieve the Nth Maximum Value](https://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/): Replace Employee with your table name, and Salary with your column name. Where N is the level of Salary to be determined. Let us see a query to retrieve the Nth Maximum Value. - [SQL SERVER - Locking Hints and Examples](https://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/): Locking Hints and Examples are as follows. The usage of them is the same but the effect is different. Let us learn it today together. - [SQL SERVER - SELECT vs. SET Performance Comparison](https://blog.sqlauthority.com/2007/04/27/sql-server-select-vs-set-performance-comparison/): Usage: SELECT : Designed to return data. SET : Designed to assign values to local variables. While testing the performance of the following two scripts in query analyzer, interesting results are discovered. SET @foo1 = 1; SET @foo2 = 2; SET @foo3 = 3; SELECT @foo1 = 1, @foo2 = 2, @foo3 = 3; While comparing their performance in loop SELECT statement gives better performance then SET. In other words, SET is slower than SELECT. The reason is that each SET statement runs individually and updates on values per execution, whereas the entire SELECT statement runs once and update all three... - [SQL SERVER - Difference Between Unique Index vs Unique Constraint](https://blog.sqlauthority.com/2007/04/26/sql-server-difference-between-unique-index-vs-unique-constraint/): Unique Index and Unique Constraint are the same. They achieve same goal. SQL Performance is same for both. Add Unique Constraint ALTER TABLE dbo.<tablename> ADD CONSTRAINT <namingconventionconstraint> UNIQUE NONCLUSTERED ( <columnname> ) ON [PRIMARY] Add Unique Index CREATE UNIQUE NONCLUSTERED INDEX <namingconventionconstraint> ON dbo.<tablename> ( <columnname> ) ON [PRIMARY] There is no difference between Unique Index and Unique Constraint. Even though syntax are different the effect is the same. Unique Constraint creates Unique Index to maintain the constraint to prevent duplicate keys. Unique Index or Primary Key Index are physical structure that maintain uniqueness over some combination of columns across all... - [SQL SERVER - Enable xp_cmdshell using sp_configure](https://blog.sqlauthority.com/2007/04/26/sql-server-enable-xp_cmdshell-using-sp_configure/): The xp_cmdshell option is a server configuration option that enables system administrators to control whether the xp_cmdshell extended stored procedure can be executed on a system. - [SQL SERVER - 2005 - DBCC ROWLOCK - Deprecated](https://blog.sqlauthority.com/2007/04/26/sql-server-2005-dbcc-rowlock-deprecated/): Title says all. My search engine log says many web users are looking for DBCC ROWLOCK in SQL SERVER 2005. It is deprecated feature for SQL SERVER 2005. It is Automatically on for SQL SERVER 2005. More Deprecated Features of SQL SERVER 2005 Refer MSDN Discontinued Database Engine Functionality in SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Alternate Fix : ERROR 1222 : Lock request time out period exceeded](https://blog.sqlauthority.com/2007/04/25/sql-server-alternate-fix-error-1222-lock-request-time-out-period-exceeded/): ERROR 1222 : Lock request time out period exceeded. - [SQL SERVER - ERROR Messages - sysmessages error severity level](https://blog.sqlauthority.com/2007/04/25/sql-server-error-messages-sysmessages-error-severity-level/): SQL ERROR Messages Each error message displayed by SQL Server has an associated error message number that uniquely identifies the type of error. The error severity levels provide a quick reference for you about the nature of the error. The error state number is an integer value between 1 and 127; it represents information about the source that issued the error. The error message is a description of the error that occurred. The error messages are stored in the sysmessages system table. - [SQL SERVER - 2005 Take Off Line or Detach Database](https://blog.sqlauthority.com/2007/04/25/sql-server-2005-take-off-line-or-detach-database/): EXEC sp_dboption N'mydb', N'offline', N'true' OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK AFTER 30 SECONDS OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK IMMEDIATE Using the alter database statement (SQL Server 2k and beyond) is the preferred method. The rollback after statement will force currently executing statements to rollback after N seconds. The default is to wait for all currently running transactions to complete and for the sessions to be terminated. Use the rollback immediate clause to rollback transactions immediately. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - TRIM() Function - UDF TRIM()](https://blog.sqlauthority.com/2007/04/24/sql-server-trim-function-udf-trim/): SQL Server does not have function which can trim leading or trailing spaces of any string. TRIM() is very popular function in many languages. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. I was expecting SQL Server 2005 to have TRIM() function. Unfortunately, SQL Server 2005 does not have that either. I have created very simple UDF which does the same work. FOR SQL SERVER 2000: CREATE FUNCTION dbo.TRIM(@string VARCHAR(8000)) RETURNS VARCHAR(8000) BEGIN RETURN LTRIM(RTRIM(@string)) END GO FOR SQL SERVER 2005: CREATE FUNCTION dbo.TRIM(@string VARCHAR(MAX)) RETURNS VARCHAR(MAX) BEGIN RETURN LTRIM(RTRIM(@string)) END GO Both the above... - [SQL SERVER - Six Properties of Relational Tables](https://blog.sqlauthority.com/2007/04/24/sql-server-six-properties-of-relational-tables/): Relational tables have six properties: Values Are Atomic This property implies that columns in a relational table are not repeating group or arrays. The key benefit of the one value property is that it simplifies data manipulation logic. Such tables are referred to as being in the “first normal form” (1NF). Column Values Are of the Same Kind In relational terms this means that all values in a column come from the same domain. A domain is a set of values which a column may have. This property simplifies data access because developers and users can be certain of the type... - [SQL SERVER - 2005 Collation Explanation and Translation](https://blog.sqlauthority.com/2007/04/24/sql-server-2005-collation-explanation-and-translation/): Just a day before one of our SQL SERVER 2005 needed Case-Sensitive Binary Collation. When we install SQL SERVER 2005 it gives options to select one of the many collation. I says in words like ‘Dictionary order, case-insensitive, uppercase preference’. I was confused for little while as I am used to read collation like ‘SQL_Latin1_General_Pref_Cp1_CI_AS_KI_WI’. I did some research and find following link which explains many of the SQL SERVER 2005 collation. Complete documentation MSDN – SQL SERVER Collation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Query Analyzer - Microsoft SQL SERVER Management Studio](https://blog.sqlauthority.com/2007/04/23/sql-server-2005-query-analyzer-microsoft-sql-server-management-studio/): Following may be very simple to some and helpful to other type of question. I have seen this in my server log as well as this has been always first question in my Developer Team. Where is SQL SERVER 2005 Query Analyzer? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). To see the familiour Query Analyzer Window follow the image below. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Find Seed Values, Increment Values and Current Identity Column value of the table](https://blog.sqlauthority.com/2007/04/23/sql-server-query-to-find-seed-values-increment-values-and-current-identity-column-value-of-the-table/): Following script will return all the tables which has identity column. It will also return the Seed Values, Increment Values and Current Identity Column value of the table. SELECT IDENT_SEED(TABLE_NAME) AS Seed, IDENT_INCR(TABLE_NAME) AS Increment, IDENT_CURRENT(TABLE_NAME) AS Current_Identity, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1 AND TABLE_TYPE = 'BASE TABLE' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Understanding new Index Type of SQL Server 2005 Included Column Index along with Clustered Index and Non-clustered Index](https://blog.sqlauthority.com/2007/04/23/sql-server-understanding-new-index-type-of-sql-server-2005-included-column-index-along-with-clustered-index-and-non-clustered-index/): Clustered Index Only 1 allowed per table Physically rearranges the data in the table to conform to the index constraints. - [SQL SERVER - Raid Configuration - RAID 10](https://blog.sqlauthority.com/2007/04/22/sql-server-raid-configuration-raid-10/): I get question about what configuration of redundant array of inexpensive disks (RAID) I use for my SQL Servers. The answer is short is: RAID 10. Why? Excellent performance with Read and Write. RAID 10 has advantage of both RAID 0 and RAID 1. RAID 10 uses all the drives in the array to gain higher I/O rates so more drives in the array higher performance. RAID 5 has penalty for write performance because of the parity in check. There are many article already written about them. If you are interested in reading more please refer book online. Reference : Pinal... - [SQL SERVER - @@DATEFIRST and SET DATEFIRST Relations and Usage](https://blog.sqlauthority.com/2007/04/22/sql-server-datefirst-and-set-datefirst-relations-and-usage/): The master database’s syslanguages table has a DateFirst column that defines the first day of the week for a particular language. SQL Server with US English as default language, SQL Server sets DATEFIRST to 7 (Sunday) by default. We can reset any day as first day of the week using SET DATEFIRST 5 This will set Friday as first day of week. @@DATEFIRST returns the current value, for the session, of SET DATEFIRST. SET LANGUAGE italian GO SELECT @@DATEFIRST GO ----This will return result as 1(Monday) SET LANGUAGE us_english GO SELECT @@DATEFIRST GO ----This will return result as 7(Sunday) In this... - [SQL SERVER - Fix : Error 1418 - Microsoft SQL Server - The server network address can not be reached](https://blog.sqlauthority.com/2007/04/22/sql-server-fix-error-1418-microsoft-sql-server-the-server-network-address-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-reissue-the-command/): Error: 1418 – Microsoft SQL Server – The server network address can not be reached or does not exist. Check the network address name and reissue the command The server network endpoint did not respond because the specified server network address cannot be reached or does not exist. - [SQL Server Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/04/21/sql-server-interview-questions-and-answers-complete-list-download/): This is summary blog post for SQL Server Interview Questions and Answers. Click here to get free chapters (PDF) in the mailbox. - [SQL Server Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2007/04/20/sql-server-interview-questions-part-6/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2007/04/19/sql-server-interview-questions-part-5/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2007/04/18/sql-server-interview-questions-part-4/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/04/17/sql-server-interview-questions-part-3/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/04/16/sql-server-interview-questions-part-2/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions-and-answers-introduction/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL SERVER - 64 bit Architecture and White Paper](https://blog.sqlauthority.com/2007/04/14/sql-server-64-bit-architecture-and-white-paper/): In supportability, manageability, scalability, performance, interoperability, and business intelligence, SQL Server 2005 provides far richer 64-bit support than its predecessor. This paper describes these enhancements. Read the original paper here. Following abstract is taken from the same paper. Another interesting article on 64-bit Computing with SQL Server 2005 is here. The primary differences between the 64-bit and 32-bit versions of SQL Server 2005 are derived from the benefits of the underlying 64-bit architecture. Some of these are: The 64-bit architecture offers a larger directly-addressable memory space. SQL Server 2005 (64-bit) is not bound by the memory limits of 32-bit systems. Therefore,... - [SQL SERVER - CASE Statement/Expression Examples and Explanation](https://blog.sqlauthority.com/2007/04/14/sql-server-case-statementexpression-examples-and-explanation/): CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in functions. Two basic formulations for CASE expression 1) Simple CASE expressions A simple CASE expression checks one expression against multiple values. Within a SELECT statement, a simple CASE expression allows only an equality check; no other comparisons are made. A simple CASE expression operates by comparing the first expression to the expression in each WHEN clause for equivalency. If these expressions... - [SQL SERVER - Fix : Error: 18452 Login failed for user '(null)'. The user is not associated with a trusted SQL Server connection.](https://blog.sqlauthority.com/2007/04/14/sql-server-fix-error-18452-login-failed-for-user-null-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Some errors never got old. I have seen many new DBA or Developers struggling with this errors. Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection. Fix/Solution/Workaround: Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)” to “Mixed Mode (Windows Authentication and SQL Server Authentication)”. Run following script in SQL Analyzer to change the authentication LOGIN sa ENABLE GO ALTER LOGIN sa WITH PASSWORD = '<password>' GO OR In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties. On the General page, you may have to create... - [SQL SERVER - Stored Procedures Advantages and Best Advantage](https://blog.sqlauthority.com/2007/04/13/sql-server-stored-procedures-advantages-and-best-advantage/): There are many advantages of Stored Procedures. I was once asked what do I think is the most important feature of Stored Procedure? I have to pick only ONE. It is tough question. I answered : Execution Plan Retention and Reuse (SP are compiled and their execution plan is cached and used again to when the same SP is executed again) Not to mentioned I received the second question following my answer : Why? Because all the other advantage known (they are mentioned below) of SP can be achieved without using SP. Though Execution Plan Retention and Reuse can only be... - [SQL SERVER - Fix: Error: The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.". (SQL Server Import and Export Wizard)](https://blog.sqlauthority.com/2012/12/30/sql-server-fix-error-the-conversion-returned-status-value-2-and-status-text-the-value-could-not-be-converted-because-of-a-potential-loss-of-data-sql-server-import-and-export-wizard/): Here is the question received from user – the email was long and had multiple request from reader to resolve this error. Scenario: The user was trying to import data from Excel to tables in SQL Server Database. Every time he attempted to import the data he faced following error. He tried using SSIS package as well using the Import Export Wizard (which creates an SSIS package under the hood as well) but he he kept on facing following error. He could not figure out the reason behind the error. I have modified the error to make it readable. Error: –... - [SQL SERVER - Weekly Series - Memory Lane - #009](https://blog.sqlauthority.com/2012/12/29/sql-server-weekly-series-memory-lane-009/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2006 In year 2006 I started to blog and honestly I had no idea what is the blogging? It was just a collection of the bookmarks and I had a great time writing them up. I always thought I will read it when I need them.... - [SQLAuthority News - NuoDB RC2 Available to Download - General Availability in Near Future](https://blog.sqlauthority.com/2012/12/28/sqlauthority-news-nuodb-rc2-available-to-download-general-availability-in-near-future/): Regular readers who are familiar with my blog will be also familiar with my interest in NuoDB. It is a very innovative new age database which follows 100% SQL, ACID and Elastically Scalability. Here is an earlier article on this subject where we explain why sharing will no more required due to the implementation of the NuoDB. Each NuoDB database consists of at least three or more processes that enable a single database to run across multiple hosts. These processes include a Broker, a Transaction Engine and a Storage Manager.  Brokers are responsible for connecting client applications to Transaction Engines and maintain a... - [SQL SERVER - Creating Database with Different Collation on Server](https://blog.sqlauthority.com/2012/12/27/sql-server-creating-database-with-different-collation-on-server/): I recently came across an organization who had very interesting infrastructure setup. Their business domains is analytics. They process millions of the records and how many clients who have case sensitive tags on their server which they want to measure. However, there are many places they do not want to care about case sensitivity. They had peta bytes of the data on their server. Let us learn about Creating Database with Different Collation on Server. - [SQL SERVER - Take Database Backup using SSMS - SQL in Sixty Seconds #037 - Video](https://blog.sqlauthority.com/2012/12/26/sql-server-take-database-backup-using-ssms-sql-in-sixty-seconds-037-video/): Whenever I am suggesting something which changes how database works or the existing status of the database, my suggestion along with it is to take the database backup before making such changes. If the changes are in configurations, that can be easily revert but if the changes are such that it will impact the data, I always suggest to take backup. The nature of this blog is such that we have readership from readers with different expertise, some are experts and some are novice. - [SQL SERVER - Restoring 2012 Database to 2008 or 2005 Version and 2 other Most Asked Questions](https://blog.sqlauthority.com/2012/12/25/sql-server-restoring-2012-database-to-2008-or-2005-version-and-2-other-most-asked-questions/): Some questions never get old. Let me list a few of them. As the year 2012 is about to end, today I will talk about three of the most asked questions to me in an email. Let us learn about restoring databases.  - [SQL SERVER - Fix - Error: 4214: BACKUP LOG cannot be performed because there is no current database backup.](https://blog.sqlauthority.com/2012/12/24/sql-server-fix-error-4214-backup-log-cannot-be-performed-because-there-is-no-current-database-backup-2/): Here is the interesting conversation I recently heard between two teammates in one of the organizations I visited. DBA Jr: I can’t take transactional backup of the database. DBA Sr: What is the recovery model? DBA Jr: How to find the recovery model? DBA Sr: Go to SSMS >> Right Click on Your Database >> Select Properties >> Go to Options >> See the Recovery Model: DBA Jr: It is a Simple recovery model. DBA Sr: Convert it to Full by Changing the drop down on the recovery model. DBA Jr: Done! Now? DBA Sr: Take your transactional backup of the... - [SQL SERVER - What is Hekaton? - Simple Words Explanation](https://blog.sqlauthority.com/2012/12/23/sql-server-what-is-hekaton-simple-words-explanation/): Readers of this blog will know that I recently attended SQL Server (PASS) Summit 2012. There were, of course, a lot of fascinating subjects and people, but let me talk about one of my favorites right now. Ted Kummert, corporate vice president of the Data Platform group at Microsoft, announced that the new version of SQL Server will include a feature called “Hekaton.” Hekaton is Greek for “hundreds,” and it was given this name for its ability to speed up database function 100x (possibly). It certainly increases application speed by 10x and nearly 50x for new, optimized applications. - [SQL SERVER - Log File Very Large, TempDB and More - Memory Lane #008](https://blog.sqlauthority.com/2012/12/22/sql-server-weekly-series-memory-lane-008/): This is the 8th episode of the weekly series of memory lane. Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. My favorite articles this time are about the solution when the log file very large as well as T-SQL script to find details about TempDB. Let me know which one of the following is your favorite article from memory lane. - [SQLAuthority News - Chrome Browser - Personal Technology](https://blog.sqlauthority.com/2012/12/21/sqlauthority-news-chrome-browser-personal-technology/): Almost every computer you can buy these days will come with Microsoft Windows installed on it automatically.  Also installed automatically – Internet Explorer, Microsoft’s web browser.  Many of us use this browser without a second thought, but in this latest Personal Technology Tip and Trick I thought I’d expand your horizons and talk about my favorite browser – Google Chrome. 1. Pin Tab Most browsers now have the tab option, which allows you to have multiple browser windows open with easy access.  However, if you’re like me and have so many tabs open that you no longer can keep track of... - [SQL SERVER - Difference Between CURRENT_TIMESTAMP and GETDATE() - CURRENT_TIMESTAMP Equivalent in SQL Server](https://blog.sqlauthority.com/2012/12/20/sql-server-difference-between-current_timestamp-and-getdate-current_timestamp-equivalent-in-sql-server/): A common question – I often get from Oracle/MySQL Professionals: “What is the Equivalent to CURRENT_TIMESTAMP in SQL Server?” Here is a common question I often get from SQL Server Professionals: “What are differences between Difference Between CURRENT_TIMESTAMP and GETDATE ()?” Very simple question but have showed up so frequently that I feel like to write about it. Well in SQL Server GETDATE() is Equivalent to CURRENT_TIMESTAMP. However, if you use CURRENT_TIMESTAMP in your select statement it will work fine. You can see in the above example – both of them returns the same value. Now let us go to next question regarding difference between... - [SQL SERVER - Select and Delete Duplicate Records - SQL in Sixty Seconds #036 - Video](https://blog.sqlauthority.com/2012/12/19/sql-server-select-and-delete-duplicate-records-sql-in-sixty-seconds-036-video/): Developers often face situations when they find their column have duplicate records and they want to delete it. A good developer will never delete any data without observing it and making sure that what is being deleted is the absolutely fine to delete. Before deleting duplicate data, one should select it and see if the data is really duplicate. In this video we are demonstrating two scripts – 1) selects duplicate records 2) deletes duplicate records. We are assuming that the table has a unique incremental id. Additionally, we are assuming that in the case of the duplicate records we would... - [SQL SERVER - Select the Most Optimal Backup Methods for Server](https://blog.sqlauthority.com/2012/12/18/sql-server-select-the-most-optimal-backup-methods-for-server/): Backup and Restore are very interesting concepts and one should be very much with the concept if you are dealing with production database. One never knows when a natural disaster or user error will surface and the first thing everybody wants is to get back on point in time when things were all fine. Well, in this article I have attempted to answer a few of the common questions related to Backup methodology. How to Select a SQL Server Backup Type In order to select a proper SQL Server backup type, a SQL Server administrator needs to understand the difference between... - [SQL SERVER - Auto Complete and Format T-SQL Code](https://blog.sqlauthority.com/2012/12/17/sql-server-auto-complete-and-format-t-sql-code-devart-sql-complete/): Some people call it laziness, some will call it efficiency, some think it is the right thing to do. At any rate, tools are meant to make a job easier, and I like to use various tools. If we consider the history of the world, if we all wanted to keep traditional practices, we would have never invented the wheel. But as time progressed, people wanted convenience and efficiency, which then led to laziness. Wanting a more efficient way to do something is not inherently lazy. That’s how I see any efficiency tools for auto complete. - [SQLAuthority News - First SQL Bangalore Event Report - Nov 24, 2012 - SQL Server User Group Bangalore](https://blog.sqlauthority.com/2012/12/16/sqlauthority-news-first-sql-bangalore-event-report-nov-24-2012-sql-server-user-group-bangalore/): A very common question I often receive – Do we have SQL Server User Group in Bangalore? Yes! SQL Bangalore – we had very first meeting on Nov 24, 2012 and very soon we are going to have another User Group meeting. The goal is to keep up a monthly rhythm of User Group meeting. If you are in Bangalore area please join the Facebook page and you will keep on getting regular update about SQL Server. In the very first meeting we have five 30 minute session and had a fantastic time. We had the best of the best speakers... - [SQL SERVER - Weekly Series - Memory Lane - #007](https://blog.sqlauthority.com/2012/12/15/sql-server-weekly-series-memory-lane-007/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2006 Find Stored Procedure Related to Table in Database – Search in All Stored Procedure In 2006 I wrote a small script which will help user  find all the Stored Procedures (SP) which are related to one or more specific tables. This was quite a popular... - [SQL Contest - Result of Cartoon Contest](https://blog.sqlauthority.com/2012/12/14/sql-contest-result-of-cartoon-contest/): Earlier we had an excellent contest ran with the help of Embarcadero Technologies. We had two different contests on the same day sponsored by the kind folks at Embarcadero. Here are the details of the winners. 1) Win USD 25 Amazon Gift Cards (10 Units) We had announced that we will award USD 25 Amazon Gift Cards to 10 lucky winners who will download the DB Optimizer between Nov 29 to Dec 8. Here is the name of the winners. Winners will get Amazon Gift Cards USD 25 in the next 5 days of this blog post to their registered email address.... - [SQLAuthority News - Speaking at Southeast Asia SharePoint Conference 2013 - Singapore](https://blog.sqlauthority.com/2012/12/13/sqlauthority-news-speaking-at-southeast-asia-sharepoint-conference-2013-singapore/): Two years ago I spoke at Southeast Asia SharePoint Conference 2011, Singapore and I had a fantastic time to present to the Singapore audience. The session was very well received and lots of interest was generated. The event is back again this year and with much bigger scale. I will be presenting on SQL Server and Sharepoint subject at the conference. Session Details: Title: Performance in 60 Seconds – Database Tricks Every SharePoint Developer & Admin MUST Know Abstract: SharePoint Developers and System Administrators often come across situations where they face a slow server response, even though their hardware specifications are above ... - [SQL SERVER - Inviting Ideas for SQL in Sixty Seconds - 12/12/12](https://blog.sqlauthority.com/2012/12/12/sql-server-inviting-ideas-for-sql-in-sixty-seconds-121212/): Today is 12/12/12 – I am not sure when will I write this kind of date again – maybe never. This opportunity comes once in a lifetime when we have the same date, month and year all have same digit. December 12th is one of the most fantastic day in my personal life. Four years ago, this day I got married to my wife – Nupur Dave.  Here are photos of our wedding (Dec 12, 2008). Here is a very interesting photo of myself earlier this year. It is not photoshoped or modified photo. The only modification I have done here... - [SQL SERVER - Asynchronous Update and Timestamp - Check if Row Values are Changed Since Last Retrieve](https://blog.sqlauthority.com/2012/12/11/sql-server-asynchronous-update-and-timestamp-check-if-row-values-are-changed-since-last-retrieve/): Here is the question received just this morning. “Pinal, Our application is much different than other application you might have come across. In simple words, I would like to call it Asynchronous Updated Application. We need your quick opinion about one of the situation which we are facing. From business side: We have bidding system (similar to eBay but not exactly) and where multiple parties bid on one item, during the last few minutes of bidding many parties try to bid at the same time with the same price. When they hit submit, we would like to check if the original data... - [SQL SERVER - Get 2 of My Books FREE at Tech Day - Where Technologies Converge!](https://blog.sqlauthority.com/2012/12/10/sql-server-get-2-books-free-tech-day-technologies-converge/): As a regular reader of my blog - you must be aware of that I love to write books and talk about various subjects of my books. They have been my biggest supporter of my books. Coming weekend they have a tech day event at their Bangalore Location. - [SQL Authority News - Download SQL Server Data Type Conversion Chart](https://blog.sqlauthority.com/2012/12/09/sql-authority-news-download-sql-server-data-type-conversion-chart/): Datatypes are very important concepts of SQL Server and there are quite often need to convert them from one datatypes to another datatype. I have seen that deveoper often get confused when they have to convert the datatype. There are two important concept when it is about datatype conversion. Implicit Conversion: Implicit conversions are those conversions that occur without specifying either the CAST or CONVERT function. Explicit Conversions: Explicit conversions are those conversions that require the CAST or CONVERT function to be specified. What it means is that if you are trying to convert value from datetime2 to time or from tinyint... - [SQL SERVER - Weekly Series - Memory Lane - #006](https://blog.sqlauthority.com/2012/12/08/sql-server-weekly-series-memory-lane-006/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2006 This was my very first year of blogging so I was every day learning something new. As I have said many times, that blogging was never an intention. I had really not understood what exactly I am working on or beginning when I was beginning... - [SQLAuthority News - Technology and Online Learning - Personal Technology Tip](https://blog.sqlauthority.com/2012/12/07/sqlauthority-news-technology-and-online-learning-personal-technology-tip/): This is the fourth post in my series about Personal Technology Tips and Tricks, and I knew exactly what I wanted to write about.  But at first I was conflicted.   Is online learning really a personal tip?  Is it really a trick that no one knows?  However, I have decided to stick with my original idea because online learning is everywhere.  It’s a trick that we can’t – and shouldn’t – overlook.  Here are ten of my ideas about how we should be taking advantage of online learning. 1) Get ahead in the work place.  We all know that a good... - [SQL SERVER - Caption the Cartoon Contest - Last 2 Days](https://blog.sqlauthority.com/2012/12/06/sql-server-caption-the-cartoon-contest-last-2-days/): Developer’s life is very interesting, we often want to start my day early at a job so we can go home early. However, the day never comes as the life of the developer is always about working late hours. If the developer goes to the office early – there are good chances that his co-workers will come late. Additionally, I am confident that there will be always something urgent for developers or DBA to solve right at the time they are ready to go home. This is the life of the developers!  Here is the interesting story of a DBA who... - [SQL SERVER - Concat Strings in SQL Server using T-SQL - SQL in Sixty Seconds #035 - Video](https://blog.sqlauthority.com/2012/12/05/sql-server-concat-strings-in-sql-server-using-t-sql-sql-in-sixty-seconds-035-video/): Concatenating  string is one of the most common tasks in SQL Server and every developer has to come across it. We have to concat the string when we have to see the display full name of the person by first name and last name. In this video we will see various methods to concatenate the strings. SQL Server 2012 has introduced new function CONCAT which concatenates the strings much efficiently. When we concat values with ‘+’ in SQL Server we have to make sure that values are in string format. However, when we attempt to concat integer we have to convert... - [SQL SERVER - Fix: Error : 402 The data types ntext and varchar are incompatible in the equal to operator](https://blog.sqlauthority.com/2012/12/04/sql-server-fix-error-402-the-data-types-ntext-and-varchar-are-incompatible-in-the-equal-to-operator/): Some errors are very simple to understand but the solution of the same is not easy to figure out. Here is one of the similar errors where it clearly suggests where the problem is but does not tell what is the solution. Additionally, there are multiple solutions so developers often get confused with which one is correct and which one is not correct. Let us first recreate scenario and understand where the problem is. Let us run following USE Tempdb GO CREATE TABLE TestTable (ID INT, MyText NTEXT) GO SELECT ID, MyText FROM TestTable WHERE MyText = 'AnyText' GO DROP TABLE... - [SQL SERVER - Fix Error: Microsoft OLE DB Provider for SQL Server error '80040e07' or Microsoft SQL Native Client error '80040e07'](https://blog.sqlauthority.com/2012/12/03/sql-server-fix-error-microsoft-ole-db-provider-for-sql-server-error-80040e07-or-microsoft-sql-native-client-error-80040e07/): I quite often receive questions where users are looking for solution to following error: Microsoft OLE DB Provider for SQL Server error ‘80040e07’ Syntax error converting datetime from character string. OR Microsoft SQL Native Client error ‘80040e07’ Syntax error converting datetime from character string. If you have ever faced above error – I have a very simple solution for you. The solution is being very check date which is inserted in the datetime column. This error often comes up when application or user is attempting to enter an incorrect date into the datetime field. Here is one of the examples –... - [SQL SERVER - Find Referenced or Referencing Object in SQL Server using sys.sql_expression_dependencies](https://blog.sqlauthority.com/2012/12/02/sql-server-find-referenced-or-referencing-object-in-sql-server-using-sys-sql_expression_dependencies/): Let us learn in this blog about sys.sql_expression_dependencies. A very common question which I often receive are: How do I find all the tables used in a particular stored procedure? How do I know which stored procedures are using a particular table? - [SQL SERVER - Weekly Series - Memory Lane - #005](https://blog.sqlauthority.com/2012/12/01/sql-server-weekly-series-memory-lane-005/): This article is the 5th edition in the memory lane series. Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. - [SQL SERVER - Fix Visual Studio Error : Connections to SQL Server files (.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL](https://blog.sqlauthority.com/2012/11/30/sql-server-fix-visual-studio-error-connections-to-sql-server-files-mdf-require-sql-server-express-2005-to-function-properly-please-verify-the-installation-of-the-component-or-download-from-the/): In one of the virtual environment while I was trying to add SQL Server Database (.mdf) file to asp.net project I encountered following error: Connections to SQL Server files (.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: https://visualstudio.microsoft.com/vs/express/ For a long time I am using SQL Server 2012 but this error was a bit interesting to me. I realize that there should not be any need of the SQL Server 2005 installation. I quickly figured out that I can remove this error if I do as mentioned below: Open... - [SQL Contest - Win USD 300 Worth Gift - Cartoon Contest is Back](https://blog.sqlauthority.com/2012/11/29/sql-contest-win-usd-300-worth-gift-cartoon-contest-is-back/): There are two excellent contests and we have lots of winning to do this year end. In this blog post we are going to have a cartoon contest again. - [SQL SERVER - Auto Recovery File Settings in SSMS - SQL in Sixty Seconds #034 - Video](https://blog.sqlauthority.com/2012/11/28/sql-server-auto-recovery-file-settings-in-ssms-sql-in-sixty-seconds-034-video/): Every developer once in a while facing an unfortunate situation where they have not yet saved the work and their SQL Server Management Studio crashes. Well, you can minimize the loss by optimizing auto recovery settings. In this video we can see how to set the auto recovery settings. - [SQL SERVER - Shard No More - An Innovative Look at Distributed Peer-to-peer SQL Database](https://blog.sqlauthority.com/2012/11/27/sql-server-shard-no-more-an-innovative-look-at-distributed-peer-to-peer-sql-database/): There is no doubt that SQL databases play an important role in modern applications. In an ideal world, a single database can handle hundreds of incoming connections from multiple clients and scale to accommodate the related transactions. However the world is not ideal and databases are often a cause of major headaches when applications need to scale to accommodate more connections, transactions, or both. In order to overcome scaling issues, application developers often resort to administrative acrobatics, also known as database sharding. Sharding helps to improve application performance and throughput by splitting the database into two or more shards. Unfortunately, this... - [SQL SERVER - Sends backups to a Network Folder, FTP Server, Dropbox, Google Drive or Amazon S3](https://blog.sqlauthority.com/2012/11/26/sql-server-sends-backups-to-a-network-folder-ftp-server-dropbox-google-drive-or-amazon-s3/): Let me tell you about one of the most useful SQL tools that every DBA should use – it is SQLBackupAndFTP. I have been using this tool since 2009 – and it is the first program I install on a SQL server. Download a free version, 1 minute configuration and your daily backups are safe in the cloud. In summary, SQLBackupAndFTP Creates SQL Server database and file backups on schedule Compresses and encrypts the backups Sends backups to a network folder, FTP Server, Dropbox, Google Drive or Amazon S3 Sends email notifications of job’s success or failure SQLBackupAndFTP comes in Free... - [SQL SERVER - Find Weekend and Weekdays from Datetime in SQL Server 2012](https://blog.sqlauthority.com/2012/11/25/sql-server-find-weekend-and-weekdays-from-datetime-in-sql-server-2012/): Yesterday we had very first SQL Bangalore User Group meeting and I was asked following question right after the session. This question is about to Find Weekend and Weekdays from Datetime in SQL Server 2012. - [SQL SERVER - Cursor, Log File and More - Memory Lane #004](https://blog.sqlauthority.com/2012/11/24/sql-server-weekly-series-memory-lane-004/): This is the 4th episode of memory lane. Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. My favorite article this week is an article discussing cursor and log file. Let me know which one of the following is your favorite article from memory lane. - [SQLAuthority News - Android Efficiency Tips and Tricks - Personal Technology Tip](https://blog.sqlauthority.com/2012/11/23/sqlauthority-news-android-efficiency-tips-and-tricks-personal-technology-tip/): I use my phone for lots of things.  I use it mainly to replace my tablet – I can e-mail, take and edit photos, and do almost everything I can do on a laptop with this phone.  And I am sure that there are many of you out there just like me.  I personally have a Galaxy S3, which uses the Android operating system, and I have decided to feature it as the third installment of my Technology Tips and Tricks series. 1) Shortcut to your favorite contacts on home screen Access your most-called contacts easily from your home screen by... - [SQL SERVER - Removing Leading Zeros From Column in Table - Part 2](https://blog.sqlauthority.com/2012/11/22/sql-server-removing-leading-zeros-from-column-in-table-part-2/): Earlier I wrote a blog post about Remvoing Leading Zeros from Column In Table. It was a great co-incident that my friend Madhivanan (no need of introduction for him) also post a similar article over on BeyondRelational.com. I strongly suggest to read his blog as well as he has suggested some cool solutions to the same problem. On original blog post asked two questions 1) if my sample for testing is correct and 2) If there is any better method to achieve the same. The response was amazing. I am proud on our SQL Community that we all keep on improving on... - [SQL SERVER - Display Datetime in Specific Format - SQL in Sixty Seconds #033 - Video](https://blog.sqlauthority.com/2012/11/21/sql-server-display-datetime-in-specific-format-sql-in-sixty-seconds-033-video/): The need of developer changes as geographic location changes. In SQL Server there are various functions to aid this requirement. There is function CAST, which developers have been using for a long time as well function CONVERT which is a more enhanced version of CAST. In the latest version of SQL Server 2012 a new function FORMAT is introduced as well to display datetime in specific format. - [SQL SERVER - Using RAND() in User Defined Functions (UDF)](https://blog.sqlauthority.com/2012/11/20/sql-server-using-rand-in-user-defined-functions-udf/): Here is the question I received in email. “Pinal, I am writing a function where we need to generate random password. While writing T-SQL I faced following issue. Everytime I tried to use RAND() function in my User Defined Function I am getting following error: - [SQL SERVER - Removing Leading Zeros From Column in Table](https://blog.sqlauthority.com/2012/11/19/sql-server-removing-leading-zeros-from-column-in-table/): Some questions surprises me and make me write code which I have never explored before. Today was similar experience as well. I have always received the question regarding how to reserve leading zeroes in SQL Server while displaying them on the SSMS or another application. I have written articles on this subject over here about leading zeros. - [SQLAuthority News - Microsoft SQL Server 2012 Service Pack 1 Released (SP1)](https://blog.sqlauthority.com/2012/11/18/sqlauthority-news-microsoft-sql-server-2012-service-pack-1-released-sp1/): Last week, I was attending SQLPASS 2012 and I had great fun attending the event. During the event long awaited SQL Serer 2012 Service Pack 1 was released. I am pretty excited with SP1 as new service packs are cumulative updates and upgrade all editions and service levels of SQL Server 2012 to SP1. This service pack contains SQL Server 2012 Cumulative Update 1 (CU1) and Cumulative Update 2 (CU2). The latest SP1 has many new and enhanced features. Here are a few for example: Cross-Cluster Migration of AlwaysOn Availability Groups for OS Upgrade Selective XML Index DBCC SHOW_STATISTICS works with... - [SQL SERVER - Weekly Series - Memory Lane - #003 - Database Encryption](https://blog.sqlauthority.com/2012/11/17/sql-server-weekly-series-memory-lane-003-database-encryption/): Here is the list of selected articles of SQLAuthority.com across all these years.  In this blog post, we will talk about database encryption. - [SQL SERVER - Retrieving Random Rows from Table Using NEWID()](https://blog.sqlauthority.com/2012/11/16/sql-server-retrieving-random-rows-from-table-using-newid/): I have previously written about how to get random rows from SQL Server. SQL SERVER – Generate A Single Random Number for Range of Rows of Any Table – Very interesting Question from Reader SQL SERVER – Random Number Generator Script – SQL Query However, I have not blogged about following trick before. Let me share the trick here as well. You can generate random scripts using following methods as well. USE AdventureWorks2012 GO -- Method 1 SELECT TOP 100 * FROM Sales.SalesOrderDetail ORDER BY NEWID() GO -- Method 2 SELECT TOP 100 * FROM Sales.SalesOrderDetail ORDER BY CHECKSUM(NEWID()) GO You will notice... - [SQL SERVER - Concurrency Basics - Guest Post by Vinod Kumar](https://blog.sqlauthority.com/2012/11/15/sql-server-concurrency-basics-guest-post-by-vinod-kumar/): This guest post is by Vinod Kumar. Vinod Kumar has worked with SQL Server extensively since joining the industry over a decade ago. Working on various versions from SQL Server 7.0, Oracle 7.3 and other database technologies – he now works with the Microsoft Technology Center (MTC) as a Technology Architect. Let us read the blog post in Vinod’s own voice. Learning is always fun when it comes to SQL Server and learning the basics again can be more fun. I did write about Transaction Logs and recovery over my blogs and the concept of simplifying the basics is a challenge. In... - [SQL SERVER - Rename Columnname or Tablename - SQL in Sixty Seconds #032 - Video](https://blog.sqlauthority.com/2012/11/14/sql-server-rename-columnname-or-tablename-sql-in-sixty-seconds-032-video/): We all make mistakes at some point of time and we all change our opinion. There are quite a lot of people in the world who have changed their name after they have grown up. Some corrected their parent’s mistake and some create new mistake. Well, databases are not protected from such incidents. There are many reasons why developers may want to change the name of the column or table after it was initially created. The goal of this video is not to dwell on the reasons, but to learn how we can rename the column and table. - [SQLAuthority News - Happy Deepavali and Happy New Year](https://blog.sqlauthority.com/2012/11/13/sqlauthority-news-happy-deepavali-and-happy-news-year-2/): Diwali or Deepavali is popularly known as the festival of lights. It literally means “array of light” or “row of lamps“. Today we build a small clay maps and fill it with oil and light it up. The significance of lighting the lamp is the triumph of good over evil. I work every single day in a year but today I am spending my time with family and little one. I make sure that my daughter is aware of our culture and she learns to celebrate the festival with the same passion and values which I have. Every year on this day, I... - [SQL SERVER - Get Free Books on While Learning SQL Server 2012 Error Handling](https://blog.sqlauthority.com/2012/11/12/sql-server-get-free-books-on-while-learning-sql-server-2012-error-handling/): Fans of this blog are aware that I have recently released my new books SQL Server Functions and SQL Server 2012 Queries. The books are available in market in limited edition but you can avail them for free on Wednesday Nov 14, 2012. Not only they are free but you can additionally learn SQL Server 2012 Error Handling as well. My book’s co-author Rick Morelan is presenting a webinar tomorrow on SQL Server 2012 Error Handling. Here is the brief abstract of the webinar: People are often shocked when they see the demo in this talk where the first statement fails... - [SQL SERVER - Changing Default Installation Path for SQL Server](https://blog.sqlauthority.com/2012/11/11/sql-server-changing-default-installation-path-for-sql-server/): Earlier I wrote a blog post about SQL SERVER – Move Database Files MDF and LDF to Another Location and in the blog post we discussed how we can change the location of the MDF and LDF files after database is already created. I had mentioned that we will discuss how to change the default location of the database. This way we do not have to change the location of the database after it is created at different locations. The ideal scenario would be to specify this default location of the database files when SQL Server Installation was performed. If you have already... - [SQL SERVER - Beginning New Weekly Series - Memory Lane - #002](https://blog.sqlauthority.com/2012/11/10/sql-server-beginning-new-weekly-series-memory-lane-002/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2006 Query to Find ByteSize of All the Tables in Database This was my second blog post and today I do not remember what was the business need which has made me build this query. It was built for SQL Server 2000 and it will not directly... - [SQLAuthority News - #SQLPASS 2012 Book Signing Photos](https://blog.sqlauthority.com/2012/11/09/sqlauthority-news-sqlpass-2012-book-signing-photos/): I am at SQLPASS 2012 and the event is going great. Here are few of the random photos and random news. We had participated in three different book signing event today. SQL Queries 2012 Joes 2 Pros Book 1 Launch and Book Signing SQL 2012 Functions Book Launch at Embarcadero SQL Backup and Recovery Book Launch at Idera Rick Morelan and I authored the first two books 1) SQL 2012 Functions and 2) SQL Queries 2012 Joes 2 Pros Volume 1. Our dear friend Tim Randney authored SQL Backup and Recovery Book. In the book signing event of Tim Radney I... - [SQLAuthority News - Learning, Community and Book Signing at #SQLPASS 2012](https://blog.sqlauthority.com/2012/11/08/sqlauthority-news-learning-community-and-book-signing-at-sqlpass-2012/): SQLPASS event is going excellent we are having great great fun! We are having book signing events and the response is overwhelmingly positive. I am glad that all of you love our books and I totally appreciate your support. Rick and I both are feeling very motivated to write more books in future. Here is our schedule for book signing. SQL Queries 2012 Joes 2 Pros Volume1 Finally a book for the true SQL Server beginner! Whether you are brand new to databases and are thinking of getting your 70-461 certification or already a semi-pro working in the field and need... - [SQLAuthority News - 2 New Books - FREE Books and Book Signing at #SQLPASS 2012](https://blog.sqlauthority.com/2012/11/07/sqlauthority-news-free-books-and-book-signing-at-sqlpass-2012-special-edition-books/): As an author the most interesting task is to participate in Book Signing Events. If you are at SQLPASS – we are going to have a lot of book signing events. Here is the good news! MY NEW BOOKS ARE OUT! SQL 2012 Functions Limited Edition This book is a very special edition book. Our current plans is to run this book for the limited edition. You can avail this book from Amazon and it will soon come to India. Join following book signing events where you will get this book for free. Wednesday, November 7, 2012 7pm-8pm – Embarcadero Booth Book Signing (FREE... - [SQLAuthority News - #SQLPASS 2012 Schedule - Where can You Find Me](https://blog.sqlauthority.com/2012/11/06/sqlauthority-news-sqlpass-2012-schedule-where-can-you-find-me/):   Yesterday I wrote about my memory lane with SQLPASS. It has been a fantastic experience and I am very confident that this year the same excellent experience is going to be repeated. Before I start for #SQLPASS every year, I plan where I want to be and what I will be doing. As I travel from India to attend this event (22+ hours flying time and door to door travel time around 36 hours), it is very crucial that I plan things in advance. This year here is my quick note where I will be during the SQLPASS event. If... - [SQLAuthority News - #SQLPASS 2012 Seattle Update - Memorylane 2009, 2010, 2011](https://blog.sqlauthority.com/2012/11/05/sqlauthority-news-sqlpass-2012-seattle-update-memorylane-2009-2010-2011/): Today is the first day of the SQLPASS 2012 and I will be soon posting SQL Server 2012 experience over here. Today when I landed in Seattle, I got the nostalgia feeling. I used to stay in the USA. I stayed here for more than 7 years – I studied here and I worked in USA. I had lots of friends in Seattle when I used to stay in the USA. I always wanted to visit Seattle because it is THE place. I remember once I purchased a ticket to travel to Seattle through Priceline (well it was the cheapest option... - [SQLAuthority News - Why I am Going to Attend #SQLPASS Summit 2012 - Seattle](https://blog.sqlauthority.com/2012/11/04/sqlauthority-news-why-i-am-going-to-attend-sqlpass-summit-2012-seattle/): I am going to Seattle I once again attend SQLPASS this year. This will be my fourth SQLPASS. Lots of people ask me why I am going to SQLPASS every year. Well there are so many different reasons for that. I go to SQLPASS because – I love it!  Here are few of the reasons I go to SQLPASS. Meet friends whom I have never met before Meet community at large – it is fun to hang around with like minded people Meet Rick Morelan – my book co-author and friend Attend various SQL Parties – there are so many parties... - [SQL SERVER - Beginning New Weekly Series - Memory Lane - #001](https://blog.sqlauthority.com/2012/11/03/sql-server-beginning-new-weekly-series-memory-lane-001/): I am introducing a new series today.  This series is called “Memory Lane.”  From the last six years and 2,300 articles, there are fantastic articles I keep revisiting.  Sometimes when I read old blog posts I think I should have included something or added a bit more to the topic.  But for many articles, I still feel they are fantastic (even after six years) and could be read again and again. I have also found that after six years of blogging, readers will write to me and say “Pinal, why don’t you write about X, Y or Z.”  The answer is:... - [SQL SERVER - Function to Round Up Time to Nearest Minute Interval](https://blog.sqlauthority.com/2012/11/02/sql-server-function-to-round-up-time-to-nearest-minutes-interval/): Though I have written more than 2300 blog posts, I always find things which I have not covered earlier in this blog post. Recently I was asked if I have written a function which rounds up or down the time based on the minute interval passed to it. Well, not earlier, but it is here today about how to create a function to round up time to nearest minute interval.  - [SQLAuthority News - 6th Anniversary and 50 Million Views and Over 2300 Blog Posts - Thank You Thank You](https://blog.sqlauthority.com/2012/11/01/sqlauthority-news-6th-anniversary-and-50-million-views-and-over-2300-blog-posts-thank-you-thank-you/): Celebrating 6th Anniversary! Six years ago, I started this SQLAuthority.com blog. There are so many things I want to say today - it is very very emotional. Instead of writing long I am including few images and cartoons. - [SQL SERVER - Copy Data from One Table to Another Table - SQL in Sixty Seconds #031 - Video](https://blog.sqlauthority.com/2012/10/31/sql-server-copy-data-from-one-table-to-another-table-sql-in-sixty-seconds-031-video/): Copy data from one table to another table is one of the most requested questions on forums, Facebook and Twitter. The question has come in many formats and there are places I have seen developers are using cursor instead of this direct method. Earlier I have written the similar article a few years ago – SQL SERVER – Insert Data From One Table to Another Table – INSERT INTO SELECT – SELECT INTO TABLE. The article has been very popular and I have received many interesting and constructive comments. However there were two specific comments keep on ending up on my mailbox. 1)... - [SQL SERVER - UNION ALL and ORDER BY - How to Order Table Separately While Using UNION ALL](https://blog.sqlauthority.com/2012/10/30/sql-server-union-all-and-order-by-how-to-order-table-separately-while-using-union-all/): I often see developers trying following syntax while using ORDER BY. SELECT Columns FROM TABLE1 ORDER BY Columns UNION ALL SELECT Columns FROM TABLE2 ORDER BY Columns However the above query will return following error. Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword ‘ORDER’. It is not possible to use two different ORDER BY in the UNION statement. UNION returns single resultsetand as per the Logical Query Processing Phases. However, if your requirement is such that you want your top and bottom query of the UNION resultset independently sorted but in the same resultset you can add an additional static... - [SQLAuthority News - Windows Efficiency Tricks and Tips - Personal Technology Tip](https://blog.sqlauthority.com/2012/10/29/sqlauthority-news-windows-efficiency-tricks-and-tips-personal-technology-tip/): This is the second post in my series about my favorite Technology Tips, and I wanted to focus on my favorite Microsoft product.  Choosing just one topic to cover was too hard, though.  There are so many interesting things I have to share that I am forced to turn this second installment into a five-part post.  My five favorite Windows tips and tricks. 1) You can open multiple applications using the task bar. With the new Windows 7 taskbar, you can start navigating with just one click.  For example, you can launch Word by clicking on the icon on your taskbar, and... - [SQL SERVER - Move Database Files MDF and LDF to Another Location](https://blog.sqlauthority.com/2012/10/28/sql-server-move-database-files-mdf-and-ldf-to-another-location/): When a novice DBA or Developer create a database they use SQL Server Management Studio to create new database. Additionally, the T-SQL script to create a database is very easy as well. You can just write CREATE DATABASE DatabaseName and it will create new database for you. The point to remember here is that it will create the database at the default location specified in SQL Server Instance (this default instance, can be changed and we will see that in future blog posts). Now, once the database files goes in production it will start to grow. - [SQL SERVER - Storing Variable Values in Temporary Array or Temporary List](https://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/): SQL Server does not support arrays or a dynamic length storage mechanism like list. Absolutely there are some clever workarounds and few extra-ordinary solutions but everybody can;t come up with such solution. Additionally, sometime the requirements are very simple that doing extraordinary coding is not required. Here is the simple case. Let us say here are the values: a, 10, 20, c, 30, d. Now the requirement is to store them in a array or list. It is very easy to do the same in C# or C. However, there is no quick way to do the same in SQL Server.... - [SQL SERVER - Introduction to Big Data](https://blog.sqlauthority.com/2012/10/26/sql-server-introduction-big-data/): Big Data, as the name suggests, is about data that is BIG in nature. The data is BIG in terms of size, and it is difficult to manage such enormous data with relational database management systems that are quite popular these days. - [SQL SERVER - Last Two Days to Get FREE Book - Joes 2 Pros Certification 70-433](https://blog.sqlauthority.com/2012/10/25/sql-server-last-two-days-to-get-free-book-joes-2-pros-certification-70-433/): Earlier this week we announced that we will be giving away FREE SQL Wait Stats book to everybody who will get SQL Server Joes 2 Pros Combo Kit. We had a fantastic response to the contest. We got an overwhelming response to the offer. We knew there would be a great response but we want to honestly say thank you to all of you for making it happen. Rick and I want to make sure that we express our special thanks to all of you who are reading our books. The offer is still on and there are two more days... - [SQL SERVER - Resolving SQL Server Connection Errors - SQL in Sixty Seconds #030 - Video](https://blog.sqlauthority.com/2012/10/24/sql-server-resolving-sql-server-connection-errors-sql-in-sixty-seconds-030-video/): One of the most famous errors related to SQL Server is about connecting to SQL Server itself. Here is how it goes, most of the time developers have worked with SQL Server and knows pretty much every error which they face during development language. However, hardly they install fresh SQL Server. As the installation of the SQL Server is a rare occasion unless you are DBA who is responsible for such an instance – the error faced during installations are pretty rare as well. I have earlier written an article about this which describes how to resolve the errors which are... - [SQL SERVER - Order By Numeric Values Formatted as String](https://blog.sqlauthority.com/2012/10/23/sql-server-order-by-numeric-values-formatted-as-string/): When I was writing this blog post I had a hard time to come up with the title of the blog post so I did my best to come up with one. Here is the reason why? I wrote a blog post earlier SQL SERVER – Find First Non-Numeric Character from String. One of the questions was that how that blog can be useful in real life scenario. This blog post is the answer to that question. Let us first see a problem. - [SQL Authority News - Vacation, Travel and Study - A New Concept](https://blog.sqlauthority.com/2012/10/22/sql-authority-news-vacation-travel-study-new-concept/): Quite often when developers go to training sessions they either find it very boring because of study or great because they treat it as a vacation. There should be a perfect balance between study and extra activities. - [SQLAuthority News - Windows Azure Training Kit Updated October 2012](https://blog.sqlauthority.com/2012/10/21/sqlauthority-news-windows-azure-training-kit-updated-october-2012/): Microsoft has recently released the updated to Windows Azure Training Kit. Earlier this month they have updated the kit and included quite a lot of things. Now the training kit contains 47 hands-on labs, 24 demos and 38 presentations. The best part is that the kit is now available to download in two different formats 1) Full Package (324.5 MB) and 2) Web Installer (2.4 MB). The full package enables you to download all of the hands-on labs and presentations to your local machine. The Web Installer allows you to select and download just the specific hands-on labs and presentations that you need. This Windows Azure... - [SQLAuthority News - Who I Am And How I Got Here - True Story as Blog Post](https://blog.sqlauthority.com/2012/10/20/sqlauthority-news-who-i-am-and-how-i-got-here-true-story-as-blog-post/): Here are few of the sample questions I get every day? “Give me shortcut to become superstar?” “How do I become like you?” “Which book I should read so I know everything?” “Can you share your secret to be successful? I want to know it but do not share with others.” There is generic answer I always give is to work hard and read good educational material or watch good online videos. One of the emails really caught my attention. It was from a friend and SQL Server Expert John Sansom (Blog | Twitter). He wrote if I would like to... - [SQLAuthority News - Storing Data and Files in Cloud - Dropbox - Personal Technology Tip](https://blog.sqlauthority.com/2012/10/19/sqlauthority-news-storing-data-and-files-in-cloud-dropbox-personal-technology-tip/): I thought long and hard about doing a Personal Technology Tips series for this blog.  I have so many tips I’d like to share.  I am on my computer almost all day, every day, so I have a treasure trove of interesting tidbits I like to share if given the chance.  The only thing holding me back – which tip to share first?  The first tip obviously has the weight of seeming like the most important.  But this would mean choosing amongst my favorite tricks and shortcuts.  This is a hard task. My Dropbox I have finally decided, though, and have... - [SQL SERVER - Finding Different ColumnName From Almost Identitical Tables](https://blog.sqlauthority.com/2012/10/18/sql-server-finding-different-columnname-from-almost-identitical-tables/): I have mentioned earlier on this blog that I love social media – Facebook and Twitter. I receive so many interesting questions that sometimes I wonder how come I never faced them in my real life scenario. Well, let us see one of the similar situation. Here is one of the questions which I received on my social media handle. “Pinal, I have a large database. I did not develop this database but I have inherited this database. In our database we have many tables but all the tables are in pairs. We have one archive table and one current table.... - [SQLAuthority News - Pluralsight Course Review - Practices for Software Startups - Part 2 of 2](https://blog.sqlauthority.com/2012/10/17/sqlauthority-news-pluralsight-course-review-practices-for-software-startups-part-2-of-2/): This is the second part of the two part series of Practices for Software Startup Pluralsight Course. Please read the first part of this series over here. The course is written by Stephen Forte (Blog | Twitter). Stephen Forte is the Chief Strategy Officer of the venture backed company, Telerik. Personal Learning Schedule After these three sessions it was 6:30 am and time to do my own blog.  But for the rest of the day, I kept thinking about the course, and wanted to go back and finish.  I was wishing that I had woken up at 3 am so I could... - [SQLAuthority News - Pluralsight Course Review - Practices for Software Startups - Part 1 of 2](https://blog.sqlauthority.com/2012/10/16/sqlauthority-news-pluralsight-course-review-practices-for-software-startups-part-1-of/): This is first part of the two part series of Practices for Software Startup Pluralsight Course. The course is written by Stephen Forte (Blog | Twitter). Stephen Forte is the Chief Strategy Officer of the venture backed company, Telerik, a leading vendor of developer and team productivity tools. Stephen is also a Certified Scrum Master, Certified Scrum Professional, PMP, and also speaks regularly at industry conferences around the world. He has written several books on application and database development.  Stephen is also a board member of the Scrum Alliance. Startups – Everybodies Dream Start-up companies are an important topic right now –... - [SQL SERVER - Free Print Book on SQL Server Joes 2 Pros Kit](https://blog.sqlauthority.com/2012/10/15/sql-server-free-print-book-on-sql-server-joes-2-pros-kit/): Rick Morelan and I were discussing earlier this month that what we can give back to the community. We believe our books are very much successful and very well received by the community. The five books are a journey from novice to expert. The books have changed many lives and helped many get jobs as well pass the SQL Certifications. Rick is from Seattle, USA and I am from Bangalore, India. There are 12 hours difference between us. We try to do weekly meeting to catch up on various personal and SQL related topics. Here is one of our recent conversations.... - [SQL SERVER - Find First Non-Numeric Character from String](https://blog.sqlauthority.com/2012/10/14/sql-server-find-first-non-numeric-character-from-string/): It is fun when you have to deal with simple problems and there are no out of the box solution. I am sure there are many cases when we needed the first non-numeric character from the string but there is no function available to identify that right away. Here is the quick script I wrote down using PATINDEX. The function PATINDEX exists for quite a long time in SQL Server but I hardly see it being used. Well, at least I use it and I am comfortable using it. Here is a simple script which I use when I have to... - [SQL SERVER - 2012 - List All The Column With Specific Data Types in Database](https://blog.sqlauthority.com/2012/10/13/sql-server-2012-list-all-the-column-with-specific-data-types-in-database/): 5 years ago I wrote script SQL SERVER – 2005 – List All The Column With Specific Data Types, when I read it again, it is very much relevant and I liked it. This is one of the script which every developer would like to keep it handy. I have upgraded the script bit more. I have included few additional information which I believe I should have added from the beginning. It is difficult to visualize the final script when we are writing it first time. I use every script which I write on this blog, the matter of the fact,... - [SQL SERVER - Advanced Data Quality Services with Melissa Data - Azure Data Market](https://blog.sqlauthority.com/2012/10/12/sql-server-advanced-data-quality-services-with-melissa-data-azure-data-market/): There has been much fanfare over the new SQL Server 2012, and especially around its new companion product Data Quality Services (DQS). Among the many new features is the addition of this integrated knowledge-driven product that enables data stewards everywhere to profile, match, and cleanse data. In addition to the homegrown rules that data stewards can design and implement, there are also connectors to third party providers that are hosted in the Azure Datamarket marketplace.  In this review, I leverage SQL Server 2012 Data Quality Services, and proceed to subscribe to a third party data cleansing product through the Datamarket to... - [SQLAuthority News - Amazon Gift Card Raffle for Beta Tester Feedback for NuoDB](https://blog.sqlauthority.com/2012/10/11/sqlauthority-news-amazon-gift-card-raffle-for-beta-tester-feedback-for-nuodb/): As regular readers know I’ve been spending some time working with the NuoDB beta software. They contacted me last week and asked if I would give you a chance to try their new web-based console for their scalable, SQL-compliant database. They have just put out their final beta release, Beta 9.  It contains a preview of a new web-based “NuoConsole” that will replace and extend the functionality of their current desktop version.  I haven’t spent any time with the new console yet but a really quick look tells me it should make it easier to do deeper monitoring than the older... - [SQL SERVER - Find Rows and Index Count - SQL in Sixty Seconds #029 - Video](https://blog.sqlauthority.com/2012/10/10/sql-server-find-rows-and-index-count-sql-in-sixty-seconds-029-video/): There are a few questions I often get asked. I wonder how interesting is that in our daily life all of us have to often need the same kind of information at the same time. Here is the example of the similar questions about index count: - [SQL SERVER - Identify Numbers of Non Clustered Index on Tables for Entire Database](https://blog.sqlauthority.com/2012/10/09/sql-server-identify-numbers-of-non-clustered-index-on-tables-for-entire-database/): Here is the script which will give you numbers of non clustered indexes on any table in entire database. SELECT COUNT(i.TYPE) NoOfIndex, [schema_name] = s.name, table_name = o.name FROM sys.indexes i INNER JOIN sys.objects o ON i.[object_id] = o.[object_id] INNER JOIN sys.schemas s ON o.[schema_id] = s.[schema_id] WHERE o.TYPE IN ('U') AND i.TYPE = 2 GROUP BY s.name, o.name ORDER BY schema_name, table_name Here is the small story behind why this script was needed. I recently went to meet my friend in his office and he introduced me to his colleague in office as someone who is an expert in SQL Server... - [SQLAuthority News - A Conversation with an Old Friend - Sri Sridharan](https://blog.sqlauthority.com/2012/10/09/sqlauthority-news-a-conversation-with-an-old-friend-sri-sridharan/): Sri Sridharan is my old friend and we often talk on GTalk. The subject varies from Life in India/USA, movies, musics, and of course SQL. We have our differences when we talk about food or movie but we always agree when we talk about SQL. Yesterday while chatting with him we talked about SQLPASS and the conversation lasted for a long time. Here is the conversation between us on GTalk. I have removed a few of the personal talks and formatted into paragraphs as GTalk often shows stuff out of formatting. Pinal: Sri, Congrats on running for the PASS BoD again. You... - [SQL SERVER - Recover the Accidentally Renamed Table](https://blog.sqlauthority.com/2012/10/08/sql-server-recover-the-accidentally-renamed-table/): I have no answer to following question. I saw a desperate email marked as urgent delivered in my mailbox. “I accidentally renamed table in my SSMS. I was scrolling very fast and I made mistakes. It was either because I double clicked or clicked on F2 (shortcut key for renaming). However, I have made the mistake and now I have no idea how to fix this. I am in big trouble. Help me get my original tablename.” I have seen many similar scenarios in my life and they give me a very good opportunity to preach wisdom but when the house... - [SQLAuthority News - Download Whitepaper - SQL Server Analysis Services to Hive](https://blog.sqlauthority.com/2012/10/07/sqlauthority-news-download-whitepaper-sql-server-analysis-services-to-hive/): The SQL Server Analysis Service is a very interesting subject and I always have enjoyed learning about it. You can read my earlier article over here. Big Data is my new interest and I have been exploring it recently. During this weekend this blog post caught my attention and I enjoyed reading it. Big Data is the next big thing. The growth is predicted to be 60% per year till 2016. There is no single solution to the growing need of the big data available in the market right now as well there is no one solution in the business intelligence... - [SQL SERVER - Manage Help Settings - CTRL + ALT + F1](https://blog.sqlauthority.com/2012/10/06/sql-server-manage-help-settings-ctrl-alt-f1/): In this blog post we will learn about how to manage help settings. It is a miracle that curiosity survives formal education. ~ Albert Einstein - [SQL SERVER - 3 Online SQL Courses at Pluralsight and Free Learning Resources](https://blog.sqlauthority.com/2012/10/05/sql-server-3-online-sql-courses-at-pluralsight-and-free-learning-resources/): Usain Bolt is an inspiration for all. He broke his own record multiple times because he wanted to do better! Read more about him on wikipedia. He is great and indeed fastest man on the planet. “Can you teach me SQL Server Performance Tuning?” This is one of the most popular questions which I receive all the time. The answer is YES. I would love to do performance tuning training for anyone, anywhere.  It is my favorite thing to do, and it is my favorite thing to train others in.  If possible, I would love to do training 24 hours a... - [SQL SERVER - Importance of User Without Login - T-SQL Demo Script](https://blog.sqlauthority.com/2012/10/04/sql-server-importance-of-user-without-login-t-sql-demo-script/): Earlier I wrote a blog post about SQL SERVER – Importance of User Without Login and my friend and SQL Expert Vinod Kumar has written excellent follow up blog post about Contained Databases inside SQL Server 2012. Now lots of people asked me if I can also explain the same concept again so here is the small demonstration for it. Let me show you how login without user can help. Before we continue on this subject I strongly recommend that you read my earlier blog post here. - [SQL SERVER - Identify Most Resource Intensive Queries - SQL in Sixty Seconds #028 - Video](https://blog.sqlauthority.com/2012/10/03/sql-server-identify-most-resource-intensive-queries-sql-in-sixty-seconds-028-video/): During performance tuning conversation the very first question people often ask is what are the queries offending the server or in another word let us identify the queries which are the most resource intensive. The resources are often described as either Memory, CPU or IO. When we talk about the queries the same is applicable for them as well. The query which is doing lots of reads or writes are for sure resource intensive as well query which are taking maximum CPU time. Performance tuning is a very deep subject and we all have our own preference regarding what should be... - [SQL SERVER - Solution - 2 T-SQL Puzzles - Display Star and Shortest Code to Display 1](https://blog.sqlauthority.com/2012/10/02/sql-server-solution-2-t-sql-puzzles-display-star-and-shortest-code-to-display-1/): Earlier on this blog we had asked two puzzles. The response from all of you is nothing but Amazing. I have received 350+ responses. Many are valid and many were indeed something I had not thought about it. I strongly suggest you read all the puzzles and their answers here – trust me if you start reading the comments you will not stop till you read every single comment. Seriously trust me on it. Personally I have learned a lot from it. Let us recap the puzzles here quickly. Puzzle 1: Why following code when executed in SSMS displays result as... - [SQLAuthority News - Follow up on - Replace a Column Name in Multiple Stored Procedure all together](https://blog.sqlauthority.com/2012/10/01/sqlauthority-news-follow-up-on-replace-a-column-name-in-multiple-stored-procedure-all-together/): Last month I had a fantastic time with lots of puzzles and brain teasers, the amount of participation which I have received on the blog is indeed inspiring to write more. One of the blog post was about how to replace a column name in all the stored procedures. The article had very interesting conversation as a follow up. Please read the original article Replace a Column Name in Multiple Stored Procedure all together before reading this blog further as they are connected. Let us start few of the interesting comments. SQL Server Expert Imran Mohammed had a wonderful first and excellent... - [SQL SERVER - Preserve Leading Zero While Coping to Excel from SSMS](https://blog.sqlauthority.com/2012/09/30/sql-server-preserve-leading-zero-while-coping-to-excel-from-ssms/): Earlier I wrote two articles about how to efficiently copy data from SSMS to Excel. Since I wrote that post there are plenty of interest generated on this subject. There are a few questions I keep on getting over this subject. One of the question is how to get the leading zero preserved while copying the data from SSMS to Excel. Well it is almost the same way as my earlier post SQL SERVER – Excel Losing Decimal Values When Value Pasted from SSMS ResultSet. The key here is in EXCEL and not in SQL Server. - [SQL SERVER - Importance of User Without Login](https://blog.sqlauthority.com/2012/09/29/sql-server-importance-of-user-without-login/): Some questions are very open ended. Here is one question I was asked in recent User Group Meeting about user without login. - [SQL SERVER - A Picture is Worth a Thousand Words - A Collection of Inspiring and Funny Posts by Vinod Kumar](https://blog.sqlauthority.com/2012/09/28/sql-server-a-picture-is-worth-a-thousand-words-a-collection-of-inspiring-and-funny-posts-by-vinod-kumar/): One of the most popular quotes is: A picture is worth a thousand words. Working on this concept I started a series over my blog called the “Picture Post”. Rather than rambling over tons of material over text, we are trying to give you a capsule mode of the blog in a quick glance. Some of the picture posts already available over my blog are: Correlation of Ego and Work: Ego and Pride most of the times become a hindrance when we work inside a team. Take this cue, the first ever Picture post was published. Simple and easy to understand... - [SQL SERVER - Not Possible - Delete From Multiple Table - Update Multiple Table in Single Statement](https://blog.sqlauthority.com/2012/09/27/sql-server-not-possible-delete-from-multiple-table-update-multiple-table-in-single-statement/): There are two questions which I get every single day multiple times. In my gmail, I have created standard canned reply for them. Let us see the questions here. I want to delete from multiple table in a single statement how will I do it? I want to update multiple table in a single statement how will I do it? The answer is – No, You cannot and you should not. SQL Server does not support deleting or updating from two tables in a single update. If you want to delete or update two different tables – you may want to... - [SQL SERVER - Copy Column Headers from Resultset - SQL in Sixty Seconds #027 - Video](https://blog.sqlauthority.com/2012/09/26/sql-server-copy-column-headers-from-resultset-sql-in-sixty-seconds-027-video/): SQL Server Management Studio returns results in Grid View, Text View and to the file. When we copy results from the Grid View to Excel there is a common complaint that the column header displayed in resultset is not copied to the Excel. I often spend time in performance tuning databases and I run many DMV's in SSMS to get a quick view of the server. In my case it is almost certain that I need all the time copy column headers when I copy my data to excel or any other place. - [SQL SERVER - Basic Calculation and PEMDAS Order of Operation](https://blog.sqlauthority.com/2012/09/25/sql-server-basic-calculation-and-pemdas-order-of-operation/): After thinking a long time, I have decided to write about this blog post. I had no plan to create a blog post about this subject but the amount of conversation this one has created on my Facebook page, I decided to bring up a few of the question and concerns discussed on the Facebook page. There are more than 10,000 comments here so far. There are lots of discussion about what should be the answer. Well, as far as I can tell there is a big debate going on on Facebook, for educational purpose you should go ahead and read some of... - [SQL SERVER - Excel Losing Decimal Values When Value Pasted from SSMS ResultSet](https://blog.sqlauthority.com/2012/09/24/sql-server-excel-losing-decimal-values-when-value-pasted-from-ssms-resultset/): I often get questions that how to fix the issue where excel loses decimal values when values are pasted from SSMS Resultset.  - [SQLAuthority News - Download SQL Server 2012 SP1 CTP4](https://blog.sqlauthority.com/2012/09/23/sqlauthority-news-download-sql-server-2012-sp1-ctp4/): There are few trends I often see in the industry, for example i) running servers on n-1 version ii) wait till SP1 to released to adopt the product. Microsoft has recently released SQL Server 2012 SP1 CTP4. CTP stands for Community Technology Preview and it is not the final version yet. The SQL Server 2012 SP1 CTP release is available for testing purposes and use on non-production environments. What’s new for SQL Server 2012 SP1: AlwaysOn Availability Group OS Upgrade: Selective XML Index FIX: DBCC SHOW_STATISTICS works with SELECT permission New dynamic function returns statistics properties SSMS Complete in Express SlipStream Full installation... - [SQL SERVER - Denali - Conversion Function - TRY_PARSE() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/07/sql-server-denali-conversion-function-try_parse-a-quick-introduction/): In SQL Server Denali, there are three new conversion functions being introduced, namely: PARSE() TRY_PARSE() TRY_CONVERT() Today we will quickly take a look at the TRY_PARSE() function. The TRY_PARSE() function can convert any string value to Numeric or Date/Time format. If the passed string value cannot be converted to Numeric or Date/Time format, it will result to a NULL. The PARSE() function relies on Common Language Runtime (CLR) to convert the string value. If there is no CLR installed in the server, the TRY_PARSE() function will return an error. Additionally, please note that TRY_PARSE() only works for String Values to be... - [SQL SERVER - A Guide to Integrating SQL Server with XML, C#, and PowerShell - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/09/07/sql-server-a-guide-to-integrating-sql-server-with-xml-c-and-powershell-book-available-for-sql-server-certification/): We recently gave away 7 physical books of Joes 2 Pros Book Volume 5. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. All objects... - [SQL SERVER - Denali - Conversion Function - PARSE() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/06/sql-server-denali-conversion-function-parse-a-quick-introduction/): In SQL Server Denali, there are three new conversion functions being introduced, namely: PARSE() TRY_PARSE() TRY_CONVERT() Today we will quickly look at PARSE() function. PARSE() function can convert any string value to Numeric or Date/Time format. If passed string value cannot be converted to Numeric or Date/Time format, it will result to an error. PARSE() function relies on Common Language Runtime (CLR) to convert the string value. If there is no CLR installed on the server, PARSE() function will return an error. Additionally, please note that PARSE only works for String Values to be converted to Numeric and Date/Time. If you... - [SQL SERVER - Download Denali CTP3 and Denali CTP 3 Product Guide](https://blog.sqlauthority.com/2011/09/06/sql-server-download-denali-ctp3-and-denali-ctp-3-product-guide/): Microsoft SQL Server code name ‘Denali’ enables a cloud-ready information platform that will help organizations unlock breakthrough insights across the organization as well as quickly build solutions and extend data across on-premises and public cloud backed by capabilities for mission critical confidence. Download Denali CTP3. Additionally you can read what are new features of the Denali CTP3 on TechNet Wiki. The SQL Server code name ‘Denali’ Community Technical Preview 3 (CTP3) Product Guide download contains the latest datasheets, white papers, click-through and auto-running demonstrations, hands-on lab previews, technical presentations, and other useful links to help you evaluate the SQL Server code... - [SQLAuthority News - Whitepaper - Running SQL Server with Hyper-V Dynamic Memory Best Practices and Considerations - Consolidating Databases Using Virtualization Planning Guide](https://blog.sqlauthority.com/2011/09/05/sqlauthority-news-whitepaper-running-sql-server-with-hyper-v-dynamic-memory-best-practices-and-considerations/): I was recently looking for best practices for Hyper-V and SQL Server and I ended up whitepaper which was published in July earlier this year. I really wish I had come across this whitepaper earlier but any way still it is better to be late then never. Download Running SQL Server with Hyper-V Dynamic Memory – Best Practices and Considerations Memory is a critical resource to Microsoft SQL Server workloads, especially in a virtualized environment where resources are shared and contention for shared resources can lead to negative impact on the workload. Windows Server 2008 R2 SP1 introduced Hyper-V Dynamic Memory,... - [SQL SERVER - Programming and Development - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/09/05/sql-server-programming-and-development-book-available-for-sql-server-certification/): We recently gave away 7 physical books of Joes 2 Pros Book Volume 4. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. All objects... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - OpenXML Options - Day 35 of 35](https://blog.sqlauthority.com/2011/09/04/sql-server-tips-from-the-sql-joes-2-pros-development-series-openxml-options-day-35-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. OpenXML Options The last posts introduced us to the OpenXML function. We learned the two required parameters for this function are the handle (which must be in the form of an integer) and the rowpattern (to know what part of the XML has your data). The OpenXML function offers some helpful options for querying. This post will explore the two main syntaxes for rowpattern recursion... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Preparing XML in Memory - Day 34 of 35](https://blog.sqlauthority.com/2011/09/03/sql-server-tips-from-the-sql-joes-2-pros-development-series-preparing-xml-in-memory-day-34-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. Preparing XML in Memory If you want to take XML data and create a result set in SQL Server, you must first store the XML in memory. The process of preparing XML in SQL includes storing the XML in memory and processing the XML so that all the data and metadata is ready and available for you to query. Recall that element levels in your... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Shredding XML - Day 33 of 35](https://blog.sqlauthority.com/2011/09/02/sql-server-tips-from-the-sql-joes-2-pros-development-series-shredding-xml-day-33-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. Shredding XML Our introduction to XML in the last 3 days of posts thus far has focused on seeing tabular data taken from SQL Server and streamed into well-formed XML instead of the rowset data we typically work with.  The next two posts will focus on the reverse process.  Our starting point will be data which is already in XML and which we will... - [SQLAuthority News - Programming & Development For Microsoft SQL Server 2008](https://blog.sqlauthority.com/2011/09/02/sqlauthority-news-programming-development-for-microsoft-sql-server-2008/): I just can not resist sharing this video which my wife took while I was reading the book I co-authored. After long debate with my wife I have decided to put this video on youtube for public viewing. I initially thought, it is good to just have this in personal collection but my wife Nupur insisted on putting it live. [youtube=http://www.youtube.com/watch?v=l1rvrBQUU-s] You can buy my book from Amazon.com and Flipkart. We did receive few notes from user that it is listed as out-of-stock. There may be some glitch but the book has been always available as there is enough copies of... - [SQLAuthority News - SQL Wait Stats Joes 2 Pros Book Released Today - 30 Million Views Completed](https://blog.sqlauthority.com/2011/09/01/sqlauthority-news-sql-wait-stats-joes-2-pros-book-released-today-30-million-views-completed/): Happy Ganesh Chaturthi to all the friends of SQLAuthority.com. On today's auspicious day I have three news to share - 1) Shaivi's 2nd Birthday 2) New Book Released 3) 30 Millions Views. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Using Root With Auto XML Mode - Day 32 of 35](https://blog.sqlauthority.com/2011/09/01/sql-server-tips-from-the-sql-joes-2-pros-development-series-using-root-with-auto-xml-mode-day-32-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. XML Path Mode The XML Raw and Auto modes are great for displaying data as all attributes or all elements – but not both at once. If you want your XML stream to have some of its data shown in attributes and some shown as elements, then you can use the XML Path mode. The following Select statement shows us all locations and the employees who work in... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Using Root With Auto XML Mode - Day 31 of 35](https://blog.sqlauthority.com/2011/08/31/sql-server-tips-from-the-sql-joes-2-pros-development-series-using-root-with-auto-xml-mode-day-31-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. Using Root With Auto XML Mode Now let’s add a root element (also called root node), so that our stream will be well-formed XML. Using the ROOT keyword in combination with the Auto mode produces the same result as it does with the Raw mode:  your XML stream will contain a root (named <root> by default). To specify a name for the root, put this name in the... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - What is XML? - Day 30 of 35](https://blog.sqlauthority.com/2011/08/30/sql-server-tips-from-the-sql-joes-2-pros-development-series-what-is-xml-day-30-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. Let’s look at another example from the Employee table.  If you ran the reset script for this chapter, you should see 14 JProCo employees showing in your Employee table. Next we will add FOR XML RAW to view the result from the Employee table as an XML output using the raw mode. We have changed our Employee table result to output as XML RAW.... - [SQL SERVER - SSQL Architecture Basics - Core Architecture Concepts - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/08/29/sql-server-ssql-architecture-basics-core-architecture-concepts-book-available-for-sql-server-certification/): We recently give away 7 physical books of Joes 2 Pros Book Volume 3. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. All objects... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - What is XML? - Day 29 of 35](https://blog.sqlauthority.com/2011/08/29/sql-server-tips-from-the-sql-joes-2-pros-development-series-what-is-xml-day-28-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 5. Every day one winner from United States will get Joes 2 Pros Volume 5. What is XML? A common observation by people seeing an XML file for the first time is that it looks like just a bunch of data inside a text file. XML files are text-based documents, which makes them easy to read.  All of the data is literally spelled out in the document and relies on a just a few characters (<, >, =)... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Structured Error Handling - Day 28 of 35](https://blog.sqlauthority.com/2011/08/28/sql-server-tips-from-the-sql-joes-2-pros-development-series-structured-error-handling-day-28-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. In everyday life, not everything you plan on doing goes your way. For example, recently I planned to turn left on Rosewood Avenue to head north to my office. To my surprise, the road was blocked because of construction. I still needed to head north, even though the signs told me that turning that direction was impossible. I could have treated the... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - SQL Server Error Messages - Day 27 of 35](https://blog.sqlauthority.com/2011/08/27/sql-server-tips-from-the-sql-joes-2-pros-development-series-sql-server-error-messages-day-27-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. SQL Server Error Messages By now, most readers have likely learned that it is better to deal with problems early on while they are small.  SQL Server detects and helps you identify most errors before you are even allowed to run the code. For example, if you try to run a query against a table which does not exist, SQL Server informs... - [SQL SERVER - Table Valued Functions - Day 26 of 35](https://blog.sqlauthority.com/2011/08/26/sql-server-tips-from-the-sql-joes-2-pros-development-series-table-valued-functions-day-26-of-35/): Let us learn about table valued functions. Every day one winner from the United States will get Joes 2 Pros Volume 4. - [SQL SERVER - Author's Book is Available in India and USA](https://blog.sqlauthority.com/2011/08/25/sql-server-authors-book-is-available-in-india-and-usa/): I am feeling very good to write this short blog post. My book is now officially available on in India and USA. In India you can get it from Flipkart – In USA you can get it from Amazon – This book is just like this blog and contains all the complex subject in very simple manner. I am confident that you will for sure like this book if you like this blog. Here is quick video shot by my wife when I was reading my own book. See the original post to see the video. [youtube=http://www.youtube.com/watch?v=l1rvrBQUU-s] Here is quick secret... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Table-Valued Store Procedure Parameters - Day 25 of 35](https://blog.sqlauthority.com/2011/08/25/sql-server-tips-from-the-sql-joes-2-pros-development-series-table-valued-store-procedure-parameters-day-25-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. Note: If you want to setup the sample JProCo database on your system you can watch this video. For this post you will want to run the SQLProgrammingChapter5.1Setup.sql script from Volume 4. Table-Valued Store Procedure Parameters Stored procedures can easily take a single parameter and use a variable to populate it.  A stored procedure can readily handle two parameters in this same fashion.  However,... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Easy Introduction to CHECK Options - Day 24 of 35](https://blog.sqlauthority.com/2011/08/24/sql-server-tips-from-the-sql-joes-2-pros-development-series-easy-introduction-to-check-options-day-24-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. Using Check Option CHECK OPTION is a very handy tool we can use with our views. If I give you the definition right away and you don’t already know what it does then is just confusing. However the examples make perfect sense. So let’s save the definition for the end of this post. First let’s look at the creation of the vHighValueGrants... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Introduction to Views - Day 23 of 35](https://blog.sqlauthority.com/2011/08/23/sql-server-tips-from-the-sql-joes-2-pros-development-series-introduction-to-views-day-23-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. View Options Not every query may be turned into a view.  There are rules which must be followed before your queries may be turned into views. View Rules This query includes a simple aggregation which totals the grant amounts according to each EmpID.  It’s a handy report, but we can’t turn it into a view. The error message shown displays when you... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - All about SQL Constraints - Day 22 of 35](https://blog.sqlauthority.com/2011/08/22/sql-server-tips-from-the-sql-joes-2-pros-development-series-all-about-sql-constraints-day-22-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 4. Every day one winner from United States will get Joes 2 Pros Volume 4. Check Constraints My old track coach would tell us to give 110% effort. However, had my math teacher heard this, he would have explained that a percentage value exceeding 100% in this context is not possible. For the coach it was a fun way that implies that you will give all you have, but then somehow you will give 10% more than... - [SQL SERVER - SQL Query Techniques For Microsoft SQL Server 2008 - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/08/22/sql-server-sql-query-techniques-for-microsoft-sql-server-2008-book-available-for-sql-server-certification/): We recently give away 7 physical books of Joes 2 Pros Book Volume 2. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. All objects... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - All about SQL Statistics - Day 21 of 35](https://blog.sqlauthority.com/2011/08/21/sql-server-tips-from-the-sql-joes-2-pros-development-series-all-about-sql-statistics-day-21-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. Real Life Statistics We are not surprised to see warm ski jackets appearing on display shelves starting in September. It’s not yet cold, but we know that winter time is a few months away based on our own recollection of the weather, which we’ve observed in previous seasons and prior years.  Our own memory of temperature and weather patterns is a knowledge... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Introduction to Page Split - Day 20 of 35](https://blog.sqlauthority.com/2011/08/20/sql-server-tips-from-the-sql-joes-2-pros-development-series-introduction-to-page-split-day-20-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. From yesterdays post we learned that the clustered index is the placement order of a table’s records in memory pages. When you insert new records, then each record will be inserted into the memory page in the order it belongs. Rick Morelan’s SSN (555-55-5555) belongs with the 5’s, so his record will be physically inserted in memory between Jonny Dirt and Sally... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - The Clustered Index - Simple Understanding - Day 19 of 35](https://blog.sqlauthority.com/2011/08/19/sql-server-tips-from-the-sql-joes-2-pros-development-series-the-clustered-index-simple-understanding-day-19-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. Since the physical storage of data impacts the speed and efficiency of our queries, in tomorrow’s post we will explore how clustered indexes can impact the physical location of data and the way SQL Server retrieves query data. For today we will need to know the basics of the Clustered Index. The Clustered Index What is clustering or a clustered index? Let’s... - [SQL SERVER - Geography Data Type - Calculating Distance Between Two Points on the Earth - Day 18 of 35](https://blog.sqlauthority.com/2011/08/18/sql-server-tips-from-the-sql-joes-2-pros-development-series-geography-data-type-calculating-distance-between-two-points-on-the-earth-day-18-of-35/): In this blog post we will learn about Geography Data Type. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Sparse Data and Space Used by Sparse Data - Day 17 of 35](https://blog.sqlauthority.com/2011/08/17/sql-server-tips-from-the-sql-joes-2-pros-development-series-sparse-data-and-space-used-by-sparse-data-day-17-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. Sparse Data Fields with fixed length data types (e.g., int, money) always consume their allotted space irrespective of how much data the field actually contains. This is true even if the field is populated with a null. Occasionally you will encounter a column in your database which is rarely used. For example, suppose you have a field called [Violation] in a table... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - System and Time Data Types - Day 16 of 35](https://blog.sqlauthority.com/2011/08/16/sql-server-tips-from-the-sql-joes-2-pros-development-series-system-and-time-data-types-day-16-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. System and Time Data Types Keeping track of date and time data points has always been a critical part of online transactional databases. For example, each sales invoice record needs a date-time stamp, as do systems which track quotes and customer contacts regarding sales opportunities. Think of how many times during your workday that you rely on a date-time stamp as helpful... - [SQLAuthority News - Pluralsight Giving Away Free Subscription to Quiz Participants](https://blog.sqlauthority.com/2011/08/16/sqlauthority-news-pluralsight-giving-away-free-subscription-to-quiz-participants/): I am sure readers of this site are familiar with Pluralsight.  It is an online training site that describes itself as “a company created by developers, specifically for developers.”  At their site you can find training courses on a variety of topics and weekly webcasts by industry specialists. Right now the latest news on the blog is that businesses can subscribe to Pluralsight to help train their employees: Pluralsight subscriptions for businesses.  The blog has also introduced course assessments so that users can track their progress – and employers can see how well their employees are doing. Pluralsight is also going... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Data Row Space Usage and NULL Storage - Day 15 of 35](https://blog.sqlauthority.com/2011/08/15/sql-server-tips-from-the-sql-joes-2-pros-development-series-data-row-space-usage-and-null-storage-day-15-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 3. Every day one winner from United States will get Joes 2 Pros Volume 3. Data Row Space Usage Most of a table’s space is occupied by its records. Indexes and other properties use a relatively small amount of known space for the table.  Suppose your company – or a hiring manager – shows you the design of the SalesInvoiceDetail table and says, “We expect this table to receive an average of 100,000 records per day during... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Output Clause in Simple Examples - Day 14 of 35](https://blog.sqlauthority.com/2011/08/14/sql-server-tips-from-the-sql-joes-2-pros-development-series-output-clause-in-simple-examples-day-14-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Output We will first begin our work with the OUTPUT clause, by diving into hands-on examples of deleting, inserting, and updating table data. Later, we will demonstrate logging these types of changes in a separate storage table. Note: The OUTPUT statement uses temporary INSERTED and/or DELETED tables. These memory-resident tables are used to determine the changes being caused by the INSERT, DELETE or UPDATE statements.... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Ranking Functions - Advanced NTILE in Detail - Day 13 of 35](https://blog.sqlauthority.com/2011/08/13/sql-server-tips-from-the-sql-joes-2-pros-development-series-ranking-functions-advanced-ntile-in-detail-day-13-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Ranking Functions Part 2 (NTILE) A friend of mine recently told me she’s very proud of her son, because he is consistently in the upper quarter of every class he takes. Right there she performed a calculation similar to the NTILE function. She didn’t know it, but she tiled the class into four pieces and then identified which piece her son belongs in.... - [SQL SERVER - Ranking Functions - RANK( ), DENSE_RANK( ), and ROW_NUMBER( ) - Day 12 of 35](https://blog.sqlauthority.com/2011/08/12/sql-server-tips-from-the-sql-joes-2-pros-development-series-ranking-functions-rank-dense_rank-and-row_number-day-12-of-35/): In this blog post we will discuss about Ranking Functions like RANK( ), DENSE_RANK( ), and ROW_NUMBER( ). Ranking Functions (Part 1) There are four ranking functions in SQL server. Today we will look at RANK( ), DENSE_RANK( ), and ROW_NUMBER( ).These functions all have the same basic behavior. Where they differ is in the handling of tie values. These three functions produce identical results, until a tying value in your data is present. - [SQL SERVER - SafePeak - The Plug and Play Immediate Acceleration Solution](https://blog.sqlauthority.com/2011/08/11/sql-server-safepeak-the-plug-and-play-immediate-acceleration-solution/): Let us learn about SafePeak - The Plug and Play Immediate Acceleration Solution. Introduction - Plug and Play Given how important performance is these days among SQL Server critical applications, I was excited to look into a new product by SafePeak Technologies that aims to immediately resolve, in a plug-and-play way, the performance, scalability and peaks challenges of SQL Server applications on the Cloud, hosting servers and enterprise data centers. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Advanced Aggregates with the Over Clause - Day 11 of 35](https://blog.sqlauthority.com/2011/08/11/sql-server-tips-from-the-sql-joes-2-pros-development-series-advanced-aggregates-with-the-over-clause-day-11-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Partitioning with the Over Clause (Part 2) Yesterday we learned how the over clause can be used to compare your number against the overall aggregated number for an entire result set. Sometimes you might want your number to be compared against its category and not all records from a table. For example I don’t get any joy in saying I never won... - [SQL SERVER - Who needs ETL Version Control?](https://blog.sqlauthority.com/2011/08/10/sql-server-who-needs-etl-version-control/): While making some changes (read: mistakes) to my ETL business logic the other day, it occurred to me much too late that those unfortunate changes had replaced the once properly working logic with now very flawed logic.  The good news was that I remembered what the working logic was supposed to be.  The bad news, I had to re-create it.  Had I had the working logic already checked-in under version control, I could have saved myself the two hours of wasted time and effort.  In an ETL team development setting, these types of issues could easily multiply and significantly impede developer... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Aggregates with the Over Clause - Day 10 of 35](https://blog.sqlauthority.com/2011/08/10/sql-server-tips-from-the-sql-joes-2-pros-development-series-aggregates-with-the-over-clause-day-10-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Aggregates with the Over Clause You have likely heard the business term “Market Share”. If your company is the biggest and has sold 15 million units in an industry that has sold a total of 50 million units then your company’s market share is 30% (15/50 = .30). Market share represents your number divide by the sum of all other numbers. In... - [SQL SERVER - Use INSERT INTO ... SELECT instead of Cursor](https://blog.sqlauthority.com/2011/08/10/sql-server-use-insert-into-select-instead-of-cursor/): This blog post is written in response to the post showing some of the worst practices of past. Well, just like last month’s theme, everybody learns by doing it one step at a time. In my case, I started my career as a network engineer and had no database knowledge during that time. I can still remember my old code which became quite a laughingstock when it was sent for a code review. This story is indeed interesting, so instead of writing shortly, I am going to write today in detail. It happened about 8 years ago when I was working... - [SQL SERVER - The SQL Hands-On Guide for Beginners - Book Available for SQL Server Certification](https://blog.sqlauthority.com/2011/08/09/sql-server-the-sql-hands-on-guide-for-beginners-book-available-for-sql-server-certification/): We recently give away 7 physical books of Joes 2 Pros eBook Volume 1. The response to following questions was overwhelming and was excellent. The book is available to purchase now in India and USA. This is great news as I often get request that where one can learn SQL Server, how to prepare for SQL Server Certifications. This book with its innovative visual approach lets you have firm hands-on experience as a SQL Server 2008 Developer. It is highly interactive with sections that challenge the student to play “Bug Catcher” in code, and do other interesting quiz games. United States:... - [SQL SERVER - Tips from the Development Series - Overriding Identity Fields - Day 9 of 35](https://blog.sqlauthority.com/2011/08/09/sql-server-tips-from-the-sql-joes-2-pros-development-series-overriding-identity-fields-tricks-and-tips-of-identity-fields-day-9-of-35/): In this blog post we are going to discuss about Overriding Identity Fields. For students new to the database world, it helps to begin thinking about ID fields in the context of larger organizations with lots of activity. A customer service department has a constant flow of activity and many representatives are entering data in the system simultaneously. The same is true for large billing departments. These are examples where an identity field helps to ensure the entities you care about get tracked properly. A CustomerID value that is automatically generated with each new record makes sure each new customer gets a unique number – even if you have many reps all entering data at the same time. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Many to Many Relationships - Day 8 of 35](https://blog.sqlauthority.com/2011/08/08/sql-server-tips-from-the-sql-joes-2-pros-development-series-many-to-many-relationships-day-8-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 2. Every day one winner from United States will get Joes 2 Pros Volume 2. Many to Many relationships If anyone has done some shopping on the internet you are familiar with the term “Shopping Cart” or “Shopping basket”. After you have selected a product you want to buy the storefront will gladly let you keep on shopping until there are many items in you shopping cart. On my last trip to Amazon.com I put 3 things... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Dirty Records and Table Hints - Day 7 of 35](https://blog.sqlauthority.com/2011/08/07/sql-server-tips-from-the-sql-joes-2-pros-development-series-dirty-records-and-table-hints-day-7-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Dirty Records Recap Most SQL people know what a “Dirty Record” is. You might also call that an “Intermediate record”. In case this is new to you here is a very quick explanation. The simplest way to describe the steps of a transaction is to use an example of updating an existing record into a table. When the insert runs, SQL Server gets... - [SQL SERVER - Row Constructors - Day 6 of 35](https://blog.sqlauthority.com/2011/08/06/sql-server-tips-from-the-sql-joes-2-pros-development-series-row-constructors-day-6-of-35/): In this blog post we will learn about Row Constructors. Row Constructors Most records we insert will come from a connection made to SQL from some external process. For example a web page ADO.NET connection to you company data layer or some data feed from an SSIS package. Still most seed data or special inserts may come from the INSERT INTO DML statement. Before SQL 2008 if you had to insert 20 records you needed 20 separate INSERT INTO statements. Now you can do all 20 inserts in one transaction. Let’s start off our example by creating a very simple table with the following code. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Finding un-matching Records - Day 5 of 35](https://blog.sqlauthority.com/2011/08/05/sql-server-tips-from-the-sql-joes-2-pros-development-series-finding-un-matching-records-day-5-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Finding un-matching Records Often time we want to find records in one table that have no matching key in another table. This is common for things like finding products that have never sold, or students who did not re-enroll. Something we were expecting is missing. Records in one table were expecting some related activity in another table and did not find them.... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Efficient Query Writing Strategy - Day 4 of 35](https://blog.sqlauthority.com/2011/08/04/sql-server-tips-from-the-sql-joes-2-pros-development-series-efficient-query-writing-strategy-day-4-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Query Writing Strategy Some people may push back on this next technique or misunderstand until getting to the very end. The goal is to have fewer errors as you write complex queries more quickly by making sure the easy stuff works first. If you are a SQL expert who only works on the same database for the rest of your life who... - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Finding Apostrophes in String and Text - Day 3 of 35](https://blog.sqlauthority.com/2011/08/03/sql-server-tips-from-the-sql-joes-2-pros-development-series-finding-apostrophes-in-string-and-text-day-3-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Finding Apostrophes in string and text - [SQL SERVER - Tips from the SQL Development Series - Wildcard - Querying Special Characters - Day 2 of 35](https://blog.sqlauthority.com/2011/08/02/sql-server-tips-from-the-sql-joes-2-pros-development-series-wildcard-querying-special-characters-day-2-of-35/): In this blog post we will learn various tips related to Querying Special Characters with the help of wildcard in SQL Server. Some special characters can be tricky to pattern match since they themselves can represent different values at different times. Let look at some examples. Here is a quick look at all the records in the [Grant] table of the JProCo database. Note: Since [Grant] is also a keyword it must be enclosed in square brackets or double quotes to designate it as the [Grant] table and now the keyword. Take a look at many of the names in the GrantName field and notice we have many names with special symbols in them. - [SQL SERVER - Tips from the SQL Joes 2 Pros Development Series - Wildcard Basics Recap - Day 1 of 35](https://blog.sqlauthority.com/2011/08/01/sql-server-tips-from-the-sql-joes-2-pros-development-series-wildcard-basics-recap-day-1-of-35/): Answer simple quiz at the end of the blog post and – Every day one winner from India will get Joes 2 Pros Volume 1. Every day one winner from United States will get Joes 2 Pros Volume 1. Wildcard ranges If you have ever been to a convention where they have a morning registration desk that must handle thousands of people in a short time you know they must put some pre-planning thought into how to handle this burst of volume. In fact often they will have many registration desks running in parallel to make things run faster. The first... - [SQL SERVER - Win a Book a Day - Contest Rules - Day 0 of 35](https://blog.sqlauthority.com/2011/08/01/sql-server-win-a-book-a-day-contest-rules-day-0-of-35/): Learning is an extremely important part of life. From the first step, everybody progresses in life and learns something new. Earlier this year, SQLAuthority.com had a month-long series on SQL Server Interview Questions. It was extremely popular series, and I received a lot of encouraging comments. While I compiled the received feedback, one important feedback was the need of good basic learning.  The reason for writing this series is to present a proper learning structure rather than a simple blog post. And here is your chance to win some exciting gifts – For the next 35 days, every day at SQLAuthority.com,... - [SQL SERVER - The Difficult Interview Question - Moment of the Life - Day 31 of 31](https://blog.sqlauthority.com/2011/07/31/sql-server-the-difficult-interview-question-moment-of-the-life-day-31-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Complete List of all the Interview Questions and Answers Series blogs. We have spent the last 30 days going over questions and answers you may come up against when you are being interviewed.  Of course, I am only human and I can’t provide you with the answer to every question, or even the answer to every situation – because sometimes acing an interview is more than getting all the answers right. Sometimes acing an interview is more about impressing... - [SQL SERVER - Interview Questions and Answers - Guest Post by Jacob Sebastian - Day 30 of 31](https://blog.sqlauthority.com/2011/07/30/sql-server-interview-questions-and-answers-guest-post-by-jacob-sebastian-day-30-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Jacob Sebastian is a SQL Server MVP, Author, Speaker and my personal friend. Jacob is one of the top rated expert in SQL Community. Jacob wrote the book The Art of XSD – SQL Server XML Schema Collections and wrote the XML Chapter in SQL Server 2008 Bible. He has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. I encourage all the readers to participate in T-SQL Challenges. I am very much... - [SQL SERVER - Interview Questions and Answers - Guest Post by Feodor Georgiev - Day 29 of 31](https://blog.sqlauthority.com/2011/07/29/sql-server-interview-questions-and-answers-guest-post-by-feodor-georgiev-day-29-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Feodor Georgiev is a SQL Server database specialist with extensive experience of thinking both within and outside the box. He has wide experience of different systems and solutions in the fields of architecture, scalability, performance, etc. Feodor has experience with SQL Server 2000 and later versions, and is certified in SQL Server 2008. He has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. About a month ago I wrote a post... - [SQL SERVER - Interview Questions and Answers - Guest Post by Nakul Vachhrajani - Day 28 of 31](https://blog.sqlauthority.com/2011/07/28/sql-server-interview-questions-and-answers-guest-post-by-nakul-vachhrajani-day-28-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Nakul Vachhrajani is a Technical Lead and systems development professional with iGATE Patni having a total IT experience of more than 6 years. He has comprehensive grasp on Database Administration, Development and Implementation with MS SQL Server and C, C++, Visual C++/C#. He has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. Interviews – A Definition The Merriam-Webster English dictionary defines an “Interview” in two ways. A formal consultation usually to... - [SQL SERVER - Latest expressor Data Integration Platform Posts](https://blog.sqlauthority.com/2011/07/28/sql-server-latest-expressor-data-integration-platform-posts/): I continue to frequently post new articles on expressor and would like to share with you my latest three posts: Introduction to expressor Datascript Modules 5 Tips for improving your data with expressor Studio expressor 3.2 Release Review I will soon be blogging about their upcoming 3.4 release to keep you informed about the latest developments around their product. If you haven’t tried yet, consider downloading and test-driving their Studio product – it’s absolutely free. Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interview Questions and Answers - Guest Post by Rick Morelan - Day 27 of 31](https://blog.sqlauthority.com/2011/07/27/sql-server-interview-questions-and-answers-guest-post-by-rick-morelan-day-27-of-31/): Rick Morelan is finest SQL Expert. He is very much known for his excellent book series Joes 2 Pros. His books are not only an inspiration to many who wants to learn SQL Server properly, but a MUST read for any SQL enthusiast. He has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. - [SQL SERVER - Interview Questions and Answers - Guest Post by Malathi Mahadevan - Day 26 of 31](https://blog.sqlauthority.com/2011/07/26/sql-server-interview-questions-and-answers-guest-post-by-malathi-mahadevan-day-26-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. Malathi Mahadevan who is known SQL Server Expert has written following guest blog post to keep alive the spirit of Interview Questions and Answers Series. I encourage all the readers to read her excellent blog and follower her on twitter. One of the questions i was asked – and a regular at most interviews where i work is ‘What is the toughest challenge you have faced at your present job and how did you handle it’? Before looking at... - [SQL SERVER - Azure Interview Questions and Answers - Guest Post by Paras Doshi - Day 25 of 31](https://blog.sqlauthority.com/2011/07/25/sql-server-azure-interview-questions-and-answers-guest-post-by-paras-doshi-day-25-of-31/): Please read the Introductory Post before continue reading Azure interview question and answers. - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Data Warehouseing Concepts - Day 24 of 31](https://blog.sqlauthority.com/2011/07/24/sql-server-interview-questions-and-answers-frequently-asked-questions-data-warehouseing-concepts-day-24-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is Hybrid Slowly Changing Dimension? Hybrid SCDs are combination of both SCD 1 and SCD 2. It may happen that in a table, some columns are important and we need to track changes for them, i.e. capture the historical data for them, whereas in some columns even if the data changes, we do not care. What is BUS Schema? BUS Schema consists of a master suite of confirmed... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Data Warehouseing Concepts - Day 23 of 31](https://blog.sqlauthority.com/2011/07/23/sql-server-interview-questions-and-answers-frequently-asked-questions-data-warehouseing-concepts-day-23-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is ETL? ETL is abbreviation of extract, transform, and load. ETL is software that enables businesses to consolidate their disparate data while moving it from place to place, and it doesn’t really matter that that data is in different forms or formats. The data can come from any source. ETL is powerful enough to handle such data disparities. First, the extract function reads data from a specified source... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Data Warehouseing Concepts - Day 22 of 31](https://blog.sqlauthority.com/2011/07/22/sql-server-interview-questions-and-answers-frequently-asked-questions-data-warehouseing-concepts-day-22-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is OLTP? OLTP is abbreviation of On-Line Transaction Processing. This system is an application that modifies data At the very instant it is received and has a large number of concurrent users. What is OLAP? OLAP is abbreviation of Online Analytical Processing. This system is an application that collects, manages, processes and presents multidimensional data for analysis and management purposes. What is the Difference between OLTP and OLAP?... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Data Warehouseing Concepts - Day 21 of 31](https://blog.sqlauthority.com/2011/07/21/sql-server-interview-questions-and-answers-frequently-asked-questions-data-warehouseing-concepts-day-21-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs 4) Data Warehousing Concepts Interview Questions & Answers What is Data Warehousing? A data warehouse is the main repository of an organization’s historical data, its corporate memory. It contains the raw material for management’s decision support system. The critical factor leading to the use of a data warehouse is that a data analyst can perform complex queries and analysis, such as data mining, on the information without slowing down... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 20 of 31](https://blog.sqlauthority.com/2011/07/20/sql-server-interview-questions-and-answers-frequently-asked-questions-day-20-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What are Policy Management Terms? To have a better grip on the concept of Policy-based management, there are some key terms you need to understand. Target – A type of entity that is appropriately managed by Policy-based management. For example, a table, database and index, to name a few. Facet -A property that can be managed in policy-based management. A clear example of facet is the name of Trigger... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 19 of 31](https://blog.sqlauthority.com/2011/07/19/sql-server-interview-questions-and-answers-frequently-asked-questions-day-19-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs How can I Track the Changes or Identify the Latest Insert-Update-Delete from a Table? In SQL Server 2005 and earlier versions, there is no inbuilt functionality to know which row was recently changed and what the changes were. However, in SQL Server 2008, a new feature known as Change Data Capture (CDC) has been introduced to capture the changed data. (Read more here) What is the CPU Pressure? CPU... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 18 of 31](https://blog.sqlauthority.com/2011/07/18/sql-server-interview-questions-and-answers-frequently-asked-questions-day-18-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs How to Copy Data from One Table to Another Table? There are multiple ways to do this. 1) INSERT INTO SELECT This method is used when table is already created in the database earlier and data have to be inserted into this table from another table. If columns listed in the INSERT clause and SELECT clause are same, listing them is not required. 2) SELECT INTO This method is... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 17 of 31](https://blog.sqlauthority.com/2011/07/17/sql-server-interview-questions-and-answers-frequently-asked-questions-day-17-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs How will you Handle Error in SQL SERVER 2008? SQL Server now supports the use of TRY…CATCH constructs for providing rich error handling. TRY…CATCH lets us build error handling at the level we need, in the way we need to by setting a region where if any error occurs, it will break out of the region and head to an error handler. The basic structure is as follows: BEGIN... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 16 of 31 - CTE- Joins](https://blog.sqlauthority.com/2011/07/16/sql-server-interview-questions-and-answers-frequently-asked-questions-day-16-of-31/): Please read the Introductory Post before continuing reading interview questions and answers. In this blog post we will learn about few popular topics of SQL Server like CTE and joins.  - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 15 of 31](https://blog.sqlauthority.com/2011/07/15/sql-server-interview-questions-and-answers-frequently-asked-questions-day-15-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is Service Broker? Service Broker is a message-queuing technology in SQL Server that allows developers to integrate SQL Server fully into distributed applications. Service Broker is a feature which provides facility to SQL Server to send an asynchronous, transactional message. It allows a database to send a message to another database without waiting for the response; so the application will continue to function if the remote database is... - [Interview Questions and Answers - FAQ - Day 14 of 31](https://blog.sqlauthority.com/2011/07/14/sql-server-interview-questions-and-answers-frequently-asked-questions-day-14-of-31/): Please read the Introductory Post before continuing reading interview questions and answers. What are the basic functions? - [SQL SERVER - Query to Find Duplicate Indexes - Script to Find Redundant Indexes](https://blog.sqlauthority.com/2011/07/13/sql-server-query-to-find-duplicate-indexes-script-to-find-redundant-indexes/): I was recently delivering session on Performance Tuning subject. I was asking if there is any harm having duplicate indexes. Of course, duplicate indexes are nothing but overhead on the database system. Database system has to maintain two sets of indexes when it has to do update, delete, insert on the table which has duplicate indexes. There is also a possibility that indexes are overlapped. For example, Index1 have Col1, Col2, Col3 but Index2 have Col1,Col2,Col3,Col4,Col5. Here Index1 and Index2 are overlapping and there is no need of Index1, which should be removed. Following is the script which does the same... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 13 of 31](https://blog.sqlauthority.com/2011/07/13/sql-server-interview-questions-and-answers-frequently-asked-questions-day-13-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is Aggregate Functions? Aggregate functions perform a calculation on a set of values and return a single value. Aggregate functions ignore NULL values except COUNT function. HAVING clause is used, along with GROUP BY for filtering query using aggregate values. The following functions are aggregate functions. AVG, MIN, CHECKSUM_AGG, SUM, COUNT, STDEV, COUNT_BIG, STDEVP, GROUPING, VAR, MAX, VARP (Read more here ) What is Use of @@ SPID... - [SQL SERVER - Database Worst Practices](https://blog.sqlauthority.com/2011/07/12/sql-server-database-worst-practices-new-town-and-new-job-and-new-disasters/): Let us talk about SQL SERVER - Database Worst Practices. Instead of writing best practices, I am going to write about few of the bad ones. - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 12 of 31](https://blog.sqlauthority.com/2011/07/12/sql-server-interview-questions-and-answers-frequently-asked-questions-day-12-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs How does Using a Separate Hard Drive for Several Database Objects Improves Performance Right Away? A non-clustered index and tempdb can be created on a separate disk to improve performance. (Read more here) How to Find the List of Fixed Hard Drive and Free Space on Server? We can use the following Stored Procedure to figure out the number of fixed drives (hard drive) a system has along with free... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 11 of 31](https://blog.sqlauthority.com/2011/07/11/sql-server-interview-questions-and-answers-frequently-asked-questions-day-11-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is Difference between Table Aliases and Column Aliases? Do they Affect Performance? Usually, when the name of the table or column is very long or complicated to write, aliases are used to refer them. e.g. SELECT VeryLongColumnName col1 FROM VeryLongTableName tab1 In the above example, col1 and tab1 are the column alias and table alias, respectively. They do not affect the performance at all. What is the difference... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 10 of 31](https://blog.sqlauthority.com/2011/07/10/sql-server-interview-questions-and-answers-frequently-asked-questions-day-10-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What Command do we Use to Rename a db, a Table and a Column? To Rename db sp_renamedb ‘oldname’ , ‘newname If someone is using db it will not accept sp_renmaedb. In that case, first bring db to single user mode using sp_dboptions. Use sp_renamedb to rename the database. Use sp_dboptions to bring the database to multi-user mode. e.g. USE MASTER; GO EXEC sp_dboption AdventureWorks, 'Single User', True GO... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 9 of 31](https://blog.sqlauthority.com/2011/07/09/sql-server-interview-questions-and-answers-frequently-asked-questions-day-9-of-31/): Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is CHECK Constraint? A CHECK constraint is used to limit the values that can be placed in a column. The check constraints are used to enforce domain integrity. (Read more here) What is NOT NULL Constraint? A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to enforce domain integrity, as the check constraints. (Read more here) What is the difference between UNION and UNION ALL? UNION The UNION... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 8 of 31](https://blog.sqlauthority.com/2011/07/08/sql-server-interview-questions-and-answers-frequently-asked-questions-day-8-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs Which Command using Query Analyzer will give you the Version of SQL Server and Operating System? SELECT SERVERPROPERTY('Edition') AS Edition, SERVERPROPERTY('ProductLevel') AS ProductLevel, SERVERPROPERTY('ProductVersion') AS ProductVersion GO (Read more here) What is an SQL Server Agent? The SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose... - [SQL SERVER - Introduction to expressor Datascript Modules](https://blog.sqlauthority.com/2011/07/08/sql-server-introduction-to-expressor-datascript-modules/): With the release of expressor 3.3, expressor software has added a significant new feature to the expressor Studio tool – the ability to easily extend functionality through the incorporation of reusable script files.  A developer using expressor Studio may write these scripts and add them to any number of projects, or you can integrate scripts written by other developers.  Let’s see how this works. Suppose you want to execute a one-to-many application in which each incoming record needs to be parsed into multiple output records.  For example, a record containing monthly data over a year period needs to be reworked so... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 7 of 31](https://blog.sqlauthority.com/2011/07/07/sql-server-interview-questions-and-answers-frequently-asked-questions-day-7-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What are Different Types of Locks? Shared Locks: Used for operations that do not change or update data (read-only operations), such as a SELECT statement. Update Locks: Used on resources that can be updated. It prevents a common form of deadlock that occurs when multiple sessions are reading, locking, and potentially updating resources later. Exclusive Locks: Used for data-modification operations, such as INSERT, UPDATE, or DELETE. It ensures that... - [Interview Questions and Answers - Frequently Asked Questions - Day 6 of 31](https://blog.sqlauthority.com/2011/07/06/sql-server-interview-questions-and-answers-frequently-asked-questions-day-6-of-31/): Please read the Introductory Post before continuing reading interview questions and answers. Some more questions are included in the blog. - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 5 of 31](https://blog.sqlauthority.com/2011/07/05/sql-server-interview-questions-and-answers-frequently-asked-questions-day-5-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is an Identity? Identity (or AutoNumber) is a column that automatically generates numeric values. A start and increment value can be set, but most DBAs leave these at 1. A GUID column also generates unique keys. Updated based on the comment of Aaron Bertrand. (Blog) What is DataWarehousing? Subject-oriented, which means that the data in the database is organized so that all the data elements relating to the... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 4 of 31](https://blog.sqlauthority.com/2011/07/04/sql-server-interview-questions-and-answers-frequently-asked-questions-day-4-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is the Difference between a Function and a Stored Procedure? UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section, whereas Stored procedures cannot be. UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables. Inline UDF’s can be thought of as views that take parameters and can be used in JOINs and other Rowset operations.... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 3 of 31](https://blog.sqlauthority.com/2011/07/03/sql-server-interview-questions-and-answers-frequently-asked-questions-day-3-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs What is a Stored Procedure? A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Day 2 of 31](https://blog.sqlauthority.com/2011/07/02/sql-server-interview-questions-and-answers-frequently-asked-questions-day-2-of-31/): Click here to get free chapters (PDF) in the mailbox Please read the Introductory Post before continue reading interview question and answers. List of all the Interview Questions and Answers Series blogs 1) General Questions on SQL SERVER What is RDBMS? Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Introduction - Day 1 of 31](https://blog.sqlauthority.com/2011/07/01/sql-server-interview-questions-and-answers-frequently-asked-questions-introduction-day-1-of-31/): Click here to get free chapters (PDF) in the mailbox List of all the Interview Questions and Answers Series blogs Posts covering interview questions and answers always make for interesting reading.  Some people like the subject for their helpful hints and thought provoking subject, and others dislike these posts because they feel it is nothing more than cheating.  I’d like to discuss the pros and cons of a Question and Answer format here. Interview Questions and Answers are Helpful Just like blog posts, books, and articles, interview Question and Answer discussions are learning material.  The popular Dummy’s books or Idiots Guides... - [SQL SERVER - Interview Questions and Answers - Frequently Asked Questions - Complete Downloadable List - Day 0 of 31](https://blog.sqlauthority.com/2011/07/01/sql-server-interview-questions-and-answers-frequently-asked-questions-complete-downloadable-list-day-0-of-31/): This blog post is running list of the blog posts in the series of Interview Questions and Answers. At the end of the 31st day of the month, a FREE PDF will be posted here which can be downloadable for offline review. SQL SERVER – Interview Questions and Answers – Frequently Asked Questions – Introduction – Day 1 of 31 In this very first blog post – various aspect of the interview questions and answers are discussed. Some people like the subject for their helpful hints and thought provoking subject, and others dislike these posts because they feel it is nothing more... - [SQL SERVER - Two Puzzles - Answer and Win USD 25 Gift Card](https://blog.sqlauthority.com/2011/06/30/sql-server-two-puzzles-answer-and-win-usd-25-gift-card/): Today I have two simple T-SQL Puzzle. You can answer them and win USD 25 Gift card. The gift card will be sent in email to winner. You will get choice of Gift Card brand based on your preference and country location. Puzzle 1: What will be the outcome and why? DECLARE @x REAL; SET @x = 9E-40 SELECT @x; The outcome here is obvious as I have used negative number in assignment. What is the reason behind the same? Puzzle 2: Why will be the outcome different from Puzzle 1: DECLARE @y REAL; SET @y = 9E+40 SELECT @y; The... - [SQL SERVER - Find Details for Statistics of Whole Database](https://blog.sqlauthority.com/2011/06/29/sql-server-find-details-for-statistics-of-whole-database-dmv-t-sql-script/): I was recently asked is there a single script which can provide all the necessary details about statistics for any database. - [SQLAuthority News - Monthly list of Puzzles and Solutions on SQLAuthority.com](https://blog.sqlauthority.com/2011/06/28/sqlauthority-news-monthly-list-of-puzzles-and-solutions-on-sqlauthority-com/): This month has been very interesting month for SQLAuthority.com we had multiple and various puzzles which everybody participated and lots of interesting conversation which we have shared. Let us start in latest puzzles and continue going down. There are few answers also posted on facebook as well. SQL SERVER – Puzzle Involving NULL – Resolve – Error – Operand data type void type is invalid for sum operator This puzzle involves NULL and throws an error. The challenge is to resolve the error. There are multiple ways to resolve this error. Readers has contributed various methods. Few of them even have supplied... - [SQL SERVER - Puzzle Involving NULL - Resolve - Error - Operand data type void type is invalid for sum operator](https://blog.sqlauthority.com/2011/06/27/sql-server-puzzle-involving-null-resolve-error-operand-data-type-void-type-is-invalid-for-sum-operator/): Today is Monday let us start this week with interesting puzzle. Yesterday I had also posted quick question here: SQL SERVER – T-SQL Scripts to Find Maximum between Two Numbers - [SQL SERVER - T-SQL Scripts to Find Maximum between Two Numbers](https://blog.sqlauthority.com/2011/06/26/sql-server-t-sql-scripts-to-find-maximum-between-two-numbers/): There are plenty of the things life one can make it simple. I really believe in the same. I was yesterday traveling for community related activity. On airport while returning I met a SQL Enthusiast. He asked me if there is any simple way to find maximum between two numbers in the SQL Server. I asked him back that what he really mean by Simple Way and requested him to demonstrate his code for finding maximum between two numbers. Here is his code: DECLARE @Value1 DECIMAL(5,2) = 9.22 DECLARE @Value2 DECIMAL(5,2) = 8.34 SELECT (0.5 * ((@Value1 + @Value2) + ABS(@Value1... - [SQLAuthority News - Download Whitepaper - SQL Server 2008 R2 Analysis Services Operations Guide](https://blog.sqlauthority.com/2011/06/25/sqlauthority-news-download-whitepaper-sql-server-2008-r2-analysis-services-operations-guide/): SQL Server Analysis Service (SSAS) has been always interesting subject for research. Analysis Services cubes are a very powerful tool in the hands of the business intelligence (BI) developer. They provide an easy way to expose even large data models directly to business users. Microsoft has published very informative white paper on Analysis Services Operations Guide. This white paper is authored by Thomas Kejser, John Sirmon, and Denny Lee. In this guide you will find information on how to test and run Microsoft SQL Server Analysis Services in SQL Server 2005, SQL Server 2008, and SQL Server 2008 R2 in a production... - [SQL SERVER - BI Quiz Hint - Performance Tuning Cubes - Hints](https://blog.sqlauthority.com/2011/06/24/sql-server-bi-quiz-hint-performance-tuning-cubes-hints/): I earlier wrote about SQL BI Quiz over here and here. - [SQLAuthority News - Ahmedabad Tech Ed On Road June 11, 2011 - A Grand Success of Community Tech Days](https://blog.sqlauthority.com/2011/06/23/sqlauthority-news-ahmedabad-tech-ed-on-road-june-11-2011-an-event-to-remember-a-grand-success-of-community-tech-days/): I am very excited to announce the huge success of the Microsoft Community Tech Days in Ahmedabad, on 11 June 2011. The turnout for this seminar was huge, and there was a great response from the audience. In fact, the AMA where the conference was held can seat 275 people – but there were over 50 people standing, the event coordinators had to find 150 more chairs, and we even had to turn away 30 people at the door because there was just no more room. This means that there were over 500 attendees! - [SQL SERVER - SSAS - Multidimensional Space Terms and Explanation](https://blog.sqlauthority.com/2011/06/22/sql-server-ssas-multidimensional-space-terms-and-explanation/): I was presenting on SQL Server session at one of the Tech Ed On Road event in India. I was asked very interesting question during ‘Stump the Speaker‘ session. I am sharing the same with all of you over here. Question: Can you tell me in simple words what is dimension, member and other terms of multidimensional space? There is no simple example for it. This is extreme fundamental question if you know Analysis Service. Those who have no exposure to the same and have not yet started on this subject, may find it a bit difficult. I really liked his... - [SQL SERVER - List of Article on Expressor Data Integration Platform](https://blog.sqlauthority.com/2011/06/22/sql-server-list-of-article-on-expressor-data-integration-platform/): The ability to transform data into meaningful and actionable information is the most important information in current business world. In this fast growing and changing business needs effective data integration is single most important thing in making proper decision making. I have been following expressor software since November 2010, when I met expressor team in Seattle. Here are my posts on their innovative data integration platform and expressor Studio, a free desktop ETL tool: 4 Tips for ETL Software IDE Developers Introduction to Adaptive ETL Tool – How adaptive is your ETL? Sharing your ETL Resources Across Applications with Ease expressor Studio Includes Powerful... - [SQL SERVER - Solution - Generating Zero Without using Any Numbers in T-SQL](https://blog.sqlauthority.com/2011/06/21/sql-server-solution-generating-zero-without-using-any-numbers-in-t-sql/): SQL Server MVP and my friend Madhivanan has asked very interesting question on his blog regarding How to Generate Zero without using Any Numbers in T-SQL. He has demonstrated various methods how one can generate Zero. When I posted note regarding how one he has generated Zero without using number in my blog post for Free Online Training, blog readers have come up with few very interesting answers. I really found them very interesting and here I am listing them with due credit. Special mention to Andery.ca as the answer Andery provided is the one, I myself come up with after... - [SQLAuthority News - Job Interviewing the Right Way (and for the Right Reasons) - Guest Post by Feodor Georgiev](https://blog.sqlauthority.com/2011/06/20/sqlauthority-news-job-interviewing-the-right-way-and-for-the-right-reasons-guest-post-by-feodor-georgiev/): Feodor Georgiev is a SQL Server database specialist with extensive experience of thinking both within and outside the box. He has wide experience of different systems and solutions in the fields of architecture, scalability, performance, etc. Feodor has experience with SQL Server 2000 and later versions, and is certified in SQL Server 2008. Feodor has written excellent article on Job Interviewing the Right Way. Here is his article in his own language. A while back I was thinking to start a blog post series on interviewing and employing IT personnel. At that time I had just read the ‘Smart and gets... - [SQL SERVER - INSERT TOP (N) INTO Table - Using Top with INSERT](https://blog.sqlauthority.com/2010/02/27/sql-server-insert-top-n-into-table-using-top-with-insert/): During my recent training at one of the clients, I was asked regarding the enhancement in TOP clause. When I demonstrated my script regarding how TOP works along with INSERT, one of the attendees suggested that I should also write about this script on my blog. Let me share this with all of you and do let me know what you think about this. Note that there are two different techniques to limit the insertion of rows into the table. Method 1: INSERT INTO TABLE … SELECT TOP (N) Cols… FROM Table1 Method 2: INSERT TOP(N) INTO TABLE … SELECT Cols…... - [SQLAuthority News - Keeping Your Ducks in a Row](https://blog.sqlauthority.com/2010/02/26/sqlauthority-news-keeping-your-ducks-in-a-row/): Last year during my visit to SQLAuthority News – SQL PASS Summit, Seattle 2009 – Day 2 I have received ducks from the event. Well during the same event I had learned from Jonathan Kehayias the saying of ‘Keeping Your Ducks in a Row‘. The most popular theory suggests that “ducks in a row” came from the world of sports, specifically bowling. Early bowling pins were often shorter and thicker than modern pins, which lead to the nickname ducks. Before the advent of automatic resetting machines, these “duck pins” would be manually put back into place between bowling rounds. Therefore, having... - [SQLAuthority News - MUGH - Microsoft User Group Hyderabad - Feb 2, 2010 Session Review](https://blog.sqlauthority.com/2010/02/25/sqlauthority-news-mugh-microsoft-user-group-hyderabad-feb-2-2010-session-review/): Earlier this month, I was very fortunate to visit Microsoft User Group Hyderabad lead by Hima Vindu Vejella. Hima is a very enthusiastic leader and kind person. I had a wonderful time meeting her as well her husband during my visit to Hyderabad. I had presented session on Index, which was well received. Brief information on this session is given below: The Other Side of SQL Server Index: Advanced Solutions to Ancient Problem SQL Server Index is very powerful tool and when in hand of the less skilled expert, the same tool can pose a danger to its performance and kill... - [SQL SERVER - Introduction to Rollup Clause](https://blog.sqlauthority.com/2010/02/24/sql-server-introduction-to-rollup-clause/): In this article we will go over basic understanding of Rollup clause in SQL Server. ROLLUP clause is used to do aggregate operation on multiple levels in hierarchy. Let us understand how it works by using an example. - [Data Mining Algorithms (Analysis Services - Data Mining)](https://blog.sqlauthority.com/2010/02/23/sqlauthority-news-links-to-book-on-line-data-mining-algorithms-analysis-services-data-mining/): I quite often receive requests for the Data Mining Algorithms details. Book Online has wonderful resources for the same. I suggest to read them here. - [SQLAuthority News - Blog Subscription and Comments RSS](https://blog.sqlauthority.com/2010/02/22/sqlauthority-news-blog-subscription-and-comments-rss/): Quite often I get email where many readers ask me how to get email from SQLAuthority.com blog. Today very quickly I will go over few standard practices of this blog using you can stay connected with SQLAuthority.com First the most important is search: I received hundreds of emails and hundreds of comments every day. I try to answer each of them but if you have any urgent question I strongly suggest to search in my custom SQLAuthority.com Search. It searches in all the blogs as well in the comments. Search @ SQLAuthority.com If you want to stay connected with SQLAuthority.com using... - [SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table)](https://blog.sqlauthority.com/2010/02/21/sql-server-if-existsselect-null-from-table-vs-if-existsselect-1-from-table/): Few days ago I wrote article about SQL SERVER – Stored Procedure Optimization Tips – Best Practices. I received lots of comments on particular blog article. In fact, almost all the comments are very interesting. If you have not read all the comments, I strongly suggest to read them. Click here to read the comments. The most interesting comment conversation is among Divya, Brian and Marko. Please read the comments of Marko for sure. It is the comment, which has triggered this post. Comments by Divya I have seen in one of the blogs to use EXISTS like IF EXISTS(Select null... - [SQL SERVER - Recompile Stored Procedure at Run Time](https://blog.sqlauthority.com/2010/02/20/sql-server-recompile-stored-procedure-at-run-time/): I recently received an email from reader after reading my previous article on SQL SERVER – Plan Recompilation and Reduce Recompilation – Performance Tuning regarding how to recompile any stored procedure at run time. There are multiple ways to do this. If you want your stored procedure to always recompile at run time, you can add the keyword RECOMPILE when you create the stored procedure. Additionally, if the stored procedure has to be recompiled at only one time, in that case, you can add RECOMPILE word one time only and run the SP as well. Let us go over these two options. - [SQLAuthority News - Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1](https://blog.sqlauthority.com/2010/02/19/sqlauthority-news-microsoft-sql-server-migration-assistant-2008-for-mysql-v1-0-ctp1-2/): Microsoft SQL Server Migration Assistant (SSMA) 2008 is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL to SQL Server 2008 and SQL Azure. SSMA 2008 for MySQL v1.0 CTP1 provides an assessment of migration efforts as well as automates schema and data migration. Download Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1 Download Microsoft SQL Server Migration Assistant 2005 for MySQL v1.0 CTP1 Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Plan Recompilation and Reduce Recompilation - Performance Tuning](https://blog.sqlauthority.com/2010/02/18/sql-server-plan-recompilation-and-reduce-recompilation-performance-tuning/): Recompilation process is same as compilation and degrades server performance. In SQL Server 2000 and earlier versions, this was a serious issue but in SQL server 2005, the severity of this issue has been significantly reduced by introducing a new feature called Statement-level recompilation. When SQL Server 2005 recompiles stored procedures, only the statement that causes recompilation is compiled, rather than the entire procedure. Recompilation occurs because of following reason: On schema change of objects. Adding or dropping column to/from a table or view Adding or dropping constraints, defaults, or rules to or from a table. Adding or dropping an index... - [SQLAuthority News - SQL Server Technical Article - The Data Loading Performance Guide](https://blog.sqlauthority.com/2010/02/17/sqlauthority-news-sql-server-technical-article-the-data-loading-performance-guide/): Note: SQL Server Technical Article – The Data Loading Performance Guide by Microsoft The white paper describes load strategies for achieving high-speed data modifications of a Microsoft SQL Server database. “Bulk Load Methods” and “Other Minimally Logged and Metadata Operations” provide an overview of two key and interrelated concepts for high-speed data loading: bulk loading and metadata operations. After this background knowledge, white paper describe how these methods can be used to solve customer scenarios. Script examples illustrating common design pattern are found in “Solving Typical Scenarios with Bulk Loading” Special consideration must be taken when you need to load and... - [SQL SERVER - Stored Procedure Optimization Tips - Best Practices](https://blog.sqlauthority.com/2010/02/16/sql-server-stored-procedure-optimization-tips-best-practices/): We will go over how to optimize Stored Procedure with making simple changes in the code. Please note there are many more other tips, which we will cover in future articles. - [SQL SERVER - Difference Between Update Lock and Exclusive Lock](https://blog.sqlauthority.com/2010/02/15/sql-server-difference-between-update-lock-and-exclusive-lock/): I have often got this question on this blog as well in different SQL Training. What is the difference between Update Lock and Exclusive Lock? When Exclusive Lock is on any processes no other lock can be placed on that row or table. Every other process have to wait till Exclusive Lock is complete its tasks. Update Lock is kind of Exclusive Lock except it can be placed on the row which already have Shared Lock on it. Update Lock reads the data of row which has Shared Lock, as soon as Update Lock is ready to change the data it... - [SQLAuthority News - SuperFlow for Creating SRS Report Models in Configuration Manager 2007](https://blog.sqlauthority.com/2010/02/14/sqlauthority-news-superflow-for-creating-srs-report-models-in-configuration-manager-2007/): Note : Download SuperFlow for Creating SRS Report Models in Configuration Manager 2007 by Microsoft The SuperFlow interactive content model provides a structured and interactive interface for viewing documentation. Each SuperFlow includes comprehensive information about a specific dataflow, workflow, or process. Depending on the focus of the SuperFlow, you will find overview information, steps that include detailed information, procedures, sample log entries, best practices, real-world scenarios, troubleshooting information, security information, animations, or other information. Each SuperFlow also includes links to relevant resources, such as Web sites or local files that are copied to your computer when you install the SuperFlow. The... - [SQLAuthority News - Download SQL Server 2008 Express Datasheet](https://blog.sqlauthority.com/2010/02/13/sqlauthority-news-download-sql-server-2008-express-datasheet/): Microsoft® SQL Server® 2008 Express is a free edition of SQL Server ideal for learning, developing and powering desktop and small server applications and for redistribution by ISVs. Download SQL Server 2008 Express Datasheet Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad Community Tech Days - Jan 30, 2010 - Huge Success](https://blog.sqlauthority.com/2010/02/12/sqlauthority-news-ahmedabad-community-tech-days-jan-30-2010-huge-success/): Ahmedabad Community Tech Days was held on Jan 30, 2010 at Bhaikaka Hall. This event was very received well and attended by a large number of technology enthusiasts and a number of TOP speakers from various technologies. During this event Pinal Dave (myself) and Jacob Sebastian had decided to do something different as the theme was innovation and efficiency. I presented session on SQL Azure, and Jacob presented session on SQL Server R2. This was a bit different than our usual relational SQL Server Presentation. This event was very well received, and we had received great feedback from the attendees. In... - [SQL SERVER - ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE](https://blog.sqlauthority.com/2010/02/11/sql-server-alter-database-dbname-set-single_user-with-rollback-immediate/): I have recently been conducting lots of training on SQL Server technology. During these trainings, I quite often create new databases and drop them as well. Many times, I am not able to drop the database as one of my instances might be using the database. As I am working on my laptop and very confident regarding dropping the database, I always take my database in single user and drop it immediately. ALTER DATABASE [YourDbName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; The above query will rollback any transaction which is running on that database and brings SQL Server database in a single... - [SQLAuthority News - Converting a Delimited String of Values into Columns](https://blog.sqlauthority.com/2010/02/10/sqlauthority-news-converting-a-delimited-string-of-values-into-columns/): This blog post is about two great bloggers and their excellent series of blog posts. It was quite unusual to see two bloggers posting articles that are supporting each other and constantly improving the articles to the next level. Two blogs which I am going to mention here are as follows: SELECT Blog FROM Brad.Schulz CROSS APPLY SQL.Server() – Brad Schulz and Demystifying SQL Server – Adam Haines. Before continuing this blog post, I suggest you all to bookmark these blogs for future reference. The whole thing started when Adam tried to answer the question “How to transform a delimited values... - [SQL SERVER - Brief Note about StreamInsight - What is StreamInsight](https://blog.sqlauthority.com/2010/02/09/sql-server-brief-note-about-streaminsight-what-is-streaminsight/): StreamInsight is a new event processing platform introduced in upcoming version SQL Server 2008 R2. Similar to other components such as SSIS, SSAS or Service Broker, it also needs to be installed along with the SQL Server. Up to SQL Server 2005, Microsoft’s main focus on SQL Server was to build a platform to efficiently store, manage, and retrieve data. However, now, Microsoft enhanced SQL Server to accept, monitor, and respond to complex and high number of events in near zero latency. For this, Microsoft introduced StreamInsight using the following approaches: Continuous and incremental processing of unending sequences of events. Lightweight... - [SQL SERVER - Find the Size of Database File - Find the Size of Log File](https://blog.sqlauthority.com/2010/02/08/sql-server-find-the-size-of-database-file-find-the-size-of-log-file/): I encountered the situation recently where I needed to find the size of the log file. When I tried to find the script by using Search@SQLAuthority.com I was not able to find the script at all. Here is the script, if you remove the WHERE condition you will find the result for all the databases. SELECT DB_NAME(database_id) AS DatabaseName, Name AS Logical_Name, Physical_Name, (size*8)/1024 SizeMB FROM sys.master_files WHERE DB_NAME(database_id) = 'AdventureWorks' GO Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Server 2008 R2 Update for Developers Training Kit](https://blog.sqlauthority.com/2010/02/07/sql-server-sql-server-2008-r2-update-for-developers-training-kit/): Note:   Download SQL Server 2008 R2 Update for Developers Training Kit by Microsoft SQL Server 2008 R2 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2008. The SQL Server 2008 R2 Update for Developers Training Kit is ideal for developers who want to understand how to take advantage of the key improvements introduced in SQL Server 2008 and SQL Server 2008 R2 in their applications, as well as for developers who are new to SQL Server. The training kit is brought to you by Microsoft Developer and Platform Evangelism. Download SQL Server... - [SQLAuthority News - Presenting Two Sessions at TechED Sri Lanka](https://blog.sqlauthority.com/2010/02/06/sqlauthority-news-presenting-two-sessions-at-teched-sri-lanka/): I will be presenting following two sessions at TechEd Sri Lanka this week. I am very excited as this is very first time I will be presenting in TechEd event. I have previously presented many sessions but I have never presented at this premier Microsoft Event. I will be presenting on following two subject. The history of the Log: Change Data Capture (CDC) Pinal Dave on 8-Feb-10 at 02.00 – 03.15 Learn to capture the history of data using CDC. An age old method of writing queries and triggers to capture change in database table is replaced with much powerful asynchronous... - [SQL SERVER - Stream Aggregate Showplan Operator - Reason of Compute Scalar before Stream Aggregate](https://blog.sqlauthority.com/2010/02/05/sql-server-stream-aggregate-showplan-operator-reason-of-compute-scalar-before-stream-aggregate/): I keep a check on the questions received from my readers; when any question crosses my threshold, I surely try to blog about it online. Stream Aggregate is a quite commonly encountered showplan operator. I have often found it in very simple COUNT(*) operation’s execution plan. If you like to read an official note on the subject, you can read the same on Book Online over here. The Stream Aggregate operator groups rows by one or more columns and then calculates one or more aggregate expressions returned by the query. Running the following query will give you Stream Aggregate Operator in... - [SQL SERVER - Get the List of Object Dependencies - sp_depends and information_schema.routines](https://blog.sqlauthority.com/2010/02/04/sql-server-get-the-list-of-object-dependencies-sp_depends-and-information_schema-routines-and-sys-dm_sql_referencing_entities/): Recently, I read a question on my friend‘s SQL site regarding the following: sp_depends does not give appropriate results whereas information_schema. routines do give proper answers. - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010 - Review Part Fun](https://blog.sqlauthority.com/2010/02/03/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010-review-part-fun/): MVP Open Day South Asia was held in Hyderabad from Jan 20, 2010 to Jan 23, 2010. This event was a fun-filled event as well as an educational one. The event was held at Microsoft IDC at Hyderabad, the largest Microsoft Development location after Redmond. I had great time meeting my friends and some of the renowned experts from all over the South Asia. The whole event started with networking with other MVPs as well as Product Group members. Besides lots of learning and meeting experts, this event was filled with fun too. The best thing for me was that I... - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010 - Review Part Business](https://blog.sqlauthority.com/2010/02/02/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010-review-part-business/): MVP Open Day South Asia was held in Hyderabad from Jan 20, 2010 to Jan 23, 2010. This event was a fun-filled as well as an educational event. This event was held at Microsoft IDC at Hyderabad – the largest Microsoft Development location after Redmond. I had a great time meeting my friends and some of the renowned experts from all over the South Asia. The whole event started with networking with other MVPs as well with Product Group members. - [SQL SERVER - Question - How to Convert Hex to Decimal](https://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/): In one of the recent projects, I realize the bottleneck of the query was an inline function which was converting Hex to Decimal. I optimized the inline function and reduced the query running time to one-tenth of the original running time. Later, I was eager to find out the script my blog readers might be using for hex to decimal conversion. Please leave your comments here and I will consider all the valid answers and publish with due credit to the author in one of the future posts. If the script you have posted here is not your original script, I... - [SQL SERVER - Location of Resource Database in SQL Server Editions](https://blog.sqlauthority.com/2010/01/31/sql-server-location-of-resource-database-in-sql-server-editions/): While working on a project of database backup and recovery, I found out that my client was not aware of the resource database at all. Location of Resource. - [SQL SERVER - Several Readers Questions and Readers Answers](https://blog.sqlauthority.com/2010/01/30/sql-server-several-readers-questions-and-readers-answers/): I often get questions on blog and many times I even get answers from readers as well. This article is collection of few of the questions and answers by readers of this blog. Q. How the records of a table can be scripted in INSERT INTO statements? A. In SQL Server 2008 : Right click Database > Tasks > Generate Scripts > In the wizard on Choose Script Option page, set Script Data option to True and complete the wizard.For SQL 2005 or earlier versions, use Database Publishing Wizard. For more details about Database Publishing wizard, please visit the blog https://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/... - [SQLAuthority News - Leadership Quotes and Inspiration](https://blog.sqlauthority.com/2010/01/29/sqlauthority-news-leadership-quotes-inspiration/): There is a big difference between leader and manager. There are plenty of interesting details written on this subject on the internet. In a recent presentation on leadership of one of the organizations I have presented a few of the quotes on the leadership subject to them. The leadership quotes were very much appreciated by the team so I am writing them over here. - [SQLAuthority News - Community Tech Days - Jan 30, 2010 - Must Attend](https://blog.sqlauthority.com/2010/01/28/sqlauthority-news-community-tech-days-jan-30-2010-must-attend/): Attend deep technology sessions for developers and IT professionals, as some of the best-known names come to your city to share their insights in topics ranging from .Net, Visual studio, Silverlight, to Windows and SQL Server. Build connections with Microsoft experts and community members and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. In Ahmedabad this event will happen on January 30, 2010. Just like last event we are expecting this time as well the event will have astonishing success and huge response. We will have five tech sessions back to back... - [SQLAuthority News - SQL Server 2008 R2 - Release Date in May 2010](https://blog.sqlauthority.com/2010/01/27/sqlauthority-news-sql-server-2008-r2-release-date-in-may-2010/): Microsoft has announced that SQL Server 2008 R2 will be available by May 2010. Its CTP (Community Technology Preview) version was already available from August 2009. It is still available for download. - [SQLAuthority News - Download White Paper - Troubleshooting Performance Problems in SQL Server 2008](https://blog.sqlauthority.com/2010/01/26/sqlauthority-news-download-white-paper-troubleshooting-performance-problems-in-sql-server-2008/): Troubleshooting Performance Problems in SQL Server 2008 SQL Server Technical Article Writers: Sunil Agarwal, Boris Baryshnikov, Keith Elmore, Juergen Thomas, Kun Cheng, Burzin Patel Technical Reviewers: Jerome Halmans, Fabricio Voznika, George Reynya Published: March 2009 It’s not uncommon to experience the occasional slowdown of a database running the Microsoft SQL Server database software. The reasons can range from a poorly designed database to a system that is improperly configured for the workload. As an administrator, you want to proactively prevent or minimize problems; if they occur, you want to diagnose the cause and take corrective actions to fix the problem whenever... - [SQL SERVER - Find Statistics Update Date - Update Statistics](https://blog.sqlauthority.com/2010/01/25/sql-server-find-statistics-update-date-update-statistics/): Statistics are one of the most important factors of a database as it contains information about how data is distributed in the database objects (tables, indexes etc). It is quite common to listen people talking about not optimal plan and expired statistics. Quite often I have heard the suggestion to update the statistics if query is not optimal. Please note that there are many other factors for query to not perform well; expired statistics are one of them for sure. If you want to know when your statistics was last updated, you can run the following query. USE AdventureWorks GO SELECT... - [SQLAuthority News - Download Sample Database for Microsoft SQL Server](https://blog.sqlauthority.com/2010/01/24/sqlauthority-news-download-sample-databases-for-microsoft-sql-server-2008-december-2009-samples-refresh-4/): This post is a response to one of the most asked questions where to get Sample Database for SQL Server 2008. The name of the new sample database is AdventureWorks.  - [SQLAuthority News - Remote BLOB Store Provider Library Implementation Specification](https://blog.sqlauthority.com/2010/01/23/sqlauthority-news-remote-blob-store-provider-library-implementation-specification/): Remote BLOB Store Provider Library Implementation Specification logo-sql08.gif SQL Server Technical Article Writers: Kevin Farlee, Pradeep Madhavarapu Technical Reviewer: Pradeep Madhavarapu, Michael Warmington Published: August 2008 Remote BLOB Store (RBS) is designed to move the storage of large binary data (BLOBs) from database servers to commodity storage solutions. With RBS, BLOB data is stored in storage solutions such as Content Addressable Stores (CAS), commodity hardware with data integrity and fault-tolerance systems, or mega service storage solutions like MSN Blue. A reference to the BLOB is stored in the database. An application stores and accesses BLOB data by calling into the RBS... - [SQL SERVER - Execution Plan - Estimated I/O Cost - Estimated CPU Cost - No Unit](https://blog.sqlauthority.com/2010/01/22/sql-server-execution-plan-estimated-io-cost-estimated-cpu-cost-no-unit/): During the SQL Server Optimization training, I enjoy teaching the Execution Plan. I am always sure that questions related to the estimated cost will be raised by attendees. Following are some common questions related to costs: - [SQLAuthority News - Community Tech Days - Jan 30, 2010 - Event Announcement](https://blog.sqlauthority.com/2010/01/21/sqlauthority-news-community-tech-days-jan-30-2010-event-announcement/): Attend deep technology sessions for developers and IT professionals, as some of the best-known names come to your city to share their insights in topics ranging from .Net, Visual studio, Silverlight, to Windows and SQL Server. Build connections with Microsoft experts and community members and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. In Ahmedabad this event will happen on January 30, 2010. Just like last event we are expecting this time as well the event will have astonishing success and huge response. We will have five tech sessions back to back... - [SQLAuthority News - MVP Open Day South Asia - Jan 20, 2010 - Jan 23, 2010](https://blog.sqlauthority.com/2010/01/20/sqlauthority-news-mvp-open-day-south-asia-jan-20-2010-jan-23-2010/): Microsoft has organized an Open Day for all MVP the South Asia MVP.  The MVP Open Day is a three day invitation-only event that is hosted at MSIDC. The event will feature a roster of keynotes and deep dive technical sessions delivered by experts from the product group. Microsoft India Development Center (MSIDC) is one of Microsoft’s largest development centers outside the headquarters in Redmond. The MVP Open Day is an exclusive event for Asia Pacific & Greater China MVPs. MVP is exceptional technical community leader. Microsoft MVP site further explains MVP as “At Microsoft, we believe that by participating in technical... - [SQL SERVER - SSMS Query Command(s) completed successfully without ANY Results](https://blog.sqlauthority.com/2010/01/19/sql-server-ssms-query-commands-completed-successfully-without-any-results/): Yesterday night, I received a phone call from one of my friends with whom I used to work in USA. I was very pleased to receive this call from my old friend after 2 years, but the situation was not good on his side. He said that whatever query he runs, he just receives a message like Query Command(s) completed successfully without any result. However, when he opened a new window, it worked fine. He said he could not figure out the reason for the same and his manager who was standing nearby asked him to find out the reason and... - [SQL SERVER - DMV Error: FIX: Error: Msg 297, Level 16 The user does not have permission to perform this action](https://blog.sqlauthority.com/2010/01/18/sql-server-dmv-error-fix-error-msg-297-level-16-the-user-does-not-have-permission-to-perform-this-action/): I just received an email from one of the readers asking for help with error he encountered while attempting to run DMV. Msg 297, Level 16, State 1, Line 1 The user does not have permission to perform this action. Fix/Solution/Workaround: The above error is usually generated when the user who is trying to run the DMV does not have access to the run the DMV. I suggested him to contact his server admin to grant him VIEW SERVER STATE permissions so that he can run the DMV. Example: If user does not have VIEW SERVER STATE permissions when he runs... - [SQL SERVER - Get Server Version and Additional Info](https://blog.sqlauthority.com/2010/01/17/sql-server-get-server-version-and-additional-info/): It is quite common to get the SQL Server version details from following query. SELECT @@VERSION VersionInfo GO Recently I have been using following SP to get version details as it also provides me few more information about the server where the SQL Server is installed. EXEC xp_msver GO Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] I like to use the second one but again that is my preference. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download Windows Azure Platform Training Kit - December Update](https://blog.sqlauthority.com/2010/01/16/sqlauthority-news-download-windows-azure-platform-training-kit-december-update/): Note :  Download Windows Azure Platform Training Kit – December Update by Microsoft I wanted to read some good SQL Azure related to documentation, I tried to do searching online. While searching I landed over Windows Azure Platform Training Kit. This contains lots of SQL Server related content.I downloaded it and started to explore, I suggest if you are interested in Azure Platform you download it as well. The Azure Services Training Kit includes a comprehensive set of technical content including hands-on labs, presentations, and demos that are designed to help you learn how to use the Windows Azure platform including:... - [SQL SERVER - Initializing a Merge Subscription Without a Snapshot](https://blog.sqlauthority.com/2010/01/15/sql-server-initializing-a-merge-subscription-without-a-snapshot/): During recent course of Disaster Recovery and Performance Tuning, I had very interesting conversation with students regarding Initializing a Merge Subscription Without a Snapshot and Initializing a Transactional Subscription Without a Snapshot. After the discussion when we were looking at MSDN pages one thing caught my notice was the note on the top of the MSDN page regarding future support of the feature for Initializing a Merge Subscription Without a Snapshot. In the book on line on the subject Initializing a Merge Subscription Without a Snapshot it suggests that this feature will be deprecated in future, whereas there is no such... - [SQLAuthority News - Vote for SQL Server 2005 Service Pack 4 - Vote for SQL Server 2008 Service Pack 2](https://blog.sqlauthority.com/2010/01/15/sqlauthority-news-vote-for-sql-server-2005-service-pack-4-vote-for-sql-server-2008-service-pack-2/): It has been long time since Microsoft has released SQL Server 2005 SP3 and SQL Server 2008 SP1. It is the time when the new SPs should be released. SQL Server 2005 Service Pack 4 SQL Server 2008 Service Pack 2 Many thanks to Steve Jones of SQLServerCentral.com for this excellent initiative. I voted there, have you voted? Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Find Busiest Database](https://blog.sqlauthority.com/2010/01/14/sql-server-find-busiest-database/): In my recent training I was asked to how to find which is the busiest database in any SQL Server Instance. What he really meant by this is which database was doing lots of read and write operation. To find the answer to this question I decided to look into the DMV which contains all the details of the executed query. From the DMV sys.dm_exec_query_stats I found three most important columns to determine busiest database. DMV sys.dm_exec_query_stats contained columns total_logical_reads, total_logical_writes, sql_handle. Column sql_handle can help to to determine the original query by CROSS JOINing DMF sys.dm_exec_sql_text. From DMF sys.dm_exec_sql_text Database... - [SQLAuthority News - SQL Server Migration QuickStart](https://blog.sqlauthority.com/2010/01/13/sqlauthority-news-sql-server-migration-quickstart/): The SQL Server Migration QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to help you get details about how to approach your customers who want to improve the return on investment from their data platforms by migrating to SQL Server from their existing Oracle or Sybase platforms. SQL Server Migration QuickStart Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fragmentation - Detect Fragmentation and Eliminate Fragmentation](https://blog.sqlauthority.com/2010/01/12/sql-server-fragmentation-detect-fragmentation-and-eliminate-fragmentation/): Q. What is Fragmentation? How to detect fragmentation and how to eliminate it? A. Storing data non-contiguously on disk is known as fragmentation. Before learning to eliminate fragmentation, you should have a clear understanding of the types of fragmentation. We can classify fragmentation into two types: Internal Fragmentation: When records are stored non-contiguously inside the page, then it is called internal fragmentation. In other words, internal fragmentation is said to occur if there is unused space between records in a page. This fragmentation occurs through the process of data modifications (INSERT, UPDATE, and DELETE statements) that are made against the table... - [SQL SERVER - The server network address "TCP://SQLServer:5023" can not be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418)](https://blog.sqlauthority.com/2010/01/11/the-server-network-address-tcpsqlserver5023-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-that-the-ports-for-the-local-and-remote-endpoints-are-operational-microso/): While doing SQL Mirroring, we receive the following as the most common error: The server network address “TCP://SQLServer:5023” cannot be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418) The solution to the above problem is very simple and as follows. Fix/WorkAround/Solution: Try all the suggestions one by one. Suggestion 1: Make sure that on Mirror Server the database is restored with NO RECOVERY option (This is the most common problem). Suggestion 2: Make sure that from Principal the latest LOG backup is... - [SQLAuthority News - Download - Microsoft Sync Framework Power Pack for SQL Azure November CTP (32-bit)](https://blog.sqlauthority.com/2010/01/10/sqlauthority-news-download-microsoft-sync-framework-power-pack-for-sql-azure-november-ctp-32-bit/): This release features the SQL Azure provider for Microsoft Sync Framework, a plug-in for Visual Studio 2008 Professional SP1 and the tool SQL Azure Data Sync Tool for SQL Server, all of which simplify using Sync Framework and SQL Azure together. Download Microsoft Sync Framework Power Pack for SQL Azure November CTP (32-bit) Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1](https://blog.sqlauthority.com/2010/01/09/sqlauthority-news-microsoft-sql-server-migration-assistant-2008-for-mysql-v1-0-ctp1/): Microsoft SQL Server Migration Assistant (SSMA) 2008 is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL to SQL Server 2008 and SQL Azure. Download Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1 Abstract courtesy : Microsoft Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Ahmedabad - Gandhinagar SQL Server User Group Meet - Dec 19, 2009](https://blog.sqlauthority.com/2010/01/08/sqlauthority-news-ahmedabad-gandhinagar-sql-server-user-group-meet-dec-19-2009/): Just like every month Ahmedabad and Gandhinagar SQL Server User Group meeting was held on Dec 19, 2009, at Ahmedabad. The interactive meeting was huge success as we had wonderful audience. We had three speakers this time. Tejas Shah talked about “Write CROSS TAB Query with PIVOT”. Tejas is an excellent SQL Expert and a very talented individual. It gives me great pleasure when I see any UG member who updates himself to next level. Tejas has earlier presented many sessions at UG, but this was one of the best sessions. He started with a very basic example and then took... - [SQLAuthority News - Webcasts - Resources for IT Managers and their Teams](https://blog.sqlauthority.com/2010/01/07/sqlauthority-news-webcasts-resources-for-it-managers-and-their-teams/): Pinal Dave and Jacob Sebastian are both SQL Server MVP are doing webcasts for IT Managers and their Teams. Join us for a 4 series webcast as follows: Part 1: Infrastructure and Resource Management for Business Intelligence – Jan 7 Part 2: BI on your desktop – End to end BI solution from MS – Jan 28 Part 3: IT Managers and Mission Critical Data – What, Why, When and How to manage – Feb 4 Part 4: Understanding security and compliance for Enterprise – Feb 11 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON - A Transactional Behavior](https://blog.sqlauthority.com/2010/01/06/sql-server-unique-nonclustered-index-creation-with-ignore_dup_key-on-a-transactional-behavior/): Earlier, I had written on SQL SERVER – Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON, and I received a comment regarding when this option can be useful. On the same day, I met Jacob Sebastian—my close friend and SQL Server MVP, I discussed this question with him. During our discussion, we came up with following example. When we have situation where we are dealing with INSERT and TRANSACTION, we can see this feature in action. Let us consider an example where we have two tables. One table has all the data and the second table has partial data. If you... - [SQL SERVER - SQL Server RDL Specification](https://blog.sqlauthority.com/2010/01/05/sql-server-sql-server-rdl-specification/): Report Definition Language (RDL) is an XML-based schema for defining reports. The goal of RDL is to promote the interoperability of commercial reporting products by defining a common schema that allows interchange of report definitions. To encourage interoperability, RDL includes the notion of compliance levels that products may choose to support. Download the RDL Specifications for SQL Server by clicking the links below. RDL Specification for SQL Server 2008 (.xps format) RDL Specification for SQL Server 2008 (.pdf format) RDL Specification for SQL Server 2005 (.pdf format) RDL Specification for SQL Server 2000 (.pdf format) Abstract courtesy : Microsoft Reference: Pinal... - [SQL SERVER - Fix: Error: 262 : SHOWPLAN permission denied in database](https://blog.sqlauthority.com/2010/01/05/sql-server-fix-error-262-showplan-permission-denied-in-database/): During one of my recent training class when I asked students to check the execution plan using (can be enabled using CTRL+M), they received error as following. Msg 262, Level 14, State 4, Line 1 SHOWPLAN permission denied in database ‘AdventureWorks’. - [SQL SERVER - Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON](https://blog.sqlauthority.com/2010/01/04/sql-server-unique-nonclustered-index-creation-with-ignore_dup_key-on/): In one of my recent training course, I was asked question regarding what is the importance of setting IGNORE_DUP_KEY = ON when creating unique nonclustered index. Here is the short answer: When nonclustered index is created without any option the default option is IGNORE_DUP_KEY = OFF, which means when duplicate values are inserted it throws an error regarding duplicate value. If option is set with syntaxIGNORE_DUP_KEY = ON when duplicate values are inserted it does not thrown an error but just displays warning. Let us try to understand this with example. Option 1: IGNORE_DUP_KEY = OFF Option 2: IGNORE_DUP_KEY = ON... - [SQLAuthority News - TechDays Session at Infosys Mysore 2009 - Change Data Capture and PowerPivot](https://blog.sqlauthority.com/2010/01/03/sqlauthority-news-techdays-session-at-infosys-mysore-2009-change-data-capture-and-powerpivot/): It has been a great pleasure to visit Infosys Mysore for an MSDN session. I had previously visited Infosys Bangalore for Technical session. Please read the details of earlier visit SQLAuthority News – Notes from TechDays 2009 at Infosys, Bangalore. This event was held on Dec 10, 2009. I have been recently presenting the subject of Change Data Capture; it has been great fun as it is a very interesting subject that really captures your attention. It was a well-received session that lasted for nearly 1.5 hours instead of regular 30 min. The smart crowd at Infosys received the subject very... - [SQL SERVER - Find Location of Data File Using T-SQL](https://blog.sqlauthority.com/2010/01/02/sql-server-find-location-of-data-file-using-t-sql/): While preparing for the training course of Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning, I needed to find out where my database files are stored on my hard drive. It is when following script came in handy to find the location of the data file using T-SQL.  - [SQL SERVER - FIX: Error: 1807 Could not obtain exclusive lock on database 'model'. Retry the operation later.](https://blog.sqlauthority.com/2010/01/01/sql-server-fix-error-1807-could-not-obtain-exclusive-lock-on-database-model-retry-the-operation-later/): While working on query optimization project, I encountered following error. Msg 1807, Level 16, State 3, Line 1 Could not obtain exclusive lock on database ‘model’. Retry the operation later. Msg 1802, Level 16, State 4, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors. The resolution of above problem is quick and easy. Fix/Workaround/Solution: Disconnect and Reconnect your SQL Server Management Studio’s session. Your error will go away. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - 1200th Post - An Important Milestone](https://blog.sqlauthority.com/2009/12/31/sqlauthority-news-1200th-post-an-important-milestone/): Today is the last day of 2009 and this is my 1200th post! This year had been a wonderful year for me. I was actively involved with the community, and there were a lot of occasions where I could work along with IT professionals to resolve their issues in projects. Today, as this is my 1200th post and last day of 2009, we will go over few but very important milestones of this year (of course, in my life). Instead of longer list, I have decided to list only the most important events. Event listed event are in order of its... - [SQL SERVER - Fix Error 1949, Level 16: Cannot create index on view. The function yields nondeterministic results](https://blog.sqlauthority.com/2009/12/30/sql-server-fix-error-msg-1949-level-16-cannot-create-index-on-view-the-function-yields-nondeterministic-results-use-a-deterministic-system-function-or-modify-the-user-defined-function-to-r/): Recently, during my training session in Hyderabad, one of the attendees wanted to know the reason of the following error that he encountered every time he tried to create a view. He informed me that he is also creating the index using WITH SCHEMABINDING option. Let us see we can fix error 1949. Msg 1949, Level 16, State 1, Line 1 Cannot create index on view . The function yields nondeterministic results. Use a deterministic system function, or modify the user-defined function to return deterministic results. - [SQL SERVER - Get Date of All Weekdays or Weekends of the Year](https://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/): Today’s article is created based on wonderful contribution from Tejas Shah. Tejas is very prominent SQL Expert and .NET wizard. He has answered the query of a reader on this blog who raised the following question: how to generate the date for all the Sundays in the upcoming year. Tejas replied here with a script. What I really liked about the script is that it is very easy to understand, and also it can be customized very quickly. DECLARE @Year AS INT, @FirstDateOfYear DATETIME, @LastDateOfYear DATETIME -- You can change @year to any year you desire SELECT @year = 2010 SELECT... - [SQL SERVER - Difference Temp Table and Table Variable - Effect of Transaction](https://blog.sqlauthority.com/2009/12/28/sql-server-difference-temp-table-and-table-variable-effect-of-transaction/): Few days ago I wrote an article on the myth of table variable stored in the memory—it was very well received by the community. Read complete article here: SQL SERVER – Difference TempTable and Table Variable – TempTable in Memory a Myth. Today, I am going to write an article which follows the same series; in this, we will continue talking about the difference between TempTable and TableVariable. Both have the same structure and are stored in the database — in this article, we observe the effect of the transaction on the both the objects. DECLARE @intVar INT SET @intVar =... - [SQL SERVER - Download FREE SQL SERVER Express Edition and Service Pack 1](https://blog.sqlauthority.com/2009/12/27/sql-server-download-free-sql-server-express-edition-and-service-pack-1/): Here is the quick link from where SQL Server 2008 Express Edition can be downloaded. Download SQL Server 2008 Express Edition You can download it with many additional details as described in following image. Click on above link to go to page and select desired version. Additionally, please install SQL Server 2008 Express Service Pack 1. You can read one of my previous article where I have covered SQL Server 2008 Express in detail SQL SERVER – SQL Server Express – A Complete Reference Guide. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Whitepaper SQL Server 2008 Full-Text Search: Internals and Enhancements](https://blog.sqlauthority.com/2009/12/26/sql-server-whitepaper-sql-server-2008-full-text-search-internals-and-enhancements/): SQL Server 2008 Full-Text Search: Internals and Enhancements SQL Server Technical Article Writer: Fernando Azpeitia Lopez, Microsoft Corp. Published: July 2008 Database systems must go beyond the traditional realm of relational data by covering an increasing amount and variety of unstructured and semistructured information, be it speech, documents, XML, bioinformatics, chemical, or multimedia. Search is a key technology capable of working with vast amounts of data: it is scalable, low-latency, and very user-friendly. It is just what is needed to make a database the best place to store all types of data. SQL Server 2008 introduces a new Full-Text Engine that... - [SQL SERVER - CDC and TRUNCATE - Cannot truncate table because it is published for replication or enabled for Change Data Capture](https://blog.sqlauthority.com/2009/12/25/sql-server-cdc-and-truncate-cannot-truncate-table-because-it-is-published-for-replication-or-enabled-for-change-data-capture/): Few days ago, I got the great opportunity to visit Bangalore Infosys. Please read the complete details for the event here: SQLAuthority News – Notes from TechDays 2009 at Infosys, Bangalore. I mentioned during the session that CDC is asynchronous and it reads the log file to populate its data. I had received a very interesting question during the session. The question is as follows: does CDC feature capture the data during the truncate operation? Answer: It is not possible or not applicable. Truncate is operation that is not logged in the log file, and if one tries to truncate the... - [SQL Authority News - Training SQL Server Query Optimization And Performance Tuning](https://blog.sqlauthority.com/2009/12/24/sql-authority-news-training-ms-sql-server-2005-2008-query-optimization-performance-tuning/): Earlier this year we had offered Query Optimization course and it was sold out in minutes. Due to popular demand we are offering the same course in the very first week of next year. The title of the course is ‘MS SQL Server Query Optimization And Performance Tuning‘. This three day course is an intensive course designed to give attendees an in-depth look at the query optimization and performance tuning concepts and methods found in SQL Server. This course is designed to prepare the SQL Server developers and administrators for a transition to SQL Server while discussing best practices for a variety of topics. - [SQL SERVER - ORDER BY Clause and TOP WITH TIES](https://blog.sqlauthority.com/2009/12/23/sql-server-order-by-clause-and-top-with-ties/): Recently, on this blog, I published an article on SQL SERVER – Interesting Observation – TOP 100 PERCENT and ORDER BY; this article was very well received because of the observation made in it. One of the comments suggested the workaround was to use clause WITH TIES along with TOP and ORDER BY. That is not the correct solution; however, but the same comment brings up the question regarding how WITH TIES clause actually works. First of all, the clause WITH TIES can be used only with TOP and ORDER BY, both the clauses are required. Let us understand from one... - [SQLAuthority News - Meeting SQL Expert Imran at Hyderabad](https://blog.sqlauthority.com/2009/12/22/sqlauthority-news-meeting-sql-expert-imran-at-hyderabad/): I was very fortunate to meet the SQL Server Expert and one of the top participants of this blog Imran Mohammed. Imran has been very active on this blog and have previously contributed with few articles as well. I have been communicating with Imran for a long time; he is always very active and quick to reply. Many times, he has solved various difficult problems of readers which. He always goes an extra mile to resolve such problems – once I happened to see him spend more than 10 hours to solve a problem posed by a reader. When I met... - [SQL SERVER - Comma Separated Values (CSV) from Table Column - Part 2](https://blog.sqlauthority.com/2009/12/21/sql-server-comma-separated-values-csv-from-table-column-part-2/): In my earlier post, I wrote about how one can use XML to convert table to string SQL SERVER – Comma Separated Values (CSV) from Table Column. The same article is also published on channel 9 SQLAuthority News – Featured on Channel 9. One of the very interesting points that was discussed on show was about the usage of function SUBSTRING. I found the following point very valid: SUBSTRING usage limits the length of the XML to be used. I have re-written the same function with function STUFF, and it removes any limit imposed on the script. USE AdventureWorks GO --... - [SQLAuthority News - Migrating DTS Packages to Integration Services](https://blog.sqlauthority.com/2009/12/20/sqlauthority-news-migrating-dts-packages-to-integration-services/): Migrating DTS Packages to Integration Services Writer: Brian Knight Published: July 2008 SQL Server Integration Services (SSIS) brings a revolutionary concept of enterprise-class ETL to the masses. The engine is robust enough to handle hundreds of millions of rows with ease, but is simple enough to let both developers and DBAs engineer an ETL process. In this whitepaper, you will see the benefits of migrating your SQL Server 2000 Data Transformation Services (DTS) packages to Integration Services by using two proven methods. You will also see how you can run and manage your current DTS packages inside of the SQL Server... - [SQLAuthority News - Migrating to SQL Server from Other Database Products](https://blog.sqlauthority.com/2009/12/19/sqlauthority-news-migrating-to-sql-server-from-other-database-products/): Guide to Migrating from MySQL to SQL Server 2008 In this migration guide you will learn the differences between the MySQL and SQL Server 2008 database platforms, and the steps necessary to convert a MySQL database to SQL Server. Guide to Migrating from Oracle to SQL Server 2008 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2008. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. The entire migration process using SQL Server Migration Assistant (SSMA) 2008 for Oracle is explained... - [SQL SERVER - Differences in Vulnerability between Oracle and SQL Server](https://blog.sqlauthority.com/2009/12/18/sql-server-differences-in-vulnerability-between-oracle-and-sql-server/): In the IT world, but not among experienced DBAs, there has been a long-standing myth that the Oracle database platform is more stable and more secure than SQL Server from Microsoft. This is due to a variety of reasons; but in my opinion, the main ones are listed below: A. Microsoft development platforms are generally more error-prone and full of bugs. This (unfairly) projects the weaknesses of earlier versions of Windows onto its other products such as SQL Server, which is a very stable and secure platform in its own right. B. Oracle has been around for longer than SQL Server... - [SQLAuthority News - Hub-And-Spoke: Building an EDW with SQL Server and Strategies of Implementation](https://blog.sqlauthority.com/2009/12/17/sqlauthority-news-hub-and-spoke-building-an-edw-with-sql-server-and-strategies-of-implementation/): Hub-And-Spoke: Building an EDW with SQL Server and Strategies of Implementation logo-sql08.gif SQL Server Technical Article Writers: Mark Theissen, Eric Kraemer Published: February 2009 To date, the implementation of a true hub-and-spoke architecture for a data warehouse environment has been an idealized and elusive goal. Although building a centralized “hub,” or enterprise data warehouse (EDW) that supports company-wide detail data is achievable, building and maintaining “spokes,” or dependent departmental data marts has proved to be the challenge. Most data warehouse environments have evolved to one of two architectures: a centralized EDW or a series of distributed and/or federated data marts. In... - [SQL SERVER - Fillfactor, Index and In-depth Look at Effect on Performance](https://blog.sqlauthority.com/2009/12/16/sql-server-fillfactor-index-and-in-depth-look-at-effect-on-performance/): I would like to start this post with an interesting question: Where in MS SQL Server is “100” equals to “0”?  And I am not talking about data types now.. Today I will be presenting the answer to this question and some topics related to it. Creating Indices in SQL Server is one of the most important tasks of any SQL DBA. Performance of your database is directly depends on your skills and proficiency in creating and maintaining the right number and quality of indices.. As a DBA, you can use “FILLFACTOR,” which is one of the important arguments that can... - [SQL SERVER - Difference TempTable and Table Variable - Table Variable in Memory a Myth](https://blog.sqlauthority.com/2009/12/15/sql-server-difference-temptable-and-table-variable-temptable-in-memory-a-myth/): Recently, I have been conducting many training sessions at a leading technology company in India. During the discussion of temp table and table variable, I quite commonly hear that Table Variables are stored in memory and Temp Tables are stored in TempDB. I would like to bust this misconception by suggesting following: Temp Table and Table Variable — both are created in TempDB and not in memory. Let us prove this concept by running the following T-SQL script. /* Check the difference between Temp Table and Memory Tables */ -- Get Current Session ID SELECT @@SPID AS Current_SessionID -- Check the space usage in page files SELECT user_objects_alloc_page_count FROM sys.dm_db_session_space_usage WHERE session_id = (SELECT @@SPID ) GO -- Create Temp Table and insert three thousand rows CREATE TABLE #TempTable (Col1... - [SQLAuthority News - An Year of Personal Events - A Life Outside SQL](https://blog.sqlauthority.com/2009/12/14/sqlauthority-news-an-year-of-personal-events-a-life-outside-sql/): Today I will keep the words very short and will convey story in three simple photographs. This post answers the question – “Do I have life outside SQL?” YES! I do and it is very beautiful. December 12, 2009 September 1, 2009 December 12, 2008 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - White Paper - Partitioned Table and Index Strategies Using SQL Server 2008](https://blog.sqlauthority.com/2009/12/13/sql-server-white-paper-partitioned-table-and-index-strategies-using-sql-server-2008/): Partitioned Table and Index Strategies Using SQL Server 2008 Writer: Ron Talmage, Solid Quality Mentors Technical Reviewer: Denny Lee, Wey Guy, Kevin Cox, Lubor Kollar, Susan Price – Microsoft Greg Low, Herbert Albert – Solid Quality Mentors When a database table grows in size to the hundreds of gigabytes or more, it can become more difficult to load new data, remove old data, and maintain indexes. Just the sheer size of the table causes such operations to take much longer. Even the data that must be loaded or removed can be very sizable, making INSERT and DELETE operations on the table... - [SQLAuthority News - Featured on Channel 9](https://blog.sqlauthority.com/2009/12/12/sqlauthority-news-featured-on-channel-9/): This blog was featured on Channel 9 MSDN over here : TWC9: Scott Hanselman, Jon Galloway, Bing, parallel unit tests, more. I was very proud that this blog was discussed for more than 5 mins (from min 18 to min 23) on my favorite online show. Scott Hanselman, Jon Galloway along with Dan Fernandez make this show very live and very very entertaining. The article which was featured in the show is SQL SERVER – Comma Separated Values (CSV) from Table Column. Here are few screenshot from the show. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ERROR: FIX: Cannot drop server because it is used as a Distributor in replication](https://blog.sqlauthority.com/2009/12/11/sql-server-error-fix-cannot-drop-server-because-it-is-used-as-a-distributor-in-replication/): Replication has been my favorite subject when it comes to resolving errors. I have found that many DBAs are stuck with the solving of the problem of replication for hours; however, the solution is very easy. One of the very common errors in replication occurs when replication is removed from any server. I have seen the following error as one attempts to remove replication from the same server when the publisher and distributor are on the same server. Cannot drop server ‘repl_distributor’ because it is used as a Distributor in replication. Cannot drop the distribution database ‘distribution’ because it is currently... - [SQL SERVER - Future of Business Intelligence](https://blog.sqlauthority.com/2009/12/10/sql-server-future-of-business-intelligence/): Business Intelligence (BI) is slated to play bigger roles in all kinds of businesses in the coming years. This is not surprising as data analysis and smarter decision making has made the use of BI inevitable in all sizes of businesses across all sectors, including Real estate, IT, mobile devices, governmental agencies, scientific and engineering communities and R&D labs, banking and insurance, to name a few. BI can effectively deal with industry-specific constraints, operations and objectives thereby helping organizations to better understand their customers, optimize their operations, minimize risk, manage revenue, and ultimately improve their results. Moreover, the changing economic environment,... - [SQL SERVER - Business Intelligence - Aligning Business Metrics](https://blog.sqlauthority.com/2009/12/09/sql-server-business-intelligence-aligning-business-metrics/): Today, executive management and managers need the latest information to drive intelligent decisions for business success. More informed decisions mean more revenue, less risk, decreased cost, and improved operational control for business agility and competitiveness. Besides, in today’s fast paced, technology-driven business world, organizations are continually struggling to deal with growing data volumes and complexity to use their own data efficiently. Constrained with competitive environments and data complexity are COO, IT Managers and Business Consultants who are asking for less information more easily for smarter, faster decision-making. They want information that is highly visual, up-to-date, personalized and secure. Also, they want... - [SQL SERVER - Fix : Error : Invalid object name 'sys.configurations'. (Microsoft SQL Server, Error: 208)](https://blog.sqlauthority.com/2009/12/08/sql-server-fix-error-invalid-object-name-sys-configurations-microsoft-sql-server-error-208/): As you all know that SQL Azure CTP has been released; here, I have included a step-by-step guide for how to configure the CTP: SQL SERVER – Azure Start Guide – Step by Step Installation Guide. For pricing and introduction, please read SQLAuthority News – SQL Azure – Microsoft SQL Data Services – Introduction and Pricing. I received many comments times when people are connected to the SQL Azure they receive following error. Invalid object name ‘sys.configurations’. (Microsoft SQL Server, Error: 208) Fix/Workaround/Solution: 1. Close out all the Connect to Server Dialogue 2. Click on the New Query button from the... - [SQL Server - White Paper - An Introduction to Fast Track Data Warehouse Architectures by Erik Veerman](https://blog.sqlauthority.com/2009/12/07/sql-server-white-paper-an-introduction-to-fast-track-data-warehouse-architectures-by-erik-veerman/): An Introduction to Fast Track Data Warehouse Architectures SQL Server Technical Article Writer: Erik Veerman, Solid Quality Mentors Technical Reviewer: Mark Theissen, Scotty Moran, Val Fontama Published: February 2009 The performance and stability of any application solution—whether line of business, transactional, or business intelligence (BI)—hinges on the integration between solution design and hardware platform. Choosing the appropriate solution architecture—especially for BI solutions—requires balancing the application’s intended purpose and expected use with the hardware platform’s components. Poor planning, bad design, and misconfigured or improperly sized hardware often lead to ongoing, unnecessary spending and, even worse, unsuccessful projects. The ultimate goal of the... - [SQL SERVER - White Papers - Consolidation Guidance for SQL Server - Consolidation Using SQL Server 2008](https://blog.sqlauthority.com/2009/12/06/sql-server-white-papers-consolidation-guidance-for-sql-server-consolidation-using-sql-server-2008/): Consolidation Using SQL Server 2008 Writer: Allan Hirt, Megahirtz LLC (allan@sqlha.com) Technical Reviewers: Lindsey Allen, Madhan Arumugam, Ben DeBow, Sung Hsueh, Rebecca Laszlo, Claude Lorenson, Prem Mehra, Mark Pohto, Sambit Samal, and Buck Woody Published: October 2009 What are the considerations when creating a consolidation plan for my environment? What are the key differentiators among the three consolidation options? How can I use these differentiators to choose the appropriate consolidation option for my environment? Read Consolidation Guidance for SQL Server Many companies are considering or have already implemented consolidation of computing resources, including Microsoft SQL Server instances and databases, in their... - [SQLAuthority News - Notes from TechDays 2009 at Infosys, Bangalore](https://blog.sqlauthority.com/2009/12/05/sqlauthority-news-notes-from-techdays-2009-at-infosys-bangalore/): I recently had opportunity to attend TechDays 2009 Infosys. The dates of the event was Nov 16-17, 2009. This event was the largest technology conference by Microsoft in Infosys. Microsoft Tech Days focused on positioning Microsoft as the company to bet on for future technology investments by businesses and consumers alike. The event was a showcase of Microsoft’s products and solutions to technologists, decision-makers, technology influencers, and analysts. The in-campus event in Infosys was attended by 2500 tech professionals and decision makers. The event was also broadcast live to all non-Bangalore Infosys locations by using Infosys’ internal infrastructure. 2.5K Attendees I... - [SQL SERVER - 2008 Star Join Query Optimization](https://blog.sqlauthority.com/2009/12/04/sql-server-2008-star-join-query-optimization/): Business Intelligence (BI) plays a significant role in businesses nowadays. Moreover, the databases that deal with the queries related to BI are presently facing an increase in workload. At present, when queries are sent to very large databases, millions of rows are returned. Also the users have to go through extended query response times when joining multiple tables are involved with such queries. ‘Star Join Query Optimization’ is a new feature of SQL Server 2008 Enterprise Edition. This mechanism uses bitmap filtering for improving the performance of some types of queries by the effective retrieval of rows from fact tables. Improved... - [SQLAuthority News - Airline Review - Paramount, Kingfisher, Go Air, Indigo, Jet Airways, Indian Airlines, Spicejet ](https://blog.sqlauthority.com/2009/12/03/sqlauthority-news-airline-review-paramount-kingfisher-go-air-indigo-jet-airways-indian-airlines-spicejet/): First of all, this is a totally different article that I have ever written on this site. As the regular readers of my blog are aware that I am always traveling due to my different assignments at work. In last two months, I have been on flight for 36 times; this makes me a regular air traveler, who travels almost every other day. For instance, considering a month of 24 days (excluding the weekends), for two months, there are 48 business days. In such case, I was almost on air always! There are many airlines in India, and I have traveled... - [SQL SERVER - Validate an XML Document in TSQL using XSD by Jacob Sebastian](https://blog.sqlauthority.com/2009/12/02/sql-server-validate-an-xml-document-in-tsql-using-xsd-by-jacob-sebastian/): Let us learn about XML Document in TSQL using XSD by Jacob Sebastian. - [SQLAuthority News - A Daily Doze of Technology - Alvin Ashcraft's Morning Dew](https://blog.sqlauthority.com/2009/12/01/sqlauthority-news-a-daily-doze-of-technology-alvin-ashcrafts-morning-dew/): A common question that I receive is regarding how I keep myself updated with latest information about technology and what is going on at present. I read lots of blogs and books. I am usually traveling 4 days in my any regular work week. I read physical books at the time. I prefer to read the books in hard copy and not on the computer screen. If you ever spot me reading books, quite often you can see me with a fiction book rather than a SQL Book. Ok… So the question is what do I read to keep myself updated... - [SQL SERVER - Size of Index Table for Each Index - Solution](https://blog.sqlauthority.com/2009/11/30/sql-server-size-of-index-table-for-each-index-solution/): Earlier I have posted small question on this blog and requested help from readers to participate here and provide solution. Please read the original Puzzle here. SQL SERVER – Size of Index Table – A Puzzle to Find Index Size for Each Index on Table The puzzle was to write a query that will return the size for each index that is on any particular table. We need a query that will return an additional column in the above listed query and it should contain the size of the index. So far I have found two potential solutions. I have done... - [SQL SERVER - Azure Start Guide - Step by Step Installation Guide](https://blog.sqlauthority.com/2009/11/29/sql-server-azure-start-guide-step-by-step-installation-guide/): As SQL Azure CTP is released I have included here step by step guide for how to configure the CTP. For pricing and introduction please read SQLAuthority News – SQL Azure – Microsoft SQL Data Services – Introduction and Pricing First it has to be configured online at Login using your Live ID Type in invitation code received from Microsoft for CTP. You can request one for your self here. Accept the TOU. Once logged it you will have to create server username and password. Click on my project and it will provide you details about your servername where your data... - [SQLAuthority News - SQL Server R2 Resources Downloads, Documentations](https://blog.sqlauthority.com/2009/11/28/sqlauthority-news-sql-server-r2-resources-downloads-documentations/): Microsoft SQL Server 2008 R2 November Community Technology Preview Building on SQL Server 2008, R2 provides an even more scalable data platform with comprehensive tools for managing your databases and applications, improving the quality of your data, and empowering your users to build rich analyses and reports using tools they are already familiar with. Microsoft SQL Server 2008 R2 November Community Technology Preview Feature Pack The Microsoft SQL Server 2008 R2 Feature Pack is a collection of stand-alone packages which provide additional value for SQL Server 2008 R2. SQL Server 2008 R2 Books Online Community Technology Preview November 2009 Download the... - [SQLAuthority News - Subscribe to Blog - Search a Blog](https://blog.sqlauthority.com/2009/11/27/sqlauthority-news-subscribe-to-blog-search-a-blog/): Quite often I get request if I send blog post in newsletter or through email. Here are few important links. You can for sure get email of my post, however, I strongly suggest to visit blog as if there are any updates in my post they are reflected on blog. Subscribe to blog post through email Subscribe SQLAuthority Feed Search SQLAuthority – This is very powerful search. Give it a try. Follow me on Twitter Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server 2008 Analysis Services Performance Guide](https://blog.sqlauthority.com/2009/11/26/sqlauthority-news-sql-server-2008-analysis-services-performance-guide/): Because Microsoft SQL Server Analysis Services query and processing performance tuning is a fairly broad subject, this white paper organizes performance tuning techniques into the following three segments. Enhancing Query Performance – Query performance directly impacts the quality of the end user experience. As such, it is the primary benchmark used to evaluate the success of an online analytical processing (OLAP) implementation. Analysis Services provides a variety of mechanisms to accelerate query performance, including aggregations, caching, and indexed data retrieval. In addition, you can improve query performance by optimizing the design of your dimension attributes, cubes, and Multidimensional Expressions (MDX) queries.... - [SQL SERVER - Comma Separated Values (CSV) from Table Column](https://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/): I use following script very often and I realized that I have never shared this script on this blog before. Creating Comma Separated Values (CSV) from Table Column is a very common task, and we all do this many times a day. Let us see the example that I use frequently and its output. - [SQL SERVER - Interesting Observation - TOP 100 PERCENT and ORDER BY](https://blog.sqlauthority.com/2009/11/24/sql-server-interesting-observation-top-100-percent-and-order-by/): Today we will go over a very simple, but interesting subject. The following error is quite common if you use ORDER BY while creating any view: Msg 1033, Level 15, State 1, Procedure something, Line 5 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. The error also explains the solution for the same – use of TOP. I have seen developers and DBAs using TOP very causally when they have to use the ORDER BY clause. Theoretically, there is no need of ORDER BY... - [SQL SERVER - A Common Design Problem - Should the Primary Key Always be a Clustered Index](https://blog.sqlauthority.com/2009/11/23/sql-server-a-common-design-problem-should-the-primary-key-always-be-a-clustered-index/): In SQL Server, whenever we create any key, a Primary Key automatically creates clustered index on the same. I like this feature and I use this feature every now and then. The question is does the change of any column as Primary Key should also create a Clustered Index? Moreover, is there any case, where one would not do the same? One of the recent conversations I had with one SQL Expert is with regard to the SSN number. The discussion was that SSN numbers are always unique and never repeated and hence are the best candidates for primary key. Additionally... - [SQL SERVER - Remove Bookmark Key Lookup - 4 Different Ideas](https://blog.sqlauthority.com/2009/11/22/sql-server-remove-bookmark-key-lookup-4-different-ideas/): I quite often get request to summarized my ideas about Removing bookmark lookup on this blog post. Bookmark lookup or key lookup are bad for any query as they force query engine to lookpup corresponding row in the table or index as it does not find required data from just reading the data. Here are list of my four post written on the same subject. SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup – Part... - [SQL SERVER - Script to Find SQL Server on Network](https://blog.sqlauthority.com/2007/04/13/sql-server-script-to-find-sql-server-on-network/): I manage lots of SQL Servers. Many times I forget how many server I have and what are their names. New servers are added frequently and old servers are replaced with powerful servers. I run following script to check if server is properly set up and announcing itself. This script requires execute permissions on XP_CMDShell. CREATE TABLE #servers(sname VARCHAR(255)) INSERT #servers (sname) EXEC master..xp_CMDShell 'ISQL -L' DELETE FROM #servers WHERE sname='Servers:' OR sname IS NULL SELECT LTRIM(sname) FROM #servers DROP TABLE #servers Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Disable Triggers - Drop Triggers](https://blog.sqlauthority.com/2007/04/13/sql-server-2005-disable-triggers-drop-triggers/): There are two ways to prevent trigger from firing. 1) Drop Trigger Example: DROP TRIGGER TriggerName GO 2) Disable Trigger DML trigger can be disabled two ways. Using ALETER TABLE statement or use DISABLE TRIGGER. I prefer DISABLE TRIGGER statement. Syntax: DISABLE TRIGGER { [ schema . ] trigger_name [ ,...n ] | ALL } ON { OBJECT_NAME | DATABASE | ALL SERVER } [ ; ] Example: DISABLE TRIGGER TriggerName ON TableName Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-1702-create-table-failed-because-column-in-table-exceeds-the-maximum-of-columns/): Error Received: Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns SQL Server 2000 supports table with maximum 1024 columns. This errors happens when we try to create table with 1024 columns or try to add columns to table which exceeds more than 1024. Fix/Solution/WorkAround: Reduce the number of columns in the table to 1,024 or less. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error: 3902, Severity: 16; State: 1 : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-3902-severity-16-state-1-the-commit-transaction-request-has-no-corresponding-begin-transaction/): SQL Server Integration Services Error : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. (Microsoft OLE DB Provider for SQL Server) Fix/Workaround/Solution: Option 1: To work around this problem, do not call the stored procedure by using ODBC Call syntax. You can call the stored procedure in may ways by using ADO. One of the methods is to call a stored procedure by using a command object. (View Example) Option 2: If the sql statements are like BEGIN TRAN SQL Statements END TRAN SET “RetainSameConnection” property on the connection manager to true. This will fix the problem. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Running 64 bit SQL SERVER 2005 on 32 bit Operating System](https://blog.sqlauthority.com/2007/04/12/sql-server-running-64-bit-sql-server-2005-on-32-bit-operating-system/): Few days ago, I have received email from users asking question :How to run 64 bit SQL SERVER 2005 on 32 bit operating system? - [SQL SERVER - UDF - User Defined Function to Extract Only Numbers From String](https://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/): Following SQL User Defined Function will extract/parse numbers from the string. CREATE FUNCTION ExtractInteger(@String VARCHAR(2000)) RETURNS VARCHAR(1000) AS BEGIN DECLARE @Count INT DECLARE @IntNumbers VARCHAR(1000) SET @Count = 0 SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1) END SET @Count = @Count + 1 END RETURN @IntNumbers END GO Run following script in query analyzer. SELECT dbo.ExtractInteger('My 3rd Phone Number is 323-111-CALL') GO It will return following values. 3323111 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Explanation of TRY...CATCH and ERROR Handling](https://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/): SQL Server 2005 offers a more robust set of tools for handling errors than in previous versions of SQL Server. Deadlocks, which are virtually impossible to handle at the database level in SQL Server 2000, can now be handled with ease. By taking advantage of these new features, you can focus more on IT business strategy development and less on what needs to happen when errors occur. In SQL Server 2005, @@ERROR variable is no longer needed after every statement executed, as was the case in SQL Server 2000. SQL Server 2005 provides the TRY…CATCH construct, which is already present in... - [SQL SERVER - 2005 - Silent Installation - Unattended Installation](https://blog.sqlauthority.com/2007/04/10/sql-server-2005-silent-installation-unattended-installation/): Silent SQL Server 2005 Installation is possible in two steps. 1) Creating an .ini file The SQL Server CD contains a template file called template.ini . Based on that create another required .ini file which includes a single [Options] section containing multiple parameters, each relating to a different feature or configuration setting. 2) Run Setup on command prompt On command prompt type following script setup.exe /settings <path TO .ini FILE> If location of sqlinstall.ini file is at C:\SQLSetup folder. The command to initiate silent installation is: setup.exe /settings C:SQLSetup sqlinstall.ini Specify the /qn switch to perform a silent installation (with no... - [SQL SERVER - SP Performance Improvement without changing T-SQL](https://blog.sqlauthority.com/2007/04/10/sql-server-sp-performance-improvement-without-changing-t-sql/): There are two ways, which can be used to improve the performance of Stored Procedure (SP) without making T-SQL changes in SP. Do not prefix your Stored Procedure with sp_. In SQL Server, all system SPs are prefixed with sp_. When any SP is called which begins sp_ it is looked into masters database first before it is looked into the database it is called in. Call your Stored Procedure prefixed with dbo.SPName – fully qualified name. When SP are called prefixed with dbo. or database.dbo. it will prevent SQL Server from placing a COMPILE lock on the procedure. While SP... - [SQL SERVER - 2005 Reserved Keywords](https://blog.sqlauthority.com/2007/04/09/sql-server-2005-reserved-keywords/): Microsoft SQL Server 2005 uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language that is used by SQL Server to parse and understand Transact-SQL statements and batches. It is not legal to include the reserved keywords in a Transact-SQL statement in any location except that defined by SQL Server. No objects in the database should be given a name that matches a reserved keyword. Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using... - [SQL SERVER - Search Text Field - CHARINDEX vs PATINDEX](https://blog.sqlauthority.com/2007/04/08/sql-server-search-text-field-charindex-vs-patindex/): We can use either CHARINDEX or PATINDEX to search in TEXT field in SQL SERVER. The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. Both functions take two arguments. With PATINDEX, you must include percent signs before and after the pattern, unless you are looking for the pattern as the first (omit the first %) or last (omit the last %) characters in a column. For CHARINDEX, the pattern cannot include wildcard characters. The second argument is a character expression, usually a column name, in which Adaptive Server searches for the specified pattern. Example of CHARINDEX:... - [SQL SERVER - DBCC Commands Introduced in SQL Server 2005](https://blog.sqlauthority.com/2007/04/07/sql-server-dbcc-commands-introduced-in-sql-server-2005/): SQL Server 2005 has introduced following two documented and five undocumented DBCC Commands. I was able to find documentation for only first one online. If you find any documentation of any other DBCC Commands please add comments. It will be helpful to all of us. Documented: freesessioncache () — no parameters Flushes the distributed query connection cache used by distributed queries against an instance of Microsoft SQL Server. View Details requeststats ({clear} | {setfastdecayrate, rate} | {setslowdecayrate, rate}) UnDocumented: mapallocunit (I8AllocUnitId | {I4part, I2part}) metadata ({‘print’ [, printopt = {0 |1}] | ‘drop’ | ‘clone’ [, ” | ….]}, {‘object’ [,... - [SQL SERVER - Fix: Server: Msg 7391, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/06/sql-server-fix-server-msg-7391-level-16-state-1-line-1/): I have received this error many times on different servers in my careers. There is no single fix for this Error. Server: Msg 7391, Level 16, State 1, Line 1 can happen due to many reasons. I have used various of this reasons with few of my servers. Please refer them and try them one by one. One of them should be applicable to your problem. You may receive a 7391 error message in SQLOLEDB when you run a distributed transaction against a linked server after you install Windows XP Service Pack 2 or Windows XP Tablet PC Edition 200. View... - [SQL SERVER - Performance Optimization of SQL Query and FileGroups](https://blog.sqlauthority.com/2007/04/05/sql-server-performance-optimization-of-sql-query-and-filegroups/): It is suggested to place transaction logs on separate physical hard drives. In this manner, data can be recovered up to the second in the event of a media failure. In SQL 2005 When database is created without specifying a transaction log size, the transaction log will be re-sized to 25 percent of the size of data files. Tables and their non-clustered indexes separated into separate file groups can improve performance, because modifications to the table can be written to both the table and the index at the same time. If tables and their corresponding indexes in a different file group,... - [SQL SERVER - Fix: HResult 0x274D, SQLCMD Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired](https://blog.sqlauthority.com/2007/04/04/sql-server-fix-hresult-0x274d-level-16-state-1-error-microsoft-sql-native-client-login-timeout-expired/): While Working with SQLCMD in SQL Server 2005 I encountered following error. Let us learn in this blog post how we can solve Fix: HResult 0x274D, Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired. - [SQL SERVER - T-SQL Paging Query Technique Comparison - SQL 2000 vs SQL 2005](https://blog.sqlauthority.com/2007/04/03/sql-server-t-sql-paging-query-technique-comparison-sql-2000-vs-sql-2005/): I was doing paging in SQL Server 2000 using Temp Table or Derived Tables. I decided to checkout new function ROW_NUMBER() in SQL Server 2005. ROW_NUMBER() returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. I have compared both the following query on SQL Server 2005. SQL 2005 Paging Method USE AdventureWorks GO DECLARE @StartRow INT DECLARE @EndRow INT SET @StartRow = 120 SET @EndRow = 140 SELECT FirstName, LastName, EmailAddress FROM ( SELECT PC.FirstName, PC.LastName, PC.EmailAddress, ROW_NUMBER() OVER( ORDER BY PC.FirstName, PC.LastName,PC.ContactID) AS RowNumber FROM... - [SQL SERVER - 2005 - Performance Dashboard Reports](https://blog.sqlauthority.com/2007/04/02/sql-server-2005-performance-dashboard-reports/): The Microsoft SQL Server 2005 Performance Dashboard Reports are used to monitor and resolve performance problems on your SQL Server 2005 database server. The SQL Server instance being monitored and the Management Studio client used to run the reports must both be running SP2 or later. Common performance problems that the dashboard reports may help to resolve include: – CPU bottlenecks (and what queries are consuming the most CPU) – IO bottlenecks (and what queries are performing the most IO). – Index recommendations generated by the query optimizer (missing indexes) – Blocking – Latch contention The SQL Server 2005 Performance Dashboard... - [SQL SERVER - TempDB is Full. Move TempDB from one drive to another drive.](https://blog.sqlauthority.com/2007/04/01/sql-server-tempdb-is-full-move-tempdb-from-one-drive-to-another-drive/): If you ever find your TEmpDB to be full and if you want to move TempDB, you will find this blog post very helpful. Here is the error message which may come across. Event ID: 17052 Description: The LOG FILE FOR DATABASE 'tempdb' IS FULL. Back up the TRANSACTION LOG FOR the DATABASE TO free Up SOME LOG SPACE - [SQL SERVER - 2005 Best Practices Analyzer (February 2007 CTP)](https://blog.sqlauthority.com/2007/03/31/sql-server-2005-best-practices-analyzer-february-2007-ctp/): Microsoft has released a tool called the Microsoft SQL Server Best Practices Analyzer. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. Download SQL Server 2005 Best Practices Analyzer (February 2007 Community Technology Preview) Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Index Seek Vs. Index Scan (Table Scan)](https://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/): Index Scan retrieves all the rows from the table. Index Seek retrieves selective rows from the table. - [SQL SERVER - Difference between DISTINCT and GROUP BY - Distinct vs Group By](https://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/): This question is asked many times to me. What is difference between DISTINCT and GROUP BY? A DISTINCT and GROUP BY usually generate the same query plan, so performance should be the same across both query constructs. GROUP BY should be used to apply aggregate operators to each group. If all you need is to remove duplicates then use DISTINCT. If you are using sub-queries execution plan for that query varies so in that case you need to check the execution plan before making decision of which is faster. Example of DISTINCT: SELECT DISTINCT Employee, Rank FROM Employees Example of GROUP... - [SQL SERVER - Fix : Error 8101 An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON](https://blog.sqlauthority.com/2007/03/28/sql-server-fix-error-8101-an-explicit-value-for-the-identity-column-in-table-can-only-be-specified-when-a-column-list-is-used-and-identity_insert-is-on/): This error occurs when the user has attempted to insert a row containing a specific identity value into a table that contains an identity column. Run following commands according to your SQL Statement. Let us learn about the IDENTITY_INSERT. - [SQL SERVER - Fix : Error 701 There is insufficient system memory to run this query](https://blog.sqlauthority.com/2007/03/27/sql-server-fix-error-701-there-is-insufficient-system-memory-to-run-this-query/): Generic Solution: Check the settings for both min server memory (MB) and max server memory (MB). If max server memory (MB) is a value close to the value of min server memory (MB), then increase the max server memory (MB) value. Check the size of the virtual memory paging file. If possible, increase the size of the file. For SQL Server 2005: Install following HotFix and Restart Server. Additionally following DBCC Commands can be ran to free memory: DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT - Retrieve Last Inserted Identity of Record](https://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/): SELECT @@IDENTITY It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value. @@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it. SELECT SCOPE_IDENTITY()... - [SQL SERVER - Stored Procedure - Clean Cache and Clean Buffer](https://blog.sqlauthority.com/2007/03/23/sql-server-stored-procedure-clean-cache-and-clean-buffer/): DBCC FREEPROCCACHE will invalidate all stored procedure plans that the optimizer has cached in memory. Let us learn how to clean cache.  - [SQL SERVER - Fix: Error Msg 128 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.](https://blog.sqlauthority.com/2007/03/22/sql-server-fix-error-msg-128-the-name-is-not-permitted-in-this-context-only-constants-expressions-or-variables-allowed-here-column-names-are-not-permitted/): Error Message: Server: Msg 128, Level 15, State 1, Line 3 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Causes: This error occurs when using a column as the DEFAULT value of another column when a table is created. CREATE TABLE [dbo].[Items] ( [OrderCount] INT, [ProductAmount] INT, [TotalAmount] DEFAULT ([OrderCount] + [ProductAmount]) ) Executing this CREATE TABLE statement will generate the following error message: Server: Msg 128, Level 15, State 1, Line 5 The name ‘TotalAmount’ is not permitted in this context. Only constants, expressions, or variables allowed here.... - [SQL SERVER - 2005 Security Best Practices - Operational and Administrative Tasks](https://blog.sqlauthority.com/2007/03/21/sql-server-2005-security-best-practices-operational-and-administrative-tasks/): This white paper covers some of the operational and administrative tasks associated with SQL Server 2005 security and enumerates best practices and operational and administrative tasks that will result in a more secure SQL Server system. - [SQL SERVER - SQL Commandments - Suggestions, Tips, Tricks](https://blog.sqlauthority.com/2007/03/20/sql-server-sql-commandments-suggestions-tips-tricks/): Few days ago, while searching for something on web site, I came across a very good article of 25 SQL Commandments. I really enjoyed reading it. It was for Oracle, I re-wrote it for SQL Server. First 18 points are taken from original article and last 2 I added to complete total of 20 Commandments. Many more rules and suggestions can be added to this list, this list is just a beginning. 1. Know your data and business application well. Familiarize yourself with these sources; you must be aware of the data volume and distribution in your database. 2. Test your... - [SQL SERVER - Fix: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17](https://blog.sqlauthority.com/2007/03/16/sql-server-fix-sqllib-error-oledb-error-encountered-calling-idbinitializeinitialize-hr-0x80004005-sqlstate-08001-native-error-17/): Error received: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17 Error state: 1, Severity: 16 Source: Microsoft OLE DB Provider for SQL Server Error message: [DBNETLIB]SQL Server does not exist or access denied The simple fix: Microsoft SQL Server 2005 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server 2005 Network Configuration >> Enable TCP-IP. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC command to RESEED Table Identity Value - Reset Table Identity](https://blog.sqlauthority.com/2007/03/15/sql-server-dbcc-reseed-table-identity-value-reset-table-identity/): DBCC CHECKIDENT can reseed (reset) the identity value of the table. For example, YourTable has 25 rows with 25 as last identity. If we want next record to have identity as 35 we need to run following T SQL script in Query Analyzer. DBCC CHECKIDENT (yourtable, reseed, 34) If table has to start with an identity of 1 with the next insert then the table should be reseeded with the identity to 0. If identity seed is set below values that currently are in table, it will violate the uniqueness constraint as soon as the values start to duplicate and will... - [SQL SERVER - Union vs. Union All - Which is better for performance?](https://blog.sqlauthority.com/2007/03/10/sql-server-union-vs-union-all-which-is-better-for-performance/): This article is completely re-written with better example SQL SERVER – Difference Between Union vs. Union All – Optimal Performance Comparison. I suggest all of my readers to go here for update article. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values. The difference between Union and Union all... - [SQL SERVER - Download 2005 SP2a](https://blog.sqlauthority.com/2007/03/07/sql-server-2005-sp2a/): Microsoft released an updated SQL Server 2005 SP2 on March 5th, 2007. The build number is 9.00.3042.01. The previous build number was 9.00.3042.00.Microsoft released a SP2a patch for the second service pack for SQL Server 2005 to fix the issues with the maintenance plans.If you have upgraded to SP2, use the download from here to patch the system. KB 933508 has more information on this patch. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Script to Determine Which Version of SQL Server 2000-2005 is Running](https://blog.sqlauthority.com/2007/03/07/sql-server-script-to-determine-which-version-of-sql-server-2000-2005-is-running/): To determine which version of SQL Server 2000/2005 is running, connect to SQL Server 2000/2005 by using Query Analyzer, and then run the following code: SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') The results are: The product version (for example, 8.00.534). The product level (for example, “RTM” or “SP2”). The edition (for example, “Standard Edition”). For example, the result looks similar to: 8.00.534 RTM Standard Edition Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation](https://blog.sqlauthority.com/2007/03/05/sql-server-quoted_identifier-onoff-and-ansi_null-onoff-explanation/): When create or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF? SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO--SQL PROCEDURE, SQL FUNCTIONS, SQL OBJECTGO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO ANSI NULL ON/OFF: This option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares a value with a null returns a 0. When off, any query that compares a value with a null returns a null value. QUOTED IDENTIFIER ON/OFF:... - [SQL SERVER - Delete Duplicate Records - Rows](https://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/): Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3. DELETE FROM MyTable WHERE ID NOT IN ( SELECT MAX(ID) FROM MyTable GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3) Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to find the CD key from Registry](https://blog.sqlauthority.com/2007/02/28/sql-server-t-sql-script-to-find-the-cd-key-from-registry/): Here is the way to find SQL Server CD key, which was used to install it on machine. If user do not have permission on the SP, please login using SA username. Expended stored procedure xp_regread can read any registry values. I have used this XP to read CD_KEY. This is undocumented Stroed Procedure and may not be supported in Future Version of SQL Server. USE master GO EXEC xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Microsoft SQL Server\80\Registration','CD_KEY' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - What is New in SQL Server Agent for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/02/26/sql-server-whats-new-in-sql-server-agent-for-microsoft-sql-server-2005/): I came across this interesting and detailed article ‘What’s New in SQL Server Agent for Microsoft SQL Server 2005’ on Microsoft TechNet. This article describes Security Improvements, New Roles in the msdb Database, Multiple Proxy Accounts, Performance Improvements, Performance Counters, New SQL Server Agent Subsystems, Shared Schedules, WMI Event Alerts, SQL Server Agent Sessions, Database Mail Support, Stored Procedure Changes in depth. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Restore Database Backup using SQL Script (T-SQL)](https://blog.sqlauthority.com/2007/02/25/sql-server-restore-database-backup-using-sql-script-t-sql/): In this blog post we are going to learn how to restore database backup using T-SQL script. We have already database which we will use to take a backup first and right after that we will use it to restore to the server. Taking backup is an easy thing, but I have seen many times when a user tries to restore the database, it throws an error. - [SQL SERVER - Download SQL Server 2005 Books Online (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-download-sql-server-2005-books-online-february-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The February 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - SQL Server 2005 Samples and Sample Databases (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-sql-server-2005-samples-and-sample-databases-february-2007/): The samples download provides over 100 samples for SQL Server 2005, demonstrating the following components: Database Engine, including administration, data access, Full-Text Search, Common Language Runtime (CLR) integration, Server Management Objects (SMO), Service Broker, and XML Analysis Services Integration Services Notification Services Reporting Services Replication The samples databases downloads include the AdventureWorks sample online transaction processing (OLTP) database, the AdventureWorksDW sample data warehouse, and the AdventureWorksAS sample projects which you can use to build the AdventureWorksAS BI database. These databases are used in the samples and in the code examples in the SQL Server 2005 Books Online. There is also a... - [SQL SERVER - Creating Comma Separate List From Table](https://blog.sqlauthority.com/2007/02/20/deprecate-dec-2007-creating-comma-separate-list-from-table/): Update : (5/5/2007) I have updated the script to support SQL SERVER 2005. Visit :SQL SERVER – Creating Comma Separate Values List from Table – UDF – SP Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 15023: User already exists in current database.](https://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/): Error 15023: User already exists in current database. 1) This is the best Solution. First of all run following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan. USE YourDB GO EXEC sp_change_users_login 'Report' GO Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist. In following example ‘ColdFusion’ is UserName, ‘cf’ is Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in... - [SQL SERVER - Function to Convert List to Table](https://blog.sqlauthority.com/2007/02/10/sql-server-function-to-convert-list-to-table/): Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005. Visit :SQL SERVER – UDF – Function to Convert List to Table Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Constraints and Unique Key Constraints](https://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/): Primary Key: Primary Key enforces uniqueness of the column on which they are defined. Primary Key creates a clustered index on the column. Primary Key does not allow Nulls. Create table with Primary Key: CREATE TABLE Authors ( AuthorID INT NOT NULL PRIMARY KEY, Name VARCHAR(100) NOT NULL ) GO Alter table with Primary Key: ALTER TABLE Authors ADD CONSTRAINT pk_authors PRIMARY KEY (AuthorID) GO Unique Key: Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value. Alter table to add unique constraint... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case](https://blog.sqlauthority.com/2007/02/01/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case/): Following function will convert any string to Title Case. I have this function for long time. I do not remember that if I wrote it myself or I modified from original source. Run Following T-SQL statement in query analyzer: SELECT dbo.udf_TitleCase('This function will convert this string to title case!') The output will be displayed in Results pan as follows: This Function Will Convert This String To Title Case! T-SQL code of the function is: CREATE FUNCTION udf_TitleCase (@InputString VARCHAR(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(1) DECLARE @OutputString VARCHAR(255) SET @OutputString = LOWER(@InputString) SET @Index = 2... - [SQL SERVER - ReIndexing Database Tables and Update Statistics on Tables](https://blog.sqlauthority.com/2007/01/31/sql-server-reindexing-database-tables-and-update-statistics-on-tables/): SQL SERVER 2005 uses ALTER INDEX syntax to reindex database. SQL SERVER 2005 supports DBREINDEX but it will be deprecated in future versions. Let us learn how to do ReIndexing Database Tables and Update Statistics on Tables. - [SQL SERVER - Query Analyzer Short Cut to display the text of Stored Procedure](https://blog.sqlauthority.com/2007/01/30/query-analyzer-short-cut-to-display-the-text-of-stored-procedure/): This is quick but interesting trick to display the text of Stored Procedure in the result window. Open SQL Query Analyzer >> Tools >> Customize >> Custom Tab type sp_helptext against Ctrl+3 (or shortcut key of your choice) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2007/01/26/sql-server-sql-joke-sql-humor-sql-laugh/): I have heard this joke from my friend. I always wanted to write it but I was not able to find the source of the joke. This joke I have located on DavidM’s Blog on SQLTeam. It is March 1st and the first day of DBMS school The teacher starts off with a role call.. Teacher: Oracle? “Present sir” Teacher: DB2? “Present sir” Teacher: SQL Server? “Present sir” Teacher: MySQL? [Silence] Teacher: MySQL? [Silence] Teacher: Where the hell is MySQL [In rushes MySQL, unshaven, hair a mess] Teacher: Where have you been MySQL “Sorry sir I thought it was February 31st”... - [SQL SERVER - Query Analyzer Shortcuts](https://blog.sqlauthority.com/2007/01/20/sql-server-query-analyzer-shortcuts/): Download Query Analyzer Shortcuts (PDF) Shortcut Function Shortcut Function ALT+BREAK Cancel a query CTRL+SHIFT+F2 Clear all bookmarks ALT+F1 Database object information CTRL+SHIFT+INSERT Insert a template ALT+F4 Exit CTRL+SHIFT+L Make selection lowercase CTRL+A Select all CTRL+SHIFT+M Replace template parameters CTRL+B Move the splitter CTRL+SHIFT+P Open CTRL+C Copy CTRL+SHIFT+R Remove comment CTRL+D Display results in grid format CTRL+SHIFT+S Show client statistics CTRL+Delete Delete through the end of the line CTRL+SHIFT+T Show server trace CTRL+E Execute query CTRL+SHIFT+U Make selection uppercase CTRL+F Find CTRL+T Display results in text format CTRL+F2 Insert/remove bookmark CTRL+U Change database CTRL+F4 Disconnect CTRL+V Paste CTRL+F5 Parse query and check... - [SQL SERVER - Query to find number Rows, Columns, ByteSize for each table in the current database - Find Biggest Table in Database](https://blog.sqlauthority.com/2007/01/10/sql-server-query-to-find-number-rows-columns-bytesize-for-each-table-in-the-current-database-find-biggest-table-in-database/): USE DatabaseName GO CREATE TABLE #temp ( table_name sysname , row_count INT, reserved_size VARCHAR(50), data_size VARCHAR(50), index_size VARCHAR(50), unused_size VARCHAR(50)) SET NOCOUNT ON INSERT #temp EXEC sp_msforeachtable 'sp_spaceused ''?''' SELECT a.table_name, a.row_count, COUNT(*) AS col_count, a.data_size FROM #temp a INNER JOIN information_schema.columns b ON a.table_name collate database_default = b.table_name collate database_default GROUP BY a.table_name, a.row_count, a.data_size ORDER BY CAST(REPLACE(a.data_size, ' KB', '') AS integer) DESC DROP TABLE #temp Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Simple Example of Cursor](https://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/): UPDATE: For working example using AdventureWorks visit : SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2 This is the simplest example of the SQL Server Cursor. I have used this all the time for any use of Cursor in my T-SQL. DECLARE @AccountID INT DECLARE @getAccountID CURSOR SET @getAccountID = CURSOR FOR SELECT Account_ID FROM Accounts OPEN @getAccountID FETCH NEXT FROM @getAccountID INTO @AccountID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @AccountID FETCH NEXT FROM @getAccountID INTO @AccountID END CLOSE @getAccountID DEALLOCATE @getAccountID Reference: Pinal Dave (http://www.SQLAuthority.com), BOL - [SQL SERVER - Shrinking Truncate Log File - Log Full](https://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/): UPDATE: Please follow link for SQL SERVER – SHRINKFILE and TRUNCATE Log File in SQL Server 2008. Sometime, it looks impossible to shrink the Truncated Log file. Following code always shrinks the Truncated Log File to minimum size possible. USE DatabaseName GO DBCC SHRINKFILE(<TransactionLogName>, 1) BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY DBCC SHRINKFILE(<TransactionLogName>, 1) GO [Update: Please note, there are much more to this subject, read my more recent blogs. This breaks the chain of the logs and in future you will not be able to restore point in time. If you have followed this advise, you are recommended to take full... - [SQL SERVER - Fix : Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved.](https://blog.sqlauthority.com/2006/12/20/sql-server-fix-error-14274-cannot-add-update-or-delete-a-job-or-its-steps-or-schedules-that-originated-from-an-msx-server-the-job-was-not-saved/): To fix the error which occurs after the Windows server name been changed, when trying to update or delete the jobs previously created in a SQL Server 2000 instance, or attaching msdb database. Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved. Reason: SQL Server 2000 supports multi-instances, the originating_server field contains the instance name in the format ‘server\instance’. Even for the default instance of the server, the actual server name is used instead of ‘(local)’. Therefore, after the Windows server is renamed, these jobs... - [SQL SERVER - Find Stored Procedure Related to Table in Database - Search in All Stored Procedure](https://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/): Following code will help to find all the Stored Procedures (SP) which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results. ----Option 1 SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so ON sc.id=so.id WHERE sc.TEXT LIKE '%tablename%' ----Option 2 SELECT DISTINCT o.name, o.xtype FROM syscomments c INNER JOIN sysobjects o ON c.id=o.id WHERE c.TEXT LIKE '%tablename%' Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Cursor to Kill All Process in Database](https://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/): When you run the script please make sure that you run it in different database then the one you want all the processes to be killed. CREATE TABLE #TmpWho (spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150), hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150)) INSERT INTO #TmpWho EXEC sp_who DECLARE @spid INT DECLARE @tString VARCHAR(15) DECLARE @getspid CURSOR SET @getspid =   CURSOR FOR SELECT spid FROM #TmpWho WHERE dbname = 'mydb'OPEN @getspid FETCH NEXT FROM @getspid INTO @spid WHILE @@FETCH_STATUS = 0 BEGIN SET @tString = 'KILL ' + CAST(@spid AS VARCHAR(5)) EXEC(@tString) FETCH NEXT FROM @getspid INTO @spid END CLOSE @getspid DEALLOCATE @getspid DROP TABLE #TmpWho... - [SQL SERVER - Simple Cursor to Select Tables in Database with Static Prefix and Date Created](https://blog.sqlauthority.com/2006/11/30/sql-server-cursor-to-process-tables-in-database-with-static-prefix-and-date-created/): Following cursor query runs through the database and find all the table with certain prefixed ('b_','delete_'). It also checks if the Table is more than certain days old or created before certain days, it will delete it. We can have any other operation on that table like to delete, print or index. - [SQL SERVER - Auto Generate Script to Delete Deprecated Fields in Current Database](https://blog.sqlauthority.com/2006/11/20/sql-server-auto-generate-script-to-delete-deprecated-fields-in-current-database/): I always mark fields to be deprecated with “dep_” as prefix. In this way, after few days, when I am sure that I do not need the field any more I run the query to auto generate the deprecation script. The script also checks for any constraint in the system and auto generate the script to drop it also. SELECT 'ALTER TABLE ['+po.name+'] DROP CONSTRAINT [' + so.name + ']' FROM sysobjects so INNER JOIN sysconstraints sc ON so.id = sc.constid INNER JOIN syscolumns col ON sc.colid = col.colid AND so.parent_obj = col.id AND col.name LIKE 'dep[_]%' INNER JOIN sysobjects po ON so.parent_obj = po.id WHERE so.xtype = 'D' ORDER BY po.name, col.name SELECT... - [SQL SERVER - Query to Find ByteSize of All the Tables in Database](https://blog.sqlauthority.com/2006/11/10/sql-server-query-to-find-byte-size/): SELECT CASE WHEN (GROUPING(sob.name)=1) THEN 'All_Tables'    ELSE ISNULL(sob.name, 'unknown') END AS Table_name,    SUM(sys.length) AS Byte_Length FROM sysobjects sob, syscolumns sys WHERE sob.xtype='u' AND sys.id=sob.id GROUP BY sob.name WITH CUBE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database](https://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/): UPDATE : SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database This is very long query. Optionally, we can limit the query to return results for one or more than one table. SELECT K_Table = FK.TABLE_NAME, FK_Column = CU.COLUMN_NAME, PK_Table = PK.TABLE_NAME, PK_Column = PT.COLUMN_NAME, Constraint_Name = C.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME INNER JOIN ( SELECT i1.TABLE_NAME, i2.COLUMN_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1 INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME WHERE i1.CONSTRAINT_TYPE = 'PRIMARY KEY' ) PT ON PT.TABLE_NAME = PK.TABLE_NAME ---- optional: ORDER BY 1,2,3,4 WHERE PK.TABLE_NAME='something'WHERE FK.TABLE_NAME='something'... - [SQLAuthority News - Microsoft SQL Server Compact 3.5 Server Tools Beta 2 Released](https://blog.sqlauthority.com/2007/08/03/sqlauthority-news-microsoft-sql-server-compact-35-server-tools-beta-2-released/): SQL Server Compact 3.5 Server Tools installs replication components on the IIS server enabling merge replication and remote data access (RDA) between SQL Server Compact 3.5 database on a Windows Desktop & Mobile devices and database servers running SQL Server 2005 and later versions of SQL Server 2005. Download SQL Server Compact 3.5 For more information please see the SQL Server Compact 3.5 Books Online Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Two Different Ways to Comment Code - Explanation and Example](https://blog.sqlauthority.com/2007/08/03/sql-server-two-different-ways-to-comment-code-explanation-and-example/): SQL Server has two different ways to comment code. Let us learn all of them here in this blog post. Various the options in the blog posts. - [SQLAuthority News - Book Review - SQL Server 2005 Practical Troubleshooting: The Database Engine](https://blog.sqlauthority.com/2007/08/02/sqlauthority-news-book-review-sql-server-2005-practical-troubleshooting-the-database-engine/): SQLAuthority.com Book Review : SQL Server 2005 Practical Troubleshooting: The Database Engine (SQL Server Series) (Paperback) by Ken Henderson Link to book on Amazon Short Review : Database Administrators can use this book on a daily basis in SQL Server 2005 troubleshooting and problem solving. Answers to SQL issues can be swiftly located using the index of this book.This book covers the topics and subjects which any other books, blogs or websites (including MSDN, BOL) do not cover. This book provides DBAs with solutions which can be used by user in highly dynamic environments to resolve common and specialized problems. This... - [SQL SERVER - FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details](https://blog.sqlauthority.com/2007/08/02/sql-server-fix-error-945-database-cannot-be-opened-due-to-inaccessible-files-or-insufficient-memory-or-disk-space-see-the-sql-server-error-log-for-details/): SQL SERVER – FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details This error is very common and many times, I have seen affect of this error as Suspected Database, Database Operation Ceased, Database Stopped transactions. Solution to this error is simple but very important. Fix/Solution/WorkAround: 1) If possible add more hard drive space either by removing of unnecessary files from hard drive or add new hard drive with larger size. 2) Check if the database is set to Autogrow on. 3) Check if... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Search SQL](https://blog.sqlauthority.com/2007/08/01/sql-server-sql-joke-sql-humor-sql-laugh-search-sql/): In meeting with DBA friends one of my friend suggested while searching for “MSSQL Client” Microsoft returns you suggestion as “MySQL Client“. I did not believe it so I tested it myself. He was correct. Here is the screen shot. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - July CTP Released](https://blog.sqlauthority.com/2007/08/01/sql-server-2008-july-ctp-released/): SQL Server 2008 July Community Technology Preview has been released. With SQL Server 2008 July CTP release, customers can immediately utilize new capabilities that support their mission-critical platform and enable pervasive insight across the enterprise. SQL Server 2008 lays the groundwork for innovative policy-based management that enables administrators to reduce their time spent on maintenance tasks. SQL Server 2008 provides enhancements in the SQL Server BI platform by enabling customers to provide up-to-date information with Change Data Capture and MERGE features, and develop highly scalable analysis services cubes with new development environments. - [SQLAuthority News - My Favorite Articles of This Blog](https://blog.sqlauthority.com/2007/07/31/sqlauthority-news-my-favorite-articles-of-this-blog/): The question I receive very often is I have more than 250 articles so far on this blog, which are my most favorite articles so far? Yesterday while talking with my parents on occasion of my birthday, they asked the same question to me. Answer is I keep running list of the my personal favorite articles on my personal website. I update it very frequently. Visit Author’s Personal Favorite Best Articles List Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Birthday of SQL Authority Author](https://blog.sqlauthority.com/2007/07/30/sqlauthority-news-birthday-of-sql-authority-author/): Today is Birthday of SQL Authority Author. Thought of the day : Family is everything. https://www.pinaldave.com/ http://www.SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Data Warehousing Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/07/29/sql-server-data-warehousing-interview-questions-and-answers-complete-list-download/): Click here to get free chapters (PDF) in the mailbox It was a great pleasure to write latest series about Data Warehousing Interview Questions and Answers. Just like always again, I received lots of suggestion and follow up questions. I have tried to accommodate all of them in the last post in the series. I hope this series is helpful to all candidates who are seeking a job as well interviewers. I have combined all the questions and answers in the one PDF which is available to download and refer at convenience. Complete Series of SQL Server Interview Questions and Answers... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/07/28/sql-server-data-warehousing-interview-questions-and-answers-part-3/): Click here to get free chapters (PDF) in the mailbox What are slowly changing dimensions (SCD)? SCD is abbreviation of Slowly changing dimensions. SCD applies to cases where the attribute for a record varies over time. There are three different types of SCD. 1) SCD1 : The new record replaces the original record. Only one record exist in database – current data. 2) SCD2 : A new record is added into the customer dimension table. Two records exist in database – current data and previous history data. 3) SCD3 : The original data is modified to include new data. One record... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/07/27/sql-server-data-warehousing-interview-questions-and-answers-part-2/): Click here to get free chapters (PDF) in the mailbox What are normalization forms? Please visit this article. Describes the foreign key columns in fact table and dimension table? Foreign keys of dimension tables are primary keys of entity tables. Foreign keys of facts tables are primary keys of Dimension tables. What is Data Mining? Data Mining is the process of analyzing data from different perspectives and summarizing it into useful information. What is the difference between view and materialized view? A view takes the output of a query and makes it appear like a virtual table and it can be... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/07/26/sql-server-data-warehousing-interview-questions-and-answers-part-1/): Let us learn about Data Warehousing Interview Questions and Answers. - [SQLAuthority News - Interesting Read - Programming Concepts, Structured Thinking Language (STL) and Relationary](https://blog.sqlauthority.com/2007/07/25/sqlauthority-news-interesting-read-programming-concepts-structured-thinking-language-stl-and-relationary/): I have always enjoyed reading articles and blogs which are different then others. There many be thousands of technology and programming blogs, only few makes difference in the tech world. One of the high quality blog, I enjoy reading is relationary by Grant Czerepak. Grant Czerepak is an IT professional with over 20 years experience in relational database technology specifically in the areas of design, development and administration. As per Grant Czerepak “In this blog I will be mixing, matching, shifting and sifting paradigms that have come up in my work with relational databases and other concepts I’ve picked up while... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/07/25/sql-server-data-warehousing-interview-questions-and-answers-introduction/): Click here to get free chapters (PDF) in the mailbox This series is in response to many of my reader’s continuous request to start Data Warehousing Interview Questions and Answers series. This series is written in the same spirit as previous two series which has received good response. Samples Question from Interview Questions and Answer Series What is Data Warehousing? A data warehouse is the main repository of an organization’s historical data, its corporate memory. It contains the raw material for management’s decision support system. The critical factor leading to the use of a data warehouse is that a data analyst... - [SQL SERVER - 2005 - Server and Database Level DDL Triggers Examples and Explanation](https://blog.sqlauthority.com/2007/07/24/sql-server-2005-server-and-database-level-ddl-triggers-examples-and-explanation/): Let's learn about Server and Database Level DDL Triggers Examples and Explanation here. Let us learn more about this topic. - [SQL SERVER - UDF - Function to Get Previous And Next Work Day - Exclude Saturday and Sunday](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-function-to-get-previous-and-next-work-day-exclude-saturday-and-sunday/): While reading ColdFusion blog of Ben Nadel Getting the Previous Day In ColdFusion, Excluding Saturday And Sunday, I realize that I use similar function on my SQL Server Database. This function excludes the Weekends (Saturday and Sunday), and it gets previous as well as next work day. - [SQL SERVER - UDF - Get the Day of the Week Function](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-get-the-day-of-the-week-function/): The day of the week can be retrieved in SQL Server by using the DatePart function. The value returned by function is between 1 (Sunday) and 7 (Saturday). To convert this to a string representing the day of the week, use a CASE statement. Method 1: Create function running following script: CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) SELECT @rtDayofWeek = CASE DATEPART(weekday,@dtDate) WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN 'Wednesday' WHEN 5 THEN 'Thursday' WHEN 6 THEN 'Friday' WHEN 7 THEN 'Saturday' END RETURN (@rtDayofWeek) END GO Call... - [SQLAuthority News - FQL - Facebook Query Language](https://blog.sqlauthority.com/2007/07/22/sqlauthority-news-fql-facebook-query-language/): I was exploring the new hype today, I found Facebook Developers Documentation very interesting. Facebook API can be queries using FQL - Facebook Query Language, which is similar to SQL. - [SQL SERVER - Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database 'yourdatabasename'. CREATE DATABASE is aborted.](https://blog.sqlauthority.com/2007/07/21/sql-server-fix-error-msg-1813-level-16-state-2-line-1-could-not-open-new-database-yourdatabasename-create-database-is-aborted/): Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database ‘yourdatabasename’. CREATE DATABASE is aborted. This errors happens when corrupt database log are attempted to attach to new server. Solution of this error is little long and it involves restart of the server. I recommend following all the steps below in order without skipping any of them. Fix/Solution/Workaround: SQL Server logs are corrupted and they need to be rebuilt to make the database operational. Follow all the steps in order. Replace the yourdatabasename name with real name of your database. 1. Create a new database... - [SQL SERVER - Fix : Error Msg 4214 - Error Msg 3013 - BACKUP LOG cannot be performed because there is no current database backup](https://blog.sqlauthority.com/2007/07/20/sql-server-fix-error-msg-4214-error-msg-3013-backup-log-cannot-be-performed-because-there-is-no-current-database-backup/): This is very interesting error as I could not found any documentation on-line. It took me nearly 1 hour to figure out what was creating error. - [SQL SERVER - 2005 - SSMS - View/Send Query Results to Text/Grid/Files](https://blog.sqlauthority.com/2007/07/19/sql-server-2005-ssms-viewsend-query-results-to-textgridfiles/): Many times I have been asked how to change the result window from Text to Grid and vice versa. There are three different ways to do it. Method 1 : Key-Board Short Cut Results to Text – CTRL + T Results to Grid – CTRL + D Results to File – CTRL + SHIFT + F Method 2 : Using Toolbar Method 3 : Using Menubar Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SPACE Function Example](https://blog.sqlauthority.com/2007/07/19/sql-server-space-function-example/): A month ago, I wrote about SQL SERVER – TRIM() Function – UDF TRIM() . I was asked in comment if SQL Server has space function? Yes. SELECT SPACE(100) will generate 100 space characters. The use of SPACE() function is demonstrated in BOL very fine. Example from BOL: USE AdventureWorks; GO SELECT RTRIM(LastName) + ',' + SPACE(2) + LTRIM(FirstName) FROM Person.Contact ORDER BY LastName, FirstName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Restore Database Without or With Backup - Everything About Restore and Backup](https://blog.sqlauthority.com/2007/07/18/sql-server-restore-database-without-or-with-backup-everything-about-restore-and-backup/): The questions I received in last two weeks: “I do not have backup, is it possible to restore database to previous state?” “How can restore the database without using backup file?” “I accidentally deleted tables in my database, how can I revert back?” “How to revert the changes, I have only logs but no complete backup?” “How to rollback the database changes, my backup file is corrupted?” Answer: You need complete backup to rollback your changes. If you do not have complete backup you can not revert back. Sorry. To restore the database to previous stage if you have full backup:... - [SQL SERVER - CASE Statement in ORDER BY Clause - ORDER BY using Variable](https://blog.sqlauthority.com/2007/07/17/sql-server-case-statement-in-order-by-clause-order-by-using-variable/): This article is as per request from Application Development Team Leader of my company. His team encountered code where application was preparing string for ORDER BY clause of SELECT statement. Application was passing this string as variable to Stored Procedure (SP) and SP was using EXEC to execute the SQL string. This is not good for performance as Stored Procedure has to recompile every time due to EXEC. sp_executesql can do the same task but still not the best performance. Previously: Application: Nesting logic to prepare variable OrderBy. Database: Stored Procedure takes variable OrderBy as input parameter. SP uses EXEC (or... - [SQL SERVER - Microsoft White Papers - Analysis Services Query Best Practices - Partial Database Availability](https://blog.sqlauthority.com/2007/07/16/sql-server-microsoft-white-papers-analysis-services-query-best-practices-partial-database-availability/): Microsoft TechNet frequently releases White Papers on SQL Server Technology. I have read the following two white papers recently. The summary of its content is here. Analysis Services Query Performance Top 10 Best Practices Optimize cube and measure group design Define effective aggregations Use partitions Write efficient MDX Use the query engine cache efficiently Ensure flexible aggregations are available to answer queries. Tune memory usage Tune processor usage Scale up where possible Scale out when you can no longer scale up Partial Database Availability Writer: Danny Tambs Download Word Document As databases become larger and larger, the infrastructure assets and technology... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - 15 Signs to Identify Bad DBA](https://blog.sqlauthority.com/2007/07/15/sql-server-sql-joke-sql-humor-sql-laugh-15-signs-to-identify-bad-dba/): 15 Signs to Identify Bad DBA They think it is bug in SQL Server when two NULL values compared with each other but SQL Server does not say they equal to each other. They do not rename the trigger name thinking it will not work after it is rename. They are looking for difference between Index Scan or Table Scan on Google. They reinstall the SQL Server if they forget the password of SA login. They use model database for testing their script. They believe compiled stored procedure is production ready. They prefix all stored procedures with ‘sp_’ to be consistent... - [SQL SERVER - 2005 Collation Explanation and Translation - Part 2](https://blog.sqlauthority.com/2007/07/14/sql-server-2005-collation-explanation-and-translation-part-2/): Following function return all the available collation of SQL Server 2005. My previous article about the SQL SERVER – 2005 Collation Explanation and Translation. SELECT * FROM sys.fn_HelpCollations() Result Set: (only few of 1011 records) Name Description Latin1_General_BIN Latin1-General, binary sort Latin1_General_BIN2 Latin1-General, binary code point comparison sort Latin1_General_CI_AI Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AI_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AI_KS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AI_KS_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-sensitive Latin1_General_CI_AS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AS_KS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AS_KS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-sensitive Latin1_General_CS_AI Latin1-General, case-sensitive, accent-insensitive, kanatype-insensitive,... - [SQL SERVER - 2005 - Use ALTER DATABASE MODIFY NAME Instead of sp_renameDB to rename](https://blog.sqlauthority.com/2007/07/13/sql-server-2005-use-alter-database-modify-name-instead-of-sp_renamedb-to-rename/): To rename database it is very common to use for SQL Server 2000 user : EXEC sp_renameDB 'oldDB','newDB' sp_renameDB syntax will be deprecated in the future version of SQL Server. It is supported in SQL Server 2005 for backwards compatibility only. It is recommended to use ALTER DATABASE MODIFY NAME instead. New syntax of ALTER DATABASE MODIFY NAME is simple as well. /* Create Test Database */ CREATE DATABASE Test GO /* Rename the Database Test to NewTest */ ALTER DATABASE Test MODIFY NAME = NewTest GO /* Cleanup NewTest Database Do not run following command if you want to use the database. It is dropped here for sample database clean up. */ DROP DATABASE NewTest GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Validate Field For DATE datatype using function ISDATE()](https://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/): This article is based on the a question from Jr. Developer at my company. He works with the system, where we import CSV file in our database. One of the fields in the database is DATETIME field. Due to architecture requirement, we insert all the CSV fields in the temp table which has all the fields VARCHAR. We validate all the data first in temp table (check for inconsistency, malicious code, incorrect data type) and if passed validation we insert them in the final table in the database. Let us learn about ISDate function in this blog post. - [SQLAuthority News - SQL Blog SQLAuthority.com Comment by Mr. Ben Forta](https://blog.sqlauthority.com/2007/07/11/sqlauthority-news-sql-blog-sqlauthoritycom-comment-by-mr-ben-forta/): Today is one of the most glorious day for SQLAuthority.com in history. Famous author of Sams Teach Yourself Microsoft SQL Server T-SQL In 10 Minutes, ColdFusion Guru, and well known evangelists Mr. Ben Forta has made comment on his blog about SQLAuthority.com. I encourage all my readers to visit comment link here. I am very thankful to Mr. Forta for finding time to visit my blog from his busy schedule. I am attaching screen shot of the original post along with this post for reference. Mr. Forta said, “Pinalkumar Dave is a DBA with extensive SQL Server (and ColdFusion) experience. I... - [SQL SERVER - 2005 - Features Comparison Chart](https://blog.sqlauthority.com/2007/07/11/sql-server-2005-features-comparison-chart/): This post in the response to all the readers who have asked what are the differences between SQL Server 2005 editions. The reason I have never posted article about this as Microsoft has wonderful comparison chart on Microsoft SQL Server web site. This chart explains the difference between features of Express, Workgroup, Standard, and Enterprise editions. Visit Microsoft SQL Server 2005 Editions Features Comparison Chart Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Scheduled Launch at an Event in Los Angeles on Feb. 27, 2008](https://blog.sqlauthority.com/2007/07/11/sql-server-2008-scheduled-launch-at-an-event-in-los-angeles-on-feb-27-2008/): SQL SERVER 2008 will be launched at an Event in Los Angeles on Feb. 27, 2008. “In anticipation for the most significant Microsoft enterprise event in the next year, Turner announced that Windows Server® 2008, Visual Studio® 2008 and Microsoft SQL Server™ 2008 will launch together at an event in Los Angeles on Feb. 27, 2008, kicking off hundreds of launch events around the world.” Read original article here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Count Duplicate Records - Rows](https://blog.sqlauthority.com/2007/07/11/sql-server-count-duplicate-records-rows/): In my previous article SQL SERVER – Delete Duplicate Records – Rows, we have seen how we can delete all the duplicate records in one simple query. In this article we will see how to find count of all the duplicate records in the table. Following query demonstrates usage of GROUP BY, HAVING, ORDER BY in one query and returns the results with duplicate column and its count in descending order. SELECT YourColumn, COUNT(*) TotalCount FROM YourTable GROUP BY YourColumn HAVING COUNT(*) > 1 ORDER BY COUNT(*) DESC Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com)... - [SQL SERVER - 2005 - List All Stored Procedure Modified in Last N Days](https://blog.sqlauthority.com/2007/07/10/sql-server-2005-list-all-stored-procedure-modified-in-last-n-days/): I usually run following script to check if any stored procedure was deployed on live server without proper authorization in last 7 days. If SQL Server suddenly start behaving in un-expectable behavior and if stored procedure were changed recently, following script can be used to check recently modified stored procedure. If stored procedure was created but never modified afterwards modified date and create date for that stored procedure are same. SELECT name FROM sys.objects WHERE type = 'P' AND DATEDIFF(D,modify_date, GETDATE()) < 7 ----Change 7 to any other day value Following script will provide name of all the stored procedure which... - [SQL SERVER - Result of EXP (Exponential) to the POWER of PI - Functions Explained](https://blog.sqlauthority.com/2007/07/09/sql-server-result-of-exp-exponential-to-the-power-of-pi-functions-explained/): SQL Server can do some intense Mathematical calculations. Following are three very basic and very necessary functions. All the three function does not need explanation. I will not introduce their definition but will demonstrate the usage of function. SELECT PI() GO SELECT POWER(2,5) GO SELECT POWER(8,-2) GO SELECT EXP(99) GO SELECT EXP(1) GO Results Set : PI ———————- 3.14159265358979 PowerEg1 ———– 32 PowerEg2 ———– 0 ExpEg1 ———————- 9.88903031934695E+42 ExpEg2 ———————- 2.71828182845905 Now the Questions asked in the Title of the Article – What is the result of EXP to the POWER of PI SELECT POWER(EXP(1), PI()) GO Results ———————- 23.1406926327793 Reference... - [SQL SERVER - FIX : ERROR Msg 244, Level 16, State 1 - FIX : ERROR Msg 245, Level 16, State 1](https://blog.sqlauthority.com/2007/07/08/sql-server-fix-error-msg-244-level-16-state-1-fix-error-msg-245-level-16-state-1/): FIX : ERROR Msg 244, Level 16, State 1, Line 1 FIX : ERROR Msg 245, Level 16, State 1, Line 1 This error can happen due to conversion of one data type to incompatible datatype. Few examples are: VARCHAR to INT, INT to TINYINT etc. I have spotted this error happening with CAST or ISNULL, please add comments if you have come across this error in other examples. Following scripts will create this error. SELECT CAST('111111' AS SMALLINT); SELECT CAST('This is not smallint' AS SMALLINT); The errors received from above two scripts are : Msg 244, Level 16, State 2,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Generic Quotes](https://blog.sqlauthority.com/2007/07/08/sql-server-sql-joke-sql-humor-sql-laugh-generic-quotes/): Few days ago, in meeting I was forced to answer one of the question from non-programmer was considered as funny quotes for long time. “Yes it is latest year 2005 version of SQL Server – still it will not play your flash movie” — Pinal Dave (SQLAuthority.com) Many of following quotes are well apply to SQL Server or any database and I find them humorous. Software is Too Important to be Left to Programmers — Meilir Page-Jones. A clever person solves a problem. A wise person avoids it. — Einstein If you think good architecture is expensive, try bad architecture. —... - [SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT](https://blog.sqlauthority.com/2007/07/07/sql-server-convert-text-to-numbers-integer-cast-and-convert/): Few of the questions I receive very frequently. I have collect them in spreadsheet and try to answer them frequently. How to convert text to integer in SQL? If table column is VARCHAR and has all the numeric values in it, it can be retrieved as Integer using CAST or CONVERT function. How to use CAST or CONVERT? SELECT CAST(YourVarcharCol AS INT) FROM Table SELECT CONVERT(INT, YourVarcharCol) FROM Table Will CAST or CONVERT thrown an error when column values converted from alpha-numeric characters to numeric? YES. Will CAST or CONVERT retrieve only numbers when column values converted from alpha-numeric characters to... - [SQL SERVER - FIX : Error : msg 8115, Level 16, State 2, Line 2 - Arithmetic overflow error converting expression to data type](https://blog.sqlauthority.com/2007/07/06/sql-server-fix-error-msg-8115-level-16-state-2-line-2-arithmetic-overflow-error-converting-expression-to-data-type/): Following errors can happen when any field in the database is attempted to insert or update larger data of the same type or other data type. Msg 8115, LEVEL 16, State 2, Line 2 Arithmetic overflow error converting expression TO data type <ANY DataType> Example is if integer 111111 is attempted to insert in TINYINT data type it will throw above error, as well as if integer 11111 is attempted to insert in VARCHAR(2) data type it will throw above error. Fix/Solution/Workaround: 1) Verify the inserted/updated value that it is of correct length and data type. 2) If inserted/updated value are... - [SQL SERVER - 2005 - Microsoft Document Explorer cannot be shown because the specified help collection 'ms-help://MS.SQLCC.v9](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-microsoft-document-explorer-cannot-be-shown-because-the-specified-help-collection-ms-helpmssqlccv9/): I have received six emails in last four days asking for the resolution of error when tried to open newly installed SQL Server Book On-Line. Microsoft Document Explorer cannot be shown because the specified help collection ‘ms-help://MS.SQLCC.v9 1) Uninstall the versions of Book On-line (different languages, different releases etc) using Add-Remove programs tools. 2) Re-install SQL Server Book On-line. Above solution is confirmed by MSDN site here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Best Practices Analyzer Tutorial - Sample Example](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-best-practices-analyzer-tutorial-sample-example/): Yesterday I posted small note about SQL SERVER – 2005 Best Practices Analyzer (July BPA). I received many request about how BPA is used. Some of readers has asked me to provide sample tutorial which can help start using BPA. This utility has many uses for best practice. I have created very simple and initial tutorial. I encourage to follow that and once used it create your own reports in your desired format. Do not hesitate to install this add-on as I have use this previously to tune our production servers. Following tutorial about BPA is ran on one of my... - [SQL SERVER - 2005 Best Practices Analyzer (July BPA)](https://blog.sqlauthority.com/2007/07/04/sql-server-2005-best-practices-analyzer-july-bpa/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD HERE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Definition, Comparison and Difference between HAVING and WHERE Clause](https://blog.sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/): In recent interview sessions in hiring process I asked this question to every prospect who said they know basic SQL. Surprisingly, none answered me correct. They knew lots of things in details but not this simple one. One prospect said he does not know cause it is not on this Blog. Well, here we are with same topic online. Answer in one line is : HAVING specifies a search condition for a group or an aggregate function used in SELECT statement. HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP... - [SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable](https://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/): #TempTable and @TempVariable are different things with different scope. Their purpose is different but highly overlapping. TempTables are originated for the storage and & storage & manipulation of temporal data. TempVariables are originated (SQL Server 2000 and onwards only) for returning date-sets from table-valued functions. Common properties of #TempTable and @TempVariable They are instantiated in tempdb. They are backed by physical disk. Changes to them are logged in the transaction log1. However, since tempdb always uses the simple recovery model, those transaction log records only last until the next tempdb checkpoint, at which time the tempdb log is truncated. Discussion of... - [SQL SERVER - 2005 Comparison SP_EXECUTESQL vs EXECUTE/EXEC](https://blog.sqlauthority.com/2007/07/02/sql-server-2005-comparison-sp_executesql-vs-executeexec/): Common Properties of SP_EXECUTESQL and EXECUTE/EXEC The Transact-SQL statements in the sp_executesql or EXECUTE string are not compiled into an execution plan until sp_executesql or the EXECUTE statement are executed. The strings are not parsed or checked for errors until they are executed. The names referenced in the strings are not resolved until they are executed. The Transact-SQL statements in the executed string do not have access to any of the variables declared in the batch that contains thesp_executesql or EXECUTE statement. The batch containing the sp_executesql or EXECUTE statement does not have access to variables or local cursors defined in... - [SQL SERVER - Explanation of WITH ENCRYPTION clause for Stored Procedure and User Defined Functions](https://blog.sqlauthority.com/2007/07/01/sql-server-explanation-of-with-encryption-clause-for-stored-procedure-and-user-defined-functions/): This article is written to answer following two questions I have received in last one week. Questions 1) How to hide code of my Stored Procedure that no one can see it? 2) Our DBA has left the job and one of the function which retrieves important information is encrypted, how can we decrypt it and find original code? Answers 1) Use WITH ENCRYPTION while creating Stored Procedure or User Defined Function. 2) Sorry, unfortunately there is no simple way to decrypt the code. Hard way is too hard to even attempt. Explanations of WITH ENCRYPTION clause If SP or UDF... - [SQL SERVER - Fix : Error : Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type 'varchar' exceeds the maximum allowed for any data type (8000)](https://blog.sqlauthority.com/2007/06/30/sql-server-fix-error-server-msg-131-level-15-state-3-line-1-the-size-given-to-the-type-varchar-exceeds-the-maximum-allowed-for-any-data-type-8000/): Error: Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type ‘varchar’ exceeds the maximum allowed for any data type (8000) When the the length is specified in declaring a VARCHAR variable or column, the maximum length allowed is still 8000. Fix/WorkAround/Solution: Use either VARCHAR(8000) or VARCHAR(MAX) . VARCHAR(MAX) of SQL Server 2005 is replacement of TEXT of SQL Server 2000. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recompile All The Stored Procedure on Specific Table](https://blog.sqlauthority.com/2007/06/29/sql-server-recompile-all-the-stored-procedure-on-specific-table/): I have noticed that after inserting many rows in one table many times the stored procedure on that table executes slower or degrades. This happens quite often after BCP or DTS. I prefer to recompile all the stored procedure on the table, which has faced mass insert or update. sp_recompiles marks stored procedures to recompile when they execute next time. Example: ----Following script will recompile all the stored procedure on table Sales.Customer in AdventureWorks database. USE AdventureWorks; GO EXEC sp_recompile N'Sales.Customer'; GO ----Following script will recompile specific stored procedure uspGetBillOfMaterials only. USE AdventureWorks; GO EXEC sp_recompile 'uspGetBillOfMaterials'; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - 2005 Improvements in TempDB](https://blog.sqlauthority.com/2007/06/28/sql-server-2005-improvements-in-tempdb/): Following are some important improvements in tempdb in SQL Server 2005 over SQL Server 2000 Input/Output traffic to TempDB is reduced as logging is improved. In SQL Server 2005 TempDB does not log “after value” everytime. E.g. For INSERT it does not log after value on log as that will be any way logged in the TempTable. Similar for DELETE as It does not have to log After value as it is not there. This is big improvement in performance in SQL Server 2005 for TempDB. Some other improvement in File System of operating system. (I am not listing them as... - [SQL SERVER - Running Batch File Using T-SQL - xp_cmdshell bat file](https://blog.sqlauthority.com/2007/06/27/sql-server-running-batch-file-using-t-sql/): In last month I received few emails emails regarding SQL SERVER – Enable xp_cmdshell using sp_configure. The questions are 1) What is the usage of xp_cmdshell and 2) How to execute BAT file using T-SQL? I really like the follow up questions of my posts/articles. Answer is xp_cmdshell can execute shell/system command, which includes batch file. 1) Example of running system command using xp_cmdshell is SQL SERVER – Script to find SQL Server on Network EXEC master..xp_CMDShell 'ISQL -L' 2) Example of running batch file using T-SQL i) Running standalone batch file (without passed parameters) EXEC master..xp_CMDShell 'c:findword.bat' ii) Running parameterized batch... - [SQL SERVER - 2005 List All Tables of Database](https://blog.sqlauthority.com/2007/06/26/sql-server-2005-list-all-tables-of-database/): This is very simple and can be achieved using system table sys.tables. USE YourDBName GO SELECT * FROM sys.Tables GO This will return all the tables in the database which user have created. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Explanation and Example Four Part Name](https://blog.sqlauthority.com/2007/06/26/sql-server-explanation-and-example-four-part-name/): What is four part name? Explanation : ServerName.DatabaseName.DatabaseOwner.TableName Example : localhost.AdventureWorks.Person.Contact Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Repeate String N Times Using String Function REPLICATE](https://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/): I came across this SQL String Function few days ago while searching for Database Replication. This is T-SQL Function and it repeats the string/character expression N number of times specified in the function. SELECT REPLICATE( ' https://blog.sqlauthority.com/ ' , 9 ) This repeats the string https://blog.sqlauthority.com/ to 9 times in result window. I think it is fun utility to generate repeated text if ever required. Result Set: https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com/) , BOL - [SQLAuthority News - Book Review - Microsoft(R) SQL Server 2005 Unleashed (Paperback)](https://blog.sqlauthority.com/2007/06/24/sqlauthority-news-book-review-microsoftr-sql-server-2005-unleashed-paperback/): SQLAuthority.com Book Review : Microsoft(R) SQL Server 2005 Unleashed (Paperback) by Ray Rankins, Paul Bertucci, Chris Gallelli, Alex T. Silverstein Link to book on Amazon Short Review : SQL Server 2005 Unleashed is focused on Database Administration and day-to-day administrative management aspects of SQL Server. All the chapters of this book are heavily based on Book On-line (BOL) and it continue discussing the topics, where BOL leaves off. This makes this book a good reference for those who are looking for additional information, tricks & tips, and behind the scene details. I recommend this book as a wonderful read and hands-on... - [SQL SERVER - Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild - SQL SERVER 2000 and SQL SERVER 2005](https://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/): Index Fragmentation: When a page of data fills to 100 percent and more data must be added to it, a page split occurs. To make room for the new data, SQL Server must move half of the data from the full page to a new page. The new page that is created is created after all the pages in database. Therefore, instead of going right from one page to the next when looking for data, SQL Server has to go one page to another page around the database looking for the next page it needs. This is Index Fragmentation. Severity of... - [SQL SERVER - 2005 Row Overflow Data Explanation](https://blog.sqlauthority.com/2007/06/23/sql-server-2005-row-overflow-data-explanation/): In SQL Server 2000 and SQL Server 2005 a table can have a maximum of 8060 bytes per row. One of my fellow DBA said that he believed that SQL Server 2000 had that restriction but SQL Server 2005 does not have that restriction and it can have a row of 2GB. I totally agreed with him but after we discussed this problem in depth, we realized that there are more into it than only 8060 bytes limit. It is still true for SQL Server 2005 that a table can have maximum of 8060 bytes per row however the restriction has... - [SQL SERVER - Explanation and Comparison of NULLIF and ISNULL](https://blog.sqlauthority.com/2007/06/22/sql-server-explanation-and-comparison-of-nullif-and-isnull/): Explanation of NULLIF Syntax: NULLIF ( expression , expression ) Returns a null value if the two specified expressions are equal. NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression. NULLIF is equivalent to a searched CASE function in which the two expressions are equal and the resulting expression is NULL. - [SQLAuthority.com News - iGoogle Gadget Published](https://blog.sqlauthority.com/2007/06/21/sqlauthoritycom-news-igoogle-gadget-published/): I have recently received many requests to add an iGoogle Gadget so it can be integrated on iGoogle home page so I’ve gone ahead and done so: Add iGoogle Gadget Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Retrieve Current DateTime in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}](https://blog.sqlauthority.com/2007/06/21/sql-server-retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/): There are three ways to retrieve the current datetime in SQL SERVER. CURRENT_TIMESTAMP, GETDATE(), {fn NOW()} - [SQL SERVER - Find Length of Text Field](https://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/): To measure the length of VARCHAR fields the function LEN(varcharfield) is useful. To measure the length of TEXT fields the function is DATALENGTH(textfield). Len will not work for text field. Example: SELECT DATALENGTH(yourtextfield) AS TEXTFieldSize Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com News - Journey to SQL Authority Milestone of SQL Server](https://blog.sqlauthority.com/2007/06/19/sqlauthoritycom-news-journey-to-sql-authority-milestone-of-sql-server/): SQLAuthority.com News – Journey to SQL Authority Milestone of SQL Server I am very glad to write this 200th post of this blog. I would like to express my gratitude to all of YOU – my readers for continuously reading this blog. I receive many comments and emails with feedback, questions and suggestion everyday. I enjoy meeting few of you during this journey as well. Please do send me feedback and your request to make this blog better. Following is milestone of Journey to SQL Authority. SQL Server Interview Questions and Answers Complete List Download (PDF) SQL Server Database Coding Standards... - [SQL SERVER - Delay Function - WAITFOR clause - Delay Execution of Commands](https://blog.sqlauthority.com/2007/06/18/sql-server-delay-function-waitfor-clause-delay-execution-of-commands/): Blocks the execution of a batch, stored procedure, or transaction until a specified time or time interval is reached, or a specified statement modifies or returns at least one row. This is very useful. Every day when I restore the database to backup server for reports post processing, I use WAITFOR clause. While executing the WAITFOR statement, the transaction is running and no other requests can run under the same transaction. If the server is busy, the thread may not be immediately scheduled; therefore, the time delay may be longer than the specified time. WAITFOR can be used with query but... - [SQL SERVER - De-fragmentation of Database at Operating System to Improve Performance](https://blog.sqlauthority.com/2007/06/17/sql-server-de-fragmentation-of-database-at-operating-system-to-improve-performance/): This issues was brought to me by our Sr. Network Engineer. While running operating system level de-fragmentation using either windows de-fragmentation or third party tool it always skip all the MDF file and never de-fragment them. He was wondering why this happens all the time. The reason MDF file are skipped all the time in de-fragmentation because they are in use when SQL Server is running. Windows operating system de-fragmentation skips all the file in are currently in use. After discovering this the real question was how to de-fragment when files are in use. Steps are Stop the Server, Re-start, keep... - [SQL SERVER - 2005 - UDF - User Defined Function to Strip HTML - Parse HTML - No Regular Expression](https://blog.sqlauthority.com/2007/06/16/sql-server-udf-user-defined-function-to-strip-html-parse-html-no-regular-expression/): One of the developers at my company asked is it possible to parse HTML and retrieve only TEXT from it without using regular expression. He wanted to remove everything between < and > and keep only Text. I found the question very interesting and quickly wrote UDF which does not use regular expression. Let us see how to parse HTML without regular expression. - [SQL SERVER - sp_HelpText for sp_HelpText - Puzzle](https://blog.sqlauthority.com/2007/06/15/sql-server-sp_helptext-for-sp_helptext-puzzle/): It was interesting to me. I was using sp_HelpText to see the text of the stored procedure. Stored Procedure were different so I had copied sp_HelpText on my clipboard and was pasting it in Query Editor of Management Studio. In rush I typed twice sp_HelpText and hit F5. Result was interesting. What are your guesses? My team mates and few of my readers suggested : SQL Server will be in recursive loop, SQL Server will be not responde, SQL Server will throw an error. Try this: sp_HelpText sp_HelpText Result was as expected. SQL Server did its job and displayed the text... - [SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases - Part 2](https://blog.sqlauthority.com/2007/06/15/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases-part-2/): I have mentioned the history of NorthWind, Pubs and AdventureWorks in my previous post SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases. I have been receiving very frequent request for NorthWind Database for SQL Server 2005 and installation method. - [SQL SERVER - Easy Sequence of SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY](https://blog.sqlauthority.com/2007/06/14/sql-server-easy-sequence-of-select-from-join-where-group-by-having-order-by/): I was called many times by Jr. Programmers in team to debug their SQL. I keep log of most of the problems and review them afterwards. This helps me to evaluate my team and identify most important next thing which I can do to improve the performance and productivity of it. Recently we have many new hires and they had almost similar questions. Since, I have send them following sequence of the SELECT clause I am not interrupted often, which helps me to focus on larger project architectural design. SELECT yourcolumns FROM tablenames JOIN tablenames WHERE condition GROUP BY yourcolumns HAVING... - [SQL SERVER - Explanation SQL SERVER Hash Join](https://blog.sqlauthority.com/2007/06/14/sql-server-explanation-sql-server-hash-join/): Hash Join works with large data set. I have seen this join used many times in data warehouses applications as well as data mining algorithms. While its characteristics are similar to merge join it does not required ordered result set to join. Hash join requiresequijoin predicate to join tables. Equijoin predicate is comparing values between one table to other table using “equals to” (“=”) operator. Hash join gives best performance when two more join tables are joined and at-least one of them have no index or is not sorted. It is also expected that smaller of the either of table can... - [SQL SERVER - Fix : Error 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time.](https://blog.sqlauthority.com/2007/06/13/sql-server-fix-error-8629-the-query-processor-could-not-produce-a-query-plan-from-the-optimizer-because-a-query-cannot-update-a-text-ntext-or-image-column-and-a-clustering-key-at-the-same-time/): Error : 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time. - [SQL SERVER - Download 2005 Books Online (May 2007)](https://blog.sqlauthority.com/2007/06/13/sql-server-download-2005-books-online-may-2007/): Microsoft has merged SQL Server 2005 Expressed to SQL Server 2005 Books Online. New Version of SQL Server 2005 Books Online is released on June 12, 2007. Download SQL Server Books Online (BOL) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recovery Models and Selection](https://blog.sqlauthority.com/2007/06/13/sql-server-recovery-models-and-selection/): SQL Server offers three recovery models: full recovery, simple recovery and bulk-logged recovery. The recovery models determine how much data loss is acceptable and determines whether and how transaction logs can be backed up. Select Simple Recovery Model if: * Your data is not critical. * Losing all transactions since the last full or differential backup is not an issue. * Data is derived from other data sources and is easily recreated. * Data is static and does not change often. Select Bulk-Logged Recovery Model if: * Data is critical, but logging large data loads bogs down the system. * Most... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2007/06/12/sql-server-sql-joke-sql-humor-sql-laugh-funny-quotes/): While searching WIKI I came across this oracle WIKI. I found this very funny. I have taken few quotes from this site. There are lot more stuff there. The degree of normality in a database is inversely proportional to that of its DBA. Program complexity grows until it exceeds the capability of the programmer who must maintain it. “Walking on water and developing software from a specification are easy if both are frozen.” — Edward V. Berard, “Life-Cycle Approaches” “Technology is dominated by two types of people: those who understand what they do not manage, and those who manage what they... - [SQL SERVER - LEN and DATALENGTH of NULL Simple Example](https://blog.sqlauthority.com/2007/06/12/sql-server-len-and-datalength-of-null-simple-example/): Simple but interesting – In recent survey I found that many developers making this generic mistake. I have seen following code in periodic code review. (The code below is not actual code, it is simple sample code) DECLARE @MyVar VARCHAR(10) SET @MyVar = NULL IF (LEN(@MyVar) = 0) … I decided to send following code to them. After running the following sample code it was clear that LEN of NULL values is not 0 (Zero) but it is NULL. Similarly, the result for DATALENGTH function is the same. DATALENGTH of NULL is NULL. Sample Test Version: DECLARE @MyVar VARCHAR(10) SET @MyVar... - [SQL SERVER - Cannot Resolve Collation Conflict For Equal to Operation](https://blog.sqlauthority.com/2007/06/11/sql-server-cannot-resolve-collation-conflict-for-equal-to-operation/): Cannot resolve collation conflict for equal to operation. In MS SQL SERVER, the collation can be set at the column level. - [SQL SERVER - 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) - CTE vs. Derived Table](https://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/): I have received few emails and comments about my post SQL SERVER – T-SQL Paging Query Technique Comparison – SQL 2000 vs SQL 2005. The main question was is this can be done using CTE? Absolutely! What about Performance? It is same! Please refer above mentioned article for history of paging. - [SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice](https://blog.sqlauthority.com/2007/06/10/sql-server-retrieve-select-only-date-part-from-datetime-best-practice/): Just a week ago, my Database Team member asked me what is the best way to only select date part from datetime. When ran following command it also provide the time along with the date. - [SQL SERVER - Fix : Error : An error has occurred while establishing a connect to the server. Solution with Images.](https://blog.sqlauthority.com/2007/06/10/sql-server-fix-error-an-error-has-occurred-while-establishing-a-connect-to-the-server-solution-with-images/): While reviewing my my blog search engine terms I find Error 40 is the most common error searched. I have previously wrote blog about how to fix this error here : SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server. Today I have added few screen shot of that error and their solution to help readers who need additional help to understand my post. Error Screen: Solution Part 1: Enable SQL Server Service Solution Part 2: Enable TCP/IP Protocol Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 9514 Xml data type is not supported in distributed queries. Remote object 'OPENROWSET' has xml column(s)](https://blog.sqlauthority.com/2007/06/09/sql-server-fix-error-msg-9514-level-16-state-1-line-1-xml-data-type-is-not-supported-in-distributed-queries-remote-object-openrowset-has-xml-columns/): In this blog post we are going to learn how to fix XML Data Type related error. - [SQL SERVER - Spatial Database Definition and Research Documents](https://blog.sqlauthority.com/2007/06/09/sql-server-spatial-database-definition-and-research-documents/): Recently I was asked in meeting of SQL SERVER user group, what my opinion about spatial database. I answered from my basic knowledge. Spatial database is like database of space (not the star wars or star trek kind space). SQL Server database can understand the numeric and string values. If we ask to SQL Server what is multiplication of 6 and 3 it will provide answer as 18. If we ask to SQL Server what is distance between two points in polygon, it will be not able to answer using native functions. Custom SQL code written by user can do similar... - [SQL SERVER - UDF - Function to Display Current Week Date and Day - Weekly Calendar](https://blog.sqlauthority.com/2007/06/08/sql-server-udf-function-to-display-current-week-date-and-day-weekly-calendar/): In analytics section of our product I frequently have to display the current week dates with days. Week starts from Sunday. We display the data considering days as column and date and other values in column. If today is Friday June 8, 2007. We need script which can provides days and dates for current week. Following script will generate the required script. DECLARE @day INT DECLARE @today SMALLDATETIME SET @today = CAST(CONVERT(VARCHAR(10), GETDATE(), 101) AS SMALLDATETIME) SET @day = DATEPART(dw, @today) SELECT DATEADD(dd, 1 - @day, @today) Sunday, DATEADD(dd, 2 - @day, @today) Monday, DATEADD(dd, 3 - @day, @today) Tuesday, DATEADD(dd,... - [SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL](https://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/): Update: For SQL Server 2008 there is even better method of Row Construction, please read it here : SQL SERVER – 2008 – Insert Multiple Records Using One Insert Statement – Use of Row Constructor This is very interesting question I have received from new developer. How can I insert multiple values in table using only one insert? Now this is interesting question. When there are multiple records are to be inserted in the table following is the common way using T-SQL. - [SQL SERVER - 2005 Download New Updated Book On Line (BOL)](https://blog.sqlauthority.com/2007/06/07/sql-server-2005-download-new-updated-book-on-line-bol/): Book On Line the primary source for help for many developers has been updated. It now includes the updates till SP2 release. I use book on line for accuracy for my definition and information on this blog. Download Book On Line (Update June 4th, 2007) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 (Katmai) June CTP Released - Improvement Pillars - Diagram](https://blog.sqlauthority.com/2007/06/07/sql-server-2008-katmai-june-ctp-released-improvement-pillars-diagram/): I received quite a few emails in last three days for not mentioning on my blog about SQL Server 2008 (Katmai) CPT June is released. The reason I did not mentioned because I was busy with my mini series SQL SERVER – Database Coding Standards and Guidelines Complete List Download. SQL Server 2008 (Katmai) June CTP (Community Technology Preview) is announced in TechNet 2007 and is available to download. SQL Server 2008 June CTP enables customers to immediately utilize new capabilities that support their mission-critical platform. The chart below explains important improvements coming online with each CTP. Please visit SQL Server... - [SQL SERVER - Fix : Error : Error 15401: Windows NT user or group 'username' not found. Check the name again.](https://blog.sqlauthority.com/2007/06/07/sql-server-fix-error-error-15401-windows-nt-user-or-group-username-not-found-check-the-name-again/): Fix : Error : Error 15401: Windows NT user or group ‘username’ not found. Check the name again. This is quite a famous error and I was asked to write about it by couple of readers. The reason I was not writing about this as the solution of this error is very well explained in Book On Line. All the potential causes and their solutions are explained well here. This post/article should be considered as book mark to solution. Fix/WorkAround/Solution: Refere Microsoft Help and Support : How to troubleshoot error 15401 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Database Coding Standards and Guidelines Complete List Download](https://blog.sqlauthority.com/2007/06/06/sql-server-database-coding-standards-and-guidelines-complete-list-download/): Download SQL SERVER Database Coding Standards and Guidelines Complete List - [SQL SERVER - Database Coding Standards and Guidelines - Part 2](https://blog.sqlauthority.com/2007/06/05/sql-server-database-coding-standards-and-guidelines-part-2/): SQL Server Database Coding Standards and Guidelines - Part 2 - [SQL SERVER - Database Coding Standards and Guidelines - Part 1](https://blog.sqlauthority.com/2007/06/04/sql-server-database-coding-standards-and-guidelines-part-1/): SQL Server Database Coding Standards and Guidelines - Part 1 - [SQL SERVER - Database Coding Standards and Guidelines - Introduction](https://blog.sqlauthority.com/2007/06/03/sql-server-database-coding-standards-and-guidelines-introduction/): I have received many many request to do another series since my series SQL Server Interview Questions and Answers Complete List Download. I have created small series of Coding Standards and Guidelines, as this is the second most request I have received from readers. This document can be extremely long but I have limited to very few pages as it is difficult to follow thousands of the rules. My experience says it is more productive developer and better code if coding standard has important fewer rules than lots of micro rules. - [SQL SERVER - 2005 Explanation and Example - SELF JOIN](https://blog.sqlauthority.com/2007/06/03/sql-server-2005-explanation-and-example-self-join/): A self-join is simply a normal SQL join that joins one table to itself. This is accomplished by using table name aliases to give each instance of the table a separate name. Joining a table to itself can be useful when you want to compare values in a column to other values in the same column. A join in which records from a table are combined with other records from the same table when there are matching values in the joined fields. A self-join can be an inner join or an outer join. A table is joined to itself based upon... - [SQL SERVER - 2005 - Microsoft SQL Server Management Pack for Microsoft Operations Manager 2005 - Download SQL Server MOM 2005](https://blog.sqlauthority.com/2007/06/02/sql-server-2005-microsoft-sql-server-management-pack-for-microsoft-operations-manager-2005-download-sql-server-mom-2005/): The Microsoft SQL Server Management Pack provides both proactive and reactive monitoring of SQL Server 2005 and SQL Server 2000 in an enterprise environment. Availability and configuration monitoring, performance data collection, and default thresholds are built for enterprise-level monitoring. Both local and remote connectivity checks help ensure database availability. Features description are available online. Download SQL Server MOM 2005 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Subscribe to Feed in Email](https://blog.sqlauthority.com/2007/06/02/sqlauthority-news-subscribe-to-feed-in-email/): You can subscribe to SQLAuthority.com Feed using Email. Email will be delivered to your preferred email address when new post appears on SQLAuthority.com Subscribe to SQLAuthority Feed Through Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Dedicated Search Engine for SQLAuthority - Search SQL Solutions](https://blog.sqlauthority.com/2007/06/01/sqlauthority-news-dedicated-search-engine-for-sqlauthority-search-sql-solutions/): Visit search.SQLAuthority.com I have been receiving many questions asking for tutorials, suggestions or questions about topics I already have wrote before but readers are have not found it or having difficulty to find them. I have almost around 200 articles on this blog so far and it is growing. One of the team member in my company keep on asking about search engine specific to SQLAuthority.com. He suggest that he always search in this blog first before he search on web. One of the loyal reader suggests that I should have search facilities in my SQL Interview Questions. I have created... - [SQL SERVER - 2005 Constraint on VARCHAR(MAX) Field To Limit It Certain Length](https://blog.sqlauthority.com/2007/06/01/sql-server-2005-constraint-on-varcharmax-field-to-limit-it-certain-length/): One of the Jr. DBA at in my Team Member asked me question the other day when he was replacing TEXT field with VARCHAR(MAX) : How can I limit the VARCHAR(MAX) field with maximum length of 12500 characters only. His Question was valid as our application was allowing 12500 characters. Traditionally thinking we only create the field as long as we need. SQL Server 2005 does support VARCHAR(MAX) but does not support VARCHAR(12500). If we try to create database field with VARCHAR(12500) it gives following error. Server: Msg 131, Level 15, State 3, Line 1 The size (12500) given to the... - [SQL SERVER - Retrieve Information of SQL Server Agent Jobs](https://blog.sqlauthority.com/2007/05/31/sql-server-retrieve-information-of-sql-server-agent-jobs/): sp_help_job returns information about jobs that are used by SQL Server Agent service to perform automated activities in SQL Server. When executed sp_help_job procedure with no parameters to return the information for all of the jobs currently defined in the msdb database. - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility - Part 2 - Management Studio](https://blog.sqlauthority.com/2007/05/31/sql-server-2005-change-database-compatible-level-backward-compatibility-part-2-management-studio/): I have received quite a few request about post I have two days ago SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility, if this can be done using SQL Server Management Studio. It is very simple to do this using Management Studio as well but I still prefer T-SQL way. Following steps will display the method to change the compatible levels. Write click on database. Click on Properties. Click on Options. Change the Compatibility level to desired compatibility. (See Attached image below) Click OK. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Must Not Contain NULL - Primary Key are NOT NULL](https://blog.sqlauthority.com/2007/05/31/sql-server-primary-key-must-not-contain-null-primary-key-are-not-null/): While reviewing the search engine log for this blog I found lots of search regarding Nullable Primary Key. It is not possible. This post is especially to clear the Not Nullable Primary Key Property. The Allow Nulls property can’t be set on a column that is part of the primary key. All columns that are part of a table’s a primary key must contain aggregate unique values other than NULL. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQLAuthority.com News - Best SQL Job Search - Best SQL Job List - Find SQL Jobs](https://blog.sqlauthority.com/2007/05/30/sqlauthoritycom-news-best-sql-job-search-best-sql-job-list-find-sql-jobs/): SQLAuthority.com News – Best SQL Job Search – Best SQL Job List – Find SQL Jobs Visit : I have been receiving two kind of requests almost every day. 1) Recruiters and Employers asking where can they find good candidates who are truly dedicated to SQL Server? 2) Job seeker asking where can they find only SQL related jobs? There are hundreds of web site which have great resources for all kind of jobs. Monster and Dice are examples of them. Many sites are bit ocean of the jobs and it is hard to find only SQL Jobs from there, many... - [SQL SERVER - Trace Flags - DBCC TRACEON](https://blog.sqlauthority.com/2007/05/30/sql-server-trace-flags-dbcc-traceon/): Trace flags are valuable tools as they allow DBA to enable or disable a database function temporarily. Once a trace flag is turned on, it remains on until either manually turned off or SQL Server restarted. Only users in the sysadmin fixed server role can turn on trace flags. If you want to enable/disable Detailed Deadlock Information (1205), use Query Analyzer and DBCC TRACEON to turn it on. 1205 trace flag sends detailed information about the deadlock to the error log. Enable Trace at current connection level: DBCC TRACEON(1205) Disable Trace: DBCC TRACEOFF(1205) Enable Multiple Trace at same time separating each... - [SQL SERVER - Fix : Error : Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table](https://blog.sqlauthority.com/2007/05/30/sql-server-fix-error-server-msg-544-level-16-state-1-line-1-cannot-insert-explicit-value-for-identity-column-in-table/): Error Message: Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF. This error message appears when you try to insert a value into a column for which the IDENTITY property was declared, but without having set the IDENTITY_INSERT setting for the table to ON. Fix/WorkAround/Solution: /* Turn Identity Insert ON so records can be inserted in the Identity Column  */ SET IDENTITY_INSERT [dbo].[TableName] ON GO INSERT INTO [dbo].[TableName] ( [ID], [Name] ) VALUES ( 2, 'InsertName') GO /* Turn Identity Insert OFF  */ SET IDENTITY_INSERT [dbo].[TableName] OFF GO Setting the IDENTITY_INSERT to ON allows explicit values to be inserted into the identity column of a table. Execute permissions... - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility](https://blog.sqlauthority.com/2007/05/29/sql-server-2005-change-database-compatible-level-backward-compatibility/): sp_dbcmptlevel Sets certain database behaviors to be compatible with the specified version of SQL Server. Example: ----SQL Server 2005 database compatible level to SQL Server 2000 EXEC sp_dbcmptlevel AdventureWorks, 80; GO ----SQL Server 2000 database compatible level to SQL Server 2005 EXEC sp_dbcmptlevel AdventureWorks, 90; GO Version of SQL Server database can be one of the following: 60 = SQL Server 6.0 65 = SQL Server 6.5 70 = SQL Server 7.0 80 = SQL Server 2000 90 = SQL Server 2005 The sp_dbcmptlevel stored procedure affects behaviors only for the specified database, not for the entire server. sp_dbcmptlevel provides only... - [SQL SERVER - Pass One Stored Procedure's Result as Another Stored Procedure's Parameter](https://blog.sqlauthority.com/2013/04/07/sql-server-pass-one-stored-procedures-result-as-another-stored-procedures-parameter/): This is one of the most asked questions related to stored procedure in recent time and the answer is even simpler. Here is the question - How to Pass One Stored Procedure's Result as Another Stored Procedure's Parameter. Stored Procedures are very old concepts and every day I see more and more adoption to Stored Procedure over dynamic code. When we have almost all of our code in Stored Procedure it is very common requirement that we have need of one stored procedure's result to be passed as another stored procedure's parameter. - [SQL SERVER - Weekly Series - Memory Lane - #023](https://blog.sqlauthority.com/2013/04/06/sql-server-weekly-series-memory-lane-023/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 TempDB is Full. Move TempDB from one drive to another drive Move TempDB from one drive to another drive. There are major two reasons why TempDB needs to move from one drive to another drive. 1) TempDB grows bigger and the existing drive does not... - [SQL SERVER - Group by Rows and Columns using XML PATH - Efficient Concating Trick](https://blog.sqlauthority.com/2013/04/05/sql-server-group-by-rows-and-columns-using-xml-path-efficient-concating-trick/): I hardly get hard time to come up with the title of the blog post. This was one of the blog post even though simple, I believe I have not come up with appropriate title: Group by Rows and Columns using XML PATH – Efficient Concating Trick. Anyway, here is the question I received. - [SQLAuthority Contests - Get 50 Amazon Gift Cards - Experience NuoDB Starlings 1.0.2](https://blog.sqlauthority.com/2013/04/04/sqlauthority-contests-get-50-amazon-gift-cards-experience-nuodb-starlings-1-0-2/): SQL is the standard database language. It has been around since the 1970s. ACID (Atomic, Consistent, Isolated, and Durable) guarantees that the database tier handles the transaction processing in a consistent and reliable manner, freeing the application from managing these tasks (and freeing you from having to code them into the application), while guaranteeing the integrity of the data in the database. NuoDB is the world’s first and only patented, elastically-scalable, SQL database built for decentralized computing resources. It is built with a focus on the elastic scalability on the cloud with 100% ACID guarantees and SQL compliance. Another interesting point about this... - [SQL SERVER - Resolve Cannot Resolve Collation Conflict Error - SQL in Sixty Seconds #047](https://blog.sqlauthority.com/2013/04/03/sql-server-resolve-cannot-resolve-collation-conflict-error-sql-in-sixty-seconds-047/): One of the most common errors database developer’s receives when they start working with database where there are different collation used. Collation is a very important concept but it is often ignored. First use the method displayed in this video to resolve your error and right away put your efforts to understand what collation stands for. Language is the most important part of communication. We all communicate with each other through language which both persons to understand. If we do not talk in the language which the other person cannot understand, the end result is not fruitful. In a similar way,... - [SQL SERVER - An Interesting Case of Redundant Indexes - Index on Col1, Col2 and Index on Col1, Col2, Col3 - Part 6](https://blog.sqlauthority.com/2013/04/02/sql-server-an-interesting-case-of-redundant-indexes-index-on-col1-col2-and-index-on-col1-col2-col3-part-6/): This is the sixth part of the series regarding Redundant Indexes. If have not read earlier part – there is quite a good chance that you will miss the context of this part. I quickly suggest you to read earlier four parts. On my production server I personally use embarcadero DB Optimizer for all performance tuning and routine health check up. I will be interested to know what is your feedback about the product. Part 1: What is Redundant Indexes? Conversation between Mike and Jon – where they discuss about the fundamentals of Redundant Indexes. Part 2: Demo – What kind of Redundant Indexes... - [SQL SERVER - Three Efficiency Tools for SQL Server From Devart](https://blog.sqlauthority.com/2013/04/01/sql-server-three-efficiency-tools-for-sql-server-from-devart/): I just returned from successful road trip of TechEd India. The trip was extremely successful and I have got big chance to engage with community and friends. One of the most frequently asked question during the trip was what kind of efficiency tools do I use while working with SQL Server. I use many different tools and here is the list of my most favorite tools from Devart. If you are using them, do let me know as I would like to get your feedback about the tools. - [SQL SERVER - Three Important Documentation to download - Standards Support, Protocol, Data Portability](https://blog.sqlauthority.com/2013/03/31/sql-server-three-important-documentation-to-download-standards-support-protocol-data-portability/): SQL Server Standards Support Documentation If you are new to the documentation set or new to Microsoft SQL Server, reading the SQL Server system overview document will help familiarize you with the organization of the documentation set as well as with SQL Server concepts and how the protocols relate to each other. The SQL Server standards support documentation provides detailed support information for certain standards that are implemented in Microsoft SQL Server. Download Now Microsoft SQL Server Protocol Documentation The Microsoft SQL Server protocol documentation provides technical specifications for Microsoft proprietary protocols that are implemented and used in Microsoft SQL Server... - [SQL SERVER - Weekly Series - Memory Lane - #022](https://blog.sqlauthority.com/2013/03/30/sql-server-weekly-series-memory-lane-022/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record This was one of the most interesting blog posts I have ever written. This blog post I wrote as I have been receiving lots of questions related to identity. To avoid the potential... - [SQL SERVER - XML Data Type- SQL Queries 2012 Joes 2 Pros Volume 5 - XML Querying Techniques for SQL Server 2012](https://blog.sqlauthority.com/2013/03/29/sql-server-xml-data-type-sql-queries-2012-joes-2-pros-volume-5-xml-querying-techniques-for-sql-server-2012/): This chapter is abstract from the Beginning SQL 2012 – Joes 2 Pros Volume 5.  Book On Amazon | Book On Flipkart Kit on Amazon | Kit on Flipkart Why buy this Book: SQL is full of relationship data with one to many relationships and so is XML. The Marriage between XML and SQL turns out to be far easier than people expected. People often tell me at the end of reading these 5 books they were surprised that this is their favorite. What will I learn after reading this book:  XML Data Type, Shredding XML, Parsing XML, XQuery Extensions, XPATH, and Binding XML to... - [SQL SERVER - Executing Dynamic SQL - SQL Queries 2012 Joes 2 Pros Volume 4 - Query Programming Objects for SQL Server 2012](https://blog.sqlauthority.com/2013/03/28/sql-server-executing-dynamic-sql-sql-queries-2012-joes-2-pros-volume-4-query-programming-objects-for-sql-server-2012/): This chapter is abstract from the Beginning SQL 2012 – Joes 2 Pros Volume 4.  Book On Amazon | Book On Flipkart Kit on Amazon | Kit on Flipkart Why buy this Book: As you get further into SQL you will discover areas you like more than others. Maybe your good at queries or performance tuning. It all comes down to writing code but that code needs to be in the right place. Code can become a function, stored procedure, Trigger, Cursor, or a script. What type of code is right for the different SQL objects can how to handle errors is what this book... - [SQL SERVER - Introduction to GUIDs - SQL Queries 2012 Joes 2 Pros Volume 3 - Advanced Query Tools and Techniques for SQL Server 2012](https://blog.sqlauthority.com/2013/03/27/sql-server-introduction-to-guids-sql-queries-2012-joes-2-pros-volume-3-advanced-query-tools-and-techniques-for-sql-server-2012/): This chapter is abstract from the Beginning SQL 2012 – Joes 2 Pros Volume 3.  Book On Amazon | Book On Flipkart Kit on Amazon | Kit on Flipkart Why buy this Book: We often learn good practices from the people that come before us. Sometimes we later learn why those practices make sense. But there are so many exceptions to these rules. Instead of memorizing the exceptions you can learn the techniques of what is really going on with SQL performance and storage. It’s actually a few simple parts that you can test What will I learn after reading this book: How data types... - [SQL SERVER - Identity Fields Review - The SQL Query Techniques Tutorial for SQL Server 2012](https://blog.sqlauthority.com/2013/03/26/sql-server-identity-fields-review-sql-queries-2012-joes-2-pros-volume-2-the-sql-query-techniques-tutorial-for-sql-server-2012/): In this blog post we are going to learn about Identity Fields Review. Why buy this Book: The beta of this book actually existed for a year and was tested and used in my classroom. Its purpose back then was to help the students do the steps individually that led to the skills where they could all pass the Microsoft test. It worked and then many went out for their SQL interview. They did good enough to get the job, but they told me about one or two questions they were not able to answer. A year of collecting this data and turning them into lessons doubled the size of this book of 300 pages to 600 pages. This book is designed to make the query question and query skills in the professional work must seem easier. Let us learn about Identity Fields Review. - [SQL SERVER - Query Writing Strategy - SQL Queries 2012 Joes 2 Pros Volume 1 - The SQL Queries 2012 Hands-On Tutorial for Beginners](https://blog.sqlauthority.com/2013/03/25/sql-server-query-writing-strategy-sql-queries-2012-joes-2-pros-volume-1-the-sql-queries-2012-hands-on-tutorial-for-beginners/): This chapter is abstract from the Beginning SQL 2012 – Joes 2 Pros Volume 1.  Book On Amazon | Book On Flipkart Kit on Amazon | Kit on Flipkart Why Buy this Book: Weather you are a tester, developer, or administrator of SQL there are some basic terms and skill they are all expected to know. The core of design, permissions, queries, and SQL objects is often many separate books. But what if you want the proficient base across all these displaces. If you are starting out or are self-thought this will help fill in the pieces you may not know was missing.... - [SQLAuthority News - Whitepaper - Plan Caching and Recompilation in SQL Server 2012](https://blog.sqlauthority.com/2013/03/24/sqlauthority-news-whitepaper-plan-caching-and-recompilation-in-sql-server-2012/): Plan Caching and Recompilation in SQL Server 2012 Whitepaper has been my favorite paper for a long time. Plan caching and recompilation are two of the best concepts which are explained in depth by my favorite author Greg Low. I have met Greg several times and I have been a big fan of his writing and ability to make complex very easy. The same white paper was earlier available for SQL Server 2005 and 2008. This paper explains how SQL Server allocates memory for plan caching, how query batches are cached and suggests best practices on maximizing reuse of cached plans. It also explains... - [SQL SERVER - Weekly Series - Memory Lane - #021](https://blog.sqlauthority.com/2013/03/23/sql-server-weekly-series-memory-lane-021/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 SQL Commandments – Suggestions, Tips, Tricks Earlier I come across an interesting article where author has written 25 commandments for other database technology. I re-wrote the same article for SQL Server and it is still very much relevant. Stored Procedure – Clean Cache and Clean... - [SQL SERVER - Fix - Error: 1060 The number of rows provided for a TOP or FETCH clauses row count parameter must be an integer](https://blog.sqlauthority.com/2013/03/22/sql-server-fix-error-1060-the-number-of-rows-provided-for-a-top-or-fetch-clauses-row-count-parameter-must-be-an-integer/): Here is the interesting error one of my friend faced and it took me 15 minutes go over various code to identify the real issue. When we see a simple example in demonstration or a blog, we often think that SQL is a much simpler language and it looks easy. However, in reality it is often more complex than we think. I was dealing with the Stored Procedure which is which had 10000 lines of the code and there were many different views and functions used in it. The worst part was my friend can’t share his original code as it... - [SQL SERVER - Identify Last User Access of Table using T-SQL Script](https://blog.sqlauthority.com/2013/03/21/sql-server-identify-last-user-access-of-table-using-t-sql-script/): During the TechEd India 2013 presentations I received a question how to identify when any table is accessed by any of the user. It seems people would like to know if the table was used in any part of query by any user. The best possible solution is to create database audit task and watch the database table access. However, sometime we all want shortcut even thought it is not accurate. Here is how you can use DMV to do so. However, please note that this DMV will get reset when database services or servers are restart. Let me know if... - [SQLAuthority News - How to Avoid Procrastination - Professional Development #001 - Video](https://blog.sqlauthority.com/2013/03/20/sqlauthority-news-how-to-avoid-procrastination-professional-development-001-video/): The inaugural video in this series addresses procrastination, a challenge we’ve all faced at some point in our lives. Let us learn more. - [SQL SERVER - TechEd India 2013 Sessions and Relevent Pluralsight Courses](https://blog.sqlauthority.com/2013/03/19/sql-server-teched-india-2013-sessions-and-relevent-pluralsight-courses/): I am presenting at TechEd India 2013 two SQL Server session. You can read about my session in this blog post. Yesterday I presented on topic SQL Server Performance Troubleshooting: Ancient Problems and Modern Solutions. Today I will be presenting on the subject Indexes – The Unsung Hero. If you are at TechEd India you must show up in my session – we will have fun talking about Indexes and performance tuning together. You can read about various details about the session over here. However, if you are not at TechEd India 2013 and still want to know what I am going to... - [SQLAuthority News - Presenting Two Technology Sessions at TechEd India 2013 - Today and Tomorrow](https://blog.sqlauthority.com/2013/03/18/sqlauthority-news-presenting-two-technology-sessions-at-teched-india-2013-today-and-tomorrow/): Every year I am looking forward to TechEd India as it presents a wonderful opportunity to meet community in first hand. Community is my passion and I love to get involved with it at every single opportunity it presents. This year once again I am presenting a technology session at TechEd India. I will be presenting two Technology Sessions on the following subject. Here is something I promise - if you attend my session - when you walk out of my session you will immediate action items which you can use it for your production server and improve the performance of the database. Additionally, I will have some goodies with me for everyone. I will have a few of my books, free subscription access to Pluralsight's library as well something totally interesting as a giveaway. - [SQLAuthority News - Excellent Learning Experience at SQLskills Immersion Events](https://blog.sqlauthority.com/2013/03/17/sqlauthority-news-excellent-learning-experience-at-sqlskills-immersion-events/): As many of you know, I attended the Immersion Event at SQLskills learning center in early Feb. I consider myself a SQL professional, but there is no age limit for being a student. One can learn forever, there is always something new to pick up – particularly when you go to a SQLskills event. They are going to teach you something fantastic, something you didn’t know before. It is quite possible to know a lot about a concept, but when we learn about the right ways and wrong ways to do things, and see all the mistakes we made without knowing... - [SQL SERVER - Weekly Series - Memory Lane - #020](https://blog.sqlauthority.com/2013/03/16/sql-server-weekly-series-memory-lane-020/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 DBCC RESEED Table Identity Value – Reset Table Identity My early career blog discusses about Table Identity Value and how to reset them to the original value. 2008 How to Retrieve TOP and BOTTOM Rows Together using T-SQL  It is easy to select Top 2... - [SQLAuthority News - Presenting Two Session at TechEd India 2013 on March 18-19, 2013 at Bangalore](https://blog.sqlauthority.com/2013/03/15/sqlauthority-news-presenting-two-session-at-teched-india-2013-on-march-18-19-2013-at-bangalore/): TechEd India is around the corner and I have two sessions in TechEd India. I am excited and nervous as well. TechEd is a special event and I am going to present 4th time in this event. This time the event is in two location – Bangalore and Pune. Performance Tuning is my favorite subject and I love to talk about it endlessly. If you know me personally, you might be familior with how I present any session. I promise that when you walk out of the session you will have gained learning which you can implement right away at the... - [SQLAuthority News - Truly Amazing Experience at Pluralsight Author Summit February 2013](https://blog.sqlauthority.com/2013/03/14/sqlauthority-news-truly-amazing-experience-at-pluralsight-author-summit-february-2013/): February was very good for me because I got to attend PluralSight’s Author Summit. The Author Summit was held in Salt Lake City, Utah and was open to all PluralSight’s authors. Most of the authors attended the conference, held at the PluralSight headquarters.  It was a three day event that was packed full of various activities. There were lots of things to do all day and every evening.  There were plenty of opportunities to network, meet people, learn, and share common experiences. What all the PluralSight authors have in common is that we love to share knowledge.  We were able to... - [SQL SERVER - Shortcut to SELECT Single Row from Table - SQL in Sixty Seconds #046 - Video](https://blog.sqlauthority.com/2013/03/13/sql-server-shortcut-to-select-single-row-from-table-sql-in-sixty-seconds-046-video/): Earlier I have blogged about the same subject and in very short time I received lots of good comments about this blog post as well lots of email from users who faced issues to make this work. Thought, the instructions are very simple in the blog post, every user read it differently and they have a different interpretation. I finally decided to do convert the same blog post in the video. I hope now it will be much easier to understand it. If you watch any SQL Server Developer, you will notice one particular task them doing every day frequently. It... - [SQL SERVER - Avoid Using Function in WHERE Clause - Scan to Seek](https://blog.sqlauthority.com/2013/03/12/sql-server-avoid-using-function-in-where-clause-scan-to-seek/): “Don’t use functions in the WHERE clause, they reduce performance.” I hear this quite often. This is true but this subject is hard to understand in a single statement. Let us see what it means and how to use the function in the WHERE clause. We will be using sample database AdventureWorks in this example. Additionally, turn on STATISTICS IO ON settings so we can see various statistics as well. USE AdventureWorks2012 GO SET STATISTICS IO ON GO Let us first execute following query and check the execution plan and statistics. -- SCAN - Select values from SalesOrderDetail SELECT [SalesOrderID], [SalesOrderDetailID],... - [SQL SERVER - How to Add Column at Specific Location in Table](https://blog.sqlauthority.com/2013/03/11/sql-server-how-to-add-column-at-specific-location-in-table/): Recently I noticed a very interesting question on Stackoverflow. A user wanted to add a particular column between two of the rows. He had an experience with MySQL so he was attempting following syntax. Following syntax will throw an error. Let us explore more about how to add column at specific locations in the table. - [SQLAuthority News - SQL Server Data Tools - Business Intelligence for Visual Studio 2012 - SQL Server 2012 Data-Tier Application Framework](https://blog.sqlauthority.com/2013/03/10/sqlauthority-news-sql-server-data-tools-business-intelligence-for-visual-studio-2012-sql-server-2012-data-tier-application-framework/): Microsoft SQL Server Data Tools provides an integrated environment for database developers to carry out all their database design work for any SQL Server platform within Visual Studio.  The SQL Server Object Explorer in Visual Studio offers a view of your database objects similar to SQL Server Management Studio. SQL Server Object Explorer allows you to do light-duty database administration and design work. You can easily create, edit, rename and delete tables, stored procedures, types, and functions. You can also edit table data, compare schemas, or execute queries by using contextual menus right from the SQL Server Object Explorer. Database developers can... - [SQL SERVER - Weekly Series - Memory Lane - #019](https://blog.sqlauthority.com/2013/03/09/sql-server-weekly-series-memory-lane-019/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation When creating or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF? I explained the same in... - [SQL SERVER - Tricky Question - What is the Default Size of the Database](https://blog.sqlauthority.com/2013/03/08/sql-server-tricky-question-what-is-the-default-size-of-the-database/): I love tricky questions – they are fun and educating. Yesterday I was presenting in one of the largest organization in India on SQL Server Performance Tuning Subject. During the conversation, one of the user suggested that every single time they are creating new database it is created with the big MDF file. They were wondering how come they have always very large file when they create new database. It was indeed a fun question to be asked. In reply to the same question – I asked following question to the audience. What is the default size of the SQL Database?... - [SQL SERVER - Check If String is a Palindrome in Using T-SQL Script - Reverse Function](https://blog.sqlauthority.com/2013/03/07/sql-server-check-if-string-is-a-palindrome-in-using-t-sql-script-reverse-function/): One of my friends who works in a big MNC recently asked me that if there is any way to check if the String is Palindrome or not. The palindrome is a word, phrase, or sequence that reads the same backward as forward. For example A man, a plan, a canal - Panama! is palindrome so as Was it a car or a cat I saw? My first reaction was to him was why does this kind of functionality. His answer was they have requirement in their business application where they are building captcha and they may display the image in mirror image as well as a part of challenge code and he can't have any word which is palindrome as an option. For this he wanted to write a script which will go letter by letter and match them. If they are same, he will not use the word for captcha. - [SQL SERVER - Watch Four Efficiency Tricks in SQL Server In Sixty Seconds - Subscribe for SQL Learning Videos](https://blog.sqlauthority.com/2013/03/06/sql-server-watch-four-efficiency-tricks-in-sql-server-in-sixty-seconds-subscribe-for-sql-learning-videos/): SQL in Sixty Seconds has been my favorite thing to do every Wednesday. It is indeed truly said that “A picture is worth a thousand words” – it is equally true that “A video is worth a thousand pictures”. Though recording the video is easy the difficult part is to edit it, process it and take it live. As a SQL developer like you I am good with the SQL but I am doing video editing is not my cup of tea. Anyway the final outcome is so good that I feel like doing these videos. Need Your Help! After an... - [SQL SERVER - Exporting Query Results to CSV using SQLCMD](https://blog.sqlauthority.com/2013/03/05/sql-server-exporting-query-results-to-csv-using-sqlcmd/): Social media is evolving at a rapid pace and every day I keep on getting question from different methods. Here is the latest question which I received on my Facebook page. The question was how to export the data of query into CSV using SQLCMD. This is indeed very easy process and very simple command to export any query data. For example we will use AdventureWorks2012 database. Here is the query we will be using for our demonstration. USE AdventureWorks2012 GO SELECT TOP 10 sp.BusinessEntityID, sp.TerritoryID, sp.SalesQuota, sp.Bonus, sp.CommissionPct FROM Sales.SalesPerson sp GO The above query will return following result set.... - [SQL SERVER - SSMS Does NOT Print NULL Values](https://blog.sqlauthority.com/2013/03/04/sql-server-ssms-does-not-print-null-values/): Here is a very interesting question asked on the blog by Karthik. I really liked the question and I would like to discuss this here about SSMS doe snot Print NULL values.  - [SQL SERVER - Download Microsoft PowerPivot for Excel 2010 and PowerPivot in Excel 2013 Samples](https://blog.sqlauthority.com/2013/03/03/sql-server-download-microsoft-powerpivot-for-excel-2010-and-powerpivot-in-excel-2013-samples/): Learning any technology is easy when we have good documentation and sample database to play along with. When I have to learn any new technology, my first action is to install the trial software and look for sample database next. Once I get sample database, I try to find a video tutorial about the technology and continue to learn onwards. Let's see PowerPivot for Excel 2010 and PowerPivot in Excel 2013 Samples here. - [SQL SERVER - Weekly Series - Memory Lane - #018](https://blog.sqlauthority.com/2013/03/02/sql-server-weekly-series-memory-lane-018/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Restore Database Backup using SQL Script (T-SQL) This is one of my most popular blog posts where I explained how to take backup using SQL Script in a few T-SQL statement. There are more than 500 comments on this blog so far. T-SQL Script to... - [SQL SERVER - Beginning SQL 2012 - Basics of CONVERT and FORMAT Function - Abstract from Joes 2 Pros Volume 5](https://blog.sqlauthority.com/2013/03/01/sql-server-beginning-sql-2012-basics-of-convert-and-format-function-abstract-from-joes-2-pros-volume-5/): This chapter is abstract from the Beginning SQL 2012 – Joes 2 Pros Volume 5.  You can get the Five part SQL Server 2012 Joes 2 Pros Combo Kit for complete reference.  Book On Amazon | Book On Flipkart OPENXML has been around longer than the XML data type in SQL Server. The OPENXML requires you to use a series of system stored procedures and a variable to keep track of a handle. Using the number handle was a formality as the real work was in the patterns getting the right values from the right nodes. In this post we will shred XML... - [SQL SERVER - Beginning SQL 2012 - Basics of CONVERT FORMAT Function](https://blog.sqlauthority.com/2013/02/28/sql-server-beginning-sql-2012-basics-of-convert-and-format-function-abstract-from-joes-2-pros-volume-4/): From the September 17, 2011 blog post on the new SQL 2012 FORMAT function we learned how to format currency and time using different cultures. This is an improvement on what came before and also gives us new possibilities for getting date labels without needing to use DATEPART. In this post we will compare the FORMAT function to the previous techniques and also show you an easy way to grab the part of the date you need for reports. Let us learn about CONVERT FORMAT Function. - [SQL SERVER - Cycle Clipboard Ring in SSMS - SQL in Sixty Seconds #045 - Video](https://blog.sqlauthority.com/2013/02/27/sql-server-cycle-clipboard-ring-in-ssms-sql-in-sixty-seconds-045-video/): Copy and Paste! In other words - CTRL + C and CTRL + V - these two are our famous shortcuts for this new age. Remember copy paste is not a bad thing, but plagiarism is for sure. I rely on a lot of Copy Paste when I am doing development. There are so many templates, code or name of the objects (tables, stored procedure) etc., which we need when we are doing development. If we keep on typing those names, there are chances of making human error which can lead to further problems. Let us learn about the Cycle Clipboard Ring in this blog post. - [SQL SERVER - Beginning SQL 2012 - Spatial Unions and Collections](https://blog.sqlauthority.com/2013/02/27/sql-server-beginning-sql-2012-spatial-unions-and-collections-abstract-from-joes-2-pros-volume-3/): In business we often hear the phrase, “We had a good quarter.” Immediately, we know this means a three month span where sales and profits have been aggregated together for the company. Take a company like Costco that might have $65 billion in total sales during the 4th Quarter (October, November and December). Of course, this total comes not from a single sale of a 65 billon dollar yacht, rather from millions of sales of common items like snacks, drinks, clothes, and light bulbs. We know how to use GROUP BY and SUM to calculate totals and combine similar data. In the case of Costco we group by calendar quarter and then sums on the sales. Although aggregates are commonly used with numbers, they can also be used with spatial land coordinates to assemble them together, much like a jigsaw puzzle. Let us learn about Spatial Unions. - [SQL SERVER - Beginning SQL 2012 - Aggregation Functions - Abstract from Joes 2 Pros Volume 2](https://blog.sqlauthority.com/2013/02/26/sql-server-beginning-sql-2012-aggregation-functions-abstract-from-joes-2-pros-volume-2/): This chapter is abstract from the Beginning SQL 2012 – Joes 2 Pros Volume 2. You can get the Five part SQL Server 2012 Joes 2 Pros Combo Kit for complete reference. Book On Amazon | Book On Flipkart All supporting files are available with a free download from the www.Joes2Pros.com web site. This example is from the “SQL Queries 2012 Joes 2 Pros Volume 2” in the file SQLQueries2012Vol2Chapter5.1Setup.sql. If you need help setting up then look in the “Free Videos” section on Joes2Pros under “Getting Started” called “How to install your labs” Aggregation Functions Most people are familiar with... - [SQL SERVER - Beginning SQL 2012 - Why we use Code Comments - Abstract from Joes 2 Pros Volume 1](https://blog.sqlauthority.com/2013/02/25/sql-server-beginning-sql-2012-why-we-use-code-comments-abstract-from-joes-2-pros-volume-1/): Old classic movies utter this famous phrase “Gentlemen, this is off the record”. In movies this is used when talking to the press and letting them know a certain comment or two will be said, however it is not meant for publication in the media. Sometimes, we want to use words or phrases within a query window that we want SQL Server to ignore when executing the code. Fortunately, SQL Server allows us to write words or phrases that are “off the record”, with a coding technique called a commenting. Let us understand why we code comments. - [SQL SERVER - Cumulative Update Released in February 2013 for SQL Server Editions](https://blog.sqlauthority.com/2013/02/24/sql-server-cumulative-update-released-in-february-2013-for-sql-server-editions/): I keep eyes on cumulative updates. I keep a watch that which one released and what they are impacting. If you are facing issues with SQL Server – Comulative Updates may have a solution for you. I suggest to install CU on Development Server first and later roll out the changes to production servers. Here are the details for the latest CU released. SQL Server 2012  CU#6 KB Article: http://support.microsoft.com/kb/2728897 SQL Server 2008 R2 SP2 CU#5 KB Article: http://support.microsoft.com/kb/2797460 SQL Server 2008 R2 SP1 CU#11 KB Article: http://support.microsoft.com/kb/2812683 I strongly suggest you go to the above links and check what are different kinds of... - [SQL SERVER - Weekly Series - Memory Lane - #017](https://blog.sqlauthority.com/2013/02/23/sql-server-weekly-series-memory-lane-017/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Year 2007 in February I was still learning how to blog and I was trying to get a grasp of the whole blogging thing, I still remember my old day and wonder how many naive I was and I had so much long way to... - [SQL SERVER - T-SQL Script to Keep CPU Busy](https://blog.sqlauthority.com/2013/02/22/sql-server-t-sql-script-to-keep-cpu-busy/): Never run this on your production server – you can just lose your job and can damage your organization. Now I am done with the disclaimer here is the subject I would like to discuss. How to keep your CPU busy? Well, actually there should not be any need of this query for production server purpose. I needed this query for development server purpose when I was testing the server for Capacity Planning as well doing the Stress Testing. When I quickly searched for this query, I end up on my old blog post over here Demo Script – Keeping CPU... - [SQL SERVER - Shortcut to SELECT only 1 Row from Table](https://blog.sqlauthority.com/2013/02/21/sql-server-shortcut-to-select-only-1-row-from-table/): If you watch any SQL Server Developer, you will notice one particular task them doing every day frequently. It is they select the row from the table to see what are the various kinds of data it contains. Most of the tables are very big so it is always advisable to retrieve only a single row from the table. It is very cumbersome for developers to continuously write following code to retrieve a single row to see what the table contains. SELECT TOP 1 * FROM TableName I suggest you try to write above code and there is good chance that... - [SQL SERVER - Restore SQL Database using SSMS - SQL in Sixty Seconds #044 - Video](https://blog.sqlauthority.com/2013/02/20/sql-server-restore-sql-database-using-ssms-sql-in-sixty-seconds-044-video/): "How do I restore SQL Database backup?" - [SQLAuthority News - Introduction to ColdFusion - Video Tutorial on Pluralsight](https://blog.sqlauthority.com/2013/02/19/sqlauthority-news-introduction-to-coldfusion-video-tutorial-on-pluralsight/): I recently released a Introduction to ColdFusion video course on Pluralsight. The course is very well received and I have received a quite a lot of good feedback about it. However, one of the questions keeps on showing up in my email box is that users had no idea that I have worked with programming language ColdFusion and I am still a hands-on expert on this subject. In response to the most asked question – I have decided to write this blog post where I explain – History of Pinal Dave and ColdFusion Everybody starts their learning from somewhere. I started... - [SQLAuthority News - NuoDB Announces Webinar Series To Demystify Cloud Data Management](https://blog.sqlauthority.com/2013/02/18/sqlauthority-news-nuodb-announces-webinar-series-to-demystify-cloud-data-management/): For those of you who read my blog regularly, you know that I’ve been evaluating NuoDB, a new database company that is re-writing the rules for relational databases. They’ve introduced a new category – Cloud Data Management Systems (CDMS) – and are claiming to be the first and only. In an effort to ‘demystify CDMS’, they’re kicking-off a 5 part webcast series where industry experts, analysts, customers and partners will join NuoDB to cover a range of topics related to managing data in the cloud. If you’re curious about the difference between a CDMS and a NoSQL store, NewSQL or even... - [SQL SERVER - Fix : Error - sqljdbc_auth.dll Issue - com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed](https://blog.sqlauthority.com/2013/02/17/sql-server-fix-error-sqljdbc_auth-dll-issue-com-microsoft-sqlserver-jdbc-sqlserverexception-the-tcpip-connection-to-the-host-localhost-port-1433-has-failed/): It seems that Sundays are marked for strange errors. Every Sunday I come across something interesting and different to post. This time I receive error from one of JDBC driver users. He sent me a message that he is not able to connect to SQL Server and he is facing the following error while connecting to SQL Server. He has already checked firewall and TCP/IP settings and still he is facing the errors. - [SQL SERVER - Weekly Series - Memory Lane - #016](https://blog.sqlauthority.com/2013/02/16/sql-server-weekly-series-memory-lane-016/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 FIX : Error 15023: User already exists in the current database One of the most popular errors when SQL Server 2000 is migrated to SQL Server 2005. 2008 SQL SERVER – Get Current Database Name A quick script which will give user current database name.... - [SQLAuthority News - Presenting at Sarasota IT Pro Camp, Florida on February 16, 2013](https://blog.sqlauthority.com/2013/02/15/sqlauthority-news-presenting-at-sarasota-it-pro-camp-florida-on-february-16-2013/): I am traveling the entire month of February 2013 in USA. First 18 days I am Florida and later part I am heading to another part of the country. When I am in India, every weekend I make a point to attend one of the User Group Meeting in the city. However, the same becomes a bit difficult when I am traveling across the globe. Well, it does not matter where I am and what position I am – if there is a community event, I am going to be there. Tomorrow on February 16, 2013 Saturday, I am going to present... - [SQL SERVER - Development Productivity Tool - dbForge Studio for SQL Server](https://blog.sqlauthority.com/2013/02/14/sql-server-development-productivity-tool-dbforge-studio-for-sql-server/): First off, it will increase SQL coding almost instantly. There is very little to learn, you are not just memorizing codes to “cheat” off of. DbForge Studio provides code completion options and automatic SQL formatting, so that you know your code will work. One of my favorite feature is “snippets,” which stores parts of code that you use over and over to cut down on typing and searching – because you know there always a few commands you use again and again! Another time saver is the hint option, which will show you information about objects, and the navigation tool that allows toggling between items using only the F12 key. - [SQL SERVER - Get SQL Server Version and Edition Information - SQL in Sixty Seconds #043 - Video](https://blog.sqlauthority.com/2013/02/13/sql-server-get-sql-server-version-and-edition-information-sql-in-sixty-seconds-043-video/): What do consultants do when they come across any new instance of SQL Server? Well, their very first question is what version of SQL Server is it? The reason is simple – SQL Server is a very vast product and each version of the product have new features released and old features deprecated. Many consultant even remembers service pack and features released in it. Well, there are multiple ways to know the version numbers of the SQL Server. In this sixty second video we will see a neat trick where we will quickly find the version number of SQL Server. Let us... - [SQL SERVER - An Interesting Case of Redundant Indexes - Index on Col1 and Included Columns Col2 and Col3 - Part 5](https://blog.sqlauthority.com/2013/02/12/sql-server-an-interesting-case-of-redundant-indexes-index-on-col1-and-included-columns-col2-and-col3-part-5/): This is the fifth part of the series regarding Redundant Indexes. If have not read earlier part – there is quite a good chance that you will miss the context of this part. I quickly suggest you to read earlier four parts. On my production server I personally use embarcadero DB Optimizer for all performance tuning and routine health check up. I will be interested to know what is your feedback about the product. Part 1: What is Redundant Indexes? Conversation between Mike and Jon – where they discuss about the fundamentals of Redundant Indexes. Part 2: Demo – What kind of Redundant Indexes... - [SQL SERVER - What is Semantics Model - A Simple Explanation](https://blog.sqlauthority.com/2013/02/11/sql-server-what-is-semantics-models-a-simple-explanation/): “Semantics” refers to the meaning behind words, sentences, or phrases.  This is its general meaning.  In technology, even the word “semantics” has more meanings.  Semantics, and semantic models, refer to how data is organized within a database to make it more useful for users.  So, in technology, semantics have the meaning of “makes sense to the user.” From a purely programming point of view, the semantics might not seem important.  Databases are just warehouses of knowledge.  You input information and simply must make the right queries to get the information returned.  However, from a user’s point of view, this is complicated,... - [SQL SERVER - Primary Key and NonClustered Index in Simple Words ](https://blog.sqlauthority.com/2013/02/10/sql-server-primary-key-and-nonclustered-index-in-simple-words/): I have been writing a weekly round up from my blog where I go over last six years of blog posts and pick the best posts from the pasts. While I do this, there are two major place where I focus 1) If there are change in features – I re-blog about it with additional details or 2) If I have not provided complete information six years ago, I try to fill up the gap now. Well, just like everything my knowledge and writing skills have evolved. Before continuing please read my latest memory lane blog post where in 2007 I... - [SQL SERVER - Weekly Series - Memory Lane - #015](https://blog.sqlauthority.com/2013/02/09/sql-server-weekly-series-memory-lane-015/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Primary Key Constraints and Unique Key Constraints There is a big difference between Primary Key and Unique Key, however, quite common they are confused and mixed up. Well, this blog post explains the concept in very simple words and explains the scripts as well. 2008... - [SQL SERVER - Backup and Restore Database Using Command Prompt - SQLCMD](https://blog.sqlauthority.com/2013/02/08/sql-server-backup-and-restore-database-using-command-prompt-sqlcmd/): Backup and Restore is one of the core tasks for DBAs. They often do this task more times than they would have ideally loved to do so. One thing I noticed in my career that every successful DBA knows how to automate their tasks and spend their time either playing games on a computer or learning something new! - [SQLAuthority News - Delhi Women Safety - 2400th Blog Post - A Milestone](https://blog.sqlauthority.com/2013/02/07/sqlauthority-news-delhi-women-safety-2400th-blog-post-milestone/): I have stopped writing milestone posts recently as I realized that they really do not serve any other value besides having boastful note about myself. I rather do some important contribution to my blog so I started to build Weekly Memory Lane series and that is a much better contribution in my opinion as that even helps me to go and re-learn some of the concepts from the past. However, this blog post is a different blog post than any other blog post. If you are familiar with what is going on recently in Delhi, India you will appreciate my reason behind... - [SQL SERVER - Generate Random Values - SQL in Sixty Seconds #042 - Video](https://blog.sqlauthority.com/2013/02/06/sql-server-generate-random-values-sql-in-sixty-seconds-042-video/): Though it looks simple it is very difficult to generate random numbers which one can’t guess. There are many different ways to generate random values in SQL Server. I have previously blogged about it over here where I have demonstrated five different methods to generate random values in SQL Server. SQL SERVER – Random Number Generator Script – SQL Query In this sixty second video we will see a neat trick where we will generate Random value between specified two numbers. Let us see the same concept in following SQL in Sixty Seconds Video: [youtube=https://www.youtube.com/watch?v=1d29ka0hHnc] Related Tips in SQL in Sixty... - [SQL SERVER - Fix: Error: 1505 The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name and the index name](https://blog.sqlauthority.com/2013/02/05/sql-server-fix-error-1505-the-create-unique-index-statement-terminated-because-a-duplicate-key-was-found-for-the-object-name-and-the-index-name/): Here is another example where the error messages are very clear but often developers get confused with the message. I think the reason for the confusion is the word “Key” used in the error message. After I explained this to a developer who sent me the error he realize that it is about how we all interpret a same statement. Following code will generate the error 1505. -- Create Table CREATE TABLE test (ID INT NOT NULL, Col1 INT, Col2 VARCHAR(100)) GO -- Populate Table INSERT INTO test (ID, Col1, Col2) SELECT 1, 1, 'First' UNION ALL SELECT 1, 2, 'Second'... - [SQL SERVER - Fix Error: 8111 - Cannot define PRIMARY KEY constraint on nullable column in table - Error: 1750 - Could not create constraint. See previous errors](https://blog.sqlauthority.com/2013/02/04/sql-server-fix-error-8111-cannot-define-primary-key-constraint-on-nullable-column-in-table-error-1750-could-not-create-constraint-see-previous-errors/): A very common error new developers receive when they begin with SQL Server and start playing with the keys. Let us first run following code which will generate an error 8111. -- Create Table CREATE TABLE test (ID INT, Col1 INT, Col2 VARCHAR(100)) GO -- Now create PK on ID Col ALTER TABLE test ADD  CONSTRAINT [PK_test] PRIMARY KEY CLUSTERED ([ID] ASC) GO When you run above code it will give following error: Msg 8111, Level 16, State 1, Line 2 Cannot define PRIMARY KEY constraint on nullable column in table ‘test’. Msg 1750, Level 16, State 0, Line 2 Could not... - [SQLAuthority News - Reset Messaging (SMS/Text) Icon Count in Android Jelly Bean](https://blog.sqlauthority.com/2013/02/03/sqlauthority-news-reset-messaging-smstext-icon-count-in-android-jelly-bean/): Though, this blog post has nothing to do with SQL, this particular issue has been annoying me for a long time. I use Galaxy SIII updated with Android Jelly Bean. I am a big fan of this phone and I have written an efficiency tip about Android as well here Android Efficiency Tips and Tricks – Personal Technology Tip. Recently it started to give me one very annoying error. I had recently received a single SMS/Text on my phone. After I read the message the icon did not reset. Here are few of the things I tried but the icon did... - [SQL SERVER - Weekly Series - Memory Lane - #014](https://blog.sqlauthority.com/2013/02/02/sql-server-weekly-series-memory-lane-014/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Query Analyzer Short Cut to display the text of Stored Procedure In my early career I picked up the shortcut to display the text of the stored procedure and believe me I am using the same shortcut till today. It is like learning how to... - [SQL SERVER - Difference Between NOLOCK and NOWAIT Hints](https://blog.sqlauthority.com/2013/02/01/sql-server-difference-between-nolock-and-nowait-hints/): It is interesting to see how a blog evolves with the time and user interacts with each blog post. Earlier I wrote two of the blog posts on NOWAIT and SET LOCK_TIMEOUT. I have received very good response on this subject. Please read following two blog posts before continuing this blog post. - [SQL SERVER - Significance of Table Input Parameter to Stored Procedure](https://blog.sqlauthority.com/2013/01/31/sql-server-significance-table-input-parameter-stored-procedure/): SQL Server has introduced a functionality to pass a table data form into stored procedures and functions. This feature greatly simplifies the process of developing. The reason being, we need not worry about forming and parsing XML data. With the help of the table Input parameter to Stored Procedure we can save many round trips. Any SQL training will vouch for the fact that SQL is capable of accepting large, complex data in the form of parameters in a stored procedure. - [SQL SERVER - Autocomplete and Code Formatting Tool - SQL in Sixty Seconds #041 - Video](https://blog.sqlauthority.com/2013/01/30/sql-server-autocomplete-and-code-formatting-tool-sql-in-sixty-seconds-041-video/): I love to write code, and I love well-written code. When I am working with clients, and I find people whose code have not been written properly, I feel a little uncomfortable. It is difficult to deal with code that is in the wrong case, with no line breaks, no white spaces, improper indents, and no text wrapping. The worst thing to encounter is code that goes all the way to the right side, and you have to scroll a million times because there are no breaks or indents. Let us see blog post about Code Formatting Tool. - [SQL SERVER - Contest to Win Amazon Card - Experience Cloud Data Management System (CDMS) and NuoDB](https://blog.sqlauthority.com/2013/01/29/sql-server-contest-to-win-amazon-card-experience-cloud-data-management-system-cdms-and-nuodb/): The world of database is changing. The traditional client server installation on premises still has a place in many organizations but many of these organizations are facing challenges with this setup setup as their data is growing exponentially every day. Well, as time changes the innovation is required. If you are reading this blog, you might have attended the announcement of the NuoDB General Availability. The event was highly attended and there was lots of interest for the product. NuoDB has announced the general availability of NuoDB Starlings Release (V 1.0) – the industry’s first and only Cloud Data Management System (CDMS).... - [SQL SERVER - Basic Explanation of SET LOCK_TIMEOUT – How to Not Wait on Locked Query](https://blog.sqlauthority.com/2013/01/28/sql-server-basic-explanation-of-set-lock_timeout-how-to-not-wait-on-locked-query/): In earlier blog post SQL SERVER – Basic Explanation of Query Hint NOWAIT – How to Not Wait on Locked Query, we learned how we can use NOWAIT query hint to not wait on any locked query and return error. The Query Hint works on query and table level. There is similar setting which can work at a connection level as well,  it is SET LOCK_TIMEOUT. When any connection starts the value of the SET LOCK_TIMEOUT is -1, which means that the query has to wait for infinite time for the lock to be released on another query. If you want to simulate the... - [SQLAuthority News - Developing Multi-tenant Applications for the Cloud, 3rd Edition - Book Download](https://blog.sqlauthority.com/2013/01/27/sqlauthority-news-developing-multi-tenant-applications-for-the-cloud-3rd-edition-book-download/): Cloud is changing the way how IT world is evolving. Honestly, just like every product and service, there are always the best practices to follow for optimal outcome. Let us learn about Developing Multi-tenant Applications for the Cloud. - [SQL SERVER - Weekly Series - Memory Lane - #013](https://blog.sqlauthority.com/2013/01/26/sql-server-weekly-series-memory-lane-013/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. Today is India’s Republic Day – Happy Republic Day to all the fellow Indians. 2007 SQL SERVER – Query Analyzer Shortcuts In year 2007 I had written a one of the very first downloadable PDF. This is something I had created for me as a production... - [SQL SERVER - Basic Explanation of Query Hint NOWAIT - How to Not Wait on Locked Query](https://blog.sqlauthority.com/2013/01/25/sql-server-basic-explanation-of-query-hint-nowait-how-to-not-wait-on-locked-query/): Everybody knows about NOLOCK  but not everyone knows about NOWAIT. They are different and they have an entire different purpose. In this blog post we will not talk about NOLOCK but we will see how NOWAIT will work. The idea of writing about blog post is based on the question I received in recent Bangalore User Group presentation. Here is the quick conversation with one of the attendee I had after my presentation. I did not ask the name of the attendee so I will have to address him as an attendee here. If you are reading this blog post, please... - [SQL SERVER - How to Use Instead of Trigger](https://blog.sqlauthority.com/2013/01/24/sql-server-use-instead-trigger/): A trigger is an exceptional sort of stored procedure which functions when we try to amend the data in a table like inserting, deleting or updating data. It is a database object, executed automatically and is bound to a table. Fundamentally, triggers are classified into two types mainly- - [SQL SERVER - TRIM Function to Remove Leading and Trailing Spaces of String - SQL in Sixty Seconds #040 - Video](https://blog.sqlauthority.com/2013/01/23/sql-server-trim-function-to-remove-leading-and-trailing-spaces-of-string-sql-in-sixty-seconds-040-video/): Trim is one of the most frequently used operation over String data types. A developer often come across a scenario where they have the string with leading and trailing spaces around string. If your business logic suggests that the logs around the spaces are not useful they should be trimmed. However, in SQL Server there is no TRIM function. When a TRIM function is used it will throw an error. - [SQLAuthority News - Great Experience at SharePoint Conference Singapore 2013](https://blog.sqlauthority.com/2013/01/22/sqlauthority-news-great-experience-at-sharepoint-conference-singapore-2013/): Last week, I had great pleasure to present at SharePoint Conference Singapore . It was my second time visit to this event and I had a great time attending this event. The event had more than 900 attendees and it was moved to bigger and better location since the last time. As many of you know I usually present on the SQL Server Topic, however, I love pretty much every other technology equally great. The audience at SharePoint conference is much different than the SQL Server Conference, however at the end everybody had a same goal – learn something new. I decided... - [SQL SERVER - Best Practices to Store the SQL Server Backups](https://blog.sqlauthority.com/2013/01/21/sql-server-best-practices-to-store-the-sql-server-backups/): Nobody doubts the necessity to create SQL Server backups – I have covered this topic extensively before. The question of where to store the backups however often goes unanswered.  I will try to compare some of the most popular options for  this task. For demonstration purposes we will use the options that SQLBackupAndFTP provides us with, when we select a destination for storing backups. SQLBackupAndFTP form to select a backup destination SQL backup to Local/Network Folder/External HDD SQLBackupAndFTP Folder Settings form If you store the backup on the same drive as your database – you won’t have it when the disk... - [SQLAuthority News - Download Whitepaper - Introducing the BI Semantic Model in Microsoft SQL Server 2012](https://blog.sqlauthority.com/2013/01/20/sqlauthority-news-download-whitepaper-introducing-the-bi-semantic-model-in-microsoft-sql-server-2012/): IT industry has recognized that businesses benefit from a model layer over their data sources. Model layers can deliver high-performance query responses even over extremely large volumes of data, and they can encapsulate business rules and effectively secure access to data.  The BI Semantic Model is a single model that serves all of the end-user experiences for Microsoft BI, including reporting analysis and dashboarding. The model can integrate data from a number of data sources, whether they are traditional data sources, such as databases or LOB applications, or nontraditional sources, such as OData feeds, text files, and spreadsheets. The BI Semantic... - [SQL SERVER - Weekly Series - Memory Lane - #012](https://blog.sqlauthority.com/2013/01/19/sql-server-weekly-series-memory-lane-012/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 This was the year I started to understand the importance of the blogging and how it is changing my life. I started to make new friends and everything I learned now had permanent repository – this was indeed exciting. 2008 Time Out Due to Executing... - [SQL SERVER - A List of Various SQL Server RTM and Service Pack Number](https://blog.sqlauthority.com/2013/01/18/sql-server-a-list-of-various-sql-server-rtm-and-service-pack-number/): A common question I receive is that how do user know which version user is using and what is the latest service pack number available for the product. Here is something at this beginning of the year, check with your production server. - [SQL SERVER - An Interesting Case of Redundant Indexes - Index on Col1, Col2 and Index on Col1, Col2, Col3 - Part 4](https://blog.sqlauthority.com/2013/01/17/sql-server-an-interesting-case-of-redundant-indexes-index-on-col1-col2-and-index-on-col1-col2-col3-part-4/): This is the fourth part of the series regarding Redundant Indexes. If have not read earlier part – there is quite a good chance that you will miss the context of this part. I quickly suggest you to read earlier three parts. On my production server I personally use embarcadero DB Optimizer for all performance tuning and routine health check up. I will be interested to know what is your feedback about the product. Part 1: What is Redundant Indexes? Conversation between Mike and Jon – where they discuss about the fundamentals of Redundant Indexes. Part 2: Demo – What kind of Redundant Indexes are... - [SQL SERVER - Send Email From SQL Server - Configure Database Mail - SQL in Sixty Seconds #039 - Video](https://blog.sqlauthority.com/2013/01/16/sql-server-send-email-from-sql-database-configure-database-mail-sql-in-sixty-seconds-039-video/): Let me start this blog post with negative note: SQL Server is not mass mailing software. If you are thinking of sending emails using SQL Server instead of your mail server – I suggest you stop doing that NOW! Whenever, I see any application using SQL Server as a mail server – I always vote against it. Well, if this is so bad, then why is it possible to send email through SQL Server. The reason is simple – there are many SQL Server Administrative scenarios where we need SQL Server to send emails, e.g. Maintenance task status, job failure messages,... - [SQL SERVER - Introduction of Showplan Warning](https://blog.sqlauthority.com/2013/01/15/sql-server-introduction-of-showplan-warning/): Vinod Kumar M is my very good friend, renowned SQL Server Expert. Vinod Kumar has worked with SQL Server extensively since joining the industry over a decade ago. Before joining Microsoft, he was a Microsoft MVP for SQL Server for more than 3 years. He now works with MTC as a Technology Architect. He is a well-known speaker at all major Microsoft and third party technical conferences. Here is a very interesting blog post he sent on the subject of Executon Plan. Let us learn about introduction to Showplan Warning. - [SQLAuthority News - Attending SQLskills Training in February 2013](https://blog.sqlauthority.com/2013/01/14/sqlauthority-news-attending-sqlskills-training-in-february-2013/): If you read my resolutions blog post, you know that one of my dreams is to learn more, and specifically to attend a SQL Server class. Paul Randal and Kimberly Tripp, along with fantastic people like Jonathan, Glenn, Erin and Joe, runs amazing organization SQLskills. It is one of the most premium training companies. I have dreamed about attending for many years, but could not for many reasons. The reasons why I couldn’t are not the point, today the point is why I want to attend. First of all – how long will you wait for a dream to come true?... - [SQLAuthority News - Download Whitepaper - SSIS Operational and Tuning Guide - SSIS for Azure and Hybrid Data Movement - Leveraging a Hadoop cluster from SSIS](https://blog.sqlauthority.com/2013/01/13/sqlauthority-news-download-whitepaper-ssis-operational-and-tuning-guide-ssis-for-azure-and-hybrid-data-movement-leveraging-a-hadoop-cluster-from-ssis/): There are three interesting Whitepaper recently released by Microsoft regarding SSIS. If you are using SSIS enthusiast and work with Hybrid data this three Whitepapers are very essential white-paper in the reference. I am listing them here together for quick reference. The abstracts are built from the content of the white paper. SSIS Operational and Tuning Guide When transferring between a database and the cloud, data obviously is in transit.  This involves multiple phases, including pre-production testing, data loading, and data synchronization.  Sound complex?  SQL Server Integration Services (SSIS) is a tool created for moving data in and out of Windows... - [SQL SERVER - Weekly Series - Memory Lane - #011](https://blog.sqlauthority.com/2013/01/12/sql-server-weekly-series-memory-lane-011/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Query to find number Rows, Columns, ByteSize for each table in the current database – Find Biggest Table in Database In this blog post, I wrote a query only, no other words, no explanation and it turned out to be most desired query ever in... - [SQL SERVER - An Interesting Case of Redundant Indexes - Index on Col1, Col2 and Index on Col1, Col2, Col3 - Part 3](https://blog.sqlauthority.com/2013/01/11/sql-server-an-interesting-case-of-redundant-indexes-index-on-col1-col2-and-index-on-col1-col2-col3-part-3/): Before you start reading this blog post, I strongly suggest you to read the part 1 of this series.It talks about What is Redundant Index. The story is a conversation between two individuals – Jon and Mike. They are different but have single goal learn and explore SQL Server. Their initial conversation sets the ground for this blog post. They earlier discussed what is a Redundant Index as well, discussed what are the special cases for the same. It is a general assumption (or common best practices) is to drop Redundant Indexes. On my production server I personally use embarcadero DB Optimizer for all performance... - [SQLAuthority News - Speaking at Southeast Asia SharePoint Conference 2013](https://blog.sqlauthority.com/2013/01/10/sqlauthority-news-speaking-southeast-asia-sharepoint-conference-2013/): Here are a few things that I hear very often: I already have a SharePoint administrator, and I don’t need a database expert.  Or, my database is already configured because we already have SharePoint installed on its default settings.  Or, Microsoft has told us not to touch the SharePoint database.  All these things may be partial or 100% true. The problem is that living your life, or administrating a database, according on one single thought is not good.  Technology is more advanced than that, and one single idea is not going to help your database move and evolve with the times.... - [SQL SERVER - How to Hide Yourself from SQL Server? - Guest Post by Balmukund Lakhani](https://blog.sqlauthority.com/2013/01/09/sql-server-how-to-hide-yourself-from-sql-server-guest-post-by-balmukund-lakhani/): Balmukund Lakhani (Blog | Twitter | Site) is currently working as Technical Lead in SQL Support team with Microsoft India GTSC. In past 7+ years with Microsoft he was also a part of the Premier Field Engineering Team for 18 months. During that time he was a part of rapid on-site support (ROSS) team. Prior to joining Microsoft in 2005, he worked as SQL developer, SQL DBA and also got a chance to wear his other hat as an ERP Consultant. Balmukund is a great friend and one of the finest SQL Server Expert I know. When I requested him for Guest Post, he has indeed... - [SQL Server - Using SSMS Command Line Parameters](https://blog.sqlauthority.com/2013/01/08/sql-server-using-ssms-commandline-parameters-guest-post-by-vinod-kumar-m/): Vinod Kumar M is my very good friend, renowned SQL Server Expert. Vinod Kumar has worked with SQL Server extensively since joining the industry over a decade ago. Before joining Microsoft, he was a Microsoft MVP for SQL Server for more than 3 years. He now works with MTC as a Technology Architect. He is a well-known speaker at all major Microsoft and third party technical conferences. Here is a very interesting blog post he sent on the subject of SSMS Command Line Parameters. - [SQLAuthority News - Register for NuoDB the Elastically Scalable, SQL/ACID Database](https://blog.sqlauthority.com/2013/01/08/sqlauthority-news-register-for-nuodb-the-elastically-scalable-sqlacid-database/): If you are reading this blog, you will be familiar with the innovative database product NuoDB, which I have been experimenting recently. I have been working with this product since last year. I got my hand’s on this product when the product was in its very early phase as well, the product was yet to be ready. Now I feel very proud when I hear the announcement the product which I have seen growing from an infant stage to become extremely mature product. NuoDB started with a blank slate to design a brand new Cloud Data Management System (CDMS) that has all of the... - [SQL SERVER - An Interesting Case of Redundant Indexes - Index on Col1, Col2 and Index on Col1, Col2, Col3 - Part 2](https://blog.sqlauthority.com/2013/01/07/sql-server-an-interesting-case-of-redundant-indexes-index-on-col1-col2-and-index-on-col1-col2-col3-part-2/): Before you start reading this blog post, I strongly suggest you to read the part 1 of this series. It talks about What is Redundant Index. The story is a conversation between two individuals – Jon and Mike. They are different but have single goal learn and explore SQL Server. Their initial conversation sets the ground for this blog post. They earlier discussed what is a Redundant Index as well, discussed what are the special cases for the same. It is a general assumption (or common best practices) is to drop Redundant Indexes. Later Mike asks for special case where even... - [SQLAuthority News - Download Whitepaper - Cleanse and Match Master Data by Using EIM](https://blog.sqlauthority.com/2013/01/06/sqlauthority-news-download-whitepaper-cleanse-and-match-master-data-by-using-eim/): Master Data Services (MDM) and Data Quality Services (DQS) go hand to hand together when they have to maintain the integrity of the database. If you are new to either of concept I suggest you to read following two articles to get an idea about them. Why Do We Need Master Data Management: MDM was hailed as a major improvement for business intelligence. MDM comes into play because it will comb through these mountains of data and make sure that all the information is consistent, accurate, and all placed in one database so that employees don’t have to search high and low... - [SQL SERVER - Cursor, Truncate Log and More - Memory Lane #010](https://blog.sqlauthority.com/2013/01/05/sql-server-weekly-series-memory-lane-010/): This is the 10th episode of memory lane. Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. My favorite articles this week are about cursor and truncate log. Let me know which one of the following is your favorite article from memory lane. - [SQL SERVER - An Interesting Case of Redundant Indexes - Index on Col1, Col2 and Index on Col1, Col2, Col3 - Part 1](https://blog.sqlauthority.com/2013/01/04/sql-server-an-interesting-case-of-redundant-indexes-index-on-col1-col2-and-index-on-col1-col2-col3-part-1/): Index never stops amazing me, there are so much to learn about Index that I never feel that there is enough knowledge out about this subject. If you are interested you can watch my Indexing Course on Pluralsight for further learning on this subject. On my production server I personally use embarcadero DB Optimizer for all performance tuning and routine health check up. I will be interested to know what is your feedback about the product. Instead of going on the theory overload – let us start with this blog post as a conversation between two individuals – Jon and Mike. These are just random... - [SQLAuthority News - Year 2012 in Review - Perspective of Blog](https://blog.sqlauthority.com/2013/01/03/sqlauthority-news-year-2012-in-review-perspective-of-blog/): The WordPress.com stats helper monkeys prepared a Year 2012 annual report for this blog. I am very much delighted that the blog has been helping many different people throughout the world for many years. I really really thank you for your kind support in helping SQLAuthority.com blog becoming the resource for everyone to learn new things. - [SQL SERVER - Wrap SQL Code in SSMS - SQL in Sixty Seconds #038 - Video](https://blog.sqlauthority.com/2013/01/02/sql-server-wrap-sql-code-in-ssms-sql-in-sixty-seconds-038-video/): Every developer has a different habit. Some like to format the functions in upper case and some wants it in lower case. I often see developers listing the columns in SELECT clause in a different way. I have my own preference but I do respect the other developer’s preference as well. I do not advise to change anybodies habit but there is one thing which I strongly prefer to do on the client side when I am editing code. WRAP THE CODE! Well, it is indeed very difficult to read the code when users have to horizontally scroll the code. Now... - [SQLAuthority News - Resolutions of Year 2013 - Commitment to Myself](https://blog.sqlauthority.com/2013/01/01/sqlauthority-news-resolutions-of-year-2013-commitment-to-myself/): First of all, happy New Year to all of you – 2013 has started! Every year I make at least one resolution, some I do for the public on my blog.  The reason is simple – if I declare something in front of all of you, there is a good chance I will be held accountable to it.  Without my readers, no one will check up on me and it will be easy to fall off the wagon.  But this year I am making more than resolutions, I am making commitments to myself, and I want to follow them.  In fact,... - [SQLAuthority News - Last Post of Year 2012](https://blog.sqlauthority.com/2012/12/31/sqlauthority-news-last-post-of-year-2012/): The year 2012 was the most interesting year. If I start listing what was special about this year – I think it will take me 2-3 days to just write a blog post about this subject. Let me pick few things which I would like to specifically call out. SQL in Sixty Seconds Series We all can be very busy but we all have one minute of time. We can find 60 seconds of the time waiting at the gas station, using an elevator, waiting in line at Starbucks, or any other common place. Honestly 60 seconds is not a big... - [SQLAuthority News - Microsoft SQL Server ODBC Driver for Linux Available Now](https://blog.sqlauthority.com/2011/12/04/sqlauthority-news-microsoft-sql-server-odbc-driver-for-linux-available-now/): We discussion pretty much everything that DBA do in their daily life. Microsoft SQL Server ODBC Driver for Linux Available Now. - [SQLAuthority News - Download Whitepaper 5 Tips for a Smooth SSIS Upgrade to SQL Server 2012](https://blog.sqlauthority.com/2011/12/03/sqlauthority-news-download-whitepaper-5-tips-for-a-smooth-ssis-upgrade-to-sql-server-2012/): Microsoft SQL Server 2012 Integration Services (SSIS) provides significant improvements in both the developer and administration experience. This article provides tips that can help to make the upgrade to Microsoft SQL Server 2012 Integration Services successful. The tips address editing package configurations and specifically connection strings, converting configurations to parameters, converting packages to the project deployment model, updating Execute Package tasks to use project references and parameterizing the PackageName property. TIP #1: Edit Package Configuration and Data Source after upgrading TIP #2: Convert to project deployment model using Project Conversion Wizard TIP #3: Update Execute Package Task to use project reference... - [SQL SERVER - Effect of SET NOCOUNT on @@ROWCOUNT](https://blog.sqlauthority.com/2011/12/02/sql-server-effect-of-set-no-count-on-rowcount/): Today I had very interesting experience when I was presenting on SQL Server. While I was presenting the session when I ran query SQL Server Management Studio returned message like (8 row(s) affected) and (2 row(s) affected) etc. After a while at one point, I started to prove usage of @@ROWCOUNT function. - [SQL SERVER - Where Can YOU Get My Books - SQL Server Interview Question and Answers](https://blog.sqlauthority.com/2011/12/01/sql-server-where-can-you-get-my-books-sql-server-interview-question-and-answers-2/): Earlier month I released by third book SQL Server Interview Question and Answers. The focus of this book is ‘master the basics’. If you rate yourself 10 out of 10 in SQL Server – this book is not for you but if you want to learn fundamentals or want to refresh your fundamentals this book is for YOU. Earlier I was overwhelmed by love you all have shown to this book on release date leading our three digit inventory to run out of stock. Read detail blog post about the subject over here A Real Story of Book Getting ‘Out of... - [SQL SERVER - Fix: Error: File Cannot be Loaded Because the Execution of Scripts is Disabled on This System](https://blog.sqlauthority.com/2011/11/30/sql-server-fix-error-file-cannot-be-loaded-because-the-execution-of-scripts-is-disabled-on-this-system-please-see-get-help-about_signing-for-more-details/): Yesterday I formatted my computer and did a fresh install as it was due from a long time. After the fresh install when I tried to install Semantic Search application using PowerShell, I was stopped by the following error. The error was related to an execution of scripts.  - [SQL SERVER - Using expressor Composite Types to Enforce Business Rules](https://blog.sqlauthority.com/2011/11/29/sql-server-using-expressor-composite-types-to-enforce-business-rules/): One of the features that distinguish the expressor Data Integration Platform from other products in the data integration space is its concept of composite types, which provide an effective and easily reusable way to clearly define the structure and characteristics of data within your application.  An important feature of the composite type approach is that it allows you to easily adjust the content of a record to its ultimate purpose.  For example, a record used to update a row in a database table is easily defined to include only the minimum set of columns, that is, a value for the key... - [SQLAuthority News - SafePeak's SQL Server Performance Contest - Winners](https://blog.sqlauthority.com/2011/11/28/sqlauthority-news-safepeaks-sql-server-performance-contest-winners/): SafePeak, the unique automated SQL performance acceleration and performance tuning software vendor, announced the winners of their SQL Performance Contest 2011. The contest quite unique: the writer of the best / most interesting and most community liked “performance story” would win an expensive gadget. The judges were the community DBAs that could participating and Like’ing stories and could also win expensive prizes. Robert Pearl SQL MVP, was the contest supervisor. I liked most of the stories and decided then to contact SafePeak and suggested to participate in the give-away and they have gladly accepted the same. The winner of best story... - [SQL SERVER - Powershell - Get a List of Fixed Hard Drive and Free Space on Server](https://blog.sqlauthority.com/2011/11/27/sql-server-powershell-get-a-list-of-fixed-hard-drive-and-free-space-on-server/): Earlier I have written this article SQL SERVER – Get a List of Fixed Hard Drive and Free Space on Server. I recently received excellent comment by MVP Ravikanth. He demonstrated that how the same can be done using Powershell. It is very sweet and quick solution. Here is the powershell script. Run the same in your powershell windows. Get-WmiObject -Class Win32_LogicalDisk | Select -Property DeviceID, @{Name=’FreeSpaceMB’;Expression={$_.FreeSpace/1MB} } | Format-Table -AutoSize Well, I ran this script in my powershell window, it gave me following result – very accurately and easily. Get-WmiObject -Class Win32_LogicalDisk | Select -Property DeviceID, @{Name=’FreeSpaceMB’;Expression={$_.FreeSpace/1MB} } | Format-Table... - [SQL SERVER - Get Directory Structure using Extended Stored Procedure xp_dirtree](https://blog.sqlauthority.com/2011/11/26/sql-server-get-directory-structure-using-extended-stored-procedure-xp_dirtree/): Many years ago I wrote article SQL SERVER – Get a List of Fixed Hard Drive and Free Space on Server where I demonstrated using undocumented Stored Procedure to find the drive letter in local system and available free space. I received question in email from reader asking if there any way he can list directory structure within the T-SQL. When I inquired more he suggested that he needs this because he wanted set up backup of the data in certain structure. Well, there is one undocumented stored procedure exists which can do the same. However, please be vary to use any... - [SQL SERVER - DVM sys.dm_os_sys_info Column Name Changed in SQL Server 2012](https://blog.sqlauthority.com/2011/11/25/sql-server-dvm-sys-dm_os_sys_info-column-name-changed-in-sql-server-2012/): SQL SERVER - DVM sys.dm_os_sys_info Column Name Changed in SQL Server. Let us learn about it in today's blog post. - [SQL SERVER - Solution to Puzzle - Simulate LEAD() and LAG() without Using SQL Server 2012 Analytic Function](https://blog.sqlauthority.com/2011/11/24/sql-server-solution-to-puzzle-simulate-lead-and-lag-without-using-sql-server-2012-analytic-function/): Earlier I wrote a series on SQL Server Analytic Functions of SQL Server 2012. During the series to keep the learning maximum and having fun, we had few puzzles. One of the puzzle was simulating LEAD() and LAG() without using SQL Server 2012 Analytic Function. Please read the puzzle here first before reading the solution : Write T-SQL Self Join Without Using LEAD and LAG. When I was originally wrote the puzzle I had done small blunder and the question was a bit confusing which I corrected later on but wrote a follow up blog post on over here where I describe... - [SQL SERVER - 2012 - Summary of All the Analytic Functions - MSDN and SQLAuthority](https://blog.sqlauthority.com/2011/11/23/sql-server-2012-summary-of-all-the-analytic-functions-msdn-and-sqlauthority/): SQL Server 2012 (RC0 Available here) has introduced new analytic functions. These functions were long awaited and I am glad that they are now here. Before when any of this function was needed, people used to write long T-SQL code to simulate these functions. But now there’s no need of doing so. Having available native function also helps performance as well readability. - [SQL SERVER - Introduction to PERCENTILE_DISC() - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/22/sql-server-introduction-to-percentile_disc-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical function PERCENTILE_DISC(). The book online gives following definition of this function: Computes a specific percentile for sorted values in an entire rowset or within distinct partitions of a rowset in Microsoft SQL Server 2012 Release Candidate 0 (RC 0). For a given percentile value P, PERCENTILE_DISC sorts the values of the expression in the ORDER BY clause and returns the value with the smallest CUME_DIST value (with respect to the same sort specification) that is greater than or equal to P. If you are clear with understanding of the function – no need to read further.... - [SQL SERVER - Puzzle to Win Print Book - Explain Value of PERCENTILE_CONT() Using Simple Example](https://blog.sqlauthority.com/2011/11/21/sql-server-puzzle-to-win-print-book-explain-value-of-percentile_cont-using-simple-example/): From last several days I am working on various Denali Analytical functions and it is indeed really fun to refresh the concept which I studied in the school. Earlier I wrote article where I explained how we can use PERCENTILE_CONT() to find median over here SQL SERVER – Introduction to PERCENTILE_CONT() – Analytic Functions Introduced in SQL Server 2012. Today I am going to ask question based on the same blog post. Again just like last time the intention of this puzzle is as following: Learn new concept of SQL Server 2012 Learn new concept of SQL Server 2012 even if you are... - [SQL SERVER - Introduction to PERCENTILE_CONT() - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/20/sql-server-introduction-to-percentile_cont-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical function PERCENTILE_CONT(). The book online gives following definition of this function: Calculates a percentile based on a continuous distribution of the column value in Microsoft SQL Server 2012 Release Candidate 0 (RC 0). The result is interpolated and might not be equal to any of the specific values in the column. If you are clear with understanding of the function – no need to read further. If you got lost here is the same in simple words – it is lot like finding median with percentile value. Now let’s have fun following query: USE AdventureWorks... - [SQL SERVER - 2012 RC0 Various Resources and Downloads](https://blog.sqlauthority.com/2011/11/19/sql-server-2012-rc0-various-resources-and-downloads/): Microsoft SQL Server 2012 Release Candidate 0 (RC0) Microsoft SQL Server 2012 RC0 enables a cloud-ready information platform that will help organizations unlock breakthrough insights across the organization. Microsoft SQL Server 2012 Express RC Microsoft SQL Server 2012 Express RC0 is a powerful and reliable free data management system that delivers a rich set of features, data protection, and performance for embedded applications, lightweight Web Sites, applications, and local data stores. Microsoft SQL Server 2012 Semantic Language Statistics RC0 The Semantic Language Statistics Database is a required component for the Statistical Semantic Search feature in Microsoft SQL Server 2012 Semantic Language... - [SQL SERVER - Introduction to PERCENT_RANK() - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/18/sql-server-introduction-to-percent_rank-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical functions PERCENT_RANK(). This function returns relative standing of a value within a query result set or partition. It will be very difficult to explain this in words so I’d like to attempt to explain its function through a brief example. Instead of creating a new table, I will be using the AdventureWorks sample database as most developers use that for experiment purposes. Now let’s have fun following query: USE AdventureWorks GO SELECT SalesOrderID, OrderQty, RANK() OVER(ORDER BY SalesOrderID) Rnk, PERCENT_RANK() OVER(ORDER BY SalesOrderID) AS PctDist FROM Sales.SalesOrderDetail WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER... - [SQL SERVER - Puzzle to Win Print Book and Free 30 Days Online Training Material](https://blog.sqlauthority.com/2011/11/17/sql-server-puzzle-to-win-print-book-and-free-30-days-online-training-material/): Yesterday I had asked a simple question SQL SERVER – Puzzle to Win Print Book – Write T-SQL Self Join Without Using LEAD and LAG with keeping two simple intention. We can all learn about new feature of SQL Server 2012 We can learn new feature of SQL Server 2012 while practicing on earlier version of SQL Server. While I was creating question due to copy-paste error the question was not correctly created. In simple word – I made a mistake. This created some confusion and I feel bad about this. Here is what we will do. Please read the question again... - [SQL SERVER - Puzzle to Win Print Book - Write T-SQL Self Join Without Using LEAD and LAG](https://blog.sqlauthority.com/2011/11/16/sql-server-puzzle-to-win-print-book-write-t-sql-self-join-without-using-first-_value-and-last_value/): Last week we asked a puzzle SQL SERVER – Puzzle to Win Print Book – Functions FIRST_VALUE and LAST_VALUE with OVER clause and ORDER BY . This puzzle got very interesting participation. The details of the winner is listed here. In this puzzle we received two very important feedback. This puzzle cleared the concepts of First_Value and Last_Value to the participants. As this was based on SQL Server 2012 many could not participate it as they have yet not installed SQL Server 2012. I really appreciate the feedback of user and decided to come up something as fun and helps learn new... - [SQL SERVER - Introduction to LEAD and LAG - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/15/sql-server-introduction-to-lead-and-lag-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical function LEAD() and LAG(). These functions accesses data from a subsequent row (for lead) and previous row (for lag) in the same result set without the use of a self-join . It will be very difficult to explain this in words so I will attempt small example to explain you this function. Instead of creating new table, I will be using AdventureWorks sample database as most of the developer uses that for experiment. Let us fun following query. USE AdventureWorks GO SELECT s.SalesOrderID,s.SalesOrderDetailID,s.OrderQty, LEAD(SalesOrderDetailID) OVER (ORDER BY SalesOrderDetailID ) LeadValue, LAG(SalesOrderDetailID) OVER (ORDER BY SalesOrderDetailID... - [SQLAuthority News - A Real Story of Book Getting 'Out of Stock' to A 25% Discount Story Available](https://blog.sqlauthority.com/2011/11/14/sqlauthority-news-a-real-story-of-book-getting-out-of-stock-to-a-25-discount-story-available/): As many of my readers may know, I have recently written a few books.  Right now I’d like to talk about SQL Server Interview Questions and Answers (https://blog.sqlauthority.com/sql-server-books/sql-server-interview-questions-and-answers-for-all-database-developers-and-developers-administrators/ ), my newest release. What inspired me to write this book was similar to my motivations for my previous titles – I wanted to help people understand SQL Server concepts and ace interview questions so that they could get a great job they love, as much as I love my own job. If you are new to SQL Server, don’t think I left you out of my book writing efforts. If you are... - [SQL SERVER - CSVExpress and Quick Data Load](https://blog.sqlauthority.com/2011/11/13/sql-server-csvexpress-and-quick-data-load/): One of the newest ETL tools is CSVexpress.com.  This is a program that can quickly load any CSV file into ODBC compliant databases uses data integration.  For those of you familiar with databases and how they operate, the question that comes to mind might be what use this program will have in your life. I have written earlier article on this subject over here SQL SERVER – Import CSV into Database – Transferring File Content into a Database Table using CSVexpress. You might know that RDBMS have automatic support for loading CSV files into tables – but it is not quite... - [SQLAuthority News - Various Microsoft SQL Server Documentations Available for Download](https://blog.sqlauthority.com/2011/11/12/sqlauthority-news-various-microsoft-sql-server-documentations-available-for-download/): Microsoft has recently released various SQL Server related documentation and here I have listed them here for quick reference. - [SQL SERVER - Puzzle to Win Print Book - Functions FIRST_VALUE and LAST_VALUE with OVER clause and ORDER BY](https://blog.sqlauthority.com/2011/11/11/sql-server-puzzle-to-win-print-book-functions-first_value-and-last_value-with-over-clause-and-order-by/): Some time an interesting feature and smart audience makes total difference at places. From last two days, I have been writing on SQL Server 2012 feature FIRST_VALUE and LAST_VALUE. Please read following post before I continue today as this question is based on the same. Introduction to FIRST_VALUE and LAST_VALUE Introduction to FIRST_VALUE and LAST_VALUE with OVER clause As a comment of the second post I received excellent question from Nilesh Molankar. He asks what will happen if we change few things in the T-SQL. I really like this question as this kind of questions will make us sharp and help... - [SQL SERVER - OVER clause with FIRST _VALUE and LAST_VALUE - Analytic Functions Introduced in SQL Server 2012 - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING](https://blog.sqlauthority.com/2011/11/10/sql-server-over-clause-with-first-_value-and-last_value-analytic-functions-introduced-in-sql-server-2012-rows-between-unbounded-preceding-and-unbounded-following/): Yesterday I had discussed two analytical functions FIRST_VALUE and LAST_VALUE. After reading the blog post I received very interesting question. “Don’t you think there is bug in your first example where FIRST_VALUE is remain same but the LAST_VALUE is changing every line. I think the LAST_VALUE should be the highest value in the windows or set of result.” I find this question very interesting because this is very commonly made mistake. No there is no bug in the code. I think what we need is a bit more explanation. Let me attempt that first. Before you do that I suggest you... - [SQL SERVER - Introduction to FIRST _VALUE and LAST_VALUE - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/09/sql-server-introduction-to-first-_value-and-last_value-analytic-functions-introduced-in-sql-server-2012/): SQL Server 2012 introduces new analytical functions FIRST_VALUE() and LAST_VALUE(). This function returns first and last value from the list. It will be very difficult to explain this in words so I’d like to attempt to explain its function through a brief example. Instead of creating a new table, I will be using the AdventureWorks sample database as most developers use that for experiment purposes. Now let’s have fun following query: USE AdventureWorks GO SELECT s.SalesOrderID,s.SalesOrderDetailID,s.OrderQty, FIRST_VALUE(SalesOrderDetailID) OVER (ORDER BY SalesOrderDetailID) FstValue, LAST_VALUE(SalesOrderDetailID) OVER (ORDER BY SalesOrderDetailID) LstValue FROM Sales.SalesOrderDetail s WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER BY s.SalesOrderID,s.SalesOrderDetailID,s.OrderQty... - [SQLAuthority News - Updates on Contests, Books and SQL Server](https://blog.sqlauthority.com/2011/11/08/sqlauthority-news-updates-on-contests-books-and-sql-server/): There are lots of things happening on this blog and I feel sometime it is difficult to keep up. One of the suggestion I keep on receiving if there is a single page where one can visit and know the updates. I did consider of the same at some point but in era of RSS Feed it is difficult to have proper audience to that page. Here are few updates on various contest and books give away in recent time. Combo set of 5 Joes 2 Pros Book – 1 for YOU and 1 for Friend – I have received so... - [SQL SERVER - Introduction to CUME_DIST - Analytic Functions Introduced in SQL Server 2012](https://blog.sqlauthority.com/2011/11/08/sql-server-introduction-to-cume_dist-analytic-functions-introduced-in-sql-server-2012/): This blog post is written in response to the T-SQL Tuesday post of Prox ‘n’ Funx. This is a very interesting subject. By the way Brad Schulz is my favorite guy when it is about blogging. I respect him as well learn a lot from him. Everybody is writing something new his subject, I decided to start SQL Server 2012 analytic functions series. SQL Server 2012 introduces new analytical function CUME_DIST(). This function provides cumulative distribution value. It will be very difficult to explain this in words so I will attempt small example to explain you this function. Instead of creating... - [SQL SERVER - Video - Performance Improvement in Columnstore Index](https://blog.sqlauthority.com/2011/11/07/sql-server-video-performance-improvement-in-columnstore-index/): I earlier wrote an article about SQL SERVER – Fundamentals of Columnstore Index and it got very well accepted in community. However, one of the suggestion I keep on receiving for that article is that many of the reader wanted to see columnstore index in the action but they were not able to do that. Some of the readers did not install SQL Server 2012 or some did not have good machine to recreate the big table involved in the demo. For the same reason, I have created small video for that. [youtube=http://youtu.be/C-Ay6UxMfMo] I have written two more article on columstore... - [SQL SERVER - Updating Data in A Columnstore Index](https://blog.sqlauthority.com/2011/11/06/sql-server-updating-data-in-a-columnstore-index/): So far I have written two articles on Columnstore Indexes, and both of them got very interesting readership. In fact, just recently I got a query on my previous article on Columnstore Index. Read the following two articles to get familiar with the Columnstore Index. They will give you a reference to the question which was asked by a certain reader: SQL SERVER – Fundamentals of Columnstore Index SQL SERVER – How to Ignore Columnstore Index Usage in Query Here is the reader’s question: ” When I tried to update my table after creating the Columnstore index, it gives me an... - [SQL SERVER - SSMS 2012 Reset Keyboard Shortcuts to Default](https://blog.sqlauthority.com/2011/11/05/sql-server-ssms-2012-reset-keyboard-shortcuts-to-default/): As a technologist, I love my laptop very much and I do not lend it to anyone as I am usually worried that my settings would be messed up when I get it back from its borrower. Honestly, I love how I have set up my laptop and I enjoy the settings and programs I have placed on my computer. If someone changes things there – it will surely be annoying for me. Recently at one of the conferences I was attending in, a small accident happened – one of the speaker’s hard drives failed. The owner immediately panicked due to... - [SQL SERVER 2012 Editions - Highlights of The Cloud-Ready Information Platform](https://blog.sqlauthority.com/2011/11/04/sql-server-2012-editions-highlights-of-the-cloud-ready-information-platform/): Microsoft has just announced SQL Server 2012 Editions information on official SQL Server 2012 site. SQL Server 2012 will be available in three main editions: Enterprise Business Intelligence Standard The other editions are Web, Developer and Express. Here is the salient features of each of the edition: Enterprise Advanced high availability with AlwaysOn High performance data warehousing with ColumnStore Maximum virtualization (with Software Assurance) Inclusive of Business Intelligence edition’s capabilities Business Intelligence Rapid data discovery with Power View Corporate and scalable reporting and analytics Data Quality Services and Master Data Services Inclusive of the Standard edition’s capabilities Standard Standard continues to... - [SQLAuthority News - SQL Server Interview Questions And Answers Book Summary](https://blog.sqlauthority.com/2011/11/04/sqlauthority-news-sql-server-interview-questions-and-answers-book-summary/): Today we are using computers for various activities, motor vehicles for traveling to places, and mobile phones for conversation. How many of us can claim the invention of micro-processor, a basic wheel, or the telegraph? Similarly, this book was not written overnight. The journey of this book goes many years back with many individuals to be thanked for. To begin with, we want to thank all those interviewers who reject interviewees by saying they need to know ‘the key things’ regardless of having high grades in class. The whole concept of interview questions and answers revolves around knowing those ‘key things’.... - [SQLAuthority News - New Book Released - SQL Server Interview Questions And Answers](https://blog.sqlauthority.com/2011/11/03/sqlauthority-news-new-book-released-sql-server-interview-questions-and-answers/): Two days ago, on birthday of my blog – I asked simple question – Guess! What is in this box? I have received lots of interesting comments on the blog about what is in it. Many of you got it absolutely incorrect and many got it close to the right answer but no one got it 100% correct. Well, no issue at all, I am going to give away the price to whoever has the closest answer first in personal email. Here is the answer to the question about what is in the box? Here it is – the box has... - [SQL SERVER - Import CSV into Database - Transferring File Content into a Database Table using CSVexpress](https://blog.sqlauthority.com/2011/11/02/sql-server-import-csv-into-database-transferring-file-content-into-a-database-table-using-csvexpress/): One of the most common data integration tasks I run into is a desire to move data from a file into a database table.  Generally the user is familiar with his data, the structure of the file, and the database table, but is unfamiliar with data integration tools and therefore views this task as something that is difficult.  What these users really need is a point and click approach that minimizes the learning curve for the data integration tool.  This is what CSVexpress (www.CSVexpress.com) is all about!  It is based on expressor Studio, a data integration tool I’ve been reviewing over... - [SQLAuthority News - 5th Anniversary Giveaways](https://blog.sqlauthority.com/2011/11/01/sqlauthority-news-5th-anniversary-giveaways/): Please read my 5th Anniversary post and my quick note on history of the Database. I am sure that we all have friends and we value friendship more than anything. In fact, the complete model of Facebook is built on friends. If you have lots of friends, you must be a lucky person. Having a lot of friends is indeed a good thing. I consider all you blog readers as my friends so now I want do something for you. What is it? Well, send me details about how many of your friends like my page and you would have a... - [SQLAuthority News - History of the Database - 5 Years of Blogging at SQLAuthority](https://blog.sqlauthority.com/2011/11/01/sqlauthority-news-history-of-the-database-5-years-of-blogging-at-sqlauthority/): Don’t miss the Contest:Participate in 5th Anniversary Contest   Today is this blog’s birthday, and I want to do a fun, informative blog post. Five years ago this day I started this blog. Intention – my personal web blog. I wrote this blog for me and still today whatever I learn I share here. I don’t want to wander too far off topic, though, so I will write about two of my favorite things – history and databases.  And what better way to cover these two topics than to talk about the history of databases. If you want to be technical,... - [SQL SERVER - Database Dynamic Caching by Automatic SQL Server Performance Acceleration](https://blog.sqlauthority.com/2011/10/31/sql-server-database-dynamic-caching-by-automatic-sql-server-performance-acceleration/): My second look at SafePeak’s new version (2.1) revealed to me few additional interesting features. For those of you who hadn’t read my previous reviews SafePeak and not familiar with it, here is a quick brief: SafePeak is in business of accelerating performance of SQL Server applications, as well as their scalability, without making code changes to the applications or to the databases. SafePeak performs database dynamic caching, by caching in memory result sets of queries and stored procedures while keeping all those cache correct and up to date. Cached queries are retrieved from the SafePeak RAM in microsecond speed and not send to the SQL Server. The application gets much faster results (100-500 micro seconds), the load on the SQL Server is reduced (less CPU and IO) and the application or the infrastructure gets better scalability. - [SQL SERVER - How to Ignore Columnstore Index Usage in Query](https://blog.sqlauthority.com/2011/10/30/sql-server-how-to-ignore-columnstore-index-usage-in-query/): Earlier I wrote about SQL SERVER – Fundamentals of Columnstore Index and very first question I received in email was as following. “We are using SQL Server 2012 CTP3 and so far so good. In our data warehouse solution we have created 1 non-clustered columnstore index on our large fact table. We have very unique situation but your article did not cover it. We are running few queries on our fact table which is working very efficiently but there is one query which earlier was running very fine but after creating this non-clustered columnstore index this query is running very slow. We... - [SQL SERVER - Fundamentals of Columnstore Index](https://blog.sqlauthority.com/2011/10/29/sql-server-fundamentals-of-columnstore-index/): There are two kind of storage in database. Row Store and Column Store. Row store does exactly as the name suggests – stores rows of data on a page – and column store stores all the data in a column on the same page. These columns are much easier to search – instead of a query searching all the data in an entire row whether the data is relevant or not, column store queries need only to search much lesser number of the columns. This means major increases in search speed and hard drive use. Additionally, the column store indexes are heavily compressed, which translates to even greater memory and faster searches. I am sure this looks very exciting and it does not mean that you convert every single index from row store to columnstore index. One has to understand the proper places where to use row store or column store indexes. Let us understand in this article what is the difference in Columnstore type of index. - [SQLAuthority News - Online Webcast How to Identify Resource Bottlenecks - Wait Types and Queues](https://blog.sqlauthority.com/2011/10/28/sqlauthority-news-online-webcast-how-to-identify-resource-bottlenecks-wait-types-and-queues/): As all of you know I have been working a recently on the subject SQL Server Wait Statistics, the reason is since I have published book on this subject SQL Wait Stats Joes 2 Pros: SQL Performance Tuning Techniques Using Wait Statistics, Types & Queues [Amazon] | [Flipkart] | [Kindle], lots of question and answers I am encountering. When I was writing the book, I kept version 1 of the book in front of me. I wanted to write something which one can use right away. I wanted to create an primer for everybody who have not explored wait stats method... - [SQLAuthority News - SQL Server Wait Stats - eBook to Download on Kindle - Answer to FREE PDF Download Request](https://blog.sqlauthority.com/2011/10/27/sqlauthority-news-sql-server-wait-stats-ebook-to-download-on-kindle-answer-to-free-pdf-download-request/): Being a book author is a completely new experience for me. I am yet to come across the issues faced by expert book authors. I assume that these interesting issues can be routine ones for expert book authors. One of the biggest requests I am getting for my SQL Server Wait Stats [Amazon] | [Flipkart] | [Kindle] book is my humble attempt to write a book. This is our very first experiment, and the book is beginning of the subject of SQL Server Wait Stats; we will come up with a new version of the book later next year when we... - [SQLAuthority News - Book Signing Event - SQLPASS 2011 Event Log](https://blog.sqlauthority.com/2011/10/26/sqlauthority-news-book-signing-event-sqlpass-2011-event-log/): I have been dreaming of writing book for really long time, and I finally got the chance – in fact, two chances!  I recently wrote two books: SQL Programming Joes 2 Pros: Programming and Development for Microsoft SQL Server 2008 [Amazon] | [Flipkart] | [Kindle] and SQL Wait Stats Joes 2 Pros: SQL Performance Tuning Techniques Using Wait Statistics, Types & Queues [Amazon] | [Flipkart] | [Kindle].  I had a lot of fun writing these two books, even though sometimes I had to sacrifice some family time and time for other personal development to write the books. The good side of... - [SQLAuthority News - Meeting SQL Friends - SQLPASS 2011 Event Log](https://blog.sqlauthority.com/2011/10/25/sqlauthority-news-meeting-sql-friends-sqlpass-2011-event-log/): One of the biggest reason I go to SQLPASS is that my friends are going there too. There are so many friends with whom I often talk on Facebook and Twitter but I rarely get time to meet them as well talk with them. One thing I am usually sure that many fo them will be for sure attend SQLPASS. This is one event which every SQL Server Enthusiast should attend. Just like everybody I had pleasant time to meet many of my SQL friends. There were so many friends that I met and I did not click photo. There were... - [SQLAuthority News - Story of Seattle - SQLPASS 2011 Event Log](https://blog.sqlauthority.com/2011/10/24/sqlauthority-news-story-of-seattle-sqlpass-2011-event-log/): Just like every year I attended SQL PASS in Seattle earlier this month. The event was scheduled from Oct 11-14, 2011 in the convention center of the Seattle. I have been to Seattle more than 6 times so far so it is not a new city for me anymore. The city has always impressed me with its vibrant life and pleasant weather. Just like every other time, I had excellent experience once again in the city. Though I just arrived on the day of the event and left right after the event was over – I hardly visited Seattle – still... - [SQL SERVER - Dedicated Access Control for SQL Server Express Edition - An error occurred while obtaining the dedicated administrator connection (DAC) port.](https://blog.sqlauthority.com/2011/10/23/sql-server-dedicated-access-control-for-sql-server-express-edition-an-error-occurred-while-obtaining-the-dedicated-administrator-connection-dac-port/): Recently I had faced very interesting situation. Due to some reason we were not able to login into the production server for one of client. The reason for the same was that server was very busy, we had to login into the system and bring server to normal situation. When all the attempts failed, I decided to login using Dedicated Administrator Connection (DAC). However when I attempted to connect using DAC it threw following error for me. C:\Users\pinald>sqlcmd -A -d master -S .\SQLEXPRESS Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : SQL Server Network Interfaces: An error occurred while obtaining... - [Personal Notes - Random Thoughts and Random Ideas](https://blog.sqlauthority.com/2011/10/22/personal-notes-random-thoughts-and-random-ideas/): There are days when I keep on wondering about SQL, and even my life overall. Let us see some random thoughts and random ideas. - [SQL SERVER - DATEDIFF - Accuracy of Various Dateparts](https://blog.sqlauthority.com/2011/10/21/sql-server-datediff-accuracy-of-various-dateparts/): I recently received the following question through email and I found it very interesting so I want to share it with you. “Hi Pinal, In SQL statement below the time difference between two given dates is 3 sec, but when checked in terms of Min it says 1 Min (whereas the actual min is 0.05Min) SELECT DATEDIFF(MI,'2011-10-14 02:18:58' , '2011-10-14 02:19:01') AS MIN_DIFF Is this is a BUG in SQL Server ?” Answer is NO. It is not a bug; it is a feature that works like that. Let us understand that in a bit more detail. When you instruct SQL... - [SQL SERVER - TRACEWRITE - Wait Type - Wait Related to Buffer and Resolution](https://blog.sqlauthority.com/2011/10/20/sql-server-tracewrite-wait-type-wait-related-to-buffer-and-resolution/): Earlier this year I wrote for a whole month on SQL Server Wait Stats and the series was one of the best reviewed I have ever written. The same series has been enhanced and compiled into a book as SQL Server Wait Stats [Amazon] | [Flipkart] | [Kindle]. The best part of this book is it is an evolving book. I am planning to expand this book at certain intervals. Yesterday I came across a very interesting system, where the top most wait type was TRACEWRITE. The DBA of the system reached out to me asking what this wait types means... - [SQL SERVER - A Simple Quiz - T-SQL Brain Trick](https://blog.sqlauthority.com/2011/10/19/sql-server-a-simple-quiz-t-sql-brain-trick/): Today we are going to have very simple and interesting question. Run following T-SQL Code in SSMS. There are total of five lines. Three T-SQL statements separated by two horizontal lines. SELECT MAX(OBJECT_ID) FROM sys.objects ______________________________________ SELECT MIN(OBJECT_ID) FROM sys.objects ______________________________________ SELECT COUNT(OBJECT_ID) FROM sys.objects Now when you execute individual lines only it will give you error as Msg 2812, Level 16, State 62, Line 1 Could not find stored procedure '______________________________________'. However, when you executed all the five statement together it will give you following resultset. What is the reason of the same? Please leave your comment as answer. I... - [SQL SERVER - Next Version of SQL Server 'Denali' is Officially Named as SQL Server 2012](https://blog.sqlauthority.com/2011/10/18/sql-server-next-version-of-sql-server-denali-is-officially-named-as-sql-server-2012/): Recently I attended SQLPASS 2011 and it had few announcements and some of them really important. I am going to write in detail in future all the announcements. However, there is one announcement needs special attention and blog post. The official name of the next version of the SQL Server. So far we were all addressing the next version of the SQL Server as SQL Server ‘Denali’. Microsoft VP Ted Kummert announced the official name of the next version of the SQL Server – SQL Server 2012. The version of the SQL Server will be 11. The release date is estimated... - [SQLAuthority News - Your Performance Story - My Contribution to Your Learning](https://blog.sqlauthority.com/2011/10/18/sqlauthority-news-your-performance-story-my-contribution-to-your-learning/): I was recently playing with SafePeak‘s performance tuning tool, while I was on their site, I noticed that they have contest running where they are giving away expensive gadgets. The contest has some really nice entries and I few of the participants are my close friends as well. I liked most of the stories. I contacted the contest owners that if I can also participate in the give-away and they have gladly accepted the same. Now you can win my  SQL Programming Joes 2 Pros (vol 4) [Amazon] | [Flipkart] | [Kindle] by participating into the contest. You can share your... - [SQLAuthority News - SafePeak version 2.1 for SQL Server Performance Acceleration](https://blog.sqlauthority.com/2011/10/17/sqlauthority-news-safepeak-releases-a-major-update-safepeak-version-2-1-for-sql-server-performance-acceleration/): Couple of months ago I had the opportunity to share with my first look at SafePeak, a new and unique software solution for improving SQL Server performance and solving bottlenecks, accelerates the data access and cuts the CPU and IO of your SQL Server. SafePeak unique approach not just tells you about the problems but actually resolves them automatically and improves SQL Server performance and the performance of the applications dramatically. Let us read about Performance Acceleration. - [SQL SERVER - Three DMVs - sys.dm_server_memory_dumps - sys.dm_server_services - sys.dm_server_registry](https://blog.sqlauthority.com/2011/10/16/sql-server-denali-three-dmvs-sys-dm_server_memory_dumps-sys-dm_server_services-sys-dm_server_registry/): In this blog post we will see three new DMVs which are introduced in Denali. The DMVs are very simple and there is not much to describe them. So here is the simple game. I will be asking a question back to you after seeing the result of the each of the DMV and you help me to complete this blog post. - [SQLAuthority News - SQL Server 2008 SP3 Available to Download](https://blog.sqlauthority.com/2011/10/15/sqlauthority-news-sql-server-2008-sp3-available-to-download/): This news is one week late but still very useful as per my perspective. Please note this are for SQL Server 2008 and will not work with SQL Server 2008 R2. SQL Server 2008 Service Pack 3 Enhanced upgrade experience from previous versions of SQL Server to SQL Server 2008 SP3. In addition, we have increased the performance & reliability of the setup experience. In SQL Server Integration Services logs will now show the total number of rows sent in Data Flows. Enhanced warning messages when creating the maintenance plan if the Shrink Database option is enabled. Resolving database issue with... - [SQL SERVER - SQLPASS Memory Lane of 2009 and 2010](https://blog.sqlauthority.com/2011/10/14/sql-server-sqlpass-memory-lane-of-2009-and-2010/): Today is the last day of the SQLPASS 2011 and I will be soon posting SQL Server 2011 experience over here. We all change, life change, event changes, experiences change and but memory hardly changes. I have quite commonly noticed that we all remember the good memories for long time and no matter how bad the memories are we often forget the same. Here is my experience of my earlier experience of attending SQLPASS. SQLAuthority News – SQLPASS Nov 8-11, 2010-Seattle – An Alternative Look at Experience SQLAuthority News – Notes of Excellent Experience at SQL PASS 2009 Summit, Seattle Every... - [SQLAuthority News - SQLPASS - Today FREE 100 SQL Wait Stats Book Print Copy - Book Signing](https://blog.sqlauthority.com/2011/10/13/sqlauthority-news-sqlpass-today-free-100-sql-wait-stats-book-print-copy/): “If there’s a book you really want to read, but it hasn’t been written yet, then you must write it.” ~Toni Morrison I wrote book on SQL Wait Stats. [Amazon] | [Flipkart] | [Kindle] I really wanted to learn about SQL Wait Stats. There was no real book available so I wrote the book myself. Since I wrote this book, I feel I can now more 100 pages to what I had contributed. I am very fortunate that my SQL Wait Stats book is very well accepted in community. Every author who authors book has dream that his book is well received... - [SQLAuthority News - SQLPASS - 100 SQL Wait Stats Book Print Copy Giveaway - A Book Every Minute for an Hour Tomorrow](https://blog.sqlauthority.com/2011/10/12/sqlauthority-news-sqlpass-100-sql-wait-stats-book-print-copy-giveaway-a-book-every-minute-for-an-hour-tomorrow/): “Appreciation is a wonderful thing: It makes what is excellent in others belong to us as well” – Voltaire “The greatest of all gifts is the power to estimate things at their true worth” – Francois De La Rochefoucauld Please Note: The date and time are Thursday 13 at 1 PM (not Wednesday) – there are few emails asking for the same. Quotes listed above are really relevant to the news of the day. Regular readers of my blog knows that I have published SQL Server Wait Stats [Amazon] | [Flipkart] book. I am glad to say that this book has... - [SQL SERVER - expressor Studio 3.4 Rules Editor - ETL Graphical Coding Tool](https://blog.sqlauthority.com/2011/10/11/sql-server-expressor-studio-3-4-rules-editor-etl-graphical-coding-tool/): New in the expressor Studio 3.4 release is the rules editor.  This graphical coding tool replaces the transform editor of earlier versions.  The rules editor works in concert with the newly introduced attribute propagation functionality to minimize the amount of data mapping and coding you need to provide.  The expressor folks are telling me that in a future release we will be able to save and reuse rules, which will make everyone’s  application development tasks even simpler and less prone to errors. So what’s attribute propagation?  expressor’s starting point observation is that in any transformation most values are either copied from... - [SQLAuthority News - Why I am Going to Attend PASS Summit Unite 2011 - Seattle](https://blog.sqlauthority.com/2011/10/11/sqlauthority-news-why-i-am-going-to-attend-pass-summit-unite-2011-seattle/): For the third year in a row, I am attending the SQLPASS Summit, October 11-14. Every year I have explained my reasons for attending this conference in Seattle, and this year I will state those reasons again. WHY? I have written two articles on this subject, which you can read here: 2009 and 2010. My main reason for attending has not changed – I love it! Why should I attend PASS Summit? There are not one or two but many reasons why I should be a part of PASS Summit. First, it is a good platform to learn the latest skills... - [SQLAuthority News - Milestone - 1900th Post and 31 Million Views - Thank You!](https://blog.sqlauthority.com/2011/10/10/sqlauthority-news-milestone-1900th-post-and-31-million-views-thank-you/): I really never thought that I would be writing this post - honestly! After 1900th post and almost 5 years, this has been a journey and lots of learning. I get to write a 100 “mile stone” post 3-4 times a year, so I am happy to be writing this one. I am eagerly looking forward to my 2000th blog post as well. - [SQLAuthority News - System Center Monitoring Pack for Microsoft SQL Server 2008 R2 Parallel Data Warehouse Appliance](https://blog.sqlauthority.com/2011/10/09/sqlauthority-news-system-center-monitoring-pack-for-microsoft-sql-server-2008-r2-parallel-data-warehouse-appliance/): Microsoft is continuously releasing System Center Monitoring Pack for Microsoft SQL Server 2008 R2 Parallel Data Warehouse Appliance - [SQLAuthority News - SQL Server Quiz 2011 - All was well few moments before all went wrong - Reasons and Resolutions](https://blog.sqlauthority.com/2011/10/08/sqlauthority-news-sql-server-quiz-2011-all-was-well-few-moments-before-all-went-wrong-reasons-and-resolutions/): I earlier wrote about DBA Quiz at All was well few moments before all went wrong – Reasons and Resolutions. I have even announced that I will give away one print book of SQL Wait Stats book. SQL Programming Joes 2 Pros (vol 4) [Amazon] | [Flipkart]- Chapter 13 has few interesting hints. However, I want to announce one more thing today. I will give giving away not one but 2 copies of the SQL Wait Stats books [Amazon] | [Flipkart] . SQL Wait Stats book is available for very low cost on Kindle at this moment. This is special promotion... - [SQL SERVER - Server Side Paging in SQL Server CE (Compact Edition)](https://blog.sqlauthority.com/2011/10/07/sql-server-server-side-paging-in-sql-server-ce-compact-edition/): SQL Server Denali is coming up with new T-SQL of Paging. I have written about the same earlier. SQL SERVER – Server Side Paging in SQL Server Denali – A Better Alternative SQL SERVER – Server Side Paging in SQL Server Denali Performance Comparison SQL SERVER – Server Side Paging in SQL Server Denali – Part2 What is very interesting is that SQL Server CE 4.0 have the same feature introduced. Here is the quick example of the same. To run the script in the example, you will have to do install Webmatrix 4.0 and download sample database. Once done you... - [SQL SERVER - Detecting Database Case Sensitive Property using fn_helpcollations()](https://blog.sqlauthority.com/2011/10/06/sql-server-detecting-database-case-sensitive-property-using-fn_helpcollations/): In my recent Office Hours, I received a question on how to determine the case sensitivity of the database. Let us learn about how we can Detecting Database Case Sensitive Property using fn_helpcollations(). - [SQLAuthority News - SQL Wait Stats Book - Available as Kindle eBook - October Special](https://blog.sqlauthority.com/2011/10/05/sqlauthority-news-sql-wait-stats-book-available-as-kindle-ebook-october-special/): Get SQL Wait Stats – Kindle Edition Last month I released my SQL Wait Stats  book. This book is the beginning of my journey in wait stats. It has been extremely popular and so far in India it has sold all the print copies twice on Flipkart. This book is available in the United States on Amazon and it has gotten a tremendous response as well. What is special about this book is that it gives you the opportunity to start on performance tuning instantly after receiving the book. The scripts are very simple and they are all available online on... - [SQL SERVER - Quick Note about JOIN - Common Questions and Simple Answers](https://blog.sqlauthority.com/2011/10/04/sql-server-quick-note-about-join-common-questions-and-simple-answers/): This blog post is written in response to the T-SQL Tuesday post of JOIN. This is a very interesting subject. Years ago, I wrote my article about SQL SERVER – Introduction to JOINs – Basic of JOINs, ‑ till date, it is my most favorite article on the blog. Today we are going to talk about join and lots of things related to the JOIN. I recently started office hours to answer questions and issues of the community. I receive so many questions that are related to JOIN. I will share few of the same over here. Most of them are... - [SQL SERVER - CE - 3 Links to Performance Tuning Compact Edition](https://blog.sqlauthority.com/2011/10/04/sql-server-ce-3-links-to-performance-tuning-compact-edition/): Today, I am going to do webcast online on how to improve performance for SQL CE. Here are three articles which I am going to base my session. Database Design and Performance (SQL Server Compact Edition) Use Database Denormalization Decide Between Variable and Fixed-length Columns Create Smaller Row Lengths Use Smaller Key Lengths Publication Article Types and Options Query Performance Tuning (SQL Server Compact Edition) Improve Indexes Choose What to Index Use the Query Optimizer Understand Response Time vs. Total Time Rewrite Subqueries to Use JOIN Use Parameterized Queries Query Only When You Must Optimizing Connectivity (SQL Server Compact Edition) Synchronization... - [SQL SERVER - SQL Backup and FTP - A Quick and Handy Tool](https://blog.sqlauthority.com/2011/10/03/sql-server-sql-backup-and-ftp-a-quick-and-handy-tool/): Scroll down at the end of this post to win my SQL Wait Stats Book. I have used this tool extensively since 2009 at numerous occasion and found it to be very impressive. What separates it from the crowd the most – it is it’s apparent simplicity and speed. When I install SQLBackupAndFTP and configure backups – all in 1 or 2 minutes, my clients are always impressed. To put it simply, SQLBackupAndFTP is MS SQL Server backup software that performs these tasks: Backup SQL Server Database Zip the backups Encrypt the backups FTP the backups to remote FTP server Move... - [SQL SERVER - CE - List of Information_Schema System Tables](https://blog.sqlauthority.com/2011/10/02/sql-server-ce-list-of-information_schema-system-tables/): Yesterday I wrote  blog post that I downloaded WebMatrix and it was very easy to install, after installing I noticed it has default database as SQL CE. I started to play with SQL CE and I was glad that it supports many of the Information_Schema. There is one important thing I need to mention. Yesterday I shared Sample Database of the SQL CE. Few of the readers tried to install that database in other versions and it give them error. Please note that SQL CE will only and will not work with any other version of the database. Here are few... - [SQL SERVER - CE - Samples Database for SQL CE 4.0](https://blog.sqlauthority.com/2011/10/01/sql-server-ce-samples-database-for-sql-ce-4-0/): I recently installed WebMatrix Version Next. I found it very neat and easy to install. You can download it for FREE. After installing it I download when I checked the about page, it displayed following result. ————————— About WebMatrix ————————— Version 2 Beta WebMatrix: 7.1.1307.1 IIS 7.5 Express: 7.1.1307.1 .NET Framework: 4.0.30319.235 (RTMGDR.030319-2300) Web Deploy: 7.1.1307.1 SQL Server Compact: 4.0.8482.1 Web Platform Installer: 7.1.1307.1 ASP.NET Web Pages: 1.0.20105.407 ASP.NET Web Pages: 2.0.10906.0 What got my attention was that when I noticed SQL Server Compact version 4 installed with WebMatrix. As soon as I see this SQL Server CE, I decided to... - [SQL SERVER - Denali - DMV - sys.dm_os_windows_info - Information about Operating System](https://blog.sqlauthority.com/2011/09/30/sql-server-denali-dmv-sys-dm_os_windows_info-information-about-operating-system/): One more quick introduction to DMV for Denali. Following DMV provides information about Windows Operating System. Here is the quick example of the same. This DMV returns information about the operating system volume (directory) on which the specified databases and files are stored. Here is the quick example I have created for the same. SELECT * FROM sys.dm_os_windows_info; Here is the screenshot of the same: Here is my question back to you – where would you use this stored procedure in your application? What is your preferred method to know details about Windows? One last question – what is 1033 in... - [SQL SERVER - Denali - DMV - sys.dm_os_volume_stats - Information about operating system volume](https://blog.sqlauthority.com/2011/09/30/sql-server-denali-dmv-sys-dm_os_volume_stats-information-about-operating-system-volume/): SQL Server Denali has many new interesting feature – one of the interesting feature is New DMVs. This DMV returns information about the operating system volume (directory) on which the specified databases and files are stored. Here is the quick example I have created for the same. SELECT DB_NAME(f.database_id) DatabaseName, f.FILE_ID, size DBSize, file_system_type, volume_mount_point, total_bytes, available_bytes FROM sys.master_files AS f CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.FILE_ID); Here is the screenshot of the same: In the result set we can see the file system and volume database is mounted on as well database size. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Various Ways to Stay in Touch with SQLAuthority.com - Best Practices](https://blog.sqlauthority.com/2011/09/29/sqlauthority-news-various-ways-to-stay-in-touch-with-sqlauthority-com-best-practices/): Social Media is growing and quite commonly we reach to the point where we have confusion about the various aspects of the same. I have written a previous article on this subject SQLAuthority News – Social Media Confusion – Twitter, FaceBook, LinkedIn and Me. I am present and active at so many spots that many wonder on how to approach me. I have decided to create this blog post, which will serve as a quick guide for others regarding how to stay in touch with SQLAuthority.com My Personal Coordinates Twitter: https://mobile.twitter.com/pinaldave Facebook: LinkedIn: https://www.linkedin.com/in/pinaldave Email: pinal ‘at’ SQLAuthority.com Blog Coordinates Facebook:... - [SQL SERVER - Denali - DMV Enhancement - sys.dm_exec_query_stats - New Columns](https://blog.sqlauthority.com/2011/09/28/sql-server-denali-dmv-enhancement-sys-dm_exec_query_stats-new-columns/): SQL Server version next Denali has lots of enhancements. Some of the enhancements are just game changing and overcomes needs of more coding to do the same thing. Similar function DMV is sys.dm_exec_query_stats. There are four new columns added to this DMV. I have often used this DMV to check recently ran query, their execution plan by joining more DMVs to it. However, there was also need of knowing how many rows my queries have returned. This DMV is enhanced with four more queries. total_rows – Total number of rows returned by query last_rows – Number of the rows return by... - [SQLAuthority News - Tomorrow Online Session - Ancient Trade of Performance Tuning - Index, Beyond Index and No Index](https://blog.sqlauthority.com/2011/09/28/sqlauthority-news-tomorrow-online-session-ancient-trade-of-performance-tuning-index-beyond-index-and-no-index/): Today in few hours I am going to present on my very favorite subject of performance tuning. You can read more about this sessions over here. This presentation is based on the famous book ‘The Art of War’ written in sixth century BC by Sun Tzu. Index is usually a favorite tool of many when it is about performance tuning. However, Index is not everything. Performance tuning is much very deep subject and one needs to understand various aspect of the performance tuning. In today’s session I will cover performance tuning beyond indexes. I have created some real interesting demos. Sessions... - [SQLAuthority News - 31 Millions Views - Free 5 Print Copy of SQL Wait Types and Queues](https://blog.sqlauthority.com/2011/09/27/sqlauthority-news-31-millions-views-free-5-print-copy-of-sql-wait-types-and-queues/): Earlier this year in February, I wrote a 30-day series on Wait Types and Queue. This series was very popular and I have received a number of good and encouraging comments on various parts of the series. The no.1 request was to compile the concept in an eBook. This idea really appealed to me. Talking about personal preferences, I do not like eBooks as I spend lots of time on the computer, and if I have to read books, I prefer to read printed ones my way. Driven with the same idea, I published SQL Wait Types and Queues in print... - [SQLAuthority News - Online Session - Ancient Trade of Performance Tuning - Index, Beyond Index and No Index](https://blog.sqlauthority.com/2011/09/26/sqlauthority-news-online-session-ancient-trade-of-performance-tuning-index-beyond-index-and-no-index/): Performance Tuning has been my favorite subject always. I love this subject the most. I personally have enjoyed every aspect of performance tuning. Quite often I have seen that when it is about performance, people end up talking about Indexes. Index for sure can help performance, but it is like secret weapon and it must be used carefully as the same thing can be dangerous. I have personally attended many sessions that are related to Indexes as well as how to identify the correct index and remove useless indexes. I always wanted Indexing presentation to bring much more than these usual... - [SQL SERVER - Denali - Startup Parameters Easy to Configure](https://blog.sqlauthority.com/2011/09/26/sql-server-denali-startup-parameters-easy-to-configure/): If you are regular reader of this blog, you must be aware that I have written about SQL Server Denali recently. I just finished a writing about various functions of Denali SQL SERVER – Denali – 14 New Functions – A Quick Guide. While working with Denali, at one point, I wanted to change the startup limits of the Denali. While working with Denali, I saw a very convenient method of changing the startup parameters. I just loved this clear way of changing the start up parameters. Here is the quick way to reach to the screen where we can change... - [SQLAuthority News - Learn SQL Azure at Microsoft Virtual Academy](https://blog.sqlauthority.com/2011/09/25/sqlauthority-news-learn-sql-azure-at-microsoft-virtual-academy/): The Microsoft Virtual Academy offers no-cost, easy-access training for IT professionals who want to get ahead in cloud computing. Developed by leading experts in this field, these modules ensure that you acquire essential skills and gain credibility as the cloud computing specialist in your organization. MVA guides you through real-life deployment scenarios and the latest cloud computing technologies and tools. By selecting the training modules that match your needs, you can use valuable new skills that help take your career to the next level. - [SQL SERVER - Denali - Download CTP3 Demo VHD Including Fully Configured Services and Integration with SharePoint 2010 and Office 2010](https://blog.sqlauthority.com/2011/09/24/sql-server-denali-download-ctp3-demo-vhd-including-fully-configured-services-and-integration-with-sharepoint-2010-and-office-2010/): During my office hours observed, a very common question is”What is Denali?” once I answer that Denali is the next version of the SQL Server, the follow up question is where can I download it. I have explained the installation and download part over here: SQL SERVER – Denali CTP3 – Step by Step Installation Video – 200 Seconds . Most of the feature of the Denali can be just experienced as it is on native T-SQL. However, to experience all the features of the SQL Server Denali CTP3, one needs SharePoint 2010 and Office 2010. Microsoft has build VHD which... - [Puzzle - Usage of New Index Hints - ForceSeek and ForceScan](https://blog.sqlauthority.com/2011/09/23/puzzle-usage-of-new-index-hints-forceseek-and-forcescan/): Tomorrow is the weekend. I just thought, let us explore something new but a quick puzzle to explore about index hints. SQL Server Denali has new Query Hint - FORCESCAN. In earlier version of SQL Server we already have Query Hint FORCESEEK but now the counter part also exists. The quick understanding is there will be cases when FORCESEEK or FORCESCAN will be helpful and improve the performance of the query. - [SQL SERVER - Learning SSAS (SQL Server Analysis Services) Online in 6 Hours - Top Down Designing and Bottom Up Designing](https://blog.sqlauthority.com/2011/09/22/sql-server-learning-ssas-sql-server-analysis-services-online-in-6-hours-top-down-designing-and-bottom-up-designing/): Those who are following me on Twitter and Facebook know that recently I am reenforcing my own concept for SQL Server Analysis Services (SSAS). Like many of us, I worked with Analysis Services in early years. In an earlier job, I got many projects for relational database performance tuning and over time, I lost touch with SSAS. This does not mean that I forgot all of the concepts but the ‘real’ hands-on experience was gathering dust. Looking back at the last five years, I realized that I have deep experience with relational performance tuning but there are a few new things which I have yet to explore and learn. - [SQLAuthority News - Latest expressor Data Integration Platform Posts](https://blog.sqlauthority.com/2011/09/22/sqlauthority-news-latest-expressor-data-integration-platform-posts/): Here is the quick summary of my recent blog post which I have written while I am experimenting expressor data Integration platform. SQL SERVER – Introduction to expressor 3.4 Lookup Tables In this blog post, I am going to take a closer look at expressor’s new and extremely versatile implementation of lookup tables, which they are releasing as part of the upcoming expressor 3.4 product release. SQL SERVER – Introduction to expressor Datascript Modules With the release of expressor 3.3, expressor software has added a significant new feature to the expressor Studio tool – the ability to easily extend functionality through... - [SQL SERVER 2012 Functions - 14 New Functions - A Quick Guide](https://blog.sqlauthority.com/2011/09/21/sql-server-denali-14-new-functions-a-quick-guide/): Last two weeks I wrote various blog posts on new functions introduced in SQL Server 2012. So many comments and request I have received from various readers that they would like to see everything together. I have put up a quick guide here where I am writing all the 14 new SQL Server 2012 Functions linking them to my blog post as well Book On-Line for a quick reference. - [SQL SERVER - Denali - Date and Time Functions - EOMONTH() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/20/sql-server-denali-date-and-time-functions-eomonth-a-quick-introduction/): In SQL Server Denali, seven new datetime functions have been introduced, namely, DATEFROMPARTS (year, month, day) DATETIME2FROMPARTS (year, month, day, hour, minute, seconds, fractions, precision) DATETIMEFROMPARTS (year, month, day, hour, minute, seconds, milliseconds) DATETIMEOFFSETFROMPARTS (year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision) SMALLDATETIMEFROMPARTS (year, month, day, hour, minute) TIMEFROMPARTS (hour, minute, seconds, fractions, precision) EOMONTH (start_date) EOMONTH() is a very interesting function. It is a very common requirement in many major applications where the user needs the last day of the month. It is very easy to figure out what is the first day of the month because obviously,... - [SQL SERVER 2012 - DateTime Functions - DATEFROMPARTS() - DATETIMEFROMPARTS() - DATETIME2FROMPARTS()](https://blog.sqlauthority.com/2011/09/19/sql-server-2012-datetime-functions-datefromparts-datetimefromparts-datetime2fromparts-timefromparts-smalldatetimefromparts/): In SQL Server 2012, there are seven new datetime functions being introduced, namely: DATEFROMPARTS ( year, month, day) DATETIME2FROMPARTS ( year, month, day, hour, minute, seconds, fractions, precision ) DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds ) DATETIMEOFFSETFROMPARTS ( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision ) SMALLDATETIMEFROMPARTS ( year, month, day, hour, minute ) TIMEFROMPARTS ( hour, minute, seconds, fractions, precision ) EOMONTH () - [SQLAuthority News - Implementing a Microsoft SQL Server Parallel Data Warehouse Using the Kimball Approach](https://blog.sqlauthority.com/2011/09/18/sqlauthority-news-implementing-a-microsoft-sql-server-parallel-data-warehouse-using-the-kimball-approach/): This white paper explores how the Kimball approach to architecting and building a data warehouse/business intelligence (DW/BI) system works with Microsoft’s Parallel Data Warehouse, and how you would incorporate this new product as the cornerstone of your DW/BI system. For readers who are not familiar with the Kimball approach, we begin with a brief overview of the approach and its key principles. We then explore the Parallel Data Warehouse (PDW) system architecture and discuss its alignment with the Kimball approach. In the last section, we identify key best practices and pitfalls to avoid when building or migrating a large data warehouse... - [SQLAuthority News - Automation of Data Mining Using Integration Services](https://blog.sqlauthority.com/2011/09/18/sqlauthority-news-automation-of-data-mining-using-integration-services/): This article is a walkthrough that illustrates how to build multiple related data models by using the tools that are provided with Microsoft SQL Server Integration Services. In this walkthrough, you will learn how to automatically build and process multiple data mining models based on a single mining structure, how to create predictions from all related models, and how to save the results to a relational database for further analysis. Finally, you view and compare the predictions, historical trends, and model statistics in SQL Server Reporting Services reports. This solution also introduces the concept of ensemble models for data mining, which... - [SQL SERVER - Denali - String Function - FORMAT() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/17/sql-server-denali-string-function-format-a-quick-introduction/): In SQL Server Denali, there are two new string functions being introduced, namely: CONCAT() FORMAT() Today we will quickly take a look at the FORMAT() function. FORMAT converts the first argument to specified format and returns the string value. This function is locale-aware and it can return the formatting of the datetime and number to as per the locale specified string. This function also uses the server .NET Framework and CLR. I was personally waiting for this function for long time and inclusion of this function made me very happy as this single function will solve lots of formatting issues for... - [SQL SERVER 2012 - String Function CONCAT() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/16/sql-server-denali-string-function-concat-a-quick-introduction/): In SQL Server 2012, there are two new string functions being introduced, namely: CONCAT(), FORMAT(). In this blog post we are going to learn about String Function CONCAT(). CONCAT takes a minimum of two arguments to concatenate them, resulting to a single string. - [SQLAuthority News - Uncut and Unedited - Interview of Pinal Dave on Book Authoring](https://blog.sqlauthority.com/2011/09/15/sqlauthority-news-uncut-and-unedited-interview-of-pinal-dave-on-book-authoring/): I was very happy when books were published and I got a print copy in my hand. In this blog post we will discuss about Book Authoring. - [SQL SERVER - Introduction to expressor 3.4 Lookup Tables](https://blog.sqlauthority.com/2011/09/14/sql-server-introduction-to-expressor-3-4-lookup-tables/): In this blog post, I am going to take a closer look at expressor’s new and extremely versatile implementation of lookup tables, which they are releasing as part of the upcoming expressor 3.4 product release.  As creation and use of the lookup table can be managed completely through simple-to-use graphical interfaces, it is very easy to utilize this feature in expressor data integration applications.  And for developers who want full control over the functionality, an API provides direct access to the table allowing their applications to read, write, update, and delete table content.  Let’s see how this all comes together! The... - [SQL SERVER - Denali - New Functions and Shorthand for CASE Statement](https://blog.sqlauthority.com/2011/09/13/sql-server-denali-new-functions-and-shorthand-for-case-statement-2/): This blog post is written in response to the T-SQL Tuesday post of Data Presentation. This is a very interesting subject. I recently started to write about Denali Logical and Comparison functions. I really enjoyed writing about new functions, but there was one question kept cropping up – is the CASE statement being replaced with this new functions. The answer is NO. New functions that are introduced are just shorthand for the CASE statement, and they are not replacing anything. 1) TRY_PARSE() is not replacing the CASE statement, infect it is not. However, it can be smartly used along with the... - [SQL SERVER - Denali CTP3 - Step by Step Installation Video - 200 Seconds](https://blog.sqlauthority.com/2011/09/12/sql-server-denali-ctp3-step-by-step-installation-video-200-seconds/): My recent article on SQL SERVER – Download Denali CTP3 and Denali CTP 3 Product Guide has inspired today’s post. After reading this blog post, I received a few emails and few comments on facebook page that if I can post a video guide to Denali CTP3 installation. Finally I create this video which is about how one can install SQL Server Denali CTP3. There is no audio in this video as the video is very simple and one can understand it quite easily. [youtube=http://www.youtube.com/watch?v=lb0uVSGjD1w] Click here to watch the Denali CTP3 Installation Video on YouTube. Let me know if you like... - [SQL SERVER - DBA Quiz 2011 - All was well few moments before all went wrong - Reasons and Resolutions](https://blog.sqlauthority.com/2011/09/12/sql-server-dba-quiz-2011-all-was-well-few-moments-before-all-went-wrong-reasons-and-resolutions/): My question just got published at DBA Quiz 2011. This question is inspired from a real life incident, which occurred to me a few years ago. That time, I was a DBA myself and then one fine day, everything went south. When we checked the log, all the logs were fine till few minutes before our server started to face the issue. After working for long hours, we fixed the issue. Our CTO had called us to analyze the situation. Instead of blaming anyone, he adorned an extremely positive attitude. He suggested that we all go out and come back with... - [SQL SERVER 2012 - Logical Function CHOOSE() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/11/sql-server-denali-logical-function-choose-a-quick-introduction/): In SQL Server 2012, there are two new logical functions being introduced, namely: IIF() and CHOOSE(). Today we will quickly take a look at the logical CHOOSE() function. This function is very simple and it returns specified index from a list of values. If Index is numeric, it is converted to integer. On the other hand, if the index is greater than the element in the list, it returns NULL. - [SQL SERVER - Denali - Logical Function - IIF() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/10/sql-server-denali-logical-function-iif-a-quick-introduction/): In SQL Server Denali, there are two new logical functions being introduced, namely: IIF() CHOOSE() Today, we will have a look at the IIF() function. This function does not need any introduction as developers have used this function in various languages from ages. This function is shorthand way for writing CASE statement. These functions take three arguments. If the first argument is true, it will return the second argument as result or it will return the third argument as result. IIF can be nested as well, which makes its usage very interesting. The limit of nesting of IIF is same as... - [SQL SERVER - Denali - Conversion Function - Difference between PARSE(), TRY_PARSE(), TRY_CONVERT()](https://blog.sqlauthority.com/2011/09/09/sql-server-denali-conversion-function-difference-between-parse-try_parse-try_convert/): In SQL Server Denali, three new conversion functions have been introduced, namely, PARSE() TRY_PARSE() TRY_CONVERT() - [SQL SERVER - Denali - Conversion Function - TRY_CONVERT() - A Quick Introduction](https://blog.sqlauthority.com/2011/09/08/sql-server-denali-conversion-function-try_convert-a-quick-introduction/): In SQL Server Denali, there are three new conversion functions being introduced, namely: PARSE() TRY_PARSE() TRY_CONVERT() Today we will quickly take a look at the TRY_CONVERT() function. The TRY_CONVERT() function is very similar to CONVERT function which is avail in SQL Server already. Only difference is that it will attempt to CONVERT the datatype in specified datatype and while doing the same, if it fails (or error occurs) instead of displaying error it will return value NULL. Function CONVERT() is same as in earlier version (as far as I know till CTP3). Now let us examine these examples showing how TRY_CONVERT()... - [SQL SERVER – Precision of SMALLDATETIME – A 1 Minute Precision](https://blog.sqlauthority.com/2010/06/01/sql-server-precision-of-smalldatetime-a-1-minute-precision/): I am myself surprised that I am writing this post today. I am going to present one of the very known facts of SQL Server SMALLDATETIME datatype. Even though this is a very well-known datatype, many a time, I have seen developers getting confused with precision of the SMALLDATETIME datatype. The precision of the datatype SMALLDATETIME is 1 minute. It discards the seconds by rounding up or rounding down any seconds greater than zero. Let us see the following example DECLARE @varSDate AS SMALLDATETIME SET @varSDate = '1900-01-01&nbsp;12:12:01' SELECT @varSDate C_SDT SET @varSDate = '1900-01-01&nbsp;12:12:29' SELECT @varSDate C_SDT SET @varSDate =... - [SQLAuthority News - Monthly Roundup of Best SQL Posts](https://blog.sqlauthority.com/2010/05/31/sqlauthority-news-monthly-roundup-of-best-sql-posts/): After receiving lots of requests from different readers for long time I have decided to write first monthly round up. If all of you like it I will continue writing the same every month. In fact, I really like the idea as I was able to go back and read all of my posts written in this month. This month was started with answering one of the most common question asked me to about What is Adventureworks? Many of you know the answer but to the surprise more number of the reader did not know the answer. There were few extra... - [SQLAuthority News - Guest Post - Performance Counters Gathering using Powershell](https://blog.sqlauthority.com/2010/05/30/sqlauthority-news-guest-post-performance-counters-gathering-using-powershell/): Laerte Junior has previously helped me personally to resolve the issue with Powershell installation on my computer. He did an awesome job to help. He has sent this another wonderful article regarding performance counter for readers of this blog. I really liked it and I expect all of you who are Powershell geeks, you will like the same as well. - [SQLAuthority News - SQL Funny Quotes](https://blog.sqlauthority.com/2010/05/29/sqlauthority-news-guest-post-fault-contract-in-wcf-with-learning-video/): Here are few SQL Funny Quotes. Q. What if your Dad loses his car keys? A. 'Parent keys not found!' - [SQL SERVER - Disabled Index and Update Statistics](https://blog.sqlauthority.com/2010/05/28/sql-server-disabled-index-and-update-statistics/): When we try to update the statistics, it throws an error as if the clustered index is disabled. Now let us enable the clustered index only and attempt to update the statistics of the table right after that. Let us learn about Disabled Index and Update Statistics. - [SQL SERVER - DATE and TIME in SQL Server 2008](https://blog.sqlauthority.com/2010/05/27/sql-server-date-and-time-in-sql-server-2008/): I was thinking about DATE and TIME datatypes in SQL Server 2008. I earlier wrote about the about best practices of the same. Recently I had written one of the scripts written for SQL Server 2008 had to run on SQL Server 2005 (don’t ask me why!), I had to convert the DATE and TIME datatypes to DATETIME. Let me run a quick demo for the same. - [SQLAuthority News - SQL Server Technology Evangelists and Evangelism](https://blog.sqlauthority.com/2010/05/26/sqlauthority-news-sql-server-technology-evangelists-and-evangelism/): This is the exact conversation that I had with three people during the recent SQL Server Public Training. Person 1: “Are you an SQL Server Evangelist?” Pinal : “No, but Vinod Kumar is.” Person 1: “Who are you?” Person 2: “He is Pinal, haha!” Person 1: “I know that, but don’t you evangelize SQL Server Technology?” Pinal : “Hmm… I do that…” Person 1: “In that case, why don’t you call yourself an Evangelist?” Pinal : “…! …” Person 2: “Good Question! Who are you Pinal?” Pinal : “I think you are asking my title, is that correct?” Person 1: “Maybe.”... - [SQLAuthority News - Win MS Office License - Last 2 days](https://blog.sqlauthority.com/2010/05/26/sqlauthority-news-win-ms-office-license-last-2-days/): Just a note for everybody who is from India and want to win FREE Office License, participate in very easy contest here. SQLAuthority News – Virtual Launch Event for Office 2010 – Contest – Win MS Office License Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Whitepaper - SQL Azure vs. SQL Server](https://blog.sqlauthority.com/2010/05/25/sqlauthority-news-whitepaper-sql-azure-vs-sql-server/): SQL Server and SQL Azure are two Microsoft Products which goes almost together. There are plenty of misconceptions about SQL Azure. I have seen enough developers not planning for SQL Azure because they are not sure what exactly they are getting into. Some are confused thinking Azure is not powerful enough. I disagree and strongly urge all of you to read following white paper written and published by Microsoft. SQL Azure vs. SQL Server by Dinakar Nethi, Niraj Nagrani SQL Azure Database is a cloud-based relational database service from Microsoft. SQL Azure provides relational database functionality as a utility service. Cloud-based... - [SQLAuthority News – Microsoft SQL Server 2008 R2 – PowerPivot for Microsoft Excel 2010](https://blog.sqlauthority.com/2010/05/24/sqlauthority-news-microsoft-sql-server-2008-r2-powerpivot-for-microsoft-excel-2010/): Microsoft has really and truly created some buzz for PowerPivot. I have been asked to show the demo of Powerpivot in recent time even when I am doing relational database training. Attached is the few details where everyone can download PowerPivot and use the same. Microsoft SQL Server 2008 R2 – PowerPivot for Microsoft Excel 2010 – RTM Microsoft® PowerPivot for Microsoft® Excel 2010 provides ground-breaking technology, such as fast manipulation of large data sets (often millions of rows), streamlined integration of data, and the ability to effortlessly share your analysis through Microsoft® SharePoint 2010. Microsoft PowerPivot for Excel 2010 Samples... - [SQL SERVER – Check the Isolation Level with DBCC useroptions](https://blog.sqlauthority.com/2010/05/24/sql-server-check-the-isolation-level-with-dbcc-useroptions/): In recent consultancy project coordinator asked me – “can you tell me what is the isolation level for this database?” I have worked with different isolation levels but have not ever queried database for the same. I quickly looked up bookonline and found out the DBCC command which can give me the same details. You can run the DBCC UserOptions command on any database to get few details about dateformat, datefirst as well isolation level. DBCC useroptions Set Option                  Value --------------------------- -------------- textsize                    2147483647 language                    us_english dateformat                  mdy datefirst                   7 lock_timeout                -1 quoted_identifier           SET arithabort                  SET ansi_null_dflt_on           SET ansi_warnings               SET ansi_padding               ... - [SQLAuthority News - Virtual Launch Event for Office 2010 - Contest - Win MS Office License](https://blog.sqlauthority.com/2010/05/23/sqlauthority-news-virtual-launch-event-for-office-2010-contest-win-ms-office-license/): Office products are integral products of any PC. I accept that without Office Suites, I can not survive or make enough leaving. I am blogger and use word to create my blogs. I am SQL Server Trainer  and I use PowerPoint as my presentation tool. I am SQL Server consultant and I use Excel to keep my work log. I can not see my life with Office Tools. Just like any other Microsoft Product there is strong community following Office Tools. Please count me in. The same community is hosting a Virtual Launch Event for Office 2010 on May 25 and... - [SQLAuthority News - Downloads Available for Microsoft SQL Server Compact 3.5](https://blog.sqlauthority.com/2010/05/22/sqlauthority-news-downloads-available-for-microsoft-sql-server-compact-3-5/): There are few downloads released for Microsoft SQL Server Compact 3.5. Here is quick lists of the same. Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Desktop SQL Server Compact 3.5 SP2 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP2 and Synchronization Services for ADO.NET version 1.0 SP1 on Windows desktop. Microsoft SQL Server Compact 3.5 Service Pack 2 Server Tools SQL Server Compact 3.5 SP2 Server Tools Windows Installer (MSI) file installs replication components on the computer... - [SQL SERVER - Simple Example of Snapshot Isolation - Reduce the Blocking Transactions](https://blog.sqlauthority.com/2010/05/21/sql-server-simple-example-of-snapshot-isolation-reduce%c2%a0the%c2%a0blocking%c2%a0transactions/): To learn any technology and move to a more advanced level, it is very important to understand the fundamentals of the subject first. Today, we will be talking about something which has been quite introduced a long time ago but not properly explored when it comes to the isolation level. Snapshot Isolation was introduced in SQL Server in 2005. However, the reality is that there are still many software shops which are using the SQL Server 2000, and therefore cannot be able to maintain the Snapshot Isolation. Many software shops have upgraded to the later version of the SQL Server, but... - [SQLAuthority News – Professional Development and Community](https://blog.sqlauthority.com/2010/05/20/sqlauthority-news-professional-development-and-community/): I was recently invited by Hyderabad Techies to deliver a keynote for their 16-day online session called TECH THUNDERS. This event has been running from May 15 and will continue up to the end of the month May 30). There would be a total of 30 sessions. In every evening of those 16 day, there will be either one or two sessions from several noted industry experts. It is the same group which has received the Microsoft Community Impact Award as the Best User Group in India as for developers. This was my opportunity to talk about Professional Development. - [SQLAuthority News – Updated Favorite Scripts and Best Articles Page](https://blog.sqlauthority.com/2010/05/19/sqlauthority-news-updated-favorite-scripts-and-best-articles-page/): I have been writing on this blog for around 4 years now and have contributed with more than 1300 blog posts. Many times, I have been asked regarding what is my most favorite article or which is the most essential script for developers and DBA. This is very difficult to answer as I so much effort has been put on my blog and a large amount of content has been generated. However, I do keep a running list of my most favorite scripts and articles. This same are listed on the side bar of this blog as well; I am including... - [SQLAuthority Book Review - DBA Survivor: Become a Rock Star DBA](https://blog.sqlauthority.com/2010/05/18/sqlauthority-book-review-dba-survivor-become-a-rock-star-dba/): DBA Survivor: Become a Rock Star DBA – Thomas LaRock Link to Amazon Link to Flipkart First of all, I thank all my readers when I wrote that I could not get this book in any local book stores, because they offered me to send a copy of this good book. A very special mention goes to Sripada and Jayesh for they gave so much effort in finding my home address and sending me the hard copy. Before, I did not have the copy of the book, but now I have two of it already! It surprises me how my readers... - [SQLAuthority News - Bookmark - Deprecated Database Engine Features in SQL Server 2008](https://blog.sqlauthority.com/2010/05/17/sqlauthority-news-bookmark-deprecated-database-engine-features-in-sql-server-2008/): When anyone asked me if any specific feature is available in SQL Server 2008 or if any feature will be disabled in future versions of SQL Server, I always pointed to the following list where all the deprecated database engine features are listed. - [SQLAuthority News - Storage and SQL Server Capacity Planning and configuration - SharePoint Server 2010](https://blog.sqlauthority.com/2010/05/16/sqlauthority-news-storage-and-sql-server-capacity-planning-and-configuration-sharepoint-server-2010/): Just a day ago, I was asked how do you plan SQL Server Storage Capacity. Here is the excellent article published by Microsoft regarding SQL Server capacity planning for SharePoint 2010. This article touches all the vital areas of this subject. Here are the bullet points for the same. Gather storage and SQL Server space and I/O requirements Choose SQL Server version and edition Design storage architecture based on capacity and IO requirements Determine memory requirements Understand network topology requirements Configure SQL Server Validate storage performance and reliability Read the original article published by Microsoft here: Storage and SQL Server Capacity... - [SQL SERVER - List All the DMV and DMF on Server](https://blog.sqlauthority.com/2010/05/15/sql-server-list-all-the-dmv-and-dmf-on-server/): "How many DMV and DVF are there in SQL Server 2008?" - this question was asked to me in one of the recent SQL Server Training. - [SQL SERVER - Find Most Expensive Queries Using DMV](https://blog.sqlauthority.com/2010/05/14/sql-server-find-most-expensive-queries-using-dmv/): The title of this post is what I can express here for this quick blog post. I was asked in recent query tuning consultation project, if I can share my script which I use to figure out which is the most expensive queries are running on SQL Server. This script is very basic and very simple, there are many different versions are available online. This basic script does do the job which I expect to do - find out the most expensive queries in SQL Server Box. - [SQL SERVER - Four Posts on Removing the Bookmark Lookup - Key Lookup](https://blog.sqlauthority.com/2010/05/13/sql-server-four-posts-on-removing-the-bookmark-lookup-key-lookup/): Recently, I have observed that not many people have proper understanding of what is bookmark lookup or key lookup. Increasing numbers of the questions tells me that this is something that developers encounter every single day, but have no idea how to deal with. I have previously written three posts on this subject. All those who are looking for further information can check out the following three posts. SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key... - [SQL SERVER - Understanding ALTER INDEX ALL REBUILD with Disabled Clustered Index](https://blog.sqlauthority.com/2010/05/12/sql-server-understanding-alter-index-all-rebuild-with-disabled-clustered-index/): This blog is in response to the ongoing communication with the reader who had earlier asked the question of SQL SERVER – Disable Clustered Index and Data Insert. The same reader has asked me the difference between ALTER INDEX ALL REBUILD and ALTER INDEX REBUILD along with disabled clustered index. Instead of writing a big theory, we will go over the demo right away. Here are the steps that we intend to follow. 1) Create Clustered and Nonclustered Index 2) Disable Clustered and Nonclustered Index 3) Enable – a) All Indexes, b) Clustered Index USE tempdb GO -- Drop Table if Exists IF EXISTS (SELECT *... - [SQL SERVER - Spatial Database Queries - What About BLOB](https://blog.sqlauthority.com/2010/05/11/sql-server-spatial-database-queries-what-about-blob-t-sql-tuesday-006/): Michael Coles is one of the most interesting book authors I have ever met. He has a flair of writing complex stuff in a simple language. There are a very few people like that. I really enjoyed reading his recent book, Expert SQL Server 2008 Encryption. I strongly suggest taking a look at it. Let us learn about Spatial Database Queries. - [SQL SERVER - Size of Index Table for Each Index - Solution 3 - Powershell Index Size](https://blog.sqlauthority.com/2010/05/10/sql-server-size-of-index-table-for-each-index-solution-3-powershell/): If you are a Powershell user, the name of the Laerte Junior is not a new name. He is the one man with exceptional knowledge of Powershell. He is not only very knowledgeable, but also very kind and eager to those in need. I have been attempting to setup Powershell for many days, but constantly facing issues. I was not able to get going with this tool. Finally, yesterday I sent email to Laerte in response to his comment posted here. Within 5 minutes, Laerte came online and helped me with the solution. He spend nearly 15 minutes working along with me to solve my problem with installation. And yes, he did resolve it remotely without looking at my screen – What a skilled and exceptional person!! I will soon post a detail note about the issue I faced and resolved with the help of Laerte. Let us see how we can find Powershell Index Size. - [SQL SERVER - Size of Index Table for Each Index - Solution 2](https://blog.sqlauthority.com/2010/05/09/sql-server-size-of-index-table-for-each-index-solution-2/): Earlier I had ran puzzle where I asked question regarding size of index table for each index in database over here SQL SERVER – Size of Index Table – A Puzzle to Find Index Size for Each Index on Table. I had received good amount answers and I had blogged about that here SQL SERVER – Size of Index Table for Each Index – Solution. As a comment to that blog I have received another very interesting comment and that provides near accurate answers to original question. Many thanks to Rama Mathanmohan for providing wonderful solution. SELECT OBJECT_NAME(i.OBJECT_ID) AS TableName, i.name... - [SQLAuthority News - MSDN Flash Mentions - TechNet Flash Mention - Top Community Contributors (Annual) Winner](https://blog.sqlauthority.com/2010/05/08/sqlauthority-news-msdn-flash-mentions-technet-flash-mention-top-community-contributors-annual-winner/): I was going over my email to reach the famous Inbox (0), and I happened to come across TechNet Flash and MSDN Flash emails. I had kept them because those email editions had my names mentioned in them. Immediately, I took the screenshot of these. I am posting them here for later reference. It is always good idea to store important information for revisiting the memory lane. As a recent update, Microsoft has awarded me Top Community Contributors (Annual) Winners. I am thankful to you all as I would have not done this without your valuable contribution. I want to dedicate... - [SQLAuthority News - List of Master Data Services White Paper](https://blog.sqlauthority.com/2010/05/07/sqlauthority-news-list-of-master-data-services-white-paper/): Since my TechEd India 2010 presentation I am very excited with SQL Server 2010 Master Data Services. I just come across very interesting white paper on Microsoft site related to this subject. Here is the list of the same and location where you can download them. They are all written by Top Experts at Microsoft. - [SQLAuthority News - SQL Server 2008 R2 Hosted Trial](https://blog.sqlauthority.com/2010/05/06/sqlauthority-news-sql-server-2008-r2-hosted-trial/): This is a bit old news but for me but it will new for many of you know. SQLPASS, Dell, Microsoft and MaximumASP has come together and build hosted environment for free to all of us to use and experiment with. Register now to try out up to seven labs: SQL Server 2008 R2 – Multi Server Management SQL Server 2008 R2 – PowerPivot SQL Server 2008 R2 – Reporting Services SQL Server 2008 R2 – Master Data Services SQL Server 2008 R2 – StreamInsight SQL Server Integration Services – Introduction SQL Server Integration Services – Intermediate to Advanced Now this... - [SQLAuthority News - Wireless Router Security and Attached Devices - Complex Password](https://blog.sqlauthority.com/2010/05/06/sqlauthority-news-wireless-router-security-and-attached-devices-complex-password/): In the last week, I have received calls from friends who told me that they have got strange emails from me. To my surprise, I did not send them any emails. I was not worried until my wife complained that she was not able to find one of the very important folders containing our daughter’s photo that is located in our shared drive. This was alarming in my par, so I started a search around my computer’s folders. Again, please note that I am by no means a security expert. I checked my entire computer with virus and spyware, and strangely,... - [SQL SERVER - Get Latest SQL Query for Sessions - DMV](https://blog.sqlauthority.com/2010/05/05/sql-server-get-latest-sql-query-for-sessions-dmv/): In recent SQL Training I was asked, how can one figure out what was the last SQL Statement executed in sessions. The query for this is very simple. It uses two DMVs and created following quick script for the same. SELECT session_id, TEXT FROM sys.dm_exec_connections CROSS APPLY sys.dm_exec_sql_text(most_recent_sql_handle) AS ST While working with DMVs if you ever find any DMV has column with name sql_handle you can right away join that DMV with another DMV sys.dm_exec_sql_text and can get the text of the SQL statement. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Microsoft SQL Server 2005/2008 Query Optimization and Performance Tuning Training](https://blog.sqlauthority.com/2010/05/04/sqlauthority-news-microsoft-sql-server-20052008-query-optimization-performance-tuning-training/): Last 3 days to register for the courses. This is one time offer with big discount. The deadline for the course registration is 5th May, 2010. There are two different courses are offered by Solid Quality Mentors 1) Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning – Pinal Dave Date: May 12-14, 2010 Price: Rs. 14,000/person for 3 days Discount Code: ‘SQLAuthority.com’ Effective Price: Rs. 11,000/person for 3 days 2) SharePoint 2010 – Joy Rathnayake Date: May 10-11, 2010 Price: Rs. 11,000/person for 3 days Discount Code: ‘SQLAuthority.com’ Effective Price: Rs. 8,000/person for 2 days Download the complete PDF brochure.... - [SQL SERVER - SHRINKFILE and TRUNCATE Log File in SQL Server 2008](https://blog.sqlauthority.com/2010/05/03/sql-server-shrinkfile-and-truncate-log-file-in-sql-server-2008/): Note: Please read the complete post before taking any actions. This blog post would discuss SHRINKFILE and TRUNCATE Log File. The script mentioned in the email received from reader contains the following questionable code: “Hi Pinal, If you could remember, I and my manager met you at TechEd in Bangalore. We just upgraded to SQL Server 2008. One of our jobs failed as it was using the following code. The error was: Msg 155, Level 15, State 1, Line 1 ‘TRUNCATE_ONLY’ is not a recognized BACKUP option. The code was: DBCC SHRINKFILE(TestDBLog, 1) BACKUP LOG TestDB WITH TRUNCATE_ONLY DBCC SHRINKFILE(TestDBLog, 1)... - [SQL SERVER - The Difference between Dual Core vs. Core 2 Duo](https://blog.sqlauthority.com/2010/05/02/sql-server-the-difference-between-dual-core-vs-core-2-duo/): I have decided that I would not write on this subject until I have received a total of 25 questions on this subject about dual core.  - [SQL SERVER - What is AdventureWorks?](https://blog.sqlauthority.com/2010/05/01/sql-server-what-is-adventureworks/): A few days ago, I received DM asking What is an AdventureWorks database and why in all the examples I use that instead of any other database (e.g. Pubs or  Northwind)? As matter of fact, when I went back to my question list, which I have yet not answered, there were a few more variations of this same question. - [SQLAuthority News - TechEd India - April 12-14, 2010 Bangalore - An Unforgettable Experience](https://blog.sqlauthority.com/2010/04/30/sqlauthority-news-teched-india-april-12-14-2010-bangalore-an-unforgettable-experience-an-opportunity-of-a-lifetime/): TechEd India was one of the largest Technology events in India led by Microsoft. This event was attended by more than 3,000 technology enthusiasts, making it one of the most well-organized events of the year. Though I attempted to attend almost all the technology events here, I have not seen any bigger or better event in Indian subcontinents other than this. There are 21 Technical Tracks at Tech·Ed India 2010 that span more than 745 learning opportunities. I was fortunate enough to be a part of this whole event as a speaker and a delegate, as well. - [SQL SERVER - Disable Clustered Index and Data Insert](https://blog.sqlauthority.com/2010/04/29/sql-server-disable-clustered-index-and-data-insert/): Earlier today, I received following email. “Dear Pinal, We looked at your script and found out that in your script of disabling indexes, you have only included selected non-clustered index during the bulk insert and missed to disabled all the clustered index. Our DBA [name removed] has changed your script a bit and included all the clustered indexes. Since then our application is not working. When DBA [name removed] tried to enable clustered indexes again he is facing error Incorrect syntax error. We are in deep problem [word replaced] [Removed Identity of organization and few unrelated stuff ]” I have replied... - [SQL SERVER - GUID vs INT - Your Opinion](https://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-your-opinion/): I think the title is clear what I am going to write in your post. This is age old problem and I want to compile the list stating advantages and disadvantages of using GUID and INT as a Primary Key or Clustered Index or Both (the usual case). Let me start a list by suggesting one advantage and one disadvantage in each case. INT Advantage: Numeric values (and specifically integers) are better for performance when used in joins, indexes and conditions. Numeric values are easier to understand for application users if they are displayed. Disadvantage: If your table is large, it... - [SQLAuthority News - Public Training Classes In Hyderabad 12-14 May - SQL and 10-11 May SharePoint](https://blog.sqlauthority.com/2010/04/27/sqlauthority-news-public-training-classes-in-hyderabad-12-14-may-microsoft-sql-server-20052008-query-optimization-performance-tuning-2/): There were lots of request about providing more details for the blog post through email address specified in the article SQLAuthority News – Public Training Classes In Hyderabad 12-14 May – Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning. Here is the complete brochure of the course. There are two different courses are offered by Solid Quality Mentors 1) Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning – Pinal Dave Date: May 12-14, 2010 Price: Rs. 14,000/person for 3 days Discount Code: ‘SQLAuthority.com‘ Effective Price: Rs. 11,000/person for 3 days 2) SharePoint 2010 – Joy Rathnayake Date: May 10-11,... - [SQLAuthority News - Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning Training](https://blog.sqlauthority.com/2010/04/26/sqlauthority-news-public-training-classes-in-hyderabad-12-14-may-microsoft-sql-server-20052008-query-optimization-performance-tuning/): After successfully delivering many corporate training as well as the private training we are launching the Public Training in Hyderabad for SQL Server 2008. I will be leading the training on Microsoft SQL Server 2005/2008 Query Optimization & Performance Tuning Training. - [SQL SERVER – Attach mdf file without ldf file in Database](https://blog.sqlauthority.com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/): Background Story: One of my friends recently called up and asked me if I had spare time to look at his database and give him a performance tuning advice. Because I had some free time to help him out, I said yes. I asked him to send me the details of his database structure and sample data. He said that since his database is in a very early stage and is small as of the moment, so he told me that he would like me to have a complete database. My response to him was “Sure! In that case, take a... - [SQLAuthority News - Free Download - Microsoft SQL Server 2008 R2 RTM - Express with Management Tools - SQL Server 2008 R2 Books Online](https://blog.sqlauthority.com/2010/04/25/sqlauthority-news-free-download-microsoft-sql-server-2008-r2-rtm-express-with-management-tools/): This blog post is in response to several inquiry about Free Download of SQL Server 2008 R2 RTM. Microsoft has announced SQL Server 2008 R2 as RTM (Release To Manufacture). Microsoft® SQL Server® 2008 R2 Express is a powerful and reliable data management system that delivers a rich set of features, data protection, and performance for embedded applications, lightweight Web Sites and applications, and local data stores. Download Microsoft SQL Server 2008 R2 RTM – Express with Management Tools. Download Microsoft SQL Server 2008 R2 RTM – Management Studio Express. Download SQL Server 2008 R2 Books Online. Reference : Pinal Dave... - [SQL SERVER - T-SQL Script to Take Database Offline - Take Database Online](https://blog.sqlauthority.com/2010/04/24/sql-server-t-sql-script-to-take-database-offline-take-database-online/): Blog reader Joyesh Mitra recently left a comment to one of my very old posts about SQL SERVER – 2005 Take Off Line or Detach Database, which I have written focusing on taking the database offline. However, I did not include how to bring the offline database to online in that post. The reason I did not write it was that I was thinking it was a very simple script that almost everyone knows. However, it seems to me that there is something I found advanced and that is simple for other people sometime, in this case, I thought simple and... - [SQL SERVER - Update Statistics are Sampled By Default](https://blog.sqlauthority.com/2010/04/23/sql-server-update-statistics-are-sampled-by-default-2/): After reading my earlier post SQL SERVER – Create Primary Key with Specific Name when Creating Table on Statistics, I have received another question by a blog reader. The question is as follows: Question: Are the statistics sampled by default? Answer: Yes. The sampling rate can be specified by the user and it can be anywhere between a very low value to 100%. Let us do a small experiment to verify if the auto update on statistics is left on. Also, let’s examine a very large table that is created and statistics by default- whether the statistics are sampled or not.... - [SQL SERVER - Create Primary Key with Specific Name when Creating Table](https://blog.sqlauthority.com/2010/04/22/sql-server-create-primary-key-with-specific-name-when-creating-table/): It is interesting how sometimes the documentation of simple concepts is not available online. I had received email from one of the reader where he has asked how to create Primary key with a specific name when creating the table itself. He said, he knows the method where he can create the table and then apply the primary key with specific name. The attached code was as follows: CREATE TABLE [dbo].[TestTable]( [ID] [int] IDENTITY(1,1) NOT NULL, [FirstName] [varchar](100) NULL) GO ALTER TABLE [dbo].[TestTable] ADD  CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED ([ID] ASC) GO He wanted to know if we can create Primary Key as part of the table name as well, and... - [SQL SERVER - When Are Statistics Updated - What Triggers Statistics to Update](https://blog.sqlauthority.com/2010/04/21/sql-server-when-are-statistics-updated-what-triggers-statistics-to-update/): If you are an SQL Server Consultant/Trainer involved with Performance Tuning and Query Optimization, I am sure you have faced the following questions many times. When is statistics updated? What is the interval of Statistics update? What is the algorithm behind update statistics? These are the puzzling questions and more. - [SQL SERVER - Find Max Worker Count using DMV - 32 Bit and 64 Bit](https://blog.sqlauthority.com/2010/04/20/sql-server-find-max-worker-count-using-dmv-32-bit-and-64-bit/): During several recent training courses, I found it very interesting that Worker Thread is not quite known to everyone despite the fact that it is a very important feature. At some point in the discussion, one of the attendees mentioned that we can double the Worker Thread if we double the CPU (add the same number of CPU that we have on current system). The same discussion has triggered this quick article. Here is the DMV which can be used to find out Max Worker Count SELECT max_workers_count FROM sys.dm_os_sys_info Let us run the above query on my system and find... - [SQL SERVER - Find Most Active Database in SQL Server - DMV dm_io_virtual_file_stats](https://blog.sqlauthority.com/2010/04/19/sql-server-find-most-active-database-in-sql-server-dmv-dm_io_virtual_file_stats/): Few days ago, I wrote about SQL SERVER – Find Current Location of Data and Log File of All the Database. There was very interesting conversation in comments by blog readers. Blog reader and SQL Expert Sreedhar has very interesting DMV presented which lists the most active database in SQL Server. For quick reference he has included the size of the disk in KB, MB and GB as well. SELECT DB_NAME(mf.database_id) AS databaseName, name AS File_LogicalName, CASE WHEN type_desc = 'LOG' THEN 'Log File' WHEN type_desc = 'ROWS' THEN 'Data File' ELSE type_desc END AS File_type_desc ,mf.physical_name ,num_of_reads ,num_of_bytes_read ,io_stall_read_ms ,num_of_writes ,num_of_bytes_written ,io_stall_write_ms ,io_stall... - [SQLAuthority News - Free eBook Download - Introducing Microsoft SQL Server 2008 R2](https://blog.sqlauthority.com/2010/04/18/sqlauthority-news-free-ebook-download-introducing-microsoft-sql-server-2008-r2/): Microsoft Press has published a FREE eBook on the most awaiting releases of SQL Server 2008 R2. The book is written by Ross Mistry and Stacia Misner. Ross is my personal friend and one of the most active book writers in SQL Server Domain. When I see his name on any book, I am sure that it will be high quality and easy to read book. - [SQL SERVER - SELECT TOP Shortcut in SQL Server Management Studio (SSMS)](https://blog.sqlauthority.com/2010/04/17/sql-server-select-top-shortcut-in-sql-server-management-studio-ssms/): This is tool is pretty old, yet always comes as a handy tip. I had a great trip at TechEd in India. And, during one of my presentations, I was asked if there are any shortcuts to SELECT only TOP 100 records from SSMS. I immediately told him that if he explores the table in SSMS, he can just right click on it and SELECT TOP 1000 records. If he wanted only 100 records, then he could edit that 1000 to 100 by means of going to Options. Go to Options, then hover the mouse over the SQL Server Object Explorer,... - [SQLAuthority News - Best Compliment - DBA Survivor: Become a Rock Star DBA](https://blog.sqlauthority.com/2010/04/16/sqlauthority-news-best-compliment-dba-survivor-become-rock-star-dba/): Today's blog post is about the best compliment I have ever received. I am very, very happy and would like to share my feelings with you. Thomas Larock (Blog | Twitter) (known as SQLRockstar) keeps the excellent ranking of the blogger in the SQL Server Arena. I am a big fan of this list and have been referring lots of people. - [SQLAuthority News - Tips for Traveling to Nepal](https://blog.sqlauthority.com/2010/04/15/sqlauthority-news-tips-for-traveling-to-nepal/): If you are a regular reader of this blog, you might know that I travel nearly 20+ days out of 30 days in a month. There are cases when I don’t have a chance to go home for an entire month and my family has to travel to different cities just to meet me. During my recent visit, one of my acquaintances suggested that I should blog about my travel experiences as well. This can be helpful to others who are traveling to the country or city. This blog post is about Nepal. - [SQL SERVER - What is Spatial Database? - Developing with SQL Server Spatial and Deep Dive into Spatial Indexing](https://blog.sqlauthority.com/2010/04/14/sql-server-what-is-spatial-database-developing-with-sql-server-spatial-and-deep-dive-into-spatial-indexing/): What is Spatial Database? A spatial database is a database that is optimized to store and query data related to objects in space, including points, lines and polygons. While typical databases can understand various numeric and character types of data, additional functionality needs to be added for databases to process spatial data types. (Source: Wikipedia) Today I will be talking about the same subject at Microsoft TechEd India. If you want to learn about how to spatial aspect of data and how to integrate them with SQL Server this is the perfect session for you. Spatial is very special concept of... - [SQL SERVER - Configure Management Data Collection in Quick Steps - T-SQL Tuesday #005](https://blog.sqlauthority.com/2010/04/13/sql-server-configure-management-data-collection-in-quick-steps-t-sql-tuesday-005/): This article was written as a response to T-SQL Tuesday #005 – Reporting. The three most important components of any computer and server are the CPU, Memory, and Hard disk specification. This post talks about  how to get more details about these three most important components using the Management Data Collection. Management Data Collection generates the reports for the three said components by default. Configuring Data Collection is a very easy task and can be done very quickly. Please note: There are many different ways to get reports generated for CPU, Memory and IO. You can use DMVs, Extended Events as... - [SQLAuthority News - Three Posts on Reporting - T-SQL Tuesday #005](https://blog.sqlauthority.com/2010/04/13/sqlauthority-news-three-posts-on-reporting-t-sql-tuesday-005/): If you are following my blog, you already know that I am more of “T-SQL and Performance Tuning” type of person. I do have a good understanding of Business Intelligence suit and I also do certain training sessions on the same subject. When I was writing the blog post for T-SQL Tuesday #005 – Reporting, I realized that I have written a post that clearly explains how to generate reports using SQL Server Management Studio. Here is a quick recap on how one can use SSMS and out-of-the-box reports which can help many developers. Please note that they can be resource-intensive... - [SQL SERVER - What is MDS? - Master Data Services in Microsoft SQL Server](https://blog.sqlauthority.com/2010/04/12/sql-server-what-is-mds-master-data-services-in-microsoft-sql-server-2008-r2/): What is MDS? Master Data Services helps enterprises standardize the data people rely on to make critical business decisions. With Master Data Services, IT organizations can centrally manage critical data assets company wide and across diverse systems, enable more people to securely manage master data directly, and ensure the integrity of information over time. (Source: Replace with Microsoft) - [SQLAuthority News - SQL Server Cheat Sheet](https://blog.sqlauthority.com/2010/04/11/sqlauthority-news-spot-the-sqlauthority-baby-contest-sql-server-cheat-sheet/): I received many requests for the same. I have only 30 copies available at this moment. I will print more copies of the cheat sheet. - [SQLAuthority News - Speaking Sessions at TechEd India - 3 Sessions - 1 Panel Discussion](https://blog.sqlauthority.com/2010/04/10/sqlauthority-news-speaking-sessions-at-teched-india-3-sessions-1-panel-discussion/): Microsoft Tech-Ed India 2010 is considered as the major Technology event of the year for various IT professionals and developers. This event will feature a comprehensive forum in order   to learn, connect, explore, and evolve the current technologies we have today. I would recommend this event to you since here you will learn about today’s cutting-edge trends, thereby enhancing your work profile and getting ahead of the rest. But, the most important benefit of all might be the networking opportunity that that you can attain by attending the forum. You can build personal connections with various Microsoft experts and peers that... - [SQLAuthority News - Meeting with Allen Bailochan Tuladhar - An Unlimited Experience](https://blog.sqlauthority.com/2010/04/09/sqlauthority-news-meeting-with-allen-bailochan-tuladhar-an-unlimited-experience/): I recently came back from my 9-day trip in Nepal and I must say that this is one of the best trips I had in my lifetime. Allen Bailochan Tuladhar is a wonderful person and an extreme enthusiast for Microsoft Technology. Allen is the Chief Executive Officer of Unlimited Technologies Pvt Ltd., Country Manager of Microsoft MDP Nepal, the Member Secretary of Nepali Language in Information Technology, and member of the Steering Committee of the Government of Nepal. It an was unlimited experience for sure. - [SQLAuthority News - Author Visit Review - TechMela Nepal - March 29-30, 2010](https://blog.sqlauthority.com/2010/04/08/sqlauthority-news-author-visit-review-techmela-nepal-march-29-30-2010/): I was very fortunate to attend TechMela at Kathmandu, Nepal on 29th and 30th of March 2010. I would like to thank Allen Bailochan Tuladhar from Microsoft MDP Nepal for inviting me. Allen is a person with seemingly infinite energy and unlimited passion for Microsoft Technology. If you get an opportunity to spend just one hour with him, you will surely be more enthusiastic with regards to Microsoft Technology. And, I was lucky enough that I was able to spend about a total of 9 days with him in Kathmandu, working along with him in the Tech Community. TechMela is considered... - [SQLAuthority News - Milestone of 1300th Post and A Few Updates](https://blog.sqlauthority.com/2010/04/07/sqlauthority-news-milestone-of-1300th-post-and-few-updates/): Today is my 1300th blog post and I realize that my blog has been quite running such a long journey. I have been writing for a lengthy time on this tech blog. Today I would like to go back and briefly recall the posts that were part of my blog’s history. Read all list of all my blog posts here. This blog only started as a list of personal bookmarks. I used to just write down scripts on the blog for my personal use. I was the one who wrote many scripts here for the servers that I was maintaining to... - [SQL SERVER - Retrieve and Explore Database Backup without Restoring Database - Idera virtual database](https://blog.sqlauthority.com/2010/04/06/sql-server-retrieve-and-explore-database-backup-without-restoring-database-idera-virtual-database/): I recently downloaded Idera’s SQL virtual database, and tested it. There are a few things about this tool which caught my attention. Let us learn about Retrieve and Explore Database Backup without Restoring Database. - [SQL SERVER - 2008 - Introduction to Snapshot Database - Restore From Snapshot](https://blog.sqlauthority.com/2010/04/05/sql-server-2008-introduction-to-snapshot-database-restore-from-snapshot/): Snapshot database is one of the most interesting concepts that I have used at some places recently. Here is a quick definition of the subject from Book On Line: A Database Snapshot is a read-only, static view of a database (the source database). Multiple snapshots can exist on a source database and can always reside on the same server instance as the database. Each database snapshot is consistent, in terms of transactions, with the source database as of the moment of the snapshot’s creation. A snapshot persists until it is explicitly dropped by the database owner. If you do not know... - [SQL SERVER - Enable Identity Insert - Import Expert Wizard](https://blog.sqlauthority.com/2010/04/04/sql-server-enable-identity-insert-import-expert-wizard/): I recently got an email from an old friend who told me that when he tries to execute the SSIS package, it fails because of some identity error. After a few series of debugging and opening his package, we finally figured out that he has the following problem. Let's learn how to Enable Identity Insert – Import Expert Wizard. - [SQL SERVER - Difference Between GRANT and WITH GRANT](https://blog.sqlauthority.com/2010/04/03/sql-server-difference-between-grant-and-with-grant/): What is the difference between GRANT and WITH GRANT when giving permissions to the user? This is a very interesting question recently asked me to during my session at TechMela Nepal. Let us first see the syntax and analyze. GRANT: USE master; GRANT VIEW ANY DATABASE TO username; GO WITH GRANT: USE master; GRANT VIEW ANY DATABASE TO username WITH GRANT OPTION; GO The difference between these options is very simple. In case of only GRANT, the username cannot grant the same permission to other users. On the other hand, with the option WITH GRANT, the username will be able to give the permission after receiving requests... - [SQL SERVER - Simple Installation of Master Data Services (MDS) and Sample Packages - Very Easy](https://blog.sqlauthority.com/2010/04/02/sql-server-simple-installation-of-master-data-services-mds-and-sample-packages-very-easy/): I twitted recently about: ‘Installing #sql Server 2008 R2 – Master Data Services. Painless.’ After doing so, I got quite a few emails from other users as to why I thought it was painless. The reason was very simple- I was able to install it rather quickly on my laptop without any issues. There were a few requests along with these emails sent to me, which regards to how to install MDS, as well sample databases. Please note that I am the admin of my machine and I installed this MDS as the admin as well. Talk to your network administrator... - [SQLAuthority News - MS Access Database is the Way to Go - April 1st Humor](https://blog.sqlauthority.com/2010/04/01/sqlauthority-news-ms-access-database-is-the-way-to-go-april-1st-humor/): First of all, today is April 1- April Fool’s Day, so I have written this post for some light entertainment. My friend has just sent me an email about why a person should go for Access Database. For a short background, I used to be an MS Access user once (I will not call myself MS Access DBA), and I must say I had a good time with Database at that time. As time passed by, I moved from MS Access to SQL Server. Well, as for my friend’s email, his reasons considering MS Access usage really made me laugh. MS... - [SQLAuthority News - Fun Quotes about Technology](https://blog.sqlauthority.com/2010/03/31/sqlauthority-news-fun-quotes-technology/): SQL Server can be boring subject many times. In this blog post, let us see some of the fun quotes. - [SQL SERVER - World Shape files Download and Upload to Database - Spatial Database](https://blog.sqlauthority.com/2010/03/30/sql-server-world-shapefile-download-and-upload-to-database-spatial-database/): During my recent, training I was asked by a student if I know a place where he can download spatial files for all the countries around the world, as well as if there is a way to upload shape files to a database. Here is a quick tutorial for it. - [SQL SERVER - Introduction to Extended Events - Finding Long Running Queries](https://blog.sqlauthority.com/2010/03/29/sql-server-introduction-to-extended-events-finding-long-running-queries/): The job of an SQL Consultant is very interesting as always. The month before, I was busy doing query optimization and performance tuning projects for our clients, and this month, I am busy delivering my performance in Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning Course. I recently read white paper about Extended Event by SQL Server MVP Jonathan Kehayias. You can read the white paper here: Using SQL Server 2008 Extended Events. I also read another appealing chapter by Jonathan in the book, SQLAuthority Book Review – Professional SQL Server 2008 Internals and Troubleshooting. After reading these excellent notes by Jonathan, I decided to upgrade my course and include Extended Event as one of the modules. - [SQLAuthority News - Author Visit to Nepal TechMela - 2 Technical Sessions](https://blog.sqlauthority.com/2010/03/28/sqlauthority-news-author-visit-to-nepal-techmela-2-technical-sessions/): Microsoft MDP Nepal is going to organize a Tech Mela for the IT community of Nepal on March 29 & 30, 2010 (2066 Chaitra 16 & 17), Monday and Tuesday,  at the Russian Center for Science & Culture, Kamalpokhari, Kathmandu. The objective of the event is to enhance and exchange knowledge about Information Technology, as well as Microsoft products and technologies, with the IT community. I am very excited to attend this one-of-a-kind event in Nepal. - [SQL SERVER - FIX : ERROR : 4214 BACKUP LOG cannot be performed because there is no current database backup](https://blog.sqlauthority.com/2010/03/27/sql-server-fix-error-4214-backup-log-cannot-be-performed-because-there-is-no-current-database-backup/): I recently got following email from one of the readers. It is about Backup Log file. - [SQL SERVER - Generate Report for Index Physical Statistics - SSMS](https://blog.sqlauthority.com/2010/03/26/sql-server-generate-report-for-index-physical-statistics-ssms/): Few days ago, I wrote about SQL SERVER – Out of the Box – Activity and Performance Reports from SSSMS (Link). A user asked me a question regarding if we can use similar reports to get the detail about Indexes. Yes, it is possible to do the same. There are similar type of reports are available at Database level, just like those available at the Server Instance level. You can right click on Database name and click Reports. Under Standard Reports, you will find following reports. Disk Usage Disk Usage by Top Tables Disk Usage by Table Disk Usage by Partition... - [SQL SERVER - Out of the Box - Activity and Performance Reports from SSSMS](https://blog.sqlauthority.com/2010/03/25/sql-server-default-activty-and-performance-reports-from-sssms/): SQL Server management Studio 2008 is a wonderful tool and has many different features. Many times, an average user does not use them as they are not aware about these features. Today, we will learn one such feature. SSMS comes with many inbuilt performance reports and activity reports, but we do not use it to the full potential. - [SQL SERVER - Fix : Error : 8501 MSDTC on server is unavailable. Changed database context to publisherdatabase](https://blog.sqlauthority.com/2010/03/24/sql-server-fix-error-8501-msdtc-on-server-is-unavailable-changed-database-context-to-publisherdatabase/): During configuring replication on one of the server, I received following error. This is very common error and the solution of the same is even simpler. MSDTC on server is unavailable. Changed database context to publisherdatabase. (Microsoft SQL Server, Error: 8501) Solution: Enable “Distributed Transaction Coordinator” in SQL Server. Method 1: Click on Start–>Control Panel->Administrative Tools->Services Select the service “Distributed Transaction Coordinator” Right on the service and choose “Start” Method 2: Type services.msc in the run command box Select “Services” manager; Hit Enter Select the service “Distributed Transaction Coordinator” Right on the service and choose “Start” Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - We're sorry... ... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now. ](https://blog.sqlauthority.com/2010/03/23/sqlauthority-news-were-sorry-but-your-computer-or-network-may-be-sending-automated-queries-to-protect-our-users-we-cant-process-your-request-right-now/): I use multiple browser many times when I am working with multiple projects simultaneously. Often I use Google Reader to read few feeds. Recently, I faced the following error and this error will not go. I even restarted my computer and rebooted my network. I am confident that my computer does not have viruses or malware, I could not tackle this error. When I opened Google Reader on another browser, it worked fine. Finally, I found the solution and I want share it with all of you. Error We’re sorry… … but your computer or network may be sending automated queries.... - [SQL SERVER - Enumerations in Relational Database - Best Practice](https://blog.sqlauthority.com/2010/03/22/sql-server-enumerations-in-relational-database-best-practice/): This article has been submitted by Marko Parkkola, Data systems designer at Saarionen Oy, Finland. Marko is excellent developer and always thinking at next level. You can read his earlier comment which created very interesting discussion here: SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table). I must express my special thanks to Marko for sending this best practice for Enumerations in Relational Database. He has really wrote excellent piece here and welcome comments here. Enumerations in Relational Database This is a subject which is very basic thing in relational databases but often not very well understood... - [SQL SERVER - Fix : Error : 3117 : The log or differential backup cannot be restored because no files are ready to rollforward](https://blog.sqlauthority.com/2010/03/21/sql-server-fix-error-3117-the-log-or-differential-backup-cannot-be-restored-because-no-files-are-ready-to-rollforward/): I received the following email from one of my readers. Dear Pinal, I am new to SQL Server and our regular DBA is on vacation. Our production database had some problem and I have just restored full database backup to production server. When I try to apply log back I am getting following error. I am sure, this is valid log backup file. Screenshot is attached. [Few other details regarding server/ip address removed] Msg 3117, Level 16, State 1, Line 1 The log or differential backup cannot be restored because no files are ready to roll forward. Msg 3013, Level 16,... - [SQLAuthority News - Microsoft SQL Server Protocol Documentation Download](https://blog.sqlauthority.com/2010/03/20/sqlauthority-news-microsoft-sql-server-protocol-documentation-download/): Download Microsoft SQL Server Protocol Documentation Authored by Microsoft The Microsoft SQL Server protocol documentation provides detailed technical specifications for Microsoft proprietary protocols (including extensions to industry-standard or other published protocols) that are implemented and used in Microsoft SQL Server to interoperate or communicate with Microsoft products. The documentation includes a set of companion overview and reference documents that supplement the technical specifications with conceptual background, overviews of inter-protocol relationships and interactions, and technical reference information. Abstract courtesy Microsoft Microsoft SQL Server Protocol Documentation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Interview Questions & Answers Needs Your Help](https://blog.sqlauthority.com/2010/03/19/sql-server-interview-questions-answers-needs-your-help/): Click here to get free chapters (PDF) in the mailbox About an year ago, I had posted SQL Server related Interview Questions and Answers. It was very well received in community. I have received many comments, suggestions and emails on this subject. I am planning to upgrade the Interview Questions and Answers and take it to next level. Here, I need your help. Please your comments, suggestions, expectation or potential interview Question (along with answer) here. Your input will be very valuable. As time goes by we all learn and get better. There were few things missing at that time when... - [SQL SERVER - Mirroring Configured Without Domain - The server network address TCP://SQLServerName:5023 can not be reached or does not exist](https://blog.sqlauthority.com/2010/03/18/sql-server-mirroring-configured-without-domain-the-server-network-address-tcpsqlservername5023-can-not-be-reached-or-does-not-exist/): Regular readers of my blog will be aware of my friend who called me few days ago with very a funny SQL Problem SQL SERVER – SSMS Query Command(s) completed successfully without ANY Results. This time, it did not take long before he called me up with another interesting problem, although the issue he was facing this time was not that interesting and also very specific to him, however, he insisted me to share with all of you. Let us understand his situation at first. My friend is preparing for DBA exam Exam 70-450: PRO: Designing, Optimizing and Maintaining a Database... - [SQL SERVER - Difference Between ROLLBACK IMMEDIATE and WITH NO_WAIT during ALTER DATABASE](https://blog.sqlauthority.com/2010/03/17/sql-server-difference-between-rollback-immediate-and-with-no_wait-during-alter-database/): We are going to discuss something very simple topic. Difference Between ROLLBACK IMMEDIATE and WITH NO_WAIT during ALTER DATABASE. - [SQL SERVER - Quick Note of Database Mirroring](https://blog.sqlauthority.com/2010/03/16/sql-server-quick-note-of-database-mirroring/): Just a day ago, I was invited at Round Table meeting at prestigious organization. They were planning to implement High Availability solution using Database Mirroring. During the meeting, I have made few notes of what was being discussed there. I just thought it would be interested for all of you know about it. Database Mirroring works on physical log records. SQL Server 2008 compresses the Transaction Log at Principal Server before it is transferred to mirror server. System databases can not be mirrored. Database which needs to be mirrored requires it to be in FULL recovery mode. High Safety Mode –... - [SQL SERVER - MAXDOP Settings to Limit Query to Run on Specific CPU](https://blog.sqlauthority.com/2010/03/15/sql-server-maxdop-settings-to-limit-query-to-run-on-specific-cpu/): This is very simple and known tip. Query Hint MAXDOP – Maximum Degree Of Parallelism can be set to restrict query to run on a certain CPU. Please note that this query cannot restrict or dictate which CPU to be used, but for sure, it restricts the usage of number of CPUs in a single batch. Let us consider the following example of this query. The following query usually runs on multicore on a dual core machine (please note it may not be the case with your machine). USE AdventureWorks GO SELECT * FROM Sales.SalesOrderDetail ORDER BY ProductID GO Now the same... - [SQLAuthority News - Interesting Whitepaper - We Loaded 1TB in 30 Minutes with SSIS, and So Can You](https://blog.sqlauthority.com/2010/03/14/sqlauthority-news-interesting-whitepaper-we-loaded-1tb-in-30-minutes-with-ssis-and-so-can-you/): We Loaded 1TB in 30 Minutes with SSIS, and So Can You SQL Server Technical Article Writers: Len Wyatt, Tim Shea, David Powell Published: March 2009 In February 2008, Microsoft announced a record-breaking data load using Microsoft SQL Server Integration Services (SSIS): 1 TB of data in less than 30 minutes. That data load, using SQL Server Integration Services, was 30% faster than the previous best time using a commercial ETL tool. This paper outlines what it took: the software, hardware, and configuration used. We will describe what we did to achieve that result, and offer suggestions for how to relate... - [SQLAuthority News - SQL Server 2008 R2 Update for Developers Training Kit (March 2010 Update)](https://blog.sqlauthority.com/2010/03/13/sqlauthority-news-sql-server-2008-r2-update-for-developers-training-kit-march-2010-update/): Note: Download SQL Server 2008 R2 Update for Developers Training Kit (March 2010 Update) Authored by Microsoft SQL Server 2008 R2 offers an impressive array of capabilities for developers that build upon key innovations introduced in SQL Server 2008. The SQL Server 2008 R2 Update for Developers Training Kit is ideal for developers who want to understand how to take advantage of the key improvements introduced in SQL Server 2008 and SQL Server 2008 R2 in their applications, as well as for developers who are new to SQL Server. The training kit is brought to you by Microsoft Developer and Platform... - [SQLAuthority News - Download Microsoft SQL Server JDBC Driver 3.0 CTP 1](https://blog.sqlauthority.com/2010/03/13/sqlauthority-news-download-microsoft-sql-server-jdbc-driver-3-0-ctp-1/): Note:  Download Microsoft SQL Server JDBC Driver 3.0 CTP 1 Authored by Microsoft Download the SQL Server JDBC Driver 3.0 CTP, a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform, Enterprise Edition 5. In its continued commitment to interoperability, Microsoft has released a preview of the upcoming Java Database Connectivity (JDBC) driver. The SQL Server JDBC Driver 3.0 CTP download is available to all SQL Server users at no additional charge, and provides access to SQL Server 2000, SQL Server 2005, and SQL Server 2008 from any Java application,... - [SQL SERVER - Checklist for Analyzing Slow-Running Queries](https://blog.sqlauthority.com/2010/03/12/sql-server-checklist-for-analyzing-slow-running-queries/): I am recently working on upgrading my class Microsoft SQL Server 2005/2008 Query Optimization and & Performance Tuning with additional details and more interesting examples. While working on slide deck I realized that I need to have one solid slide which talks about checklist for analyzing slow running queries. A quick search on my saved book mark link come up with interesting book online link. This link very clearly suggests: To save time, consult this checklist before you contact your technical support provider. I strongly suggest you to do the same, first consult this checklist and if you still further need... - [SQL SERVER - Force Index Scan on Table - Use No Index to Retrieve the Data - Query Hint](https://blog.sqlauthority.com/2010/03/11/sql-server-force-index-scan-on-table-use-no-index-to-retrieve-the-data-query-hint/): Recently I received the following two questions from readers and both the questions have very similar answers. Question 1: I have a unique requirement where I do not want to use any index of the table; how can I achieve this? Question 2: Currently my table uses clustered index and does seek operation; how can I convert seek to scan? First of all, I am not going to analysis their need of why, in fact, they want to convert seek to scan or use no index here. The requirement is strange as using no index or scanning large table may reduce... - [SQLAuthority Book Review - Professional SQL Server 2008 Internals and Troubleshooting](https://blog.sqlauthority.com/2010/03/10/sqlauthority-book-review-professional-sql-server-2008-internals-and-troubleshooting/): Professional SQL Server 2008 Internals and Troubleshooting by Christian Bolton, Justin Langford, Brent Ozar, James Rowland-Jones, Steven Wort Link to Amazon (Worldwide) Link to Flipkart (India) Brief Review: Having a book on internal and associating that with real life is “almost” an impossible task. The reason for using the word “almost” is because this book has accomplished this very well. This internals book is written by keeping real life scenarios as top focus. The highlight of the book is that it teaches how to use internals to troubleshoot the real life issues of performance, storage, query processing and all the other... - [SQL SERVER - Improve Performance by Reducing IO - Creating Covered Index](https://blog.sqlauthority.com/2010/03/09/sql-server-improve-performance-by-reducing-io-creating-covered-index/): This blog post is in the response of the T-SQL Tuesday #004: IO by Mike Walsh. The subject of this month is IO. Here is my quick blog post on how Cover Index can Improve Performance by Reducing IO. Let us kick off this post with disclaimers about Index. Index is a very complex subject and should be exercised with experts. Too many indexes, and in particular, too many covering indexes can hamper the performance. Again, indexes are very important aspect of performance tuning. In this post, I am demonstrating very limited capacity of Index. We will create covering index for... - [SQLAuthority News - SQL SERVER 2008 R2 Pricing](https://blog.sqlauthority.com/2010/03/08/sql-server-2008-r2-pricing/): I was recently asked question about SQL Server 2008 pricing. I have bookmarked official site here which lists the pricing. Official site: What’s New in SQL Server 2008 R2 Editions Editions Per Processor PricingRetail Per Server Plus CAL PricingRetail Parallel Data Warehouse $57,498 Not offered via Server CAL Datacenter $57,498 Not offered via Server CAL Enterprise $28,749 $13,969 with 25 CALs Standard $7,499 $1,849 with 5 CALs However, I have bookmarked following site of Brent Ozar SQL Server 2008 R2 Pricing and Feature Changes. I think Brent has answered one very interesting question there that SQL Server R2 is FREE for... - [SQLAuthority News - Office 2010 Readiness Check - Are you ready for Office 2010?](https://blog.sqlauthority.com/2010/03/07/sqlauthority-news-office-2010-readiness-check-are-you-ready-for-office-2010/): PowerPivot for Excel is a data analysis tool that delivers unmatched computational power directly within the application users already know and love—Microsoft Excel. Office 2010 is the next version of Office 2010. We all know Office 2010 is on the verge of getting released and the reviews available online say that it’s a phenomenal product. My friend Vijay Raj has written excellent article on Office 2010 Readiness Check. Vijay is a Microsoft MVP, focusing on Application Setup and Deployment. He is also a Springboard Series Technical Expert Panel member for Windows 7.  He is one among the core team members at... - [SQLAuthority News - SQL Server Modeling CTP - Nov 2009 Release 2 (formerly Oslo)](https://blog.sqlauthority.com/2010/03/06/sqlauthority-news-sql-server-modeling-ctp-nov-2009-release-2-formerly-oslo/): Note : Download SQL Server Modeling CTP – Nov 2009 Release 2 (formerly Oslo)  by Microsoft SQL Server Modeling (formerly code name “Oslo”) is a set of future technologies that provide significant productivity gains across the lifecycle of .NET applications by enabling developers, architects, and IT professionals to work together more effectively with SQL Server at the center of the application lifecycle. The components of the SQL Server Modeling CTP are: “M” is a highly productive, developer friendly, textual language for defining schemas, queries, values, functions and DSLs for SQL Server databases “Quadrant” is a customizable tool for interacting with large... - [SQL SERVER - Order of Columns in Update Statement Does not Matter](https://blog.sqlauthority.com/2010/03/05/sql-server-order-of-columns-in-update-statement-does-not-matter/): I recently received few comments that I have not written on simple subjects recently. In fact, this blog is dedicated to all those who are really learning SQL Server and almost all the articles and posts are posted here keeping this goal in mind. One of the questions in the email which requested to write simple subjects was “Does the order of columns in UPDATE statements matter?” Let me try to answer this question today. The question in detail: Does the order of the columns in UPDATE statements matter? For example, is there any difference between option 1 and option 2... - [SQL SERVER - Rollback TRUNCATE Command in Transaction](https://blog.sqlauthority.com/2010/03/04/sql-server-rollback-truncate-command-in-transaction/): This is a very common concept that truncate cannot be rolled back. Let us learn in today's blog post that Rollback TRUNCATE is possible. - [SQL SERVER - Performance Comparison - INSERT TOP (N) INTO Table - Using Top with INSERT](https://blog.sqlauthority.com/2010/03/03/sql-server-performance-comparison-insert-top-n-into-table-using-top-with-insert/): Recently I wrote about SQL SERVER – INSERT TOP (N) INTO Table – Using Top with INSERT I mentioned about how TOP works with INSERT. I have mentioned that I will write about the performance in next article. Here is the performance comparison of the two options. - [SQLAuthority News - Excellent Event - TechEd Sri Lanka - Feb 8, 2010](https://blog.sqlauthority.com/2010/03/02/sqlauthority-news-excellent-event-teched-sri-lanka-feb-8-2010/): TechEd Sri Lanka was held at Waters Edge, Colombo between Feb 8 and Feb 10, 2010. It was one of the largest successful technical event in Sri Lanka. I was extremely surprised to how technically sound this event was and how excited the TechEd attendees were. I presented there on two different subject. They were very enthusiastic and had so many interesting questions during the session. One of my session received rating of 8.9. I must thank you to all the attendees for sending their feedback and appreciating my session. Both of my session have received feedback above average. The Other... - [SQL SERVER - Data and Page Compressions - Data Storage and IO Improvement](https://blog.sqlauthority.com/2010/03/01/sql-server-data-and-page-compressions-data-storage-and-io-improvement/): The performance of SQL Server is primarily decided by the disk I/O efficiency. Improving I/O definitely improves the performance. SQL Server 2008 introduced Data and Backup compression features to improve the disk I/O. Here, I will explain Data compression. Data compression implies the reduction in the disk space reserved by data. Therefore, data compression can be configured for a table, clustered index, non-clustered index, indexed view or a partition of table or index. Data compression is implemented at two levels: ROW and PAGE. Even page compression automatically implements row compression. Tables and indexes can be compressed when they are created by... - [SQLAuthority News - Hyderabad Techies February Fever Feb 11, 2010 - Indexing for Performance](https://blog.sqlauthority.com/2010/02/28/sqlauthority-news-hyderabad-techies-february-fever-feb-11-2010-indexing-for-performance/): I recently presented in Hyderabad User Group on the subject of The Other Side of SQL Server Index: Advanced Solutions to Ancient Problem , you can read more about this event here SQLAuthority News – MUGH – Microsoft User Group Hyderabad – Feb 2, 2010 Session Review. I really had great time talking about Index and Index Tuning. Index is very important part of database performance tuning and understanding it is a big thing. I have learned a lot of performance tuning tricks from Itzik Ben-Gan and Greg Low. After successful session at Hyderabad User Group, I have presented follow up... - [SQL SERVER - User Defined Functions (UDF) Limitations](https://blog.sqlauthority.com/2007/05/29/sql-server-user-defined-functions-udf-limitations/): UDF have its own advantage and usage but in this article we will see the limitation of UDF. Things UDF can not do and why Stored Procedure are considered as more flexible then UDFs. Stored Procedure are more flexibility then User Defined Functions(UDF). UDF has No Access to Structural and Permanent Tables. UDF can call Extended Stored Procedure, which can have access to structural and permanent tables. (No Access to Stored Procedure) UDF Accepts Lesser Numbers of Input Parameters. UDF can have upto 1023 input parameters, Stored Procedure can have upto 21000 input parameters. UDF Prohibit Usage of Non-Deterministic Built-in Functions... - [SQLAuthority News - Author Visit - Meeting with Readers - Top Three Features of SQL SERVER 2005](https://blog.sqlauthority.com/2007/05/28/sqlauthority-news-author-visit-meeting-with-readers-top-three-features-of-sql-server-2005/): Lots of travelers are visiting to Las Vegas due to long weekend of Memorial Day. I was invited to dinner meeting by two of my readers. It was wonderful discussion with them. We primarily discussed about scalability and upgrading issues about SQL Server. I received feedback about SQLAuthority.com site. There were two primarily request for them. I have been working on both of them already as I have received quite a few request for them from other readers as well. Beta testing has been completed, I will announce them on 1st June. While enjoying dinner I was asked interesting question and... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - SP](https://blog.sqlauthority.com/2007/05/28/sql-server-sql-joke-sql-humor-sql-laugh-sp/): One of my Friend send me(in email) following stored procedure. I laughed when I read it. Please enjoy it. It is here for amusement purpose only. Never use on development or production server. This is already dangerous you have been warned. CREATE PROCEDURE MyMarriage @ BrideGroom CHAR(NotBad), @ Bride CHAR(Good) AS BEGIN SELECT Bride FROM india_ Brides WHERE FatherInLaw = 'Millionaire' AND CarCount > 2 AND HouseStatus ='TwoStoreyed' AND BrideEduStatus='PG or Above' AND HavingBrothers='NO' AND HavingSisters ='No' AND AllowRelocate ='YES' SELECT Gold ,Cash,Car,BankBalance FROM FatherInLaw UPDATE MyBankAccout SET MyBal = MyBal + FatherinLawBal UPDATE MyLocker SET MyLockerContents = MyLockerContents + FatherinLawGold... - [SQL SERVER - Download Feature Pack for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/05/27/sql-server-download-feature-pack-for-microsoft-sql-server-2005/): Feature Pack for Microsoft SQL Server 2005 – February 2007 Download the February 2007 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. I have listed all the stand alone packages here. Even though title says February 2007, publication day of this package is 5/25/2007. All DBA should go through following list and see if their organization is using any of the application/feature and update is required for them. Microsoft ADOMD.NET Microsoft Core XML Services (MSXML) 6.0 Microsoft OLEDB Provider for DB2 Microsoft SQL Server Management Pack for MOM... - [SQL SERVER - 2005 Limiting Result Sets by Using TABLESAMPLE - Examples](https://blog.sqlauthority.com/2007/05/27/sql-server-2005-limiting-result-sets-by-using-tablesample-examples/): Introduced in SQL Server 2005, TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set. Example 1: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (10 PERCENT) Example 2: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (1000 ROWS) If you run above script many times you will notice that different numbers of... - [SQL SERVER - 2005 Replace TEXT with VARCHAR(MAX) - Stop using TEXT, NTEXT, IMAGE Data Types](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-replace-text-with-varcharmax-stop-using-text-ntext-image-data-types/): Yesterday, in Friday Afternoon team meeting. I was asked question by one of application developer “I am asked in new coding standards to use VARHCAR(MAX) instead of TEXT. Is VARCHAR(MAX) big enough to store TEXT field?” Well, I realize that I was not clear enough in my coding standard. It is extremely important for coding standards to be clear and have a enough explanation that developer have no doubt about them. I updated coding standards after the meeting. The answer is “Yes, VARCHAR(MAX) is big enough to accommodate TEXT field. TEXT, NTEXT and IMAGE data types of SQL Server 2000 will... - [SQL SERVER - 2005 Find Table without Clustered Index - Find Table with no Primary Key](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-find-table-without-clustered-index-find-table-with-no-primary-key/): One of the basic Database Rule I have is that all the table must Clustered Index. Clustered Index speeds up performance of the query ran on that table. Clustered Index are usually Primary Key but not necessarily. I frequently run following query to verify that all the Jr. DBAs are creating all the tables with no Clustered Index. USE AdventureWorks ----Replace AdventureWorks with your DBName GO SELECT DISTINCT [TABLE] = OBJECT_NAME(OBJECT_ID) FROM SYS.INDEXES WHERE INDEX_ID = 0 AND OBJECTPROPERTY(OBJECT_ID,'IsUserTable') = 1 ORDER BY [TABLE] GO Result set for AdventureWorks: TABLE ——————————————————- DatabaseLog ProductProductPhoto (2 row(s) affected) Related Post: SQL SERVER –... - [SQL SERVER - Change Default Fill Factor For Index](https://blog.sqlauthority.com/2007/05/25/sql-server-change-default-fill-factor-for-index/): SQL Server has default value for fill factor is Zero (0). The fill factor is implemented only when the index is created; it is not maintained after the index is created as data is added, deleted, or updated in the table. When creating an index, you can specify a fill factor to leave extra gaps and reserve a percentage of free space on each leaf level page of the index to accommodate future expansion in the storage of the table's data and reduce the potential for page splits. Let us learn about how to change default fill factor of index. - [SQL SERVER - Stored Procedure to display code (text) of Stored Procedure, Trigger, View or Object](https://blog.sqlauthority.com/2007/05/25/sql-server-stored-procedure-to-display-code-text-of-stored-procedure-trigger-view-or-object/): This is another popular question I receive. How to see text/content/code of Stored Procedure. System stored procedure that prints the text of a rule, a default, or an unencrypted stored procedure, user-defined function, trigger, or view. Syntax sp_helptext @objname = 'name' sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name Displaying the definition of a trigger or stored procedure sp_helptext 'dbo.nameofsp' Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Disadvantages (Problems) of Triggers](https://blog.sqlauthority.com/2007/05/24/sql-server-disadvantages-problems-of-triggers/): One of my team member asked me should I use triggers or stored procedure. Both of them has its usage and needs. I just basically told him few issues with triggers. This is small note about our discussion. Disadvantages(Problems) of Triggers It is easy to view table relationships , constraints, indexes, stored procedure in database but triggers are difficult to view. Triggers execute invisible to client-application application. They are not visible or can be traced in debugging code. It is hard to follow their logic as it they can be fired before or after the database insert/update happens. It is easy... - [SQL SERVER - 2005 Retrieve Configuration of Server](https://blog.sqlauthority.com/2007/05/24/sql-server-2005-retrieve-configuration-of-server/): Few days ago I was asked what is our SQL Server’s configuration. I provided way more information then they requested. Run following script and it will provide all the information about SQL Server . SQL Server provides in detailed information if Advanced Options are turned on. It is very clear from this that maximum number of object SQL Server can have is 2,147,483,647. It is considerably very big number. I am not worried yet about my database reaching its limit. EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure GO EXEC sp_configure 'show advanced options', 0 GO To change... - [SQL SERVER - NorthWind Database or AdventureWorks Database - Samples Databases](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases/): SQL Server 2005 does not install sample databases by default due to security reasons.I have received many questions regarding where is sample database in SQL Server 2005. One can install it afterward. AdventureWorks and AdvetureWorksDS are the new sample databases for SQL Server 2005, they can be download from here. Let us learn how to install NorthWind Database - samples databases.  - [SQL SERVER - 2005 Explanation Left Semi Join Showplan Operator and Other Operator](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-explanation-left-semi-join-showplan-operator-and-other-operator/): I come across very interesting documentation about Joins, while I was researching about article about EXCEPT yesterday. There are few interesting kind of join operations exists when execution plan is displayed in text format. Left Semi Join Showplan Operator The Left Semi Join operator returns each row from the first (top) input when there is a matching row in the second (bottom) input. If no join predicate exists in the Argument column, each row is a matching row. Left Anti Semi Join Showplan Operator The Left Anti Semi Join operator returns each row from the first (top) input when there is... - [SQLAuthority News - Funny One Liners - Humor](https://blog.sqlauthority.com/2007/05/23/sqlauthority-news-funny-one-liners-humor/): Once in a while we should laugh and relax. Here are few of my favorite funny one liners which I often use in my presentations. Let us start- Just read that 4,153,237 people got married last year, not to cause any trouble, but shouldn't that be an even number? - [SQLAuthority News - T-Shirts in Action](https://blog.sqlauthority.com/2007/05/22/sqlauthority-news-t-shirts-in-action/): Thank you All for great response to SQLAuthority T-Shirts. I have ran out of all of them. Please put your request here. I will go over all of them soon and see what I can do. They are made from high quality fiber and very comfortable. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Comparison EXCEPT operator vs. NOT IN](https://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/): The EXCEPT operator returns all of the distinct rows from the query to the left of the EXCEPT operator when there are no matching rows in the right query. The EXCEPT operator is equivalent of the Left Anti Semi Join. EXCEPT operator works the same way NOT IN. EXCEPTS returns any distinct values from the query to the left of the EXCEPT operand that do not also return from the right query. - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - T-Shirt](https://blog.sqlauthority.com/2007/05/21/sql-server-sql-joke-sql-humor-sql-laugh-t-shirt/): My friend sent me this in an email two days ago as he wanted me to have SQLAuthority T-Shirt with this image. I found it funny, I am not sure if I will have this on SQLAuthority T-Shirts. Please pay attention to the options available to select. I spend more than 3 hours to find the original source as my friend did not remember the source. Let's see some SQL Humor here: - [SQL SERVER - Top 15 free SQL Injection Scanners - Link to Security Hacks](https://blog.sqlauthority.com/2007/05/21/sql-server-top-15-free-sql-injection-scanners-link-to-security-hacks/): SQL injection is a technique for exploiting web applications that use client-supplied data in SQL queries, but without first stripping potentially harmful characters. Checking for SQL Injection vulnerabilities involves auditing your web applications and the best way to do it is by using automated SQL Injection Scanners. Security-Hacks.com compiled a list of free SQL Injection Scanners. I really enjoy reading the article. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Build List Link](https://blog.sqlauthority.com/2007/05/21/sql-server-2005-build-list-link/): What is Build List? All SQL Server has build list, this is incremental list of numbers which indicates which version SQL Server is running and what are its compatibility, patches etc. Regular Columnist Steve Jones of SQL Server Central has created build list. It is updated and informative. Microsoft Hot fixes are always cumulative. You can find your build number with: SELECT@@Version Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Code Formatting Tools](https://blog.sqlauthority.com/2007/05/20/sql-server-sql-code-formatter-tools/): SQL Code Formatting is very important. Every SQL Server DBA has its own preference about formatting. I like to format all keywords to uppercase. Following are two online tools, which formats SQL Code very good. I tested following script with those tools and I found two of the tools worth mentioning here. - [SQL SERVER - Script/Function to Find Last Day of Month](https://blog.sqlauthority.com/2007/05/20/sql-server-scriptfunction-to-find-last-day-of-month/): Following query will find the last day of the month. Query also take care of Leap Year. Script: DECLARE @date DATETIME SET @date='2008-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO DECLARE @date DATETIME SET @date='2007-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO ResultSet: LastDayOfMonth ----------------------- 2008-02-29 00:00:00.000 (1 row(s) affected) LastDayOfMonth ----------------------- 2007-02-28 00:00:00.000 (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ASCII to Decimal and Decimal to ASCII Conversion](https://blog.sqlauthority.com/2007/05/19/sql-server-ascii-to-decimal-and-decimal-to-ascii/): In this blog post we will see how we can convert ASCII to Decimal and Decimal to ASCII. In simple words, we will see the decimal and ASCII conversion. - [SQL SERVER - Math Functions Available in SQL Server](https://blog.sqlauthority.com/2007/05/19/sql-server-math-functions-for-2005/): The large majority of math functions is specific to applications using trigonometry, calculus, and geometry. This is very important and it is very difficult to have all of them together at place. - [SQL SERVER - 2005 Understanding Trigger Recursion and Nesting with examples](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-understanding-trigger-recursion-and-nesting-with-examples/): Trigger events can be fired within another trigger action. One Trigger execution can trigger even on another table or same table. This trigger is called NESTED TRIGGER or RECURSIVE TRIGGER. Nested triggers SQL Server supports the nesting of triggers up to a maximum of 32 levels. Nesting means that when a trigger is fired, it will also cause another trigger to be fired. If a trigger creates an infinitive loop, the nesting level of 32 will be exceeded and the trigger will cancel with an error message. Recursive triggers When a trigger fires and performs a statement that will cause the... - [SQL SERVER - 2005 - SSMS Change T-SQL Batch Separator](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-ssms-change-t-sql-batch-separator/): I recently received one big file with many T-SQL batches. It was a very big file and I was asked that this file was tested many times and it can run one transaction. I noticed the separator of the batches is not GO but it was EndBatch. I have followed two options to run the whole batch in one transaction. Let us learn how to change T-SQL Batch Separator. - [SQLAuthority News - Limited Edition T-Shirts Arrived](https://blog.sqlauthority.com/2007/05/17/sqlauthority-news-limited-edition-t-shirts-arrived/): I have received quite a few request for SQLAuthority.com T-shirts. Every day I receive lots of emails and suggestions. Many readers have great suggestions and have helped to improve content. First of all I express my gratitude to all of you. Few of my loyal and enthusiastic readers will receive the T-shirt by tomorrow. T-shirts are very limited. I have kept only two for me and have shipped all other. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Disable Index - Enable Index - ALTER Index](https://blog.sqlauthority.com/2007/05/17/sql-server-disable-index-enable-index-alter-index/): There are few requirements in real world when Index on table needs to be disabled and re-enabled afterwards. e.g. DTS, BCP, BULK INSERT etc. Index can be dropped and recreated. I prefer to disable the Index if I am going to re-enable it again. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO ----Enable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact REBUILD GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-1205-transaction-process-id-was-deadlocked-on-resources-with-another-process-and-has-been-chosen-as-the-deadlock-victim-rerun-the-transaction/): Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction. - [SQL SERVER - Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-130-cannot-perform-an-aggregate-function-on-an-expression-containing-an-aggregate-or-a-subquery/): Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery Following statement will give the following error: “Cannot perform an aggregate function on an expression containing an aggregate or a subquery.” MS SQL Server doesn’t support it. USE PUBS GO SELECT AVG(COUNT(royalty)) RoyaltyAvg FROM dbo.roysched GO You can get around this problem by breaking out the computation of the average in derived tables. USE PUBS GO SELECT AVG(t.RoyaltyCounts) FROM ( SELECT COUNT(royalty) AS RoyaltyCounts FROM dbo.roysched ) T GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL. - [SQL SERVER - Binary Sequence Generator - Truth Table Generator](https://blog.sqlauthority.com/2007/05/15/sql-server-binary-sequence-generator-truth-table-generator/): Run following script in query editor to generate truth table with its decimal value and binary sequence. The truth table is 512 rows long. This can be extended or reduced by adding or removing cross joins respectively. Script: USE AdventureWorks; DECLARE @Binary TABLE ( Digit bit) INSERT @Binary VALUES (0) INSERT @Binary VALUES (1) SELECT ((a.Digit*256) + (b.Digit*128) + (c.Digit*64) + (d.Digit*32) + (e.Digit*16) + (f.Digit*8) + (g.Digit*4) + (h.Digit*2) + (i.Digit*1)) DecimalValue, a.Digit '256', b.Digit '128' , c.Digit '64', d.Digit '32', e.Digit '16', f.Digit '8', g.Digit '4', h.Digit '2', i.Digit '1' FROM @Binary a CROSS JOIN @Binary b CROSS JOIN... - [SQL SERVER - DBCC commands List - documented and undocumented](https://blog.sqlauthority.com/2007/05/15/sql-server-dbcc-commands-list-documented-and-undocumented/): Database Consistency Checker (DBCC) commands can gives valuable insight into what’s going on inside SQL Server system. DBCC commands have powerful documented functions and many undocumented capabilities. Current DBCC commands are most useful for performance and troubleshooting exercises. To learn about all the DBCC commands run following script in query analyzer. DBCC TRACEON(2520) DBCC HELP (‘?’) GO To learn about syntax of an individual DBCC command run following script in query analyzer. DBCC HELP(<command>) GO Following is the list of all the DBCC commands and their syntax. List contains all documented and undocumented DBCC commands. DBCC activecursors [(spid)] DBCC addextendedproc (function_name,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Photo](https://blog.sqlauthority.com/2007/05/14/sql-server-sql-joke-sql-humor-sql-laugh-photo/): Pay attention to the last line of the ingredients. I found this entry at Worse Than Failure. I found it humorous. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - MS TechNet : Storage Top 10 Best Practices](https://blog.sqlauthority.com/2007/05/14/sql-server-ms-technet-storage-top-10-best-practices/): This one of the very interesting article I read regarding SQL Server 2005 Storage. Please refer original article at MS TechNet here. Understand the IO characteristics of SQL Server and the specific IO requirements / characteristics of your application. More / faster spindles are better for performance. Try not to “over” optimize the design of the storage; simpler designs generally offer good performance and more flexibility. Validate configurations prior to deployment. Always place log files on RAID 1+0 (or RAID 1) disks. Isolate log from data at the physical disk level. Consider configuration of TEMPDB database. Lining up the number of... - [SQL SERVER - Query to Find First and Last Day of Current Month - Date Function](https://blog.sqlauthority.com/2007/05/13/sql-server-query-to-find-first-and-last-day-of-current-month/): Following query will run respective on today's date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month. Let us see how we can do this with the help of Date Function in SQL Server. - [SQL SERVER - UDF - Function to Parse AlphaNumeric Characters from String](https://blog.sqlauthority.com/2007/05/13/sql-server-udf-function-to-parse-alphanumeric-characters-from-string/): Following function keeps only Alphanumeric characters in string and removes all the other character from the string. This is very handy function when working with Alphanumeric String only. I have used this many times. CREATE FUNCTION dbo.UDF_ParseAlphaChars ( @string VARCHAR(8000) ) RETURNS VARCHAR(8000) AS BEGIN DECLARE @IncorrectCharLoc SMALLINT SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) WHILE @IncorrectCharLoc > 0 BEGIN SET @string = STUFF(@string, @IncorrectCharLoc, 1, '') SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) END SET @string = @string RETURN @string END GO —-Test SELECT dbo.UDF_ParseAlphaChars('ABC”_I+{D[]}4|:e;””5,<.F>/?6') GO Result Set : ABCID4e5F6 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List all the database](https://blog.sqlauthority.com/2007/05/12/sql-server-2005-list-all-the-database/): List all the database on SQL Servers. All the following Stored Procedure list all the Databases on Server. I personally use EXEC sp_databases because it gives the same results as other but it is self explaining. ----SQL SERVER 2005 System Procedures EXEC sp_databases EXEC sp_helpdb ----SQL 2000 Method still works in SQL Server 2005 SELECT name FROM sys.databases SELECT name FROM sys.sysdatabases ----SQL SERVER Un-Documented Procedure EXEC sp_msForEachDB 'PRINT ''?''' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support](https://blog.sqlauthority.com/2007/05/12/sql-server-fix-error-msg-6263-level-16-state-1-line-2-enabling-sql-server-2005-for-clr-support/): Error: Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support 1) Enable Server for CLR Support. - [SQL SERVER - Explanation SQL Command GO](https://blog.sqlauthority.com/2007/05/11/sql-server-explanation-sql-command-go/): GO is not a Transact-SQL statement; it is often used in T-SQL code. Go causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches. SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is... - [SQL SERVER - Download Microsoft SQL Server 2005 System Views Map](https://blog.sqlauthority.com/2007/05/11/sql-server-download-microsoft-sql-server-2005-system-views-map/): The Microsoft SQL Server 2005 System Views Map shows the key system views included in SQL Server 2005, and the relationships between them. It is available to download from Microsoft Site. It can be printed and mounted at Office Depot or Kinko’s. Download SQL SERVER 2005 System Views Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 Katmai - Download Datasheet Final from Microsoft](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-download-datasheet-final-from-microsoft/): Few interesting thing about Katmai. SQL Server “Katmai” will provide a more secure, reliable and manageable enterprise data platform. SQL Server “Katmai” will enable developers and administrators to save time by allowing them to store and consume any type of data from XML to documents. SQL Server “Katmai” provides a more scalable infrastructure that enables IT to drive business intelligence throughout the organization. SQL Server “Katmai” along with .NET Framework 3.0 will accelerate the development of the next generation of applications. Reference : Pinal Dave (https://blog.sqlauthority.com) MS SQL Server (All the above text) Download Final Datasheet of Katmai from Microsoft - [SQL SERVER - Fix: Error: HResult 0x2, Named Pipes Provider: Could not open a connection](https://blog.sqlauthority.com/2007/05/10/sql-server-fix-error-hresult-0x2-level-16-state-1-named-pipes-provider-could-not-open-a-connection-to-sql-server/): In this blog post we are going to fix the error which is related to Named Pipes Provider. - [SQL SERVER - 2008 Katmai - Your Data, Any Place, Any Time](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-your-data-any-place-any-time/): I was following up on the news of first Microsoft Business Intelligence (BI) Conference held at Seattle. Good news is – SQL Server 2008 code name ‘Katmai’ is announced. I went to the official website I like the catchy line “Your Data, Any Place, Any Time“. As per my opinion the most important thing about Katmai is that it can be used to manage any type of data, including relational data, documents, geographic information and XML. The question I received many times since yesterday is : I am still using SQL Server 2000, I was planning to upgrade to SQL Server... - [SQL SERVER - Fix : Error 2501 : Cannot find a table or object with the name . Check the system catalog.](https://blog.sqlauthority.com/2007/05/09/sql-server-fix-error-2501-cannot-find-a-table-or-object-with-the-name-check-the-system-catalog/): Error 2501 : Cannot find a table or object with the name . Check the system catalog. This is very generic error beginner DBAs or Developers faces. The solution is very simple and easy. Follow the direction below in order. Fix/Workaround/Solution: Make sure that correct Database is selected. If not please run USE YourDatabase. Check the object or table name. They must be spelled correct. If database is case sensitive please use correct case. Use object belongs to other owner use two parts name as scheme_name.object_name. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - MIS2007 Part II - Database Raid Discussion](https://blog.sqlauthority.com/2007/05/09/sqlauthority-news-author-visit-mis2007-part-ii-database-raid-discussion/): MIS2007 is really going good. There are many things going on. As I mentioned in my previous article, It is really pleasure to meet industry leaders. There was discussion about what is good for database RAID 5 configuration or RAID 10. This subject is always very interesting. We were discussing from small databases (5GB) to larger databases(5 TB). The question was which RAID 5 or RAID 10. Surprisingly, everybody who participated in discussion said their experience says RAID 10 is better for this particular application as there are lots of reads and writes in database. One of the expert suggested that... - [SQL SERVER - Index Optimization CheckList](https://blog.sqlauthority.com/2007/05/08/sql-server-index-optimization-checklist/): Index optimization is always interesting subject to me. Every time I receive requests to help optimize query or query on any specific table. I always ask Jr.DBA to go over following list first before I take a look at it. Most of the time the Query Speed is optimized just following basic rules mentioned below. Once following checklist applied interesting optimization part begins which only experiment and experience can resolve. - [SQLAuthority News - Author Visit - The 2007 Marketing Innovation Summit, Las Vegas](https://blog.sqlauthority.com/2007/05/08/sqlauthority-news-author-visit-the-2007-marketing-innovation-summit-las-vegas/): I am attending The 2007 Marketing Innovation Summit“, Las Vegas. It started on 5/6/2007 and will continue till 5/9/2007. Unica Corporation has arranged this conference. The MIS 2007 Agenda includes: Case studies and best practices Sessions focused on Relationship Marketing, Internet Marketing and Marketing Operations Hands on “how to” sessions General sessions from distinguished industry experts A one-day Pre-Summit Affinium New User Workshop and Getting Prepared for Affinium Plan Post-Summit Hands-On Training Evening networking activities In two days so far, I have learned a lot and have met many industry leaders. Talking about cutting edge technology and SQL Server was perfect... - [SQL SERVER - Top 10 Hidden Gems in SQL Server 2005](https://blog.sqlauthority.com/2007/05/07/sql-server-top-10-hidden-gems-in-sql-server-2005/): Top 10 Hidden Gems in SQL Server 2005 By Cihan Biyikoglu SQL Server 2005 has hundreds of new and improved components. Some of these improvements get a lot of the spotlight. However there is another set that are the hidden gems that help us improve performance, availability or greatly simplify some challenging scenarios. This paper lists the top 10 such features in SQL Server 2005 that we have discovered through the implementation with some of our top customers and partners. TableDiff.exe Triggers for Logon Events (New in Service Pack 2) Boosting performance with persisted-computed-columns (pcc). DEFAULT_SCHEMA setting in sys.database_principles Forced Parameterization... - [SQL SERVER - 2005/2000 Examples and Explanation for GOTO](https://blog.sqlauthority.com/2007/05/07/sql-server-20052000-examples-and-explanation-for-goto/): The GOTO statement causes the execution of the T-SQL batch to stop processing the following commands to GOTO and processing continues from the label where GOTO points. GOTO statement can be used anywhere within a procedure, batch, or function. GOTO can be nested as well. GOTO can be executed by any valid user on SQL SERVER. GOTO can co-exists with other control of flow statements (IF…ELSE, WHILE). GOTO can only go(jump) to label in the same batch, it can not go to label out side of the batch. Syntax: Define the label: label: ALTER the execution: GOTO label Notes from MSDN... - [SQL SERVER - Creating Comma Separate Values List from Table - UDF - SP](https://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/): Following script will create common separate values (CSV) or common separate list from tables. convert list to table. Following script is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. There are three ways to do this. 1) Using COALESCE 2) Using SELECT Smartly 3) Using CURSOR. The table is example is: TableName: NumberTable NumberCols first second third fourth fifth Output : first,second,third,fourth,fifth Option 1: This is... - [SQL SERVER - UDF - Function to Convert List to Table](https://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/): Following Users Defined Functions will convert list to table. It also supports user defined delimiter. Following UDF is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. CREATE FUNCTION dbo.udf_List2Table ( @List VARCHAR(MAX), @Delim CHAR ) RETURNS @ParsedList TABLE ( item VARCHAR(MAX) ) AS BEGIN DECLARE @item VARCHAR(MAX), @Pos INT SET @List = LTRIM(RTRIM(@List))+ @Delim SET @Pos = CHARINDEX(@Delim, @List, 1) WHILE @Pos > 0 BEGIN SET... - [SQL SERVER - 2005 Enable CLR using T-SQL script](https://blog.sqlauthority.com/2007/05/05/sql-server-2005-enable-clr-using-t-sql-script/): Before doing any .Net coding in SQL Server you must enable the CLR. In SQL Server 2005, the CLR is OFF by default. This is done in an effort to limit security vulnerabilities. Following is the script which will enable CLR. EXEC sp_CONFIGURE 'show advanced options' , '1'; GO RECONFIGURE; GO EXEC sp_CONFIGURE 'clr enabled' , '1' GO RECONFIGURE; GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - UDF - User Defined Function to Find Weekdays Between Two Dates](https://blog.sqlauthority.com/2007/05/05/sql-server-udf-user-defined-function-to-find-weekdays-between-two-dates/): Following user defined function returns number of weekdays between two dates specified. This function excludes the dates which are passed as input params. It excludes Saturday and Sunday as they are weekends. I always had this function with for reference but after some research I found original source website of the function. This function has been written by Author Alexander Chigrik. CREATE FUNCTION dbo.spDBA_GetWeekDays ( @StartDate datetime, @EndDate datetime ) RETURNS INT AS BEGIN DECLARE @WorkDays INT, @FirstPart INT DECLARE @FirstNum INT, @TotalDays INT DECLARE @LastNum INT, @LastPart INT IF (DATEDIFF(DAY, @StartDate, @EndDate) 0) THEN @LastPart - 1 ELSE 0 END... - [SQL SERVER - Fix : Error : Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset DBSCHEMA_TABLES_INFO for OLE DB provider SQLNCLI for linked server LinkedServerName](https://blog.sqlauthority.com/2007/05/04/sql-server-fix-error-msg-7311-level-16-state-2-line-1-cannot-obtain-the-schema-rowset-dbschema_tables_info-for-ole-db-provider-sqlncli-for-linked-server-linkedservername/): You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server. Error: The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator. Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset “DBSCHEMA_TABLES_INFO” for OLE DB provider “SQLNCLI” for linked server “<LinkedServerName>”. The provider supports the interface, but returns a failure code when it is used. Fix/WorkAround/Solution: Use Windows Authentication mode For a... - [SQL SERVER - Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts)](https://blog.sqlauthority.com/2007/05/04/sql-server-download-sql-server-management-studio-keyboard-shortcuts-ssms-shortcuts/): Download SQL Server Management Studio Keyboard Shortcuts I have received many emails appreciating my article Query Analyzer Shortcuts and requesting same for SQL Server Management Studio Keyboard Shortcuts. I see frequent downloads of the PDF generated by SQLAuthority for the same on server. There is original article on MSDN site. I have combined complete article in one PDF again. It is easy to refer, print and manage. Download SQL Server Management Studio Keyboard Shortcuts Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC Commands to Free SQL Server Memory Caches](https://blog.sqlauthority.com/2007/05/03/sql-server-dbcc-commands-to-free-several-sql-server-memory-caches/): Lots of people do not know that following command can be very helpful to clear your memory caches of SQL Server. I have often seen people restarting their entire system to clear the memory caches. - [SQL SERVER - Enable Login - Disable Login using ALTER LOGIN - Change name of the 'SA'](https://blog.sqlauthority.com/2007/05/03/sql-server-enable-login-disable-login-using-alter-login-change-name-of-the-sa/): Enable Login – Disable Login using ALTER LOGIN – Change name of the ‘SA’ - [SQL SERVER - FIX : ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup](https://blog.sqlauthority.com/2007/05/02/sql-server-fix-error-1101-could-not-allocate-a-new-page-for-database-because-of-insufficient-disk-space-in-filegroup/): ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup . Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. Fix/Workaround/Solution: Make sure there is enough Hard Disk space where database files are stored on server. Turn on AUTOGROW for file groups. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 TOP Improvements/Enhancements](https://blog.sqlauthority.com/2007/05/02/sql-server-2005-top-improvementsenhancements/): SQL Server 2005 introduces two enhancements to the TOP clause. 1) User can specify an expression as an input to the TOP keyword. 2) User can use TOP in modification statements (INSERT, UPDATE, and DELETE). Explanation : User can specify an expression as an input to the TOP keyword. In SQL SERVER 2000 usage of TOP is implemented in following query. SELECT TOP 10 TableColumnID FROM TableName   For ages Developers and DBAs wants to pass parameters to TOP keyword. IN SQL SERVER 2005 it is possible. Example, @iNum is variables set before SELECT statement is ran. DECLARE @iNum INT SET... - [SQL SERVER - User Defined Functions (UDF) to Reverse String - UDF_ReverseString](https://blog.sqlauthority.com/2007/05/01/sql-server-user-defined-functions-udf-to-reverse-string-udf_reversestring/): UDF_ReverseString UDF_ReverseString User Defined Functions returns the Reversed String starting from certain position. First parameters takes the string to be reversed. Second parameters takes the position from where the string starts reversing. Script of UDF_ReverseString function to return Reverse String. CREATE FUNCTION UDF_ReverseString ( @StringToReverse VARCHAR(8000), @StartPosition INT ) RETURNS VARCHAR(8000) AS BEGIN IF (@StartPosition <= 0) OR (@StartPosition > LEN(@StringToReverse)) RETURN (REVERSE(@StringToReverse)) RETURN (STUFF (@StringToReverse, @StartPosition, LEN(@StringToReverse) - @StartPosition + 1, REVERSE(SUBSTRING (@StringToReverse, @StartPosition LEN(@StringToReverse) - @StartPosition + 1)))) END GO Usage of above UDF_ReverseString: Reversing the string from third position SELECT dbo.UDF_ReverseString('forward string',3) Results Set : forgnirts draw Reversing... - [SQL SERVER - Copy Column Headers in Query Analyzers in Result Set](https://blog.sqlauthority.com/2007/05/01/sql-server-copy-column-headers-in-query-analyzers-in-result-set/): Copy Column Headers in Query Analyzers in Result Set. In Query Analyzer go to Menu >> Tools >> Options >> Results Select Default results Target: Results to Text Results output format:(*): Tab Delimited Print column headers(*): Checkbox ON(check) [youtube=http://www.youtube.com/watch?v=BL5GO-jH3HA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com 100th Post - Gratitude Note to Readers](https://blog.sqlauthority.com/2007/05/01/sqlauthoritycom-101st-post-gratitude-note-to-readers/): Hello All, I would like to express my deep gratitude to all of my readers for their emails, comments, suggestions and continuous support on the occasion of 101st post on this blog. I would like to extend my gratitude to my parents. In good times or trying times my parents are there with me always. Mom and Dad thank you for your encouragement, warmth, advise and continuous love. Kind Regards and Best Wishes, Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Collate - Case Sensitive SQL Query Search](https://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/): In this blog post we are going to learn about how to do Case Sensitive SQL Query Search. If Column1 of Table1 has following values ‘CaseSearch, casesearch, CASESEARCH, CaSeSeArCh’, following statement will return you all the four records. - [SQL SERVER - FIX : ERROR : Msg 3159, Level 16, State 1, Line 1 - Msg 3013, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/30/sql-server-fix-error-msg-3159-level-16-state-1-line-1-msg-3013-level-16-state-1-line-1/): While moving some of the script from SQL SERVER 2000 to SQL SERVER 2005 our migration team faced following error. Msg 3159, Level 16, State 1, Line 1 The tail of the log for the database “AdventureWorks” has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. Following is the similar script using AdventureWorks... - [SQL SERVER - SET ROWCOUNT - Retrieving or Limiting the First N Records from a SQL Query](https://blog.sqlauthority.com/2007/04/30/sql-server-set-rowcount-retrieving-or-limiting-the-first-n-records-from-a-sql-query/): A SET ROWCOUNT statement simply limits the number of records returned to the client during a single connection. As soon as the number of rows specified is found, SQL Server stops processing the query. The syntax looks like this: - [SQL SERVER - 2005 Security DataSheet](https://blog.sqlauthority.com/2007/04/29/sql-server-2005-security-datasheet/): Microsoft has implemented strong security features into the Microsoft® SQL Server™ 2005, which provides a security-enabled platform for enterprise-class relational database and analysis solutions. SQL Server 2005 provides cutting edge security technology and addresses several security issues, including automatic secured updates and encryption of sensitive data. Download the SQL Server 2005 Security DataSheet from SQLAuthority.com Download the SQL Server 2005 Security DataSheet from Microsoft.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Random Number Generator Script - SQL Query](https://blog.sqlauthority.com/2007/04/29/sql-server-random-number-generator-script-sql-query/): Random Number Generator. There are many methods to generate random numbers in SQL Server. Method 1: Generate Random Numbers (Int) between Rang - [SQL SERVER - Replication Keywords Explanation and Basic Terms](https://blog.sqlauthority.com/2007/04/29/sql-server-replication-keywords-explanation-and-basic-terms/): While discussing replication with Jr. DBAs at work, I realize some of them have not experienced replication feature of SQL SERVER. Following is quick reference of replication keywords I created for easy conversation. - [SQL SERVER - Explanation SQL SERVER Merge Join](https://blog.sqlauthority.com/2007/04/28/sql-server-explanation-sql-server-merge-join/): The Merge Join transformation provides an output that is generated by joining two sorted data sets using a FULL, LEFT, or INNER join. The Merge Join transformation requires that both inputs be sorted and that the joined columns have matching meta-data. User cannot join a column that has a numeric data type with a column that has a character data type. If the data has a string data type, the length of the column in the second input must be less than or equal to the length of the column in the first input with which it is merged. USE pubs... - [SQL SERVER - Restrictions of Views - T SQL View Limitations](https://blog.sqlauthority.com/2007/04/28/sql-server-restrictions-of-views-t-sql-view-limitations/): UPDATE: (5/15/2007) Thank you Ben Taylor for correcting errors and incorrect information from this post. He is Database Architect and writes Database Articles at www.sswug.org. I have been coding as T-SQL for many years. I never have to use view ever in my career. I do not see in my near future I am using Views. I am able to achieve same database architecture goal using either using Third Normal tables, Replications or other database design work around.SQL Views have many many restrictions. There are few listed below. I love T-SQL but I do not like using Views. - [SQL SERVER - Good, Better and Best Programming Techniques](https://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/): A week ago, I was invited to meeting of programmers. Subject of meeting was “Good, Better and Best Programming Techniques”. I had made small note before I went to meeting, so if I have to talk about or discuss SQL Server it can come handy. Well, I did not get chance to talk on that as it was very causal and just meeting and greetings. Everybody just talked about what they think about their job. I talked very briefly about SQL Server, my current job and some funny incident at work. Everybody laughed big when I talked about funny bug ticket... - [SQL SERVER - Query to Retrieve the Nth Maximum Value](https://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/): Replace Employee with your table name, and Salary with your column name. Where N is the level of Salary to be determined. Let us see a query to retrieve the Nth Maximum Value. - [SQL SERVER - Locking Hints and Examples](https://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/): Locking Hints and Examples are as follows. The usage of them is the same but the effect is different. Let us learn it today together. - [SQL SERVER - SELECT vs. SET Performance Comparison](https://blog.sqlauthority.com/2007/04/27/sql-server-select-vs-set-performance-comparison/): Usage: SELECT : Designed to return data. SET : Designed to assign values to local variables. While testing the performance of the following two scripts in query analyzer, interesting results are discovered. SET @foo1 = 1; SET @foo2 = 2; SET @foo3 = 3; SELECT @foo1 = 1, @foo2 = 2, @foo3 = 3; While comparing their performance in loop SELECT statement gives better performance then SET. In other words, SET is slower than SELECT. The reason is that each SET statement runs individually and updates on values per execution, whereas the entire SELECT statement runs once and update all three... - [SQL SERVER - Difference Between Unique Index vs Unique Constraint](https://blog.sqlauthority.com/2007/04/26/sql-server-difference-between-unique-index-vs-unique-constraint/): Unique Index and Unique Constraint are the same. They achieve same goal. SQL Performance is same for both. Add Unique Constraint ALTER TABLE dbo.<tablename> ADD CONSTRAINT <namingconventionconstraint> UNIQUE NONCLUSTERED ( <columnname> ) ON [PRIMARY] Add Unique Index CREATE UNIQUE NONCLUSTERED INDEX <namingconventionconstraint> ON dbo.<tablename> ( <columnname> ) ON [PRIMARY] There is no difference between Unique Index and Unique Constraint. Even though syntax are different the effect is the same. Unique Constraint creates Unique Index to maintain the constraint to prevent duplicate keys. Unique Index or Primary Key Index are physical structure that maintain uniqueness over some combination of columns across all... - [SQL SERVER - Enable xp_cmdshell using sp_configure](https://blog.sqlauthority.com/2007/04/26/sql-server-enable-xp_cmdshell-using-sp_configure/): The xp_cmdshell option is a server configuration option that enables system administrators to control whether the xp_cmdshell extended stored procedure can be executed on a system. - [SQL SERVER - 2005 - DBCC ROWLOCK - Deprecated](https://blog.sqlauthority.com/2007/04/26/sql-server-2005-dbcc-rowlock-deprecated/): Title says all. My search engine log says many web users are looking for DBCC ROWLOCK in SQL SERVER 2005. It is deprecated feature for SQL SERVER 2005. It is Automatically on for SQL SERVER 2005. More Deprecated Features of SQL SERVER 2005 Refer MSDN Discontinued Database Engine Functionality in SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Alternate Fix : ERROR 1222 : Lock request time out period exceeded](https://blog.sqlauthority.com/2007/04/25/sql-server-alternate-fix-error-1222-lock-request-time-out-period-exceeded/): ERROR 1222 : Lock request time out period exceeded. - [SQL SERVER - ERROR Messages - sysmessages error severity level](https://blog.sqlauthority.com/2007/04/25/sql-server-error-messages-sysmessages-error-severity-level/): SQL ERROR Messages Each error message displayed by SQL Server has an associated error message number that uniquely identifies the type of error. The error severity levels provide a quick reference for you about the nature of the error. The error state number is an integer value between 1 and 127; it represents information about the source that issued the error. The error message is a description of the error that occurred. The error messages are stored in the sysmessages system table. - [SQL SERVER - 2005 Take Off Line or Detach Database](https://blog.sqlauthority.com/2007/04/25/sql-server-2005-take-off-line-or-detach-database/): EXEC sp_dboption N'mydb', N'offline', N'true' OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK AFTER 30 SECONDS OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK IMMEDIATE Using the alter database statement (SQL Server 2k and beyond) is the preferred method. The rollback after statement will force currently executing statements to rollback after N seconds. The default is to wait for all currently running transactions to complete and for the sessions to be terminated. Use the rollback immediate clause to rollback transactions immediately. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - TRIM() Function - UDF TRIM()](https://blog.sqlauthority.com/2007/04/24/sql-server-trim-function-udf-trim/): SQL Server does not have function which can trim leading or trailing spaces of any string. TRIM() is very popular function in many languages. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. I was expecting SQL Server 2005 to have TRIM() function. Unfortunately, SQL Server 2005 does not have that either. I have created very simple UDF which does the same work. FOR SQL SERVER 2000: CREATE FUNCTION dbo.TRIM(@string VARCHAR(8000)) RETURNS VARCHAR(8000) BEGIN RETURN LTRIM(RTRIM(@string)) END GO FOR SQL SERVER 2005: CREATE FUNCTION dbo.TRIM(@string VARCHAR(MAX)) RETURNS VARCHAR(MAX) BEGIN RETURN LTRIM(RTRIM(@string)) END GO Both the above... - [SQL SERVER - Six Properties of Relational Tables](https://blog.sqlauthority.com/2007/04/24/sql-server-six-properties-of-relational-tables/): Relational tables have six properties: Values Are Atomic This property implies that columns in a relational table are not repeating group or arrays. The key benefit of the one value property is that it simplifies data manipulation logic. Such tables are referred to as being in the “first normal form” (1NF). Column Values Are of the Same Kind In relational terms this means that all values in a column come from the same domain. A domain is a set of values which a column may have. This property simplifies data access because developers and users can be certain of the type... - [SQL SERVER - 2005 Collation Explanation and Translation](https://blog.sqlauthority.com/2007/04/24/sql-server-2005-collation-explanation-and-translation/): Just a day before one of our SQL SERVER 2005 needed Case-Sensitive Binary Collation. When we install SQL SERVER 2005 it gives options to select one of the many collation. I says in words like ‘Dictionary order, case-insensitive, uppercase preference’. I was confused for little while as I am used to read collation like ‘SQL_Latin1_General_Pref_Cp1_CI_AS_KI_WI’. I did some research and find following link which explains many of the SQL SERVER 2005 collation. Complete documentation MSDN – SQL SERVER Collation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Query Analyzer - Microsoft SQL SERVER Management Studio](https://blog.sqlauthority.com/2007/04/23/sql-server-2005-query-analyzer-microsoft-sql-server-management-studio/): Following may be very simple to some and helpful to other type of question. I have seen this in my server log as well as this has been always first question in my Developer Team. Where is SQL SERVER 2005 Query Analyzer? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). To see the familiour Query Analyzer Window follow the image below. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Find Seed Values, Increment Values and Current Identity Column value of the table](https://blog.sqlauthority.com/2007/04/23/sql-server-query-to-find-seed-values-increment-values-and-current-identity-column-value-of-the-table/): Following script will return all the tables which has identity column. It will also return the Seed Values, Increment Values and Current Identity Column value of the table. SELECT IDENT_SEED(TABLE_NAME) AS Seed, IDENT_INCR(TABLE_NAME) AS Increment, IDENT_CURRENT(TABLE_NAME) AS Current_Identity, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1 AND TABLE_TYPE = 'BASE TABLE' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Understanding new Index Type of SQL Server 2005 Included Column Index along with Clustered Index and Non-clustered Index](https://blog.sqlauthority.com/2007/04/23/sql-server-understanding-new-index-type-of-sql-server-2005-included-column-index-along-with-clustered-index-and-non-clustered-index/): Clustered Index Only 1 allowed per table Physically rearranges the data in the table to conform to the index constraints. - [SQL SERVER - Raid Configuration - RAID 10](https://blog.sqlauthority.com/2007/04/22/sql-server-raid-configuration-raid-10/): I get question about what configuration of redundant array of inexpensive disks (RAID) I use for my SQL Servers. The answer is short is: RAID 10. Why? Excellent performance with Read and Write. RAID 10 has advantage of both RAID 0 and RAID 1. RAID 10 uses all the drives in the array to gain higher I/O rates so more drives in the array higher performance. RAID 5 has penalty for write performance because of the parity in check. There are many article already written about them. If you are interested in reading more please refer book online. Reference : Pinal... - [SQL SERVER - @@DATEFIRST and SET DATEFIRST Relations and Usage](https://blog.sqlauthority.com/2007/04/22/sql-server-datefirst-and-set-datefirst-relations-and-usage/): The master database’s syslanguages table has a DateFirst column that defines the first day of the week for a particular language. SQL Server with US English as default language, SQL Server sets DATEFIRST to 7 (Sunday) by default. We can reset any day as first day of the week using SET DATEFIRST 5 This will set Friday as first day of week. @@DATEFIRST returns the current value, for the session, of SET DATEFIRST. SET LANGUAGE italian GO SELECT @@DATEFIRST GO ----This will return result as 1(Monday) SET LANGUAGE us_english GO SELECT @@DATEFIRST GO ----This will return result as 7(Sunday) In this... - [SQL SERVER - Fix : Error 1418 - Microsoft SQL Server - The server network address can not be reached](https://blog.sqlauthority.com/2007/04/22/sql-server-fix-error-1418-microsoft-sql-server-the-server-network-address-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-reissue-the-command/): Error: 1418 – Microsoft SQL Server – The server network address can not be reached or does not exist. Check the network address name and reissue the command The server network endpoint did not respond because the specified server network address cannot be reached or does not exist. - [SQL Server Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/04/21/sql-server-interview-questions-and-answers-complete-list-download/): This is summary blog post for SQL Server Interview Questions and Answers. Click here to get free chapters (PDF) in the mailbox. - [SQL Server Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2007/04/20/sql-server-interview-questions-part-6/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2007/04/19/sql-server-interview-questions-part-5/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2007/04/18/sql-server-interview-questions-part-4/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/04/17/sql-server-interview-questions-part-3/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/04/16/sql-server-interview-questions-part-2/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions-and-answers-introduction/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL SERVER - 64 bit Architecture and White Paper](https://blog.sqlauthority.com/2007/04/14/sql-server-64-bit-architecture-and-white-paper/): In supportability, manageability, scalability, performance, interoperability, and business intelligence, SQL Server 2005 provides far richer 64-bit support than its predecessor. This paper describes these enhancements. Read the original paper here. Following abstract is taken from the same paper. Another interesting article on 64-bit Computing with SQL Server 2005 is here. The primary differences between the 64-bit and 32-bit versions of SQL Server 2005 are derived from the benefits of the underlying 64-bit architecture. Some of these are: The 64-bit architecture offers a larger directly-addressable memory space. SQL Server 2005 (64-bit) is not bound by the memory limits of 32-bit systems. Therefore,... - [SQL SERVER - CASE Statement/Expression Examples and Explanation](https://blog.sqlauthority.com/2007/04/14/sql-server-case-statementexpression-examples-and-explanation/): CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in functions. Two basic formulations for CASE expression 1) Simple CASE expressions A simple CASE expression checks one expression against multiple values. Within a SELECT statement, a simple CASE expression allows only an equality check; no other comparisons are made. A simple CASE expression operates by comparing the first expression to the expression in each WHEN clause for equivalency. If these expressions... - [SQL SERVER - Fix : Error: 18452 Login failed for user '(null)'. The user is not associated with a trusted SQL Server connection.](https://blog.sqlauthority.com/2007/04/14/sql-server-fix-error-18452-login-failed-for-user-null-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Some errors never got old. I have seen many new DBA or Developers struggling with this errors. Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection. Fix/Solution/Workaround: Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)” to “Mixed Mode (Windows Authentication and SQL Server Authentication)”. Run following script in SQL Analyzer to change the authentication LOGIN sa ENABLE GO ALTER LOGIN sa WITH PASSWORD = '<password>' GO OR In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties. On the General page, you may have to create... - [SQL SERVER - Stored Procedures Advantages and Best Advantage](https://blog.sqlauthority.com/2007/04/13/sql-server-stored-procedures-advantages-and-best-advantage/): There are many advantages of Stored Procedures. I was once asked what do I think is the most important feature of Stored Procedure? I have to pick only ONE. It is tough question. I answered : Execution Plan Retention and Reuse (SP are compiled and their execution plan is cached and used again to when the same SP is executed again) Not to mentioned I received the second question following my answer : Why? Because all the other advantage known (they are mentioned below) of SP can be achieved without using SP. Though Execution Plan Retention and Reuse can only be... - [SQL SERVER - Script to Find SQL Server on Network](https://blog.sqlauthority.com/2007/04/13/sql-server-script-to-find-sql-server-on-network/): I manage lots of SQL Servers. Many times I forget how many server I have and what are their names. New servers are added frequently and old servers are replaced with powerful servers. I run following script to check if server is properly set up and announcing itself. This script requires execute permissions on XP_CMDShell. CREATE TABLE #servers(sname VARCHAR(255)) INSERT #servers (sname) EXEC master..xp_CMDShell 'ISQL -L' DELETE FROM #servers WHERE sname='Servers:' OR sname IS NULL SELECT LTRIM(sname) FROM #servers DROP TABLE #servers Watch a 60 second video on this subject [youtube=http://www.youtube.com/watch?v=8P5TuOg3PlA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Disable Triggers - Drop Triggers](https://blog.sqlauthority.com/2007/04/13/sql-server-2005-disable-triggers-drop-triggers/): There are two ways to prevent trigger from firing. 1) Drop Trigger Example: DROP TRIGGER TriggerName GO 2) Disable Trigger DML trigger can be disabled two ways. Using ALETER TABLE statement or use DISABLE TRIGGER. I prefer DISABLE TRIGGER statement. Syntax: DISABLE TRIGGER { [ schema . ] trigger_name [ ,...n ] | ALL } ON { OBJECT_NAME | DATABASE | ALL SERVER } [ ; ] Example: DISABLE TRIGGER TriggerName ON TableName Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-1702-create-table-failed-because-column-in-table-exceeds-the-maximum-of-columns/): Error Received: Error 1702 CREATE TABLE failed because column in table exceeds the maximum of columns SQL Server 2000 supports table with maximum 1024 columns. This errors happens when we try to create table with 1024 columns or try to add columns to table which exceeds more than 1024. Fix/Solution/WorkAround: Reduce the number of columns in the table to 1,024 or less. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error: 3902, Severity: 16; State: 1 : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.](https://blog.sqlauthority.com/2007/04/12/sql-server-fix-error-3902-severity-16-state-1-the-commit-transaction-request-has-no-corresponding-begin-transaction/): SQL Server Integration Services Error : The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. (Microsoft OLE DB Provider for SQL Server) Fix/Workaround/Solution: Option 1: To work around this problem, do not call the stored procedure by using ODBC Call syntax. You can call the stored procedure in may ways by using ADO. One of the methods is to call a stored procedure by using a command object. (View Example) Option 2: If the sql statements are like BEGIN TRAN SQL Statements END TRAN SET “RetainSameConnection” property on the connection manager to true. This will fix the problem. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Running 64 bit SQL SERVER 2005 on 32 bit Operating System](https://blog.sqlauthority.com/2007/04/12/sql-server-running-64-bit-sql-server-2005-on-32-bit-operating-system/): Few days ago, I have received email from users asking question :How to run 64 bit SQL SERVER 2005 on 32 bit operating system? - [SQL SERVER - UDF - User Defined Function to Extract Only Numbers From String](https://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/): Following SQL User Defined Function will extract/parse numbers from the string. CREATE FUNCTION ExtractInteger(@String VARCHAR(2000)) RETURNS VARCHAR(1000) AS BEGIN DECLARE @Count INT DECLARE @IntNumbers VARCHAR(1000) SET @Count = 0 SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1) END SET @Count = @Count + 1 END RETURN @IntNumbers END GO Run following script in query analyzer. SELECT dbo.ExtractInteger('My 3rd Phone Number is 323-111-CALL') GO It will return following values. 3323111 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Explanation of TRY...CATCH and ERROR Handling](https://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/): SQL Server 2005 offers a more robust set of tools for handling errors than in previous versions of SQL Server. Deadlocks, which are virtually impossible to handle at the database level in SQL Server 2000, can now be handled with ease. By taking advantage of these new features, you can focus more on IT business strategy development and less on what needs to happen when errors occur. In SQL Server 2005, @@ERROR variable is no longer needed after every statement executed, as was the case in SQL Server 2000. SQL Server 2005 provides the TRY…CATCH construct, which is already present in... - [SQL SERVER - 2005 - Silent Installation - Unattended Installation](https://blog.sqlauthority.com/2007/04/10/sql-server-2005-silent-installation-unattended-installation/): Silent SQL Server 2005 Installation is possible in two steps. 1) Creating an .ini file The SQL Server CD contains a template file called template.ini . Based on that create another required .ini file which includes a single [Options] section containing multiple parameters, each relating to a different feature or configuration setting. 2) Run Setup on command prompt On command prompt type following script setup.exe /settings <path TO .ini FILE> If location of sqlinstall.ini file is at C:\SQLSetup folder. The command to initiate silent installation is: setup.exe /settings C:SQLSetup sqlinstall.ini Specify the /qn switch to perform a silent installation (with no... - [SQL SERVER - SP Performance Improvement without changing T-SQL](https://blog.sqlauthority.com/2007/04/10/sql-server-sp-performance-improvement-without-changing-t-sql/): There are two ways, which can be used to improve the performance of Stored Procedure (SP) without making T-SQL changes in SP. Do not prefix your Stored Procedure with sp_. In SQL Server, all system SPs are prefixed with sp_. When any SP is called which begins sp_ it is looked into masters database first before it is looked into the database it is called in. Call your Stored Procedure prefixed with dbo.SPName – fully qualified name. When SP are called prefixed with dbo. or database.dbo. it will prevent SQL Server from placing a COMPILE lock on the procedure. While SP... - [SQL SERVER - 2005 Reserved Keywords](https://blog.sqlauthority.com/2007/04/09/sql-server-2005-reserved-keywords/): Microsoft SQL Server 2005 uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language that is used by SQL Server to parse and understand Transact-SQL statements and batches. It is not legal to include the reserved keywords in a Transact-SQL statement in any location except that defined by SQL Server. No objects in the database should be given a name that matches a reserved keyword. Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using... - [SQL SERVER - Search Text Field - CHARINDEX vs PATINDEX](https://blog.sqlauthority.com/2007/04/08/sql-server-search-text-field-charindex-vs-patindex/): We can use either CHARINDEX or PATINDEX to search in TEXT field in SQL SERVER. The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. Both functions take two arguments. With PATINDEX, you must include percent signs before and after the pattern, unless you are looking for the pattern as the first (omit the first %) or last (omit the last %) characters in a column. For CHARINDEX, the pattern cannot include wildcard characters. The second argument is a character expression, usually a column name, in which Adaptive Server searches for the specified pattern. Example of CHARINDEX:... - [SQL SERVER - DBCC Commands Introduced in SQL Server 2005](https://blog.sqlauthority.com/2007/04/07/sql-server-dbcc-commands-introduced-in-sql-server-2005/): SQL Server 2005 has introduced following two documented and five undocumented DBCC Commands. I was able to find documentation for only first one online. If you find any documentation of any other DBCC Commands please add comments. It will be helpful to all of us. Documented: freesessioncache () — no parameters Flushes the distributed query connection cache used by distributed queries against an instance of Microsoft SQL Server. View Details requeststats ({clear} | {setfastdecayrate, rate} | {setslowdecayrate, rate}) UnDocumented: mapallocunit (I8AllocUnitId | {I4part, I2part}) metadata ({‘print’ [, printopt = {0 |1}] | ‘drop’ | ‘clone’ [, ” | ….]}, {‘object’ [,... - [SQL SERVER - Fix: Server: Msg 7391, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/06/sql-server-fix-server-msg-7391-level-16-state-1-line-1/): I have received this error many times on different servers in my careers. There is no single fix for this Error. Server: Msg 7391, Level 16, State 1, Line 1 can happen due to many reasons. I have used various of this reasons with few of my servers. Please refer them and try them one by one. One of them should be applicable to your problem. You may receive a 7391 error message in SQLOLEDB when you run a distributed transaction against a linked server after you install Windows XP Service Pack 2 or Windows XP Tablet PC Edition 200. View... - [SQL SERVER - Performance Optimization of SQL Query and FileGroups](https://blog.sqlauthority.com/2007/04/05/sql-server-performance-optimization-of-sql-query-and-filegroups/): It is suggested to place transaction logs on separate physical hard drives. In this manner, data can be recovered up to the second in the event of a media failure. In SQL 2005 When database is created without specifying a transaction log size, the transaction log will be re-sized to 25 percent of the size of data files. Tables and their non-clustered indexes separated into separate file groups can improve performance, because modifications to the table can be written to both the table and the index at the same time. If tables and their corresponding indexes in a different file group,... - [SQL SERVER - Fix: HResult 0x274D, SQLCMD Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired](https://blog.sqlauthority.com/2007/04/04/sql-server-fix-hresult-0x274d-level-16-state-1-error-microsoft-sql-native-client-login-timeout-expired/): While Working with SQLCMD in SQL Server 2005 I encountered following error. Let us learn in this blog post how we can solve Fix: HResult 0x274D, Level 16, State 1 Error: Microsoft SQL Native Client : Login timeout expired. - [SQL SERVER - T-SQL Paging Query Technique Comparison - SQL 2000 vs SQL 2005](https://blog.sqlauthority.com/2007/04/03/sql-server-t-sql-paging-query-technique-comparison-sql-2000-vs-sql-2005/): I was doing paging in SQL Server 2000 using Temp Table or Derived Tables. I decided to checkout new function ROW_NUMBER() in SQL Server 2005. ROW_NUMBER() returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. I have compared both the following query on SQL Server 2005. SQL 2005 Paging Method USE AdventureWorks GO DECLARE @StartRow INT DECLARE @EndRow INT SET @StartRow = 120 SET @EndRow = 140 SELECT FirstName, LastName, EmailAddress FROM ( SELECT PC.FirstName, PC.LastName, PC.EmailAddress, ROW_NUMBER() OVER( ORDER BY PC.FirstName, PC.LastName,PC.ContactID) AS RowNumber FROM... - [SQL SERVER - 2005 - Performance Dashboard Reports](https://blog.sqlauthority.com/2007/04/02/sql-server-2005-performance-dashboard-reports/): The Microsoft SQL Server 2005 Performance Dashboard Reports are used to monitor and resolve performance problems on your SQL Server 2005 database server. The SQL Server instance being monitored and the Management Studio client used to run the reports must both be running SP2 or later. Common performance problems that the dashboard reports may help to resolve include: – CPU bottlenecks (and what queries are consuming the most CPU) – IO bottlenecks (and what queries are performing the most IO). – Index recommendations generated by the query optimizer (missing indexes) – Blocking – Latch contention The SQL Server 2005 Performance Dashboard... - [SQL SERVER - TempDB is Full. Move TempDB from one drive to another drive.](https://blog.sqlauthority.com/2007/04/01/sql-server-tempdb-is-full-move-tempdb-from-one-drive-to-another-drive/): If you ever find your TEmpDB to be full and if you want to move TempDB, you will find this blog post very helpful. Here is the error message which may come across. Event ID: 17052 Description: The LOG FILE FOR DATABASE 'tempdb' IS FULL. Back up the TRANSACTION LOG FOR the DATABASE TO free Up SOME LOG SPACE - [SQL SERVER - 2005 Best Practices Analyzer (February 2007 CTP)](https://blog.sqlauthority.com/2007/03/31/sql-server-2005-best-practices-analyzer-february-2007-ctp/): Microsoft has released a tool called the Microsoft SQL Server Best Practices Analyzer. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. Download SQL Server 2005 Best Practices Analyzer (February 2007 Community Technology Preview) Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Index Seek Vs. Index Scan (Table Scan)](https://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/): Index Scan retrieves all the rows from the table. Index Seek retrieves selective rows from the table. - [SQL SERVER - Difference between DISTINCT and GROUP BY - Distinct vs Group By](https://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/): This question is asked many times to me. What is difference between DISTINCT and GROUP BY? A DISTINCT and GROUP BY usually generate the same query plan, so performance should be the same across both query constructs. GROUP BY should be used to apply aggregate operators to each group. If all you need is to remove duplicates then use DISTINCT. If you are using sub-queries execution plan for that query varies so in that case you need to check the execution plan before making decision of which is faster. Example of DISTINCT: SELECT DISTINCT Employee, Rank FROM Employees Example of GROUP... - [SQL SERVER - Fix : Error 8101 An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON](https://blog.sqlauthority.com/2007/03/28/sql-server-fix-error-8101-an-explicit-value-for-the-identity-column-in-table-can-only-be-specified-when-a-column-list-is-used-and-identity_insert-is-on/): This error occurs when the user has attempted to insert a row containing a specific identity value into a table that contains an identity column. Run following commands according to your SQL Statement. Let us learn about the IDENTITY_INSERT. - [SQL SERVER - Fix : Error 701 There is insufficient system memory to run this query](https://blog.sqlauthority.com/2007/03/27/sql-server-fix-error-701-there-is-insufficient-system-memory-to-run-this-query/): Generic Solution: Check the settings for both min server memory (MB) and max server memory (MB). If max server memory (MB) is a value close to the value of min server memory (MB), then increase the max server memory (MB) value. Check the size of the virtual memory paging file. If possible, increase the size of the file. For SQL Server 2005: Install following HotFix and Restart Server. Additionally following DBCC Commands can be ran to free memory: DBCC FREESYSTEMCACHE DBCC FREESESSIONCACHE DBCC FREEPROCCACHE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT - Retrieve Last Inserted Identity of Record](https://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/): SELECT @@IDENTITY It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value. @@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it. SELECT SCOPE_IDENTITY()... - [SQL SERVER - Stored Procedure - Clean Cache and Clean Buffer](https://blog.sqlauthority.com/2007/03/23/sql-server-stored-procedure-clean-cache-and-clean-buffer/): DBCC FREEPROCCACHE will invalidate all stored procedure plans that the optimizer has cached in memory. Let us learn how to clean cache.  - [SQL SERVER - Fix: Error Msg 128 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.](https://blog.sqlauthority.com/2007/03/22/sql-server-fix-error-msg-128-the-name-is-not-permitted-in-this-context-only-constants-expressions-or-variables-allowed-here-column-names-are-not-permitted/): Error Message: Server: Msg 128, Level 15, State 1, Line 3 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Causes: This error occurs when using a column as the DEFAULT value of another column when a table is created. CREATE TABLE [dbo].[Items] ( [OrderCount] INT, [ProductAmount] INT, [TotalAmount] DEFAULT ([OrderCount] + [ProductAmount]) ) Executing this CREATE TABLE statement will generate the following error message: Server: Msg 128, Level 15, State 1, Line 5 The name ‘TotalAmount’ is not permitted in this context. Only constants, expressions, or variables allowed here.... - [SQL SERVER - 2005 Security Best Practices - Operational and Administrative Tasks](https://blog.sqlauthority.com/2007/03/21/sql-server-2005-security-best-practices-operational-and-administrative-tasks/): This white paper covers some of the operational and administrative tasks associated with SQL Server 2005 security and enumerates best practices and operational and administrative tasks that will result in a more secure SQL Server system. - [SQL SERVER - SQL Commandments - Suggestions, Tips, Tricks](https://blog.sqlauthority.com/2007/03/20/sql-server-sql-commandments-suggestions-tips-tricks/): Few days ago, while searching for something on web site, I came across a very good article of 25 SQL Commandments. I really enjoyed reading it. It was for Oracle, I re-wrote it for SQL Server. First 18 points are taken from original article and last 2 I added to complete total of 20 Commandments. Many more rules and suggestions can be added to this list, this list is just a beginning. 1. Know your data and business application well. Familiarize yourself with these sources; you must be aware of the data volume and distribution in your database. 2. Test your... - [SQL SERVER - Fix: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17](https://blog.sqlauthority.com/2007/03/16/sql-server-fix-sqllib-error-oledb-error-encountered-calling-idbinitializeinitialize-hr-0x80004005-sqlstate-08001-native-error-17/): Error received: Sqllib error: OLEDB Error encountered calling IDBInitialize::Initialize. hr = 0x80004005. SQLSTATE: 08001, Native Error: 17 Error state: 1, Severity: 16 Source: Microsoft OLE DB Provider for SQL Server Error message: [DBNETLIB]SQL Server does not exist or access denied The simple fix: Microsoft SQL Server 2005 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server 2005 Network Configuration >> Enable TCP-IP. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC command to RESEED Table Identity Value - Reset Table Identity](https://blog.sqlauthority.com/2007/03/15/sql-server-dbcc-reseed-table-identity-value-reset-table-identity/): DBCC CHECKIDENT can reseed (reset) the identity value of the table. For example, YourTable has 25 rows with 25 as last identity. If we want next record to have identity as 35 we need to run following T SQL script in Query Analyzer. DBCC CHECKIDENT (yourtable, reseed, 34) If table has to start with an identity of 1 with the next insert then the table should be reseeded with the identity to 0. If identity seed is set below values that currently are in table, it will violate the uniqueness constraint as soon as the values start to duplicate and will... - [SQL SERVER - Union vs. Union All - Which is better for performance?](https://blog.sqlauthority.com/2007/03/10/sql-server-union-vs-union-all-which-is-better-for-performance/): This article is completely re-written with better example SQL SERVER – Difference Between Union vs. Union All – Optimal Performance Comparison. I suggest all of my readers to go here for update article. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected. UNION ALL The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values. The difference between Union and Union all... - [SQL SERVER - Download 2005 SP2a](https://blog.sqlauthority.com/2007/03/07/sql-server-2005-sp2a/): Microsoft released an updated SQL Server 2005 SP2 on March 5th, 2007. The build number is 9.00.3042.01. The previous build number was 9.00.3042.00.Microsoft released a SP2a patch for the second service pack for SQL Server 2005 to fix the issues with the maintenance plans.If you have upgraded to SP2, use the download from here to patch the system. KB 933508 has more information on this patch. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Script to Determine Which Version of SQL Server 2000-2005 is Running](https://blog.sqlauthority.com/2007/03/07/sql-server-script-to-determine-which-version-of-sql-server-2000-2005-is-running/): To determine which version of SQL Server 2000/2005 is running, connect to SQL Server 2000/2005 by using Query Analyzer, and then run the following code: SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') The results are: The product version (for example, 8.00.534). The product level (for example, “RTM” or “SP2”). The edition (for example, “Standard Edition”). For example, the result looks similar to: 8.00.534 RTM Standard Edition Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation](https://blog.sqlauthority.com/2007/03/05/sql-server-quoted_identifier-onoff-and-ansi_null-onoff-explanation/): When create or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF? SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO--SQL PROCEDURE, SQL FUNCTIONS, SQL OBJECTGO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO ANSI NULL ON/OFF: This option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares a value with a null returns a 0. When off, any query that compares a value with a null returns a null value. QUOTED IDENTIFIER ON/OFF:... - [SQL SERVER - Delete Duplicate Records - Rows](https://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/): Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3. DELETE FROM MyTable WHERE ID NOT IN ( SELECT MAX(ID) FROM MyTable GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3) Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to find the CD key from Registry](https://blog.sqlauthority.com/2007/02/28/sql-server-t-sql-script-to-find-the-cd-key-from-registry/): Here is the way to find SQL Server CD key, which was used to install it on machine. If user do not have permission on the SP, please login using SA username. Expended stored procedure xp_regread can read any registry values. I have used this XP to read CD_KEY. This is undocumented Stroed Procedure and may not be supported in Future Version of SQL Server. USE master GO EXEC xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Microsoft SQL Server\80\Registration','CD_KEY' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - What is New in SQL Server Agent for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/02/26/sql-server-whats-new-in-sql-server-agent-for-microsoft-sql-server-2005/): I came across this interesting and detailed article ‘What’s New in SQL Server Agent for Microsoft SQL Server 2005’ on Microsoft TechNet. This article describes Security Improvements, New Roles in the msdb Database, Multiple Proxy Accounts, Performance Improvements, Performance Counters, New SQL Server Agent Subsystems, Shared Schedules, WMI Event Alerts, SQL Server Agent Sessions, Database Mail Support, Stored Procedure Changes in depth. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Restore Database Backup using SQL Script (T-SQL)](https://blog.sqlauthority.com/2007/02/25/sql-server-restore-database-backup-using-sql-script-t-sql/): In this blog post we are going to learn how to restore database backup using T-SQL script. We have already database which we will use to take a backup first and right after that we will use it to restore to the server. Taking backup is an easy thing, but I have seen many times when a user tries to restore the database, it throws an error. - [SQL SERVER - Download SQL Server 2005 Books Online (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-download-sql-server-2005-books-online-february-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The February 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - SQL Server 2005 Samples and Sample Databases (February 2007)](https://blog.sqlauthority.com/2007/02/24/sql-server-sql-server-2005-samples-and-sample-databases-february-2007/): The samples download provides over 100 samples for SQL Server 2005, demonstrating the following components: Database Engine, including administration, data access, Full-Text Search, Common Language Runtime (CLR) integration, Server Management Objects (SMO), Service Broker, and XML Analysis Services Integration Services Notification Services Reporting Services Replication The samples databases downloads include the AdventureWorks sample online transaction processing (OLTP) database, the AdventureWorksDW sample data warehouse, and the AdventureWorksAS sample projects which you can use to build the AdventureWorksAS BI database. These databases are used in the samples and in the code examples in the SQL Server 2005 Books Online. There is also a... - [SQL SERVER - Creating Comma Separate List From Table](https://blog.sqlauthority.com/2007/02/20/deprecate-dec-2007-creating-comma-separate-list-from-table/): Update : (5/5/2007) I have updated the script to support SQL SERVER 2005. Visit :SQL SERVER – Creating Comma Separate Values List from Table – UDF – SP Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : Error 15023: User already exists in current database.](https://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/): Error 15023: User already exists in current database. 1) This is the best Solution. First of all run following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan. USE YourDB GO EXEC sp_change_users_login 'Report' GO Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist. In following example ‘ColdFusion’ is UserName, ‘cf’ is Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in... - [SQL SERVER - Function to Convert List to Table](https://blog.sqlauthority.com/2007/02/10/sql-server-function-to-convert-list-to-table/): Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005. Visit :SQL SERVER – UDF – Function to Convert List to Table Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Constraints and Unique Key Constraints](https://blog.sqlauthority.com/2007/02/05/sql-server-primary-key-constraints-and-unique-key-constraints/): Primary Key: Primary Key enforces uniqueness of the column on which they are defined. Primary Key creates a clustered index on the column. Primary Key does not allow Nulls. Create table with Primary Key: CREATE TABLE Authors ( AuthorID INT NOT NULL PRIMARY KEY, Name VARCHAR(100) NOT NULL ) GO Alter table with Primary Key: ALTER TABLE Authors ADD CONSTRAINT pk_authors PRIMARY KEY (AuthorID) GO Unique Key: Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value. Alter table to add unique constraint... - [SQL SERVER - UDF - Function to Convert Text String to Title Case - Proper Case](https://blog.sqlauthority.com/2007/02/01/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case/): Following function will convert any string to Title Case. I have this function for long time. I do not remember that if I wrote it myself or I modified from original source. Run Following T-SQL statement in query analyzer: SELECT dbo.udf_TitleCase('This function will convert this string to title case!') The output will be displayed in Results pan as follows: This Function Will Convert This String To Title Case! T-SQL code of the function is: CREATE FUNCTION udf_TitleCase (@InputString VARCHAR(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(1) DECLARE @OutputString VARCHAR(255) SET @OutputString = LOWER(@InputString) SET @Index = 2... - [SQL SERVER - ReIndexing Database Tables and Update Statistics on Tables](https://blog.sqlauthority.com/2007/01/31/sql-server-reindexing-database-tables-and-update-statistics-on-tables/): SQL SERVER 2005 uses ALTER INDEX syntax to reindex database. SQL SERVER 2005 supports DBREINDEX but it will be deprecated in future versions. Let us learn how to do ReIndexing Database Tables and Update Statistics on Tables. - [SQL SERVER - Query Analyzer Short Cut to display the text of Stored Procedure](https://blog.sqlauthority.com/2007/01/30/query-analyzer-short-cut-to-display-the-text-of-stored-procedure/): This is quick but interesting trick to display the text of Stored Procedure in the result window. Open SQL Query Analyzer >> Tools >> Customize >> Custom Tab type sp_helptext against Ctrl+3 (or shortcut key of your choice) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh](https://blog.sqlauthority.com/2007/01/26/sql-server-sql-joke-sql-humor-sql-laugh/): I have heard this joke from my friend. I always wanted to write it but I was not able to find the source of the joke. This joke I have located on DavidM’s Blog on SQLTeam. It is March 1st and the first day of DBMS school The teacher starts off with a role call.. Teacher: Oracle? “Present sir” Teacher: DB2? “Present sir” Teacher: SQL Server? “Present sir” Teacher: MySQL? [Silence] Teacher: MySQL? [Silence] Teacher: Where the hell is MySQL [In rushes MySQL, unshaven, hair a mess] Teacher: Where have you been MySQL “Sorry sir I thought it was February 31st”... - [SQL SERVER - Query Analyzer Shortcuts](https://blog.sqlauthority.com/2007/01/20/sql-server-query-analyzer-shortcuts/): Download Query Analyzer Shortcuts (PDF) Shortcut Function Shortcut Function ALT+BREAK Cancel a query CTRL+SHIFT+F2 Clear all bookmarks ALT+F1 Database object information CTRL+SHIFT+INSERT Insert a template ALT+F4 Exit CTRL+SHIFT+L Make selection lowercase CTRL+A Select all CTRL+SHIFT+M Replace template parameters CTRL+B Move the splitter CTRL+SHIFT+P Open CTRL+C Copy CTRL+SHIFT+R Remove comment CTRL+D Display results in grid format CTRL+SHIFT+S Show client statistics CTRL+Delete Delete through the end of the line CTRL+SHIFT+T Show server trace CTRL+E Execute query CTRL+SHIFT+U Make selection uppercase CTRL+F Find CTRL+T Display results in text format CTRL+F2 Insert/remove bookmark CTRL+U Change database CTRL+F4 Disconnect CTRL+V Paste CTRL+F5 Parse query and check... - [SQL SERVER - Query to find number Rows, Columns, ByteSize for each table in the current database - Find Biggest Table in Database](https://blog.sqlauthority.com/2007/01/10/sql-server-query-to-find-number-rows-columns-bytesize-for-each-table-in-the-current-database-find-biggest-table-in-database/): USE DatabaseName GO CREATE TABLE #temp ( table_name sysname , row_count INT, reserved_size VARCHAR(50), data_size VARCHAR(50), index_size VARCHAR(50), unused_size VARCHAR(50)) SET NOCOUNT ON INSERT #temp EXEC sp_msforeachtable 'sp_spaceused ''?''' SELECT a.table_name, a.row_count, COUNT(*) AS col_count, a.data_size FROM #temp a INNER JOIN information_schema.columns b ON a.table_name collate database_default = b.table_name collate database_default GROUP BY a.table_name, a.row_count, a.data_size ORDER BY CAST(REPLACE(a.data_size, ' KB', '') AS integer) DESC DROP TABLE #temp Reference: Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Simple Example of Cursor](https://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/): UPDATE: For working example using AdventureWorks visit : SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2 This is the simplest example of the SQL Server Cursor. I have used this all the time for any use of Cursor in my T-SQL. DECLARE @AccountID INT DECLARE @getAccountID CURSOR SET @getAccountID = CURSOR FOR SELECT Account_ID FROM Accounts OPEN @getAccountID FETCH NEXT FROM @getAccountID INTO @AccountID WHILE @@FETCH_STATUS = 0 BEGIN PRINT @AccountID FETCH NEXT FROM @getAccountID INTO @AccountID END CLOSE @getAccountID DEALLOCATE @getAccountID Reference: Pinal Dave (http://www.SQLAuthority.com), BOL - [SQL SERVER - Shrinking Truncate Log File - Log Full](https://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/): UPDATE: Please follow link for SQL SERVER – SHRINKFILE and TRUNCATE Log File in SQL Server 2008. Sometime, it looks impossible to shrink the Truncated Log file. Following code always shrinks the Truncated Log File to minimum size possible. USE DatabaseName GO DBCC SHRINKFILE(<TransactionLogName>, 1) BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY DBCC SHRINKFILE(<TransactionLogName>, 1) GO [Update: Please note, there are much more to this subject, read my more recent blogs. This breaks the chain of the logs and in future you will not be able to restore point in time. If you have followed this advise, you are recommended to take full... - [SQL SERVER - Fix : Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved.](https://blog.sqlauthority.com/2006/12/20/sql-server-fix-error-14274-cannot-add-update-or-delete-a-job-or-its-steps-or-schedules-that-originated-from-an-msx-server-the-job-was-not-saved/): To fix the error which occurs after the Windows server name been changed, when trying to update or delete the jobs previously created in a SQL Server 2000 instance, or attaching msdb database. Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved. Reason: SQL Server 2000 supports multi-instances, the originating_server field contains the instance name in the format ‘server\instance’. Even for the default instance of the server, the actual server name is used instead of ‘(local)’. Therefore, after the Windows server is renamed, these jobs... - [SQL SERVER - Find Stored Procedure Related to Table in Database - Search in All Stored Procedure](https://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/): Following code will help to find all the Stored Procedures (SP) which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results. ----Option 1 SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so ON sc.id=so.id WHERE sc.TEXT LIKE '%tablename%' ----Option 2 SELECT DISTINCT o.name, o.xtype FROM syscomments c INNER JOIN sysobjects o ON c.id=o.id WHERE c.TEXT LIKE '%tablename%' Reference : Pinal Dave (http://www.SQLAuthority.com) - [SQL SERVER - Cursor to Kill All Process in Database](https://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/): When you run the script please make sure that you run it in different database then the one you want all the processes to be killed. CREATE TABLE #TmpWho (spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150), hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150)) INSERT INTO #TmpWho EXEC sp_who DECLARE @spid INT DECLARE @tString VARCHAR(15) DECLARE @getspid CURSOR SET @getspid =   CURSOR FOR SELECT spid FROM #TmpWho WHERE dbname = 'mydb'OPEN @getspid FETCH NEXT FROM @getspid INTO @spid WHILE @@FETCH_STATUS = 0 BEGIN SET @tString = 'KILL ' + CAST(@spid AS VARCHAR(5)) EXEC(@tString) FETCH NEXT FROM @getspid INTO @spid END CLOSE @getspid DEALLOCATE @getspid DROP TABLE #TmpWho... - [SQL SERVER - Simple Cursor to Select Tables in Database with Static Prefix and Date Created](https://blog.sqlauthority.com/2006/11/30/sql-server-cursor-to-process-tables-in-database-with-static-prefix-and-date-created/): Following cursor query runs through the database and find all the table with certain prefixed ('b_','delete_'). It also checks if the Table is more than certain days old or created before certain days, it will delete it. We can have any other operation on that table like to delete, print or index. - [SQL SERVER - Auto Generate Script to Delete Deprecated Fields in Current Database](https://blog.sqlauthority.com/2006/11/20/sql-server-auto-generate-script-to-delete-deprecated-fields-in-current-database/): I always mark fields to be deprecated with “dep_” as prefix. In this way, after few days, when I am sure that I do not need the field any more I run the query to auto generate the deprecation script. The script also checks for any constraint in the system and auto generate the script to drop it also. SELECT 'ALTER TABLE ['+po.name+'] DROP CONSTRAINT [' + so.name + ']' FROM sysobjects so INNER JOIN sysconstraints sc ON so.id = sc.constid INNER JOIN syscolumns col ON sc.colid = col.colid AND so.parent_obj = col.id AND col.name LIKE 'dep[_]%' INNER JOIN sysobjects po ON so.parent_obj = po.id WHERE so.xtype = 'D' ORDER BY po.name, col.name SELECT... - [SQL SERVER - Query to Find ByteSize of All the Tables in Database](https://blog.sqlauthority.com/2006/11/10/sql-server-query-to-find-byte-size/): SELECT CASE WHEN (GROUPING(sob.name)=1) THEN 'All_Tables'    ELSE ISNULL(sob.name, 'unknown') END AS Table_name,    SUM(sys.length) AS Byte_Length FROM sysobjects sob, syscolumns sys WHERE sob.xtype='u' AND sys.id=sob.id GROUP BY sob.name WITH CUBE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database](https://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/): UPDATE : SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database This is very long query. Optionally, we can limit the query to return results for one or more than one table. SELECT K_Table = FK.TABLE_NAME, FK_Column = CU.COLUMN_NAME, PK_Table = PK.TABLE_NAME, PK_Column = PT.COLUMN_NAME, Constraint_Name = C.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME INNER JOIN ( SELECT i1.TABLE_NAME, i2.COLUMN_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1 INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME WHERE i1.CONSTRAINT_TYPE = 'PRIMARY KEY' ) PT ON PT.TABLE_NAME = PK.TABLE_NAME ---- optional: ORDER BY 1,2,3,4 WHERE PK.TABLE_NAME='something'WHERE FK.TABLE_NAME='something'... - [SQL SERVER - 2008 - Server Consolidation WhitePaper Download](https://blog.sqlauthority.com/2007/10/28/sql-server-2008-server-consolidation-whitepaper-download/): Server Consolidation with SQL Server 2008 Writer: Martin Ellis Reviewer: Prem Mehra,Lindsey Allen, Tiffany Wissner, Sambit Samal Published: March 2009 Microsoft SQL Server 2008 supports multiple options for server consolidation, which provides organizations with the flexibility to choose the consolidation approach that best meets their requirements to centralize data services management and reduce hardware and maintenance costs. By providing centralized management, auditing, and monitoring capabilities, SQL Server 2008 makes it easy to manage multiple databases and data services, which significantly reduces administrative overheads in large enterprises. Finally, SQL Server 2008 provides the reassurance of industry-leading performance and scalability, and unprecedented control... - [SQL SERVER - 2005 - Get Current User - Get Logged In User](https://blog.sqlauthority.com/2007/10/27/sql-server-2005-get-current-user-get-logged-in-user/): Interesting enough Jr. DBA asked me how he can get current user for any particular query is ran. He said he wants it for debugging purpose as well for security purpose. I totally understand the need of this request. Knowing the current user can be extremely helpful in terms of security. To get current user run following script in Query Editor SELECT SYSTEM_USER SYSTEM_USER will return current user. From Book On-Line – SYSTEM_USER returns the name of the currently executing context. If the EXECUTE AS statement has been used to switch context, SYSTEM_USER returns the name of the impersonated context. Reference... - [SQL SERVER - Deterministic Functions and Nondeterministic Functions](https://blog.sqlauthority.com/2007/10/26/sql-server-deterministic-functions-and-nondeterministic-functions/): Deterministic functions always returns the same output result all the time it is executed for same input values. i.e. ABS, DATEDIFF, ISNULL etc. Nondeterministic functions may return different results each time they are executed. i.e. NEWID, RAND, @@CPU_BUSY etc. Functions that call extended stored procedures are nondeterministic. User-defined functions that create side effects on the database are not recommended. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Forced Parameterization and Simple Parameterization - T-SQL and SSMS](https://blog.sqlauthority.com/2007/10/25/sql-server-2005-forced-parameterization-and-simple-parameterization-t-sql-and-ssms/): SQL Server compiles query and saves the procedures cache plans in the database. When the same query is called it uses compiled execution plan which improves the performance by saving compilation time. Queries which are parametrized requires less recompilation and dynamically built queries needs compilations and recompilation very frequently. Forced parameterization may improve the performance of certain databases by reducing the frequency of query compilations and recompilations. Database which has high volumes of the queries can be most benefited from this feature. When the PARAMETERIZATION option is set to FORCED, any literal value that appears in a SELECT, INSERT, UPDATE or... - [SQL SERVER - Simple Example of WHILE Loop With CONTINUE and BREAK Keywords](https://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/): I have tried to explain the usage of simple WHILE loop in the first example. BREAK keywords will exit the stop the while loop and control is moved. - [SQL SERVER - Get Permissions of My Username / Userlogin on Server / Database](https://blog.sqlauthority.com/2007/10/23/sql-server-get-permissions-of-my-username-userlogin-on-server-database/): A few days ago, I was invited to one of the largest database company. I was asked to review database schema and propose changes to it. There was special username or user logic was created for me, so I can review their database. I was very much interested to know what kind of permissions I was assigned per server level and database level. I did not feel like asking their Sr. DBA the question about permissions. - [SQL SERVER - Difference Between @@Version and xp_msver - Retrieve SQL Server Information](https://blog.sqlauthority.com/2007/10/22/sql-server-difference-between-version-and-xp_msver-retrieve-sql-server-information/): Just a day ago, I was asked which SQL Server version I am using. I said SQL Server 2005. However, the person I was talking was looking for more information then that. He requested more detail about the version. I responded with SQL Server 2005 Service Pack 2. After the discussion was over I thought there must be some global variable which brings back this information. I took guess and typed following command in SQL Query Editor SELECT @@Version 'SQL Version' I was really glad when it worked and returned following result. Resultset: Microsoft SQL Server 2005 – 9.00.3054.00 (Intel X86)... - [SQL SERVER - 2005 - Limitation of Online Index Rebuld Operation](https://blog.sqlauthority.com/2007/10/21/sql-server-2005-limitation-of-online-index-rebuld-operation/): Just a day ago, during one interview question of Online Indexing come up. I really enjoy discussing this issue as I was talking with candidate who was very smart. Following two questions were discussed. 1) What is Online Index Rebuild Operation? Online operation means when online operations are happening the database are in normal operational condition, the processes which are participating in online operations does not require exclusive access to database. Read about this in-depth in my previous article SQL SERVER – 2005 – Explanation and Script for Online Index Operations – Create, Rebuild, Drop 2) What are the limitation of... - [SQL SERVER - Set Server Level FILLFACTOR Using T-SQL Script](https://blog.sqlauthority.com/2007/10/20/sql-server-set-server-level-fillfactor-using-t-sql-script/): As the title is very clear what this post is about I will not write long description. I have listed definition of FILLFACTOR from BOL here. - [SQL SERVER - Types of DBCC Commands When Used as Database Console Commands](https://blog.sqlauthority.com/2007/10/19/sql-server-types-of-dbcc-commands-when-used-as-database-console-commands/): Just a day ago, while discussing some SQL issues with one of the Sr. Database Administrator in India, we end up discussing DBCC as Database Console Commands when used as T-SQL. We both tried to remember what are the types of DBCC as Database Console Commands and could not come up with more than two types, however we both knew there are four. When the conversation was over, I looked up MSDN for the types of the DBCC. I found following documentation here. There are four types of the Database Console Commands. Maintenance Maintenance tasks on a database, index, or filegroup.... - [SQL SERVER - 2005 - Fix : Error : Msg 7411, Level 16, State 1 Server is not configured for RPC](https://blog.sqlauthority.com/2007/10/18/sql-server-2005-fix-error-msg-7411-level-16-state-1-server-is-not-configured-for-rpc/): Error : Msg 7411, Level 16, State 1 Server is not configured for RPC This was annoying error which was fixed by Jr. DBA, whom I am personally training at my organization. I think he is going to be great programmer. He worked in my organization for more than 8 months. I finally have decided to coach him myself. When I encountered this error, I gave him task to figure this out himself. I absolutely gave him no direction and very few min to fix this problem. As you might have guessed without using internet help (as there is no help... - [SQLAuthority News - Book Review - Backup & Recovery (Paperback)](https://blog.sqlauthority.com/2007/10/17/sqlauthority-news-book-review-backup-recovery-paperback/): Backup & Recovery [ILLUSTRATED] (Paperback) by W. Curtis Preston (Author) Link to Amazon Short Summary: This book’s does not only teaches you have to create safe backup but it takes you to the next level where a large organization can save tons of dollars a year by making their backup and restore faster and more reliable process. Detail Summary: Backup and Recovery is the most interesting subject to me. I have always enjoyed reading and writing about this subject. I personally believe that without proper backup and ability to restore the backup to recover the system to original state, any organization... - [SQL SERVER - Three T-SQL Script to Create Primary Keys on Table](https://blog.sqlauthority.com/2007/10/16/sql-server-three-t-sql-script-to-create-primary-keys-on-table/): I have always enjoyed writing about three topics Constraint and Keys, Backup and Restore and Datetime Functions. Primary Keys constraints prevents duplicate values for columns and provides unique identifier to each column, as well it creates clustered index on the columns. -- Primary Key Constraint upon Table Created Method 1 USE AdventureWorks GO CREATE TABLE ConstraintTable (ID INT CONSTRAINT Ct_ID PRIMARY KEY, ColSecond INT) GO --Clean Up DROP TABLE ConstraintTable GO -- Primary Key Constraint upon Table Created Method 2 USE AdventureWorks GO CREATE TABLE ConstraintTable (ID INT, ColSecond INT, CONSTRAINT Ct_ID PRIMARY KEY (ID)) GO --Clean Up DROP TABLE ConstraintTable... - [SQL SERVER - 2005 - Driver for PHP Community Technology Preview (October 2007)](https://blog.sqlauthority.com/2007/10/16/sql-server-2005-driver-for-php-community-technology-preview-october-2007/): In its continued commitment to interoperability, Microsoft has released a new SQL Server 2005 Driver for PHP. The SQL Server 2005 Driver for PHP Community Technology Preview (CTP) download is available to all SQL Server users at no additional charge. The SQL Server 2005 Driver for PHP is a PHP 5 extension that allows for the reading and writing of SQL Server data from within PHP scripts. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2000. How to install driver 1. Download sqlsrv-for-php_version_language.exe to a temporary directory. 2. Run sqlsrv-for-php_version_language.exe.... - [SQL SERVER - Explanation and Understanding NOT NULL Constraint](https://blog.sqlauthority.com/2007/10/15/sql-server-explanation-and-understanding-not-null-constraint/): NOT NULL is integrity CONSTRAINT. It does not allow creating of the row where column contains NULL value. Most discussed question about NULL is what is NULL? I will not go in depth analysis it. Simply put NULL is unknown or missing data. When NULL is present in database columns, it can affect the integrity of the database. I really do not prefer NULL in database unless they are absolutely necessary. (Please make sure it is just my preference, and I use NULL it is absolutely needed). To prevent nulls to be inserted in the database, table should have NOT NULL... - [SQL SERVER - Three Rules to Use UNION](https://blog.sqlauthority.com/2007/10/14/sql-server-three-rules-to-use-union/): I have previously written two articles on UNION and they are quite popular. I was reading SQL book Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes By Ben Forta and I came across three rules of UNION and I felt like mentioning them here. UNION RULES A UNION must be composed of two or more SELECT statements, each separated by the keyword UNION. Each query in a UNION must contain the same columns, expressions, or aggregate functions, and they must be listed in the same order. Column datatypes must be compatible: They need not be the same exact same... - [SQL SERVER - 2005 - SQL Server Surface Area Configuration Tool Examples and Explanation](https://blog.sqlauthority.com/2007/10/13/sql-server-2005-sql-server-surface-area-configuration-tool-examples-and-explanation/): Microsoft has turned off all the potential features of SQL Server 2005 that could be susceptible to security risks and hacker attacks. Many features of SQL Server 2005 i.e. xp_cmdshell, DAC etc comes disabled by default, this makes the vulnerable surface area less visible to potential attacks. The Surface Area Configuration tool provides DBAs with a single, easy-to-use method of configuring external security of SQL Server. Use SQL Server Surface Area Configuration to enable, disable, start, or stop the features, services, and remote connectivity of your SQL Server 2005 installations. You can use SQL Server Surface Area Configuration on local and... - [SQL SERVER - Pre-Code Review Tips - Tips For Enforcing Coding Standards](https://blog.sqlauthority.com/2007/10/12/sql-server-pre-code-review-tips-tips-for-enforcing-coding-standards/): Each organization has its own coding standards and enforcement rules. It is sometime difficult for DBAs to change the code following code review, as it may affect many different layers of the application. In large organizations, many stored procedures are written and modified every day. It is smart to keep watch on all stored procedures, at frequent intervals, before code comes to final code review. Pre-code reviewing in this manner will save lots of time. I run a few scripts every day to check the status of all the stored procedures on our development server. Doing so gives me a good... - [SQL SERVER - T-SQL Script to Add Clustered Primary Key](https://blog.sqlauthority.com/2007/10/11/sql-server-t-sql-script-to-add-clustered-primary-key/): Jr. DBA asked me three times in a day, how to create Clustered Primary Key. I gave him following sample example. That was the last time he asked “How to create Clustered Primary Key to table?” USE [AdventureWorks] GO ALTER TABLE [Sales].[Individual] ADD CONSTRAINT [PK_Individual_CustomerID] PRIMARY KEY CLUSTERED ( [CustomerID] ASC ) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF vs. Stored Procedures and Having vs. WHERE](https://blog.sqlauthority.com/2007/10/10/sql-server-udf-vs-stored-procedures-and-having-vs-where/): Read my First Article in SQL Server Magazine – Oct 2007 [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Sample Example of RANKING Functions - ROW_NUMBER, RANK, DENSE_RANK, NTILE](https://blog.sqlauthority.com/2007/10/09/sql-server-2005-sample-example-of-ranking-functions-row_number-rank-dense_rank-ntile/): I have not written about this subject for long time, as I strongly believe that Book On Line explains this concept very well. SQL Server 2005 has total of 4 ranking function. Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. ROW_NUMBER () OVER ([<partition_by_clause>] <order_by_clause>) Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. RANK () OVER ([<partition_by_clause>] <order_by_clause>) Returns the rank of each row within the partition of a result set. DENSE_RANK () OVER ([<partition_by_clause>]... - [SQL SERVER - 2005 - Connection Property of SQL Server Management Studio SSMS](https://blog.sqlauthority.com/2007/10/08/sql-server-2005-connection-property-of-sql-server-management-studio-ssms/): Following images quickly explain how to connect to SQL Server with different connection property. It can be useful when connection properties need to be changed for SQL Server when connected. I use this in my company when I connect to one of our servers using named pipes instead of TCP/IP. Let us learn about Connection Property of SQL Server Management Studio SSMS. - [SQLAuthority News - Latest Interesting Downloads and Articles](https://blog.sqlauthority.com/2007/10/07/sqlauthority-news-latest-interesting-downloads-and-articles/): White Paper: Precision Considerations for Analysis Services Users This white paper covers accuracy and precision considerations in SQL Server 2005 Analysis Services. For example, it is possible to query Analysis Services with similar queries and obtain two different answers. While this appears to be a bug, it actually is due to the fact that Analysis Services caches query results and the imprecision that is associated with approximate data types. This white paper discusses how these issues manifest themselves, why they occur, and best practices to minimize their effect. Microsoft SQL Server 2005 JDBC Driver 1.1 In its continued commitment to interoperability,... - [SQL SERVER - Executing Remote Stored Procedure - Calling Stored Procedure on Linked Server](https://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure-calling-stored-procedure-on-linked-server/): I was going through comments on various posts to see if I have missed to answer any comments. I realized that there are quite a few times I have answered question which discuss about how to call stored procedure or query on linked server or another server. This is very detailed topic, I will keep it very simple. I am making assumptions that remote server is already set up as linked server with proper permissions in application and network is arranged. Method 1 : Remote Stored Procedure can be called as four part name: Syntax: EXEC [RemoteServer] .DatabaseName.DatabaseOwner.StoredProcedureName ‘Params’ Example: EXEC... - [SQL SERVER - 2005 - Open SSMS From Command Prompt - sqlwb.exe Example](https://blog.sqlauthority.com/2007/10/05/sql-server-2005-open-ssms-from-command-prompt-sqlwbexe-example/): This article is written by request and suggestion of Sr. Web Developer at my organization. Due to nature of this article most of the content are referred from Book On-Line. sqlwb command prompt utility which opens SQL Server Management Studio. sqlwb command does not run queries from command prompt. sqlcmd utility runs queries from command prompt, read for more information. The syntax of this sqlwb is very simple. I will copy complete syntax from BOL here : sqlwb [scriptfile] [projectfile] [solutionfile] [-S servername] [-d databasename] [-U username] [-P password] [-E] [-nosplash] [-?] I use following script very frequently. 1) Open SQL... - [SQL SERVER - 2005 - Different Types of Cache Objects](https://blog.sqlauthority.com/2007/10/04/sql-server-2005-different-types-of-cache-objects/): About two months ago I reviewed book SQL Server 2005 Practical Troubleshooting: The Database Engine. Yesterday I received a request from reader, if I can write something from this book, which is not common knowledge in DBA community. I really like the idea, however I must respect the Authors copyright about this book. This book is unorthodox SQL book, it talks about things which can get you to fix your problem faster, if problem is discussed in book. There are few places it teaches behind the scene SQL stories. - [SQL SERVER - 2005 - Explanation of TRY…CATCH and ERROR Handling With RAISEERROR Function](https://blog.sqlauthority.com/2007/10/03/sql-server-2005-explanation-of-trycatch-and-error-handling-with-raiseerror-function/): One of the developer at my company thought that we can not use RAISEERROR function in new feature of SQL Server 2005 TRY…CATCH. When asked for explanation he suggested SQL SERVER – 2005 Explanation of TRY…CATCH and ERROR Handling article as excuse suggesting that I did not give example of RAISEERROR with TRY…CATCH. We all thought it was funny. Just to keep record straight, TRY…CATCH can sure use RAISEERROR function. First read original article for additional information about how TRY…CATCH works with ERROR codes. SQL SERVER – 2005 Explanation of TRY…CATCH and ERROR Handling Example 1 : Simple TRY…CATCH without RAISEERROR... - [SQL SERVER - Find Name of The SQL Server Instance](https://blog.sqlauthority.com/2007/10/02/sql-server-find-name-of-the-sql-server-instance/): Few days ago, there was complex condition when we had one database on two different server. We were migrating database from one server to another server using nightly backup and restore. Based on database server stored procedures has to run different logic. We came up with two different solutions. 1) When database schema is very much changed, we wrote completely new stored procedure and deprecated older version once it was not needed. 2) When logic depended on Server Name we used global variable @@SERVERNAME. It was very convenient while writing migrating script which depended on server name for the same database.... - [SQL SERVER - 2005 - OUTPUT Clause Example and Explanation with INSERT, UPDATE, DELETE](https://blog.sqlauthority.com/2007/10/01/sql-server-2005-output-clause-example-and-explanation-with-insert-update-delete/): SQL Server 2005 has new OUTPUT clause, which is quite useful. OUTPUT clause has accesses to inserted and deleted tables (virtual tables) just like triggers. OUTPUT clause can be used to return values to client clause. OUTPUT clause can be used with INSERT, UPDATE, or DELETE to identify the actual rows affected by these statements. OUTPUT clause can generate table variable, a permanent table, or temporary table. Even though, @@Identity will still work in SQL Server 2005, however I find OUTPUT clause very easy and powerful to use. Let us understand OUTPUT clause using example. ———————————————————————————————————————— —-Example 1 : OUTPUT clause... - [SQL SERVER - 2005 Query Editor - Microsoft SQL Server Management Studio](https://blog.sqlauthority.com/2007/09/30/sql-server-2005-query-editor-microsoft-sql-server-management-studio/): This post may be very simple for most of the users of SQL Server 2005. Earlier this year, I have received one question many times – Where is Query Analyzer in SQL Server 2005? I wrote small post about it and pointed many users to that post – SQL SERVER – 2005 Query Analyzer – Microsoft SQL SERVER Management Studio. Recently I have been receiving similar question. Where is Query Editor in SQL Server 2005? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). I have been pointing my users to my... - [SQL SERVER - Two Connections Related Global Variables Explained - @@CONNECTIONS and @@MAX_CONNECTIONS](https://blog.sqlauthority.com/2007/09/29/sql-server-two-connections-related-global-variables-explained-connections-and-max_connections/): Few days ago, I was searching MSDN and I stumbled upon following two global variables. Following variables are very briefly explained in the BOL. I have taken their definition from BOL and modified BOL example to displayed both the global variable together. @@CONNECTIONS Returns the number of attempted connections, either successful or unsuccessful since SQL Server was last started. @@MAX_CONNECTIONS Returns the maximum number of simultaneous user connections allowed on an instance of SQL Server. The number returned is not necessarily the number currently configured. @@MAX_CONNECTIONS is the maximum number of connections allowed simultaneously to the server. @@CONNECTIONS is incremented with... - [SQL SERVER - Introduction and Example for DATEFORMAT Command](https://blog.sqlauthority.com/2007/09/28/sql-server-introduction-and-example-for-dateformat-command/): While doing surprise code review of Jr. DBA I found interesting syntax DATEFORMAT. This keywords is very less used as CONVERT and CAST can do much more than this command. It is still interesting to learn about learn about this new syntax. Sets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data. This command allows you to input strings that would normally not be recognized by SQL server as dates. The SET DATEFORMAT command lets you specify order of data parts. The options for DATEFORMAT are mdy, dmy, ymd, ydm, myd, or dym. The default DATEFORMAT is mdy.... - [SQL SERVER - FIX : Error 3154: The backup set holds a backup of a database other than the existing database](https://blog.sqlauthority.com/2007/09/27/sql-server-fix-error-3154-the-backup-set-holds-a-backup-of-a-database-other-than-the-existing-database/): Our Jr. DBA ran to me with this error just a few days ago while restoring the database. Error 3154: The backup set holds a backup of a database other than the existing database. Solution is very simple and not as difficult as he was thinking. He was trying to restore the database on another existing active database. Fix/WorkAround/Solution: 1) Use WITH REPLACE while using the RESTORE command. View Example 2) Delete the older database which is conflicting and restore again using RESTORE command. I understand my solution is little different than BOL but I use it to fix my database... - [SQLAuthority News - Book Review - Programming SQL Server 2005 [ILLUSTRATED]](https://blog.sqlauthority.com/2007/09/26/sqlauthority-news-book-review-programming-sql-server-2005-illustrated/): Programming SQL Server 2005 [ILLUSTRATED] (Paperback) by Bill Hamilton (Author) Link to Amazon User does not have to be experience SQL Server 2005 programmer to use this book; as it is designed for users of all levels. This book also suggests that user does not have to be experienced with SQL Server 2000. However, I disagree with that. This book only covers new features of SQL Server 2005. Understanding of fundamental relational database concepts is helpful to digest and accept the concepts introduced in this book. This book covers following perspective of SQL Server 2005 new features. Tools and utilities Data... - [SQL SERVER - Effect of TRANSACTION on Local Variable - After ROLLBACK and After COMMIT](https://blog.sqlauthority.com/2007/09/25/sql-server-effect-of-transaction-on-local-variable-after-rollback-and-after-commit/): Few days ago, one of the Jr. Developer asked me this question (What will be the Effect of TRANSACTION on Local Variable – After ROLLBACK and After COMMIT?) while I was rushing to an important meeting. I was getting late so I asked him to talk with his Application Tech Lead. When I came back from meeting both of them were looking for me. They said they are confused. I quickly wrote down following example for them. Example: PRINT 'After ROLLBACK example' DECLARE @FlagINT INT SET @FlagInt = 1 PRINT @FlagInt ---- @FlagInt Value will be 1 BEGIN TRANSACTION SET @FlagInt... - [SQL SERVER - Order of Result Set of SELECT Statement on Clustered Indexed Table When ORDER BY is Not Used](https://blog.sqlauthority.com/2007/09/24/sql-server-order-of-result-set-of-select-statement-on-clustered-indexed-table-when-order-by-is-not-used/): "What will be the order of the result set of a SELECT statement on clustered indexed table when the ORDER BY clause is not used?" - [SQL SERVER - Stored Procedure to Know Database Access Permission to Current User](https://blog.sqlauthority.com/2007/09/23/sql-server-stored-procedure-to-know-database-access-permission-to-current-user/): Jr. DBA in my company only have access to the database which they need to use. Often they try to access database and if they do not have permission they face error. Jr. DBAs always check which database they have access using following system stored procedure. It is very reliable and provides accurate information. Sytanx: EXEC sp_MShasdbaccess GO ResultSet: ( I have listed only one column) AdventureWorks AdventureWorksDW master model msdb MyDB ReportServer ReportServerTempDB tempdb Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Version Information and Additional Information - Extended Stored Procedure xp_msver](https://blog.sqlauthority.com/2007/09/22/sql-server-2005-version-information-and-additional-information-extended-stored-procedure-xp_msver/): I was glad when I discovered this Extended Stored Procedure myself. I always used different syntax to retrieve server information. Many of information I was looking up using system information of the windows operating system. Syntax: EXEC xp_msver ResultSet: Index Name Internal_Value Character_Value —— ——————————– ————– ————————————- 1 ProductName NULL Microsoft SQL Server 2 ProductVersion 589824 9.00.3042.00 3 Language 1033 English (United States) 4 Platform NULL NT INTEL X86 5 Comments NULL NT INTEL X86 6 CompanyName NULL Microsoft Corporation 7 FileDescription NULL SQL Server Windows NT 8 FileVersion NULL 2005.090.3042.00 9 InternalName NULL SQLSERVR 10 LegalCopyright NULL © Microsoft Corp.... - [SQL SERVER - 2005 - Multiple Language Support](https://blog.sqlauthority.com/2007/09/21/sql-server-2005-multiple-language-support/): SQL Server supports multiple languages. Information about all the languages are stored in sys.syslanguages system view. You can run following script in Query Editor and see all the information about each language. Information about Months and Days varies for each language. Syntax: SELECT Alias, * FROM sys.syslanguages ResultSet: (* results not included) Alias ————– English German French Japanese Danish Spanish Italian Dutch Norwegian Portuguese Finnish Swedish Czech Hungarian Polish Romanian Croatian Slovak Slovenian Greek Bulgarian Russian Turkish British English Estonian Latvian Lithuanian Brazilian Traditional Chinese Korean Simplified Chinese Arabic Thai Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - FIX : ERROR : 3260 An internal buffer has become full](https://blog.sqlauthority.com/2007/09/20/sql-server-fix-error-3260-an-internal-buffer-has-become-full/): ERROR : 3260 An internal buffer has become full The reason I have picked to write about this error is because we have encountered this error many times in one of our older server. Fix/WorkAround/Solution: We were not able to absolutely reduce this error but following changes helped. 1) Rebooted server if error is happening frequently. 2) Increased RAM to Server. 3) Increased RAM allocation to SQL Server application. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Rename Database to New Name Using Stored Procedure by Changing to Single User Mode](https://blog.sqlauthority.com/2007/09/19/sql-server-rename-database-to-new-name-using-stored-procedure-by-changing-to-single-user-mode/): In my organization we rename the database on development server when are refreshing the development server with live data. We save the old database with new name and restore the database from live with same name. If developer/Jr. DBA have not saved the SQL Script from development server, he/she can go back to old Server and retrieve the script. There are few interesting facts to note when the database is renamed. When renamed the database, filegroup name or filename (.mdf,.ldf) are not changed. User with SA privilege can rename the database with following script when the context of the database is... - [SQLAuthority News - Scale-Out Querying with Analysis Services Using SAN Snapshots](https://blog.sqlauthority.com/2007/09/18/sqlauthority-news-scale-out-querying-with-analysis-services-using-san-snapshots/): White paper describes the use of virtual copy Storage Area Network (SAN) snapshots in a load-balanced scalable querying environment for SQL Server 2005 Analysis Services. This architecture provides the following improvements Improves the utilization of disk resources Optimizes cube processing operations Supports dedicated snapshots for specific users at different points in time In selecting a snapshot implementation for use with for Analysis Services, users may wish to consider the following snapshot attributes: Provisioning of snapshots Writeability of snapshots Scalability of snapshots Performance of snapshots Efficiency of snapshots I have created this article here only to promote the original White Paper, which... - [SQL SERVER - UDF - Validate Positive Integer Function - Validate Natural Integer Function](https://blog.sqlauthority.com/2007/09/18/sql-server-udf-validate-positive-integer-function-validate-natural-integer-function/): Few days ago I wrote SQL SERVER – UDF – Validate Integer Function. It was very interesting to write this and developers at my company started to use it. One Jr. DBA modified this function to validate only positive integers. I will share this with everybody who are interested in similar functionality. Code: CREATE FUNCTION [dbo].[udf_IsNatural] ( @Number VARCHAR(100) ) RETURNS BIT BEGIN DECLARE @Ret BIT IF (PATINDEX('%[^0-9-]%', @Number) = 0 AND CHARINDEX('-', @Number) <= 1 AND @Number NOT IN ('.', '-', '+', '^') AND LEN(@Number)>0 AND @Number NOT LIKE '%-%') SET @Ret = 1 ELSE SET @Ret = 0 RETURN @Ret END GO... - [SQLAuthority News - NASDAQ Uses SQL Server 2005 - Reducing Costs through Better Data Management](https://blog.sqlauthority.com/2007/09/17/sqlauthority-news-nasdaq-uses-sql-server-2005-reducing-costs-through-better-data-management/): I just came across PDF published by Microsoft to promote SQL Server 2005. I find few things very interesting. I will list them here. NASDAQ - [SQL SERVER - Difference Between UPDATE and UPDATE()](https://blog.sqlauthority.com/2007/09/17/sql-server-difference-between-update-and-update/): What is the difference between UPDATE and UPDATE()? UPDATE is syntax used to update the database tables or database views. USE AdventureWorks ; GO UPDATE Production.Product SET ListPrice = ListPrice * 2; GO UPDATE() is used in triggers to check update/insert to the database tables or database views. Returns a Boolean value that indicates whether an INSERT or UPDATE attempt was made on a specified column of a table or view. UPDATE() is used anywhere inside the body of a Transact-SQL INSERT or UPDATE trigger to test whether the trigger should execute certain actions. USE AdventureWorks ; GO CREATE TRIGGER reminder... - [SQLAuthority News - Active Directory Integration Sample Script](https://blog.sqlauthority.com/2007/09/16/sqlauthority-news-active-directory-integration-sample-script/): A sample script that enables you to extract a list of computer names from your custom SQL Server database and add them to an Active Directory security group. The security group can then be referenced in the Agent Assignment and Failover Wizard to automate agent assignments to Management Servers. 1. Queries customer SQL asset database. 2. Populates custom security group with computer accounts of computers returned by the SQL query. Download from MSDN Abstract courtesy : Microsoft Reference :Pinal Dave (https://blog.sqlauthority.com), Text from MSDN - [SQL SERVER - 2005 - List All The Constraint of Database - Find Primary Key and Foreign Key Constraint in Database](https://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/): Following script are very useful to know all the constraint in the database. I use this many times to check the foreign key and primary key constraint in database. This is simple but useful script from my personal archive. USE AdventureWorks; GO SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint, SCHEMA_NAME(schema_id) AS SchemaName, OBJECT_NAME(parent_object_id) AS TableName, type_desc AS ConstraintType FROM sys.objects WHERE type_desc LIKE '%CONSTRAINT' GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Pro T-SQL 2005 Programmer's Guide (Paperback)](https://blog.sqlauthority.com/2007/09/15/sqlauthority-news-book-review-pro-t-sql-2005-programmers-guide-paperback/): Pro T-SQL 2005 Programmer’s Guide (Paperback) Book Review - [SQLAuthority News - Random Article from SQLAuthority Blog](https://blog.sqlauthority.com/2007/09/14/sqlauthority-news-random-article-from-sqlauthority-blog/): It has been wonderful writing on this blog. Many times I visit my older articles and read them. One of my favorite feature on WordPress.com (where I host my blog) is Random Article Feature. I use it quite often to land on random page on my blog. It is really good to read articles written previously because there are so many new things to learn as well keep previously learned knowledge refreshed. I have added link to random article in the side bar of this blog. User can click on it to visit random article as well click in the link... - [SQL SERVER - Difference Between EXEC and EXECUTE vs EXEC() - Use EXEC/EXECUTE for SP always](https://blog.sqlauthority.com/2007/09/13/sql-server-difference-between-exec-and-execute-vs-exec-use-execexecute-for-sp-always/): What is the difference between EXEC and EXECUTE? They are the same. Both of them executes stored procedure when called as EXEC sp_help GO EXECUTE sp_help GO I have seen enough times developer getting confused between EXEC and EXEC(). EXEC command executes stored procedure where as EXEC() function takes dynamic string as input and executes them. EXEC('EXEC sp_help') GO Another common mistakes I have seen is not using EXEC before stored procedure. It is always good practice to use EXEC before stored procedure name even though SQL Server assumes any command as stored procedure when it does not recognize the first... - [SQLAuthority News - Scrum: Agile Software Development for Project Management](https://blog.sqlauthority.com/2007/09/12/sqlauthority-news-scrum-agile-software-development-for-project-management/): This is something I have learned while working for so many years as Project Manager. It is not as important to know how things are done but it is important to know how to get things done. Scrum is an Agile Software Development system which helps developers to get project done in reasonable time and with superior quality. Scrum is organized around the following roles: Product Owner – Determines what functionality is needed ScrumMaster – Leads the Scrum and is primarily responsible for making sure the Scrum process is followed and removing impediments that keep the Team from working The Team... - [SQL SERVER - Frequency of SQL Server Reboot and Restart](https://blog.sqlauthority.com/2007/09/11/sql-server-frequency-of-sql-server-reboot-and-restart/): This is very interesting question. I will keep the answer of this question very simple. First of all there is no scientific research or white paper I can backup my results with. Answer contains part simple observation and part experience. There is no need to reboot SQL Server. Once it is on it is ON! However, I have heard that frequent reboot improves performance. In my company our network administration department has policy to reboot all the servers every 15 days. We reboot all the servers at every 15 days. Regarding performance improvement, our servers are always up and running as... - [SQLAuthority News - Book Review - SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills](https://blog.sqlauthority.com/2007/09/11/sqlauthority-news-book-review-sql-server-2005-dba-street-smarts-a-real-world-guide-to-sql-server-2005-certification-skills/): SQL Server 2005 DBA Street Smarts: A Real World Guide to SQL Server 2005 Certification Skills (Paperback) by Joseph L. Jorden Link to Amazon Short Review: Microsoft’s new generation of certifications is design not only to emphasize your proficiency with a specific technology but also to prove you have the skills needed to perform a specific role. This book is developed based on the exam objective of the 70-431, although its purpose is to server more as a reference than just an exam preparation book. Detail Review: This book is designed to give DBAs some insight into the world of typical... - [SQL SERVER - 2005 - White Paper - Integrating Visio 2007 and Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/09/10/sql-server-2005-white-paper-integrating-visio-2007-and-microsoft-sql-server-2005/): This article focuses on integration techniques specific to Microsoft Office Visio 2007 and Microsoft SQL Server 2005. Using Visio 2007, you can connect Visio shapes to data that was generated outside Visio. A large amount of data can be captured in a SQL Analysis Services database. Being able to analyze that data in a visual way enhances the value of the data. In the following example, sales data stored in an Analysis Services cube is used to generate a Visio PivotDiagram so that the data can be explored and graphically enhanced. View Integrating Visio 2007 and Microsoft SQL Server 2005 Reference... - [SQLAuthority News - Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide](https://blog.sqlauthority.com/2007/09/10/sqlauthority-news-job-opportunity-in-ahmedabad-india-to-work-with-technology-leaders-worldwide/): If you have one or more years of experience in any web based programming language (.NET, ColdFusion, PHP) and interested in SQL Server as well willing to locate Ahmadabad, India. Please send me your resume, if selected you may get chance to work with one of the most progressing industry in world as well some smartest technology leaders worldwide. Salary depends on Experience. If selected for interview I suggest you go over SQL Server Interview Questions and Answers Complete List Download, as there is great chance I may be participating in interview. Please send your resume at pinaldave “at” yahoo.com and... - [SQL SERVER - 2005 - Start Stop Restart SQL Server From Command Prompt](https://blog.sqlauthority.com/2007/09/09/sql-server-2005-start-stop-restart-sql-server-from-command-prompt/): Very frequently I use following command prompt script to start and stop default instance of SQL Server. Our network admin loves this commands as this is very easy. Click Start >> Run >> type cmd to start command prompt. Start default instance of SQL Server net start mssqlserver Stop default instance of SQL Server net stop mssqlserver Start and Stop default instance of SQL Server. You can create batch file to execute both the commands together. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - UDF - User Defined Function - Get Number of Days in Month](https://blog.sqlauthority.com/2007/09/08/sql-server-udf-user-defined-function-get-number-of-days-in-month/): Following User Defined Function (UDF) returns the numbers of days in month. It is very simple yet very powerful and full proof UDF. CREATE FUNCTION [dbo].[udf_GetNumDaysInMonth] ( @myDateTime DATETIME ) RETURNS INT AS BEGIN DECLARE @rtDate INT SET @rtDate = CASE WHEN MONTH(@myDateTime) IN (1, 3, 5, 7, 8, 10, 12) THEN 31 WHEN MONTH(@myDateTime) IN (4, 6, 9, 11) THEN 30 ELSE CASE WHEN (YEAR(@myDateTime) % 4 = 0 AND YEAR(@myDateTime) % 100 != 0) OR (YEAR(@myDateTime) % 400 = 0) THEN 29 ELSE 28 END END RETURN @rtDate END GO Run following script in Query Editor: SELECT dbo.udf_GetNumDaysInMonth(GETDATE()) NumDaysInMonth... - [SQL SERVER - Correlated and Noncorrelated - SubQuery Introduction, Explanation and Example](https://blog.sqlauthority.com/2007/09/07/sql-server-correlated-and-noncorrelated-subquery-introduction-explanation-and-example/): A correlated subquery is an inner subquery which is referenced by the main outer query such that the inner query is considered as being executed repeatedly. Example: ----Example of Correlated Subqueries USE AdventureWorks; GO SELECT e.EmployeeID FROM HumanResources.Employee e WHERE e.ContactID IN ( SELECT c.ContactID FROM Person.Contact c WHERE MONTH(c.ModifiedDate) = MONTH(e.ModifiedDate) ) GO A noncorrelated subquery is subquery that is independent of the outer query and it can executed on its own without relying on main outer query. Example: ----Example of Noncorrelated Subqueries USE AdventureWorks; GO SELECT e.EmployeeID FROM HumanResources.Employee e WHERE e.ContactID IN ( SELECT c.ContactID FROM Person.Contact c... - [SQL SERVER - 2005 - Introduction and Explanation to sqlcmd](https://blog.sqlauthority.com/2007/09/06/sql-server-2005-introduction-and-explanation-to-sqlcmd/): I decided to write this article to respond to request of one of usergroup, which requested that they would like to learn sqlcmd 101. SQL Server 2005 has introduced new utility sqlcmd to run ad hoc Transact-SQL statements and scripts from command prompt. T-SQL commands are entered in command prompt window and result is displayed in the same window, unless result set are sent to output files. sqlcmd can execute single T-SQL statement as well as batch file. sqlcmd utility can connect to earlier versions of SQL Server as well. The sqlcmd utility uses the OLE DB provider to execute T-SQL... - [SQLAuthority News - SQL SERVER 2008 CTP 4 Released](https://blog.sqlauthority.com/2007/09/06/sqlauthority-news-sql-server-2008-ctp-4-released/): SQL Server 2008 CTP 4 is released as a pre-configured VHD. This allows you to trial SQL Server 2008 CTP 4 in a virtual environment. Download SQL Server 2008 CTP 4 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Valid SQL Error](https://blog.sqlauthority.com/2007/09/05/sql-server-sql-joke-sql-humor-sql-laugh-valid-sql-error/): Yesterday I had posted my 300th post and I missed the announcement. One of my reader sent me following Image in email congratulating SQLAuthority blog for completing 300th post and also informing me that it has been long time I have posted something funny. I have written few articles about frequent SQL Server Errors on this blog. He suggested that this humorous images goes along with it. If you know source of this image please let me know I would like to include that. Visit more SQL Server Humors. Reference : Pinal Dave (https://blog.sqlauthority.com) , Need original reference for image. - [SQLAuthority News - Interesting Read - Using A SQL JOIN In A SQL UPDATE/Delete Statement - Ben Nadel](https://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/): As everybody know SQL is what I like most. Before I was into SQL Server, I was very much into ColdFusion. ColdFusion is still my most favorite programming language. I still program in ColdFusion, infect my personal website https://www.pinaldave.com/ is in ColdFusion. I regularly read ColdFusion blog and latest updates in ColdFusion. Recently at company where I work, we upgraded to ColdFusion 8 and .NET 2.0 (C# is our preferred language in .NET technology). Both of this languags work with SQL Server 2005 very well in my company. My favorite blog for ColdFusion technology is blog of BEN NADEL . Ben... - [SQL SERVER - 2005 - Find Tables With Primary Key Constraint in Database](https://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-primary-key-constraint-in-database/): My article SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key has received following question many times. I have deleted similar questions and kept only latest comment there. In SQL Server 2005 How to Find Tables With Primary Key Constraint in Database? Script to find all the primary key constraint in database: USE AdventureWorks; GO SELECT i.name AS IndexName, OBJECT_NAME(ic.OBJECT_ID) AS TableName, COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName FROM sys.indexes AS i INNER JOIN sys.index_columns AS ic ON i.OBJECT_ID = ic.OBJECT_ID AND i.index_id = ic.index_id WHERE i.is_primary_key = 1 In SQL Server 2005 How to Find Tables... - [SQL SERVER - 2005 - Find Tables With Foreign Key Constraint in Database](https://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/): While writing article based on my SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key I got an idea about writing this article. I was thinking if you can find primary key for any table in the database, you can sure find foreign key for any table in the database as well. - [SQL SERVER - 2005 - Search Stored Procedure Code - Search Stored Procedure Text](https://blog.sqlauthority.com/2007/09/03/sql-server-2005-search-stored-procedure-code-search-stored-procedure-text/): I receive following question many times by my team members. How can I find if particular table is being used in the stored procedure? How to search in stored procedures? How can I do dependency check for objects in stored procedure without using sp_depends? I have previously wrote article about this SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored procedure. The same feature can be implemented using following script in SQL Server 2005. USE AdventureWorks GO --Searching for Empoloyee table SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Employee%' GO --Searching for Empoloyee table... - [SQL SERVER - Fix : Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward](https://blog.sqlauthority.com/2007/09/02/sql-server-fix-error-msg-3117-level-16-state-4-the-log-or-differential-backup-cannot-be-restored-because-no-files-are-ready-to-rollforward/): Following error occurs when tried to restored the differential backup. Fix : Error : Msg 3117, Level 16, State 4 The log or differential backup cannot be restored because no files are ready to rollforward Fix/WorkAround/Solution: This error happens when Full back up is not restored before attempting to restore differential backup or full backup is restored with WITH RECOVERY option. Make sure database is not in operational conditional when differential backup is attempted to be restored. Example of restoring differential backup successfully after restoring full backup. RESTORE DATABASE AdventureWorks FROM DISK = 'C:\AdventureWorksFull.bak' WITH NORECOVERY; RESTORE DATABASE AdventureWorks FROM DISK... - [SQL SERVER - 2005 - Find Database Status Using sys.databases or DATABASEPROPERTYEX](https://blog.sqlauthority.com/2007/08/31/sql-server-2005-find-database-status-using-sysdatabases-or-databasepropertyex/): While writing article about database collation, I came across sys.databases and DATABASEPROPERTYEX. It was very interesting to me that this two can tell user so much about database properties. Following are main database status: (Reference: BOL Database Status) ONLINE Database is available for access. OFFLINE Database is unavailable. RESTORING One or more files of the primary filegroup are being restored, or one or more secondary files are being restored offline. RECOVERING Database is being recovered. RECOVERY PENDING SQL Server has encountered a resource-related error during recovery. SUSPECT At least the primary filegroup is suspect and may be damaged. EMERGENCY User has... - [SQL SERVER - 2005 - Find Database Collation Using T-SQL and SSMS](https://blog.sqlauthority.com/2007/08/30/sql-server-2005-find-database-collation-using-t-sql-and-ssms/): This article is written based on feedback I have received on SQL SERVER – Cannot resolve collation conflict for equal to operation. Many reader asked me how to find collation of current database. There are two different ways to find out SQL Server database collation. 1) Using T-SQL (My Recommendation) Run following Script in Query Editor SELECT DATABASEPROPERTYEX('AdventureWorks', 'Collation') SQLCollation; ResultSet: SQLCollation ———————————— SQL_Latin1_General_CP1_CI_AS 2) Using SQL Server Management Studio Refer the following two diagram to find out the SQL Collation. Write Click on Database Click on Properties Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Difference and Explanation among DECIMAL, FLOAT and NUMERIC](https://blog.sqlauthority.com/2007/08/29/sql-server-difference-and-explanation-among-decimal-float-and-numeric/): The basic difference between Decimal and Numeric : They are the exactly same. Same thing different name. The basic difference between Decimal/Numeric and Float : Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly. Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type reane can be represented exactly with precision and scale. Converting from Decimal or Numeric to float can cause some loss of precision. For the Decimal or Numeric data types, SQL Server considers each specific combination of precision and scale as a... - [SQL SERVER - Actual Execution Plan vs. Estimated Execution Plan](https://blog.sqlauthority.com/2007/08/28/sql-server-actual-execution-plan-vs-estimated-execution-plan/): I was recently invited to participate in big discussion on one of the online forum, the topic was Actual Execution Plan vs. Estimated Execution Plan. I refused to participate in that particular discussion as I have very simple but strong opinion about this topic. I always use Actual Execution Plan as it is accurate. Why not Estimated Execution Plan? It is not accurate. Sometime it is easier or useful to to know the plan without running query. I just run query and have correct and accurate Execution Plan. Shortcut for Display Estimated Execution Plan : CTRL + L Shortcut for Include... - [SQL SERVER - 2005 - Use Always Outer Join Clause instead of (*= and =*)](https://blog.sqlauthority.com/2007/08/27/sql-server-2005-use-always-outer-join-clause-instead-of-and/): Yesterday I wrote about how SQL Server 2005 does not support named pipes. Today, my friend called me asking some of his query does not work. I asked him to send me the queries. I asked him to send me query. I noticed in his queries something, I have never practiced before and I never had any issue therefore. Instead of using LEFT OUTER JOIN clause he was using *= and similarly instead of using RIGHT OUTER JOIN clause he was using =*. Once I replaced did necessary modification, queries run just fine. I wish I can give you example of... - [SQL SERVER - 2005 - No Backup Support For Named Pipes](https://blog.sqlauthority.com/2007/08/26/sql-server-2005-no-backup-support-for-named-pipes/): While helping one of my DBA friend (who works in big company in LA) to upgrade SQL Server 2000 to SQL Server 2005 I just found one thing, which I have not paid attention before. SQL Server 2000 supported named pipe backup device. SQL Server 2005 does not support named pipe backup device, however SQL Server 2005 supports disk and tape devices. I receive following question many times, I have answered this question earlier on this blog. I will still answer it again. What is my preferred method of backup? We use SAN with RAID 10 configuration. Some industry experts suggested... - [SQL SERVER - FIX : Error : msg 2540 - The system cannot self repair this error](https://blog.sqlauthority.com/2007/08/25/sql-server-fix-error-msg-2540-the-system-cannot-self-repair-this-error/): SQL SERVER – FIX : Error : msg 2540 – The system cannot self repair this error This is most annoying error. I have only faced this error twice so far. I solved this error restoring the database back up. Read here for additional help on SQL Backup And Restore. This error is occurs when database is in state when it can not be heal itself, i.e. corrupted metadata or corrupted important system database files. Fix/WorkAround/Solution: My prefered order to fix the problem. 1) Restored database from backup. 2) Run DBCC with repair option, which will not bring much favorable answer.... - [SQL SERVER - T-SQL Script to Attach and Detach Database](https://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/): Following script can be used to detach or attach the database. If the database is to be from one database to another database following script can be used to detach from old server and attach to a new server. Let us learn about how to Attach and Detach Database. - [SQL SERVER - 2005 - Use of Non-deterministic Function in UDF - Find Day Difference Between Any Date and Today](https://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/): While writing few articles about SQL Server DataTime I accidentally wrote User Defined Function (UDF), which I would have not wrote usually. Once I wrote this function, I did not find it very interesting and decided to discard it. However, I suddenly noticed use of Non-Deterministic function in the UDF. I always thought that use of Non-Deterministic function is prohibited in UDF. I even wrote about it earlier SQL SERVER – User Defined Functions (UDF) Limitations. It seems like SQL Server 2005 either have removed this restriction or it is bug. I think I will not say this is bug but... - [SQL SERVER - T-SQL Script to Insert Carriage Return and New Line Feed in Code](https://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/): Very simple and very effective. We use all the time for many reasons - formatting, while creating dynamically generated SQL to separate GO command from other T-SQL, saving some user input text to database etc. Let us learn about T-SQL Script to Insert Carriage Return and New Line Feed in Code. - [SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects](https://blog.sqlauthority.com/2007/08/21/sql-server-2005-create-script-to-copy-database-schema-and-all-the-objects-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/): Update: This article is re-written with SQL Server 2008 R2 instance over here: SQL SERVER – 2008 – 2008 R2 – Create Script to Copy Database Schema and All The Objects – Data, Schema, Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects Following quick tutorial demonstrates how to create T-SQL script to copy complete database schema and all of its objects such as Stored Procedure, Functions, Triggers, Tables, Views, Constraints etc. You can review your schema, backup for reference or use it to compare with previous backup. Step 1 : Start Step 2 : Welcome Screen Step... - [SQLAuthority News - Principles of Simplicity](https://blog.sqlauthority.com/2007/08/20/sqlauthority-news-principles-of-simplicity/): Yesterday I came across Principles of Simplicity by Mads Kristensen. I think this is good write up and I enjoyed reading it. This are very generic and applies to all programming language and databases applications. Principles of Simplicity by Mads Kristensen 1. Simplicity or not at all Some developers tend to over-complicate a task and ends up writing too many classes to solve a simple problem. 2. Don’t build submarines It’s a common fact that IT projects take longer than scheduled even if you schedule for delays. 3. Test when appropriate Testing is one very important factor of the development cycle... - [SQL SERVER - Find Monday of the Current Week](https://blog.sqlauthority.com/2007/08/20/sql-server-find-monday-of-the-current-week/): Very Simple Script which find Monday of the Current Week SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0) MondayOfCurrentWeek Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes](https://blog.sqlauthority.com/2007/08/19/sqlauthority-news-book-review-sams-teach-yourself-microsoft-sql-server-t-sql-in-10-minutes/): Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes (Sams Teach Yourself) by Ben Forta Link to Amazon Short Review: If T-SQL (Transact-Structured Query Language) is foreign tongue to you, after reading this book, you will speak T-SQL. This book is SQL Server version of best-selling book Sams Teach Yourself SQL in 10 Minutes. This book teaches what a SQL developer must know methodically, systematically, and exactly. Anybody who are new to SQL Server and wants to learn most of T-SQL which can be implemented in short time in their application – BUY this book immediately. Detail Review: This is... - [SQL SERVER - Find Last Day of Any Month - Current Previous Next](https://blog.sqlauthority.com/2007/08/18/sql-server-find-last-day-of-any-month-current-previous-next/): Few questions are always popular. They keep on coming up through email, comments or from co-workers. Finding Last Day of Any Month is similar question. I have received it many times and I enjoy answering it as well. I have answered this question twice before here: SQL SERVER – Script/Function to Find Last Day of Month SQL SERVER – Query to Find First and Last Day of Current Month Today, we will see the same solution again. Please use the method you find appropriate to your requirement. Following script demonstrates the script to find last day of previous, current and next... - [SQL SERVER - 2005 - Explanation and Script for Online Index Operations - Create, Rebuild, Drop](https://blog.sqlauthority.com/2007/08/17/sql-server-2005-explanation-and-script-for-online-index-operations-create-rebuild-drop/): SQL Server 2005 Enterprise Edition supports online index operations. Index operations are creating, rebuilding and dropping indexes. The question which I receive quite often – what is online operation? Is online operation is related to web, internet or local network? Online operation means when online operations are happening the database are in normal operational condition, the processes which are participating in online operations does not require exclusive access to database. In case of Online Indexing Operations, when Index operations (create, rebuild, dropping) are occuring they do not require exclusive access to database, they do not lock any database tables. This is... - [SQLAuthority News - Subscribed to SQLAuthority Emails](https://blog.sqlauthority.com/2007/08/16/sqlauthority-news-subscribed-to-sqlauthority-emails/): I have got many request about alert system when new post is published on this blog. I use feedburner email service, which sends email whenever new post is published on my blog. Many times, I update my post based on feedback from comments or news. If you want updated information, visit the blog. Subscribe to SQLAuthority.com Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Book On-Line Link - BOL](https://blog.sqlauthority.com/2007/08/16/sql-server-2008-book-on-line-link/): I am researching SQL Server. Those who are asking me questions about SQL Server 2008, please refer following link. I will post my tutorials and articles very soon. Books Online is commonly known as BOL. - [SQL SERVER - 2005 - Difference and Similarity Between NEWSEQUENTIALID() and NEWID()](https://blog.sqlauthority.com/2007/08/16/sql-server-2005-difference-and-similarity-between-newsequentialid-and-newid/): NEWSEQUENTIALID() and NEWID() both generates the GUID of datatype of uniqueidentifier. NEWID() generates the GUID in random order whereas NEWSEQUENTIALID() generates the GUID in sequential order. Let us see example first demonstrating both of the function. USE AdventureWorks; GO ----Create Test Table for with default columns values CREATE TABLE TestTable (NewIDCol uniqueidentifier DEFAULT NEWID(), NewSeqCol uniqueidentifier DEFAULT NewSequentialID()) ----Inserting five default values in table INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES INSERT INTO TestTable DEFAULT VALUES ----Test Table to see NewID() is random ----Test Table to see NewSequentialID()... - [SQL SERVER - Insert Data From One Table to Another Table - INSERT INTO SELECT - SELECT INTO TABLE](https://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table/): Following three questions are many times asked on this blog. How to insert data from one table to another table efficiently? How to insert data from one table using where condition to another table? How can I stop using cursor to move data from one table to another table? There are two different ways to implement inserting data from one table to another table. I strongly suggest to use either of the methods over the cursor. Performance of following two methods is far superior over the cursor. I prefer to use Method 1 always as I works in all the cases.... - [SQLAuthority News - Book Review - Learning SQL on SQL Server 2005 (Learning)](https://blog.sqlauthority.com/2007/08/14/sqlauthority-news-book-review-learning-sql-on-sql-server-2005-learning/): SQLAuthority.com Book Review : Learning SQL on SQL Server 2005 (Learning) [ILLUSTRATED] (Paperback) by Sikha Bagui, Richard Earp Link to book on Amazon Short Review: This books covers simple and complex concept in very easy language with lots of examples. Every beginner can learn a great amount of tips from experienced authors. Whether you are a self-learner, new to databases or in need of SQL refresher, this is good read. Detail Review: This book is written by two conceptual strong SQL Server Gurus. SQL Server is growing extremely popular in the area of high-performance data applications. It is very important to... - [SQL SERVER - What is SQL? How to pronounce SQL?](https://blog.sqlauthority.com/2007/08/14/sql-server-what-is-sql-how-to-pronounce-sql/): SQL is abbreviation of Structured Query Language. SQL is pronounced as S.Q.L. (ess-que-ell or ess-cue-ell) not sequel. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - Database Architecture and Implementation Discussion - New York, New Jersey Details](https://blog.sqlauthority.com/2007/08/13/sqlauthority-news-author-visit-database-architecture-and-implementation-discussion-new-york-new-jersey-details/): Last weekend I visited New York City (NY) and Edison (NJ) to attend database architecture meeting with a big environmental technology firm. It was very interesting to meet CEO and few of the lead database administrators. Lots of database related things were discussed. I will list few of the points discussed in the meeting here, due to privacy policy I will be not able to write many of the interesting details I have learned there. Please let me know if you are interested in any of the particular topic. I can elaborate more on the topic which interests everybody. 1) Database... - [SQL SERVER - Fix : ERROR : Msg 1033, Level 15, State 1 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.](https://blog.sqlauthority.com/2007/08/12/sql-server-fix-error-msg-1033-level-15-state-1-the-order-by-clause-is-invalid-in-views-inline-functions-derived-tables-subqueries-and-common-table-expressions-unless-top-or-for-xml-is-als/): Following error is encountered when view is attempted to created with ORDER BY clause in it. ORDER BY clause is not allowed in views in SQL Server 2005. This solution also displays the workaround to use ORDER BY in VIEW. I really do not prefer to use views. My views on SQL Views read it SQL SERVER – Restrictions of Views – T SQL View Limitations. Msg 1033, Level 15, State 1 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. This is error interested... - [SQL SERVER - UDF - Validate Integer Function](https://blog.sqlauthority.com/2007/08/11/sql-server-udf-validate-integer-function/): I received quite a good feedback about my post about SQL SERVER – Validate Field For DATE datatype using function ISDATE() One of the most interesting comment I received from my reader from Canada. I was suggested just like ISDATE() to write about ISNUMERIC() which can be used to validate numeric values. As per BOL: ISNUMERIC returns 1 when the input expression evaluates to a valid numeric data type; otherwise it returns 0. ISNUMERIC returns 1 for some characters that are not numbers, such as plus (+), minus (-), and valid currency symbols such as the dollar sign ($). Now this... - [SQL SERVER - 2005 - Find Stored Procedure Create Date and Modified Date](https://blog.sqlauthority.com/2007/08/10/sql-server-2005-find-stored-procedure-create-date-and-modified-date/): This post is second part of my previous post about SQL SERVER – 2005 – List All Stored Procedure Modified in Last N Days - [SQL SERVER - 2005 - List All The Column With Specific Data Types](https://blog.sqlauthority.com/2007/08/09/sql-server-2005-list-all-the-column-with-specific-data-types/): Since we upgraded to SQL Server 2005 from SQL Server 2000, we have used following script to find out columns with specific datatypes many times. It is very handy small script. SQL Server 2005 has new datatype of VARCHAR(MAX), we decided to change all our TEXT datatype columns to VARCHAR(MAX). The reason to do that as TEXT datatype will be deprecated in future version of SQL Server and VARCHAR(MAX) is superior to TEXT datatype in features. We run following script to identify all the columns which are TEXT datatype and developer converts them to VARCHAR(MAX) Script 1 : Simple script to... - [SQL SERVER - 2005 - SSMS - Enable Autogrowth Database Property](https://blog.sqlauthority.com/2007/08/08/sql-server-2005-ssms-enable-autogrowth-database-property/): We can use SSMS to Enable Autogrowth property of the Database. Right-click on Database click on Properties and click on Files. There will be column of Autogrowth, click on small box with three (…) dots. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List Tables in Database Without Primary Key](https://blog.sqlauthority.com/2007/08/07/sql-server-2005-list-tables-in-database-without-primary-key/): This is very simple but effective script. It list all the table without primary keys. USE DatabaseName; GO SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableName FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0 ORDER BY SchemaName, TableName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Fix: Error 2596 The repair statement was not processed. The database cannot be in read-only mode](https://blog.sqlauthority.com/2007/08/06/sql-server-fix-error-2596-the-repair-statement-was-not-processed-the-database-cannot-be-in-read-only-mode/): ERROR 2596 : The repair statement was not processed. The database cannot be in read-only mode. - [SQL SERVER - Stop SQL Server Immediately Using T-SQL](https://blog.sqlauthority.com/2007/08/05/sql-server-stop-sql-server-immediately-using-t-sql/): This question has came up many quite a few times with our development team as well as emails I have received about how to stop SQL Server immediately (due to accidentally ran t-sql, business logic or just need of to stop SQL Server using T-SQL). Answer is very simple, run following command in SQL Editor. SHUTDOWN If you want to shutdown the system without performing checkpoints in every database and without attempting to terminate all user processes use following command. SHUTDOWN WITH NOWAIT Server can be turned off using windows services as well. SHUTDOWN permissions are assigned to members of the... - [SQL SERVER - One Thing All DBA Must Know](https://blog.sqlauthority.com/2007/08/04/sql-server-one-thing-all-dba-must-know/): FULLY BACKUP DATABASE. Update : I posted this post with only line. However I received many comments and questions asking different questions related to it. I have compiled all of them and modified this post. Most asked Question : What is the best time when database should be backed up? Answer : When everything is running perfect. This is the time when backup should be taken because in troubled time this is the backup required to be restored. The best backup is when system was running PERFECT. Question : I am experienced DBA, what should be the frequency of backup when... - [SQLAuthority News - Download SQL Server 2005 Samples and Sample Databases](https://blog.sqlauthority.com/2007/08/04/sqlauthority-news-download-sql-server-2005-samples-and-sample-databases/): Microsoft has purchased GitHub, the world’s leading software development platform where more than 28 million developers learn, share and collaborate to create the future for 7.5 Billion dollars.  - [SQLAuthority News - Author Visit - Database Architecture and Implementation Discussion - New York, New Jersey](https://blog.sqlauthority.com/2007/08/04/sqlauthority-news-author-visit-database-architecture-and-implementation-discussion-new-york-new-jersey/): I will be traveling for next two days to New York and New Jersey for Database Architecture and Implementation Discussion with one of the largest software technology company. The major focus of this firm is environmental product analysis. I will be not able to answer any questions, comments and emails during next two days 8/5 Saturday and 8/6 Sunday. I will post all the interesting details (which I can disclose safely without violating privacy policy) once I am come back to my city – Las Vegas. I am looking forward to meet industry giants and prominent personalities for next two days.... - [SQL - What ACID stands in the Database? - Contest to Win 24 Amazon Gift Cards and Joes 2 Pros 2012 Kit](https://blog.sqlauthority.com/2013/07/15/sql-what-acid-stands-in-the-database-contest-to-win-24-amazon-gift-cards-and-joes-2-pros-2012-kit/): We love puzzles. One of the brain’s main task is to solve puzzles. Sometime puzzles are very complicated (e.g Solving Rubik Cube or Sodoku)  and sometimes the puzzles are very simple (multiplying 4 by 8 or finding the shortest route while driving). It is always to solve puzzle and it creates an experience which humans are not able to forget easily. The best puzzles are the one where one has to do multiple things to reach to the final goal. Let us do something similar today. We will have a contest where you can participate and win something interesting. Contest This contest... - [SQL SERVER - Drivers for PHP, JDBC, ODBC and OLE DB](https://blog.sqlauthority.com/2013/07/14/sql-server-drivers-for-php-jdbc-odbc-and-ole-db/): A driver is software that allows your computer to communicate with hardware, devices or other software. Without drivers, the software or hardware you connect to your computer will not work properly. Here is the list of the drivers which are available for SQL Server to connect from multiple applications and programming language. Microsoft JDBC Driver 4.0 for SQL Server The JDBC driver can access many of the features including database mirroring; the xml, user-defined, and large-value data types; and it supports the new “snapshot” transaction isolation. Microsoft Drivers for PHP for SQL Server The Microsoft Drivers for PHP for SQL Server... - [SQL SERVER - Weekly Series - Memory Lane - #037](https://blog.sqlauthority.com/2013/07/13/sql-server-weekly-series-memory-lane-037/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Convert Text to Numbers (Integer) – CAST and CONVERT If table column is VARCHAR and has all the numeric values in it, it can be retrieved as Integer using CAST or CONVERT function. List All Stored Procedure Modified in Last N Days If SQL Server... - [MySQL - Learning MySQL Online in 6 Hours - MySQL Fundamentals in 320 Minutes](https://blog.sqlauthority.com/2013/07/12/mysql-learning-mysql-online-in-6-hours-mysql-fundamentals-in-320-minutes/): MySQL is one of the most popular database language and I have been recently working with it a lot. Data have no barrier and every database have their own place. I have been working with MySQL for quite a while and just like SQL Server, I often find lots of people asking me if I have a tutorial which can teach them MySQL from the beginning. Here is the good news, I have written two different courses on MySQL Fundamentals, which is available online. The reason for writing two different courses was to keep the learning simple. Both of the courses... - [SQL - Agile Software Development Methodology vs Waterfall Software Development Methodology](https://blog.sqlauthority.com/2013/07/11/sql-agile-software-development-methodology-vs-waterfall-software-development-methodology/): If you are in the process of developing and creating software, a business, or product, the steps to get from point A – the idea – to point B – the finished product – can seem completely overwhelming.  You start brainstorming, you get a great idea and follow it, but if it doesn’t work out, you are back at the beginning, brainstorming.  It might feel like you are going nowhere, you don’t know which way to turn, and all you’d really like is a road map straight to success. Well, I can’t promise you a road map, but I can get... - [SQL SERVER - Need Your Feedback - Next Action Items in SQL in Sixty Seconds](https://blog.sqlauthority.com/2013/07/10/sql-server-need-your-feedback-next-action-items-in-sql-in-sixty-seconds/): SQL in Sixty Second series has been going on for over a year and we have over 50 videos. Here is one idea. I am planning to do a series on one topic in SQL in Sixty Seconds. I would like to gather your feedback about what should I create this series on. - [SQL - Download Database Cheat Sheet for MongoDB, NuoDB, MySQL for FREE](https://blog.sqlauthority.com/2013/07/09/sql-download-database-cheat-sheet-for-mongodb-nuodb-mysql-for-free/): In the new database world there are so many different solutions, vendors and options available that it is super hard to figure out which database is the right solution for us. First of all the world of the big data itself is very confusing. It is so hard to figure out from where to start and where to stop. There are so many tutorials out but none of them addresses the need of the absolute beginner. Now the same thing goes to the next level when one has to select the right database for their organization and there is no clear... - [SQL - Difference between != and <> Operator used for NOT EQUAL TO Operation](https://blog.sqlauthority.com/2013/07/08/sql-difference-between-and-operator-used-for-not-equal-to-operation/): Here is interesting question received on my Facebook page. (On a side note, today we have crossed over 50,000 fans on SQLAuthority Facebook Fan Page). What is the difference between != and <>Operator in SQL Server as both of them works same for Not Equal To Operator?  Very interesting question indeed. Even though this looks very simple when I asked quite a few people if they know the answer before I decided to blog about it. The answer which I received was that it seems that many know the answer but everybody wanted to know the more about it. Here is the... - [SQL SERVER - Check Database Level (IsNullConcat) and Session Level Settings (CONCAT_NULL_YIELDS_NULL) using T-SQL](https://blog.sqlauthority.com/2013/07/07/sql-server-check-database-level-isnullconcat-and-session-level-settings-concat_null_yields_null-using-t-sql/): Earlier I wrote a blog post SQL SERVER – A Quick Note on CONCAT_NULL_YIELDS_NULL and in follow up to the blog post, I received few questions. Let me try to answer those questions in following blog post. Q: How do we know if setting which returns NULL when concated to another NULL value is ON at database level? A: You can run following script to identify the settings of the database level. In my script I have described AdventureWorks database and is checking if the settings which returns NULL when any other value is concated with NULL or not. If the query returns 1 that means when... - [SQL SERVER - Weekly Series - Memory Lane - #036](https://blog.sqlauthority.com/2013/07/06/sql-server-weekly-series-memory-lane-036/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Explanation of WITH ENCRYPTION clause for Stored Procedure and User Defined Functions How to hide code of my Stored Procedure that no one can see it? 2) Our DBA has left the job and one of the function which retrieves important information is encrypted, how... - [SQL SERVER - A Quick Note on CONCAT_NULL_YIELDS_NULL](https://blog.sqlauthority.com/2013/07/05/sql-server-a-quick-note-on-concat_null_yields_null/): Recently one of my friends sent me a SQL script to debug and I noticed that above all of his scripts he was executed following query. SET CONCAT_NULL_YIELDS_NULL OFF; This made me curious and I asked him reason why is he executes above script. He answered that when his application have few columns which when he concats return the value as zero because his column contains NULL values. This made me curious as I believe if he has such business needs he should have changed his columns to allow NOT Null. When asked he suggested that he can’t do that as well... - [SQL SERVER - How to Refresh SSMS Intellisense Cache to Update Schema Changes](https://blog.sqlauthority.com/2013/07/04/sql-server-how-to-refresh-ssms-intellisense-cache-to-update-schema-changes/): Have you ever faced situation where you have just created or modified object but SSMS still shows the error. I quite often face this situation where I come across situation where my SSMS Intellisense Cache is not refreshed or updated. This is indeed very frustrating when you are presenting something on stage as the red underline means an error in graved in many people’s minds and it is hard for them to believe when the code with underline runs successfully. Here is image of the recent situation. Where I had just dropped index but SSMS Intellisense was still showing that the... - [Developer Training Courses - Online Courses to Learn SQL Server, MySQL and Technology](https://blog.sqlauthority.com/2013/07/03/developer-training-courses-online-courses-learn-sql-server-mysql-technology/): Developer Training Courses are the next big thing and I am so happy that I have so far authored 6 different video courses with Pluralsight. Here is the list of the courses. I have listed all of my video courses over here. - [Personal Technology - Excel Tip: Comparing Excel Files](https://blog.sqlauthority.com/2013/07/02/personal-technology-excel-tip-comparing-excel-files/): This guest post is by Vinod Kumar. Vinod Kumar has worked with SQL Server extensively since joining the industry over a decade ago. Working on various versionsfrom SQL Server 7.0, Oracle 7.3 and other database technologies – he now works with the Microsoft Technology Center (MTC) as a Technology Architect. Let us read the blog post in Vinod’s own voice. I have been writing about Excel Tips over my blog and thought it would be great to share one interesting tips here as a guest blog here. Assume a situation where you want to compare multiple excel files. Here is a typical scenario I... - [SQL SERVER - Check If Column Exists in SQL Server Table](https://blog.sqlauthority.com/2013/07/01/sql-server-check-if-column-exists-in-sql-server-table/): A very frequent task among SQL developers is to check if any specific column exists in the database table or not. Based on the output developers perform various tasks. Here are couple of simple tricks which you can use to check if column exists in your database table or not. Method 1 IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'columnName' AND OBJECT_ID = OBJECT_ID(N'tableName')) BEGIN PRINT 'Your Column Exists' END   For AdventureWorks sample database IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'Name' AND OBJECT_ID = OBJECT_ID(N'[HumanResources].[Department]')) BEGIN PRINT 'Your Column Exists' END   Method 2 IF COL_LENGTH('table_name','column_name') IS NOT NULL... - [SQL SERVER - 2014 CTP1 Available for Download - SQL SERVER 2014 Community Technology Preview 1](https://blog.sqlauthority.com/2013/06/30/sql-server-2014-ctp1-available-for-download-sql-server-2014-community-technology-preview-1/): Microsoft announced that SQL Server 2014 CTP 1 available to download at TechEd Europe. You can download SQL Server 2014 CTP1 from here. Additionally, there is in depth documentation of the product in the Product Guide over here. In this blog post I have in depth discussed what are the salient features which I was looking forward in the new version. Always On supports now 8 secondaries instead of 4 Online Indexing at partition level – this is a good thing as now index rebuilding can be done at a partition level Statistics at the partition level – this will be a huge improvement... - [SQL SERVER - Weekly Series - Memory Lane - #035](https://blog.sqlauthority.com/2013/06/29/sql-server-weekly-series-memory-lane-035/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Row Overflow Data Explanation  In SQL Server 2005 one table row can contain more than one varchar(8000) fields. One more thing, the exclusions has exclusions also the limit of each individual column max width of 8000 bytes does not apply to varchar(max), nvarchar(max), varbinary(max), text,... - [SQL SERVER - How to Set Variable and Use Variable in SQLCMD Mode](https://blog.sqlauthority.com/2013/06/28/sql-server-how-to-set-variable-and-use-variable-in-sqlcmd-mode/): Here is the question which I received the other day on SQLAuthority Facebook page. Social media is a wonderful thing and I love the active conversation between blog readers and myself – actually I think social media adds lots of human factor to any conversation. Here is the question – “I am using sqlcmd in SSMS – I am not sure how to declare variable and pass it, for example I have a database and it has table, how can I make the table variable dynamic and pass different value everytime?” Fantastic question, and here is its very simple answer. First of... - [SQL SERVER - Another lesser known feature of SQL Server Management Studio 2012 - Guest Post by Balmukund Lakhani](https://blog.sqlauthority.com/2013/06/27/sql-server-another-lesser-known-feature-of-sql-server-management-studio-2012-guest-post-by-balmukund-lakhani/): This is a fantastic blog post from my dear friend Balmukund ( blog | twitter | facebook ). He had presented a fantastic session in our last UG and there were lots of requests from attendees that he blogs about it. Well, here is the blog post about the same very popular UG session. Let us read the entire blog post in the voice of the Balmukund himself. In one of my previous guest blog on SQL Authority, I wrote about “Additional Connection Parameter” tab of login screen in SQL Server Management Studio (a.k.a. SSMS). On the similar lines, this blog is going to show little less known new feature of login main screen (“Connect to Server”) of SSMS 2012. - [SQL SERVER - Maximize Database Performance with DB Optimizer - SQL in Sixty Seconds #054](https://blog.sqlauthority.com/2013/06/26/sql-server-maximize-database-performance-with-db-optimizer-sql-in-sixty-seconds-054/): Performance tuning is an interesting concept and everybody evaluates it differently. Every developer and DBA have different opinion about how one can do performance tuning. I personally believe performance tuning is a three step process Understanding the Query Identifying the Bottleneck Implementing the Fix While, we are working with large database application and it suddenly starts to slow down. We are all under stress about how we can get back the database back to normal speed. Most of the time we do not have enough time to do deep analysis of what is going wrong as well what will fix the... - [SQL SERVER - Relationship with Parallelism with Locks and Query Wait - Question for You](https://blog.sqlauthority.com/2013/06/25/sql-server-relationship-with-parallelism-with-locks-and-query-wait-question-for-you/): Today, I have one very simple question based on following image. A full disclaimer is that I have no idea why it is like that. I tried to reach out to few of my friends who know a lot about SQL Server but no one has any answer. Here is the question: If you go to server properties and click on Advanced you will see the following screen. Under the Parallelism section if you noticed there are four options: Cost Threshold for Parallelism Locks Max Degree of Parallelism Query Wait I can clearly understand why Cost Threshold for Parallelism and Max Degree of... - [SQL SERVER - An Efficiency Tool to Compare and Synchronize SQL Server Databases](https://blog.sqlauthority.com/2013/06/24/sql-server-an-efficiency-tool-to-compare-and-synchronize-sql-server-databases/): There is no need to reinvent the wheel if it is already invented and if the wheel is already available at ease, there is no need to wait to grab it. Here is the similar situation. I came across a very interesting situation and I had to look for efficiency tool which can make my life easier and solve my business problem. - [SQL SERVER - List of All the Samples Database Available to Download for FREE](https://blog.sqlauthority.com/2013/06/23/sql-server-list-of-all-the-samples-database-available-to-download-for-free/): It is pretty much very common to have a sample database for any database product. Different companies keep on improving their product and keep on coming up with innovation in their product. To demonstrate the capability of their new enhancements they need the sample database. Microsoft have various sample database available for free download for their SQL Server Product. I have collected them here in a single blog post. - [SQL SERVER - Weekly Series - Memory Lane - #034](https://blog.sqlauthority.com/2013/06/22/sql-server-weekly-series-memory-lane-034/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 UDF – User Defined Function to Strip HTML – Parse HTML – No Regular Expression The UDF used in the blog does fantastic task – it scans entire HTML text and removes all the HTML tags. It keeps only valid text data without HTML task. This... - [SQL SERVER - Storing 64-bit Unsigned Integer Value in Database](https://blog.sqlauthority.com/2013/06/21/sql-server-storing-64-bit-unsigned-integer-value-in-database/): Here is a very interesting question I received in an email just another day. Some questions just are so good that it makes me wonder how come I have not faced it first hand. Anyway here is the question – “Pinal, I am migrating my database from MySQL to SQL Server and I have faced unique situation. I have been using Unsigned 64-bit integer in MySQL but when I try to migrate that column to SQL Server, I am facing an issue as there is no datatype which I find appropriate for my column. It is now too late to change... - [SQL - Contest to Get The Date - Win USD 50 Amazon Gift Cards and Cool Gift](https://blog.sqlauthority.com/2013/06/20/sql-contest-to-get-the-date-win-usd-50-amazon-gift-cards-and-cool-gift/): If you are a regular reader of this blog – you will find no issue at all in resolving this puzzle. This contest is based on my experience with NuoDB. If you are not familiar with NuoDB, here are few pointers for you. Step by Step Guide to Download and Install NuoDB – Getting Started with NuoDB Quick Start with Admin Sections of NuoDB – Manage NuoDB Database Quick Start with Explorer Sections of NuoDB – Query NuoDB Database In today’s contest you have to answer following questions: Q 1: Precision of NOW() What is the precision of the NuoDB’s NOW()... - [SQL SERVER - NuoDB in Sixty Seconds - SQL in Sixty Seconds #053](https://blog.sqlauthority.com/2013/06/19/sql-server-nuodb-in-sixty-seconds-sql-in-sixty-seconds-053/): Earlier this week, I have done five part blog series on NuoDB and it was very well received by audience. NuoDB is an elastically scalable SQL database that can run on local host, datacenter and cloud-based resources. t is an operational NewSQL database built on a patented emergent architecture with full support for SQL and ACID guarantees. In this blog post, I will explore how one can download and install NuoDB database. In this video I explain how one can install NuoDB in very few seconds and set up the entire environment in additional few seconds. One can get going with installation of NuoDB and sample database in... - [SQL - NuoDB and Third Party Explorer - SQuirreL SQL Client, SQL Workbench/J and DbVisualizer](https://blog.sqlauthority.com/2013/06/18/sql-nuodb-and-third-party-explorer-squirrel-sql-client-sql-workbenchj-and-dbvisualizer/): I recently wrote a four-part series on how I started to learn about and begin my journey with NuoDB. Big Data is indeed a big world and the learning of the Big Data is like spaghetti – no one knows in reality where to start, so I decided to learn it with the help of NuoDB. You can download NuoDB and continue your journey with me as well. Part 1 – Install NuoDB in 90 Seconds Part 2 – Manage NuoDB Installation Part 3 – Explore NuoDB Database Part 4 – Migrate from SQL Server to NuoDB …and in this blog... - [SQL - Migrate Database from SQL Server to NuoDB - A Quick Tutorial](https://blog.sqlauthority.com/2013/06/17/sql-migrate-database-from-sql-server-to-nuodb-a-quick-tutorial/): Data is growing exponentially and every organization with growing data is thinking of next big innovation in the world of Big Data. Big data is a indeed a future for every organization at one point of the time. Just like every other next big thing, big data has its own challenges and issues. The biggest challenge associated with the big data is to find the ideal platform which supports the scalability and growth of the data. If you are a regular reader of this blog, you must be familiar with NuoDB. I have been working with NuoDB for a while and their recent... - [SQL SERVER - Microsoft SQL Server 2014 CTP1 Product Guide](https://blog.sqlauthority.com/2013/06/16/sql-server-microsoft-sql-server-2014-ctp1-product-guide/): Today in User Group meeting there were lots of questions related to SQL Server 2014. There are plenty of people still using SQL Server 2005 but everybody is curious about what is coming in SQL Server 2014.  Microsoft has officially released SQL Server 2014 CTP1 Product Guide. You can easily download the product guide and explore various learning around SQL Server 2014 as well explore the new concepts introduced in this latest version. This SQL Server 2014 CTP1 Product Guide contains few interesting White Papers, a Datasheet and Presentation Deck. Here is the list of the white papers: Mission-Critical Performance and... - [SQL SERVER - Weekly Series - Memory Lane - #033](https://blog.sqlauthority.com/2013/06/15/sql-server-weekly-series-memory-lane-033/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Spatial Database Definition and Research Documents Here is the definition from Wikipedia about spatial database : A spatial database is a database that is optimized to store and query data related to objects in space, including points, lines and polygons. While typical databases can understand various numeric... - [SQL - Quick Start with Explorer Sections of NuoDB - Query NuoDB Database](https://blog.sqlauthority.com/2013/06/14/sql-quick-start-with-explorer-sections-of-nuodb-query-nuodb-database/): This is the third post in the series of the blog posts I am writing about NuoDB. NuoDB is very innovative and easy-to-use product. I can clearly see how one can scale-out NuoDB with so much ease and confidence. In my very first blog post we discussed how we can install NuoDB (link), and in my second post I discussed how we can manage the NuoDB database transaction engines and storage managers with a few clicks (link). Note: You can Download NuoDB from here. In this post, we will learn how we can use the Explorer feature of NuoDB to do various SQL operations.... - [SQL - Quick Start with Admin Sections of NuoDB - Manage NuoDB Database](https://blog.sqlauthority.com/2013/06/13/sql-quick-start-with-admin-sections-of-nuodb-manage-nuodb-database/): In the yesterday’s blog post we have seen that it is extremely easy to install the NuoDB database on your local machine. Now that the application is properly set up, let us explore NuoDB a bit more and get you familiar with the how it works and what the important areas of the NuoDB are that you should learn. As we have already installed NuoDB, now we will quickly start with two of the important areas in NuoDB: 1) Admin and 2) Explorer. In this blog post I will explore how the Admin Section of the NuoDB Console works.  In the next blog post we will learn... - [SQL - Step by Step Guide to Download and Install NuoDB - Getting Started with NuoDB](https://blog.sqlauthority.com/2013/06/12/sql-step-by-step-guide-to-download-and-install-nuodb-getting-started-with-nuodb/): Let us take a look at the application you own at your business. If you pay attention to the underlying database for that application you will be amazed. Every successful business these days processes way more data than they used to process before. The number of transactions and the amount of data is growing at an exponential rate. Every single day there is way more data to process than before. Big data is no longer a concept; it is now turning into reality. If you look around there are so many different big data solutions and it can be a quite difficult... - [SQL SERVER - Puzzle #1 - Querying Pattern Ranges and Wild Cards](https://blog.sqlauthority.com/2013/06/11/sql-server-puzzle-1-querying-pattern-ranges-and-wild-cards/): Note: Read at the end of the blog post how you can get five Joes 2 Pros Book #1 and a surprise gift. I have been blogging for almost 7 years and every other day I receive questions about Querying Pattern Ranges. The most common way to solve the problem is to use Wild Cards. However, not everyone knows how to use wild card properly. SQL Queries 2012 Joes 2 Pros Volume 1 – The SQL Queries 2012 Hands-On Tutorial for Beginners Book On Amazon | Book On Flipkart Learn SQL Server get all the five parts combo kit Kit on Amazon | Kit on Flipkart Many... - [SQL SERVER - New SQL Server 2012 Functions - Webinar by Rick Morelan](https://blog.sqlauthority.com/2013/06/10/sql-server-new-sql-server-2012-functions-webinar-by-rick-morelan/): My friend Rick Morelan is a wonderful speaker and listening to him is very delightful. Rick is one of the speakers who can articulate a very complex subject in very simple words. Rick has attained over 30 Microsoft certifications in applications, networking, databases and .NET development, including MCDBA, MCTS, MCITP, MCAD, MOE, MCSE and MCSE+. Here is the chance for every one who has not listened Rick Morelan before as he is presenting an online webinar on New SQL Server 2012 Functions. Whether or not you’re a database developer or administrator, you love the power of SQL functions. The functions in SQL Server... - [SQL SERVER - The Story of a Lesser Known Startup Parameter in SQL Server - Guest Post by Balmukund Lakhani](https://blog.sqlauthority.com/2013/06/10/sql-server-the-story-of-a-lesser-known-startup-parameter-in-sql-server-guest-post-by-balmukund-lakhani/): This is a fantastic blog post from my dear friend Balmukund ( blog | twitter | facebook ). He had presented a fantastic session in our last UG and there were lots of requests from attendees that he blogs about it. Well, here is the blog post about the same very popular UG session. Let us read the entire blog post in the voice of the Balmukund himself. During my last session in SQL Bangalore User Group (Facebook) meeting, I was lucky enough to deliver a session on SQL Server Startup issue. The name of the session was “SQL Engine Starting Trouble –... - [SQL SERVER - 2014 Announced and SQL Server 2014 Datasheet](https://blog.sqlauthority.com/2013/06/09/sql-server-2014-announced-and-sql-server-2014-datasheet/): Earlier this week Microsoft has announced SQL Server 2014. The release date of Trial of SQL Server to be believed later this year. - [SQL SERVER - Coding Standards - Weekly Series - Memory Lane - #032](https://blog.sqlauthority.com/2013/06/08/sql-server-weekly-series-memory-lane-032/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. Let us learn about Coding Standards in this blog post.  - [SQL SERVER - QUOTED_IDENTIFIER ON/OFF Explanation and Example - Question on Real World Usage](https://blog.sqlauthority.com/2013/06/07/sql-server-quoted_identifier-onoff-explanation-and-example-question-on-real-world-usage/): This is a follow up blog post of SQL SERVER – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation. I wrote that blog six years ago and I had plans that I will write a follow up blog post of the same. Today, when I was going over my to-do list and I was surprised that I had an item there which was six years old and I never got to do that. In the earlier blog post I wrote about exploitation of the Quoted Identifier and ANSI Null. In this blog post we will see a quick example of Quoted Identifier. However, before we... - [SQLAuthority News - Top 5 Latest Microsoft Certifications of 2013](https://blog.sqlauthority.com/2013/06/06/sqlauthority-news-top-5-latest-microsoft-certifications-of-2013/): With the IT job market getting more and more competent by the day, certifications are a must for anyone who wishes to get a strong foothold in the industry. Microsoft community comes up with regular updates and enhancements in its existing products to keep up with the rapidly evolving requirements of the ICT industry. We bring you a list of five latest Microsoft certifications that you must consider acquiring this year. - [SQL SERVER - SQL in Sixty Seconds - Need Your Opinion](https://blog.sqlauthority.com/2013/06/05/sql-server-sql-in-sixty-seconds-need-your-opinion/): Though this may look very simple to you it is very crucial to me and I would like to know your opinion about it. I have included the latest video. - [SQL SERVER - Script to Update a Specific Column in Entire Database](https://blog.sqlauthority.com/2013/06/04/sql-server-script-to-update-a-specific-column-in-entire-database/): Last week, I have received a very interesting question and I find in email and I really liked the question as I had to play around with SQL Script for a while to come up with the answer he was looking for. Please read the question and I believe that all of us face this kind of situation. “Pinal, In our database we have recently introduced ModifiedDate column in all of the tables. Now onwards any update happens in the row, we are updating current date and time to that field. Now here is the issue, when we added that field... - [SQLAuthority News - Advantages of Distance Learning](https://blog.sqlauthority.com/2013/06/02/sqlauthority-news-advantages-of-distance-education/): Distance education is extremely popular – almost overnight, it seems.  Almost everyone has taken an online course, or knows someone who has, or is considering joining an online school.  There are many advantages and disadvantages to attending an online school – but the same can be said of attending a physical school!  Let’s take a look at the top reasons to use distance education. 1) Flexibility.  Physical universities are usually willing to make some concessions to student – like night classes, study hours, and online networks.  However, nothing is going to beat the flexibility of distance education.  You can attend classes... - [SQL SERVER - Weekly Series - Memory Lane - #031](https://blog.sqlauthority.com/2013/06/01/sql-server-weekly-series-memory-lane-031/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Find Table without Clustered Index – Find Table with no Primary Key Clustered index is very important concept for any table. They impact the performance very heavily. Here is a quick script to find tables without a clustered index. Replace TEXT with VARCHAR(MAX) – Stop... - [SQLAuthority News - New Theme of SQLAuthority and Video Courses](https://blog.sqlauthority.com/2013/05/31/sqlauthority-news-new-theme-of-sqlauthority-and-video-courses/): I have been blogging for almost 7 years now. Recently I reached a very important milestone for my blog. I completed over 2500 blog posts as well have been receiving consistently over 2 Million Views every month. It has been a fantastic ride and I am planning to continue contributing to blog and community. However, just like everything else the blog was in need of the fresh look for a long time. I recently updated entire theme of SQLAuthority.com and have given clear fresh look to it. Here are few of the details of enhancements: Changed width from 600 px to 840... - [SQL SERVER - Add Identity Column to Table Based on Order of Another Column](https://blog.sqlauthority.com/2013/05/30/sql-server-add-identity-column-to-table-based-on-order-of-another-column/): After reading my earlier article on Identity Column, I received a very interesting question. The reason, I like to call it interesting is though, I have provided answers to him, I believe there should be another better alternative to this problem. Let us see the question first in his own words. “Hi Pinal, I already have existing table and the table already have fewer columns. The table does not have identity column and I would like to add an identity column to this table. The problem is that every time when I try to add an identity column to the table, it... - [SQL SERVER - Puzzle SET ANSI_NULLS and Resultset - SQL in Sixty Seconds #052](https://blog.sqlauthority.com/2013/05/29/sql-server-puzzle-set-ansi_nulls-and-resultset-sql-in-sixty-seconds-052/): Earlier I have posted a puzzle where I was receiving different results when I executed two different queries. I encourage all of you to read the original puzzle here, the puzzle had received many fantastic responses and I have later blogged about the solution of the puzzle over here. Now I have decided to extend the same puzzle and take it to the next level. In earlier puzzle I had value of the ANSI_NULLS was set to ON. Now in this puzzle let us set the value of the ANSI_NULLS to OFF. When the value of ANSI_NULLS was off at that time,... - [SQL SERVER- Solution - SQL Puzzle of SET ANSI_NULL](https://blog.sqlauthority.com/2013/05/28/sql-server-solution-sql-puzzle-of-set-ansi_null/): Earlier I have posted a puzzle which received so many valid responses and got a fantastic explanation to the questions as well. I encourage all of you to read the original puzzle here. First run following script: SET ANSI_NULLS ON; -- Query1 SELECT 'SQLAuthority' AS Statement11 WHERE 'Authority' IN ('S','Q', 'L', 'Authority', NULL); -- Query 2 SELECT 'SQLAuthority' AS Statement12 WHERE 'Authority' NOT IN ('S','Q', 'L', NULL); You will get following result: You can clearly see that in the first case we are getting different results. Question: Why do Query 1 return results but Query 2 does not return any result?... - [SQL SERVER - How to INSERT data from Stored Procedure to Table - 2 Different Methods](https://blog.sqlauthority.com/2013/05/27/sql-server-how-to-insert-data-from-stored-procedure-to-table-2-different-methods/): Here is a very common question which I keep on receiving on my facebook page as well on twitter. “How do I insert the results of the stored procedure in my table?” This question has two fold answers – 1) When the table is already created and 2) When the table is to be created run time. In this blog post we will explore both the scenarios together. However, first let us create a stored procedure which we will use for our example. CREATE PROCEDURE GetDBNames AS SELECT name, database_id FROM sys.databases GO We can execute this stored procedure using the... - [Blogging Best Practices - Checklist for Building Successful Blog - Part 6](https://blog.sqlauthority.com/2013/05/26/blogging-best-practices-checklist-for-building-successful-blog-part-6/): Abstract of my Pluralsight Course Building a Successful Blog Module – Checklist for Building Successful Blog. [youtube=http://www.youtube.com/watch?v=12p4j4Ht8os] I hope everyone has learned a little or a lot with me through this whole course.  Even if you are already a professional blogger, my hope is that everyone could learn something.  I love blogging and the point of this course was to make it accessible to more people – because I believe that it is something everyone would enjoy. If you’re excited about starting a blog, here is a checklist for things to do to get one started. RSS Feed or Email Subscription Easy Navigation... - [SQL SERVER - Weekly Series - Memory Lane - #030](https://blog.sqlauthority.com/2013/05/25/sql-server-weekly-series-memory-lane-030/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 ASCII to Decimal and Decimal to ASCII I still use this script many times in my daily work. It works and it is cool. Script/Function to Find Last Day of Month A simple trick but we are often lazy to write, a script like this... - [Blogging Best Practices - Frequently Asked Questions - Part 5](https://blog.sqlauthority.com/2013/05/24/blogging-best-practices-frequently-asked-questions-part-5/): Abstract of my Pluralsight Course Building a Successful Blog Module – Frequently Asked Questions. [youtube=http://www.youtube.com/watch?v=12p4j4Ht8os] If you have been following this blog series about starting and maintaining a blog, you might be excited to go start blogging right now.  But if you have a few more questions, let me get them out of the way right now with some Frequently Asked Questions. Here are few of the questions which I discuss over here. Should I start Blogging? Of course!  It’s fun, easy (if you love what you do, it will be easy), it is rewarding, and you could even earn money. What if... - [Blogging Best Practices - Blogging Rules, Ethics and Etiquette - Part 4](https://blog.sqlauthority.com/2013/05/23/blogging-best-practices-blogging-rules-ethics-and-etiquette-part-4/): Abstract of my Pluralsight Course Building a Successful Blog Module – Blogging Rules, Ethics and Etiquette. [youtube=http://www.youtube.com/watch?v=12p4j4Ht8os] To have a successful blog, your posts should be interesting, you probably would like to have a large audience, and you want to provide quality content to the subject.  However, to be truly successful, you also ought to follow a few ethical rules, as well – your blog might be popular, but if you are just plagiarizing from a less well-known source, your success is not honestly won, and not truly your own. Legal Issues One of the biggest issues that bloggers ought to keep in... - [Blogging Best Practices - Writing an Interesting Blog - Part 3](https://blog.sqlauthority.com/2013/05/22/blogging-best-practices-writing-an-interesting-blog-part-3/): Abstract of my Pluralsight Course Building a Successful Blog Module – Writing an Interesting Blog. [youtube=http://www.youtube.com/watch?v=12p4j4Ht8os] Getting Started Is writing an interesting blog so simple that I can just TELL you how to do it right now?  Almost!  I’m sure you started your blog because you had something you felt you had to write about.  But now you’ve created the site and are staring at a blank page that represents all the millions of different directions you can go with this new idea.  Just remember as you write – if you wanted to write about it, there are certainly a few people who... - [Blogging Best Practices - Getting Started with Blogging - Part 2](https://blog.sqlauthority.com/2013/05/21/blogging-best-practices-getting-started-with-blogging-part-2/): Abstract of my Pluralsight Course Building a Successful Blog Module – Getting Started with Blogging. [youtube=http://www.youtube.com/watch?v=12p4j4Ht8os] Choosing a Blog Host If you’ve recently decided to start blogging, the very first thing you have to decide on is which hosting service to use.  There are many blog hosts: Blogger, WordPress, Typepad, to name just a few.  With so many options, how can you choose? There are a few criteria to keep in mind when choosing a blog host. What is the purpose of this blog?  If it a personal website, you don’t need anything too technical or one that is uniquely designed for you. ... - [Blogging Best Practices - Concepts, Ideas and Motives - Part 1](https://blog.sqlauthority.com/2013/05/20/blogging-best-practices-concepts-ideas-and-motives-part-1/): Abstract of my Pluralsight Course, Building Building a Successful Blog Module - Getting Started with Blogging. Blogging Best Practices. - [Blogging Best Practices - Pluralsight Online Course Based on My Experience](https://blog.sqlauthority.com/2013/05/19/blogging-best-practices-pluralsight-online-course-based-on-my-experience/): I have been blogging for more than 6.5 years and I have so far written over 2500 articles on this blog and every blog has been journey itself. Over six years I have not missed any single blog and no matter what happens I keep on blogging every day, month after month and year after year. This demonstrates how much I love to blog and engage with all of you. I honestly love all of you and respect a lot when you engage with me on this blog. During this journey, one of the most common suggestion I received was that I... - [SQL SERVER - Weekly Series - Memory Lane - #029](https://blog.sqlauthority.com/2013/05/18/sql-server-weekly-series-memory-lane-029/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 List all the database A Simple script which list all the database from the server. Function to Parse AlphaNumeric Characters from String Following function keeps only Alphanumeric characters in string and removes all the other character from the string. This is a very handy function... - [SQL SERVER - Solution to Puzzle - REPLICATE over 8000 Characters](https://blog.sqlauthority.com/2013/05/17/sql-server-solution-to-puzzle-replicate-over-8000-characters/): Earlier this week, I asked a puzzle about how REPLICATE works with 8000 and over 8000 characters. I strongly suggest to read the original blog post where I have described the problem in detail SQL SERVER Puzzle – REPLICATE over 8000 Characters. Just quick to summarize the puzzle. Here is the quick recap of the same. Now let us run following script. DECLARE @FirstString VARCHAR(MAX) DECLARE @SecondString VARCHAR(MAX) DECLARE @ThirdString VARCHAR(MAX) SET @FirstString = REPLICATE('A',4000) SELECT LEN(@FirstString) LenFirstString; SET @SecondString = REPLICATE('B',8000) SELECT LEN(@SecondString) LenSecondString; SET @ThirdString = REPLICATE('C',11000) SELECT LEN(@ThirdString) LenThirdString; The script above will return following result: Quiz 1: Pay attention... - [SQLAuthority News - 2500 Blog Posts, 2 Million Views per month, 62 Million Total Views](https://blog.sqlauthority.com/2013/05/16/sqlauthority-news-2500-blog-posts-2-million-views-per-month-62-million-total-views/): Today, I am very happy as the journey I started almost 6.5 years ago has very important milestone. I have stopped blogging about my milestone for a long time as I believe that was just taking up the space in my blog and was not providing any useful information. However, today is a special day. This is my 2500th blog post and now the next 2500th blog post will come after many years. We also got 2 Million Views per month this year. - [SQL SERVER - SQL Puzzle of SET ANSI_NULL - Win USD 50 worth Amazon Gift Cards and Bubble Copter R/C](https://blog.sqlauthority.com/2013/05/15/sql-server-sql-puzzle-of-set-ansi_null-win-usd-250-worth-amazon-gift-cards-and-bubble-copter-rc/): Note: This contest is over, so enjoy the brain teaser about ANSI_NULL. We all love puzzles and here is interesting puzzle which you can play with me and win Amazon Gift Cards and Bubble Copter R/C. The contest for Amazon Gift Card is open worldwide, however, Bubble Copter winner will be chosen from USA only. - [SQL SERVER - How to use xp_sscanf in Real World Scenario?](https://blog.sqlauthority.com/2013/05/14/sql-server-how-to-use-xp_sscanf-in-real-world-scenario/): I need your help. I recently came across extended stored procedure xp_sscanf. After reading a lot about it and searching online, I could not figure out how and where in real world, I will use this function. Microsoft documentations suggest that this extended stored procedure reads data from the string into the argument locations specified by each format argument. I still do not get it. I know it is very similar to C function but again I am not sure where in the real world I will use this function. Here is the demonstration of how this function works. Following example... - [SQL SERVER - Puzzle and Answer - REPLICATE over 8000 Characters](https://blog.sqlauthority.com/2013/05/13/sql-server-puzzle-and-answer-replicate-over-8000-characters/): It has been a long time since we have played a puzzle over this blog. This Monday, let us play a quick puzzle. SQL Server have REPLICATE function which will replicate the string passed as many as times as the second parameter. For example execute following string. SELECT 'Ha'+REPLICATE('ha',20) The script above will return following result: You can notice that it has returned a string ha about 20 times after first Ha. Now let us run following script. DECLARE @FirstString VARCHAR(MAX) DECLARE @SecondString VARCHAR(MAX) DECLARE @ThirdString VARCHAR(MAX) SET @FirstString = REPLICATE('A',4000) SELECT LEN(@FirstString) LenFirstString; SET @SecondString = REPLICATE('B',8000) SELECT LEN(@SecondString) LenSecondString; SET... - [SQL SERVER - Interesting Observation of CONCAT_NULL_YIELDS_NULL and CONCAT](https://blog.sqlauthority.com/2013/05/12/sql-server-interesting-observation-of-concat_null_yields_null-and-concat/): Have you ever worked with CONCAT_NULL_YIELDS_NULL earlier in your career? If yes, you will find this post very interesting for CONCAT. - [SQL SERVER - Weekly Series - Memory Lane - #028](https://blog.sqlauthority.com/2013/05/11/sql-server-weekly-series-memory-lane-028/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 UDF – Function to Convert List to Table Article contains UDF written for SQL SERVER 2005. It will also work well with the very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar... - [SQL SERVER - Adding Column Defaulting to Current Datetime in Table](https://blog.sqlauthority.com/2013/05/10/sql-server-adding-column-defaulting-to-current-datetime-in-table/): Presenting a technical session is a greatest experience one can have and I enjoy doing the same. While I write this blog post, I am presenting at Great Indian Developer Summit in India. The event is a grand success and I am having a great time at this event. One of the questions which I often receive is how do one can add the column to existing table which will be auto-populated with the current datetime when the original row is inserted. There is indeed a simple solution to achieve this goal. One has to just create table with default value as a current datetime. - [SQL SERVER - A New Approach to Scale .NET Applications](https://blog.sqlauthority.com/2013/05/09/sql-server-a-new-approach-to-scale-net-applications/): In a previous article, I wrote about scale-up vs. scale-out architectures using SQL Server and NuoDB as examples.  NuoDB recently announced the general availability of their latest product release, 1.1, and it looks like they’ve made significant progress in improving their Microsoft support. NuoDB now supports 64-bit Windows environments, natively integrates with Visual Studio, LINQ and EntityFramework to name a few. For those of you who haven’t had a chance to read my previous article, NuoDB is a distributed cloud database that supports SQL and ACID transactions. A single logical NuoDB database can be deployed on one or many cloud machines... - [SQL SERVER - RESEED Identity Column in Database Table - Rest Table Identity Value - SQL in Sixty Seconds #051](https://blog.sqlauthority.com/2013/05/08/sql-server-reseed-identity-in-table-column-rest-table-identity-value-sql-in-sixty-seconds-051/): This is the 51th episode of SQL in Sixty Seconds Video and we will see in this episode how to RESEED identity of the table column. Identity column is every increasing (or decreasing) value based on the interval specified in its property. In today’s SQL in Sixty Seconds video we will see that how we can reseed the identity value to any other value. In the video I demonstrate that we can set the value to any value which is greater than the current column value however, you can also set the identity value to any value lower than the current... - [SQLAuthority News - Sharding or No Sharding of Database - Working on my Weekend Project](https://blog.sqlauthority.com/2013/05/07/sqlauthority-news-sharding-or-no-sharding-of-database-working-on-my-weekend-project/): Recently I came across situation where database sharding was once again a suggested solution by architectures. Everytime I hear the word sharding I remember my earlier article about NuoDB on Shard No More – An Innovative Look at Distributed Peer-to-peer SQL Database. Sharding requires developers to think about things like rollbacks, constraints, and referential integrity across tables within their applications when these types of concerns are best handled by the database. It also makes other common operations such as joins, searches, and memory management very difficult. Each NuoDB database consists of at least three or more processes that enable a single database to run across... - [SQL SERVER - Azure SQL Databases Backup Made Easy with SQLBackupAndFTP](https://blog.sqlauthority.com/2013/05/06/sql-server-azure-sql-databases-backup-made-easy-with-sqlbackupandftp/): Azure SQL database backup used to be a difficult task. Not any more. With SQLBackupAndFTP with Azure it became trivial. Here’s what you basically need to do: Once  SQLBackupAndFTP with Azure  is installed, click at “Connect to SQL Server / Azure” button and specify connection properties for your Azure SQL Databases: Then click “Run Now” to backup your Azure SQL Database(s): Scheduling backups is also very simple – just check “Schedule this job on the main form” to run once daily or go to Advanced Settings for more options Sounds simple? There are just a couple more things you need for this... - [SQL SERVER - sys.dm_xe_map_values - Reasons for Statement Recompilation](https://blog.sqlauthority.com/2013/05/05/sql-server-sys-dm_xe_map_values-reasons-for-statement-recompilation/): Sometime I feel I know a lot about SQL Server and very next moment, I realize that honestly I do not know much about this product. Earlier today, I had similar moments. I was playing with few DMVs and suddenly I ended up on the DMV sys.dm_xe_map_values. There are only four columns and one of the columns is a GUID. The reason I ended up on this DMV was because I was asked a question what are the different reasons any statement can be recompiled. I knew few of the reasons why would any statement recompile but I was not aware of... - [SQL SERVER - Weekly Series - Memory Lane - #027](https://blog.sqlauthority.com/2013/05/04/sql-server-weekly-series-memory-lane-027/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Good, Better and Best Programming Techniques Well, here is my note which I prepared to discuss in my earlier meeting. This is not complete and is not in very details. This note contains what I think is best programming technique in SQL. There are lots... - [SQL SERVER - DELETE From SELECT Statement - Using JOIN in DELETE Statement - Multiple Tables in DELETE Statement](https://blog.sqlauthority.com/2013/05/03/sql-server-delete-from-select-statement-using-join-in-delete-statement-multiple-tables-in-delete-statement/): This blog post is inspired from my earlier blog post of UPDATE From SELECT Statement – Using JOIN in UPDATE Statement – Multiple Tables in Update Statement. In the blog post I discussed about how we can use JOIN and multiple tables in the UPDATE statement. There were plenty of the emails after this blog post discussing about using JOIN in the DELETE statement as well using multiple tables in the DELETE statement. It is totally possible to use JOIN and multiple tables in the DELETE statement. Let us use the same table structure which we had used previously. Let us... - [SQLAuthority News - Presenting 3 Technical Sessions at Great Indian Developer Summit - May 7, 2013 - Bangalore](https://blog.sqlauthority.com/2013/05/02/sqlauthority-news-presenting-3-technical-sessions-at-great-indian-developer-summit-may-7-2013-bangalore/): I will be presenting once again 3 Technical Sessions on SQL Server and Performance Tuning at Great Indian Developer Summit on May 7, 2013. If you are going to attend the event, you do not want to miss the technical sessions at any cost. Here is the generic theme for every session I will be presenting at Great Indian Developer Summit. Each session will have 30% theory and 70% demonstrations Attendees will have access to scripts presented in the session Location to review the videos and free learning material associated with the session Practical Performance Tuning Tips to tune your server Attendees... - [SQLAuthority News - Learn Fundamentals of MySQL Online - Pluralsight Course](https://blog.sqlauthority.com/2013/05/01/sqlauthority-news-learn-fundamentals-of-mysql-online-pluralsight-course/): Here are few of the question I often receive – Do you know anything besides SQL Server? So how does it feel when the only thing which you know is SQL Server? Have you worked in the past with any other programming language? Actually, I find these questions very interesting as I do work with other technologies and I still do work with many other technologies besides SQL Server. Recently I got the opportunity to work with MySQL and have also built quite a lot of knowledge about the application as well. I found MySQL very interesting and easy to learn.... - [SQL SERVER - UPDATE From SELECT Statement - Using JOIN in UPDATE Statement - Multiple Tables in Update Statement](https://blog.sqlauthority.com/2013/04/30/sql-server-update-from-select-statement-using-join-in-update-statement-multiple-tables-in-update-statement/): This is one of the most interesting questions I keep on getting on this email and I find that not everyone knows about it. In recent times I have seen a developer writing a cursor to update a table. When asked the reason was he had no idea how to use multiple tables with the help of the JOIN clause in the UPDATE statement. Let us see the following example. We have two tables Table 1 and Table 2. -- Create table1 CREATE TABLE Table1 (Col1 INT, Col2 INT, Col3 VARCHAR(100)) INSERT INTO Table1 (Col1, Col2, Col3) SELECT 1, 11, 'First' UNION... - [SQL SERVER - Disable All the Foreign Key Constraint in Database - Enable All the Foreign Key Constraint in Database](https://blog.sqlauthority.com/2013/04/29/sql-server-disable-all-the-foreign-key-constraint-in-database-enable-all-the-foreign-key-constraint-in-database/): Here is an email I received during the weekend. “Hi Pinal, I am a senior tester in the leading organization and we have two different environments 1) Testing 2) Production. As a part of the testing we want to insert garbage data into the database system and see how the application behaves in this scenario. However, there is a small problem. Everytime when I try to insert garbage data in the database system the tables start giving me error that due to constraints on the table, I need to populate data in certain order and it has to be correct. Actually, we... - [SQLAuthority News - Download PowerPivot or PowerView enabled Workbook Optimizer - Download SQL Server Connector for Apache Hadoop](https://blog.sqlauthority.com/2013/04/28/sqlauthority-news-download-powerpivot-or-powerview-enabled-workbook-optimizer-download-sql-server-connector-for-apache-hadoop/): Earlier this week Microsoft have released two very interesting downloads which got my attention. Haddop, PowerPivot and PowerView all three are not directly related to traditional RDBMS but their important is growing in the industry as big data is taking over market. The Microsoft SQL Server SQOOP Connector for Hadoop is now part of Apache SQOOP 1.4 and we are not providing a separate download anymore. Please note that Microsoft’s HDInsight service includes the connector as well. Linux (for Hadoop setup) and Windows (with SQL Server 2008 R2 installed). Both are required to use the SQL Server-Hadoop Connector. With SQL Server-Hadoop Connector,... - [SQL SERVER - Weekly Series - Memory Lane - #026](https://blog.sqlauthority.com/2013/04/27/sql-server-weekly-series-memory-lane-026/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 SQL Server Interview Questions and Answers Complete List Download SQL Server interview questions and answers is very crucial for any beginners. Some use this as a reference for future and some use it for refreshing the technology. Well, anyway, this is one of the most... - [SQL SERVER - UNION ALL and UNION are Different Operation](https://blog.sqlauthority.com/2013/04/26/sql-server-union-all-and-union-are-different-operation/): I have previously written about the difference between UNION ALL and UNION multiple times over this blog but it seems like this question never gets old and I keep on getting the question again and again. Let us learn about the different operations about the unions.  - [SQL SERVER - Return Specific Row to at the Bottom of the Resultset - T-SQL Script - Part 2](https://blog.sqlauthority.com/2013/04/25/sql-server-return-specific-row-to-at-the-bottom-of-the-resultset-t-sql-script-part-2/): “How do I return a  few of my resultset rows at the bottom of the entire resultset?” I was previously asked this question and my response was that we can do this by using the CASE statement in the ORDER BY clause and I wrote a blog post describing the same over here SQL SERVER – Return Specific Row to at the Bottom of the Resultset – T-SQL Script. In the blog post I had mentioned that there is an alternative method of UNION ALL. There have been few emails and comments regarding how to use UNION ALL in this situation hence I... - [SQL SERVER - Interview Questions and Answers Sample Chapter Free Download - SQL in Sixty Seconds #050](https://blog.sqlauthority.com/2013/04/24/sql-server-interview-questions-and-answers-sample-chapter-free-download-sql-in-sixty-seconds-050/): This journey of SQL in Sixty Seconds we started almost a year ago and today we are at very interesting milestone where I am recording 50th episode. Thought I wanted to keep the length of each video to sixty seconds, sometimes it went up by a few seconds. Due to this we are also at very interesting milestone as well – today’s 50th episode also accumulates the play time for entire playlist to 60 minutes (complete 1 hour). There are two different milestones to celebrate today. This is the 50th Episode of SQL in Sixty Seconds Total play time for SQL in Sixty Seconds is One hour complete... - [SQL SERVER - Return Specific Row to at the Bottom of the Resultset - T-SQL Script](https://blog.sqlauthority.com/2013/04/23/sql-server-return-specific-row-to-at-the-bottom-of-the-resultset-t-sql-script/): “How do I return a few of my resultset rows at the bottom of the entire resultset?” - [SQL SERVER - Discussion - Scale-up vs Scale-out Architectures](https://blog.sqlauthority.com/2013/04/22/sql-server-discussion-scale-up-vs-scale-out-architectures/): Note: NuoDB is a complete re-think of relational databases with innovative support for the Cloud’s dynamic, asynchronous nature. Download NuoDB to experience the Scaling Out scenario discussed in this blog post. Scaling Up There are many different ways of scaling SQL Server to accommodate more transactions and throughput. The general scale-up approach includes: Adding more CPU to increase computational performance Adding RAM to increase query and data caching Adding more storage such as SSDs and partitioning various I/O processes to different physical disks As long as larger machines are available and your organization has the means to purchase them, then scaling up your database... - [SQLAuthority News - Webinar SQL Server Locking and Concurrency by Rick Morelan](https://blog.sqlauthority.com/2013/04/22/sqlauthority-news-webinar-sql-server-locking-and-concurrency-by-rick-morelan/): My book co-author Rick Morelan is giving away SQL Queries Book and DVD set (valued at over $200) in his next webinar. SQL Server is known for handing many requests at once and updating as new data comes in. If concurrency allows many things to happen at once, and locking prevents multiple users from changing the same piece of data at the same time… how do they work together? Register for the webinar now to learn: The different types of concurrency How to identify blocking locks and choose between competing processes Tools to profile the database, finding locks and wait times Date... - [SQLAuthority News - Women in SQL - Youngest SQL Speaker - Bangalore SQL User Group Event on April 20, 2013](https://blog.sqlauthority.com/2013/04/21/sqlauthority-news-women-in-sql-youngest-sql-speaker-bangalore-sql-user-group-event-on-april-20-2013/): It was a great day today as at a SQL Bangalore User Group we had an event “Women in SQL” day. This event was one of the milestone event as in India there was no UG in my knowledge had done an event where we appreciated “Women Power”. We had a very strong line up of the speakers and around 100+ people were there to appreciate the knowledge and presentation. SQL Bangalore is the most active SQL User Group in Bangalore and we have a vibrant and active community here. Here is the Facebook page where we are extremely active and... - [SQL SERVER - Weekly Series - Memory Lane - #025](https://blog.sqlauthority.com/2013/04/20/sql-server-weekly-series-memory-lane-025/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 CASE Statement/Expression Examples and Explanation CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in... - [SQL SERVER - How to Begin with VMware - Introduction to Virtualization](https://blog.sqlauthority.com/2013/04/19/sql-server-how-to-begin-with-vmware-introduction-to-virtualization/): Virtualization has slowly crept in and made its rightful place into enterprises of all sizes and segments today. More and more organizations are realizing the importance of virtualization and adopting this revolutionary technology in its entirety. However, for a beginner, it is pretty confusing. The market is flooded with various vendors offering a slice of this technology in various forms and features. - [SQL SERVER - Using SSIS to Import CSV File into Salesforce Online Database with dotConnect for Salesforce from Devart](https://blog.sqlauthority.com/2013/04/18/sql-server-using-ssis-to-import-csv-file-into-salesforce-online-database-with-dotconnect-for-salesforce-from-devart/): I have previously written article how one can import a CSV file into a database table using SSIS package. This was a simple import operation when the CSV file structure corresponded to the table structure column-to-column. However SQL Server Integration Services is a very powerful tool that can be used for much more complex data import CSV operations. - [SQL SERVER - Remove Cached Login from SSMS Connect Dialog - SQL in Sixty Seconds #049](https://blog.sqlauthority.com/2013/04/17/sql-server-remove-cached-login-from-ssms-connect-dialog-sql-in-sixty-seconds-049/): One of the most annoying thing which I have personally come across is drop down list of Server Lists on Connect dialog in SQL Server Management Studio. Here are two of the cases when I want to delete something from SSMS Connect Screen: 1) Incorrect server name typed 2) Server does not require in the future. When I see a name of the server which is there for a long time and I know that I am not going to use it, I feel like deleting it right away so I do not have to see it again. In SQL Server... - [SQL SERVER - Get High Availability with SQL Server 2012](https://blog.sqlauthority.com/2013/04/16/sql-server-get-high-availability-with-sql-server-2012/): The SQL Server 2012 offers a plethora of solutions for high-availability that assures 99.999% server and database Availability. These solutions enhance database and server availability, hide the failures of software or hardware and maintain application availability to curtail user downtime. It simplifies management and deployment of high availability systems with incorporated monitoring and configuration tools. It also enhances performance and cost efficiency of IT utilizing up to four Active Secondary. An SQL Server 2012 High Availability course helps you develop capabilities that contribute in taking your career to new horizons. Some of the key capabilities are utilizing standby hardware to the fullest, implementing disaster recovery and high availability and raising the total application uptime significantly. - [SQLAuthority News - Excellent Experience at TechEd India 2013 Bangalore and Pune - Photo Journey](https://blog.sqlauthority.com/2013/04/15/sqlauthority-news-excellent-experience-at-teched-india-2013-bangalore-and-pune-photo-journey/): TechEd is the premier event from Microsoft and it is always pleasure to be part of the TechEd. This year I attended my fifth TechEd and I had presented at this event 4th time in the row. Presenting at TechEd is fun as there is a totally different level of pressure when presenting at this event. This year TechEd India was in two cities and it was double the fun. TechEd Bangalore was on 18-19 March, 2013 and TechEd Pune was on March 25-26, 2013. I had presented 2 sessions at both the cities, total 4 presentation in TechEd India 2013.... - [SQL SERVER - Tricks for Row Offset and Paging in Various Versions of SQL Server](https://blog.sqlauthority.com/2013/04/14/sql-server-tricks-for-row-offset-and-paging-in-various-versions-of-sql-server/): Paging is one of the most needed tasks when developers are developing applications. SQL Server has introduced various features of SQL Server 2000 to the latest version of SQL Server 2012. Here is the blog post which I wrote which demonstrates how SQL Server Row Offset and Paging works in various versions of the SQL Server. Instead of giving the generic algorithm, I have used AdventureWorks database and build a script. This will give you better control over your data if you have installed the AdventureWorks database and you can play around with various parameters. The goal is to retrieve row... - [SQL SERVER - Weekly Series - Memory Lane - #024](https://blog.sqlauthority.com/2013/04/13/sql-server-weekly-series-memory-lane-024/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Search Text Field – CHARINDEX vs PATINDEX Both functions take two arguments. With PATINDEX, you must include percent signs before and after the pattern, unless you are looking for the pattern as the first (omit the first %) or last (omit the last %) characters... - [SQLAuthority News - HP Project Moonshot Interchangeable and Interlockable Servers with Elastically Scale NuoDB](https://blog.sqlauthority.com/2013/04/12/sqlauthority-news-hp-project-moonshot-interchangeable-and-interlockable-servers-with-elastically-scale-nuodb/): HP has recently released a new product called Project Moonshot.  For anyone interested in databases, server systems, or cloud computing, the description of this new option was intriguing.  On its most basic level, Project Moonshot is a scalable server system, available in small units that are easy to enlarge and can run a variety of databases and clouds – anything you can think up. Update: Don’t forget to scroll all the way down and read call for action. I value your opinion about NuoDB. Basics of Project Moonshot Here are the basics:  Moonshot consists of interchangeable and interlockable servers that are much... - [SQLAuthority News - World's Largest IT Training Center](https://blog.sqlauthority.com/2013/04/11/sqlauthority-news-worlds-largest-training-center/): My friend houses the world's largest IT training center . It comprises over 50 classrooms for imparting training as well as more than 26 hi-tech testing stations. There are also four other campuses throughout India, as well as a center in Dubai, to best suit all the students, no matter where they are. Every campus boasts the same high standards, facilities, and amenities. Let us talk about world's largest IT training center. - [SQL SERVER - Enable SQLCMD Mode in SSMS - SQL in Sixty Seconds #048](https://blog.sqlauthority.com/2013/04/10/sql-server-enable-sqlcmd-mode-in-ssms-sql-in-sixty-seconds-048/): The sqlcmd utility is a command-line utility for ad hoc, interactive execution of Transact-SQL statements and scripts and for automating Transact-SQL scripting tasks. Often a developer believes that sqlcmd works with only command prompt, however that is not true. sqlcmd can also work with SQL Server Management Studio. There are lots of cool tricks we can do with sqlcmd while we are using it along with T-SQL. - [SQL SERVER - Fix : Error: 217 Implicit conversion from data type datetime to int is not allowed.](https://blog.sqlauthority.com/2013/04/09/sql-server-fix-error-217-implicit-conversion-from-data-type-datetime-to-int-is-not-allowed-use-the-convert-function-to-run-this-query/): Just a day before I was working on some query and faced this error. As soon as I receive this, I realized that what I had done wrong and what I needed to fix. The suggestion demonstrated in the error message is to the point and accurate. Let us learn how to fix error 217 for Implicit conversion. - [SQL SERVER - The procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.](https://blog.sqlauthority.com/2013/04/08/sql-server-the-procedure-attempted-to-return-a-status-of-null-which-is-not-allowed-a-status-of-0-will-be-returned-instead/): Here is one of the very common question I receive on SQLAuthority Facebook page. I usually answer them on Facebook but this one I find it very interesting so I decided to answer here. “There are few of the stored procedure when I try to execute they return following message. Would you please explain what does it mean and is it alright to receive them? The procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.” Very interesting question and before I explore it further let us answer execute following stored procedure.... - [SQL SERVER - T-SQL Errors and Reactions - Demo - SQL in Sixty Seconds #005 - Video](https://blog.sqlauthority.com/2012/03/07/sql-server-t-sql-errors-and-reactions-demo-sql-in-sixty-seconds-005-video/): We got tremendous response to video of Error and Reaction of SQL in Sixty Seconds #002. We all have idea how SQL Server reacts when it encounters T-SQL Error. Today Rick explains the same in quick seconds. After watching this I felt confident to answer talk about SQL Server’s reaction to Error. We received many request to follow up video of the earlier video. Many requested T-SQL demo of the concept. In today’s SQL in Sixty Seconds Rick Morelan has presented T-SQL demo of very visual reach concept of SQL Server Errors and Reaction. [youtube=http://www.youtube.com/watch?v=X19KQgxEt7g] More on Errors: Explanation of TRY…CATCH and... - [SQLAuthority News - TechED India 2012 - Bangalore - March 21-23, 2012](https://blog.sqlauthority.com/2012/03/06/sqlauthority-news-teched-india-2012-bangalore-march-21-23-2012/): TechEd is one event which every developers and IT professionals are looking forward to attend. It is opportunity of life time and no matter how many time one gets chance to engage with it, it is never enough. I still remember every single moment of every TechEd I have attended so far. This year TechEd India 2012 will be held in Bangalore between March 21 and 23. There will be three 3 days of lots of learning and fun. If you are data professional, you are going to find yourself very very fortunate as every single day we will have data... - [Data Integration - Top 10 "Ease of Use" Features of expressor Studio](https://blog.sqlauthority.com/2012/03/05/data-integration-top-10-ease-use-features-expressor-studio/): expressor Studio is a new data integration platform that is being marketed as the most easy to use tools of its kind. But “easy to use” can be a relative term – an expert can find a very complex system easier, but a beginner might be stumped. A recent article online discussed exactly what makes expressor Studio so easy use, and here is my view on this subject. - [SQL SERVER - Technical Reference Guides for Designing Mission-Critical Solutions](https://blog.sqlauthority.com/2012/03/04/sql-server-technical-reference-guides-for-designing-mission-critical-solutions-a-must-read/): Yesterday I was reading architecture reference material helping my friend who was looking for material in this respect. While working together we were searching twitter, facebook and search engines to find relevant material.While searching online we end up on very interactive reference point. Once I send the same to him, he replied he may not need anything more after referencing this material. Let's learn about Designing Mission-Critical Solutions in this blog post. - [SQL SERVER - Various Leap Year Logics](https://blog.sqlauthority.com/2012/03/03/sql-server-various-leap-year-logics/): Earlier I wrote one article on Leap Year and created one video about Leap Year. My point of view was to demonstrate how we can use SQL Server 2012 features to identify Leap year. How ever during the conversation I had some really good conversation. Here are updates for those who have missed reading the excellent comments on the blog. Incorrect Logic There are so many people still think Leap Year is the event which is consistently happening at every four year and the way to find it is divide the year with 4 and if the remainder is 0. That... - [SQL SERVER - Logon Trigger Feature for Managing Data Access](https://blog.sqlauthority.com/2012/03/02/sql-server-safepeak-logon-trigger-feature-for-managing-data-access/): This blog post is about SafePeak "Logon Trigger” Feature for Managing Data Access. Just a quick update the product is no longer available. - [SQLAuthority News - The Best Quotes of "Who Wrote This?" Contest](https://blog.sqlauthority.com/2012/03/01/sqlauthority-news-the-best-quotes-of-who-wrote-this-contest/): I am a frequent reader of Brent Ozar PLF, it is one of my favorite blogs. A recent post announced a “Who Wrote This?” contest to see if readers could tell their three contributors apart based on some writing samples. Here are my favorite lines from the sample paragraphs, from each of the three “mystery authors.” Topic 1: Working with Bad Managers Mystery Author A – “Working with bad managers means working against my own happiness, and I’ve come to learn that there’s no changing bad managers.” I love this line because, as anyone who has had a bad manager knows,... - [SQL SERVER - Function: Is Function - SQL in Sixty Seconds #004 - Video](https://blog.sqlauthority.com/2012/02/29/sql-server-function-is-function-sql-in-sixty-seconds-004-video/): Today is February 29th. An unique date which we only get to observe once every four year. Year 2012 is leap year and SQL Server 2012 is also releasing this year. Yesterday I wrote an article where we have seen observed how using four different function we can create another function which can accurately validate if any year is leap year or not. We will use three functions newly introduced in SQL Server 2012 and demonstrate how we can find if any year is leap year or not. This function uses three of the SQL Server 2012 functions – IIF, EOMONTH and... - [SQL SERVER - Detecting Leap Year in T-SQL using SQL Server 2012 - IIF, EOMONTH and CONCAT Function](https://blog.sqlauthority.com/2012/02/28/sql-server-detecting-leap-year-in-t-sql-using-sql-server-2012-iif-eomonth-and-concat-function/): Note: Tomorrow is February 29th. This blog post is dedicated to coming tomorrow – a special day :) Subu: “How can I find leap year in using SQL Server 2012?“ Pinal: “Are you asking me how to year 2012 is leap year using T-SQL – search online and you will find many example of the same.” Subu: “No. I am asking – How can I find leap year in using SQL Server 2012?“ Pinal: “Oh so you are asking – How can I find leap year in using SQL Server 2012?“ Subu: “Yeah – How can I find leap year in using SQL... - [SQL SERVER - Identifying Guest User using Policy Based Management](https://blog.sqlauthority.com/2012/02/27/sql-server-identifying-guest-user-using-policy-based-management/): If you are following my recent blog posts, you may have noticed that I’ve written a lot about Guest User in SQL Server. Here are all the blog posts which I have written on Policy Based Management subject. One of the requests I received was whether we could create a policy that would prevent users unable guest user in user databases. Well, here is a quick tutorial to answer this. Let us see how quickly we can do it. - [SQL SERVER - Standards Support, Protocol, Data Portability](https://blog.sqlauthority.com/2012/02/26/sql-server-standards-support-protocol-data-portability-3-important-sql-server-documentations-for-downloads/): Let us read more about Standards Support, Protocol, Data Portability. Sometimes I read easy things and sometimes not so easy. - [SQL SERVER - A Cool Trick - Restoring the Default SQL Server Management Studio - SSMS](https://blog.sqlauthority.com/2012/02/25/sql-server-a-cool-trick-restoring-the-default-sql-server-management-studio-ssms/): “I do not know where my windows went!” “I just closed my object explorer and now I cannot find it.” “How do I get my original windows layout back in SQL Server Management Studio?” “How do I get the window which was there in left side back again?” Since last 2-3 years, every single day I receive more than 5 emails on SSMS and its layout. For the beginners it is very common to get confused when they attempt to change SQL Server Management Studio’s windows layout. They often change the layout and are not able to get the original layout... - [SQL SERVER - guest User and MSDB Database - Enable guest User on MSDB Database](https://blog.sqlauthority.com/2012/02/24/sql-server-guest-user-and-msdb-database-enable-guest-user-on-msdb-database/): I have written a few articles recently on the subject of guest account and MSDB Database. Here’s a quick list of these articles: SQL SERVER – Disable Guest Account – Serious Security Issue SQL SERVER – Force Removing User from Database – Fix: Error: Could not drop login ‘test’ as the user is currently logged in. SQL SERVER – Detecting guest User Permissions – guest User Access Status - [SQL SERVER - Detecting guest User Permissions - guest User Access Status](https://blog.sqlauthority.com/2012/02/23/sql-server-detecting-guest-user-permissions-guest-user-access-status/): Earlier I wrote the blog post SQL SERVER – Disable Guest Account – Serious Security Issue, and I got many comments asking questions related to the guest user. Here are the comments of Manoj: 1) How do we know if the uest user is enabled or disabled? 2) What is the default for guest user in SQL Server? Default settings for guest user When SQL Server is installed by default, the guest user is disabled for security reasons. If the guest user is not properly configured, it can create a major security issue. You can read more about this here. Identify guest user status There... - [SQL SERVER - T-SQL Constructs - Declaration and Initialization - SQL in Sixty Seconds #003 - Video](https://blog.sqlauthority.com/2012/02/22/sql-server-t-sql-constructs-declaration-and-initialization-sql-in-sixty-seconds-003-video/): We got tremendous response to our very first video of SQL in Sixty Seconds #001 and SQL in Sixty Seconds #002. We talked about how to convert Subquery to CTE and Error and Reaction. My co-authors Vinod Kumar and Rick Morelan, we often came across very interesting and useful tips which we believe would be helpful to readers. In today’s SQL in Sixty Seconds Vinod Kumar has presented very visual reach concept of SQL Server. T-SQL has many enhancements which are less explored. In this quick video we learn how T-SQL Constructions works. We will explore Declaration and Initialization of T-SQL Constructions. We can... - [SQL SERVER - Force Removing User from Database - Fix: Error: Could not drop login 'test'](https://blog.sqlauthority.com/2012/02/21/sql-server-force-removing-user-from-database-fix-error-could-not-drop-login-test-as-the-user-is-currently-logged-in/): Yesterday I wrote a blog post discussing how the guest user can become a security threat. The script which was demonstrated in the example had a small T-SQL query which creates a new user. Later, I got an email from a user who had created this scenario on his production environment. It makes me sad that I had clearly talked multiple times about how to execute this as a trial on a development server or a test server, but NOT on a production server. Anyway, here is the email about the Force Removing User. - [SQL SERVER - Disable Guest Account - Serious Security Issue](https://blog.sqlauthority.com/2012/02/20/sql-server-disable-guest-account-serious-security-issue/): “No Guests PLEASE!” “Doesn’t your Indian tradition suggest welcoming guests and treating them in the best way possible?” “Yes, but I am talking about the Guest user in SQL Server.” “Oh!” This was a real conversation that happened a couple of years ago. I welcome guests as much as any other Indian does; however, I am strongly opinionated about guest user in SQL Server. I like to keep it disabled unless there is a special need of it. If there is some persistent need of a guest user, I suggest to create separate account. Again, there are always special cases where there is a need... - [SQL SERVER - Migration Assistant for Oracle, MySQL, Sybase and Access v5.2](https://blog.sqlauthority.com/2012/02/19/sql-server-migration-assistant-for-oracle-mysql-sybase-and-access-v5-2/): Migration is always the challenge, it does not matter if people are migrating from one country to another country or birds are migrating from one continent to another continent or database is migrating from one platform to another platform. I remember years ago when I had to migrate our database from another platform to SQL Server, I was extremely scared but as time passed by I learned that migration is not difficult as it seems. Of course there are challenges but there are tools available to make the migration much easier than it seems. SQL Server Migration Assistant (SSMA) is a free supported tool... - [SQL SERVER - Case Sensitive Database and Database User - Fix: Error: 15151 - Cannot find the user , because it does not exist or you do not have permission.](https://blog.sqlauthority.com/2012/02/18/sql-server-case-sensitive-database-and-database-user-fix-error-15151-cannot-find-the-user-because-it-does-not-exist-or-you-do-not-have-permission/): Jeff asked me another question! If you do not know Jeff, you may read the following blog posts. You will get the idea of Jeff’s personality and who Jeff really is. SQL SERVER – Installation Log Summary File Location – 2012 – 2008 R2 SQL SERVER – INNER JOIN Returning More Records than Exists in Table This time, he sent me a screenshot. He was facing a very strange error. As his screenshot had confidential details, I created my own images which exactly simulate his issue for demonstration’s sake. Here are the partial details of his email. Please note that I... - [SQL SERVER - Solution Part 2 - A Quick Puzzle on SQL JOIN and NULL - SQL Brain Teaser](https://blog.sqlauthority.com/2012/02/17/sql-server-solution-part-2-a-quick-puzzle-on-join-and-null-sql-brain-teaser/): Some questions are timeless and they never grow old; no matter how much they grow old their interest never dies. Earlier, I asked a simple puzzle based on a conversation on SQLAuthority Page, and have received an overwhelming response from readers. I still get emails related to this puzzle every day. Let us see a quick puzzle between SQL Join and SQL Null. - [SQL SERVER - Be Different - Be Leader - An Interactive Journey - Questions and Answers - Book and Video](https://blog.sqlauthority.com/2012/02/16/sql-server-be-different-be-leader-an-interactive-journey-questions-and-answers-book-and-video/): This is a true story. My wife and my daughter were playing in the play area in our resident complex. I was sitting a ways off and was watching them play various games. My daughter likes the slides a lot. Suddenly, one kid started to climb the slide from the slide instead of the stairs. There were a few kids on the slide already and naturally a collision happened. Kids are kids and they moved on (I wish adults could be like that more often). After a few minutes the same routine repeated. The kid was attempting to go from the... - [SQL SERVER - T-SQL Errors and Reactions - SQL in Sixty Seconds #002 - Video](https://blog.sqlauthority.com/2012/02/15/sql-server-t-sql-errors-and-reactions-sql-in-sixty-seconds-002-video/): We got tremendous response to our very first video of SQL in Sixty Seconds #001. We talked about how to convert Subquery to CTE very quickly. My co-authors Vinod Kumar and Rick Morelan, we often came across very interesting and useful tips which we believe would be helpful to readers. In today’s SQL in Sixty Seconds Rick Morelan has presented very visual reach concept of SQL Server. We all have idea how SQL Server reacts when it encounters T-SQL Error. Today Rick explains the same in quick seconds. When I personally watched this video, I suddenly felt that this is great... - [SQL SERVER - What is Big Data - An Explanation in Simple Words](https://blog.sqlauthority.com/2012/02/14/sql-server-what-is-big-data-an-explanation-in-simple-words/): Let us start with a very interesting quote for Big Data. Decoding the human genome originally took 10 years to process; now it can be achieved in one week - The Economist. This blog post is written in response to the T-SQL Tuesday post of The Big Data. This is a very interesting subject. Data is growing every single day. I remember my first computer which had 1 GB of the Hard Drive. I had told my dad that I will never need any more hard drive, we are good for next 10 years. I bought much larger Harddrive over 2 years and today I have a NAS at home, which can hold 2 TB and have few file hosting in the cloud as well. Well the point is, the amount of the data any individual deals with has increased significantly. - [SQL SERVER - Building Interactive Reports in Quick Moments - From CSV to Excel Pivot Table - A Conversation turned to Webinar](https://blog.sqlauthority.com/2012/02/13/sql-server-building-interactive-reports-in-quick-moments-from-csv-to-excel-pivot-table-a-conversation-turned-to-webinar/): “I have text files and I need to create interactive reports for my boss – do you have few minutes of time right now? Let us discuss.” I often get questions from people who are new to technology and struggling to get something done. However, this time it was not a question from any beginner. This question was from an expert – a friend and an excellent technologist. Wiqar and I have known each other for a long time and often discuss various technologies. He works at expressor Technologies  as a product manager and has built the complete product using .NET... - [SQLAuthority News - Business Intelligence features of SQL Server 2012 RC0 - Download Virtual Machine](https://blog.sqlauthority.com/2012/02/12/sqlauthority-news-business-intelligence-features-of-sql-server-2012-rc0-download-virtual-machine/): I am in front of computer 16+ hours of the day. However, I accept that I am bit lazy when it is about doing installation etc. I always prefer that IT department help me to install my computer and I use it right away. Same feeling I get when I have to install Beta, RC or any other version in my computer. I prefer virtual machines for the same. Again, I do not like to prepare virtual machines. Now following news is very exciting. As I Microsoft has prepared virtual machine for all of us using all essential Business Intelligence features... - [SQL SERVER - Solution - A Quick Puzzle on JOIN and NULL - SQL Brain Teaser](https://blog.sqlauthority.com/2012/02/11/sql-server-solution-a-quick-puzzle-on-join-and-null-sql-brain-teaser/): Yesterday was really fun. I asked a simple Brain Teaser and we had excellent conversation on SQLAuthority Page as well SQL SERVER – A Quick Puzzle on JOIN and NULL – SQL Brain Teaser. That was an easy puzzle for those who have attended the SQL Server Questions and Answers online course. Here is a quick recap of the puzzle. Lots of people said it is a very easy puzzle, but the correct answer was provided by only a few readers. There were lots of conversation on Facebook page and lots of emails I received, many saying that there was some sort of an error in the... - [SQL SERVER - A Quick Puzzle on JOIN and NULL - SQL Brain Teaser](https://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/): It seems that we all love to solve puzzles. On SQLAuthority Page, we have been playing the number game and those who are playing with us know how much fun we are having. Sometimes, the answers are so innovative and informative that they open up those aspects of the technology which I have not thought of. Today, I have a very relaxing puzzle and a SQL Brain Teaser for all of you. It is based on my earlier blog post on INNER JOIN and NULL, so I suggest reading the said post first if you want to get the complete idea. - [SQL SERVER - INNER JOIN Returning More Records than Exists in Table](https://blog.sqlauthority.com/2012/02/09/sql-server-inner-join-returning-more-records-than-exists-in-table/): I blog and engage with the community because it gives me satisfaction when someone resolves an issue. A few days ago, I blogged about a DBA who began his first day at a new company and could not find out where the installation summary file was. He was very happy when I featured his story on our blog. Today he asked me another question and when I received his question my first reaction was – not possible. Later I said, may be possible, and when he shared more information, I said of course it is possible and natural. Let us go... - [SQL SERVER - Convert Subquery to CTE - SQL in Sixty Seconds #001 - Video](https://blog.sqlauthority.com/2012/02/08/sql-server-convert-subquery-to-cte-sql-in-sixty-seconds-001-video/): SQL Server is an ocean of information. I believe if one starts learning today, after 60 years he/she may still be learning the subject (there are always a few exceptions)! Recently, I published the SQL Server Questions and Answers video tutorial, and since the course came out, I have been receiving lots of request to share SQL Tips which are small and easy to digest. While writing the SQL books with my co-authors Vinod Kumar and Rick Morelan, we often came across very interesting and useful tips which we believe would be helpful to readers. Sometimes the tips are so small... - [SQL SERVER - Installation Log Summary File Location - 2012 - 2008 R2](https://blog.sqlauthority.com/2012/02/07/sql-server-installation-log-summary-file-location-2012-2008-r2/): Here is email received from user: “Pinal, I am new DBA in my organization and I have to manage SQL Server 2005, 2008 and 2008 R2. Today is my first day at job and my manager has asked me to install all these different edition on our test environment. I have finished installing them. Later he has asked me provide him Installation Log Summary. I searched on internet and I could not find it, would you send me format of the installation log summary?” I like this question, even though it is very simple, it demonstrates how new job can be... - [SQL SERVER - ERROR: FIX - Database diagram support objects cannot be installed](https://blog.sqlauthority.com/2012/02/06/sql-server-error-fix-database-diagram-support-objects-cannot-be-installed-because-this-database-does-not-have-a-valid-owner/): Recently, one of my friends sent me email that he is having some problem with his very small database. We talked for a few minutes and we agreed that to further investigation, I will need access to the whole database. As the database was very big he dropped it in a common location. Let us learn about error Database diagram support objects cannot be installed because this database does not have a valid owner. - [SQLAuthority News - Microsoft SQL Server AlwaysOn Solutions Guide for High Availability and Disaster Recovery](https://blog.sqlauthority.com/2012/02/05/sqlauthority-news-microsoft-sql-server-alwayson-solutions-guide-for-high-availability-and-disaster-recovery/): SQL Server 2012 is has very exciting new feature of SQL Server AlwaysOn. This new feature reduces planned and unplanned downtime and maximize application available. Additionally it provides data protection keeping database always available. Microsoft has released a whitepaper on this subject where it discusses common context business stakeholders, technical decision makers, system architects, infrastructure engineers, and database administrators. This whitepaper discusses two major points. Following is the abstract from book online: High Availability and Disaster Recovery Concepts. Provide a brief discussion of the drivers and challenges of planning, managing, and measuring the business objectives of a highly available database environment.... - [SQL SERVER - Finding Count of Logical CPU using T-SQL Script - Identify Virtual Processors](https://blog.sqlauthority.com/2012/02/04/sql-server-finding-count-of-logical-cpu-using-t-sql-script-identify-virtual-processors/): I recently received email from one of my very close friend from California. His question was very interesting. He wanted to know how many virtual processors are there available for SQL Server. He already had script for SQL Server 2008 but was mainly looking for SQL Server 2000. He made me go to my past. I found following script from my old emails (I have no reference listed along with it, so not sure the original source). - [SQLAuthority News - An Incredible Successful SQL Saturday #116 Event - First SQL Saturday in India](https://blog.sqlauthority.com/2012/02/03/sqlauthority-news-an-incredible-successful-sql-saturday-116-event-first-sql-saturday-in-india/): We have recently wrapped up our most recent event, SQL Saturday #116, and I am I am sure I am not alone in reporting that it was a huge success!  We had a full crowd – every seat taken, plus standing-room-only in the back.  We also had a lot of good feedback and the crowd was definitely involved and engaged, so I think it was an all-around success. Given the success of our UG meetings in Bangalore, this year we tried to accommodate even more people by hosting two technical tracks at the same event.  I think this plan worked out... - [SQL SERVER - An Inspiring Personal Story - Movie from The Book - Video Course - SQL Server Questions and Answers - Pluralsight](https://blog.sqlauthority.com/2012/02/02/sql-server-an-inspiring-personal-story-movie-from-the-book-video-course-sql-server-questions-and-answers-pluralsight/): Nov 3, 2011 – Visit to Grandma When our SQL Server Interview Questions and Answers book got published I ran to my grandma with a copy of the book for her blessings. Well, just like every grandma, she loves me, her grandson, unconditionally. She is not into the technology domain (obviously), but she loved the book. She read the first few pages where I was mentioned and read about my co-author Vinod Kumar. After reading the introduction she looked at me and said “When I was young we used to read books, now all those good books are converted into the movies, when do you... - [SQL SERVER - What is Slowly Changing Dimension - Quiz - Puzzle - 31 of 31](https://blog.sqlauthority.com/2012/02/01/sql-server-what-is-slowly-changing-dimension-quiz-puzzle-31-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Advantages of Partitioning - Quiz - Puzzle - 30 of 31](https://blog.sqlauthority.com/2012/01/31/sql-server-advantages-of-partitioning-quiz-puzzle-30-of-31/): The year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author's Perspective. Let us see the puzzle of Advantages of Partitioning.  - [SQL SERVER - Data Collector Usage - Quiz - Puzzle - 29 of 31](https://blog.sqlauthority.com/2012/01/30/sql-server-data-collector-usage-quiz-puzzle-29-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Reclaiming Space Back from Database - Quiz - Puzzle - 28 of 31](https://blog.sqlauthority.com/2012/01/29/sql-server-reclaiming-space-back-from-database-quiz-puzzle-28-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Lots of Date Functions - Find Right One to Use - Quiz - Puzzle - 27 of 31](https://blog.sqlauthority.com/2012/01/28/sql-server-lots-of-date-functions-find-right-one-to-use-quiz-puzzle-27-of-31/): The year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author's Perspective. Let us see a puzzle on date functions. - [SQL SERVER - Common Gotcha's Associated with Common Table Expressions (CTE) - Quiz - Puzzle - 26 of 31](https://blog.sqlauthority.com/2012/01/27/sql-server-common-gotchas-associated-with-common-table-expressions-cte-quiz-puzzle-26-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQLAuthority News - Interview with Book Authors after 2 Months of Book Released](https://blog.sqlauthority.com/2012/01/26/sqlauthority-news-interview-with-book-authors-after-2-months-of-book-released/): Community is the most motivating force for me. I have often found situations where I have done more and better things because there was community around me. My latest book SQL Server Interview Questions and Answers is the result of the community’s support and love. Without the wide acceptance of the community I would have never reached where I am. Thank you! Recently, the kind folks of INETA APAC – Sanjay Shetty and Raj Chaudhuri – conducted an interview with myself and Vinod Kumar (co-author of my book). We had lots of fun during the interview. Sanjay asks questions which, even... - [SQL SERVER - Different Aspect of Policy Based Management - Quiz - Puzzle - 25 of 31](https://blog.sqlauthority.com/2012/01/26/sql-server-different-aspect-of-policy-based-management-quiz-puzzle-25-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Correct Value for Fillfactor - Quiz - Puzzle - 24 of 31](https://blog.sqlauthority.com/2012/01/25/sql-server-correct-value-for-fillfactor-quiz-puzzle-24-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Database Mirroring and Fine-Prints - Quiz - Puzzle - 23 of 31](https://blog.sqlauthority.com/2012/01/24/sql-server-database-mirroring-and-fine-prints-quiz-puzzle-23-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - What is Piecemeal Restore - Quiz - Puzzle - 22 of 31](https://blog.sqlauthority.com/2012/01/23/sql-server-what-is-piecemeal-restore-quiz-puzzle-22-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Difference between Create Index - Drop Index - Rebuild Index - Quiz - Puzzle - 21 of 31](https://blog.sqlauthority.com/2012/01/22/sql-server-difference-between-create-index-drop-index-rebuild-index-quiz-puzzle-21-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Methods for Accessing SQL Server XML Datatype - Quiz - Puzzle - 20 of 31](https://blog.sqlauthority.com/2012/01/21/sql-server-methods-for-accessing-sql-server-xml-datatype-quiz-puzzle-20-of-31/): In this blog post, we will learn about methods for accessing SQL Server XML DataType. Here is an article which discusses the Author's Perspective. - [SQL SERVER - MERGE or INSERT, UPDATE, DELETE - Quiz - Puzzle - 19 of 31](https://blog.sqlauthority.com/2012/01/20/sql-server-merge-or-insert-update-delete-quiz-puzzle-19-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Importance of Resource Database - Quiz - Puzzle - 18 of 31](https://blog.sqlauthority.com/2012/01/19/sql-server-importance-of-resource-database-quiz-puzzle-18-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Various Ways to Create Constraints - Quiz - Puzzle - 17 of 31](https://blog.sqlauthority.com/2012/01/18/sql-server-various-ways-to-create-constraints-quiz-puzzle-17-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - CHECKPOINT Behavior and Database Recovery Models - Quiz - Puzzle - 16 of 31](https://blog.sqlauthority.com/2012/01/17/sql-server-checkpoint-behavior-and-database-recovery-models-quiz-puzzle-16-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Difference between CHAR, VARCHAR, NVARCHAR and VARCHAR(MAX) - Quiz - Puzzle - 15 of 31](https://blog.sqlauthority.com/2012/01/16/sql-server-difference-between-char-varchar-nvarchar-and-varcharmax-quiz-puzzle-15-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Using SafePeak to Accelerate Performance of 3rd Party Applications](https://blog.sqlauthority.com/2012/01/16/sql-server-using-safepeak-to-accelerate-performance-of-3rd-party-applications/): An exciting solution I found last year (2011) for SQL Server performance acceleration is SafePeak. Designed to specifically to accelerate and tune performance of cases where you have minimum control on the applications, like 3rd party line of business applications. SafePeak performs automated caching of queries and procedures results, returning with very high speed results from memory and reducing the SQL load by factor of 10. No code changes needed. And that is make it very interesting and appealing! One of the questions I hear many times concern performance acceleration of 3rd party applications applications that are critical to business function,... - [SQL SERVER - Cases When Stored Procedure RECOMPILE - Quiz - Puzzle - 14 of 31](https://blog.sqlauthority.com/2012/01/15/sql-server-cases-when-stored-procedure-recompile-quiz-puzzle-14-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Debate - Table Variables vs Temporary Tables - Quiz - Puzzle - 13 of 31](https://blog.sqlauthority.com/2012/01/14/sql-server-debate-table-variables-vs-temporary-tables-quiz-puzzle-13-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - DACPAC and SQL Azure - Quiz - Puzzle - 12 of 31](https://blog.sqlauthority.com/2012/01/13/sql-server-dacpac-and-sql-azure-quiz-puzzle-12-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - Non-Clustered Index and Automatic Rebuild - Quiz - Puzzle - 11 of 31](https://blog.sqlauthority.com/2012/01/12/sql-server-non-clustered-index-and-automatic-rebuild-quiz-puzzle-11-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The... - [SQL SERVER - A Quick Look at expressor Data Quality Solutions](https://blog.sqlauthority.com/2012/01/11/sql-server-a-quick-look-at-expressor-data-quality-solutions/): Last month I described the extension framework that allows one to easily add functionality to an expressor Studio installation.  I then used this added functionality – the input and output operators to SalesForce.com – to develop an example application.  But expressor has a second mechanism that allows you to easily enhance the functionality of your installation – reusable templates.  The idea behind this approach is that once you develop an operator that performs processing that could have value in other applications you convert this operator into a template that can be easily integrated into additional projects.  This is the approach expressor has followed... - [SQL SERVER - Reasons for Using Output Clause - Quiz - Puzzle - 10 of 31](https://blog.sqlauthority.com/2012/01/11/sql-server-reasons-for-using-output-clause-quiz-puzzle-10-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Locking, Blocking and Deadlock - Quiz - Puzzle - 9 of 31](https://blog.sqlauthority.com/2012/01/10/sql-server-locking-blocking-and-deadlock-quiz-puzzle-9-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Using RANKING Functions Instead of SQL Looping Logic of Cursor - Quiz - Puzzle - 8 of 31](https://blog.sqlauthority.com/2012/01/09/sql-server-using-ranking-functions-instead-of-sql-looping-logic-of-cursor-quiz-puzzle-8-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Indexed Views and Restrictions - Quiz - Puzzle - 7 of 31](https://blog.sqlauthority.com/2012/01/08/sql-server-indexed-views-and-restrictions-quiz-puzzle-7-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Collation and Collation Sensitivity - Quiz - Puzzle - 6 of 31](https://blog.sqlauthority.com/2012/01/07/sql-server-collation-and-collation-sensitivity-quiz-puzzle-6-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Locking and Blocking - Important Aspect of Database and Effect on Performance - Quiz - Puzzle - 5 of 31](https://blog.sqlauthority.com/2012/01/06/sql-server-locking-and-blocking-important-aspect-of-database-and-effect-on-performance-quiz-puzzle-5-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - An Important Part of Most SELECT statement - WHERE clause - Quiz - Puzzle - 4 of 31](https://blog.sqlauthority.com/2012/01/05/sql-server-an-important-part-of-most-select-statement-where-clause-quiz-puzzle-4-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQLAuthority News - I am Speaking at SQL Saturday 116 - Bangalore, India on January 7, 2012 - First SQL Saturday in India](https://blog.sqlauthority.com/2012/01/05/sqlauthority-news-i-am-speaking-at-sql-saturday-116-bangalore-india-on-january-7-2012-first-sql-saturday-in-india/): SQLSaturday 116 is now only 3 days away. SQL Saturday is FREE event all the attendees and 100% SQL community driven. This is very first SQL Saturday in India and I am very much excited that I will be speaking at this event on my favorite subject of SQL Server Performance Tuning. I have so far delivered 100s of presentation on this subject but this subject never gets old and I never ran out of new tips and tricks. I suggest you mark your calender right now and present at the hall before time to secure your seat. Session Details SQL... - [SQL SERVER - Understanding Identity Beyond its Every Increasing Nature - Quiz - Puzzle - 3 of 31](https://blog.sqlauthority.com/2012/01/04/sql-server-understanding-identity-beyond-its-every-increasing-nature-quiz-puzzle-3-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQLAuthority News - To Err is Human; to Forgive, Divine - Errata of SQL Server Interview Book](https://blog.sqlauthority.com/2012/01/04/sqlauthority-news-to-err-is-human-to-forgive-divine-errata-of-sql-server-interview-book/): Regular readers of my blog will know that I have written three books this year.  We are currently reviewing readers comments about SQL Server Interview Questions and Answers.  I am sorry to announce that we made a mistake but happy to add that we have corrected it. We will pay closer attention to the error and make sure that it does not happen again. Writing a book is a lengthy very interesting process. I have had an excellent experience in writing my recent book SQL Server Interview Questions and Answers; we had so much fun and few moments of stress, too.... - [SQL SERVER - Significance of Various Kinds of Triggers- Quiz - Puzzle - 2 of 31](https://blog.sqlauthority.com/2012/01/03/sql-server-significance-of-various-kinds-of-triggers-quiz-puzzle-2-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. Here is an article which discusses the Author’s Perspective. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL... - [SQL SERVER - Importance of ANSI ISOLATION Levels in SQL Server Database - Quiz - Puzzle - 1 of 31](https://blog.sqlauthority.com/2012/01/02/sql-server-importance-of-ansi-isolation-levels-in-sql-server-database-quiz-puzzle-1-of-31/): Click here to get free chapters (PDF) in the mailbox Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is the article which discusses Author’s Perspective. Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz.... - [SQL SERVER - Interview Questions and Answers - Perspectives of an Author](https://blog.sqlauthority.com/2012/01/01/sql-server-interview-questions-and-answers-perspectives-of-an-author/): Today is the first day of year 2012 - Happy New Year!. This blog post is written by my co-author of SQL Server Interview Questions. - [SQLAuthority News - An Year Worth Remembering and Looking Forward to Better Next Year](https://blog.sqlauthority.com/2011/12/31/sqlauthority-news-an-year-worth-remembering-and-looking-forward-to-better-next-year/): Year 2011 will be my favorite year for long time. I have achieved many personal milestones this year. I will list few things here today, which should keep me inspired next year to do even better. Here is my blog post which I have written for January 1, 2011 SQLAuthority News – Resolution for New Year 2011. Reduced Travel Last year I traveled to six new countries and traveled internationally 11 times. This year I traveled internationally only two times and to a single country – the USA. Additionally, I traveled much less domestically. The effect of less travel is spending... - [SQLAuthority News - A Quick History of Writing Three Books in Year 2011](https://blog.sqlauthority.com/2011/12/30/sqlauthority-news-a-quick-history-of-writing-three-books-in-year-2011/): This has been an eventful year for me. I write in various formats online and offline but becoming a published author of printed book was always my dream. Every day I write continuously. Here are few of the writing tasks I do in my everyday routine. I write – Emails I write nearly 400+ emails every day. I get about 1000 emails and 10s of thousands of spam e-mails. I am thankful that 99.99% of the spam is caught by spam filters. The remaining spam I report to my email provider. However, I still get over 1000 valid emails. I do... - [SQL SERVER - Year End Brain Teaser - Disabled Login and Associated User Without Disabled User Red Arrow](https://blog.sqlauthority.com/2011/12/29/sql-server-year-end-brain-teaser-disabled-login-and-associated-user-without-disabled-user-red-arrow/): I have received lots of good responses to the puzzles, quizzes and brain teasers posted on this blog post. As the year is ending, I have decided to give two interesting puzzles for you. The first one is easy and the second one is equally uncomplicated, but let us see if any of you can come up with a logical answer to it. Puzzle 1: Find “The Hidden Tiger” Find “The Hidden Tiger” in the following image created by American wildlife artist Rusty Rust. Just to give you a hint – there is already one tiger standing and looking at us.... - [SQL SERVER - Effect of Compressed Backup Setting at Server Level on Database Backup](https://blog.sqlauthority.com/2011/12/28/sql-server-effect-of-compressed-backup-setting-at-server-level-on-database-backup/): I recently received following question from reader. I would like to share the complete story in few short sentences with you to give you complete idea. Let us call the reader Margie. Our long email conversation is converted into chat like conversation Margie: Hi Pinal – I am seeing strange behavior with regards to my database backup. Pinal: What is the exact issue? Margie: I am taking database backup with following script for more than an year and my database is of always certain size. From last six days the size of the database backup is reduced big times. There is... - [SQL SERVER - Target Recovery Time of a Database - Advance Option in SQL Server 2012](https://blog.sqlauthority.com/2011/12/27/sql-server-target-recovery-time-of-a-database-advance-option-in-sql-server-2012/): Recently I was going over few advanced options of SQL Server 2012 in database properties and I found a new option in the property screen. Properties screen of SQL Server 2008 R2 Properties screen of SQL Server 2012 I got little curious and decided to learn what does this new feature indicates. When I started to learn more about this subject, I had excellent learning experience. The default value of this option is 0. This value is directly related to Checkpoint. When it is set to greater than 0 (zero) it uses indirect-checkpoints and establishes an upper-bound on recovery time for... - [SQL SERVER - Fix: Error: 15138 - The database principal owns a schema in the database, and cannot be dropped](https://blog.sqlauthority.com/2011/12/26/sql-server-fix-error-15138-the-database-principal-owns-a-schema-in-the-database-and-cannot-be-dropped/): Last day I had excellent fun asking puzzle on SQL Server Login SQL SERVER – Merry Christmas and Happy Holidays – Database Properties – Number of Users. One of the user sent me email asking urgent question about how to resolve following error. Reader was trying to remove the login from database but every single time he was getting error and was not able to remove the user. The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138) As per him it was very urgent and he was not able to solve the same.... - [SQL SERVER - Merry Christmas and Happy Holidays - Database Properties - Number of Users](https://blog.sqlauthority.com/2011/12/25/sql-server-merry-christmas-and-happy-holidays-database-properties-number-of-users/): First of all Merry Christmas and Happy Holidays to everybody. I wish you best holiday season. In today’s blog post – I am sharing very small question received by one of the reader. Though simple sometime a small question make people think. He sent me very similar to following image and asked few questions. As his image represented his server’s information, I am reproducing very similar image using AdventureWorks database. Question: What does the number of users signifies in database properties? Does this mean current connected users or total active users or total enabled users or what exactly?” Answer: Database Properties... - [SQL SERVER - A Simple Puzzle and Simple Solution of Datatype and Computed Column](https://blog.sqlauthority.com/2011/12/24/sql-server-a-simple-puzzle-and-simple-solution-of-datatype-and-computed-column/): Christmas is just near and happy holidays to all of you. Today is Christmas eve and I decided to share something very simple but interesting with you. Recently some one reading my SQL Server Interview Questions and Answers book asked me following question. “Pinal, Instead of puzzle, or difficult interview question, I was asked following riddle in my interview. I could not answer it, do you have any idea. Riddle: Create a table with two columns but you are allowed to specify datatypes only once. Additionally, write a mechanism that your data is copied from first column to second column without... - [SQL SERVER - A Quick Script for Point in Time Recovery - Back Up and Restore](https://blog.sqlauthority.com/2011/12/23/sql-server-a-quick-script-for-point-in-time-recovery-back-up-and-restore/): Blogging is like writing a big novel in parts. It has its own mood and it has its own colors. Someday I feel like writing philosophy and some day I like writing theory and some day just a script. Today is one of the day when I just feel like providing working script for user requested frequently. Here is one of the script which I refer whenever I faced situation about restoring the database at point in time. In this demo we will see three step operations: Set up script and backup database Restore the database in point in time Clean... - [SQL SERVER - Mastering the Basics - Igniting Learning - A Unique Learning Experience](https://blog.sqlauthority.com/2011/12/22/sql-server-mastering-the-basics-igniting-learning-a-unique-learning-experience/): I had very clear idea what my goals were in the book. I believed in unique learning experience. Let us talk about it in today's blog. - [SQL SERVER - A Quick Trick about SQL Server 2012 CONCAT Function - PRINT](https://blog.sqlauthority.com/2011/12/21/sql-server-a-quick-trick-about-sql-server-2012-concat-function-print/): Yesterday I posted A Quick Trick about SQL Server 2012 CONCAT function and the very first comment in few minutes of Vinod Kumar. He suggested that this function should be also used with the PRINT statement as well. While I was having conversation with him – Jacob Sebastian sent me message suggesting the same. As I got feedback in first 10 minutes of publishing the blog post – I decided to update the blog post. While I started to write there was an email from Rick Morelan suggesting that this function can be used along with PRINT statement. Alright – 3 SQL... - [SQL SERVER - A Quick Trick about SQL Server CONCAT function](https://blog.sqlauthority.com/2011/12/20/sql-server-a-quick-trick-about-sql-server-2012-concat-function/): Just a day before I was presenting at Virtual Tech Days and I wanted to demonstrate the current time to audience using SQL Server Management Studio, I ended up a quick error. If any of you ever tried to concat multiple values of different datatype this should not be surprise to you. - [SQLAuthority News - Introduction to expressor Connectivity to Salesforce - expressor Data Integration Applications](https://blog.sqlauthority.com/2011/12/19/sql-server-introduction-to-expressor-connectivity-to-salesforce-expressor-data-integration-applications/): This month, expressor software is releasing the newest version of their data integration product – expressor 3.5.  This release includes three significant enhancements to this powerful and adaptable product: an extensibility framework, integration with Melissa Data’s data quality tools, and operators to read from and write to Salesforce.com databases. As a proof of the usability of the extensibility framework, expressor implemented their Salesforce support through an extensibility library.  In the future, as this framework is used to implement more functionality, you will be able to add new features to your expressor deployment without needing to install a newer version of the... - [SQL SERVER - AdventureWorks for SQL Server 2012 RC0 - Samples Database for SQL Server 2012 RC0](https://blog.sqlauthority.com/2011/12/18/sql-server-adventure-works-for-sql-server-2012-rc0-samples-database-for-sql-server-2012-rc0/): Microsoft has just released AdventureWorks database for SQL Server 2012 RC0. I am very happy that now I will be able to play with this new sample database and base my various demo script around the same. Here is the link to download AdventureWorks 2012 RC0 database. - [SQL SERVER - FIX - ERROR : Msg 3201, Level 16 Cannot open backup device.Operating system error 3 (The system cannot find the path specified.)](https://blog.sqlauthority.com/2011/12/17/sql-server-fix-error-msg-3201-level-16-cannot-open-backup-device-operating-system-error-3-the-system-cannot-find-the-path-specified/): I had very interesting and frustrating experience. Recently I was attempting to backup one of my database and I end up on following error. Msg 3201, Level 16, State 1, Line 1 Cannot open backup device ‘D:\Backup\SQLAuthority.bak’. Operating system error 3(The system cannot find the path specified.). Msg 3013, Level 16, State 1, Line 1 BACKUP DATABASE is terminating abnormally. Solution: Go to your drive and create the missing folder. In my case I went to Drive D and created Backup Folder there. Additional Story: If you read the first line of the blog post you will read there that I... - [SQL SERVER - 2012 Auditing Enhancement - On Audit Log Failure Options - Maximum Rollover Files](https://blog.sqlauthority.com/2011/12/16/sql-server-2012-auditing-enhancement-on-audit-log-failure-options-maximum-rollover-files/): Recently I was exploring SQL Server Audit and found something very interesting. I found two enhancements in the SQL Server 2008 Create Audit Screen. SQL Server 2012 Create Audit Screen SQL Server 2008 Create Audit Screen On Audit Log Failure Options You can see that in SQL Server 2012 they have added two more options for audit log failure. In earlier version the only option was to shut down the server when there was audit log failure. Now you can fail the operation as well continue on log failure. This new options now give finer control on the behavior of the... - [SQLAuthority News - Online Session Practical Tricks and Tips to Speed up Database Queries Today](https://blog.sqlauthority.com/2011/12/15/sqlauthority-news-online-session-practical-tricks-and-tips-to-speed-up-database-queries-today/): I am presenting on performance tuning topic again today at Virtual Tech Days. This time I am going to talk about lots of practical tips and will focus on what we can do immediately right after the session is over. During the session I have two things for you to spot. How many times, I say word “performance”? How many times, I use the phrase “It is interesting to …”? Let us see if you can tell me after the session the count. Trust me, I am not going to count there as I will be presenting so I let you... - [SQL SERVER - Explain Error:166 : does not allow specifying the database name as a prefix to the object name - Puzzle to Win SQL Server Interview Questions and Answers Book](https://blog.sqlauthority.com/2011/12/14/sql-server-explain-error166-does-not-allow-specifying-the-database-name-as-a-prefix-to-the-object-name-puzzle-to-win-sql-server-interview-questions-and-answers-book/): I was recently reading excellent Just Learned Tip regarding 3 part naming Cannot be used when dropping Views,Functions or Procedures. This is quite a well known tip however, every developer and DBA learns at sometime in their career with ‘hm…’ moment. To illustrate this further here is a simple case scenario. Setup environment CREATE DATABASE TestDB GO USE TestDB GO CREATE TABLE TestTable (ID INT) GO CREATE PROCEDURE TestSP AS SELECT 1 Col GO Drop Table The drop table will works and gives success message. DROP TABLE TestDB.dbo.TestTable GO Drop Procedure The drop procedure will give following error. DROP PROCEDURE TestDB.dbo.TestSP... - [SQL SERVER - A Quick Look at Performance - A Quick Look at Configuration](https://blog.sqlauthority.com/2011/12/13/sql-server-a-quick-look-at-performance-a-quick-look-at-configuration/): This blog post is written in response to the T-SQL Tuesday post of Tips and Tricks. For me, this is a very interesting subject. I perfectly enjoy a discussion when it is about performance tuning. I commonly get follow-up questions regarding this subject, but most of them do not give the complete information about their environment. Whenever I get a question which does not have complete information but is obviously requesting for my help, my initial reaction is to ask more questions. When I ask more details, I usually get more questions from them rather than the details I was asking... - [SQLAuthority News - Virtual Presentation on Practical Tricks and Tips to Speed up Database Queries - December 15, 2011](https://blog.sqlauthority.com/2011/12/12/sqlauthority-news-virtual-presentation-on-practical-tricks-and-tips-to-speed-up-database-queries-december-15-2011/): Performance tuning has been my favorite subject and any time when I have to present on this subject, this itself gives me tremendous pleasure as well. I am always excited to present something new on this topic. Virtual Tech Days is just here around the corner and I am going to present about performance tuning subject once again. However, I am going to focus that instead of theory, I will talk about the practical aspect of the performance tuning and share tips which one can use right away. Sessions Details Title: Practical Tricks and Tips to Speed up Database Queries Timing:... - [SQL SERVER - Fix: Error: Msg 1904, Level 16 The statistics on table has 33 column names in statistics key list. The maximum limit for index or statistics key column list is 32](https://blog.sqlauthority.com/2011/12/11/sql-server-fix-error-msg-1904-level-16-the-statistics-on-table-has-33-column-names-in-statistics-key-list-the-maximum-limit-for-index-or-statistics-key-column-list-is-32/): Earlier I wrote an article where I demonstrated that an index with more than 16 column is not possible. Here is the link to the article. After reading the same article I received email from user suggesting does it mean that statistics can be only created on only 16 columns. Well, answer is NO. One can create statistics on total of 32 columns, where as the limit of creating index is only 16 columns (and 900 bytes). Here is the quick example where when attempted to create statistics on 33 columns is generating error but when statistics are created on 32... - [SQLAuthority News - SQL Saturday 116 - SQL Saturday in Bangalore, India on January 7, 2012 - 4 Saturdays to Go](https://blog.sqlauthority.com/2011/12/10/sqlauthority-news-sql-saturday-116-sql-saturday-in-bangalore-india-on-january-7-2012-4-saturdays-to-go/): SQLSaturday 116 is now only 4 weeks away. SQL Saturday is FREE event all the attendees and 100% SQL community driven. Schedule and Venue Event Date: January 7, 2012 Event Time: 10 AM to 6 PM Event Venue: Microsoft Singature Building, Domlur, Bangalore , Bangalore, India Important Links: Register for the event – We are 100% over capacity. Please put your name on waiting list, we are working on various options. Submit your session title and abstract by December 10, 2011. Today is last day! Call to Action – Spread the words Blog, tweet, facebook it – spread the word. Use... - [SQL SERVER - 2012 RC0: Fix Setup Error: File format is not valid](https://blog.sqlauthority.com/2011/12/10/sql-server-2012-rc0-fix-setup-error-file-format-is-not-valid/): I recently had long email conversation with one of the blog reader who was struggling with installing SQL Server 2012 RC0 installation. I just thought I will publish what we have done and how we solved problem so if you are facing the same issue, you can avoid the same. In this blog post we will see how to fix setup error. - [SQL SERVER - Bad Practice of Using Keywords as an Object Name - Avoid Using Keywords as an Object](https://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/): Madhivanan is SQL Server MVP and very talented SQL expert. Here is one of the nugget he shared on Just Learned. He shared a tip where there were two interesting point to learn. Do not use keywords as an object name [read DHall’s excellent comment below] He has given excellent example how GO can be executed as stored procedure. Here is the extension of the tip. Create a small table and now just hit EXEC GO; and you will notice that there is row in the table. Create Stored Procedure CREATE PROCEDURE GO AS SELECT 1 AS NUMBER Create Table CREATE... - [SQL SERVER - Error: Deleting Offline Database and Creating the Same Name](https://blog.sqlauthority.com/2011/12/08/sql-server-error-deleting-offline-database-and-creating-the-same-name/): Offline database is very interesting subject, and there are a couple of interesting details associated with it, which one must know. There are two common queries related to offline database: 1)      My hard drive is getting full and I deleted my ‘offline’ databases. After deleting my offline databases, my hard drive is still full and there is no empty space. 2)      I recently deleted the ‘offline’ database, and now, when I am attempting to create database with the same name, it is giving me error that the database file already exists. I can see why these questions are coming up frequently.... - [SQL SERVER - Plenty of SQL Community Updates](https://blog.sqlauthority.com/2011/12/07/sql-server-plenty-of-sql-community-updates/): Every day we learn something new and we come across something which we like to read. I had decided to keep a log of things what I do during whole day. Here are few updates which I think you will find it interesting. This updates are in no specific order. Comment by David Bridge on SQL SERVER – Effect of SET NOCOUNT on @@ROWCOUNT David has written comment and clarified the message which I wanted to pass while writing blog post. I wish I had written the statement “NOCOUNT statement only affects the information messages and not the DML statement results ”... - [SQLAuthority News - SQL Server Interview Questions and Answers Available on Kindle Format as eBook to Download](https://blog.sqlauthority.com/2011/12/06/sqlauthority-news-sql-server-interview-questions-and-answers-available-on-kindle-format-as-ebook-to-download/): Reading the books on Kindle seems to be very popular. Since our new book released a month ago, we have received so many request from users regarding making it available on Kindle. Well, today we have acknowledge the request. Our new book is available to purchase on kindle. SQL Server Interview Questions and Answers on Kindle I am really impressed how kindle ebook format works. If I find any errata or make changes in the kindle format book now and re-publish the book in kindle format again, if you have purchased the eBook earlier, you will get updated version automatically and... - [SQLAuthority News - SQL Saturday 116 - SQL Saturday in Bangalore, India on January 7, 2012](https://blog.sqlauthority.com/2011/12/05/sqlauthority-news-sql-saturday-116-sql-saturday-in-bangalore-india-on-january-7-2012/): This is the biggest news for SQL Enthusiast in India. SQL Saturday is here in India. PASS SQLSaturday’s are free 1-day training events for SQL Server professionals that focus on local speakers, providing a variety of high-quality technical sessions, and making it all happen through the efforts of volunteers. We think you’ll find it’s a great way to spend a Saturday – or any day. SQL Saturday is FREE event all the attendees and 100% SQL community driven. Schedule and Venue Event Date: January 7, 2012 Event Time: 10 AM to 6 PM Event Venue: Microsoft Singature Building, Domlur, Bangalore ,... - [SQL SERVER - Few Notes on Fast Track Data Warehouse](https://blog.sqlauthority.com/2010/09/05/sql-server-few-notes-on-fast-track-data-warehouse/): I recently delivered fast track data warehouse training. This training was very challenging as this training requires very specific hardware and extremely different way of looking at data warehousing. While training I have made few notes and I will now share the same notes with you. Please note that this are just notes and not learning material. Fast Track Data Warehouse has a primary emphasis on eliminating potential performance bottlenecks. It supports maximum of 48 TB data at this moment. Currently HP, Dell, Bull, IBM and EMC2 provides necessary hardware for Fast Track Data Warehouse. All the Software and Hardware comes... - [SQLAuthority News - Social Media Confusion - Twitter, FaceBook, LinkedIn and Me](https://blog.sqlauthority.com/2010/09/04/sqlauthority-news-social-media-confusion-twitter-facebook-linkedin-and-me/): No story today – I am sure all of you know what I want to talk today. I am indeed not happy with how social media is evolving. There was a time when every social media has its own style and concept. Today wherever I go, I see the same thing. Same news, same update and same old thing. I see now a days not much difference between Twitter, FaceBook and LinkedIn. They all have lost their meaning. Here is what I see the use of social media. Twitter: For short update of what exactly you are doing right now. Not... - [SQL SERVER - Soft Delete - IsDelete Column - Your Opinion](https://blog.sqlauthority.com/2010/09/03/sql-server-soft-delete-isdelete-column-your-opinion/): Just a day ago, I was reading the blog post of Michale J Swart. If you are a regular reader of this blog, I am sure you will be familiar with him. He is a very interesting blogger for sure. He recently wrote an article about Ten Things I hate to See in T-SQL; it was really fun, but the thing which caught my eyes was the subject of isDeleted Column. First of all, let me say that I totally agree with his view point. Let me re-produce what Michale exactly suggests. “Deleted records aren’t deleted. Look, they’re right there!” You... - [SQLAuthority News – SQL Server Health Check Service – Speed UP SQL Server](https://blog.sqlauthority.com/2010/09/02/sqlauthority-news-sql-server-health-check-service-speed-up-sql-server/): In my earlier article SQLAuthority News – Training and Consultancy and Travel – Story of Last 30 Days I had mentioned that I prefer to do 50% consultation and 50% training. Since then I often receive what do I do consultation for and what is my expertise. I am basically man of the performance tuning. I love to tune servers and I love to speed up queries. I often get queries what do I do when I go to performance tuning. Here I am listing my complete service descriptions. This whole exercise can be done remotely as well on site. The... - [SQLAuthority News - Fathers and Daughters](https://blog.sqlauthority.com/2010/09/01/sqlauthority-news-fathers-and-daughters/): Today I am very happy as my daughter is one year old. I have no words to explain how lucky I am to be father of daughter. She is everything to me and my wife have (sweet) complain that I stopped paying attention to her since our daughter has arrived. Check out here one year old photographs. There is special bond between fathers and daughters. An year ago here is the comment I have received from Solid Quality Mentors Global CEO Fernando G. Guerrero wrote to me in email. “What a wonderful gift. Someone told me once that if I had... - [SQLAuthority News - A Monthly Roundups of SQLAuthority Blog Posts - Updated 2019](https://blog.sqlauthority.com/2010/08/31/sqlauthority-news-a-monthly-roundups-of-sqlauthority-blog-posts-updated-2019/): Monthly roundups are very refreshing as it gives me a chance to go back and see what did I do last month. Let us learn in this blog post. - [SQLAuthority News - SQL Server Performance Optimization - Seminar Series](https://blog.sqlauthority.com/2010/08/30/sqlauthority-news-sql-server-performance-optimization-seminar-series/): I am very glad that I will be presenting my very first seminar training series worldwide. This event is called the Solid Quality DIRECTIONS Seminar Series. I am very fortunate that I am given this opportunity to work under prestigious organizations. I have been with Solid Quality Mentors for more than a year now. I have learned a lot and I have grown a lot through this group. While working for Solid Quality, I have conducted many training events and various consultations projects. I can say that I have collected and kept with me all the wisdom and knowledge related to... - [SQLAuthority News - Download - SQL Server Monitoring Management Pack](https://blog.sqlauthority.com/2010/08/29/sqlauthority-news-download-sql-server-monitoring-management-pack/): The SQL Server Management Pack provides the capabilities for Operations Manager 2007 SP1 and R2 to discover SQL Server 2005, 2008, and 2008 R2. It monitors SQL Server components such as database engine instances, databases, and SQL Server agents. The monitoring provided by this management pack includes performance, availability, and configuration monitoring, performance data collection, and default thresholds. You can integrate the monitoring of SQL Server components into your service-oriented monitoring scenarios. In addition to health monitoring capabilities, this management pack includes dashboard views, extensive knowledge with embedded inline tasks, and views that enable near real-time diagnosis and resolution of detected... - [SQL SERVER - Plan Cache - Retrieve and Remove - A Simple Script](https://blog.sqlauthority.com/2010/08/28/sql-server-plan-cache-retrieve-and-remove-a-simple-script/): I had a very interesting situation at my recent performance tuning project. I realize that the developers there were running very large dataset queries on their production server randomly. I got alarmed so I suggested their developer not to do that on the production server; instead, they could create some alternate scenarios where they could synchronize database and query on the same server. The production server should not be used for development work. It should be queried with proper methods (queries, Stored Procedures, etc.), supporting production application. - [SQL SERVER - Getting Started with Execution Plans](https://blog.sqlauthority.com/2010/08/27/sql-server-getting-started-with-execution-plans/): Execution Plans is one of the most interesting subjects and I often get a question about it. Many people want to know how to get started. - [SQL SERVER – Adding Column is Expensive by Joining Table Outside View – Limitation of the Views Part 2](https://blog.sqlauthority.com/2010/08/26/sql-server-adding-column-is-expensive-limitation-of-the-views-part-2/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Note: I have updated the title based on feedback of Davide Mauri (Solid Quality Mentors). Thank you for your help. Let’s see another reason why I do not like Views. Regular queries or Stored Procedures give us flexibility when we need another column; we can add a column to regular queries right away. If we want to do the same with Views, we will have to modify them first. This means any query that does... - [SQL SERVER - Does Order of Column in WHERE Clause Matter?](https://blog.sqlauthority.com/2010/08/25/sql-server-deos-order-of-column-in-where-clause-matter/): Today is a quick puzzle time. Let us learn about - Does the order of column used in WHERE clause matter for performance? Let us learn today. - [SQLAuthority News - Download Microsoft SQL Server Migration Assistant](https://blog.sqlauthority.com/2010/08/24/sqlauthority-news-download-microsoft-sql-server-migration-assistant/): SSMA for Oracle v4.2 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from Oracle to SQL Server 2005, SQL Server 2008 or SQL Server 2008 R2. SSMA for Access v4.2 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from Access to SQL Server 2005, SQL Server 2008, SQL Server 2008 R2 and SQL Azure. SSMA for MySQL v1.0 Microsoft SQL Server Migration Assistant (SSMA) is a toolkit that dramatically cuts the effort, cost, and risk of migrating from MySQL... - [SQLAuthority News - Feedback Received for Virtual Tech Days Sessions on Spatial Database](https://blog.sqlauthority.com/2010/08/24/sqlauthority-news-feedback-received-for-virtual-tech-days-sessions-on-spatial-database/): I recently got opportunity to speak at Virtual Tech Days on August 18, 2010 on the subject Spatial Database. The event was heavily attended by enthusiasts world wide. I delivered session the on the subject of Spatial Database and it was great fun to deliver the session. I have delivered similar session many times before but delivering online is always wonderful experience and it is indeed fun. I got the feedback right away from the organizers and it is above the average of data track. Session Name: Developing with SQL Server Spatial and Deep Dive into Spatial Indexing Adj. LM Attendance:... - [SQL SERVER – ORDER BY Does Not Work – Limitation of the Views Part 1](https://blog.sqlauthority.com/2010/08/23/sql-server-order-by-does-not-work-limitation-of-the-views-part-1/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Recently, I was about the limitations of views. I started to make a list and realized that there are many limitations of the views. Let us start with the first well-known limitation. Order By clause does not work in View. I agree with all of you  who say that there is no need of using ORDER BY in the View. ORDER BY should be used outside the View and not in the View. This example is... - [SQL SERVER - Computed Columns - Index and Performance](https://blog.sqlauthority.com/2010/08/22/sql-server-computed-columns-index-and-performance/): This is the last article in the series of the computed columns I have been writing. Here are previous articles. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER – Computed Column – PERSISTED and Performance – Part 2 This article talks about how non-persisted columns give better performance than PERSISTED columns. SQL SERVER – Computed Column and Performance... - [SQL SERVER – Computed Column – PERSISTED and Storage – Part 2](https://blog.sqlauthority.com/2010/08/21/sql-server-computed-column-persisted-and-storage-part-2/): I am really enjoying writing about computed column and its effect in terms of storage. Before I go on with this topic, I suggest you read the earlier articles about computed column to get the complete context. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns.... - [SQL SERVER – Function to Retrieve First Word of Sentence – String Operation](https://blog.sqlauthority.com/2010/08/20/sql-server-function-to-retrieve-first-word-of-sentence-string-operation/): I have sent of function library where I store all the UDF I have ever written. Recently I received email from my friend requesting if I have UDF which manipulate string and returns only very first word of the statement. Well, I realize that I do not have such a script at all. I found myself writing down this similar script after long time. Let me know if you know any other better script to do the same task. DECLARE @StringVar VARCHAR(100) SET @StringVar = ' anything ' SELECT CASE CHARINDEX(' ', LTRIM(@StringVar), 1) WHEN 0 THEN LTRIM(@StringVar) ELSE SUBSTRING(LTRIM(@StringVar), 1,... - [SQL SERVER - Negative Identity Seed Value and Negative Increment Interval](https://blog.sqlauthority.com/2010/08/19/sql-server-negative-identity-seed-value-and-negative-increment-interval/): Let us learn today about Negative Identity Seed Value and Negative Increment Interval. I have also included a video in this blog post. - [SQL SERVER - Download SQL Server 2008 Interview Questions and Answers Complete List](https://blog.sqlauthority.com/2010/08/18/sql-server-download-sql-server-2008-interview-questions-and-answers-complete-list/): I was getting many request to update SQL Server Interview Questions and Answers I had written couple of years ago. I have modified the original document a bit and corrected few of the typos and errors. I have really enjoyed going over all the Interview Questions and Answers. It has been the most popular subject always on this blog. I am in process of updating that with few new questions and answers I have received from industry experts. Please provide your feedback on how we can further improve them or what kind of questions and answers would like to include in... - [SQLAuthority News - Speaking Online at Virtual Techdays - Aug 18, 2010 - Spatial Datatypes](https://blog.sqlauthority.com/2010/08/17/sqlauthority-news-speaking-online-at-virtual-techdays-aug-18-2010-spatial-datatypes/): I am honored that I have been invited to speak at Virtual TechDays on Aug 18, 2010 by Microsoft. I will be speaking on my favorite subject of Spatial Datatypes. This exclusive Online event will have 30 deep technical sessions per day – and, attendance is completely FREE. There are dedicated tracks for Architects, Software  Developers / Project Managers, Infrastructure Managers / Professionals and Enterprise Developers. Register for the event over here. Date and Time : August 18, 2010, 4:15pm – 5:15pm Developing with SQL Server Spatial and Deep Dive into Spatial Indexing Microsoft SQL Server 2008 delivers new spatial data... - [SQL SERVER - Finding the Occurrence of Character in String](https://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/): This article is written in response to provide hint to TSQL Beginners Challenge 14. The challenge is about counting the number of occurrences of characters in the string. Here is quick method how you can count occurrence of character in any string. Here is quick example which provides you two different details. How many times the character/word exists in string? How many total characters exists in Occurrence? Let us see following example and it will clearly explain it to you. DECLARE @LongSentence VARCHAR(MAX) DECLARE @FindSubString VARCHAR(MAX) SET @LongSentence = 'My Super Long String With Long Words' SET @FindSubString = 'long' SELECT... - [SQLAuthority News - Bookmark Link for Sync Framework for SQL Azure](https://blog.sqlauthority.com/2010/08/15/sqlauthority-news-bookmark-link-for-sync-framework-for-sql-azure/): I have been looking for good tutorial for Sync Framework for SQL Server. There was quite a bit demand of the product. I have received quite a few request as well. I finally found good list of the link of Sync Framework. The links are listed below. Introduction to Sync Framework Introduction to Sync Framework Database Synchronization Understanding Scopes Microsoft Sync Framework Power Pack for SQL Azure Walkthrough Microsoft Sync Framework Power Pack for SQL Azure Synchronizing Databases I have found above links from the document Sync Framework for SQL Azure. The document talks about sync framework and also included supplemented... - [SQLAuthority News - Why SQL Server is better than any other RDBMS Applications?](https://blog.sqlauthority.com/2010/08/14/sqlauthority-news-why-sql-server-is-better-than-any-other-rdbms-applications/): Earlier I had announced contest on blog where I gave away two MSDN Subscriptions to person who has provided best comment on the subject of “Why SQL Server is better than any other RDBMS Applications?” I have received tremendous response to the contest. I got many responses, it was extremely difficult to announce the winner and I requested help of two SQL Server MVPs to help me out with the results. Here is the winner of the contest. They really spend good time and wrote about their feeling for SQL Server product. Here is their answers. I strongly suggest that you... - [SQL SERVER – Computed Column and Performance – Part 3](https://blog.sqlauthority.com/2010/08/13/sql-server-computed-column-and-performance-part-3/): I am really enjoying writing about computed column and its effect in terms of performance. Before continuing this article, I suggest you read the earlier articles on the same subject to get the complete context. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER... - [SQL SERVER – SHRINKDATABASE For Every Database in the SQL Server](https://blog.sqlauthority.com/2010/08/12/sql-server-shrinkdatabase-for-every-database-in-the-sql-server/): I was recently called to attend the Query Tuning Project. I had a very interesting experience in this event. I would like to share to you what actually happened. Note: If you are just going to say that shrinking database is bad, I agree with you and that is the main point of this blog post. Please read the whole blog post first. The problem definition of the consultation was to improve the performance of the database server. I usually fly to the client’s location a day before, so the next day I am all fresh upon reaching the client’s office... - [SQLAuthority News - MSDN Subscription Giveaway Announced](https://blog.sqlauthority.com/2010/08/11/sqlauthority-news-msdn-subscription-giveaway-announced/): Last Month received following “NOT FOR SALE” subscription of Microsoft Visual Studio 2010 Ultimate with MSDN. As a MVP, MCT I already have free subscription to MSDN and TechNet. I plan to give away this free subscription to someone who is need of the same or can use it the best. I have already given away two of the subscription to someone who can really use them. In fact, they have reported me where and how they are using the subscription. This gives me great satisfaction. I have announced one subscription for all of you my reader to win. Top SQL... - [SQL SERVER - Best Practices for DBA Before Taking Vacation](https://blog.sqlauthority.com/2010/08/10/sql-server-best-practices-for-dba-before-taking-vacation/): This blog post is written in response to T-SQL Tuesday hosted by Jason Brimhall. Everybody wants to take a vacation. Who does not love vacation, anyway? However, it seems that it has been getting more and more difficult to take vacation recently. There are two reasons why a person is not able to enjoy his vacation. First is due to company policies (bad boss!), and second is your responsibilities. Well, I cannot guide you much about company policy issues simply because I cannot do something about it. I have a wonderful boss and I have been taking many vacations, doing a... - [SQLAuthority News - Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool New v1.2](https://blog.sqlauthority.com/2010/08/09/sqlauthority-news-risk-health-assessment-program-microsoft-sql-server-scoping-tool-new-v1-2/): Risk and Health Assessment Program for Microsoft SQL Server helps reduce business risks associated with downtime, performance bottlenecks, and the complexities of deploying and managing an enterprise-level, data management solution. You can read more about Risk and Health Assessment Program for Microsoft SQL Server in the datasheet over  here. Microsoft has released recently the tool for its Premier Customers. This tool provides all the necessary details to prepare and qualify any environment to receive a risk and health assessment Program for Microsoft SQL Server. You can download Risk and Health Assessment Program for Microsoft SQL Server – Scoping Tool v1.2 from... - [SQLAuthority News - SQL Server Monitoring Management Pack Download](https://blog.sqlauthority.com/2010/08/09/sqlauthority-news-sql-server-monitoring-management-pack-download/): Microsoft has SQL Server Health monitoring tool, which I have noticed that many of us do not give it a try. Microsoft has released Monitoring management pack download recently and it does plenty of the task, which normally one would like to do. Instead of going for third party tool, I suggest you give it a try. Following text is produced directly from original MSDN page from here. The SQL Server Management Pack provides the capabilities for Operations Manager 2007 SP1 and R2 to discover SQL Server 2005, 2008, and 2008 R2. It monitors SQL Server components such as database engine... - [SQLAuthority News - Microsoft SQL Server 2008 R2 Report Builder 3.0](https://blog.sqlauthority.com/2010/08/08/sqlauthority-news-microsoft-sql-server-2008-r2-report-builder-3-0/): Microsoft has recently released Microsoft SQL Server 2008 R2 Report Builder 3.0. This version is enhancement to earlier versions by adding many new features. It provides an intuitive report authoring environment for business and power users. It supports the full capabilities of SQL Server 2008 R2 Reporting Services. The download provides a stand-alone installer for Report Builder 3.0. Report Builder 3.0 introduces additional visualizations including maps, sparklines and databars which can help produce new insights well beyond what can be achieved with standard tables and charts. The Report Part Gallery is also included in this release – taking self-service reporting to... - [SQLAuthority News – Community Tech Days, Ahmedabad – July 24, 2010](https://blog.sqlauthority.com/2010/08/07/sqlauthority-news-community-tech-days-ahmedabad-july-24-2010/): Community Tech Days are a series of events in my city. Ahmedabad Community is one of the best communities I have ever come across in this world. People are genius, very kind and very patient. They are not shy to ask any questions and I could see their keen desire to learn and absorb new technology. My special thanks to the Community because without them, this event series would not be possible. - [SQL SERVER - Parallelism Query in Database](https://blog.sqlauthority.com/2010/08/06/sql-server-parallelism-query-in-database/): I recently came across two interesting questions asked by Feodor over here. He has asked very interesting questions. Please check them as follows: If I have a dual core computer and I would like to get a query executed with parallelism in order to test it, how would I do that? You can use the AdventureWorks database and let me know if you can get a query to execute in parallel. I am running machine which has 2 different cores. I was able to reproduce the parallel query using following T-SQL Script. USE AdventureWorks GO SELECT * FROM Sales.SalesOrderDetail sod INNER... - [SQLAuthority News – SQL Data Camp, Chennai, July 17, 2010 – A Huge Success](https://blog.sqlauthority.com/2010/08/05/sqlauthority-news-sql-data-camp-chennai-july-17-2010-a-huge-success/): I had great pleasure to attend very first SQL Data Camp at Chennai on July 17, 2010. This event was very unique as this was very first one-day SQL Event in whole Indian Subcontinent. The event was blast as there were so many back–to-back SQL Sessions with SQL Server MVPs. I was fortunate to present two different sessions at the SQL Data Camp in Chennai. I must express my special thanks to event organizers Sugesh, Deepak and Vidyasagar for organizing such a wonderful event. Every participant who was attending the event had a great time and expressed their passion for SQL... - [SQL SERVER - Computed Column - PERSISTED and Performance - Part 2](https://blog.sqlauthority.com/2010/08/04/sql-server-computed-column-persisted-and-performance-part-2/): This is the third article in the series which I am writing on Persisted Columns. I suggest you read following two article first before continuing on this article. This is the list of the all the articles in the series of computed column. SQL SERVER – Computed Column – PERSISTED and Storage This article talks about how computed columns are created and why they take more storage space than before. SQL SERVER – Computed Column – PERSISTED and Performance This article talks about how PERSISTED columns give better performance than non-persisted columns. SQL SERVER – Computed Column – PERSISTED and Performance... - [SQL SERVER - Computed Column - PERSISTED and Performance](https://blog.sqlauthority.com/2010/08/03/sql-server-computed-column-persisted-and-performance/): This is the list of the all the articles in the series of computed column. - [SQLAuthority News - T-SQL Challenges and Hints and Suggestions](https://blog.sqlauthority.com/2010/08/02/sqlauthority-news-t-sql-challenges-and-hints-and-suggestions/): Those who read my blog are for sure know my very good friend Jacob Sebastian. He is SQL Server MVP and founder of wonderful site T-SQL Challenges. No matter how expert we are, challenges are made to make us think and try to go to next level. There are certain people who writes always challenging code, however there are many who are yet not expert but the passion of T-SQL is on them. Jacob has many wonderful ideas and T-SQL challenge is his contribution to community, where he helps community to think, help them to mentor and help them to become one better coder. - [SQL SERVER – Introduction to BINARY_CHECKSUM and Working Example](https://blog.sqlauthority.com/2010/08/01/sql-server-introduction-to-binary_checksum-and-working-example/): In one of the recent consultancy, I was asked if I can give working example of BINARY_CHECKSUM. This is usually used to detect changes in a row. If any row has any value changed, this function can be used to figure out if the values are changed in the rows. However, if the row is changed from A to B and once again changed back to A, the BINARY_CHECKSUM cannot be used to detect the changes. Let us see quick example of the of same. Following example is modified from the original example taken from BOL. USE AdventureWorks; GO -- Create... - [SQLAuthority News - A Monthly Round Up of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/07/31/sqlauthority-news-a-monthly-round-up-of-sqlauthority-blog-posts-2/): This month was very interesting month for me. I visited 2 different countries – Malaysia and Sri Lanka. I had great time attending 3 community sessions – Chennai, Kuala Lumpur and Ahmedabad. Though, I was at home only 5 nights, I was fortunate enough to spend good amount of the time with family as well. My family traveled along with me to different countries as well few of my business trips.I also have few good news in this week. SQLAuthority News – I am a MVP and I Love SQL Server SQLAuthority News – I am Microsoft Certified Trainer (MCT) SQLAuthority... - [SQL Tips - 5 SQL Server Best Practices](https://blog.sqlauthority.com/2010/07/30/sqlauthority-news-authors-birthday-5-sql-server-best-practices/): In this blog post we will see 5 SQL Server Best Practices. Backup Master. I am going to have a backup of the database using script; however, the backup script has not been updated for a long time now. - [SQL SERVER - Check Advanced Server Configuration](https://blog.sqlauthority.com/2010/07/29/sql-server-check-advanced-server-configuration/): I was recently asked following question about how to Check Advanced Server Configuration. - [SQLAuthority News - 2 Sessions at TechInsight 2010 - June 29 - July 1, 2010](https://blog.sqlauthority.com/2010/07/28/sqlauthority-news-2-sessions-at-techinsight-2010-june-29-july-1-2010/): Earlier this month, I got the opportunity to visit Malaysia for community sessions on June 29 – July 1, 2010 at Kuala Lumpur, Malaysia, which I would consider as valuable experience. I presented two different sessions at the event. The event was extremely popular in local community, and I had great time meeting people in Malaysia. I must say that the best thing about Kuala Lumpur is the people and their response. Techinsights is a major technology conference to network with like-minded peers and also up-skill your knowledge on latest technologies. An event that offers opportunity to dabble in hardcore technologies... - [SQL SERVER - Computed Column - PERSISTED and Storage](https://blog.sqlauthority.com/2010/07/27/sql-server-computed-column-persisted-and-storage/): This is the list of the all the articles in the series of computed column. - [SQL SERVER – FIX: ERROR: 8170 Insufficient result space to convert uniqueidentifier value to char](https://blog.sqlauthority.com/2010/07/26/sql-server-fix-error-8170-insufficient-result-space-to-convert-uniqueidentifier-value-to-char/): I just came across very simple error and the solution was even simpler. While concatenating NEWID to another varchar string, I had to CONVERT/CAST it to VARCHAR and I accidentally put length of VARCHAR to 10 instead of 36. It displayed following error. Msg 8170, Level 16, State 2, Line 1 Insufficient result space to convert uniqueidentifier value to char. - [SQLAuthority News - Last 2 Day to Win MSDN Subscription - Total 2 to Win](https://blog.sqlauthority.com/2010/07/25/sqlauthority-news-last-2-day-to-win-msdn-subscription-total-2-to-win/): Today is the last day to win MSDN subscription on this blog. SQL Server MVP Madhivanan is known name. As there are more than 150 comments, I had requested him to help me out with deciding the winner. After looking at the quality responses, he has for sure accepted to hep me out with the deciding the winner but also added one more subscription from his side. This leads to total 2 of the subscription to win. Today is the last day to participate in the content. However, as we have added one more subscription on very last day, we have... - [SQLAuthority News - The story of the world - Spatial Data types - July 24, 2010](https://blog.sqlauthority.com/2010/07/24/sqlauthority-news-the-story-of-the-world-spatial-data-types-july-24-2010/): Today I will be speaking on the subject of Spatial Database at Community Tech Days at Ahmedabad. The event is absolutely FREE. We have so far received 500+ RSVP but there are only limited 250 seats are available. We are doing our best to inform everybody about their registration status. If you have received confirmation email, I suggest that you come in early enough to reserve the place. - [SQL SERVER - Find Queries using Parallelism from Cached Plan](https://blog.sqlauthority.com/2010/07/24/sql-server-find-queries-using-parallelism-from-cached-plan/): I recently came across wonderful blog post of Feodor Georgiev. He is one fine developer and like to dwell in the subject of performance tuning and query optimizations. He is one real genius and original blogger. Recently I came across his wonderful script, which I was in fact writing myself and I found out that he has already posted the same query over here. After getting his permission I am reproducing the same query on this blog. Note to not run the following script on busy transactional production environment as well, it does not get all historical results as it only... - [SQLAuthority News - Funny Technology Quotes - Humor](https://blog.sqlauthority.com/2010/07/23/sqlauthority-news-guest-post-walkthrough-on-creating-wcf-data-service-odata-and-consuming-in-windows-7-mobile-application/): I am including a few of the interesting quotes today. Let us see Funny Technology Quotes. Here are few interesting new lessons. - [SQLAuthority News - SolidQ Journal Released - A Must Read for All](https://blog.sqlauthority.com/2010/07/22/sqlauthority-news-solidq-journal-released-a-must-read-for-all/): SQL Server is one of the most popular products of Microsoft and a large amount of quality content is available online. Solid Quality Mentors have together built a superior quality journal, which contains the best of the best authentic articles from renowned experts of SQL Server. When I downloaded SolidQ Journal, the very first feeling I got was like that of old days of reading technology magazines online. Very soon, I was busy reading the articles one by one and did not realize that I spend nearly 3 hours on single sitting reading the entire journal. After reading it completely, I... - [SQL SERVER - Win USD 11,899 worth MSDN Subscription 5 Days to go](https://blog.sqlauthority.com/2010/07/21/sql-server-win-usd-11899-worth-msdn-subscription-5-days-to-go/): Few days ago, I had posted content SQLAuthority News – FREE Microsoft Visual Studio 2010 Ultimate with MSDN. It has received tremendous response to them. This competition is still open for 5 more days. I am sure you can win the subscription if you leave the best comment. Win $ 11,899 worth Price You need to answer one simple question: You need to answer one simple question: Why SQL Server is better than any other RDBMS applications? Please do not leave comments in this thread, leave at original thread over here. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SELECT * FROM dual - Dual Equivalent](https://blog.sqlauthority.com/2010/07/20/sql-server-select-from-dual-dual-equivalent/): This blog post is for all the Oracle developers who keep on asking for the lack of “dual” table in SQL Server. Here is a quick note about DUAL table, in an easy question-and-answer format. What is DUAL in Oracle? Dual is a table that is created by Oracle together with data dictionary. It consists of exactly one column named “dummy”, and one record. The value of that record is X. You can check the content of the DUAL table using the following syntax. SELECT * FROM dual It will return only one record with the value ‘X’. What is the... - [SQL SERVER - Identifying Statistics Used by Query](https://blog.sqlauthority.com/2010/07/19/sql-server-identifying-statistics-used-by-query/): “Can I know which statistics were used by my query?” Recently, someone asked this question in my training class of query optimization and performance tuning. I really liked the question. The answer for me is very simple. “No.” Well, if I stop here suggesting only “No,” it will be an incomplete answer. Let us continue a bit more. There is no direct method or DVM or any tool which can tell us which statistics were used by any query. In fact, it looks like there is no way one can know if the any created statistics was ever used or not.... - [SQLAuthority News - SQL Server Quickstart Downloads from Microsoft](https://blog.sqlauthority.com/2010/07/18/sqlauthority-news-sql-server-quickstart-downloads-from-microsoft/): Here are few recent published by Microsoft. Application Platform Optimization SQL Server Migration QuickStart The SQL Server Migration QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to help you get details about how to approach your customers who want to improve the return on investment from their data platforms by migrating to SQL Server from their existing Oracle or Sybase platforms. Application Platform Optimization SQL Server Consolidation QuickStart The SQL Server Consolidation QuickStart includes a comprehensive set of technical content including presentations, whitepapers and demos that are designed to present to customers who... - [SQLAuthority News - Community TechDays, Ahmedabad - July 24, 2010](https://blog.sqlauthority.com/2010/07/17/sqlauthority-news-community-techdays-ahmedabad-july-24-2010/): Dive deep into the world of Microsoft technologies at the Community TechDays and get trained on the latest from Microsoft. Build real connections with Microsoft experts and community members, and gain the inspiration and skills needed to maximize your impact on your organization while enhancing your career. What more… you can watch some of these sessions LIVE online from the comfort of your workstation as well. The event registration site is here. I will be speaking on the subject. SQL Server – The story of the world – Spatial Data types Speaker: Pinal Dave Event Date: 24th July 2010 Session Time:... - [SQL SERVER - Datetime Function TODATETIMEOFFSET Example](https://blog.sqlauthority.com/2010/07/16/sql-server-datetime-function-todatetimeoffset-example/): Earlier I wrote about SQL SERVER – Datetime Function SWITCHOFFSET Example. After reading this blog post, I got another quick reply that if I can explain the usage of TODATETIMEOFFSET as well. - [SQL SERVER - Datetime Function SWITCHOFFSET Example](https://blog.sqlauthority.com/2010/07/15/sql-server-datetime-function-switchoffset-example/): I was recently asked if I know how SWITCHOFFSET works. This feature only works in SQL Server 2008. Here is quick definition of the same from BOL: Returns a datetimeoffset value that is changed from the stored time zone offset to a specified new time zone offset. What essentially it does is that changes the current offset of the time to any other offset which we defined. Let us see the example of the same. SELECT SYSDATETIMEOFFSET() GetCurrentOffSet; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '-04:00') 'GetCurrentOffSet-4'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '-02:00') 'GetCurrentOffSet-2'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+00:00') 'GetCurrentOffSet+0'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+02:00') 'GetCurrentOffSet+2'; SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+04:00') 'GetCurrentOffSet+4'; Now let us... - [SQLAuthority News - Two SQL Sessions at SQL Data Camp at Chennai - July 17, 2010](https://blog.sqlauthority.com/2010/07/14/sqlauthority-news-two-sql-sessions-at-sql-data-camp-at-chennai-july-17-2010/): I will be presenting two SQL Server advance level sessions at SQL Data Camp @ Chennai. I am very excited for this event as I am going to meet my friends Sugesh, Deepak, Vidhya and Madhivanan at this event. All of them are SQL Server MVPs. I have come to know that there are two other SQL Server MVPs – Madhu andVenkatesh are also joining the event as speaker. This is going to be one mega fest as so many of SQL Server MVPs are going to be present at same place. The event is going to be world-class event and... - [SQL SERVER - How do I Learn and How do I Teach](https://blog.sqlauthority.com/2010/07/13/sql-server-how-do-i-learn-and-how-do-i-teach/): This blog post is written in response to T-SQL Tuesday hosted by Robert L Davis (aka SQLSoldier). The blog post has raised three very interesting questions. How do you learn? How do you teach? What are you learning or teaching? Let me try to answer the same. How do I learn? This question is very interesting. I have written a blog post on the very same subject few days ago when I completed my 1400th blog post. Learning is a continuous process and it never ends. There are many different ways through which one can learn. Looking back, when I was... - [SQLAuthority News - FREE Microsoft Visual Studio 2010 Ultimate with MSDN](https://blog.sqlauthority.com/2010/07/12/sqlauthority-news-free-microsoft-visual-studio-2010-ultimate-with-msdn/): I just received following “NOT FOR SALE” subscription of Microsoft Visual Studio 2010 Ultimate with MSDN. As a MVP, MCT I already have free subscription to MSDN and TechNet. I plan to give away this free subscription to someone who is need of the same or can use it the best. You can win the subscription. I will pick the winner of the subscription on 25th of the July. Which means you have 10 days to take part. I will decide the winner with the help of fellow MVPs and subject matter experts. You need to answer one simple question: Why... - [SQL SERVER - Parallelism - Row per Processor - Row per Thread - Thread 0](https://blog.sqlauthority.com/2010/07/11/sql-server-parallelism-row-per-processor-row-per-thread-thread-0/): Earlier I had posted article answering question. “When SQL Server executes any query on multiple processors, do all processors process equal numbers of rows?” Read the answer over SQL SERVER – Parallelism – Row per Processor – Row per Thread. In the same article, I had asked back to readers as well. “If you look carefully in the Properties window or XML Plan, there is “Thread 0″. What does this “Thread 0” indicate?” Here is the answer of the question, many thanks to all of you and special mention to Marko Parkkola, who has answered first and the answer is very detailed.... - [SQLAuthority News - Milestone - 1400th Post and Why do I blog](https://blog.sqlauthority.com/2010/07/10/sqlauthority-news-milestone-1400th-post-and-why-do-i-blog/): I am very glad today that I have reached milestone of 1400th post. I was looking back to my journey which I started on Nov 1, 2006 and I feel that it has been long way. I have noticed a lot of changes in myself too. Earlier, I used to write a milestone post every time I reach either 1 million views or when I am writing the 100th post. I noticed that such “milestones” started happening quite often; so I decided to write about such milestones on every 100th post. Well, this limited the number of such milestone posts to... - [SQLAuthority News - I am a MVP and I Love SQL Server](https://blog.sqlauthority.com/2010/07/09/sqlauthority-news-i-am-a-mvp-and-i-love-sql-server/): I am very glad that I received this prestigious award for the third time in a row. I am very thankful to Microsoft for introducing this wonderful technology of SQL Server. I enjoy getting involved with the community, which also helps in my self-improvement as well. I would like to take this moment to thank all my friends, readers, session attendees, MS Product Teams, MVP Program and my Organization for the constant support and encouragement. There are few questions that I often receive about the MVP program. Today, I will answer them in brief. Microsoft MVP Logo Question: How can I become a... - [SQL SERVER - The Self Join - Inner Join and Outer Join ](https://blog.sqlauthority.com/2010/07/08/sql-server-the-self-join-inner-join-and-outer-join/): Self Join has always been an note-worthy case. It is interesting to ask questions on self join in a room full of developers. I often ask – if there are three kind of joins, i.e.- Inner Join, Outer Join and Cross Join; what type of join is Self Join? The usual answer is that it is an Inner Join. In fact, it can be classified under any type of join. I have previously written about this in my interview questions and answers series. I have also mentioned this subject when I explained the joins in detail over SQL SERVER – Introduction... - [SQL SERVER - Upper Case Shortcut SQL Server Management Studio](https://blog.sqlauthority.com/2010/07/07/sql-server-upper-case-shortcut-sql-server-management-studio/): Few days ago, I received code which is very similar to code shown below. select * from Sales.SalesOrderDetail where ProductID > 777 I am not the guy who go crazy for formatting but I do appreciate proper coding. I like if the code was formatted like below. SELECT * FROM Sales.SalesOrderDetail WHERE ProductID > 777 The fastest way one can do this in SSMS is either search and replace or using SSMS short cut to covert keywords to upper case. What I do is I select the word and hit CTRL+SHIFT+U and it SSMS immediately changes the case of the selected... - [SQLAuthority News - I am Microsoft Certified Trainer (MCT) ](https://blog.sqlauthority.com/2010/07/06/sqlauthority-news-i-am-microsoft-certified-trainer-mct/): I am a Microsoft Certified Trainer and I am very much proud of it. Because I am a MCT, I have the support of great community leaders and trainers who help me constantly to improve in what I do. I have many Microsoft Certifications and I constantly try to take more of these. Every time, a new certification is announced, I make sure to add it to my list of existing ones. This post is written to make the community aware that how sometimes strict bureaucracy guidelines can create issues and a very well-confirmed project can crash. Those who know me... - [SQL SERVER – PowerShell Version Info](https://blog.sqlauthority.com/2010/07/05/sql-server-powershell-version-info/): I have multiple computer systems at home. I have previously taken a picture of my home office and published it here. Also, I recently had a scenario where I was listing a PowerShell version installed in my computer systems. While searching online, I found two different commands that can determine the version of PowerShell. One of them worked fine in Version 1, while both worked on Version 2. The commands are: $PSVersionTable and $host I have run both the commands on different PowerShell versions and found the following output. This is a call to all PowerShell experts to help me out... - [SQL SERVER - Index Levels, Page Count, Record Count and DMV - sys.dm_db_index_physical_stats](https://blog.sqlauthority.com/2010/07/04/sql-server-index-levels-page-count-record-count-and-dmv-%c2%a0sys-dm_db_index_physical_stats/): In the recent Query Tuning project, one of the developers who were helping me out in the project asked me if there is any way that he could know how many pages are used by any Index,  and if there is any way I could demonstrate the different levels of B-Tree. The following is the diagram on Clustered Index that I have quickly drawn using MS Word for the said developer. Clustered Index B-Tree Let us quickly see the diagram of B-Tree and how the levels are set up. The leaf level is always considered as Level 0. There can be... - [SQL SERVER - View XML Query Plans in SSMS as Graphical Execution Plan](https://blog.sqlauthority.com/2010/07/03/sql-server-view-xml-query-plans-in-ssms-as-graphical-execution-plan/): Earlier I wrote a blog post on SQL SERVER – Parallelism – Row per Processor – Row per Thread, where I mentioned the XML Plan. As a follow up on the blog post, I received the request to send the same execution plan so that the blog readers can also use the same and reproduce it on their machine. I realized that I have actually never written on how one can send a graphical execution plan to another user so that they can reproduce the same exact details without all the actual tables, indexes and objects. Here is very simple method... - [SQL SERVER - Parallelism - Row per Processor - Row per Thread](https://blog.sqlauthority.com/2010/07/02/sql-server-parallelism-row-per-processor-row-per-thread/): Here is a question I received via email: “When SQL Server executes any query on multiple processors, do all processors process equal numbers of rows?” I find this one very interesting. I quickly wrote down a query which can run on multiple CPU in my machine. My laptop has a Core 2 Duo processor and has two CPUs. When I ran the query, I found out from the execution plan that there is a parallelism operator, which runs my query in both CPUs. I pressed F4 to see the Properties of the execution plan. You can open the Properties window by... - [SQL SERVER - Introduction to Best Practices Analyzer - Quick Tutorial](https://blog.sqlauthority.com/2010/07/01/sql-server-introduction-to-best-practices-analyzer-quick-tutorial/): I previously wrote about SQLAuthority News – Download – Microsoft SQL Server 2008 R2 Best Practices Analyzer earlier and since then I have received many emails requesting to explain how it works. I assume that you can download and install the tool successfully. Once done just follow the steps listed below. You will be successfully able to test multiple instances of SQL Server using this tool. Once the tool is launched, select the product you wish to analysis. Click on Start Scan will take few minutes to analysis the server. Select the appropriate features to include the analysis in report. I... - [SQLAuthority News - A Monthly Round Up of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/06/30/sqlauthority-news-a-monthly-round-up-of-sqlauthority-blog-posts/): Last month I wrote monthly round up and I was very well received. For the same here it goes this months wrote up for all the SQLAuthority.com blogs. The month started very interesting subject of SQL SERVER – Precision of SMALLDATETIME – A 1 Minute Precision which lead to few datetime related blog posts. I find them very interesting and hopefully you will too. SQL SERVER – Difference Between GETDATE and SYSDATETIME SQL SERVER – Difference Between DATETIME and DATETIME2 SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE Another interesting blog post series was on the subject how SQL... - [SQL SERVER - Outer Join Not Allowed in Indexed Views](https://blog.sqlauthority.com/2010/06/29/sql-server-outer-join-not-allowed-in-indexed-views/): I recently received an email that contains a question from one of my readers. I have already replied the answer to his email, but I would still like to bring it to your attention and ask if you think I could have done any better with the example I gave. The question was raised when the email sender read the white paper, Improving Performance with SQL Server 2008 Indexed Views. If you scroll all the way down through the said white paper, there are several questions and answers. Q: Why can’t I use OUTER JOIN in an Indexed view? A: Rows... - [SQLAuthority News - Exam 70-433 - MCTS - Microsoft SQL Server 2008, Database Development](https://blog.sqlauthority.com/2010/06/29/sqlauthority-news-exam-70-433-mcts-microsoft-sql-server-2008-database-development/): I often receive lots of questions regarding how to pass SQL Server Certification exams. I have previously written about the road map over SQL SERVER – Roadmap of Microsoft Certifications – SQL Server Certifications. I have tremendous respect for Microsoft Certification and I enjoy the preparation phase as well as attending the real exam. The real value is after passing the exams as I am always sure that during the whole process, I have learned something new and my knowledge has been updated. Prometric Testing Center Experience: I had a Prometric voucher for one free exam, which was expiring on June... - [SQL SERVER - Default Statistics on Column - Automatic Statistics on Column](https://blog.sqlauthority.com/2010/06/28/sql-server-default-statistics-on-column-automatic-statistics-on-column/): During the SQL Server Training, I frequently noticed confusion in people in terms of Statistics. Many people have no idea on how Statistics works. There are so many misconceptions with respect to Statistics. I recently had an interesting conversation with one attendee who believed that Statistics only exists on Column if there is an Index on the Column, or if we explicitly create Statistics on it. - [SQLAuthority News – Announcing Winners of the Office 2010 Giveaway](https://blog.sqlauthority.com/2010/06/27/sqlauthority-news-announcing-winners-of-the-office-2010-giveaway/): Thank you all for participating in Office 2010 giveaway. After carefully evaluation following user is announced as the winner. The question was as following. Choose best option: With which Microsoft Office Product Powerpivot is associated? Options: 1) PowerPoint 2) Excel 3) Word The answer was suppose to be most creative and informative. Many congratulations to the winner of the Office Giveaway. Winning comment by Sagar. PowerPivot refers to a collection of applications and services that provide an end-to-end solution for creating and sharing business intelligence using Excel and SharePoint. As SharePoint is not the option answer is ‘EXCEL’. PowerPivot for Excel... - [SQL SERVER - Fast Track Data Warehouse for SQL Server 2008](https://blog.sqlauthority.com/2010/06/26/sql-server-fast-track-data-warehouse-for-sql-server-2008/): I recently attended a wonderful training session organized by Microsoft on Fast Track Data Warehouse Reference Architectures. If you are regular reader of my blog, you will be well aware of the fact that I am more of the Relational guy than a Business Intelligence professional. I was initially a bit skeptic about this training. However, once I start learning about it, to my surprise, I thought that I am the perfect guy to learn this. In fact, I realized that few of the tricks which this course is suggesting have already been implemented in my earlier consulting assignments. Fast Track... - [SQLAuthority News – Download – Microsoft SQL Server 2008 R2 Best Practices Analyzer](https://blog.sqlauthority.com/2010/06/25/sqlauthority-news-download-microsoft-sql-server-2008-r2-best-practices-analyzer/): Microsoft has released wonderful tool SQL Server 2008 R2 Best Practices Analyzer. I have previously used this tool and found it quite helpful. Here is the latest version which you can download from MS site. Microsoft SQL Server 2008 R2 Best Practices Analyzer However, I received quite a few emails that users are not able to install it after downloading this tool. There is nothing wrong with this tool but there are two prerequisites which are needed. I am additionally listing the download link to all of them here with. Microsoft Baseline Configuration Analyzer 2.0 Microsoft PowerShell 2.0 Reference: Pinal Dave... - [SQLAuthority News – Meeting Bryan Oliver and Learning Wisdom of Life](https://blog.sqlauthority.com/2010/06/24/sqlauthority-news-meeting-bryan-oliver-and-learning-wisdom-of-life/): During my most recent travel outside India, I was fortunate enough to meet Bryan Oliver. I have heard a lot about him but never had chance to meet him in person. Just like we all do for someone we never met before, I had already some preconceived notions about him. I assumed that he might be someone who will be quite proud about his knowledge with 20+ years of experience in the industry. I was also not expecting a very friendly approach as he was quite older than me. I am sure by now that all of you might have guessed... - [SQLAuthority News - Guest Post - SELECT * FROM XML - Jacob Sebastian](https://blog.sqlauthority.com/2010/06/23/sqlauthority-news-guest-post-select-from-xml-jacob-sebastian/): One of the most common problem SQL Server developers face while dealing with XML is related to writing the correct XPath expression to read a specific value from an XML document. I usually get a lot of questions by email, on my blog or in the forums which looks like the following: - [SQLAuthority News - Price List - Oracle vs SQL Server](https://blog.sqlauthority.com/2010/06/22/sqlauthority-news-price-list-oracle-vs-sql-server/): During one of the consulting project, I was asked to prove that the SQL Server is a more economical choice than Oracle. Well, I do not want to start again the battle, which has been clearly won by SQL Server. Summary: SQL Server is a feature-rich and economical choice compared to Oracle. The base product of Oracle is expensive and to add all the features that are offered by the SQL Server, it requires many more different add-ons. These extra add-ons further increase the price to make SQL Server much more affordable than Oracle, which is ridiculously expensive. I suggest that... - [SQL SERVER - TRANSACTION, DML and Schema Locks](https://blog.sqlauthority.com/2010/06/21/sql-server-transaction-dml-and%c2%a0schema%c2%a0locks/): Today we will be going over a simple but interesting concept. Many a time, I have come across the lack of understanding on how the transactions work in SQL Server. Today we will go over a small but interesting observation. One of my clients had recently invited me to help them out with an interview for their senior developers. I had interviewed nearly 50+ candidates in a single day. There were many different questions, but the following question was incorrectly answered most of the time. The question was to create a scenario where you can see the SCHEMA LOCK. The interview... - [SQL SERVER - Free Download - SQL Server 2008 R2 Update for Developers Training Kit](https://blog.sqlauthority.com/2010/06/20/sql-server-free-download-sql-server-2008-r2-update-for-developers-training-kit/): SQL Server 2008 R2 is released and have been a stable product since the day it is released. I have not received any complains or rants from any of my customers who has upgraded to this version. The number one request is how one can learn about the new features of SQL Server or how one can get going in using SQL Server 2008. Microsoft has released SQL Server 2008 R2 Developers Training Kit. This is awesome kit and I just suggest to have a look at the content one time. Here is what MS say for this kit: SQL Server... - [SQLAuthority News - Delivering Two SQL Sessions at SQL Data Camp at Chennai - July 17, 2010](https://blog.sqlauthority.com/2010/06/19/sqlauthority-news-delivering-two-sql-sessions-at-sql-data-camp-at-chennai-july-17-2010/): SQL Server Community is very strong community world-wide. In India SQL is considered as one of the most popular technology. Chennai is the only city in India where there are more than 3 SQL Server MVPs are from. My MVP friends has arranged one of the very first whole day SQL event in India at Chennai. At this event all the speakers are MVPs as well there will be more than 6 SQL Server MVP present at this single event. You can register for this event by going to the site and clicking on link Register. I am very much looking... - [SQLAuthority News - Interview with SQL Server MVP Madhivanan - A Real Problem Solver](https://blog.sqlauthority.com/2010/06/18/sqlauthority-news-interview-with-sql-server-mvp-madhivanan-a-real-problem-solver/): Madhivanan (SQL Server MVP) is a real community hero. He is known for his two skills – 1) Help Community and 2) Help Community. I have met him many times and every time I feel if anybody in online world needs help Madhivanan does his best to reach them out and solve problem. His name is not new if you are reading this blog or have ever asked a question in any online SQL forum. He is always there to help. When Madhivanan has time he even helps people on this blog as well. He spends his valuable time to help... - [SQL SERVER - Data Pages in Buffer Pool - Data Stored in Memory Cache](https://blog.sqlauthority.com/2010/06/17/sql-server-data-pages-in-buffer-pool-data-stored-in-memory-cache/): This will drop all the clean buffers so we will be able to start again from there. Now, run the following script and check the execution plan of the query. Have you ever wondered what types of data are there in your cache? During SQL Server Trainings, I am usually asked if there is any way one can know how much data in a table is stored in the memory cache? The more detailed question I usually get is if there are multiple indexes on table (and used in a query), were the data of the single table stored multiple times... - [SQL SERVER - Find Largest Supported DML Operation - Question to You](https://blog.sqlauthority.com/2010/06/16/sql-server-find-largest-supported-dml-operation-question-to-you/): SQL Server is very big and it is not possible to know everything in SQL Server but we all keep learning. Recently I was going over the best practices of transactions log and I come across following statement. The log size must be at least twice the size of largest supported DML operation (using uncompressed data volumes). First of all I totally agree with this statement. However, here is my question – How do we measure the size of the largest supported DML operation? I welcome all the opinion and suggestions. I will combine the list and will share that with... - [SQL SERVER - Shrinking Database NDF and MDF Files](https://blog.sqlauthority.com/2010/06/15/sql-server-shrinking-ndf-and-mdf-files-readers-opinion/): Previously, I had written a blog post about SQL SERVER. I am posting this blog post here about Shrinking Database. - [SQLAuthority News - Author Visit - SQL Server 2008 R2 Launch](https://blog.sqlauthority.com/2010/06/14/sqlauthority-news-author-visit-sql-server-2008-r2-launch/): June 11, 2010 was a wonderful day because I attended the very first SQL Server 2008 R2 Launch event held by Microsoft at Mumbai. I traveled to Mumbai from my home town, Ahmedabad. The event was located at one of the best hotels in Mumbai,”The Leela”. SQL Server R2 Launch was an evening event that had a few interesting talks. SQL PASS is associated with this event as one of the partners and its goal is to increase the awareness of the Community about SQL Server. I met many interesting people and had a great networking opportunity at the event. This... - [SQL SERVER - What is Denali?](https://blog.sqlauthority.com/2010/06/13/sql-server-what-is-denali/): I see following question quite common on Twitter or in my email box. “What is Denali?” Denali is code name of SQL Server 2011. Here is the list of the code name of other versions of SQL Server. In 1988, Microsoft released its first version of SQL Server. It was developed jointly by Microsoft and Sybase for the OS/2 platform. 1993 – SQL Server 4.21 for Windows NT 1995 – SQL Server 6.0, codenamed SQL95 1996 – SQL Server 6.5, codenamed Hydra 1999 – SQL Server 7.0, codenamed Sphinx 1999 – SQL Server 7.0 OLAP, codenamed Plato 2000 – SQL Server... - [SQL SERVER - Difference Between DATETIME and DATETIME2 - WITH GETDATE](https://blog.sqlauthority.com/2010/06/12/sql-server-difference-between-datetime-and-datetime2-with-getdate/): Earlier I wrote blog post SQL SERVER – Difference Between GETDATE and SYSDATETIME which inspired me to write SQL SERVER – Difference Between DATETIME and DATETIME2. Now earlier two blog post inspired me to write this blog post (and 4 emails and 3 reads from readers). I previously populated DATETIME and DATETIME2 field with SYSDATETIME, which gave me very different behavior as SYSDATETIME was rounded up/down for the DATETIME datatype. I just ran the same experiment but instead of populating SYSDATETIME in this script I will be using GETDATE function. DECLARE @Intveral INT SET @Intveral = 10000 CREATE TABLE #TimeTable (FirstDate DATETIME, LastDate DATETIME2)... - [SQL SERVER - Difference Between DATETIME and DATETIME2](https://blog.sqlauthority.com/2010/06/11/sql-server-difference-between-datetime-and-datetime2/): Yesterday I have written a very quick blog post on SQL SERVER – Difference Between GETDATE and SYSDATETIME and I got tremendous response for the same. I suggest you read that blog post before continuing with this blog post today. I had asked people to honestly take part and share their view about the above two system functions. There are few emails as well as few comments on the blog post asking a question on how did I come to know the difference between the same. The answer is from real world issues. I was called in for performance tuning consultancy,... - [SQL SERVER - Difference Between GETDATE and SYSDATETIME](https://blog.sqlauthority.com/2010/06/10/sql-server-difference-between-getdate-and-sysdatetime/): Sometime something so simple skips our mind. I never knew the difference between GETDATE and SYSDATETIME. I just ran simple query as following and realized the difference. SELECT GETDATE() fn_GetDate, SYSDATETIME() fn_SysDateTime In case of GETDATE the precision is till miliseconds and in case of SYSDATETIME the precision is till nanoseconds. Now the questions is to you – did you know this? Be honest and please share your views. I already accepted that I did not know this in very first line. This applies to SQL Server 2008 only. Reference: Pinal Dave (http://www.SQLAuthority.com), - [SQL SERVER - Fastest Way to Restore Database](https://blog.sqlauthority.com/2010/06/09/sql-server-fastest-way-to-restore-the-database/): A few days ago, I received following email from blog reader where the question was about the fastest way to restore database. - [SQL SERVER - Merge Operations - Insert, Update, Delete in Single Execution](https://blog.sqlauthority.com/2010/06/08/sql-server-merge-operations-insert-update-delete-in-single-execution/): This blog post is written in response to T-SQL Tuesday hosted by Jorge Segarra. I have been very active using these Merge operations in my development. However, I have found out from my consulting work and friends that these amazing operations are not utilized by them most of the time. Here is my attempt to bring the necessity of using the Merge Operation to surface one more time. - [SQL SERVER - Subquery or Join - Various Options - SQL Server Engine Knows the Best - Part 2](https://blog.sqlauthority.com/2010/06/07/sql-server-subquery-or-join-various-options-sql-server-engine-knows-the-best-part-2/): This blog post is part 2 of the earlier written article SQL SERVER – Subquery or Join – Various Options – SQL Server Engine knows the Best by Paulo R. Pereira. Paulo has left excellent comment to earlier article once again proving the point that SQL Server Engine is smart enough to figure out the best plan itself and uses the same for the query. Let us go over his comment as he has posted. “I think IN or EXISTS is the best choice, because there is a little difference between ‘Merge Join’ of query with JOIN (Inner Join) and the... - [SQL SERVER - Subquery or Join - Various Options - SQL Server Engine knows the Best](https://blog.sqlauthority.com/2010/06/06/sql-server-subquery-or-join-various-options-sql-server-engine-knows-the-best/): This is followup post of my earlier article SQL SERVER – Convert IN to EXISTS – Performance Talk, after reading all the comments I have received I felt that I could write more on the same subject to clear few things out. First let us run following four queries, all of them are giving exactly same resultset. USE AdventureWorks GO -- use of = SELECT * FROM HumanResources.Employee E WHERE E.EmployeeID = ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- use of in SELECT * FROM HumanResources.Employee E WHERE E.EmployeeID IN ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- use of exists SELECT * FROM HumanResources.Employee E... - [SQL SERVER - Convert IN to EXISTS - Performance Talk](https://blog.sqlauthority.com/2010/06/05/sql-server-convert-in-to-exists-performance-talk/): In recent training one of the attendee asked if I can show a simple method to convert IN clause to EXISTS clause so it impacts performance. Here is the simple example. - [SQL SERVER - Generate Database Script for SQL Azure](https://blog.sqlauthority.com/2010/06/04/sql-server-generate-database-script-for-sql-azure/): When talking about SQL Azure the common complaint I hear is that the script generated from stand-along SQL Server database is not compatible with SQL Azure. This was true for some time for sure, but not any more. If you have SQL Server 2008 R2 installed you can follow the guideline below to generate a script which is compatible with SQL Azure. - [SQLAuthority News - Training and Consultancy and Travel - Story of Last 30 Days](https://blog.sqlauthority.com/2010/06/03/sqlauthority-news-training-and-consultancy-and-travel-story-of-30-last-30-days/): Today’s blog post is not technical as usual. Here, I present a real story, and I also invite you all to share your thoughts or opinions on this post. I am a professional SQL Server Trainer; I also do consultation in the area of the Performance Tuning and Query Optimizations. In any month, I like the mix of both in my schedule. I prefer to do training for one week, and then commit the next week for some consultation work. Due to the advancement in technology, for most of the consultation works, there is no client location visit or first time... - [SQL SERVER - Stored Procedure and Transactions](https://blog.sqlauthority.com/2010/06/02/sql-server-stored-procedure-and-transactions/): I just overheard the following statement – “I do not use Transactions in SQL as I use Stored Procedure“. I just realized that there are so many misconceptions about this subject. Transactions has nothing to do with Stored Procedures. Let me demonstrate that with a simple example. USE tempdb GO -- Create 3 Test Tables CREATE TABLE TABLE1 (ID INT); CREATE TABLE TABLE2 (ID INT); CREATE TABLE TABLE3 (ID INT); GO -- Create SP CREATE PROCEDURE TestSP AS INSERT INTO TABLE1 (ID) VALUES (1) INSERT INTO TABLE2 (ID) VALUES ('a') INSERT INTO TABLE3 (ID) VALUES (3) GO -- Execute SP --... - [SQLAuthority News - Microsoft SQL Server Compact 3.5 Server Tools Beta 2 Released](https://blog.sqlauthority.com/2007/08/03/sqlauthority-news-microsoft-sql-server-compact-35-server-tools-beta-2-released/): SQL Server Compact 3.5 Server Tools installs replication components on the IIS server enabling merge replication and remote data access (RDA) between SQL Server Compact 3.5 database on a Windows Desktop & Mobile devices and database servers running SQL Server 2005 and later versions of SQL Server 2005. Download SQL Server Compact 3.5 For more information please see the SQL Server Compact 3.5 Books Online Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Two Different Ways to Comment Code - Explanation and Example](https://blog.sqlauthority.com/2007/08/03/sql-server-two-different-ways-to-comment-code-explanation-and-example/): SQL Server has two different ways to comment code. Let us learn all of them here in this blog post. Various the options in the blog posts. - [SQLAuthority News - Book Review - SQL Server 2005 Practical Troubleshooting: The Database Engine](https://blog.sqlauthority.com/2007/08/02/sqlauthority-news-book-review-sql-server-2005-practical-troubleshooting-the-database-engine/): SQLAuthority.com Book Review : SQL Server 2005 Practical Troubleshooting: The Database Engine (SQL Server Series) (Paperback) by Ken Henderson Link to book on Amazon Short Review : Database Administrators can use this book on a daily basis in SQL Server 2005 troubleshooting and problem solving. Answers to SQL issues can be swiftly located using the index of this book.This book covers the topics and subjects which any other books, blogs or websites (including MSDN, BOL) do not cover. This book provides DBAs with solutions which can be used by user in highly dynamic environments to resolve common and specialized problems. This... - [SQL SERVER - FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details](https://blog.sqlauthority.com/2007/08/02/sql-server-fix-error-945-database-cannot-be-opened-due-to-inaccessible-files-or-insufficient-memory-or-disk-space-see-the-sql-server-error-log-for-details/): SQL SERVER – FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details This error is very common and many times, I have seen affect of this error as Suspected Database, Database Operation Ceased, Database Stopped transactions. Solution to this error is simple but very important. Fix/Solution/WorkAround: 1) If possible add more hard drive space either by removing of unnecessary files from hard drive or add new hard drive with larger size. 2) Check if the database is set to Autogrow on. 3) Check if... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Search SQL](https://blog.sqlauthority.com/2007/08/01/sql-server-sql-joke-sql-humor-sql-laugh-search-sql/): In meeting with DBA friends one of my friend suggested while searching for “MSSQL Client” Microsoft returns you suggestion as “MySQL Client“. I did not believe it so I tested it myself. He was correct. Here is the screen shot. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - July CTP Released](https://blog.sqlauthority.com/2007/08/01/sql-server-2008-july-ctp-released/): SQL Server 2008 July Community Technology Preview has been released. With SQL Server 2008 July CTP release, customers can immediately utilize new capabilities that support their mission-critical platform and enable pervasive insight across the enterprise. SQL Server 2008 lays the groundwork for innovative policy-based management that enables administrators to reduce their time spent on maintenance tasks. SQL Server 2008 provides enhancements in the SQL Server BI platform by enabling customers to provide up-to-date information with Change Data Capture and MERGE features, and develop highly scalable analysis services cubes with new development environments. - [SQLAuthority News - My Favorite Articles of This Blog](https://blog.sqlauthority.com/2007/07/31/sqlauthority-news-my-favorite-articles-of-this-blog/): The question I receive very often is I have more than 250 articles so far on this blog, which are my most favorite articles so far? Yesterday while talking with my parents on occasion of my birthday, they asked the same question to me. Answer is I keep running list of the my personal favorite articles on my personal website. I update it very frequently. Visit Author’s Personal Favorite Best Articles List Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Birthday of SQL Authority Author](https://blog.sqlauthority.com/2007/07/30/sqlauthority-news-birthday-of-sql-authority-author/): Today is Birthday of SQL Authority Author. Thought of the day : Family is everything. https://www.pinaldave.com/ http://www.SQLAuthority.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Data Warehousing Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/07/29/sql-server-data-warehousing-interview-questions-and-answers-complete-list-download/): Click here to get free chapters (PDF) in the mailbox It was a great pleasure to write latest series about Data Warehousing Interview Questions and Answers. Just like always again, I received lots of suggestion and follow up questions. I have tried to accommodate all of them in the last post in the series. I hope this series is helpful to all candidates who are seeking a job as well interviewers. I have combined all the questions and answers in the one PDF which is available to download and refer at convenience. Complete Series of SQL Server Interview Questions and Answers... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/07/28/sql-server-data-warehousing-interview-questions-and-answers-part-3/): Click here to get free chapters (PDF) in the mailbox What are slowly changing dimensions (SCD)? SCD is abbreviation of Slowly changing dimensions. SCD applies to cases where the attribute for a record varies over time. There are three different types of SCD. 1) SCD1 : The new record replaces the original record. Only one record exist in database – current data. 2) SCD2 : A new record is added into the customer dimension table. Two records exist in database – current data and previous history data. 3) SCD3 : The original data is modified to include new data. One record... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/07/27/sql-server-data-warehousing-interview-questions-and-answers-part-2/): Click here to get free chapters (PDF) in the mailbox What are normalization forms? Please visit this article. Describes the foreign key columns in fact table and dimension table? Foreign keys of dimension tables are primary keys of entity tables. Foreign keys of facts tables are primary keys of Dimension tables. What is Data Mining? Data Mining is the process of analyzing data from different perspectives and summarizing it into useful information. What is the difference between view and materialized view? A view takes the output of a query and makes it appear like a virtual table and it can be... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/07/26/sql-server-data-warehousing-interview-questions-and-answers-part-1/): Let us learn about Data Warehousing Interview Questions and Answers. - [SQLAuthority News - Interesting Read - Programming Concepts, Structured Thinking Language (STL) and Relationary](https://blog.sqlauthority.com/2007/07/25/sqlauthority-news-interesting-read-programming-concepts-structured-thinking-language-stl-and-relationary/): I have always enjoyed reading articles and blogs which are different then others. There many be thousands of technology and programming blogs, only few makes difference in the tech world. One of the high quality blog, I enjoy reading is relationary by Grant Czerepak. Grant Czerepak is an IT professional with over 20 years experience in relational database technology specifically in the areas of design, development and administration. As per Grant Czerepak “In this blog I will be mixing, matching, shifting and sifting paradigms that have come up in my work with relational databases and other concepts I’ve picked up while... - [SQL SERVER - Data Warehousing Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/07/25/sql-server-data-warehousing-interview-questions-and-answers-introduction/): Click here to get free chapters (PDF) in the mailbox This series is in response to many of my reader’s continuous request to start Data Warehousing Interview Questions and Answers series. This series is written in the same spirit as previous two series which has received good response. Samples Question from Interview Questions and Answer Series What is Data Warehousing? A data warehouse is the main repository of an organization’s historical data, its corporate memory. It contains the raw material for management’s decision support system. The critical factor leading to the use of a data warehouse is that a data analyst... - [SQL SERVER - 2005 - Server and Database Level DDL Triggers Examples and Explanation](https://blog.sqlauthority.com/2007/07/24/sql-server-2005-server-and-database-level-ddl-triggers-examples-and-explanation/): Let's learn about Server and Database Level DDL Triggers Examples and Explanation here. Let us learn more about this topic. - [SQL SERVER - UDF - Function to Get Previous And Next Work Day - Exclude Saturday and Sunday](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-function-to-get-previous-and-next-work-day-exclude-saturday-and-sunday/): While reading ColdFusion blog of Ben Nadel Getting the Previous Day In ColdFusion, Excluding Saturday And Sunday, I realize that I use similar function on my SQL Server Database. This function excludes the Weekends (Saturday and Sunday), and it gets previous as well as next work day. - [SQL SERVER - UDF - Get the Day of the Week Function](https://blog.sqlauthority.com/2007/07/23/sql-server-udf-get-the-day-of-the-week-function/): The day of the week can be retrieved in SQL Server by using the DatePart function. The value returned by function is between 1 (Sunday) and 7 (Saturday). To convert this to a string representing the day of the week, use a CASE statement. Method 1: Create function running following script: CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE @rtDayofWeek VARCHAR(10) SELECT @rtDayofWeek = CASE DATEPART(weekday,@dtDate) WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN 'Wednesday' WHEN 5 THEN 'Thursday' WHEN 6 THEN 'Friday' WHEN 7 THEN 'Saturday' END RETURN (@rtDayofWeek) END GO Call... - [SQLAuthority News - FQL - Facebook Query Language](https://blog.sqlauthority.com/2007/07/22/sqlauthority-news-fql-facebook-query-language/): I was exploring the new hype today, I found Facebook Developers Documentation very interesting. Facebook API can be queries using FQL - Facebook Query Language, which is similar to SQL. - [SQL SERVER - Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database 'yourdatabasename'. CREATE DATABASE is aborted.](https://blog.sqlauthority.com/2007/07/21/sql-server-fix-error-msg-1813-level-16-state-2-line-1-could-not-open-new-database-yourdatabasename-create-database-is-aborted/): Fix : Error Msg 1813, Level 16, State 2, Line 1 Could not open new database ‘yourdatabasename’. CREATE DATABASE is aborted. This errors happens when corrupt database log are attempted to attach to new server. Solution of this error is little long and it involves restart of the server. I recommend following all the steps below in order without skipping any of them. Fix/Solution/Workaround: SQL Server logs are corrupted and they need to be rebuilt to make the database operational. Follow all the steps in order. Replace the yourdatabasename name with real name of your database. 1. Create a new database... - [SQL SERVER - Fix : Error Msg 4214 - Error Msg 3013 - BACKUP LOG cannot be performed because there is no current database backup](https://blog.sqlauthority.com/2007/07/20/sql-server-fix-error-msg-4214-error-msg-3013-backup-log-cannot-be-performed-because-there-is-no-current-database-backup/): This is very interesting error as I could not found any documentation on-line. It took me nearly 1 hour to figure out what was creating error. - [SQL SERVER - 2005 - SSMS - View/Send Query Results to Text/Grid/Files](https://blog.sqlauthority.com/2007/07/19/sql-server-2005-ssms-viewsend-query-results-to-textgridfiles/): Many times I have been asked how to change the result window from Text to Grid and vice versa. There are three different ways to do it. Method 1 : Key-Board Short Cut Results to Text – CTRL + T Results to Grid – CTRL + D Results to File – CTRL + SHIFT + F Method 2 : Using Toolbar Method 3 : Using Menubar Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SPACE Function Example](https://blog.sqlauthority.com/2007/07/19/sql-server-space-function-example/): A month ago, I wrote about SQL SERVER – TRIM() Function – UDF TRIM() . I was asked in comment if SQL Server has space function? Yes. SELECT SPACE(100) will generate 100 space characters. The use of SPACE() function is demonstrated in BOL very fine. Example from BOL: USE AdventureWorks; GO SELECT RTRIM(LastName) + ',' + SPACE(2) + LTRIM(FirstName) FROM Person.Contact ORDER BY LastName, FirstName; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Restore Database Without or With Backup - Everything About Restore and Backup](https://blog.sqlauthority.com/2007/07/18/sql-server-restore-database-without-or-with-backup-everything-about-restore-and-backup/): The questions I received in last two weeks: “I do not have backup, is it possible to restore database to previous state?” “How can restore the database without using backup file?” “I accidentally deleted tables in my database, how can I revert back?” “How to revert the changes, I have only logs but no complete backup?” “How to rollback the database changes, my backup file is corrupted?” Answer: You need complete backup to rollback your changes. If you do not have complete backup you can not revert back. Sorry. To restore the database to previous stage if you have full backup:... - [SQL SERVER - CASE Statement in ORDER BY Clause - ORDER BY using Variable](https://blog.sqlauthority.com/2007/07/17/sql-server-case-statement-in-order-by-clause-order-by-using-variable/): This article is as per request from Application Development Team Leader of my company. His team encountered code where application was preparing string for ORDER BY clause of SELECT statement. Application was passing this string as variable to Stored Procedure (SP) and SP was using EXEC to execute the SQL string. This is not good for performance as Stored Procedure has to recompile every time due to EXEC. sp_executesql can do the same task but still not the best performance. Previously: Application: Nesting logic to prepare variable OrderBy. Database: Stored Procedure takes variable OrderBy as input parameter. SP uses EXEC (or... - [SQL SERVER - Microsoft White Papers - Analysis Services Query Best Practices - Partial Database Availability](https://blog.sqlauthority.com/2007/07/16/sql-server-microsoft-white-papers-analysis-services-query-best-practices-partial-database-availability/): Microsoft TechNet frequently releases White Papers on SQL Server Technology. I have read the following two white papers recently. The summary of its content is here. Analysis Services Query Performance Top 10 Best Practices Optimize cube and measure group design Define effective aggregations Use partitions Write efficient MDX Use the query engine cache efficiently Ensure flexible aggregations are available to answer queries. Tune memory usage Tune processor usage Scale up where possible Scale out when you can no longer scale up Partial Database Availability Writer: Danny Tambs Download Word Document As databases become larger and larger, the infrastructure assets and technology... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - 15 Signs to Identify Bad DBA](https://blog.sqlauthority.com/2007/07/15/sql-server-sql-joke-sql-humor-sql-laugh-15-signs-to-identify-bad-dba/): 15 Signs to Identify Bad DBA They think it is bug in SQL Server when two NULL values compared with each other but SQL Server does not say they equal to each other. They do not rename the trigger name thinking it will not work after it is rename. They are looking for difference between Index Scan or Table Scan on Google. They reinstall the SQL Server if they forget the password of SA login. They use model database for testing their script. They believe compiled stored procedure is production ready. They prefix all stored procedures with ‘sp_’ to be consistent... - [SQL SERVER - 2005 Collation Explanation and Translation - Part 2](https://blog.sqlauthority.com/2007/07/14/sql-server-2005-collation-explanation-and-translation-part-2/): Following function return all the available collation of SQL Server 2005. My previous article about the SQL SERVER – 2005 Collation Explanation and Translation. SELECT * FROM sys.fn_HelpCollations() Result Set: (only few of 1011 records) Name Description Latin1_General_BIN Latin1-General, binary sort Latin1_General_BIN2 Latin1-General, binary code point comparison sort Latin1_General_CI_AI Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AI_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AI_KS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AI_KS_WS Latin1-General, case-insensitive, accent-insensitive, kanatype-sensitive, width-sensitive Latin1_General_CI_AS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive Latin1_General_CI_AS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-sensitive Latin1_General_CI_AS_KS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-insensitive Latin1_General_CI_AS_KS_WS Latin1-General, case-insensitive, accent-sensitive, kanatype-sensitive, width-sensitive Latin1_General_CS_AI Latin1-General, case-sensitive, accent-insensitive, kanatype-insensitive,... - [SQL SERVER - 2005 - Use ALTER DATABASE MODIFY NAME Instead of sp_renameDB to rename](https://blog.sqlauthority.com/2007/07/13/sql-server-2005-use-alter-database-modify-name-instead-of-sp_renamedb-to-rename/): To rename database it is very common to use for SQL Server 2000 user : EXEC sp_renameDB 'oldDB','newDB' sp_renameDB syntax will be deprecated in the future version of SQL Server. It is supported in SQL Server 2005 for backwards compatibility only. It is recommended to use ALTER DATABASE MODIFY NAME instead. New syntax of ALTER DATABASE MODIFY NAME is simple as well. /* Create Test Database */ CREATE DATABASE Test GO /* Rename the Database Test to NewTest */ ALTER DATABASE Test MODIFY NAME = NewTest GO /* Cleanup NewTest Database Do not run following command if you want to use the database. It is dropped here for sample database clean up. */ DROP DATABASE NewTest GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - Validate Field For DATE datatype using function ISDATE()](https://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/): This article is based on the a question from Jr. Developer at my company. He works with the system, where we import CSV file in our database. One of the fields in the database is DATETIME field. Due to architecture requirement, we insert all the CSV fields in the temp table which has all the fields VARCHAR. We validate all the data first in temp table (check for inconsistency, malicious code, incorrect data type) and if passed validation we insert them in the final table in the database. Let us learn about ISDate function in this blog post. - [SQLAuthority News - SQL Blog SQLAuthority.com Comment by Mr. Ben Forta](https://blog.sqlauthority.com/2007/07/11/sqlauthority-news-sql-blog-sqlauthoritycom-comment-by-mr-ben-forta/): Today is one of the most glorious day for SQLAuthority.com in history. Famous author of Sams Teach Yourself Microsoft SQL Server T-SQL In 10 Minutes, ColdFusion Guru, and well known evangelists Mr. Ben Forta has made comment on his blog about SQLAuthority.com. I encourage all my readers to visit comment link here. I am very thankful to Mr. Forta for finding time to visit my blog from his busy schedule. I am attaching screen shot of the original post along with this post for reference. Mr. Forta said, “Pinalkumar Dave is a DBA with extensive SQL Server (and ColdFusion) experience. I... - [SQL SERVER - 2005 - Features Comparison Chart](https://blog.sqlauthority.com/2007/07/11/sql-server-2005-features-comparison-chart/): This post in the response to all the readers who have asked what are the differences between SQL Server 2005 editions. The reason I have never posted article about this as Microsoft has wonderful comparison chart on Microsoft SQL Server web site. This chart explains the difference between features of Express, Workgroup, Standard, and Enterprise editions. Visit Microsoft SQL Server 2005 Editions Features Comparison Chart Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - Scheduled Launch at an Event in Los Angeles on Feb. 27, 2008](https://blog.sqlauthority.com/2007/07/11/sql-server-2008-scheduled-launch-at-an-event-in-los-angeles-on-feb-27-2008/): SQL SERVER 2008 will be launched at an Event in Los Angeles on Feb. 27, 2008. “In anticipation for the most significant Microsoft enterprise event in the next year, Turner announced that Windows Server® 2008, Visual Studio® 2008 and Microsoft SQL Server™ 2008 will launch together at an event in Los Angeles on Feb. 27, 2008, kicking off hundreds of launch events around the world.” Read original article here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Count Duplicate Records - Rows](https://blog.sqlauthority.com/2007/07/11/sql-server-count-duplicate-records-rows/): In my previous article SQL SERVER – Delete Duplicate Records – Rows, we have seen how we can delete all the duplicate records in one simple query. In this article we will see how to find count of all the duplicate records in the table. Following query demonstrates usage of GROUP BY, HAVING, ORDER BY in one query and returns the results with duplicate column and its count in descending order. SELECT YourColumn, COUNT(*) TotalCount FROM YourTable GROUP BY YourColumn HAVING COUNT(*) > 1 ORDER BY COUNT(*) DESC Watch the view to see the above concept in action: [youtube=http://www.youtube.com/watch?v=ioDJ0xVOHDY] Reference : Pinal Dave (https://blog.sqlauthority.com)... - [SQL SERVER - 2005 - List All Stored Procedure Modified in Last N Days](https://blog.sqlauthority.com/2007/07/10/sql-server-2005-list-all-stored-procedure-modified-in-last-n-days/): I usually run following script to check if any stored procedure was deployed on live server without proper authorization in last 7 days. If SQL Server suddenly start behaving in un-expectable behavior and if stored procedure were changed recently, following script can be used to check recently modified stored procedure. If stored procedure was created but never modified afterwards modified date and create date for that stored procedure are same. SELECT name FROM sys.objects WHERE type = 'P' AND DATEDIFF(D,modify_date, GETDATE()) < 7 ----Change 7 to any other day value Following script will provide name of all the stored procedure which... - [SQL SERVER - Result of EXP (Exponential) to the POWER of PI - Functions Explained](https://blog.sqlauthority.com/2007/07/09/sql-server-result-of-exp-exponential-to-the-power-of-pi-functions-explained/): SQL Server can do some intense Mathematical calculations. Following are three very basic and very necessary functions. All the three function does not need explanation. I will not introduce their definition but will demonstrate the usage of function. SELECT PI() GO SELECT POWER(2,5) GO SELECT POWER(8,-2) GO SELECT EXP(99) GO SELECT EXP(1) GO Results Set : PI ———————- 3.14159265358979 PowerEg1 ———– 32 PowerEg2 ———– 0 ExpEg1 ———————- 9.88903031934695E+42 ExpEg2 ———————- 2.71828182845905 Now the Questions asked in the Title of the Article – What is the result of EXP to the POWER of PI SELECT POWER(EXP(1), PI()) GO Results ———————- 23.1406926327793 Reference... - [SQL SERVER - FIX : ERROR Msg 244, Level 16, State 1 - FIX : ERROR Msg 245, Level 16, State 1](https://blog.sqlauthority.com/2007/07/08/sql-server-fix-error-msg-244-level-16-state-1-fix-error-msg-245-level-16-state-1/): FIX : ERROR Msg 244, Level 16, State 1, Line 1 FIX : ERROR Msg 245, Level 16, State 1, Line 1 This error can happen due to conversion of one data type to incompatible datatype. Few examples are: VARCHAR to INT, INT to TINYINT etc. I have spotted this error happening with CAST or ISNULL, please add comments if you have come across this error in other examples. Following scripts will create this error. SELECT CAST('111111' AS SMALLINT); SELECT CAST('This is not smallint' AS SMALLINT); The errors received from above two scripts are : Msg 244, Level 16, State 2,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Generic Quotes](https://blog.sqlauthority.com/2007/07/08/sql-server-sql-joke-sql-humor-sql-laugh-generic-quotes/): Few days ago, in meeting I was forced to answer one of the question from non-programmer was considered as funny quotes for long time. “Yes it is latest year 2005 version of SQL Server – still it will not play your flash movie” — Pinal Dave (SQLAuthority.com) Many of following quotes are well apply to SQL Server or any database and I find them humorous. Software is Too Important to be Left to Programmers — Meilir Page-Jones. A clever person solves a problem. A wise person avoids it. — Einstein If you think good architecture is expensive, try bad architecture. —... - [SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT](https://blog.sqlauthority.com/2007/07/07/sql-server-convert-text-to-numbers-integer-cast-and-convert/): Few of the questions I receive very frequently. I have collect them in spreadsheet and try to answer them frequently. How to convert text to integer in SQL? If table column is VARCHAR and has all the numeric values in it, it can be retrieved as Integer using CAST or CONVERT function. How to use CAST or CONVERT? SELECT CAST(YourVarcharCol AS INT) FROM Table SELECT CONVERT(INT, YourVarcharCol) FROM Table Will CAST or CONVERT thrown an error when column values converted from alpha-numeric characters to numeric? YES. Will CAST or CONVERT retrieve only numbers when column values converted from alpha-numeric characters to... - [SQL SERVER - FIX : Error : msg 8115, Level 16, State 2, Line 2 - Arithmetic overflow error converting expression to data type](https://blog.sqlauthority.com/2007/07/06/sql-server-fix-error-msg-8115-level-16-state-2-line-2-arithmetic-overflow-error-converting-expression-to-data-type/): Following errors can happen when any field in the database is attempted to insert or update larger data of the same type or other data type. Msg 8115, LEVEL 16, State 2, Line 2 Arithmetic overflow error converting expression TO data type <ANY DataType> Example is if integer 111111 is attempted to insert in TINYINT data type it will throw above error, as well as if integer 11111 is attempted to insert in VARCHAR(2) data type it will throw above error. Fix/Solution/Workaround: 1) Verify the inserted/updated value that it is of correct length and data type. 2) If inserted/updated value are... - [SQL SERVER - 2005 - Microsoft Document Explorer cannot be shown because the specified help collection 'ms-help://MS.SQLCC.v9](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-microsoft-document-explorer-cannot-be-shown-because-the-specified-help-collection-ms-helpmssqlccv9/): I have received six emails in last four days asking for the resolution of error when tried to open newly installed SQL Server Book On-Line. Microsoft Document Explorer cannot be shown because the specified help collection ‘ms-help://MS.SQLCC.v9 1) Uninstall the versions of Book On-line (different languages, different releases etc) using Add-Remove programs tools. 2) Re-install SQL Server Book On-line. Above solution is confirmed by MSDN site here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Best Practices Analyzer Tutorial - Sample Example](https://blog.sqlauthority.com/2007/07/05/sql-server-2005-best-practices-analyzer-tutorial-sample-example/): Yesterday I posted small note about SQL SERVER – 2005 Best Practices Analyzer (July BPA). I received many request about how BPA is used. Some of readers has asked me to provide sample tutorial which can help start using BPA. This utility has many uses for best practice. I have created very simple and initial tutorial. I encourage to follow that and once used it create your own reports in your desired format. Do not hesitate to install this add-on as I have use this previously to tune our production servers. Following tutorial about BPA is ran on one of my... - [SQL SERVER - 2005 Best Practices Analyzer (July BPA)](https://blog.sqlauthority.com/2007/07/04/sql-server-2005-best-practices-analyzer-july-bpa/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD HERE Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Definition, Comparison and Difference between HAVING and WHERE Clause](https://blog.sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/): In recent interview sessions in hiring process I asked this question to every prospect who said they know basic SQL. Surprisingly, none answered me correct. They knew lots of things in details but not this simple one. One prospect said he does not know cause it is not on this Blog. Well, here we are with same topic online. Answer in one line is : HAVING specifies a search condition for a group or an aggregate function used in SELECT statement. HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP... - [SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable](https://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/): #TempTable and @TempVariable are different things with different scope. Their purpose is different but highly overlapping. TempTables are originated for the storage and & storage & manipulation of temporal data. TempVariables are originated (SQL Server 2000 and onwards only) for returning date-sets from table-valued functions. Common properties of #TempTable and @TempVariable They are instantiated in tempdb. They are backed by physical disk. Changes to them are logged in the transaction log1. However, since tempdb always uses the simple recovery model, those transaction log records only last until the next tempdb checkpoint, at which time the tempdb log is truncated. Discussion of... - [SQL SERVER - 2005 Comparison SP_EXECUTESQL vs EXECUTE/EXEC](https://blog.sqlauthority.com/2007/07/02/sql-server-2005-comparison-sp_executesql-vs-executeexec/): Common Properties of SP_EXECUTESQL and EXECUTE/EXEC The Transact-SQL statements in the sp_executesql or EXECUTE string are not compiled into an execution plan until sp_executesql or the EXECUTE statement are executed. The strings are not parsed or checked for errors until they are executed. The names referenced in the strings are not resolved until they are executed. The Transact-SQL statements in the executed string do not have access to any of the variables declared in the batch that contains thesp_executesql or EXECUTE statement. The batch containing the sp_executesql or EXECUTE statement does not have access to variables or local cursors defined in... - [SQL SERVER - Explanation of WITH ENCRYPTION clause for Stored Procedure and User Defined Functions](https://blog.sqlauthority.com/2007/07/01/sql-server-explanation-of-with-encryption-clause-for-stored-procedure-and-user-defined-functions/): This article is written to answer following two questions I have received in last one week. Questions 1) How to hide code of my Stored Procedure that no one can see it? 2) Our DBA has left the job and one of the function which retrieves important information is encrypted, how can we decrypt it and find original code? Answers 1) Use WITH ENCRYPTION while creating Stored Procedure or User Defined Function. 2) Sorry, unfortunately there is no simple way to decrypt the code. Hard way is too hard to even attempt. Explanations of WITH ENCRYPTION clause If SP or UDF... - [SQL SERVER - Fix : Error : Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type 'varchar' exceeds the maximum allowed for any data type (8000)](https://blog.sqlauthority.com/2007/06/30/sql-server-fix-error-server-msg-131-level-15-state-3-line-1-the-size-given-to-the-type-varchar-exceeds-the-maximum-allowed-for-any-data-type-8000/): Error: Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type ‘varchar’ exceeds the maximum allowed for any data type (8000) When the the length is specified in declaring a VARCHAR variable or column, the maximum length allowed is still 8000. Fix/WorkAround/Solution: Use either VARCHAR(8000) or VARCHAR(MAX) . VARCHAR(MAX) of SQL Server 2005 is replacement of TEXT of SQL Server 2000. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recompile All The Stored Procedure on Specific Table](https://blog.sqlauthority.com/2007/06/29/sql-server-recompile-all-the-stored-procedure-on-specific-table/): I have noticed that after inserting many rows in one table many times the stored procedure on that table executes slower or degrades. This happens quite often after BCP or DTS. I prefer to recompile all the stored procedure on the table, which has faced mass insert or update. sp_recompiles marks stored procedures to recompile when they execute next time. Example: ----Following script will recompile all the stored procedure on table Sales.Customer in AdventureWorks database. USE AdventureWorks; GO EXEC sp_recompile N'Sales.Customer'; GO ----Following script will recompile specific stored procedure uspGetBillOfMaterials only. USE AdventureWorks; GO EXEC sp_recompile 'uspGetBillOfMaterials'; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL - [SQL SERVER - 2005 Improvements in TempDB](https://blog.sqlauthority.com/2007/06/28/sql-server-2005-improvements-in-tempdb/): Following are some important improvements in tempdb in SQL Server 2005 over SQL Server 2000 Input/Output traffic to TempDB is reduced as logging is improved. In SQL Server 2005 TempDB does not log “after value” everytime. E.g. For INSERT it does not log after value on log as that will be any way logged in the TempTable. Similar for DELETE as It does not have to log After value as it is not there. This is big improvement in performance in SQL Server 2005 for TempDB. Some other improvement in File System of operating system. (I am not listing them as... - [SQL SERVER - Running Batch File Using T-SQL - xp_cmdshell bat file](https://blog.sqlauthority.com/2007/06/27/sql-server-running-batch-file-using-t-sql/): In last month I received few emails emails regarding SQL SERVER – Enable xp_cmdshell using sp_configure. The questions are 1) What is the usage of xp_cmdshell and 2) How to execute BAT file using T-SQL? I really like the follow up questions of my posts/articles. Answer is xp_cmdshell can execute shell/system command, which includes batch file. 1) Example of running system command using xp_cmdshell is SQL SERVER – Script to find SQL Server on Network EXEC master..xp_CMDShell 'ISQL -L' 2) Example of running batch file using T-SQL i) Running standalone batch file (without passed parameters) EXEC master..xp_CMDShell 'c:findword.bat' ii) Running parameterized batch... - [SQL SERVER - 2005 List All Tables of Database](https://blog.sqlauthority.com/2007/06/26/sql-server-2005-list-all-tables-of-database/): This is very simple and can be achieved using system table sys.tables. USE YourDBName GO SELECT * FROM sys.Tables GO This will return all the tables in the database which user have created. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Explanation and Example Four Part Name](https://blog.sqlauthority.com/2007/06/26/sql-server-explanation-and-example-four-part-name/): What is four part name? Explanation : ServerName.DatabaseName.DatabaseOwner.TableName Example : localhost.AdventureWorks.Person.Contact Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Repeate String N Times Using String Function REPLICATE](https://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/): I came across this SQL String Function few days ago while searching for Database Replication. This is T-SQL Function and it repeats the string/character expression N number of times specified in the function. SELECT REPLICATE( ' https://blog.sqlauthority.com/ ' , 9 ) This repeats the string https://blog.sqlauthority.com/ to 9 times in result window. I think it is fun utility to generate repeated text if ever required. Result Set: https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ https://blog.sqlauthority.com/ (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com/) , BOL - [SQLAuthority News - Book Review - Microsoft(R) SQL Server 2005 Unleashed (Paperback)](https://blog.sqlauthority.com/2007/06/24/sqlauthority-news-book-review-microsoftr-sql-server-2005-unleashed-paperback/): SQLAuthority.com Book Review : Microsoft(R) SQL Server 2005 Unleashed (Paperback) by Ray Rankins, Paul Bertucci, Chris Gallelli, Alex T. Silverstein Link to book on Amazon Short Review : SQL Server 2005 Unleashed is focused on Database Administration and day-to-day administrative management aspects of SQL Server. All the chapters of this book are heavily based on Book On-line (BOL) and it continue discussing the topics, where BOL leaves off. This makes this book a good reference for those who are looking for additional information, tricks & tips, and behind the scene details. I recommend this book as a wonderful read and hands-on... - [SQL SERVER - Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild - SQL SERVER 2000 and SQL SERVER 2005](https://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/): Index Fragmentation: When a page of data fills to 100 percent and more data must be added to it, a page split occurs. To make room for the new data, SQL Server must move half of the data from the full page to a new page. The new page that is created is created after all the pages in database. Therefore, instead of going right from one page to the next when looking for data, SQL Server has to go one page to another page around the database looking for the next page it needs. This is Index Fragmentation. Severity of... - [SQL SERVER - 2005 Row Overflow Data Explanation](https://blog.sqlauthority.com/2007/06/23/sql-server-2005-row-overflow-data-explanation/): In SQL Server 2000 and SQL Server 2005 a table can have a maximum of 8060 bytes per row. One of my fellow DBA said that he believed that SQL Server 2000 had that restriction but SQL Server 2005 does not have that restriction and it can have a row of 2GB. I totally agreed with him but after we discussed this problem in depth, we realized that there are more into it than only 8060 bytes limit. It is still true for SQL Server 2005 that a table can have maximum of 8060 bytes per row however the restriction has... - [SQL SERVER - Explanation and Comparison of NULLIF and ISNULL](https://blog.sqlauthority.com/2007/06/22/sql-server-explanation-and-comparison-of-nullif-and-isnull/): Explanation of NULLIF Syntax: NULLIF ( expression , expression ) Returns a null value if the two specified expressions are equal. NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression. NULLIF is equivalent to a searched CASE function in which the two expressions are equal and the resulting expression is NULL. - [SQLAuthority.com News - iGoogle Gadget Published](https://blog.sqlauthority.com/2007/06/21/sqlauthoritycom-news-igoogle-gadget-published/): I have recently received many requests to add an iGoogle Gadget so it can be integrated on iGoogle home page so I’ve gone ahead and done so: Add iGoogle Gadget Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Retrieve Current DateTime in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}](https://blog.sqlauthority.com/2007/06/21/sql-server-retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/): There are three ways to retrieve the current datetime in SQL SERVER. CURRENT_TIMESTAMP, GETDATE(), {fn NOW()} - [SQL SERVER - Find Length of Text Field](https://blog.sqlauthority.com/2007/06/20/sql-server-find-length-of-text-field/): To measure the length of VARCHAR fields the function LEN(varcharfield) is useful. To measure the length of TEXT fields the function is DATALENGTH(textfield). Len will not work for text field. Example: SELECT DATALENGTH(yourtextfield) AS TEXTFieldSize Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com News - Journey to SQL Authority Milestone of SQL Server](https://blog.sqlauthority.com/2007/06/19/sqlauthoritycom-news-journey-to-sql-authority-milestone-of-sql-server/): SQLAuthority.com News – Journey to SQL Authority Milestone of SQL Server I am very glad to write this 200th post of this blog. I would like to express my gratitude to all of YOU – my readers for continuously reading this blog. I receive many comments and emails with feedback, questions and suggestion everyday. I enjoy meeting few of you during this journey as well. Please do send me feedback and your request to make this blog better. Following is milestone of Journey to SQL Authority. SQL Server Interview Questions and Answers Complete List Download (PDF) SQL Server Database Coding Standards... - [SQL SERVER - Delay Function - WAITFOR clause - Delay Execution of Commands](https://blog.sqlauthority.com/2007/06/18/sql-server-delay-function-waitfor-clause-delay-execution-of-commands/): Blocks the execution of a batch, stored procedure, or transaction until a specified time or time interval is reached, or a specified statement modifies or returns at least one row. This is very useful. Every day when I restore the database to backup server for reports post processing, I use WAITFOR clause. While executing the WAITFOR statement, the transaction is running and no other requests can run under the same transaction. If the server is busy, the thread may not be immediately scheduled; therefore, the time delay may be longer than the specified time. WAITFOR can be used with query but... - [SQL SERVER - De-fragmentation of Database at Operating System to Improve Performance](https://blog.sqlauthority.com/2007/06/17/sql-server-de-fragmentation-of-database-at-operating-system-to-improve-performance/): This issues was brought to me by our Sr. Network Engineer. While running operating system level de-fragmentation using either windows de-fragmentation or third party tool it always skip all the MDF file and never de-fragment them. He was wondering why this happens all the time. The reason MDF file are skipped all the time in de-fragmentation because they are in use when SQL Server is running. Windows operating system de-fragmentation skips all the file in are currently in use. After discovering this the real question was how to de-fragment when files are in use. Steps are Stop the Server, Re-start, keep... - [SQL SERVER - 2005 - UDF - User Defined Function to Strip HTML - Parse HTML - No Regular Expression](https://blog.sqlauthority.com/2007/06/16/sql-server-udf-user-defined-function-to-strip-html-parse-html-no-regular-expression/): One of the developers at my company asked is it possible to parse HTML and retrieve only TEXT from it without using regular expression. He wanted to remove everything between < and > and keep only Text. I found the question very interesting and quickly wrote UDF which does not use regular expression. Let us see how to parse HTML without regular expression. - [SQL SERVER - sp_HelpText for sp_HelpText - Puzzle](https://blog.sqlauthority.com/2007/06/15/sql-server-sp_helptext-for-sp_helptext-puzzle/): It was interesting to me. I was using sp_HelpText to see the text of the stored procedure. Stored Procedure were different so I had copied sp_HelpText on my clipboard and was pasting it in Query Editor of Management Studio. In rush I typed twice sp_HelpText and hit F5. Result was interesting. What are your guesses? My team mates and few of my readers suggested : SQL Server will be in recursive loop, SQL Server will be not responde, SQL Server will throw an error. Try this: sp_HelpText sp_HelpText Result was as expected. SQL Server did its job and displayed the text... - [SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases - Part 2](https://blog.sqlauthority.com/2007/06/15/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases-part-2/): I have mentioned the history of NorthWind, Pubs and AdventureWorks in my previous post SQL SERVER - 2005 NorthWind Database or AdventureWorks Database - Samples Databases. I have been receiving very frequent request for NorthWind Database for SQL Server 2005 and installation method. - [SQL SERVER - Easy Sequence of SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY](https://blog.sqlauthority.com/2007/06/14/sql-server-easy-sequence-of-select-from-join-where-group-by-having-order-by/): I was called many times by Jr. Programmers in team to debug their SQL. I keep log of most of the problems and review them afterwards. This helps me to evaluate my team and identify most important next thing which I can do to improve the performance and productivity of it. Recently we have many new hires and they had almost similar questions. Since, I have send them following sequence of the SELECT clause I am not interrupted often, which helps me to focus on larger project architectural design. SELECT yourcolumns FROM tablenames JOIN tablenames WHERE condition GROUP BY yourcolumns HAVING... - [SQL SERVER - Explanation SQL SERVER Hash Join](https://blog.sqlauthority.com/2007/06/14/sql-server-explanation-sql-server-hash-join/): Hash Join works with large data set. I have seen this join used many times in data warehouses applications as well as data mining algorithms. While its characteristics are similar to merge join it does not required ordered result set to join. Hash join requiresequijoin predicate to join tables. Equijoin predicate is comparing values between one table to other table using “equals to” (“=”) operator. Hash join gives best performance when two more join tables are joined and at-least one of them have no index or is not sorted. It is also expected that smaller of the either of table can... - [SQL SERVER - Fix : Error 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time.](https://blog.sqlauthority.com/2007/06/13/sql-server-fix-error-8629-the-query-processor-could-not-produce-a-query-plan-from-the-optimizer-because-a-query-cannot-update-a-text-ntext-or-image-column-and-a-clustering-key-at-the-same-time/): Error : 8629 The query processor could not produce a query plan from the optimizer because a query cannot update a text, ntext, or image column and a clustering key at the same time. - [SQL SERVER - Download 2005 Books Online (May 2007)](https://blog.sqlauthority.com/2007/06/13/sql-server-download-2005-books-online-may-2007/): Microsoft has merged SQL Server 2005 Expressed to SQL Server 2005 Books Online. New Version of SQL Server 2005 Books Online is released on June 12, 2007. Download SQL Server Books Online (BOL) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Recovery Models and Selection](https://blog.sqlauthority.com/2007/06/13/sql-server-recovery-models-and-selection/): SQL Server offers three recovery models: full recovery, simple recovery and bulk-logged recovery. The recovery models determine how much data loss is acceptable and determines whether and how transaction logs can be backed up. Select Simple Recovery Model if: * Your data is not critical. * Losing all transactions since the last full or differential backup is not an issue. * Data is derived from other data sources and is easily recreated. * Data is static and does not change often. Select Bulk-Logged Recovery Model if: * Data is critical, but logging large data loads bogs down the system. * Most... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2007/06/12/sql-server-sql-joke-sql-humor-sql-laugh-funny-quotes/): While searching WIKI I came across this oracle WIKI. I found this very funny. I have taken few quotes from this site. There are lot more stuff there. The degree of normality in a database is inversely proportional to that of its DBA. Program complexity grows until it exceeds the capability of the programmer who must maintain it. “Walking on water and developing software from a specification are easy if both are frozen.” — Edward V. Berard, “Life-Cycle Approaches” “Technology is dominated by two types of people: those who understand what they do not manage, and those who manage what they... - [SQL SERVER - LEN and DATALENGTH of NULL Simple Example](https://blog.sqlauthority.com/2007/06/12/sql-server-len-and-datalength-of-null-simple-example/): Simple but interesting – In recent survey I found that many developers making this generic mistake. I have seen following code in periodic code review. (The code below is not actual code, it is simple sample code) DECLARE @MyVar VARCHAR(10) SET @MyVar = NULL IF (LEN(@MyVar) = 0) … I decided to send following code to them. After running the following sample code it was clear that LEN of NULL values is not 0 (Zero) but it is NULL. Similarly, the result for DATALENGTH function is the same. DATALENGTH of NULL is NULL. Sample Test Version: DECLARE @MyVar VARCHAR(10) SET @MyVar... - [SQL SERVER - Cannot Resolve Collation Conflict For Equal to Operation](https://blog.sqlauthority.com/2007/06/11/sql-server-cannot-resolve-collation-conflict-for-equal-to-operation/): Cannot resolve collation conflict for equal to operation. In MS SQL SERVER, the collation can be set at the column level. - [SQL SERVER - 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) - CTE vs. Derived Table](https://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/): I have received few emails and comments about my post SQL SERVER – T-SQL Paging Query Technique Comparison – SQL 2000 vs SQL 2005. The main question was is this can be done using CTE? Absolutely! What about Performance? It is same! Please refer above mentioned article for history of paging. - [SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice](https://blog.sqlauthority.com/2007/06/10/sql-server-retrieve-select-only-date-part-from-datetime-best-practice/): Just a week ago, my Database Team member asked me what is the best way to only select date part from datetime. When ran following command it also provide the time along with the date. - [SQL SERVER - Fix : Error : An error has occurred while establishing a connect to the server. Solution with Images.](https://blog.sqlauthority.com/2007/06/10/sql-server-fix-error-an-error-has-occurred-while-establishing-a-connect-to-the-server-solution-with-images/): While reviewing my my blog search engine terms I find Error 40 is the most common error searched. I have previously wrote blog about how to fix this error here : SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server. Today I have added few screen shot of that error and their solution to help readers who need additional help to understand my post. Error Screen: Solution Part 1: Enable SQL Server Service Solution Part 2: Enable TCP/IP Protocol Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 9514 Xml data type is not supported in distributed queries. Remote object 'OPENROWSET' has xml column(s)](https://blog.sqlauthority.com/2007/06/09/sql-server-fix-error-msg-9514-level-16-state-1-line-1-xml-data-type-is-not-supported-in-distributed-queries-remote-object-openrowset-has-xml-columns/): In this blog post we are going to learn how to fix XML Data Type related error. - [SQL SERVER - Spatial Database Definition and Research Documents](https://blog.sqlauthority.com/2007/06/09/sql-server-spatial-database-definition-and-research-documents/): Recently I was asked in meeting of SQL SERVER user group, what my opinion about spatial database. I answered from my basic knowledge. Spatial database is like database of space (not the star wars or star trek kind space). SQL Server database can understand the numeric and string values. If we ask to SQL Server what is multiplication of 6 and 3 it will provide answer as 18. If we ask to SQL Server what is distance between two points in polygon, it will be not able to answer using native functions. Custom SQL code written by user can do similar... - [SQL SERVER - UDF - Function to Display Current Week Date and Day - Weekly Calendar](https://blog.sqlauthority.com/2007/06/08/sql-server-udf-function-to-display-current-week-date-and-day-weekly-calendar/): In analytics section of our product I frequently have to display the current week dates with days. Week starts from Sunday. We display the data considering days as column and date and other values in column. If today is Friday June 8, 2007. We need script which can provides days and dates for current week. Following script will generate the required script. DECLARE @day INT DECLARE @today SMALLDATETIME SET @today = CAST(CONVERT(VARCHAR(10), GETDATE(), 101) AS SMALLDATETIME) SET @day = DATEPART(dw, @today) SELECT DATEADD(dd, 1 - @day, @today) Sunday, DATEADD(dd, 2 - @day, @today) Monday, DATEADD(dd, 3 - @day, @today) Tuesday, DATEADD(dd,... - [SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL](https://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/): Update: For SQL Server 2008 there is even better method of Row Construction, please read it here : SQL SERVER – 2008 – Insert Multiple Records Using One Insert Statement – Use of Row Constructor This is very interesting question I have received from new developer. How can I insert multiple values in table using only one insert? Now this is interesting question. When there are multiple records are to be inserted in the table following is the common way using T-SQL. - [SQL SERVER - 2005 Download New Updated Book On Line (BOL)](https://blog.sqlauthority.com/2007/06/07/sql-server-2005-download-new-updated-book-on-line-bol/): Book On Line the primary source for help for many developers has been updated. It now includes the updates till SP2 release. I use book on line for accuracy for my definition and information on this blog. Download Book On Line (Update June 4th, 2007) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 (Katmai) June CTP Released - Improvement Pillars - Diagram](https://blog.sqlauthority.com/2007/06/07/sql-server-2008-katmai-june-ctp-released-improvement-pillars-diagram/): I received quite a few emails in last three days for not mentioning on my blog about SQL Server 2008 (Katmai) CPT June is released. The reason I did not mentioned because I was busy with my mini series SQL SERVER – Database Coding Standards and Guidelines Complete List Download. SQL Server 2008 (Katmai) June CTP (Community Technology Preview) is announced in TechNet 2007 and is available to download. SQL Server 2008 June CTP enables customers to immediately utilize new capabilities that support their mission-critical platform. The chart below explains important improvements coming online with each CTP. Please visit SQL Server... - [SQL SERVER - Fix : Error : Error 15401: Windows NT user or group 'username' not found. Check the name again.](https://blog.sqlauthority.com/2007/06/07/sql-server-fix-error-error-15401-windows-nt-user-or-group-username-not-found-check-the-name-again/): Fix : Error : Error 15401: Windows NT user or group ‘username’ not found. Check the name again. This is quite a famous error and I was asked to write about it by couple of readers. The reason I was not writing about this as the solution of this error is very well explained in Book On Line. All the potential causes and their solutions are explained well here. This post/article should be considered as book mark to solution. Fix/WorkAround/Solution: Refere Microsoft Help and Support : How to troubleshoot error 15401 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Database Coding Standards and Guidelines Complete List Download](https://blog.sqlauthority.com/2007/06/06/sql-server-database-coding-standards-and-guidelines-complete-list-download/): Download SQL SERVER Database Coding Standards and Guidelines Complete List - [SQL SERVER - Database Coding Standards and Guidelines - Part 2](https://blog.sqlauthority.com/2007/06/05/sql-server-database-coding-standards-and-guidelines-part-2/): SQL Server Database Coding Standards and Guidelines - Part 2 - [SQL SERVER - Database Coding Standards and Guidelines - Part 1](https://blog.sqlauthority.com/2007/06/04/sql-server-database-coding-standards-and-guidelines-part-1/): SQL Server Database Coding Standards and Guidelines - Part 1 - [SQL SERVER - Database Coding Standards and Guidelines - Introduction](https://blog.sqlauthority.com/2007/06/03/sql-server-database-coding-standards-and-guidelines-introduction/): I have received many many request to do another series since my series SQL Server Interview Questions and Answers Complete List Download. I have created small series of Coding Standards and Guidelines, as this is the second most request I have received from readers. This document can be extremely long but I have limited to very few pages as it is difficult to follow thousands of the rules. My experience says it is more productive developer and better code if coding standard has important fewer rules than lots of micro rules. - [SQL SERVER - 2005 Explanation and Example - SELF JOIN](https://blog.sqlauthority.com/2007/06/03/sql-server-2005-explanation-and-example-self-join/): A self-join is simply a normal SQL join that joins one table to itself. This is accomplished by using table name aliases to give each instance of the table a separate name. Joining a table to itself can be useful when you want to compare values in a column to other values in the same column. A join in which records from a table are combined with other records from the same table when there are matching values in the joined fields. A self-join can be an inner join or an outer join. A table is joined to itself based upon... - [SQL SERVER - 2005 - Microsoft SQL Server Management Pack for Microsoft Operations Manager 2005 - Download SQL Server MOM 2005](https://blog.sqlauthority.com/2007/06/02/sql-server-2005-microsoft-sql-server-management-pack-for-microsoft-operations-manager-2005-download-sql-server-mom-2005/): The Microsoft SQL Server Management Pack provides both proactive and reactive monitoring of SQL Server 2005 and SQL Server 2000 in an enterprise environment. Availability and configuration monitoring, performance data collection, and default thresholds are built for enterprise-level monitoring. Both local and remote connectivity checks help ensure database availability. Features description are available online. Download SQL Server MOM 2005 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Subscribe to Feed in Email](https://blog.sqlauthority.com/2007/06/02/sqlauthority-news-subscribe-to-feed-in-email/): You can subscribe to SQLAuthority.com Feed using Email. Email will be delivered to your preferred email address when new post appears on SQLAuthority.com Subscribe to SQLAuthority Feed Through Email Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Dedicated Search Engine for SQLAuthority - Search SQL Solutions](https://blog.sqlauthority.com/2007/06/01/sqlauthority-news-dedicated-search-engine-for-sqlauthority-search-sql-solutions/): Visit search.SQLAuthority.com I have been receiving many questions asking for tutorials, suggestions or questions about topics I already have wrote before but readers are have not found it or having difficulty to find them. I have almost around 200 articles on this blog so far and it is growing. One of the team member in my company keep on asking about search engine specific to SQLAuthority.com. He suggest that he always search in this blog first before he search on web. One of the loyal reader suggests that I should have search facilities in my SQL Interview Questions. I have created... - [SQL SERVER - 2005 Constraint on VARCHAR(MAX) Field To Limit It Certain Length](https://blog.sqlauthority.com/2007/06/01/sql-server-2005-constraint-on-varcharmax-field-to-limit-it-certain-length/): One of the Jr. DBA at in my Team Member asked me question the other day when he was replacing TEXT field with VARCHAR(MAX) : How can I limit the VARCHAR(MAX) field with maximum length of 12500 characters only. His Question was valid as our application was allowing 12500 characters. Traditionally thinking we only create the field as long as we need. SQL Server 2005 does support VARCHAR(MAX) but does not support VARCHAR(12500). If we try to create database field with VARCHAR(12500) it gives following error. Server: Msg 131, Level 15, State 3, Line 1 The size (12500) given to the... - [SQL SERVER - Retrieve Information of SQL Server Agent Jobs](https://blog.sqlauthority.com/2007/05/31/sql-server-retrieve-information-of-sql-server-agent-jobs/): sp_help_job returns information about jobs that are used by SQL Server Agent service to perform automated activities in SQL Server. When executed sp_help_job procedure with no parameters to return the information for all of the jobs currently defined in the msdb database. - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility - Part 2 - Management Studio](https://blog.sqlauthority.com/2007/05/31/sql-server-2005-change-database-compatible-level-backward-compatibility-part-2-management-studio/): I have received quite a few request about post I have two days ago SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility, if this can be done using SQL Server Management Studio. It is very simple to do this using Management Studio as well but I still prefer T-SQL way. Following steps will display the method to change the compatible levels. Write click on database. Click on Properties. Click on Options. Change the Compatibility level to desired compatibility. (See Attached image below) Click OK. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Primary Key Must Not Contain NULL - Primary Key are NOT NULL](https://blog.sqlauthority.com/2007/05/31/sql-server-primary-key-must-not-contain-null-primary-key-are-not-null/): While reviewing the search engine log for this blog I found lots of search regarding Nullable Primary Key. It is not possible. This post is especially to clear the Not Nullable Primary Key Property. The Allow Nulls property can’t be set on a column that is part of the primary key. All columns that are part of a table’s a primary key must contain aggregate unique values other than NULL. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQLAuthority.com News - Best SQL Job Search - Best SQL Job List - Find SQL Jobs](https://blog.sqlauthority.com/2007/05/30/sqlauthoritycom-news-best-sql-job-search-best-sql-job-list-find-sql-jobs/): SQLAuthority.com News – Best SQL Job Search – Best SQL Job List – Find SQL Jobs Visit : I have been receiving two kind of requests almost every day. 1) Recruiters and Employers asking where can they find good candidates who are truly dedicated to SQL Server? 2) Job seeker asking where can they find only SQL related jobs? There are hundreds of web site which have great resources for all kind of jobs. Monster and Dice are examples of them. Many sites are bit ocean of the jobs and it is hard to find only SQL Jobs from there, many... - [SQL SERVER - Trace Flags - DBCC TRACEON](https://blog.sqlauthority.com/2007/05/30/sql-server-trace-flags-dbcc-traceon/): Trace flags are valuable tools as they allow DBA to enable or disable a database function temporarily. Once a trace flag is turned on, it remains on until either manually turned off or SQL Server restarted. Only users in the sysadmin fixed server role can turn on trace flags. If you want to enable/disable Detailed Deadlock Information (1205), use Query Analyzer and DBCC TRACEON to turn it on. 1205 trace flag sends detailed information about the deadlock to the error log. Enable Trace at current connection level: DBCC TRACEON(1205) Disable Trace: DBCC TRACEOFF(1205) Enable Multiple Trace at same time separating each... - [SQL SERVER - Fix : Error : Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table](https://blog.sqlauthority.com/2007/05/30/sql-server-fix-error-server-msg-544-level-16-state-1-line-1-cannot-insert-explicit-value-for-identity-column-in-table/): Error Message: Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF. This error message appears when you try to insert a value into a column for which the IDENTITY property was declared, but without having set the IDENTITY_INSERT setting for the table to ON. Fix/WorkAround/Solution: /* Turn Identity Insert ON so records can be inserted in the Identity Column  */ SET IDENTITY_INSERT [dbo].[TableName] ON GO INSERT INTO [dbo].[TableName] ( [ID], [Name] ) VALUES ( 2, 'InsertName') GO /* Turn Identity Insert OFF  */ SET IDENTITY_INSERT [dbo].[TableName] OFF GO Setting the IDENTITY_INSERT to ON allows explicit values to be inserted into the identity column of a table. Execute permissions... - [SQL SERVER - 2005 Change Database Compatible Level - Backward Compatibility](https://blog.sqlauthority.com/2007/05/29/sql-server-2005-change-database-compatible-level-backward-compatibility/): sp_dbcmptlevel Sets certain database behaviors to be compatible with the specified version of SQL Server. Example: ----SQL Server 2005 database compatible level to SQL Server 2000 EXEC sp_dbcmptlevel AdventureWorks, 80; GO ----SQL Server 2000 database compatible level to SQL Server 2005 EXEC sp_dbcmptlevel AdventureWorks, 90; GO Version of SQL Server database can be one of the following: 60 = SQL Server 6.0 65 = SQL Server 6.5 70 = SQL Server 7.0 80 = SQL Server 2000 90 = SQL Server 2005 The sp_dbcmptlevel stored procedure affects behaviors only for the specified database, not for the entire server. sp_dbcmptlevel provides only... - [SQL SERVER - User Defined Functions (UDF) Limitations](https://blog.sqlauthority.com/2007/05/29/sql-server-user-defined-functions-udf-limitations/): UDF have its own advantage and usage but in this article we will see the limitation of UDF. Things UDF can not do and why Stored Procedure are considered as more flexible then UDFs. Stored Procedure are more flexibility then User Defined Functions(UDF). UDF has No Access to Structural and Permanent Tables. UDF can call Extended Stored Procedure, which can have access to structural and permanent tables. (No Access to Stored Procedure) UDF Accepts Lesser Numbers of Input Parameters. UDF can have upto 1023 input parameters, Stored Procedure can have upto 21000 input parameters. UDF Prohibit Usage of Non-Deterministic Built-in Functions... - [SQLAuthority News - Author Visit - Meeting with Readers - Top Three Features of SQL SERVER 2005](https://blog.sqlauthority.com/2007/05/28/sqlauthority-news-author-visit-meeting-with-readers-top-three-features-of-sql-server-2005/): Lots of travelers are visiting to Las Vegas due to long weekend of Memorial Day. I was invited to dinner meeting by two of my readers. It was wonderful discussion with them. We primarily discussed about scalability and upgrading issues about SQL Server. I received feedback about SQLAuthority.com site. There were two primarily request for them. I have been working on both of them already as I have received quite a few request for them from other readers as well. Beta testing has been completed, I will announce them on 1st June. While enjoying dinner I was asked interesting question and... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - SP](https://blog.sqlauthority.com/2007/05/28/sql-server-sql-joke-sql-humor-sql-laugh-sp/): One of my Friend send me(in email) following stored procedure. I laughed when I read it. Please enjoy it. It is here for amusement purpose only. Never use on development or production server. This is already dangerous you have been warned. CREATE PROCEDURE MyMarriage @ BrideGroom CHAR(NotBad), @ Bride CHAR(Good) AS BEGIN SELECT Bride FROM india_ Brides WHERE FatherInLaw = 'Millionaire' AND CarCount > 2 AND HouseStatus ='TwoStoreyed' AND BrideEduStatus='PG or Above' AND HavingBrothers='NO' AND HavingSisters ='No' AND AllowRelocate ='YES' SELECT Gold ,Cash,Car,BankBalance FROM FatherInLaw UPDATE MyBankAccout SET MyBal = MyBal + FatherinLawBal UPDATE MyLocker SET MyLockerContents = MyLockerContents + FatherinLawGold... - [SQL SERVER - Download Feature Pack for Microsoft SQL Server 2005](https://blog.sqlauthority.com/2007/05/27/sql-server-download-feature-pack-for-microsoft-sql-server-2005/): Feature Pack for Microsoft SQL Server 2005 – February 2007 Download the February 2007 Feature Pack for Microsoft SQL Server 2005, a collection of standalone install packages that provide additional value for SQL Server 2005. I have listed all the stand alone packages here. Even though title says February 2007, publication day of this package is 5/25/2007. All DBA should go through following list and see if their organization is using any of the application/feature and update is required for them. Microsoft ADOMD.NET Microsoft Core XML Services (MSXML) 6.0 Microsoft OLEDB Provider for DB2 Microsoft SQL Server Management Pack for MOM... - [SQL SERVER - 2005 Limiting Result Sets by Using TABLESAMPLE - Examples](https://blog.sqlauthority.com/2007/05/27/sql-server-2005-limiting-result-sets-by-using-tablesample-examples/): Introduced in SQL Server 2005, TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set. Example 1: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (10 PERCENT) Example 2: SELECT FirstName,LastName FROM Person.Contact TABLESAMPLE SYSTEM (1000 ROWS) If you run above script many times you will notice that different numbers of... - [SQL SERVER - 2005 Replace TEXT with VARCHAR(MAX) - Stop using TEXT, NTEXT, IMAGE Data Types](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-replace-text-with-varcharmax-stop-using-text-ntext-image-data-types/): Yesterday, in Friday Afternoon team meeting. I was asked question by one of application developer “I am asked in new coding standards to use VARHCAR(MAX) instead of TEXT. Is VARCHAR(MAX) big enough to store TEXT field?” Well, I realize that I was not clear enough in my coding standard. It is extremely important for coding standards to be clear and have a enough explanation that developer have no doubt about them. I updated coding standards after the meeting. The answer is “Yes, VARCHAR(MAX) is big enough to accommodate TEXT field. TEXT, NTEXT and IMAGE data types of SQL Server 2000 will... - [SQL SERVER - 2005 Find Table without Clustered Index - Find Table with no Primary Key](https://blog.sqlauthority.com/2007/05/26/sql-server-2005-find-table-without-clustered-index-find-table-with-no-primary-key/): One of the basic Database Rule I have is that all the table must Clustered Index. Clustered Index speeds up performance of the query ran on that table. Clustered Index are usually Primary Key but not necessarily. I frequently run following query to verify that all the Jr. DBAs are creating all the tables with no Clustered Index. USE AdventureWorks ----Replace AdventureWorks with your DBName GO SELECT DISTINCT [TABLE] = OBJECT_NAME(OBJECT_ID) FROM SYS.INDEXES WHERE INDEX_ID = 0 AND OBJECTPROPERTY(OBJECT_ID,'IsUserTable') = 1 ORDER BY [TABLE] GO Result set for AdventureWorks: TABLE ——————————————————- DatabaseLog ProductProductPhoto (2 row(s) affected) Related Post: SQL SERVER –... - [SQL SERVER - Change Default Fill Factor For Index](https://blog.sqlauthority.com/2007/05/25/sql-server-change-default-fill-factor-for-index/): SQL Server has default value for fill factor is Zero (0). The fill factor is implemented only when the index is created; it is not maintained after the index is created as data is added, deleted, or updated in the table. When creating an index, you can specify a fill factor to leave extra gaps and reserve a percentage of free space on each leaf level page of the index to accommodate future expansion in the storage of the table's data and reduce the potential for page splits. Let us learn about how to change default fill factor of index. - [SQL SERVER - Stored Procedure to display code (text) of Stored Procedure, Trigger, View or Object](https://blog.sqlauthority.com/2007/05/25/sql-server-stored-procedure-to-display-code-text-of-stored-procedure-trigger-view-or-object/): This is another popular question I receive. How to see text/content/code of Stored Procedure. System stored procedure that prints the text of a rule, a default, or an unencrypted stored procedure, user-defined function, trigger, or view. Syntax sp_helptext @objname = 'name' sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name Displaying the definition of a trigger or stored procedure sp_helptext 'dbo.nameofsp' Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - Disadvantages (Problems) of Triggers](https://blog.sqlauthority.com/2007/05/24/sql-server-disadvantages-problems-of-triggers/): One of my team member asked me should I use triggers or stored procedure. Both of them has its usage and needs. I just basically told him few issues with triggers. This is small note about our discussion. Disadvantages(Problems) of Triggers It is easy to view table relationships , constraints, indexes, stored procedure in database but triggers are difficult to view. Triggers execute invisible to client-application application. They are not visible or can be traced in debugging code. It is hard to follow their logic as it they can be fired before or after the database insert/update happens. It is easy... - [SQL SERVER - 2005 Retrieve Configuration of Server](https://blog.sqlauthority.com/2007/05/24/sql-server-2005-retrieve-configuration-of-server/): Few days ago I was asked what is our SQL Server’s configuration. I provided way more information then they requested. Run following script and it will provide all the information about SQL Server . SQL Server provides in detailed information if Advanced Options are turned on. It is very clear from this that maximum number of object SQL Server can have is 2,147,483,647. It is considerably very big number. I am not worried yet about my database reaching its limit. EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure GO EXEC sp_configure 'show advanced options', 0 GO To change... - [SQL SERVER - NorthWind Database or AdventureWorks Database - Samples Databases](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-northwind-database-or-adventureworks-database-samples-databases/): SQL Server 2005 does not install sample databases by default due to security reasons.I have received many questions regarding where is sample database in SQL Server 2005. One can install it afterward. AdventureWorks and AdvetureWorksDS are the new sample databases for SQL Server 2005, they can be download from here. Let us learn how to install NorthWind Database - samples databases.  - [SQL SERVER - 2005 Explanation Left Semi Join Showplan Operator and Other Operator](https://blog.sqlauthority.com/2007/05/23/sql-server-2005-explanation-left-semi-join-showplan-operator-and-other-operator/): I come across very interesting documentation about Joins, while I was researching about article about EXCEPT yesterday. There are few interesting kind of join operations exists when execution plan is displayed in text format. Left Semi Join Showplan Operator The Left Semi Join operator returns each row from the first (top) input when there is a matching row in the second (bottom) input. If no join predicate exists in the Argument column, each row is a matching row. Left Anti Semi Join Showplan Operator The Left Anti Semi Join operator returns each row from the first (top) input when there is... - [SQLAuthority News - Funny One Liners - Humor](https://blog.sqlauthority.com/2007/05/23/sqlauthority-news-funny-one-liners-humor/): Once in a while we should laugh and relax. Here are few of my favorite funny one liners which I often use in my presentations. Let us start- Just read that 4,153,237 people got married last year, not to cause any trouble, but shouldn't that be an even number? - [SQLAuthority News - T-Shirts in Action](https://blog.sqlauthority.com/2007/05/22/sqlauthority-news-t-shirts-in-action/): Thank you All for great response to SQLAuthority T-Shirts. I have ran out of all of them. Please put your request here. I will go over all of them soon and see what I can do. They are made from high quality fiber and very comfortable. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Comparison EXCEPT operator vs. NOT IN](https://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/): The EXCEPT operator returns all of the distinct rows from the query to the left of the EXCEPT operator when there are no matching rows in the right query. The EXCEPT operator is equivalent of the Left Anti Semi Join. EXCEPT operator works the same way NOT IN. EXCEPTS returns any distinct values from the query to the left of the EXCEPT operand that do not also return from the right query. - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - T-Shirt](https://blog.sqlauthority.com/2007/05/21/sql-server-sql-joke-sql-humor-sql-laugh-t-shirt/): My friend sent me this in an email two days ago as he wanted me to have SQLAuthority T-Shirt with this image. I found it funny, I am not sure if I will have this on SQLAuthority T-Shirts. Please pay attention to the options available to select. I spend more than 3 hours to find the original source as my friend did not remember the source. Let's see some SQL Humor here: - [SQL SERVER - Top 15 free SQL Injection Scanners - Link to Security Hacks](https://blog.sqlauthority.com/2007/05/21/sql-server-top-15-free-sql-injection-scanners-link-to-security-hacks/): SQL injection is a technique for exploiting web applications that use client-supplied data in SQL queries, but without first stripping potentially harmful characters. Checking for SQL Injection vulnerabilities involves auditing your web applications and the best way to do it is by using automated SQL Injection Scanners. Security-Hacks.com compiled a list of free SQL Injection Scanners. I really enjoy reading the article. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Build List Link](https://blog.sqlauthority.com/2007/05/21/sql-server-2005-build-list-link/): What is Build List? All SQL Server has build list, this is incremental list of numbers which indicates which version SQL Server is running and what are its compatibility, patches etc. Regular Columnist Steve Jones of SQL Server Central has created build list. It is updated and informative. Microsoft Hot fixes are always cumulative. You can find your build number with: SELECT@@Version Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - SQL Code Formatting Tools](https://blog.sqlauthority.com/2007/05/20/sql-server-sql-code-formatter-tools/): SQL Code Formatting is very important. Every SQL Server DBA has its own preference about formatting. I like to format all keywords to uppercase. Following are two online tools, which formats SQL Code very good. I tested following script with those tools and I found two of the tools worth mentioning here. - [SQL SERVER - Script/Function to Find Last Day of Month](https://blog.sqlauthority.com/2007/05/20/sql-server-scriptfunction-to-find-last-day-of-month/): Following query will find the last day of the month. Query also take care of Leap Year. Script: DECLARE @date DATETIME SET @date='2008-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO DECLARE @date DATETIME SET @date='2007-02-03' SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date)) AS LastDayOfMonth GO ResultSet: LastDayOfMonth ----------------------- 2008-02-29 00:00:00.000 (1 row(s) affected) LastDayOfMonth ----------------------- 2007-02-28 00:00:00.000 (1 row(s) affected) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ASCII to Decimal and Decimal to ASCII Conversion](https://blog.sqlauthority.com/2007/05/19/sql-server-ascii-to-decimal-and-decimal-to-ascii/): In this blog post we will see how we can convert ASCII to Decimal and Decimal to ASCII. In simple words, we will see the decimal and ASCII conversion. - [SQL SERVER - Math Functions Available in SQL Server](https://blog.sqlauthority.com/2007/05/19/sql-server-math-functions-for-2005/): The large majority of math functions is specific to applications using trigonometry, calculus, and geometry. This is very important and it is very difficult to have all of them together at place. - [SQL SERVER - 2005 Understanding Trigger Recursion and Nesting with examples](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-understanding-trigger-recursion-and-nesting-with-examples/): Trigger events can be fired within another trigger action. One Trigger execution can trigger even on another table or same table. This trigger is called NESTED TRIGGER or RECURSIVE TRIGGER. Nested triggers SQL Server supports the nesting of triggers up to a maximum of 32 levels. Nesting means that when a trigger is fired, it will also cause another trigger to be fired. If a trigger creates an infinitive loop, the nesting level of 32 will be exceeded and the trigger will cancel with an error message. Recursive triggers When a trigger fires and performs a statement that will cause the... - [SQL SERVER - 2005 - SSMS Change T-SQL Batch Separator](https://blog.sqlauthority.com/2007/05/18/sql-server-2005-ssms-change-t-sql-batch-separator/): I recently received one big file with many T-SQL batches. It was a very big file and I was asked that this file was tested many times and it can run one transaction. I noticed the separator of the batches is not GO but it was EndBatch. I have followed two options to run the whole batch in one transaction. Let us learn how to change T-SQL Batch Separator. - [SQLAuthority News - Limited Edition T-Shirts Arrived](https://blog.sqlauthority.com/2007/05/17/sqlauthority-news-limited-edition-t-shirts-arrived/): I have received quite a few request for SQLAuthority.com T-shirts. Every day I receive lots of emails and suggestions. Many readers have great suggestions and have helped to improve content. First of all I express my gratitude to all of you. Few of my loyal and enthusiastic readers will receive the T-shirt by tomorrow. T-shirts are very limited. I have kept only two for me and have shipped all other. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Disable Index - Enable Index - ALTER Index](https://blog.sqlauthority.com/2007/05/17/sql-server-disable-index-enable-index-alter-index/): There are few requirements in real world when Index on table needs to be disabled and re-enabled afterwards. e.g. DTS, BCP, BULK INSERT etc. Index can be dropped and recreated. I prefer to disable the Index if I am going to re-enable it again. USE AdventureWorks GO ----Diable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE GO ----Enable Index ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact REBUILD GO Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-1205-transaction-process-id-was-deadlocked-on-resources-with-another-process-and-has-been-chosen-as-the-deadlock-victim-rerun-the-transaction/): Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction. - [SQL SERVER - Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery](https://blog.sqlauthority.com/2007/05/16/sql-server-fix-error-130-cannot-perform-an-aggregate-function-on-an-expression-containing-an-aggregate-or-a-subquery/): Fix: Error 130: Cannot perform an aggregate function on an expression containing an aggregate or a subquery Following statement will give the following error: “Cannot perform an aggregate function on an expression containing an aggregate or a subquery.” MS SQL Server doesn’t support it. USE PUBS GO SELECT AVG(COUNT(royalty)) RoyaltyAvg FROM dbo.roysched GO You can get around this problem by breaking out the computation of the average in derived tables. USE PUBS GO SELECT AVG(t.RoyaltyCounts) FROM ( SELECT COUNT(royalty) AS RoyaltyCounts FROM dbo.roysched ) T GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL. - [SQL SERVER - Binary Sequence Generator - Truth Table Generator](https://blog.sqlauthority.com/2007/05/15/sql-server-binary-sequence-generator-truth-table-generator/): Run following script in query editor to generate truth table with its decimal value and binary sequence. The truth table is 512 rows long. This can be extended or reduced by adding or removing cross joins respectively. Script: USE AdventureWorks; DECLARE @Binary TABLE ( Digit bit) INSERT @Binary VALUES (0) INSERT @Binary VALUES (1) SELECT ((a.Digit*256) + (b.Digit*128) + (c.Digit*64) + (d.Digit*32) + (e.Digit*16) + (f.Digit*8) + (g.Digit*4) + (h.Digit*2) + (i.Digit*1)) DecimalValue, a.Digit '256', b.Digit '128' , c.Digit '64', d.Digit '32', e.Digit '16', f.Digit '8', g.Digit '4', h.Digit '2', i.Digit '1' FROM @Binary a CROSS JOIN @Binary b CROSS JOIN... - [SQL SERVER - DBCC commands List - documented and undocumented](https://blog.sqlauthority.com/2007/05/15/sql-server-dbcc-commands-list-documented-and-undocumented/): Database Consistency Checker (DBCC) commands can gives valuable insight into what’s going on inside SQL Server system. DBCC commands have powerful documented functions and many undocumented capabilities. Current DBCC commands are most useful for performance and troubleshooting exercises. To learn about all the DBCC commands run following script in query analyzer. DBCC TRACEON(2520) DBCC HELP (‘?’) GO To learn about syntax of an individual DBCC command run following script in query analyzer. DBCC HELP(<command>) GO Following is the list of all the DBCC commands and their syntax. List contains all documented and undocumented DBCC commands. DBCC activecursors [(spid)] DBCC addextendedproc (function_name,... - [SQL SERVER - SQL Joke, SQL Humor, SQL Laugh - Photo](https://blog.sqlauthority.com/2007/05/14/sql-server-sql-joke-sql-humor-sql-laugh-photo/): Pay attention to the last line of the ingredients. I found this entry at Worse Than Failure. I found it humorous. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - MS TechNet : Storage Top 10 Best Practices](https://blog.sqlauthority.com/2007/05/14/sql-server-ms-technet-storage-top-10-best-practices/): This one of the very interesting article I read regarding SQL Server 2005 Storage. Please refer original article at MS TechNet here. Understand the IO characteristics of SQL Server and the specific IO requirements / characteristics of your application. More / faster spindles are better for performance. Try not to “over” optimize the design of the storage; simpler designs generally offer good performance and more flexibility. Validate configurations prior to deployment. Always place log files on RAID 1+0 (or RAID 1) disks. Isolate log from data at the physical disk level. Consider configuration of TEMPDB database. Lining up the number of... - [SQL SERVER - Query to Find First and Last Day of Current Month - Date Function](https://blog.sqlauthority.com/2007/05/13/sql-server-query-to-find-first-and-last-day-of-current-month/): Following query will run respective on today's date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month. Let us see how we can do this with the help of Date Function in SQL Server. - [SQL SERVER - UDF - Function to Parse AlphaNumeric Characters from String](https://blog.sqlauthority.com/2007/05/13/sql-server-udf-function-to-parse-alphanumeric-characters-from-string/): Following function keeps only Alphanumeric characters in string and removes all the other character from the string. This is very handy function when working with Alphanumeric String only. I have used this many times. CREATE FUNCTION dbo.UDF_ParseAlphaChars ( @string VARCHAR(8000) ) RETURNS VARCHAR(8000) AS BEGIN DECLARE @IncorrectCharLoc SMALLINT SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) WHILE @IncorrectCharLoc > 0 BEGIN SET @string = STUFF(@string, @IncorrectCharLoc, 1, '') SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string) END SET @string = @string RETURN @string END GO —-Test SELECT dbo.UDF_ParseAlphaChars('ABC”_I+{D[]}4|:e;””5,<.F>/?6') GO Result Set : ABCID4e5F6 Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - List all the database](https://blog.sqlauthority.com/2007/05/12/sql-server-2005-list-all-the-database/): List all the database on SQL Servers. All the following Stored Procedure list all the Databases on Server. I personally use EXEC sp_databases because it gives the same results as other but it is self explaining. ----SQL SERVER 2005 System Procedures EXEC sp_databases EXEC sp_helpdb ----SQL 2000 Method still works in SQL Server 2005 SELECT name FROM sys.databases SELECT name FROM sys.sysdatabases ----SQL SERVER Un-Documented Procedure EXEC sp_msForEachDB 'PRINT ''?''' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support](https://blog.sqlauthority.com/2007/05/12/sql-server-fix-error-msg-6263-level-16-state-1-line-2-enabling-sql-server-2005-for-clr-support/): Error: Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support 1) Enable Server for CLR Support. - [SQL SERVER - Explanation SQL Command GO](https://blog.sqlauthority.com/2007/05/11/sql-server-explanation-sql-command-go/): GO is not a Transact-SQL statement; it is often used in T-SQL code. Go causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches. SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is... - [SQL SERVER - Download Microsoft SQL Server 2005 System Views Map](https://blog.sqlauthority.com/2007/05/11/sql-server-download-microsoft-sql-server-2005-system-views-map/): The Microsoft SQL Server 2005 System Views Map shows the key system views included in SQL Server 2005, and the relationships between them. It is available to download from Microsoft Site. It can be printed and mounted at Office Depot or Kinko’s. Download SQL SERVER 2005 System Views Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 Katmai - Download Datasheet Final from Microsoft](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-download-datasheet-final-from-microsoft/): Few interesting thing about Katmai. SQL Server “Katmai” will provide a more secure, reliable and manageable enterprise data platform. SQL Server “Katmai” will enable developers and administrators to save time by allowing them to store and consume any type of data from XML to documents. SQL Server “Katmai” provides a more scalable infrastructure that enables IT to drive business intelligence throughout the organization. SQL Server “Katmai” along with .NET Framework 3.0 will accelerate the development of the next generation of applications. Reference : Pinal Dave (https://blog.sqlauthority.com) MS SQL Server (All the above text) Download Final Datasheet of Katmai from Microsoft - [SQL SERVER - Fix: Error: HResult 0x2, Named Pipes Provider: Could not open a connection](https://blog.sqlauthority.com/2007/05/10/sql-server-fix-error-hresult-0x2-level-16-state-1-named-pipes-provider-could-not-open-a-connection-to-sql-server/): In this blog post we are going to fix the error which is related to Named Pipes Provider. - [SQL SERVER - 2008 Katmai - Your Data, Any Place, Any Time](https://blog.sqlauthority.com/2007/05/10/sql-server-2008-katmai-your-data-any-place-any-time/): I was following up on the news of first Microsoft Business Intelligence (BI) Conference held at Seattle. Good news is – SQL Server 2008 code name ‘Katmai’ is announced. I went to the official website I like the catchy line “Your Data, Any Place, Any Time“. As per my opinion the most important thing about Katmai is that it can be used to manage any type of data, including relational data, documents, geographic information and XML. The question I received many times since yesterday is : I am still using SQL Server 2000, I was planning to upgrade to SQL Server... - [SQL SERVER - Fix : Error 2501 : Cannot find a table or object with the name . Check the system catalog.](https://blog.sqlauthority.com/2007/05/09/sql-server-fix-error-2501-cannot-find-a-table-or-object-with-the-name-check-the-system-catalog/): Error 2501 : Cannot find a table or object with the name . Check the system catalog. This is very generic error beginner DBAs or Developers faces. The solution is very simple and easy. Follow the direction below in order. Fix/Workaround/Solution: Make sure that correct Database is selected. If not please run USE YourDatabase. Check the object or table name. They must be spelled correct. If database is case sensitive please use correct case. Use object belongs to other owner use two parts name as scheme_name.object_name. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Author Visit - MIS2007 Part II - Database Raid Discussion](https://blog.sqlauthority.com/2007/05/09/sqlauthority-news-author-visit-mis2007-part-ii-database-raid-discussion/): MIS2007 is really going good. There are many things going on. As I mentioned in my previous article, It is really pleasure to meet industry leaders. There was discussion about what is good for database RAID 5 configuration or RAID 10. This subject is always very interesting. We were discussing from small databases (5GB) to larger databases(5 TB). The question was which RAID 5 or RAID 10. Surprisingly, everybody who participated in discussion said their experience says RAID 10 is better for this particular application as there are lots of reads and writes in database. One of the expert suggested that... - [SQL SERVER - Index Optimization CheckList](https://blog.sqlauthority.com/2007/05/08/sql-server-index-optimization-checklist/): Index optimization is always interesting subject to me. Every time I receive requests to help optimize query or query on any specific table. I always ask Jr.DBA to go over following list first before I take a look at it. Most of the time the Query Speed is optimized just following basic rules mentioned below. Once following checklist applied interesting optimization part begins which only experiment and experience can resolve. - [SQLAuthority News - Author Visit - The 2007 Marketing Innovation Summit, Las Vegas](https://blog.sqlauthority.com/2007/05/08/sqlauthority-news-author-visit-the-2007-marketing-innovation-summit-las-vegas/): I am attending The 2007 Marketing Innovation Summit“, Las Vegas. It started on 5/6/2007 and will continue till 5/9/2007. Unica Corporation has arranged this conference. The MIS 2007 Agenda includes: Case studies and best practices Sessions focused on Relationship Marketing, Internet Marketing and Marketing Operations Hands on “how to” sessions General sessions from distinguished industry experts A one-day Pre-Summit Affinium New User Workshop and Getting Prepared for Affinium Plan Post-Summit Hands-On Training Evening networking activities In two days so far, I have learned a lot and have met many industry leaders. Talking about cutting edge technology and SQL Server was perfect... - [SQL SERVER - Top 10 Hidden Gems in SQL Server 2005](https://blog.sqlauthority.com/2007/05/07/sql-server-top-10-hidden-gems-in-sql-server-2005/): Top 10 Hidden Gems in SQL Server 2005 By Cihan Biyikoglu SQL Server 2005 has hundreds of new and improved components. Some of these improvements get a lot of the spotlight. However there is another set that are the hidden gems that help us improve performance, availability or greatly simplify some challenging scenarios. This paper lists the top 10 such features in SQL Server 2005 that we have discovered through the implementation with some of our top customers and partners. TableDiff.exe Triggers for Logon Events (New in Service Pack 2) Boosting performance with persisted-computed-columns (pcc). DEFAULT_SCHEMA setting in sys.database_principles Forced Parameterization... - [SQL SERVER - 2005/2000 Examples and Explanation for GOTO](https://blog.sqlauthority.com/2007/05/07/sql-server-20052000-examples-and-explanation-for-goto/): The GOTO statement causes the execution of the T-SQL batch to stop processing the following commands to GOTO and processing continues from the label where GOTO points. GOTO statement can be used anywhere within a procedure, batch, or function. GOTO can be nested as well. GOTO can be executed by any valid user on SQL SERVER. GOTO can co-exists with other control of flow statements (IF…ELSE, WHILE). GOTO can only go(jump) to label in the same batch, it can not go to label out side of the batch. Syntax: Define the label: label: ALTER the execution: GOTO label Notes from MSDN... - [SQL SERVER - Creating Comma Separate Values List from Table - UDF - SP](https://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/): Following script will create common separate values (CSV) or common separate list from tables. convert list to table. Following script is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. There are three ways to do this. 1) Using COALESCE 2) Using SELECT Smartly 3) Using CURSOR. The table is example is: TableName: NumberTable NumberCols first second third fourth fifth Output : first,second,third,fourth,fifth Option 1: This is... - [SQL SERVER - UDF - Function to Convert List to Table](https://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/): Following Users Defined Functions will convert list to table. It also supports user defined delimiter. Following UDF is written for SQL SERVER 2005. It will also work well with very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. CREATE FUNCTION dbo.udf_List2Table ( @List VARCHAR(MAX), @Delim CHAR ) RETURNS @ParsedList TABLE ( item VARCHAR(MAX) ) AS BEGIN DECLARE @item VARCHAR(MAX), @Pos INT SET @List = LTRIM(RTRIM(@List))+ @Delim SET @Pos = CHARINDEX(@Delim, @List, 1) WHILE @Pos > 0 BEGIN SET... - [SQL SERVER - 2005 Enable CLR using T-SQL script](https://blog.sqlauthority.com/2007/05/05/sql-server-2005-enable-clr-using-t-sql-script/): Before doing any .Net coding in SQL Server you must enable the CLR. In SQL Server 2005, the CLR is OFF by default. This is done in an effort to limit security vulnerabilities. Following is the script which will enable CLR. EXEC sp_CONFIGURE 'show advanced options' , '1'; GO RECONFIGURE; GO EXEC sp_CONFIGURE 'clr enabled' , '1' GO RECONFIGURE; GO Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - UDF - User Defined Function to Find Weekdays Between Two Dates](https://blog.sqlauthority.com/2007/05/05/sql-server-udf-user-defined-function-to-find-weekdays-between-two-dates/): Following user defined function returns number of weekdays between two dates specified. This function excludes the dates which are passed as input params. It excludes Saturday and Sunday as they are weekends. I always had this function with for reference but after some research I found original source website of the function. This function has been written by Author Alexander Chigrik. CREATE FUNCTION dbo.spDBA_GetWeekDays ( @StartDate datetime, @EndDate datetime ) RETURNS INT AS BEGIN DECLARE @WorkDays INT, @FirstPart INT DECLARE @FirstNum INT, @TotalDays INT DECLARE @LastNum INT, @LastPart INT IF (DATEDIFF(DAY, @StartDate, @EndDate) 0) THEN @LastPart - 1 ELSE 0 END... - [SQL SERVER - Fix : Error : Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset DBSCHEMA_TABLES_INFO for OLE DB provider SQLNCLI for linked server LinkedServerName](https://blog.sqlauthority.com/2007/05/04/sql-server-fix-error-msg-7311-level-16-state-2-line-1-cannot-obtain-the-schema-rowset-dbschema_tables_info-for-ole-db-provider-sqlncli-for-linked-server-linkedservername/): You may receive an error message when you try to run distributed queries from a 64-bit SQL Server 2005 client to a linked 32-bit SQL Server 2000 server or to a linked SQL Server 7.0 server. Error: The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator. Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset “DBSCHEMA_TABLES_INFO” for OLE DB provider “SQLNCLI” for linked server “<LinkedServerName>”. The provider supports the interface, but returns a failure code when it is used. Fix/WorkAround/Solution: Use Windows Authentication mode For a... - [SQL SERVER - Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts)](https://blog.sqlauthority.com/2007/05/04/sql-server-download-sql-server-management-studio-keyboard-shortcuts-ssms-shortcuts/): Download SQL Server Management Studio Keyboard Shortcuts I have received many emails appreciating my article Query Analyzer Shortcuts and requesting same for SQL Server Management Studio Keyboard Shortcuts. I see frequent downloads of the PDF generated by SQLAuthority for the same on server. There is original article on MSDN site. I have combined complete article in one PDF again. It is easy to refer, print and manage. Download SQL Server Management Studio Keyboard Shortcuts Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - DBCC Commands to Free SQL Server Memory Caches](https://blog.sqlauthority.com/2007/05/03/sql-server-dbcc-commands-to-free-several-sql-server-memory-caches/): Lots of people do not know that following command can be very helpful to clear your memory caches of SQL Server. I have often seen people restarting their entire system to clear the memory caches. - [SQL SERVER - Enable Login - Disable Login using ALTER LOGIN - Change name of the 'SA'](https://blog.sqlauthority.com/2007/05/03/sql-server-enable-login-disable-login-using-alter-login-change-name-of-the-sa/): Enable Login – Disable Login using ALTER LOGIN – Change name of the ‘SA’ - [SQL SERVER - FIX : ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup](https://blog.sqlauthority.com/2007/05/02/sql-server-fix-error-1101-could-not-allocate-a-new-page-for-database-because-of-insufficient-disk-space-in-filegroup/): ERROR 1101 : Could not allocate a new page for database because of insufficient disk space in filegroup . Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. Fix/Workaround/Solution: Make sure there is enough Hard Disk space where database files are stored on server. Turn on AUTOGROW for file groups. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 TOP Improvements/Enhancements](https://blog.sqlauthority.com/2007/05/02/sql-server-2005-top-improvementsenhancements/): SQL Server 2005 introduces two enhancements to the TOP clause. 1) User can specify an expression as an input to the TOP keyword. 2) User can use TOP in modification statements (INSERT, UPDATE, and DELETE). Explanation : User can specify an expression as an input to the TOP keyword. In SQL SERVER 2000 usage of TOP is implemented in following query. SELECT TOP 10 TableColumnID FROM TableName   For ages Developers and DBAs wants to pass parameters to TOP keyword. IN SQL SERVER 2005 it is possible. Example, @iNum is variables set before SELECT statement is ran. DECLARE @iNum INT SET... - [SQL SERVER - User Defined Functions (UDF) to Reverse String - UDF_ReverseString](https://blog.sqlauthority.com/2007/05/01/sql-server-user-defined-functions-udf-to-reverse-string-udf_reversestring/): UDF_ReverseString UDF_ReverseString User Defined Functions returns the Reversed String starting from certain position. First parameters takes the string to be reversed. Second parameters takes the position from where the string starts reversing. Script of UDF_ReverseString function to return Reverse String. CREATE FUNCTION UDF_ReverseString ( @StringToReverse VARCHAR(8000), @StartPosition INT ) RETURNS VARCHAR(8000) AS BEGIN IF (@StartPosition <= 0) OR (@StartPosition > LEN(@StringToReverse)) RETURN (REVERSE(@StringToReverse)) RETURN (STUFF (@StringToReverse, @StartPosition, LEN(@StringToReverse) - @StartPosition + 1, REVERSE(SUBSTRING (@StringToReverse, @StartPosition LEN(@StringToReverse) - @StartPosition + 1)))) END GO Usage of above UDF_ReverseString: Reversing the string from third position SELECT dbo.UDF_ReverseString('forward string',3) Results Set : forgnirts draw Reversing... - [SQL SERVER - Copy Column Headers in Query Analyzers in Result Set](https://blog.sqlauthority.com/2007/05/01/sql-server-copy-column-headers-in-query-analyzers-in-result-set/): Copy Column Headers in Query Analyzers in Result Set. In Query Analyzer go to Menu >> Tools >> Options >> Results Select Default results Target: Results to Text Results output format:(*): Tab Delimited Print column headers(*): Checkbox ON(check) [youtube=http://www.youtube.com/watch?v=BL5GO-jH3HA] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority.com 100th Post - Gratitude Note to Readers](https://blog.sqlauthority.com/2007/05/01/sqlauthoritycom-101st-post-gratitude-note-to-readers/): Hello All, I would like to express my deep gratitude to all of my readers for their emails, comments, suggestions and continuous support on the occasion of 101st post on this blog. I would like to extend my gratitude to my parents. In good times or trying times my parents are there with me always. Mom and Dad thank you for your encouragement, warmth, advise and continuous love. Kind Regards and Best Wishes, Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Collate - Case Sensitive SQL Query Search](https://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/): In this blog post we are going to learn about how to do Case Sensitive SQL Query Search. If Column1 of Table1 has following values ‘CaseSearch, casesearch, CASESEARCH, CaSeSeArCh’, following statement will return you all the four records. - [SQL SERVER - FIX : ERROR : Msg 3159, Level 16, State 1, Line 1 - Msg 3013, Level 16, State 1, Line 1](https://blog.sqlauthority.com/2007/04/30/sql-server-fix-error-msg-3159-level-16-state-1-line-1-msg-3013-level-16-state-1-line-1/): While moving some of the script from SQL SERVER 2000 to SQL SERVER 2005 our migration team faced following error. Msg 3159, Level 16, State 1, Line 1 The tail of the log for the database “AdventureWorks” has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. Following is the similar script using AdventureWorks... - [SQL SERVER - SET ROWCOUNT - Retrieving or Limiting the First N Records from a SQL Query](https://blog.sqlauthority.com/2007/04/30/sql-server-set-rowcount-retrieving-or-limiting-the-first-n-records-from-a-sql-query/): A SET ROWCOUNT statement simply limits the number of records returned to the client during a single connection. As soon as the number of rows specified is found, SQL Server stops processing the query. The syntax looks like this: - [SQL SERVER - 2005 Security DataSheet](https://blog.sqlauthority.com/2007/04/29/sql-server-2005-security-datasheet/): Microsoft has implemented strong security features into the Microsoft® SQL Server™ 2005, which provides a security-enabled platform for enterprise-class relational database and analysis solutions. SQL Server 2005 provides cutting edge security technology and addresses several security issues, including automatic secured updates and encryption of sensitive data. Download the SQL Server 2005 Security DataSheet from SQLAuthority.com Download the SQL Server 2005 Security DataSheet from Microsoft.com Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Random Number Generator Script - SQL Query](https://blog.sqlauthority.com/2007/04/29/sql-server-random-number-generator-script-sql-query/): Random Number Generator. There are many methods to generate random numbers in SQL Server. Method 1: Generate Random Numbers (Int) between Rang - [SQL SERVER - Replication Keywords Explanation and Basic Terms](https://blog.sqlauthority.com/2007/04/29/sql-server-replication-keywords-explanation-and-basic-terms/): While discussing replication with Jr. DBAs at work, I realize some of them have not experienced replication feature of SQL SERVER. Following is quick reference of replication keywords I created for easy conversation. - [SQL SERVER - Explanation SQL SERVER Merge Join](https://blog.sqlauthority.com/2007/04/28/sql-server-explanation-sql-server-merge-join/): The Merge Join transformation provides an output that is generated by joining two sorted data sets using a FULL, LEFT, or INNER join. The Merge Join transformation requires that both inputs be sorted and that the joined columns have matching meta-data. User cannot join a column that has a numeric data type with a column that has a character data type. If the data has a string data type, the length of the column in the second input must be less than or equal to the length of the column in the first input with which it is merged. USE pubs... - [SQL SERVER - Restrictions of Views - T SQL View Limitations](https://blog.sqlauthority.com/2007/04/28/sql-server-restrictions-of-views-t-sql-view-limitations/): UPDATE: (5/15/2007) Thank you Ben Taylor for correcting errors and incorrect information from this post. He is Database Architect and writes Database Articles at www.sswug.org. I have been coding as T-SQL for many years. I never have to use view ever in my career. I do not see in my near future I am using Views. I am able to achieve same database architecture goal using either using Third Normal tables, Replications or other database design work around.SQL Views have many many restrictions. There are few listed below. I love T-SQL but I do not like using Views. - [SQL SERVER - Good, Better and Best Programming Techniques](https://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/): A week ago, I was invited to meeting of programmers. Subject of meeting was “Good, Better and Best Programming Techniques”. I had made small note before I went to meeting, so if I have to talk about or discuss SQL Server it can come handy. Well, I did not get chance to talk on that as it was very causal and just meeting and greetings. Everybody just talked about what they think about their job. I talked very briefly about SQL Server, my current job and some funny incident at work. Everybody laughed big when I talked about funny bug ticket... - [SQL SERVER - Query to Retrieve the Nth Maximum Value](https://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/): Replace Employee with your table name, and Salary with your column name. Where N is the level of Salary to be determined. Let us see a query to retrieve the Nth Maximum Value. - [SQL SERVER - Locking Hints and Examples](https://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/): Locking Hints and Examples are as follows. The usage of them is the same but the effect is different. Let us learn it today together. - [SQL SERVER - SELECT vs. SET Performance Comparison](https://blog.sqlauthority.com/2007/04/27/sql-server-select-vs-set-performance-comparison/): Usage: SELECT : Designed to return data. SET : Designed to assign values to local variables. While testing the performance of the following two scripts in query analyzer, interesting results are discovered. SET @foo1 = 1; SET @foo2 = 2; SET @foo3 = 3; SELECT @foo1 = 1, @foo2 = 2, @foo3 = 3; While comparing their performance in loop SELECT statement gives better performance then SET. In other words, SET is slower than SELECT. The reason is that each SET statement runs individually and updates on values per execution, whereas the entire SELECT statement runs once and update all three... - [SQL SERVER - Difference Between Unique Index vs Unique Constraint](https://blog.sqlauthority.com/2007/04/26/sql-server-difference-between-unique-index-vs-unique-constraint/): Unique Index and Unique Constraint are the same. They achieve same goal. SQL Performance is same for both. Add Unique Constraint ALTER TABLE dbo.<tablename> ADD CONSTRAINT <namingconventionconstraint> UNIQUE NONCLUSTERED ( <columnname> ) ON [PRIMARY] Add Unique Index CREATE UNIQUE NONCLUSTERED INDEX <namingconventionconstraint> ON dbo.<tablename> ( <columnname> ) ON [PRIMARY] There is no difference between Unique Index and Unique Constraint. Even though syntax are different the effect is the same. Unique Constraint creates Unique Index to maintain the constraint to prevent duplicate keys. Unique Index or Primary Key Index are physical structure that maintain uniqueness over some combination of columns across all... - [SQL SERVER - Enable xp_cmdshell using sp_configure](https://blog.sqlauthority.com/2007/04/26/sql-server-enable-xp_cmdshell-using-sp_configure/): The xp_cmdshell option is a server configuration option that enables system administrators to control whether the xp_cmdshell extended stored procedure can be executed on a system. - [SQL SERVER - 2005 - DBCC ROWLOCK - Deprecated](https://blog.sqlauthority.com/2007/04/26/sql-server-2005-dbcc-rowlock-deprecated/): Title says all. My search engine log says many web users are looking for DBCC ROWLOCK in SQL SERVER 2005. It is deprecated feature for SQL SERVER 2005. It is Automatically on for SQL SERVER 2005. More Deprecated Features of SQL SERVER 2005 Refer MSDN Discontinued Database Engine Functionality in SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Alternate Fix : ERROR 1222 : Lock request time out period exceeded](https://blog.sqlauthority.com/2007/04/25/sql-server-alternate-fix-error-1222-lock-request-time-out-period-exceeded/): ERROR 1222 : Lock request time out period exceeded. - [SQL SERVER - ERROR Messages - sysmessages error severity level](https://blog.sqlauthority.com/2007/04/25/sql-server-error-messages-sysmessages-error-severity-level/): SQL ERROR Messages Each error message displayed by SQL Server has an associated error message number that uniquely identifies the type of error. The error severity levels provide a quick reference for you about the nature of the error. The error state number is an integer value between 1 and 127; it represents information about the source that issued the error. The error message is a description of the error that occurred. The error messages are stored in the sysmessages system table. - [SQL SERVER - 2005 Take Off Line or Detach Database](https://blog.sqlauthority.com/2007/04/25/sql-server-2005-take-off-line-or-detach-database/): EXEC sp_dboption N'mydb', N'offline', N'true' OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK AFTER 30 SECONDS OR ALTER DATABASE [mydb] SET OFFLINE WITH ROLLBACK IMMEDIATE Using the alter database statement (SQL Server 2k and beyond) is the preferred method. The rollback after statement will force currently executing statements to rollback after N seconds. The default is to wait for all currently running transactions to complete and for the sessions to be terminated. Use the rollback immediate clause to rollback transactions immediately. Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL - [SQL SERVER - TRIM() Function - UDF TRIM()](https://blog.sqlauthority.com/2007/04/24/sql-server-trim-function-udf-trim/): SQL Server does not have function which can trim leading or trailing spaces of any string. TRIM() is very popular function in many languages. SQL does have LTRIM() and RTRIM() which can trim leading and trailing spaces respectively. I was expecting SQL Server 2005 to have TRIM() function. Unfortunately, SQL Server 2005 does not have that either. I have created very simple UDF which does the same work. FOR SQL SERVER 2000: CREATE FUNCTION dbo.TRIM(@string VARCHAR(8000)) RETURNS VARCHAR(8000) BEGIN RETURN LTRIM(RTRIM(@string)) END GO FOR SQL SERVER 2005: CREATE FUNCTION dbo.TRIM(@string VARCHAR(MAX)) RETURNS VARCHAR(MAX) BEGIN RETURN LTRIM(RTRIM(@string)) END GO Both the above... - [SQL SERVER - Six Properties of Relational Tables](https://blog.sqlauthority.com/2007/04/24/sql-server-six-properties-of-relational-tables/): Relational tables have six properties: Values Are Atomic This property implies that columns in a relational table are not repeating group or arrays. The key benefit of the one value property is that it simplifies data manipulation logic. Such tables are referred to as being in the “first normal form” (1NF). Column Values Are of the Same Kind In relational terms this means that all values in a column come from the same domain. A domain is a set of values which a column may have. This property simplifies data access because developers and users can be certain of the type... - [SQL SERVER - 2005 Collation Explanation and Translation](https://blog.sqlauthority.com/2007/04/24/sql-server-2005-collation-explanation-and-translation/): Just a day before one of our SQL SERVER 2005 needed Case-Sensitive Binary Collation. When we install SQL SERVER 2005 it gives options to select one of the many collation. I says in words like ‘Dictionary order, case-insensitive, uppercase preference’. I was confused for little while as I am used to read collation like ‘SQL_Latin1_General_Pref_Cp1_CI_AS_KI_WI’. I did some research and find following link which explains many of the SQL SERVER 2005 collation. Complete documentation MSDN – SQL SERVER Collation Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 Query Analyzer - Microsoft SQL SERVER Management Studio](https://blog.sqlauthority.com/2007/04/23/sql-server-2005-query-analyzer-microsoft-sql-server-management-studio/): Following may be very simple to some and helpful to other type of question. I have seen this in my server log as well as this has been always first question in my Developer Team. Where is SQL SERVER 2005 Query Analyzer? SQL SERVER 2005 has combined Query Analyzer and Enterprise Manager into one Microsoft SQL SERVER Management Studio (MSSMS). To see the familiour Query Analyzer Window follow the image below. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Query to Find Seed Values, Increment Values and Current Identity Column value of the table](https://blog.sqlauthority.com/2007/04/23/sql-server-query-to-find-seed-values-increment-values-and-current-identity-column-value-of-the-table/): Following script will return all the tables which has identity column. It will also return the Seed Values, Increment Values and Current Identity Column value of the table. SELECT IDENT_SEED(TABLE_NAME) AS Seed, IDENT_INCR(TABLE_NAME) AS Increment, IDENT_CURRENT(TABLE_NAME) AS Current_Identity, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1 AND TABLE_TYPE = 'BASE TABLE' Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Understanding new Index Type of SQL Server 2005 Included Column Index along with Clustered Index and Non-clustered Index](https://blog.sqlauthority.com/2007/04/23/sql-server-understanding-new-index-type-of-sql-server-2005-included-column-index-along-with-clustered-index-and-non-clustered-index/): Clustered Index Only 1 allowed per table Physically rearranges the data in the table to conform to the index constraints. - [SQL SERVER - Raid Configuration - RAID 10](https://blog.sqlauthority.com/2007/04/22/sql-server-raid-configuration-raid-10/): I get question about what configuration of redundant array of inexpensive disks (RAID) I use for my SQL Servers. The answer is short is: RAID 10. Why? Excellent performance with Read and Write. RAID 10 has advantage of both RAID 0 and RAID 1. RAID 10 uses all the drives in the array to gain higher I/O rates so more drives in the array higher performance. RAID 5 has penalty for write performance because of the parity in check. There are many article already written about them. If you are interested in reading more please refer book online. Reference : Pinal... - [SQL SERVER - @@DATEFIRST and SET DATEFIRST Relations and Usage](https://blog.sqlauthority.com/2007/04/22/sql-server-datefirst-and-set-datefirst-relations-and-usage/): The master database’s syslanguages table has a DateFirst column that defines the first day of the week for a particular language. SQL Server with US English as default language, SQL Server sets DATEFIRST to 7 (Sunday) by default. We can reset any day as first day of the week using SET DATEFIRST 5 This will set Friday as first day of week. @@DATEFIRST returns the current value, for the session, of SET DATEFIRST. SET LANGUAGE italian GO SELECT @@DATEFIRST GO ----This will return result as 1(Monday) SET LANGUAGE us_english GO SELECT @@DATEFIRST GO ----This will return result as 7(Sunday) In this... - [SQL SERVER - Fix : Error 1418 - Microsoft SQL Server - The server network address can not be reached](https://blog.sqlauthority.com/2007/04/22/sql-server-fix-error-1418-microsoft-sql-server-the-server-network-address-can-not-be-reached-or-does-not-exist-check-the-network-address-name-and-reissue-the-command/): Error: 1418 – Microsoft SQL Server – The server network address can not be reached or does not exist. Check the network address name and reissue the command The server network endpoint did not respond because the specified server network address cannot be reached or does not exist. - [SQL Server Interview Questions and Answers Complete List Download](https://blog.sqlauthority.com/2007/04/21/sql-server-interview-questions-and-answers-complete-list-download/): This is summary blog post for SQL Server Interview Questions and Answers. Click here to get free chapters (PDF) in the mailbox. - [SQL Server Interview Questions and Answers - Part 6](https://blog.sqlauthority.com/2007/04/20/sql-server-interview-questions-part-6/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 5](https://blog.sqlauthority.com/2007/04/19/sql-server-interview-questions-part-5/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 4](https://blog.sqlauthority.com/2007/04/18/sql-server-interview-questions-part-4/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 3](https://blog.sqlauthority.com/2007/04/17/sql-server-interview-questions-part-3/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 2](https://blog.sqlauthority.com/2007/04/16/sql-server-interview-questions-part-2/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Part 1](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL Server Interview Questions and Answers - Introduction](https://blog.sqlauthority.com/2007/04/15/sql-server-interview-questions-and-answers-introduction/): Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. - [SQL SERVER - 64 bit Architecture and White Paper](https://blog.sqlauthority.com/2007/04/14/sql-server-64-bit-architecture-and-white-paper/): In supportability, manageability, scalability, performance, interoperability, and business intelligence, SQL Server 2005 provides far richer 64-bit support than its predecessor. This paper describes these enhancements. Read the original paper here. Following abstract is taken from the same paper. Another interesting article on 64-bit Computing with SQL Server 2005 is here. The primary differences between the 64-bit and 32-bit versions of SQL Server 2005 are derived from the benefits of the underlying 64-bit architecture. Some of these are: The 64-bit architecture offers a larger directly-addressable memory space. SQL Server 2005 (64-bit) is not bound by the memory limits of 32-bit systems. Therefore,... - [SQL SERVER - CASE Statement/Expression Examples and Explanation](https://blog.sqlauthority.com/2007/04/14/sql-server-case-statementexpression-examples-and-explanation/): CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in functions. Two basic formulations for CASE expression 1) Simple CASE expressions A simple CASE expression checks one expression against multiple values. Within a SELECT statement, a simple CASE expression allows only an equality check; no other comparisons are made. A simple CASE expression operates by comparing the first expression to the expression in each WHEN clause for equivalency. If these expressions... - [SQL SERVER - Fix : Error: 18452 Login failed for user '(null)'. The user is not associated with a trusted SQL Server connection.](https://blog.sqlauthority.com/2007/04/14/sql-server-fix-error-18452-login-failed-for-user-null-the-user-is-not-associated-with-a-trusted-sql-server-connection/): Some errors never got old. I have seen many new DBA or Developers struggling with this errors. Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection. Fix/Solution/Workaround: Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)” to “Mixed Mode (Windows Authentication and SQL Server Authentication)”. Run following script in SQL Analyzer to change the authentication LOGIN sa ENABLE GO ALTER LOGIN sa WITH PASSWORD = '<password>' GO OR In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties. On the General page, you may have to create... - [SQL SERVER - Stored Procedures Advantages and Best Advantage](https://blog.sqlauthority.com/2007/04/13/sql-server-stored-procedures-advantages-and-best-advantage/): There are many advantages of Stored Procedures. I was once asked what do I think is the most important feature of Stored Procedure? I have to pick only ONE. It is tough question. I answered : Execution Plan Retention and Reuse (SP are compiled and their execution plan is cached and used again to when the same SP is executed again) Not to mentioned I received the second question following my answer : Why? Because all the other advantage known (they are mentioned below) of SP can be achieved without using SP. Though Execution Plan Retention and Reuse can only be... - [SQLAuthority News - Book Review - Beginners Guide to SQL Server Integration Services Using Visual Studio 2005](https://blog.sqlauthority.com/2008/01/28/sqlauthority-news-book-review-beginners-guide-to-sql-server-integration-services-using-visual-studio-2005/): Beginners Guide to SQL Server Integration Services Using Visual Studio 2005 (Paperback) by Jayaram Krishnaswamy (Author) Link to Amazon Short Summary: SQL Server Integration Services Using Visual Studio 2005 contains all the information and education needed for one to begin with SSIS. It covers all the basic concepts in depth and moves towards advance concepts of Extraction, Transformation and Loading (ETL). One book for all the beginners in SSIS. Detail Summary: SQL Server Integration Services (SSIS) is a comprehensive ETL tool available in SQL Server 2005. It is integrated with Visual Studio 2005 (VS2K5). SSIS is replacement of Data Transformation Services... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Funny Quotes](https://blog.sqlauthority.com/2008/01/27/sqlauthority-news-sql-joke-sql-humor-sql-laugh-funny-quotes/): Following is the collection of some funny quotes regarding computers. Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Rich Cook. UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. Dennis Ritchie. The perfect computer has been developed. You just feed in your problems and they never come out again. Al Goodman. Computers make it easier to do a lot of things, but most of the things they make... - [SQLAuthority News - Microsoft SQL Server 2000 MSIT Configuration Pack for Configuration Manager 2007](https://blog.sqlauthority.com/2008/01/26/sqlauthority-news-microsoft-sql-server-2000-msit-configuration-pack-for-configuration-manager-2007/): Microsoft SQL Server 2000 MSIT Comprehensive Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2000 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2000 MSIT Intermediate Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2000 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2000 MSIT Basic Configuration Pack for Configuration Manager 2007 This... - [SQL SERVER - 2005 - Database Table Partitioning Tutorial - How to Horizontal Partition Database Table](https://blog.sqlauthority.com/2008/01/25/sql-server-2005-database-table-partitioning-tutorial-how-to-horizontal-partition-database-table/): I have received calls from my DBA friend who read my article SQL SERVER - 2005 - Introduction to Partitioning. He suggested that I should write a simple tutorial about how to horizontal partition database table. Here is a simple tutorial which explains how a table can be partitioned. - [SQL SERVER - 2005 - Introduction to Partitioning](https://blog.sqlauthority.com/2008/01/24/sql-server-2005-introduction-to-partitioning/): Partitioning is the database process or method where very large tables and indexes are divided in multiple smaller and manageable parts. SQL Server 2005 allows to partition tables using defined ranges and also provides management features and tools to keep partition tables in optimal performance. Tables are partition based on column which will be used for partitioning and the ranges associated to each partition. Example of this column will be incremental identity column, which can be partitioned in different ranges. Different ranges can be on different partitions, different partition can be on different filegroups, and different partition can be on different... - [SQLAuthority News - Download Microsoft SQL Server 2005 Assessment Configuration Pack](https://blog.sqlauthority.com/2008/01/23/sqlauthority-news-download-microsoft-sql-server-2005-assessment-configuration-pack/): Microsoft SQL Server 2005 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Gramm-Leach Bliley Act compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains... - [SQLAuthority News - Fix : Remote Desktop Copy Paste Stop Working](https://blog.sqlauthority.com/2008/01/22/sqlauthority-news-fix-remote-desktop-copy-paste-stop-working/): Today’s article is not related to SQL Server 100%, however it is quite related to SQL Server, or atleast I found it while working with SQL Server. Just two days ago, while I was working with remote SQL Server using Remote Desktop tool provided by Windows XP. Suddenly, copy/paste feature of windows stop working on remote desktop. I was not able to copy from local machine to remote machine and remote machine to local machine, both ways. I was able to copy/paste from remote machine to remote machine and local machine to local machine. I thought may be if I restart... - [SQL SERVER - Get a Row Per File of a Database as Stored in the Master Database](https://blog.sqlauthority.com/2008/01/21/sql-server-2005-get-a-row-per-file-of-a-database-as-stored-in-the-master-database/): Each database has a minimum of two files associated with the database. If a database has more than one filegroup it will have many files associated with one database. Following quick script will give you recordset per file of a database which is stored in master database. - [SQL SERVER - Introduction to Statistical Functions - VAR, STDEVP, STDEV, VARP](https://blog.sqlauthority.com/2008/01/20/sql-server-introduction-to-statistical-functions-var-stdevp-stdev-varp/): Yesterday I wrote article about SQL SERVER – Introduction to Aggregate Functions. I received one email that four of the aggregate functions are statistical function and I should write something about that. VAR, STDEVP, STDEV, VARP are statistical functions as well they absolutely fit in the definition of aggregate function as well. The usage of this function is pretty simple so instead of explaining them I will go to example right away. USE AdventureWorks; GO SELECT VAR(Bonus) 'Variance', STDEVP(Bonus) 'Standard Deviation', STDEV(Bonus) 'Standard Deviation', VARP(Bonus) 'Variance for the Population' FROM Sales.SalesPerson; GO All the functions returns result as datatype float. VAR... - [SQL SERVER - Introduction to Aggregate Functions](https://blog.sqlauthority.com/2008/01/19/sql-server-introduction-to-aggregate-functions/): Recently I have been taking many interviews to increase work force in my companies outsourcing establishment. One question I ask to all interview candidates. What is Aggregate Function? So far I have received two different kind of response. First, I do not know. Second, AVG, SUM, COUNT are aggregate functions. The second response is good enough but not technically correct. None of the candidate have gave me good definition of Aggregate Function. Definition from BOL is Aggregate functions perform a calculation on a set of values and return a single value. Following functions are aggregate functions. AVG, MIN, CHECKSUM_AGG, SUM, COUNT,... - [SQL SERVER - 2005 Best Practices Analyzer (January 2008)](https://blog.sqlauthority.com/2008/01/18/sql-server-2005-best-practices-analyzer-january-2008/): The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. With this tool, you can test and implement a combination of SQL Server best practices and then implement them on your SQL Server. The SQL Server 2005 Best Practices Analyzer gathers data from Microsoft Windows and SQL Server configuration settings. Best Practices Analyzer uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment. DOWNLOAD TOOL HERE Best Practice Analyzer (BPA) Tutorial Abstract courtesy : Microsoft Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Job Description of Database Administrator (DBA) or Database Developer](https://blog.sqlauthority.com/2008/01/17/sqlauthority-news-job-description-of-database-administrator-dba-or-database-developer/): Job Description of Database Administrator (DBA) or Database Developer Develop standards and guidelines to guide the use and acquisition of software and to protect vulnerable information. Modify existing databases and database management systems or direct programmers and analysts to make changes. Test programs or databases, correct errors and make necessary modifications. Plan, coordinate and implement security measures to safeguard information in computer files against accidental or unauthorized damage, modification or disclosure. Approve, schedule, plan, and supervise the installation and testing of new products and improvements to computer systems, such as the installation of new databases. Train users and answer questions. Establish... - [SQLAuthroity News - Microsoft SQL Server 2000 Assessment Configuration Pack](https://blog.sqlauthority.com/2008/01/16/sqlauthroity-news-microsoft-sql-server-2000-assessment-configuration-pack/): Microsoft SQL Server 2000 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2000 servers in order to support your Federal Information Security Management Act compliance efforts. Microsoft SQL Server 2000 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2000 servers in order to support your Gramm-Leach Bliley Act compliance efforts. Microsoft SQL Server 2000 Assessment Configuration Pack for Health Insurance Portability... - [SQL SERVER - What is - DML, DDL, DCL and TCL - Introduction and Examples](https://blog.sqlauthority.com/2008/01/15/sql-server-what-is-dml-ddl-dcl-and-tcl-introduction-and-examples/): DML DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database. Examples: SELECT, UPDATE, INSERT statements DDL DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database. Examples: CREATE, ALTER, DROP statements DCL DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it. Examples: GRANT, REVOKE statements TCL TCL is abbreviation of Transactional Control Language. It is used to... - [SQL SERVER - Time Out Due to Executing DELETE on Large RecordSet](https://blog.sqlauthority.com/2008/01/14/sql-server-time-out-due-to-executing-delete-on-large-recordset/): Just a day ago, I received following question: “I have large table more than 1M rows. I want to delete every row in my table. Everytime I ran DELETE statement, it times out and does not do it job. The data in table is useless and I do not need it ever. Your suggestion please.” The reason I decided to write article about this question because I receive similar questions very often. I think many readers will find answer to this question useful. My answer to his question is here with: “If DELETE is timing out use TRUNCATE instead. It will... - [SQLAuthority News - Good Motivational Quotes for Interviews](https://blog.sqlauthority.com/2008/01/13/sqlauthority-news-good-motivational-quotes-interviews/): Here are few motivational quotes for candidates who are appearing for interview. I have collected this throughout the years and it is running list of the interview. Please feel free to let me know if you find any such good interview quote and I will update in this list. - [SQL SERVER - 2005 - Change Compatibility Level - T-SQL Procedure](https://blog.sqlauthority.com/2008/01/12/sql-server-2005-change-compatibility-level-t-sql-procedure/): Six months ago I wrote article about SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility. Yesterday I received an email asking that one of my blog reader is not able to use the sp_dbcmptlevel command with error that database is in use. He has asked me to write about proper procedure of changing database compatibility which will always work. First read my previous article SQL SERVER – 2005 Change Database Compatible Level – Backward Compatibility as it has explained many details about compatibility. The best practice to change the compatibility level of database is in following three steps.... - [SQL SERVER - Reclaim Space After Dropping Variable - Length Columns Using DBCC CLEANTABLE](https://blog.sqlauthority.com/2008/01/11/sql-server-reclaim-space-after-dropping-variable-length-columns-using-dbcc-cleantable/): All DBA and Developers must have observed when any variable length column is dropped from table, it does not reduce the size of table. Table size stays the same till Indexes are reorganized or rebuild. There is also DBCC command DBCC CLEANTABLE, which can be used to reclaim any space previously occupied with variable length columns. Variable length columns include varchar, nvarchar, varchar(max), nvarchar(max), varbinary, varbinary(max), text, ntext, image, sql_variant, and xml. Space can be reclaimed when variable length column is also modified to lesser length. - [SQL SERVER - 2005 - Display Fragmentation Information of Data and Indexes of Database Table](https://blog.sqlauthority.com/2008/01/10/sql-server-2005-display-fragmentation-information-of-data-and-indexes-of-database-table/): One of my friend involved with large business of medical transcript invited me for SQL Server improvement talk last weekend. I had great time talking with group of DBA and developers. One of the topic which was discussed was how to find out Fragmentation Information for any table in one particular database. For SQL Server 2000 it was easy to find using DBCC SHOWCONTIG command. DBCC SHOWCONTIG has some limitation for SQL Server 2000. SQL Server 2005 has sys.dm_db_index_physical_stats dynamic view which returns size and fragmentation information for the data and indexes of the specified table or view. You can run... - [SQL SERVER - Execute Same Query and Statement Multiple Times Using Command GO](https://blog.sqlauthority.com/2008/01/09/sql-server-execute-same-query-and-statement-multiple-times-using-command-go/): Following question was asking by one of long time reader who really liked trick of SQL SERVER – Explanation SQL Command GO and SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL. She asked how can I execute same code multiple times without Copy and Paste multiple times in Query Editor. The answer to this question is very simple. Use the command GO. Following example demonstrate how GO can be used to execute same code multiple times. SELECT GETDATE() AS CurrentTime GO 5 Above code will return current time 5 times as GO is followed... - [SQL SERVER - Export Data From SQL Server to Microsoft Excel Datasheet](https://blog.sqlauthority.com/2008/01/08/sql-server-2005-export-data-from-sql-server-2005-to-microsoft-excel-datasheet/): Question: How to Export Data From SQL Server to Microsoft Excel Datasheet? - [SQL SERVER - 2005 - Introduction and Explanation to SYNONYM - Helpful T-SQL Feature for Developer](https://blog.sqlauthority.com/2008/01/07/sql-server-2005-introduction-and-explanation-to-synonym-helpful-t-sql-feature-for-developer/): One of my friend and extremely smart DBA Jonathan from Las Vegas has pointed out nice little enhancement in T-SQL. I was very pleased when I learned about SYNONYM feature in SQL Server 2005. DBA have been referencing database objects in four part names. SQL Server 2005 introduces the concept of a synonym. A synonyms is a single-part name which can replace multi part name in SQL Statement. Use of synonyms cuts down typing long multi part server name and can replace it with one synonyms. It also provides an abstractions layer which will protect SQL statement using synonyms from changes... - [SQL SERVER - Download Frequently Asked Generic Interview Questions](https://blog.sqlauthority.com/2008/01/06/sql-server-download-frequently-asked-generic-interview-questions/): Yesterday I posted article about SQL SERVER – Most Frequently Asked Generic Interview Questions. I always enjoy when I receive emails and comments about my article. Many readers have asked me to write more about this, I suggest that my readers help me here and add their suggestion and answers to original article. The common question asked to me is why I have not included answers with this questions. Each question is very unique to each individual and its answer can be very different from person to person. There is no right or wrong answer here. Just answer what you feel... - [SQL SERVER - Most Frequently Asked Generic Interview Questions](https://blog.sqlauthority.com/2008/01/05/sql-server-most-frequently-asked-generic-interview-questions/): Tell me about yourself. What experience do you have in this field? How many years of experience do you have in area you are applying for? Why did you leave your last job? Why are you planning to leave your current job? What do you know about this organization? Why do you want to work for this organization? How would you describe your ideal job? How long would you expect to work for us if hired? What have you done to improve your knowledge recently? What do co-workers say about you? What irritates you about co-workers? What kind of person would... - [SQL SERVER - Quick Note on CROSS APPLY](https://blog.sqlauthority.com/2008/01/04/sql-server-2005-cross-apply/): Yesterday I wrote article about SQL SERVER – 2005 – Last Ran Query – Recently Ran Query. I had used CROSS APPLY in the query. I got email from one reader asking what is CROSS APPLY. In simpler words, cross apply is like inner join to table valued function which can take parameters. This particular operation is not possible to do using regular JOIN syntax You can see example of CROSS APPLY in my article here. - [SQL SERVER - 2005 - Last Ran Query - Recently Ran Query](https://blog.sqlauthority.com/2008/01/03/sql-server-2005-last-ran-query-recently-ran-query/): How many times we have wondered what were the last few queries ran on SQL Server? Following quick script demonstrates last ran query along with the time it was executed on SQL Server 2005. SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest ORDER BY deqs.last_execution_time DESC Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL – sys.dm_exec_query_stats, BOL – sys.dm_exec_sql_text - [SQLAuthority New - Best Practices for Speeding Up Your Web Site](https://blog.sqlauthority.com/2008/01/03/sqlauthority-new-best-practices-for-speeding-up-your-web-site/): Steve Souders, Chief Performance Yahoo! Best Practices for Speeding Up Your Web Site. I suggest everybody should read this basic guidelines. They are extremely important for high performance websites. 1. Make Fewer HTTP Requests 2. Use a Content Delivery Network 3. Add an Expires Header 4. Gzip Components 5. Put Stylesheets at the Top 6. Put Scripts at the Bottom 7. Avoid CSS Expressions 8. Make JavaScript and CSS External 9. Reduce DNS Lookups 10. Minify JavaScript 11. Avoid Redirects 12. Remove Duplicate Scripts 13. Configure ETags 14. Make Ajax Cacheable Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Fix : Error 15281 SQL Server blocked access to STATEMENT OpenRowset/OpenDatasource of](https://blog.sqlauthority.com/2008/01/02/sql-server-fix-error-15281-sql-server-blocked-access-statement-openrowsetopendatasource-component-ad-hoc-distributed-queries-component-turned-off/): Error 15281 Msg 15281, Level 16, State 1, Line 3 SQL Server blocked access to STATEMENT ‘OpenRowset/OpenDatasource’ of component ‘Ad Hoc Distributed Queries’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ad Hoc Distributed Queries’ by using sp_configure. For more information about enabling ‘Ad Hoc Distributed Queries’, see “Surface Area Configuration” in SQL Server Books Online. - [SQLAuthority New - Happy New Year 2008](https://blog.sqlauthority.com/2008/01/01/sqlauthority-new-happy-new-year-2008/): Today is New Year and I wish you all Best for Year 2008. Let us all start our new year with motivational new year quote. We will open the book. Its pages are blank. We are going to put words on them ourselves. The book is called “Opportunity” and its first chapter is New Year’s Day. – Edith Lovejoy Pierce Microsoft has big gift for all SQL Server fans and developers. It is realizing SQL Server 2008. Today in New Year let us have some laugh together. We will continue together with SQL Server articles from tomorrow. I hope you enjoy... - [SQLAuthority News - Thank You to Blog Readers](https://blog.sqlauthority.com/2007/12/31/sqlauthority-news-thank-you-to-blog-readers/): Thank You very much for reading SQLAuthority.com for entire 2007 year. Wish you the BEST for year 2008. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Remove Duplicate Characters From a String](https://blog.sqlauthority.com/2007/12/30/sql-server-remove-duplicate-characters-from-a-string/): Follow up of my previous article of Remove Duplicate Chars From String here is another great article written by Madhivanan where similar solution is suggested with alternate method of Number table approach. Check out Remove duplicate characters from a string Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Change Password of SA Login Using Management Studio](https://blog.sqlauthority.com/2007/12/29/sql-server-change-password-of-sa-login-using-management-studio/): Login into SQL Server using Windows Authentication. In Object Explorer, open Security folder, open Logins folder. Right Click on SA account and go to Properties. Change SA password, and confirm it. Click OK. Make sure to restart the SQL Server and all its services and test new password by log into system using SA login and new password. Reference : Pinal Dave (https://blog.sqlauthority.com) UPDATE : There has been discussion about restarting the SQL Server and all its services. Please read all of them before making final decision for your scenario. - [SQL SERVER - Difference Between Quality Assurance and Quality Control - QA vs QC](https://blog.sqlauthority.com/2007/12/28/sql-server-difference-between-quality-assurance-and-quality-control-qa-vs-qc/): Regular readers of this blog are aware of my current outsourcing assignment. I am managing very large outsourcing project in India. One thing is very special in all Indian offices are “Tea Time.” Everybody wants to attend Tea Time not only for tea or coffee but for the interesting discussion occurs at that time. This is the time when all the department employees are together and discussing whatever they wish.Today there was an interesting discussion about Quality Assurance (QA) and Quality Control (QC). - [SQLAuthority News - Book Review - A Practitioner's Guide to Software Test Design](https://blog.sqlauthority.com/2007/12/27/sqlauthority-news-book-review-a-practitioners-guide-to-software-test-design/): A Practitioner's Guide to Software Test Design is one book containing all the important latest test design approaches. This book makes life of software tester very easy. Software tester can find all the information in this book instead of searching through hundreds of books, periodicals and websites. - [SQL SERVER - TRUNCATE Can't be Rolled Back Using Log Files After Transaction Session Is Closed](https://blog.sqlauthority.com/2007/12/26/sql-server-truncate-cant-be-rolled-back-using-log-files-after-transaction-session-is-closed/): You might have listened and read either of following sentence many many times. “DELETE can be rolled back and TRUNCATE can not be rolled back”. OR “DELETE can be rolled back as well as TRUNCATE can be rolled back”. As soon as above sentence is completed, someone will object it saying either TRUNCATE can be or can not be rolled back. Let us make sure that we understand this today, in simple words without talking about theory in depth. While database is in full recovery mode, it can rollback any changes done by DELETE using Log files. TRUNCATE can not be... - [SQL SERVER - Mirrored Backup Introduction and Explanation](https://blog.sqlauthority.com/2007/12/25/sql-server-mirrored-backup-introduction-and-explanation/): SQL Server 2005 Enterprise Edition and Development Edition supports mirrored backup. Mirroring a media set increases backup reliability by adding redundancy of backup media which effectively reduces the impact of backup-device failing. While taking backup of database, same backup is taken on multiple media or locations. T-SQL code to take Mirrored Backup : BACKUP DATABASE AdventureWorks TO DISK = 'c:\AdventureWorksBackup.bak' MIRROR TO DISK = 'd:\AdventureWorksBackupCopy.bak' WITH FORMAT; Above script will create two backups at two different locations, if backup of one location is corrupted backup from another location will work fine. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Delete Duplicate Records - Count Duplicate Records Links](https://blog.sqlauthority.com/2007/12/25/sql-server-delete-duplicate-records-count-duplicate-records-links/): I have wrote following two articles for Duplicate Rows Management in SQL Server. SQL SERVER – Count Duplicate Records – Rows SQL SERVER – Delete Duplicate Records – Rows Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Object Oriented Database Management Systems](https://blog.sqlauthority.com/2007/12/24/sql-server-object-oriented-database-management-systems/): I have received few emails and comments about why I do not write about Object Oriented Database Management Systems (OODBMS). The reason for that is that I am big follower of Relational Database Management Systems (RDBMS) and that particularly of Microsoft SQL Server. If you are interested in reading about OODBMS, I have came across one interesting article, which I can share here. Visit : AN EXPLORATION OF OBJECT ORIENTED DATABASE MANAGEMENT SYSTEMS by Dare Obasanjo The purpose of above mentioned paper is to provide answers to the following questions What is an Object Oriented Database Management System (OODBMS)? Is an... - [SQLAuthority News - Download Microsoft SQL Server 2000/2005 Management Pack](https://blog.sqlauthority.com/2007/12/24/sqlauthority-news-download-microsoft-sql-server-20002005-management-pack/): Note: Download Microsoft SQL Server 2000/2005 Management Pack by Microsoft The SQL Server Management Pack monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems. Availability and performance monitoring is done using synthetic transactions. In addition, the Management Pack collects Event Log alerts and provides associated knowledge articles with additional user details, possible causes, and suggested resolutions. The Management Pack discovers Database Engines, Database Instances, and Databases and can optionally discover Database File and Database File Group objects. Feature Summary: Active Directory Helper Service SQL Server Agent Backup Databases and Tables DBCC Full... - [SQLAuthority News - Jobs, Search, Best Articles, Homepage](https://blog.sqlauthority.com/2007/12/24/sqlauthority-news-jobs-search-best-articles-homepage/): If you are looking for solution of any of your question : Search SQLAuthority If you are looking for best job in IT field : Find Job or email pinal@sqlauthority.com If you are looking for talented IT professional : Post Job or email pinal@sqlauthority.com If you want to read my personally selected articles : Best Articles If you want to know more about me : pinaldave.com If you want to subscribe to my blog : Email or Feed Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2008 - New DataTypes DATE and TIME](https://blog.sqlauthority.com/2007/12/23/sql-server-2008-new-datatypes-date-and-time/): One of our project manager asked me why SQL Server does not have only DATE or TIME datatypes? I thought his question is very valid, he is not DBA however he understands the RDBMS concepts very well. I find his question very interesting. I told him that there are ways to do that in SQL Server 2005 and earlier versions. He asked me but if there are DATE and TIME datatypes not DATETIME combined. This question we all DBA had for many years and we all wanted DATE and TIME separate datatypes then DATETIME combined. Microsoft has incorporated this feature in... - [SQL SERVER - Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script](https://blog.sqlauthority.com/2007/12/22/sql-server-difference-between-index-rebuild-and-index-reorganize-explained-with-t-sql-script/): Index Rebuild : This process drops the existing Index and Recreates the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REBUILD GO Index Reorganize : This process physically reorganizes the leaf nodes of the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REORGANIZE GO Recommendation: Index should be rebuild when index fragmentation is great than 40%. Index should be reorganized when index fragmentation is between 10% to 40%. Index rebuilding process uses more CPU and it locks the database resources. SQL Server development version and Enterprise version has option ONLINE, which can be turned on when Index is rebuilt.... - [SQL SERVER - Enabling Clustered and Non-Clustered Indexes - Interesting Fact](https://blog.sqlauthority.com/2007/12/21/sql-server-enabling-clustered-and-non-clustered-indexes-interesting-fact/): While playing with Indexes I have found following interesting fact. I did some necessary tests to verify that it is true. When a clustered index is disabled, all the nonclustered indexes on the same tables are auto disabled as well. User do not need to disable non-clustered index separately. However, when clustered index is enabled, it does not automatically enable nonclustered index. All the nonclustered indexes needs to be enabled individually. I wondered if there is any short cut to enable all the indexes together. Index rebuilding came to my mind instantly. I ran T-SQL command of rebuilding all the indexes... - [SQL SERVER - DISTINCT Keyword Usage and Common Discussion](https://blog.sqlauthority.com/2007/12/20/sql-server-distinct-keyword-usage-and-common-discussion/): Jr. DBA asked me a day ago, how to apply DISTINCT keyword to only first column of SELECT. When asked for additional information about question, he showed me following query. SELECT Roles, FirstName, LastName FROM UserNames He wanted to apply DISTINCT to only Roles and not across FirstName and LastName. When he finished I realize that it is not possible and there is logical error in thinking query like that. I helped him with what he needed however, after he left I realize that answer to his original question was “NO”. Distinct can not be applied to only few columns it... - [SQL SERVER - Cumulative Update Package 5 for SQL Server 2005 Service Pack 2](https://blog.sqlauthority.com/2007/12/19/sql-server-cumulative-update-package-5-for-sql-server-2005-service-pack-2/): Microsoft SQL Server 2005 hotfixes are created for specific SQL Server service packs. You must apply a SQL Server 2005 Service Pack 2 hotfix to an installation of SQL Server 2005 Service Pack 2. By default, any hotfix that is provided in a SQL Server service pack is included in the next SQL Server service pack. Cumulative Update 5 contains hotfixes for SQL Server 2005 issues that have been fixed since the release of Service Pack 2. Latest Build 3215. Download Information Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - RML Utilities for SQL Server](https://blog.sqlauthority.com/2007/12/19/sqlauthority-news-rml-utilities-for-sql-server/): The RML utilities allow you to process SQL Server trace files and view reports showing how SQL Server is performing. For example, you can quickly see: Which application, database or login is using the most resources, and which queries are responsible for that Whether there were any plan changes for a batch during the time when the trace was captured and how each of those plans performed What queries are running slower in today’s data compared to a previous set of data Download RML Utilities for SQL Server (x86) Download RML Utilities for SQL Server (x64) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Get Information of Index of Tables and Indexed Columns](https://blog.sqlauthority.com/2007/12/18/sql-server-get-information-of-index-of-tables-and-indexed-columns/): Knowledge of T-SQL inbuilt functions and store procedure can save great amount of time for developers. Following is very simple store procedure which can display name of Indexes and the columns on which indexes are created. Very handy stored Procedure. USE AdventureWorks; GO EXEC sp_helpindex 'Person.Address' GO Above SP will return following information. IndexName – IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode Index_Description – nonclustered, unique located on PRIMARY Index_Keys – AddressLine1, AddressLine2, City, StateProvinceID, PostalCode Let me know if you think this kind of small tips are useful to you. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - T-SQL Script to Find Details About TempDB Information](https://blog.sqlauthority.com/2007/12/17/sql-server-t-sql-script-to-find-details-about-tempdb/): Two days ago I wrote an article about SQL SERVER - TempDB Restrictions - Temp Database Restrictions. Since then I have received few emails asking details about Temp DB. I use following T-SQL Script to know details about my TempDB. This script is a pretty old script but it does work great most of the time. I strongly encourage all of you to use a script to check your TempDB Information. - [SQL SERVER - Solution - Log File Very Large - Log Full](https://blog.sqlauthority.com/2007/12/16/sql-server-solution-log-file-very-large-log-full/): I have been receiving following question again and again either through email or through comments on this blog. My log file is too big, what should I do? Answer to this question is in three steps. Backup the log file to any device. Truncate the log file. Shrink the log file. I have previously written two article about this issue. Refer them for additional information and details. SQL SERVER – Shrinking Truncate Log File – Log Full(Script) SQL SERVER – Shrinking Truncate Log File – Log Full – Part 2(Management Studio) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - TempDB Restrictions - Temp Database Restrictions](https://blog.sqlauthority.com/2007/12/15/sql-server-tempdb-restrictions-temp-database-restrictions/): While conducting Interview for my outsourcing project, I asked one question to interviewer that what are the restrictions on TempDB? The candidate was not able to answer the question. I thought it would be good for all my readers to know the answer to this question so if you face this question in an interview or if you meet me in the interview you will be able to answer this question. - [SQLAuthority News - Top 10 Tips for Successful Software Outsourcing](https://blog.sqlauthority.com/2007/12/14/sqlauthority-news-top-10-tips-for-successful-software-outsourcing/): Few days ago, I wrote article about SQLAuthority Author Visit – IT Outsourcing to India – Top 10 Reasons Companies Outsource. I received quite a few emails regarding this article. I was really impressed that how much vendors care about their reputation and their client. I received so many requests from my blog readers who are interested in learning how to be successful at Software Outsourcing. I decided to write top 10 tips for the same. I have not described them in depth as they are pretty self explanatory. Define the scope of project clearly and as much as detail it... - [SQL SERVER - Do Not Store Images in Database - Store Location of Images (URL)](https://blog.sqlauthority.com/2007/12/13/sql-server-do-not-store-images-in-database-store-location-of-images-url/): Just a day ago I received phone call from my friend in Bangalore. He asked me What do I think of storing images in database and what kind of datatype he should use? I have very strong opinion about this issue. I suggest to store the location of the images in the database using VARCHAR datatype instead of any BLOB or other binary datatype. Storing the database location reduces the size of database greatly as well updating or replacing the image are much simpler as it is just an file operation instead of massive update/insert/delete in database. Reference : Pinal Dave... - [SQL SERVER - White Papers: Migration from Oracle Sybase, or Microsoft Access to Microsoft SQL Server](https://blog.sqlauthority.com/2007/12/12/sql-server-white-papers-migration-from-oracle-sybase-or-microsoft-access-to-microsoft-sql-server/): Guide to Migrating from Oracle to SQL Server 2005 This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2005. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. The entire migration process using SQL Server Migration Assistant for Oracle (SSMA Oracle) is explained in depth, with a special focus on converting database objects and PL/SQL code. Guide to Migrating from Sybase ASE to SQL Server 2005 This white paper covers known issues for migrating Sybase Adaptive Server Enterprise database to SQL Server... - [SQL SERVER - Microsoft Synchronization Services for ADO.NET v2.0 CTP1 Refresh](https://blog.sqlauthority.com/2007/12/11/sql-server-microsoft-synchronization-services-for-adonet-v20-ctp1-refresh/): Microsoft Synchronization Services for ADO.NET provides the ability to synchronize data from disparate sources over two-tier, N-tier, and service-based architectures. Rather than simply replicating a database and its schema, the Synchronization Services application programming interface (API) provides a set of components to synchronize data between data services and a local store. Applications are increasingly used on mobile clients, such as laptops and devices, that do not have a consistent or reliable network connection to a central server. It is crucial for these applications to work against a local copy of data on the client. Equally important is the need to synchronize... - [SQLAuthority News - Microsoft SQL Server 2008 Community Technology Preview (November 2007) VHD](https://blog.sqlauthority.com/2007/12/10/sqlauthority-news-microsoft-sql-server-2008-community-technology-preview-november-2007-vhd/): SQL Server 2008, the next release of Microsoft SQL Server, will provide a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with relevant insights. This download comes as a pre-configured VHD. This allows you to trial SQL Server 2008 CTP in a virtual environment. Download from here. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - ACID (Atomicity, Consistency, Isolation, Durability)](https://blog.sqlauthority.com/2007/12/09/sql-server-acid-atomicity-consistency-isolation-durability/): ACID (an acronym for Atomicity Consistency Isolation Durability) is a concept that Database Professionals generally look for when evaluating databases and application architectures. For a reliable database all this four attributes should be achieved. - [SQL SERVER - Generic Architecture Image](https://blog.sqlauthority.com/2007/12/08/sql-server-generic-architecture-image/): Just a day ago, while I was surfing Wikipedia about SQL Server, I came across this generic architecture image. I found it interesting. Click on image to view it in large size. The physical structure of the database is divided into the MDF and LDF. The part of MDF contains file group, data files, tables and indexes, extended and page. The LDF file contains a transaction log file. The physical architecture is about how the data is actually stored in the file system. Page, extend, database files are physical architecture. - [SQL SERVER - FIX : Error : 3702 Cannot drop database because it is currently in use.](https://blog.sqlauthority.com/2007/12/07/sql-server-fix-error-3702-cannot-drop-database-because-it-is-currently-in-use/): Msg 3702, Level 16, State 3, Line 2 Cannot drop database “DataBaseName” because it is currently in use. This is a very generic error when DROP Database is command is executed and the database is not dropped. The common mistake user is kept the connection open with this database and trying to drop the database. The following commands will raise above error: USE AdventureWorks; GO DROP DATABASE AdventureWorks; GO Fix/Workaround/Solution: The following commands will not raise an error and successfully drop the database: USE Master; GO DROP DATABASE AdventureWorks; GO If you want to drop the database use master database first... - [SQL SERVER - 2005 - Dynamic Management Views (DMV) and Dynamic Management Functions (DMF)](https://blog.sqlauthority.com/2007/12/06/sql-server-2005-dynamic-management-views-dmv-and-dynamic-management-functions-dmf/): Dynamic Management Views (DMV) and Dynamic Management Functions (DMF) return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance. They can exactly tell what is going on with SQL Server and its objects at the moment.There are tow kinds of DMVs and DMFs. Server-scoped dynamic management views and functions. Database-scoped dynamic management views and functions. All dynamic management views and functions exist in the sys schema and follow this naming convention dm_*. When you use a dynamic management view or function, you must prefix the name of the view or... - [SQL SERVER - UDF - Remove Duplicate Chars From String](https://blog.sqlauthority.com/2007/12/05/sql-server-udf-remove-duplicate-chars-from-string/): Few days ago, I received following wonderful UDF from one of this blog reader. This UDF is written for specific purpose of removing duplicate chars string from one large string. Virendra Chauhan, author of this UDF is working as DBA in Lutheran Health Network. CREATE FUNCTION dbo.REMOVE_DUPLICATE_INSTR (@datalen_tocheck INT,@string VARCHAR(255)) RETURNS VARCHAR(255) AS BEGIN DECLARE @str VARCHAR(255) DECLARE @count INT DECLARE @start INT DECLARE @result VARCHAR(255) DECLARE @end INT SET @start=1 SET @end=@datalen_tocheck SET @count=@datalen_tocheck SET @str = @string WHILE (@count <=255) BEGIN IF (@result IS NULL) BEGIN SET @result='' END SET @result=@result+SUBSTRING(@str,@start,@end) SET @str=REPLACE(@str,SUBSTRING(@str,@start,@end),'') SET @count=@count+@datalen_tocheck END RETURN @result END... - [SQLAuthority Author Visit - IT Outsourcing to India - Top 10 Reasons Companies Outsource](https://blog.sqlauthority.com/2007/12/04/sqlauthority-author-visit-it-outsourcing-to-india-top-10-reasons-companies-outsource/): Yesterday I had meeting with few of the leading outsourcing companies in Ahmedabad, India. Regular readers of this blog knows that I am currently in India handling large scale outsourcing assignment. My responsibilities includes managing application development, system architecture and database architecture. The purpose of meeting was to exchange the views and learn methodologies from one another regarding how to provide quality service to offshore clients. There were about 10-15 Sr. Managers from different outsourcing company. The conversation was excellent and we all felt that we have learned a lot from each other. Two major things discussed were quality of products... - [SQL SERVER - Grouping JOIN Clauses In SQL](https://blog.sqlauthority.com/2007/12/03/sql-server-grouping-join-clauses-in-sql/): I always enjoy writing and reading articles about JOIN Clauses. One of my friend and the best ColdFusion Expert Ben Nadel has written good article about SQL JOINs. There are few interesting comments as well at the end of article. “JOIN grouping is pretty powerful and can get you out of those sticky situations that involve mixed table relationship rules. ” Ben Nadel – Grouping JOIN Clauses In SQL Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Q and A with Database Administrators](https://blog.sqlauthority.com/2007/12/02/sql-server-qa-with-database-administrators/): I have been in India for more than a month now, as I am leading a very large outsourcing project. We have conducted few interviews since the project required more Database Administrators and Senior Developers. I am listing few of the questions discussed during all the interviews. The whole event of interviews was very interesting. I met some very good programmers from all over the country. Many interesting questions were discussed between interviewers and candidates. I am listing some of those questions here. Some are technical and some are just my personal opinions. I will appreciate your thought about this article.... - [SQL SERVER - Sharpen Your Skills: Brush up on FILLFACTOR, ISNULL, NULLIF, and % as wildcard and operator](https://blog.sqlauthority.com/2007/12/01/sql-server-sharpen-your-skills-brush-up-on-fillfactor-isnull-nullif-and-as-wildcard-and-operator/): Read my article in SQL Server Magazine December 2007 Edition I will be not able to post complete article here due to copyright issues. Please visit the link above to read the article. [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Download SQL Server 2005 Books Online (September 2007)](https://blog.sqlauthority.com/2007/11/30/sqlauthority-news-download-sql-server-2005-books-online-september-2007/): Download an updated version of Books Online for Microsoft SQL Server 2005. Books Online is the primary documentation for SQL Server 2005. The September 2007 update to Books Online contains new material and fixes to documentation problems reported by customers after SQL Server 2005 was released. Refer to “New and Updated Books Online Topics” for a list of topics that are new or updated in this version. Topics with significant updates have a Change History table at the bottom of the topic that summarizes the changes. Beginning with the February 2007 update, SQL Server 2005 Books Online reflects product upgrades included... - [SQL SERVER - Database Interview Questions and Answers Complete List](https://blog.sqlauthority.com/2007/11/29/sql-server-database-interview-questions-and-answers-complete-list/): Update: I have updated this article series and newly updated article series is over here. If you are subscribed to my blog you will know that I receive request to send Database or SQL Server very frequently. Following is list of articles of my questions and answers series. Download SQL Server Interview Questions and Answers Complete List Complete Series of SQL Server Interview Questions and Answers SQL Server Interview Questions and Answers – Introduction SQL Server Interview Questions and Answers – Part 1 SQL Server Interview Questions and Answers – Part 2 SQL Server Interview Questions and Answers – Part 3... - [SQL SERVER - Correct Syntax for Stored Procedure SP](https://blog.sqlauthority.com/2007/11/28/sql-server-correct-syntax-for-stored-procedure-sp/): Just a day ago, I received interesting question about correct syntax for Stored Procedure. Many readers of this blog will think that it is very simple question. The reason this is interesting is the question behavior of BEGIN … END statements and GO command in Stored Procedure. Let us first see what is correct syntax. Correct Syntax: CREATE PROCEDURE usp_SelectRecord AS BEGIN SELECT * FROM TABLE END GO I have seen many new developers write statements after END statement. This will not work but will probably execute first fine when stored procedure is created. Rule is anything between BEGIN and END... - [SQL SERVER - 2005 - List All Stored Procedure in Database](https://blog.sqlauthority.com/2007/11/27/sql-server-2005-list-all-stored-procedure-in-database/): Run following simple script on SQL Server 2005 to retrieve all stored procedure in database. SELECT * FROM sys.procedures; This will ONLY work with SQL Server 2005. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Rules of Third Normal Form and Normalization Advantage - 3NF](https://blog.sqlauthority.com/2007/11/26/sql-server-rules-of-third-normal-form-and-normalization-advantage-3nf/): I always ask question about Third Normal Form in interviews I take. Q. What is Third Normal Form and what is its advantage? A. Third Normal Form (3NF) is most preferable normal form in RDBMS. Normalization is the process of designing a data model to efficiently store data in a database. The rules of 3NF are mentioned here Make a separate table for each set of related attributes, and give each table a primary key. If an attribute depends on only part of a multi-valued key, remove it to a separate table If attributes do not contribute to a description of... - [SQLAuthority News - SQL Server Compact 3.5 Downloads and ReportViewer Visual Studio Download](https://blog.sqlauthority.com/2007/11/25/sqlauthority-news-sql-server-compact-35-downloads-and-reportviewer-visual-studio-download/): SQL Server Compact 3.5 Books Online and Samples SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the Books Online and Samples for SQL Server Compact 3.5 SQL Server Compact 3.5 for Windows Mobile SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the CAB files and DLL’s that are used to install SQL Server Compact 3.5 on the Windows Mobile Devices platform SQL Server... - [SQL SERVER - Upgrade Advise - From 2000 to 2005 or 2008](https://blog.sqlauthority.com/2007/11/24/sql-server-upgrade-advise-from-2000-to-2005-or-2008/): There has some good amount of discussion going on in SQL Server community about should we upgrade from SQL Server 2000 to SQL Server 2005 or wait for SQL Server 2008. I have received quite a few email and invitations to participate in forums on this topic. Instead of talking about this topic on different places, I have decided to write my opinion on my blog. I recommend to upgrade to SQL Server 2000 users to SQL Server 2005. SQL Server 2008 is due next year. The RTM may or may not be available till February 2008. After the release the... - [SQL SERVER - 2008 - November CPT5 New Improvement](https://blog.sqlauthority.com/2007/11/23/sql-server-2008-november-cpt5-new-improvement/): The progress map of SQL Server 2008 is diagrammatically listed here. I am listing the new improvements here as list. Data Collection and Performance Warehouse for Relational Engine Service Broker Enhancements Registered Servers Enhancements Synchronous net-changes change tracking for SQL Server T-SQL IntelliSense Declarative Management Framework (DMF) Enhancements Geo-spatial Support Analysis Services Query and Writeback Performance Robust Report Server Platform Integration Services – Lookup Enhancements Analysis Services MDX Query Optimizer – Block Computation Analysis Services Aggregation Design Analysis Services Cube Design Reporting Services Scale Engine Transparent Data Encryption Resource Governor – Limit Specification Backup Compression Plan Freezing Fully Parallel Plans Scale... - [SQL SERVER - Shrinking Truncate Log File - Log Full - Part 2](https://blog.sqlauthority.com/2007/11/22/sql-server-shrinking-truncate-log-file-log-full-part-2/): About a year ago, I wrote SQL SERVER - Shrinking Truncate Log File - Log Full. I was just going through some of the earlier posts and comments. - [SQL SERVER - Generate Incremented Linear Number Sequence](https://blog.sqlauthority.com/2007/11/21/sql-server-generate-incremented-linear-number-sequence/): Just a day ago, I received interesting question on this blog. Read original question here. This is very good question and after reading this question I quickly wrote small script as answer. Let us see the question and answer together. Q. How can we generate incremented linear number in sql server as in oracle we generate in via sequence? - [SQL SERVER - Sharpen Your Skills: Joins, Groupings, and Data Types](https://blog.sqlauthority.com/2007/11/20/sql-server-sharpen-your-skills-joins-groupings-and-data-types/): Read my article in SQL Server Magazine November 2007 Edition [Articles are relocated so links are disabled] Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server 2008 Community Technology Preview (CTP) Download Now Available](https://blog.sqlauthority.com/2007/11/19/sqlauthority-news-sql-server-2008-community-technoloypreview-ctp-download-now-available/): Download the latest SQL Server 2008 Community Technology Preview (CTP) and try out the latest features of SQL Server 2008! The SQL Server development team uses your CTP feedback to help refine and enhance product features. Download it today and send your feedback. Microsoft SQL Server 2008, the next release of Microsoft SQL Server, provides a comprehensive data platform that is more secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with... - [SQLAuthority News - Job Opportunity in Ahmedabad, India to Work with Technology Leaders Worldwide - SQL Server, ColdFusion, ASP.NET](https://blog.sqlauthority.com/2007/11/18/sqlauthority-news-job-opportunity-in-ahmedabad-india-to-work-with-technology-leaders-worldwide-sql-server-coldfusion-aspnet/): If you have one or more years of experience in any web based programming language (.NET, ColdFusion, PHP) and interested in SQL Server as well willing to locate Ahmadabad, India. Please send me your resume, if selected you may get chance to work with one of the most progressing industry in world as well some smartest technology leaders worldwide. Salary depends on Experience. If selected for interview I suggest you go over SQL Server Interview Questions and Answers Complete List Download, as there is great chance I may be participating in interview. Please send your resume at pinaldave “at” yahoo.com and... - [SQL SERVER - 2005 - Best Practices for SQL Server Health Check](https://blog.sqlauthority.com/2007/11/17/sql-server-2005-best-practices-for-sql-server-health-check/): Here are few of the best practices one should follow for SQL Server Health Check. - [SQL SERVER - Generate Script with Data from Database - Database Publishing Wizard](https://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/): I really enjoyed writing about SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects. Since then the I have received question that how to copy data as well along with schema. The answer to this is Database Publishing Wizard. This wizard is very flexible and works with modes like schema only, data only or both. It generates a single SQL script file which can be used to recreate the contents of a database by manually executing the script on a target server. - [SQLAuthority News - Microsoft SQL Server 2005 Assessment Configuration Pack Download](https://blog.sqlauthority.com/2007/11/15/sqlauthority-news-microsoft-sql-server-2005-assessment-configuration-pack-download/): Microsoft SQL Server 2005 Assessment Configuration Pack for Gramm-Leach Bliley Act (GLBA) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Gramm-Leach Bliley Act compliance efforts Microsoft SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX) This configuration pack contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts. Microsoft SQL Server 2005 Assessment Configuration Pack for Federal Information Security Management Act (FISMA) This configuration pack contains... - [SQLAuthority News - SQL Joke, SQL Humor, SQL Laugh - Database Dilbert](https://blog.sqlauthority.com/2007/11/14/sqlauthority-news-sql-joke-sql-humor-sql-laugh-database-dilbert/): This is my favorite Dilbert. Dilbert is an American comic strip written and illustrated by Scott Adams, first published in the year 1969. - [SQLAuthority News - Microsoft SQL Server 2005 MSIT Three Configuration Pack for Configuration Manager 2007](https://blog.sqlauthority.com/2007/11/14/sqlauthority-news-microsoft-sql-server-2005-msit-three-configuration-pack-for-configuration-manager-2007/): Microsoft SQL Server 2005 MSIT Basic Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2005 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2005 MSIT Intermediate Configuration Pack for Configuration Manager 2007 This configuration pack contains configuration items intended to manage your SQL Server 2005 server roles, and was developed based on settings used by Microsoft IT in the configuration of these server roles. Microsoft SQL Server 2005 MSIT Comprehensive Configuration Pack for Configuration Manager 2007 This... - [SQL SERVER - DBCC CHECKDB Introduction and Explanation - DBCC CHECKDB Errors Solution](https://blog.sqlauthority.com/2007/11/13/sql-server-dbcc-checkdb-introduction-and-explanation-dbcc-checkdb-errors-solution/): DBCC CHECKDB checks the logical and physical integrity of all the objects in the specified database. If DBCC CHECKDB ran on database user should not run DBCC CHECKALLOC, DBCC CHECKTABLE, and DBCC CHECKCATALOG on database as DBCC CHECKDB includes all the three command. Usage of these included DBCC commands is listed below. - [SQL SERVER - FIX : ERROR Msg 1803 The CREATE DATABASE statement failed. The primary file must be at least 2 MB to accommodate a copy of the model database](https://blog.sqlauthority.com/2007/11/12/sql-server-fix-error-msg-1803-the-create-database-statement-failed-the-primary-file-must-be-at-least-2-mb-to-accommodate-a-copy-of-the-model-database/): Following error occurs when database which is attempted to be created is smaller than Model Database. It is must that all the databases are larger than Model database and 512KB. Following code will create the error discussed in this post. CREATE DATABASE Tests ON ( NAME = 'Tests', FILENAME = 'c:\tests.mdf', SIZE = 512KB ) GO Msg 1803, Level 16, State 1, Line 1 The CREATE DATABASE statement failed. The primary file must be at least 2 MB to accommodate a copy of the model database. Fix/WorkAround/Solution : Create database which is larger than Model database and 512KB. Size of the... - [SQLAuthority News - The Equations of Relativist](https://blog.sqlauthority.com/2007/11/12/sqlauthority-news-the-equations-of-relativist/): F = mg ….. Galileo F = ma ….. Newton E = mc²….. Einstein Reference : Pinal Dave (https://blog.sqlauthority.com) , Great Site – relationary) - [SQL SERVER - FIX : ERROR Msg 5174 Each file size must be greater than or equal to 512 KB](https://blog.sqlauthority.com/2007/11/12/sql-server-fix-error-msg-5174-each-file-size-must-be-greater-than-or-equal-to-512-kb/): Following error occurs when database which is attempted to be created is smaller than 512KB. It is must that all the databases are larger than 512KB. It will also follow with another error 1802, which is due to previous error 5174. Following code will create the error discussed in this post. CREATE DATABASE Tests ON ( NAME = 'Tests', FILENAME = 'c:\tests.mdf', SIZE = 12KB ) GO Msg 5174, Level 16, State 1, Line 1 Each file size must be greater than or equal to 512 KB. Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names... - [SQLAuthority News - SQL Server 2005 Powers Global Forensic Data Security Tool](https://blog.sqlauthority.com/2007/11/11/sqlauthority-news-sql-server-2005-powers-global-forensic-data-security-tool/): Note :  Download Whitepaper by Microsoft Find out how SQL Server 2005 powers a 27 TB data management system called ICE 3.0 that gathers forensic data from more than 85 Microsoft corporate proxy servers into a single database. The Information Security team at Microsoft uses an internal tool called Information Security Consolidated Event Management (ICE 3.0) to gather forensic data from more than 85 proxy servers around the world. Powered by SQL Server 2005, the 27 TB data management system collects different types of global evidence, such as inbound and outbound e-mail traffic, Login events, and Web browsing, into a single... - [SQL SERVER - 2005 2000 - Search String in Stored Procedure](https://blog.sqlauthority.com/2007/11/10/sql-server-2005-2000-search-string-in-stored-procedure/): SQL Server has released SQL Server 2000 edition before 7 years and SQL Server 2005 edition before 2 years now. There are still few users who have not upgraded to SQL Server 2005 and they are waiting for SQL Server 2008 in February 2008 to SQL Server 2008 to release. This blog has is heavily visited by users from both the SQL Server products. I have two previous posts which demonstrate the code which can be searched string in stored procedure. Many users get confused with the script version and try to execute SQL Server 2005 version on SQL Server 2000,... - [SQL SERVER - Versions, CodeNames, Year of Release](https://blog.sqlauthority.com/2007/11/09/sql-server-versions-codenames-year-of-release/): Just a day ago, while I was discussing one of the project with another outsourcing team lead in India (who is leading team of 100+ programmer and developer) he asked me if I know all the codenames of the SQL Server releases so far. I knew only two code names SQL Server 2005 – Yukon and SQL Server 2008 – Katmai. Once our meeting was over, I could not stop thinking about this question. I search online and very easily I found answer to this question on wikipedia. 1993 – SQL Server 4.21 for Windows NT 1995 – SQL Server 6.0,... - [SQLAuthority News - Book Review - SQL Server 2005 Management and Administration (Paperback)](https://blog.sqlauthority.com/2007/11/08/sqlauthority-news-book-review-sql-server-2005-management-and-administration-paperback/): SQL Server 2005 Management and Administration (Paperback) by Ross Mistry (Author), Chris Amaris (Author), Alec Minty (Author), Rand Morimoto (Author) Link to Amazon Short Summary: SQL SERVER 2005 is a trusted database platform that provides organizations a competitive advantage by allowing them to obtain faster results and make better business decisions. This book covers all the topics which can help Database Administrators to be successful and effective. Detail summary: This book is covers all the topics and modules of the SQL Server 2005, e.g. database engine, Analysis Services, Integration Services, replication, Reporting Services, Notification Services, services broker and full text search.... - [SQLAuthority News - 1 Million Visitors in last 1 year - [Update 2019]](https://blog.sqlauthority.com/2007/11/07/sqlauthority-news-1-million-visitors-in-last-1-year-update-2019/): It is indeed a bit day for me. I am very happy that I have 1 million visitors in just last 1 year. Read my story of 365 days. - [SQLAuthority News - Microsoft Synchronization Services for ADO.NET v2.0 CTP1](https://blog.sqlauthority.com/2007/11/06/sqlauthority-news-microsoft-synchronization-services-for-adonet-v20-ctp1/): Microsoft Synchronization Services for ADO.NET provides the ability to synchronize data from disparate sources over two-tier, N-tier, and service-based architectures. Rather than simply replicating a database and its schema, the Synchronization Services application programming interface (API) provides a set of components to synchronize data between data services and a local store. Applications are increasingly used on mobile clients, such as laptops and devices, that do not have a consistent or reliable network connection to a central server. It is crucial for these applications to work against a local copy of data on the client. Equally important is the need to synchronize... - [SQLAuthority News - Few Add-ons for SQLAuthority](https://blog.sqlauthority.com/2007/11/05/sqlauthority-news-few-add-ons-for-sqlauthority/): SQL Random Article Find Post SQL Jobs Search SQLAuthority Subscribe Email Update SQLAuthority Feed My Other Blog Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Best Articles on SQLAuthority.com](https://blog.sqlauthority.com/2007/11/04/sqlauthority-news-best-articles-on-sqlauthoritycom/): SQL SERVER – Cursor to Kill All Process in Database SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored procedure SQL SERVER – Shrinking Truncate Log File – Log Full SQL SERVER – Simple Example of Cursor SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case SQL SERVER – Restore Database Backup using SQL Script (T-SQL) SQL SERVER – T-SQL Script to find the CD key from Registry SQL SERVER – Delete Duplicate Records – Rows SQL SERVER – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF Explanation SQL SERVER... - [SQLAuthority News - Best SQLAuthority Articles on Other Popular Sites](https://blog.sqlauthority.com/2007/11/03/sqlauthority-news-best-sqlauthority-articles-on-other-popular-sites/): Best SQLAuthority Articles on Other Popular Sites SQL SERVER – UDF vs. Stored Procedures and Having vs. WHERE (SQL Server Magazine) SQL SERVER – Pre-Code Review Tips – Tips For Enforcing Coding Standards (dotnetslackers.com) Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Best Downloads on SQLAuthority.com](https://blog.sqlauthority.com/2007/11/02/sqlauthority-news-best-downloads-on-sqlauthoritycom/): Best Downloads on SQLAuthority.com SQL SERVER – Query Analyzer Shortcuts SQL Server Interview Questions and Answers Complete List Download SQL SERVER – Download SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts) SQL SERVER Database Coding Standards and Guidelines Complete List Download SQL SERVER – Data Warehousing Interview Questions and Answers Complete List Download Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - First Birthday of Blog - 365 Post in One Year](https://blog.sqlauthority.com/2007/11/01/sqlauthority-news-first-birthday-of-blog-365-post-in-one-year/): Hello Everyone, Today is birthday of this blog. Exactly one year ago, I started this journey of SQL Server and today I have reached first mile stone. There are so many great experience I had during this year. One thing I enjoyed the most is My Extremely Knowledgeable and Friendly Readers. I have learned a lot from all my readers, their emails and comments on this blog. You have been wonderful part of this blog. I was very surprised when I counted how many articles I had posted last year. It was perfect 365! One article a day!! Once again, I... - [SQL SERVER - Importance of Master Database for SQL Server Startup](https://blog.sqlauthority.com/2007/10/31/sql-server-importance-of-master-database-for-sql-server-startup/): I have received following questions. I will list all the questions here and answer them together. What is the purpose of Master database? - [SQL SERVER - Business Intelligence (BI) Basic Terms Explanation](https://blog.sqlauthority.com/2007/10/30/sql-server-business-intelligence-bi-basic-terms-explanation/): Business Intelligence Business intelligence is a method of storing and presenting key enterprise data so that anyone in your company can quickly and easily ask questions of accurate and timely data. Effective BI allows end users to use data to understand why your business go the particular results that it did, to decide on courses of action based on past data, and to accurately forecast future results. Data Warehouse A single structure that usually, but not always, consists of one or more cubes. Data Mart A defined subset of a data warehouse, often a single cube from a group. It represents... - [SQL SERVER - Disable All Triggers on a Database - Disable All Triggers on All Servers](https://blog.sqlauthority.com/2007/10/29/sql-server-disable-all-triggers-on-a-database-disable-all-triggers-on-all-servers/): Just a day ago, I received question in email regarding my article SQL SERVER – 2005 Disable Triggers – Drop Triggers. Question : How to disable all the triggers for database? Additionally, how to disable all the triggers for all servers? Answer: Disable all the triggers for a single database: USE AdventureWorks; GO DISABLE TRIGGER Person.uAddress ON AdventureWorks; GO Disable all the triggers for all servers: USE AdventureWorks; GO DISABLE TRIGGER ALL ON ALL SERVER; GO Reference : Pinal Dave (https://blog.sqlauthority.com), BOL-Triggers - [Big Data - Role of Cloud Computing in Big Data - Day 11 of 21](https://blog.sqlauthority.com/2013/10/15/big-data-role-of-cloud-computing-in-big-data-day-11-of-21/): In this post we learned the importance of the NewSQL. In this article we will understand the role of Cloud Computing in Big Data Story - [Big Data - Buzz Words: What is NewSQL - Day 10 of 21](https://blog.sqlauthority.com/2013/10/14/big-data-buzz-words-what-is-newsql-day-10-of-21/): In yesterday’s blog post we learned the importance of the relational database. In this article we will take a quick look at the what is NewSQL. What is NewSQL? NewSQL stands for new scalable and high performance SQL Database vendors. The products sold by NewSQL vendors are horizontally scalable. NewSQL is not kind of databases but it is about vendors who supports emerging data products with relational database properties (like ACID, Transaction etc.) along with high performance. Products from NewSQL vendors usually follow in memory data for speedy access as well are available immediate scalability. NewSQL term was coined by 451... - [SQLAuthority News - Presented Technical Session at DevReach 2013, Sofia, Bulgaria - Oct 1, 2013](https://blog.sqlauthority.com/2013/10/13/sqlauthority-news-presented-technical-session-at-devreach-2013-sofia-bulgaria-oct-1-2013/): Earlier this month, I had a fantastic time presenting at DevReach 2013, in Sofia, Bulgaria on Oct 1, 2013. DevReach strives to be the premier developer conference in Central and Eastern Europe. It is organized annually in Sofia, Bulgaria. The 8th edition of the conference is moving to a new and bigger venue: Sofia Event Center. In my career, I have presented over 9 different countries (India, USA, Canada, Singapore, Hong Kong, Malaysia, Sri Lanka, Nepal, Thailand), this was the first time for me to present in Europe. DevReach was perfect places to start my journey in Europe as an evangelist. The event... - [SQL SERVER - Weekly Series - Memory Lane - #050](https://blog.sqlauthority.com/2013/10/12/sql-server-weekly-series-memory-lane-050/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Executing Remote Stored Procedure – Calling Stored Procedure on Linked Server In this example we see two different methods of how to call Stored Procedures remotely.  Connection Property of SQL Server Management Studio SSMS A very simple example of the how to build connection properties... - [Big Data - Buzz Words: Importance of Relational Database in Big Data World - Day 9 of 21](https://blog.sqlauthority.com/2013/10/11/big-data-buzz-words-importance-of-relational-database-in-big-data-world-day-9-of-21/): In yesterday’s blog post we learned what is HDFS. In this article we will take a quick look at the importance of the Relational Database in Big Data world. A Big Question? Here are a few questions I often received since the beginning of the Big Data Series – Does the relational database have no space in the story of the Big Data? Does relational database is no longer relevant as Big Data is evolving? Is relational database not capable to handle Big Data? Is it true that one no longer has to learn about relational data if Big Data is the... - [Big Data - Buzz Words: What is HDFS - Day 8 of 21](https://blog.sqlauthority.com/2013/10/10/big-data-buzz-words-what-is-hdfs-day-8-of-21/): In yesterday’s blog post we learned what is MapReduce. In this article we will take a quick look at one of the four most important buzz words which goes around Big Data – HDFS. What is HDFS ? HDFS stands for Hadoop Distributed File System and it is a primary storage system used by Hadoop. It provides high performance access to data across Hadoop clusters. It is usually deployed on low-cost commodity hardware. In commodity hardware deployment server failures are very common. Due to the same reason HDFS is built to have high fault tolerance. The data transfer rate between compute nodes... - [Big Data - Buzz Words: What is MapReduce - Day 7 of 21](https://blog.sqlauthority.com/2013/10/09/big-data-buzz-words-what-is-mapreduce-day-7-of-21/): In yesterday's blog post we learned what is Hadoop. In this article we will take a quick look at one of the four most important buzz words which goes around Big Data - MapReduce. - [SQLAuthority News - Mark the Date: October 16, 2013 - Introducing NuoDB Blackbirds: THE Distributed Database ](https://blog.sqlauthority.com/2013/10/08/sqlauthority-news-mark-the-date-october-16-2013-introducing-nuodb-blackbirds-the-distributed-database/): I am very excited to announce first on this blog about the release of NuoDB Blackbirds (NuoDB Release 2.0). NuoDB is my favorite application to work with data now a days. They are increasingly gaining market share as well as brining out new features with their every new release. I was very excited when I learned that NuoDB is releasing their flagship release of 2.0 on October 16, 2013. Interesting enough I will be in USA while this release happens and I will be watching it live during my day time. Even though if I had to stay up the entire... - [Big Data - Buzz Words: What is Hadoop - Day 6 of 21](https://blog.sqlauthority.com/2013/10/08/big-data-buzz-words-what-is-hadoop-day-6-of-21/): In yesterday’s blog post we learned what is NoSQL. In this article we will take a quick look at one of the four most important buzz words which goes around Big Data – Hadoop. What is Hadoop? Apache Hadoop is an open-source, free and Java based software framework offers a powerful distributed platform to store and manage Big Data. It is licensed under an Apache V2 license. It runs applications on large clusters of commodity hardware and it processes thousands of terabytes of data on thousands of the nodes. Hadoop is inspired from Google’s MapReduce and Google File System (GFS) papers.... - [Big Data - Buzz Words: What is NoSQL - Day 5 of 21](https://blog.sqlauthority.com/2013/10/07/big-data-buzz-words-what-is-nosql-day-5-of-21/): In yesterday’s blog post we explored the basic architecture of Big Data . In this article we will take a quick look at one of the four most important buzz words which goes around Big Data – NoSQL. What is NoSQL? NoSQL stands for Not Relational SQL or Not Only SQL. Lots of people think that NoSQL means there is No SQL, which is not true – they both sound same but the meaning is totally different. NoSQL does use SQL but it uses more than SQL to achieve its goal. As per Wikipedia’s NoSQL Database Definition – “A NoSQL database provides a mechanism... - [SQL - Business Intelligence: Derive Data or Information?](https://blog.sqlauthority.com/2013/10/06/sql-business-intelligence-derive-data-or-information/): We all know the value of information in our lives. Whether it's a personal decision or a business initiated one, people need it. But the question is: who is to make the distinction between data and information? We all come across a whole lot of data daily, that may be significant or not. We filter what's required and forget about the rest. Information is filtered and distilled data. Filtering and distillation can also alter its actual meaning and natural state. Therefore, in this blog we discover some ways to ensure that we're using business intelligence derived from the right information for making critical management decisions. - [SQL SERVER - Weekly Series - Memory Lane - #049](https://blog.sqlauthority.com/2013/10/05/sql-server-weekly-series-memory-lane-049/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Two Connections Related Global Variables Explained – @@CONNECTIONS and @@MAX_CONNECTIONS @@CONNECTIONS Returns the number of attempted connections, either successful or unsuccessful since SQL Server was last started. @@MAX_CONNECTIONS Returns the maximum number of simultaneous user connections allowed on an instance of SQL Server. The number... - [Big Data - Basics of Big Data Architecture - Day 4 of 21](https://blog.sqlauthority.com/2013/10/04/big-data-basics-of-big-data-architecture-day-4-of-21/): In yesterday’s blog post we understood how Big Data evolution happened. Today we will understand basics of the Big Data Architecture. Big Data Cycle Just like every other database related applications, bit data project have its development cycle. Though three Vs (link) for sure plays an important role in deciding the architecture of the Big Data projects. Just like every other project Big Data project also goes to similar phases of the data capturing, transforming, integrating, analyzing and building actionable reporting on the top of  the data. While the process looks almost same but due to the nature of the data the architecture is often totally different. Here are... - [Big Data - Evolution of Big Data - Day 3 of 21](https://blog.sqlauthority.com/2013/10/03/big-data-evolution-of-big-data-day-3-of-21/): In yesterday’s blog post we answered what is the Big Data. Today we will understand why and how the evolution of Big Data has happened. Though the answer is very simple, I would like to tell it in the form of a history lesson. Data in Flat File In earlier days data was stored in the flat file and there was no structure in the flat file.  If any data has to be retrieved from the flat file it was a project by itself. There was no possibility of retrieving the data efficiently and data integrity has been just a term discussed without any... - [Big Data - What is Big Data - 3 Vs of Big Data - Volume, Velocity and Variety - Day 2 of 21](https://blog.sqlauthority.com/2013/10/02/big-data-what-is-big-data-3-vs-of-big-data-volume-velocity-and-variety-day-2-of-21/): Data is forever. Think about it – it is indeed true. Are you using any application as it is which was built 10 years ago? Are you using any piece of hardware which was built 10 years ago? The answer is most certainly No. However, if I ask you – are you using any data which were captured 50 years ago, the answer is most certainly Yes. For example, look at the history of our nation. I am from India and we have documented history which goes back as over 1000s of year. Well, just look at our birthday data –... - [Big Data - Beginning Big Data - Day 1 of 21](https://blog.sqlauthority.com/2013/10/01/big-data-beginning-big-data-day-1-of-21/): What is Big Data? I want to learn Big Data. I have no clue where and how to start learning about it. Does Big Data really means data is big? What are the tools and software I need to know to learn Big Data? I often receive questions which I mentioned above. They are good questions and honestly when we search online, it is hard to find authoritative and authentic answers. I have been working with Big Data and NoSQL for a while and I have decided that I will attempt to discuss this subject over here in the blog. In the next 21... - [Big Data - Beginning Big Data Series Next Month in 21 Parts](https://blog.sqlauthority.com/2013/09/30/big-data-beginning-big-data-series-next-month-in-21-parts/): Big Data is the next big thing. There was a time when we used to talk in terms of MB and GB of the data. However, the industry is changing and we are now moving to a conversation where we discuss about data in Petabyte, Exabyte and Zettabyte. It seems that the world is now talking about increased Volume of the data. In simple world we all think that Big Data is nothing but plenty of volume. In reality Big Data is much more than just a huge volume of the data. When talking about the data we need to understand... - [SQL - Download FREE Book - Data Access for HighlyScalable Solutions: Using SQL, NoSQL, and Polyglot Persistence](https://blog.sqlauthority.com/2013/09/29/sql-download-free-book-data-access-for-highlyscalable-solutions-using-sql-nosql-and-polyglot-persistence/): Recently I was preparing for Big Data and I ended up on very interesting read for everybody. This is created by Microsoft and it is indeed a fantastic read as per my opinion. It took me some time to read this entire book but it was worth reading this as it tried to answer two of the very interesting questions related to muscle. Here is the abstract from the book: Organizations seeking to use a NoSQL database are therefore faced with a twofold challenge: • Which NoSQL database(s) best meet(s) the needs of the organization? • How does an organization integrate... - [SQL SERVER - Weekly Series - Memory Lane - #048](https://blog.sqlauthority.com/2013/09/28/sql-server-weekly-series-memory-lane-048/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Order of Result Set of SELECT Statement on Clustered Indexed Table When ORDER BY is Not Used Above theory is true in most of the cases. However SQL Server does not use that logic when returning the resultset. SQL Server always returns the resultset which it... - [SQL Contests - Solution - Identify the Database Celebrity](https://blog.sqlauthority.com/2013/09/27/sql-contests-solution-identify-the-database-celebrity/): Last week we were running contest Identify the Database Celebrity and we had received a fantastic response to the contest. - [SQL SERVER - Select Columns from Stored Procedure Resultset](https://blog.sqlauthority.com/2013/09/26/sql-server-select-columns-from-stored-procedure-resultset/): It is fun to go back to basics often. Here is the one classic question: “How to select columns from Stored Procedure Resultset?” Though Stored Procedure has been introduced many years ago, the question about retrieving columns from Stored Procedure is still very popular with beginners. Let us see the solution in quick steps. First we will create a sample stored procedure. CREATE PROCEDURE SampleSP AS SELECT 1 AS Col1, 2 AS Col2 UNION SELECT 11, 22 GO Now we will create a table where we will temporarily store the result set of stored procedures. We will be using INSERT INTO... - [SQL SERVER - How to Access the Previous Row and Next Row value in SELECT statement? - Part 4](https://blog.sqlauthority.com/2013/09/25/sql-server-how-to-access-the-previous-row-and-next-row-value-in-select-statement-part-4/): This is the fourth post in the series of finding previous row and next row value in SELECT Statement. Read all the blog post before continuing reading this blog post for complete idea. In the very first part I discussed that performance with the help of CTE is very poor and I encouraged users to use LEAD and LAG function of SQL Server 2012. My friend and SQL Server Expert Szymon Wojcik have written a fantastic post about this subject. I encourage everyone to read that blog post. He has demonstrated that with the help of numbers table, we can further improve the performance of the query. - [SQL SERVER - How to Access the Previous Row and Next Row value in SELECT statement? - Part 3](https://blog.sqlauthority.com/2013/09/24/sql-server-how-to-access-the-previous-row-and-next-row-value-in-select-statement-part-3/): Earlier I wrote a blog post SQL SERVER – How to Access the Previous Row and Next Row value in SELECT statement? and SQL SERVER – How to Access the Previous Row and Next Row value in SELECT statement? – Part 2. In part 2 of the blog post, I wanted to write a solution which works with SQL Server 2000. In the solution I removed CTE but I forgot the detail that I SQL Server 2000 does not support RowNumber function as well. Thanks to smart blog readers who caught the error and immediately pointed that out in the comment area. Thank you... - [SQL Contest - Hint for Identify the Database Celebrity](https://blog.sqlauthority.com/2013/09/23/sql-contest-hint-for-identify-the-database-celebrity/): Earlier week I have posted a SQL Contest about Identifing the Database Celebrity over here Identify the Database Celebrity – Win USD 100 Amazon Gift Card. We have got fantastic response to the blog post however, there are quite many readers have requested Hint to the contest. In the world of Internet and Google Search, it is honestly not difficult to find the answers of the quiz. However, it seems there are many friends who wants me to provide some hint. Here is the hint for Part 1: Identify Database Celebrity Write click on the image of the celebrity and save... - [SQL SERVER - How to Access the Previous Row and Next Row value in SELECT statement? - Part 2 ](https://blog.sqlauthority.com/2013/09/23/sql-server-how-to-access-the-previous-row-and-next-row-value-in-select-statement-part-2/): Earlier I wrote a blog post SQL SERVER – How to Access the Previous Row and Next Row value in SELECT statement?. Right after the blog post was published I received an email from SQL Server users who have no access to CTE and wanted me to help him out with the solution as well. Absolutely, Here is the solution for the anyone who is using SQL Server 2005 and does not use CTE. I strongly suggest you read my earlier blog post before continuing this blog post as they are related to each other. The question was that, how to... - [SQL SERVER - How to Access the Previous Row and Next Row value in SELECT statement?](https://blog.sqlauthority.com/2013/09/22/sql-server-how-to-access-the-previous-row-and-next-row-value-in-select-statement/): The first email I read this morning had only one statement in it, and it gave me an idea to write this blog post. “How to access Previous Row Value and Next Row Value in SELECT statement?” Very interesting question indeed. The matter of the fact, I have written about this in my earlier blog Introduction to LEAD and LAG – Analytic Functions Introduced in SQL Server 2012. Let us quickly understand it in it with the help of script. For example here is the column where we want to get access to the previous row and the next row in SELECT statement. USE... - [SQL SERVER - UDF, UPDATE and More - Memory Lane - #047](https://blog.sqlauthority.com/2013/09/21/sql-server-weekly-series-memory-lane-047/): This is the 47th episode of Memory Lane. Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. My favorite blog posts are about UDF and the difference between UPDATE and UPDATE (). Let me know which one of the following is your favorite article from memory lane. - [Developer - Best Practices for Daily Stand-Up or Daily Scrum - Rules and Regulations](https://blog.sqlauthority.com/2013/09/20/developer-best-practices-for-daily-stand-up-or-daily-scrum-rules-and-regulations/): Scrum is an Agile Software Development framework that helps teams complete projects efficiently while maintaining high quality. - [SQL Contest - Identify the Database Celebrity - Win USD 100 Amazon Gift Card](https://blog.sqlauthority.com/2013/09/19/sql-contest-identify-the-database-celebrity-win-usd-100-amazon-gift-card/): Regular readers of this blog are familiar with NuoDB and their generous offers for SQLAuthority.com readers. I was just talking to them earlier and together we have come up with a very interesting contest for all of us. This contest has two parts. Part 1 Identify Database Personality and in Part 2 You have to identify the size of the NuoDB installer. You have to answer both the questions to eligible to enter in the contest. Part 1: Identify Database Celebrity Personality 1 – He is known as the father of Relational Database Personality 2 – He has received the Turing Award “for... - [SQL SERVER - Five Puzzles around UNION - Participate in All Five](https://blog.sqlauthority.com/2013/09/18/sql-server-five-puzzles-around-union-participate-in-all-five/): Earlier this week, I ran five part series on UNION and it received very good response. Today I learned from Amazon that for a brief period of the time (to be precise for next 96 hours) they have reduced the price for price of Kindle Book of SQL Server Interview Questions and Answers. The price in India will be INR 99 (Instead of INR 199) and in USA will be USD 4.99 (Instead of USD 7.99). As I mentioned the prices are only valid for next 96 hours. I just decided to make it even more sweeter. If you participate in ALL... - [SQL SERVER - Detecting Potential Bottlenecks with the help of Profiler](https://blog.sqlauthority.com/2013/09/17/sql-server-detecting-potential-bottlenecks-with-the-help-of-profiler/): Probably, everyone who writes SQL code has used INSERT statement, which alongside SELECT, UPDATE and DELETE, is a part of a basic operations’ set for data manipulation. At the first sight syntax of the INSERT statement may seem very trivial , especially when inserting one record –  INSERT INTO … VALUES … . It’s not surprising, whereas in SQL Server 2005 basic syntax the VALUES keyword was applied only in the context of inserting records through using the INSERT statement. However, after the release of SQL Server 2008 the basic syntax of T-SQL was considerably expanded. Owing to this, usage of... - [SQL SERVER - Execute Operating System Commands in sqlcmd](https://blog.sqlauthority.com/2013/09/16/sql-server-execute-operating-system-commands-in-sqlcmd/): Here is the email received just the other day – “Hi Pinal, I have been using sqlcmd for a long time and I find it very comfortable. I am going to soon learn Powershell as well. However, here is one typical problem I face it every day and I want to check if you have any workaround. When I work with sqlcmd I always connect via command prompt and whenever I want to check something back in OS, I always have to exit from sqlcmd or I have to open different window. Is there any trick, which I can use to execute Operating System commands... - [Personal Technology - Who is Accessing your Google Account?](https://blog.sqlauthority.com/2013/09/15/personal-technology-who-is-accessing-your-google-account/): Do you know who is accessing your Google Account? Well, I did not know till yesterday. However, when I learn what apps are accessing my Google Accounts and particularly Gmail, I was really really scared. I receive lots of emails and just like all of us, some are private and some contains essential information about server setups. I have been using Google for many years and I have used their authentication at quite a many places. When I login to any site with the help of Google Account, I really do not see what is written there as in most cases... - [SQL SERVER - Memory Lane - Scrum, SQL Reboot and More - #046](https://blog.sqlauthority.com/2013/09/14/sql-server-weekly-series-memory-lane-046/): Let me know which one of the following is your favorite article from memory lane. My favorite article is about Scrum and SQL Reboot. - [SQL - Weekend Project - Watching Technically Seth Series - What is your plan for this weekend?](https://blog.sqlauthority.com/2013/09/13/sql-weekend-project-watching-technically-seth-series-what-is-your-plan-for-this-weekend/): “What is your plan for this weekend?” I was recently asked by my fellow colleague. I replied: “I have plan learn about Big Data and SQL from Technically Seth.” “Technically Seth!” He replied, “Never heard of him.” “Honestly even he has not heard of you.” I tried to look serious while making fun of him. “Come on tell me more.” “Dude!” (tried with fake Californian accent) I replied – “Even I am going to learn this weekend.” “But who is Seth?” He asks impatiently. I finally decided to stop annoying him and I replied “Seth is the CTO at NuoDB. He has nearly... - [SQL SERVER - Automatically Store Results of Query to File with sqlcmd](https://blog.sqlauthority.com/2013/09/12/sql-server-automatically-store-results-of-query-to-file-with-sqlcmd/): I receive lots of email everyday and I do answer almost every email I receive. However, I prefer to answer all the technical questions on my facebook page. With the help of social media it is very easy to reach out to multiple people with the same problem. Here is the recent question which I received on my facebook page. “How I automatically execute my T-SQL script and save output of the query (resultset) in a different file automatically? I do not want to use SSMS” Well, very interesting and simple question. It is very easy to direct the output of the query... - [SQL SERVER - Simple Puzzle with UNION - Part 5](https://blog.sqlauthority.com/2013/09/11/sql-server-simple-puzzle-with-union-part-5/): It seems that my yesterday’s Simple Puzzle with UNION intrigued many readers. Here is my fifth and final part of this Puzzles with UNION. I strongly suggest to read yesterday’s puzzle before continuing today’s puzzle as it is very much based on yesterday’s puzzle. SQL SERVER – Simple Puzzle with UNION SQL SERVER – Simple Puzzle with UNION – Part 2 SQL SERVER – Simple Puzzle with UNION – Part 3 SQL SERVER – Simple Puzzle with UNION – Part 4 Well, Now if you have solved yesterday’s puzzle today’s puzzle will be a bit easy for you. Here are two almost similar queries... - [SQL SERVER - Simple Puzzle with UNION - Part 4](https://blog.sqlauthority.com/2013/09/10/sql-server-simple-puzzle-with-union-part-4/): When I started to write Simple Puzzle with UNION last week, I had no clue this will be extremely popular blog post and will turn into a mini-series. Earlier I wrote three different blog posts on this subject and they are very well received. All the three blog posts which I wrote earlier are kind of back to basics. There are few readers who have requested to post something which make them think. Well for those who requested here is another fourth puzzle in the same series. SQL SERVER – Simple Puzzle with UNION SQL SERVER – Simple Puzzle with UNION –... - [SQL SERVER - Simple Puzzle with UNION - Part 3](https://blog.sqlauthority.com/2013/09/09/sql-server-simple-puzzle-with-union-part-3/): Earlier last week I had two simple puzzles related to UNION clause and the response to those puzzles have been amazing. Lots of email I have received that people wants me to post such basics puzzle again. Well here is one more puzzle which uses UNION and tests your basic knowledge. However, before you continue for today’s puzzle, I suggest you to read earlier two puzzles. If you have not participated in this earlier two puzzle. Please go ahead, there is no prize for winning besides satisfaction you can get when you get the basics correct. SQL SERVER – Simple Puzzle... - [SQL SERVER - Download SQL Server Developer Edition 2012 for USD 60](https://blog.sqlauthority.com/2013/09/08/sql-server-download-sql-server-developer-edition-2012-for-usd-60/): SQL Server professionals often send me email asking about where can they download the full version of SQL Server for their own development. Microsoft only provides evalution version of its enterprise software (full version). The evaluation version is bound by time and it expires when the time trial is over. This does not work out well when developers want to install the SQL Server into their local machine and try out various features of SQL Server. Additionally, many organizations when they are developing an application do not purchase a full version of the SQL Server. They often prefer to install a free version of... - [SQL SERVER - Weekly Series - Memory Lane - #045](https://blog.sqlauthority.com/2013/09/07/sql-server-weekly-series-memory-lane-045/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Here are three blog posts where I have written scripts to do various helpful task developers have to frequently. Search Stored Procedure Code – Search Stored Procedure Text Find Tables With Foreign Key Constraint in Database Find Tables With Primary Key Constraint in Database Introduction... - [SQL SERVER - Simple Puzzle with UNION - Part 2](https://blog.sqlauthority.com/2013/09/06/sql-server-simple-puzzle-with-union-part-2/): Yesterday we had very easy kind of Back to Basics Puzzle with UNION and I have received tremendous response to the simple puzzle. Even though there is no giveaway due to sheer interest in the subject, I have received many replies. Due to all the request, here is another back to the basic question with UNION again. Let us execute following three query one by one. Please make sure to enable Execution Plan in SQL Server Management Studio (SSMS). Query 1 SELECT 1 UNION ALL SELECT 2 The query above will return following result The query above will return following execution... - [SQL SERVER - Simple Puzzle with UNION](https://blog.sqlauthority.com/2013/09/05/sql-server-simple-puzzle-with-union/): It has been a long time since played a simple game on SQLAuthority.com. Let us play a simple game today. It is very simple puzzle but indeed a fun one. First let us execute following SQL. Query 1: SELECT 1 UNION ALL SELECT 1 ORDER BY 1 It will return following result: Now try to execute the following query and guess the result: Query 2: SELECT 2 UNION ALL SELECT 2 ORDER BY 2 When you execute the same it gives error that: Msg 108, Level 16, State 1, Line 4 The ORDER BY position number 2 is out of range... - [SQLAuthority News - 10 SQL in Sixty Days Video in 10 Days - Contest to Win 10 Cool Gifts](https://blog.sqlauthority.com/2013/09/04/sqlauthority-news-10-sql-in-sixty-days-video-in-10-days-contest-to-win-10-cool-gifts/): SQL in Sixty Seconds series has received a very high appreciation in the community. I have been posting every month 3 or 4 new videos in this series but the popularity of the SQL in Sixty Seconds is such that I am constantly receiving emails requesting new videos in this series. Recently I had teamed up with Rick Morelan (Joes 2 Pros fame) to build 10 videos in this SQL in Sixty Seconds series. We had a fantastic response to this video and we have crossed over 3200 subscribers and over 300,000 views in our YouTube Channel. If you have not... - [SQLAuthority News - Learn MySQL Indexing in 99 Minutes - MySQL Indexing for Performance - Video Course](https://blog.sqlauthority.com/2013/09/03/sqlauthority-news-learn-mysql-indexing-in-99-minutes-mysql-indexing-for-performance-video-course/): Every year around September 1st, I have decided to do something cool. This is because September 1st is my daughter Shaivi’s birthday. In previous years, I have released my new books as well new courses on this day.  This year I have done something similar for her. I like to work hard and dedicate my efforts to my family as they are the one who provides me unconditional support to do various activities for the community. Journey to Learn MySQL Indexing in 99 Minutes Indexes are considered to be sure solution for Performance tuning but it has two sides of the... - [SQLAuthority News - IT Security for Small Businesses](https://blog.sqlauthority.com/2013/09/02/sqlauthority-news-it-security-for-small-businesses/): Headlines today are filled with news of cyber attacks on some of the biggest corporate houses. Recently, media players such as the US newsletters. - [SQL SERVER - SQL Basics Video: SQL 2012 Certification Path - SQL in Sixty Seconds #065](https://blog.sqlauthority.com/2013/09/01/sql-server-sql-basics-video-sql-2012-certification-path-sql-in-sixty-seconds-065/): This is the 10th post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). The new breakdown of the Microsoft SQL 2012 certification model offers new incentives and rewards. The entry level certification in the 2012 model starts with one of three certification tests. In training hundreds of people over that last decade to get their Microsoft certification, to my surprise the biggest benefit you get is something else. The most common benefit my students tell me about... - [SQL SERVER - Weekly Series - Memory Lane - #044](https://blog.sqlauthority.com/2013/08/31/sql-server-weekly-series-memory-lane-044/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Use Always Outer Join Clause instead of (*= and =*) Instead of using LEFT OUTER JOIN clause he was using *= and similarly instead of using RIGHT OUTER JOIN clause he was using =*. Once I replaced did necessary modification, queries run just fine. Actual... - [SQL SERVER - SQL Basics Video: What Are Filegroups - SQL in Sixty Seconds #064](https://blog.sqlauthority.com/2013/08/30/sql-server-sql-basics-video-what-are-filegroups-sql-in-sixty-seconds-064/): This is the 9th post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). There are many advantages to using filegroups to manage the database workload. A filegroup may contain many datafiles, and the properties of all the datafiles can be managed simultaneously with a filegroup. There are many advantages to using filegroups to manage the database workload. A filegroup may contain many datafiles, and the properties of all the datafiles can be managed simultaneously with a filegroup. A... - [SQL SERVER - SQL Basics Video: Database Datafiles and Logfiles - SQL in Sixty Seconds #063](https://blog.sqlauthority.com/2013/08/29/sql-server-sql-basics-video-database-datafiles-and-logfiles-sql-in-sixty-seconds-063/): This is the 8th post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). We know that SQL Server stores its data much like other applications, in files which are saved to a persistent drive. But a distinguishing feature of SQL Server is its robust ability to keep track of things. The security and safety of the data and reliability of the system are SQL Server’s top priorities. Therefore, you can imagine that logging activity, which tracks every transaction made... - [SQL SERVER - Tips for SQL Query Optimization by Analyzing Query Plan](https://blog.sqlauthority.com/2013/08/28/sql-server-tips-for-sql-query-optimization-by-analyzing-query-plan/): Update: You can download dbForge Studio for SQL Server for free trial. One of the most exciting periods of my life relates to the maintenance and optimization of ERP system for one large manufacturing company. The problem was that the system was initially created for a limited range of tasks, which over time grew much bigger than expected. When multiple users simultaneously used the system, working in it was close to impossible. Increasing the operating capacity of a server could not completely solve the problem. So it was settled on revising current business-functionality and optimizing the most resource-consuming SQL queries. Before I go... - [SQL SERVER - SQL Basics Video: Database Careers - SQL in Sixty Seconds #062](https://blog.sqlauthority.com/2013/08/28/sql-server-sql-basics-video-database-careers-sql-in-sixty-seconds-062/): This is the 7th post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). The live system is the one that interacts with our customers and must stay up during all business hours which is often 24-7 in today’s global business world. These databases should be designed to collect the data in transactions that are needed to do business. This is often called the Online Transaction Processing database (or OLTP database). This OLTP system must respond immediately to user requests through... - [SQL Contest - Download NuoDB 1.2 to Win 20 Amazon Gift Cards](https://blog.sqlauthority.com/2013/08/27/sql-contest-download-nuodb-1-2-to-win-20-amazon-gift-cards/): NuoDb have earlier released NuoDB 1.2 and I have been using it for an entire month and my favorite feature is their support to Stored Procedure. I am a big fan of stored procedures and their advantages. Nod 1.2 has received great response in the industry and it has emerged as a serious competitor to many of the NewSQL databases. To celebrate the success and reception in the industry. The kind folks at NuoDB have announced 20 Amazon Gift Card (each of USD 10). To enter in the contest you just have to download NuoDB 1.2. Everybody who downloads NuoDB in... - [SQL SERVER - SQL Basics Video: SQL Code Generators - SQL in Sixty Seconds #061](https://blog.sqlauthority.com/2013/08/27/sql-server-sql-basics-video-sql-code-generators-sql-in-sixty-seconds-061/): This is the 6th post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). With the SQL Server Management Studio User Interface (SSMS UI), we can create a table by writing code in a query window, or use the “point and click” method. Point and click allows us to create a table without writing any code ourselves. It is much easier to send someone the code script to accomplish a task with SQL Server than it is to send step-by-step instructions on... - [SQL SERVER - SQL Basics Video: Using Management Studio - SQL in Sixty Seconds #060](https://blog.sqlauthority.com/2013/08/26/sql-server-sql-basics-video-using-management-studio-sql-in-sixty-seconds-060/): This is the 5th post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). By now you have written several queries. This means you have opened SQL Server Management Studio and then opened a query window to write your code. Once it came time to execute your code you can do so by pressing F5 or clicking the Execute button. Management Studio connects to your server and provides you handy tools to manage your databases. You even have the Object... - [SQL SERVER - SQL Basics Video: Code Comments - SQL in Sixty Seconds #059](https://blog.sqlauthority.com/2013/08/25/sql-server-sql-basics-video-code-comments-sql-in-sixty-seconds-059/): This is the 4th post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). The amount of effort to type the ‘–‘ signs for a single-line comment increases dramatically as the number of continuous lines to be commented out grows. What if we wanted to disable the last 300 lines of code? Typing ‘/*’ and ‘*/’ signs one time each, is definitely easier than typing the ‘–‘ sign 300 times to achieve the exact same result. Unlike the double... - [SQL SERVER - Weekly Series - Memory Lane - #043](https://blog.sqlauthority.com/2013/08/24/sql-server-weekly-series-memory-lane-043/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Find Last Day of Any Month – Current Previous Next Few questions are always popular. They keep on coming up through email, comments or from co-workers. Finding Last Day of Any Month is similar question. I have received it many times and I enjoy answering... - [SQL SERVER - SQL Basics Video: Joining Tables - SQL in Sixty Seconds #058](https://blog.sqlauthority.com/2013/08/23/sql-server-sql-basics-video-joining-tables-sql-in-sixty-seconds-058/): This is the 3rd post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). An INNER JOIN clause allows us to join multiple tables in a single query, although it requires a specific condition in order for it to work correctly. We must ensure that the INNER JOIN statement has two tables with at least one common or overlapping field. We already know the Employee and Location tables share a common field (LocationID). The relationship is between Employee.LocationID and Location.LocationID,... - [SQL SERVER - Basics Video: Running SQL Code - SQL in Sixty Seconds #057](https://blog.sqlauthority.com/2013/08/22/sql-server-basics-video-running-sql-code-sql-in-sixty-seconds-057/): This is the 2nd post out of my 10 post series of my videos on my 10th book - SQL Basics Video: Running SQL Code. Wach the video here - [SQL SERVER - SQL Basics Video: Data and Information in Businesses - SQL in Sixty Seconds #056](https://blog.sqlauthority.com/2013/08/21/sql-server-sql-basics-video-data-and-information-in-businesses-sql-in-sixty-seconds-056/): This is the 1st post out of my 10 post series of my videos on my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). Databases have been around since cavemen were drawing stick figures of their family’s on the rock walls. A database is a collection of related information. In the last 20 years what has improved greatly is we can get the information we need instantly from databases. For example if we ran a test promotion in Florida that we were thinking about running around the world we... - [SQL SERVER - Simple Trick to Backup Azure Database with SkyDrive](https://blog.sqlauthority.com/2013/08/20/sql-server-simple-trick-to-backup-azure-database-with-skydrive/): To ensure your SQL Server or Azure databases remain safe, you should backup your databases periodically. And it is important to store the backups in a reliable location. Microsoft SkyDrive currently offers 7GB free, Box offers 5GB free – both are reliable and it is simple to send your backups there. SQLBackupAndFTP in it’s latest version 9 added the option to backup to SkyDrive and Box ( in addition to local/network folder, NAS drive, FTP, Dropbox, Google Drive and Amazon S3). Just select the databases that you’d like to backup and select to store the backups in SkyDrive or Box. Below... - [SQL - Solution - Crossword Puzzle Based on Course Building Successful High Traffic Profitable Blog](https://blog.sqlauthority.com/2013/08/19/sql-solution-crossword-puzzle-based-on-course-building-successful-high-traffic-profitable-blog/): Earlier this month we were running a contest for solving the crossword based on my Blogging courses - Course 1, Course 2. Here are the details of the contest. The winner of the contest was to win Melting Clock (Do not confuse this as a dummy or not working clock. This looks like melting, but it always shows accurate time and it is perfectly balanced to hang off of any flat surface). Let us see Crossword Puzzle. - [Personal Technology - Chrome Missing Close Button - Chrome in Desktop Mode in Windows 8](https://blog.sqlauthority.com/2013/08/18/personal-technology-chrome-missing-close-button-chrome-in-desktop-mode-in-windows-8/): I have been using Windows 7 very comfortably for a long time. I love the product and I love the presence of my start menu. I use my laptop/computer for a causal use as well as for professional work. One of my primary job as an evangelist is to present technology sessions at various places. I use my mobile ultrabook for the all the presentations. This ultrabook is pretty new (11 months old) and it has Win 8 Operating System. Though I use my laptop as a tablet most of the time, I still use Desktop mode ALL the time for everything I do. I personally have not found a reason to switch to Windows 8 modern UI modes as I just love desktop mode. Let us learn what can we do when Chrome is missing close button. - [SQL SERVER - Online Index Operations, NEWID and More - Memory Lane #042](https://blog.sqlauthority.com/2013/08/17/sql-server-weekly-series-memory-lane-042/): This is the 42nd edition of Memory Lane weekly series. Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. My favorite article is about Online Index Operations and NEWID. Let me know which one of the following is your favorite article from memory lane. - [SQL SERVER - SQL Basics: SQL 2012 Certification Path - Day 10 of 10](https://blog.sqlauthority.com/2013/08/16/sql-server-sql-basics-sql-2012-certification-path-day-10-of-10/): This is the 10th post out of my 10 post series of my 10th book - SQL Basics. Today will show the importance of data and information. Let us see SQL 2012 Certification Path. You can get that in Paperback (USA) and Kindle (Worldwide). In training hundreds of people over that last decade to get their Microsoft certification, to my surprise the biggest benefit you get is something else. The most common benefit my students tell me about is that they get invited to far more job openings after getting certified than they did before. When the stack or resumes gets sorted down, they need a proven reason to keep yours on the short list. - [SQL SERVER - SQL Basics: What Are Filegroups - Day 9 of 10](https://blog.sqlauthority.com/2013/08/15/sql-server-sql-basics-what-are-filegroups-day-9-of-10/): This is the 9th post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). Using Filegroups There are many advantages to using filegroups to manage the database workload. A filegroup may contain many datafiles, and the properties of all the datafiles can be managed simultaneously with a filegroup. Primary and Secondary Filegroups A primary filegroup contains the primary datafile (mdf) and possibly secondary datafiles (ndf). All system tables are allocated to the primary filegroup. A secondary filegroup (also called a user-defined filegroup) contains secondary... - [SQL SERVER - SQL Basics: Database Datafiles and Logfiles - Day 8 of 10](https://blog.sqlauthority.com/2013/08/14/sql-server-sql-basics-database-datafiles-and-logfiles-day-8-of-10/): This is the 8th post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). Logging Data Changes In my experience, many students do not find the concept of datafile and logfile activity an intuitive one. So we will ease into it with an example that we have found helps students grasp this topic more quickly. But first we need a little explanation as to why SQL Server uses logfiles. We know that SQL Server stores its data much like other applications, in files... - [SQL SERVER - SQL Basics: Database Careers - Day 7 of 10](https://blog.sqlauthority.com/2013/08/13/sql-server-sql-basics-database-careers-day-7-of-10/): This is the 7th post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. - [SQL SERVER - SQL Basics: SQL Code Generators - Day 6 of 10](https://blog.sqlauthority.com/2013/08/12/sql-server-sql-basics-sql-code-generators-day-6-of-10/): This is the 6th post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). Almost everyone these days feels comfortable with using a “point and click” process to get things done with a computer. Only a small percentage of us have ventured into writing code or working with command line utilities to create the programs that perform these tasks. Whether we write code or use clicks, what really matters is getting the job done. Computers will respond to their instructions, regardless... - [SQL SERVER - SQL Basics: Using Management Studio - Day 5 of 10](https://blog.sqlauthority.com/2013/08/11/sql-server-sql-basics-using-management-studio-day-5-of-10/): This is the 5th post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). By now you have written several queries. This means you have opened SQL Server Management Studio and then opened a query window to write your code. Once it came time to execute your code you can do so by pressing F5 or clicking the Execute button. Management Studio connects to your server and provides you handy tools to manage your databases. You even have the Object Explorer to browse all... - [SQL SERVER - Weekly Series - Memory Lane - #041](https://blog.sqlauthority.com/2013/08/10/sql-server-weekly-series-memory-lane-041/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Stop SQL Server Immediately Using T-SQL How would you stop SQL Server using T-SQL – this is a simple script demonstrating the same. List Tables in Database Without Primary Key A simple to the script blog where user can find all the tables where there... - [SQL SERVER - SQL Basics: Code Comments - Day 4 of 10](https://blog.sqlauthority.com/2013/08/09/sql-server-sql-basics-code-comments-day-4-of-10/): This is the 4th post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). Code Comments Old classic movies utter this famous phrase “Gentlemen, this is off the record”. In the movies this is used when talking to the press and letting them know a certain comment or two will be said, however; it is not meant for publication in the media. Sometimes, we want to use words or phrases within a query window that we want SQL Server to ignore when... - [SQL - NuoDB Releases 1.2 has Several SQL Enhancements](https://blog.sqlauthority.com/2013/08/08/sql-nuodb-releases-1-2-has-several-sql-enhancements/): I have been following NuoDB for quite a while and the matter of the fact, I am very much impressed with the product. What impresses me that release cycle. Every 2-3 month they add some really new features to their products and make it more mature. When I was using NuoDB 1.0, I was thinking that they have finished the development of the product as it was very stable release and had pretty much most of the features which I was looking for. However, when I see the latest release of NuoDB 1.2, I can clearly see that they have indeed... - [SQL SERVER - SQL Basics: Joining Tables - Day 3 of 10](https://blog.sqlauthority.com/2013/08/08/sql-server-sql-basics-joining-tables-day-3-of-10/): This is the 3rd post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). Relational Data When was the last time we received a vague answer to a question? For most of us, it happens every day. Let’s say we asked someone where they worked. We are anticipating a response that may include a city name or address, except the answer we actually get is, “I work at headquarters”. While this is an accurate answer, it is not the detailed answer... - [SQL SERVER - SQL Basics: Running SQL Code - Day 2 of 10](https://blog.sqlauthority.com/2013/08/07/sql-server-sql-basics-running-sql-code-day-2-of-10/): This is the 2nd post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. You can get that in Paperback (USA) and Kindle (Worldwide). Running SQL Code When we run SQL code, it is often a series of SQL statements created by someone else. Still we are often tasked with adding to the code to customize it for our system or testing the code and making suggestions. For this reason the SQL Admin must know basic SQL coding skills. This section will focus on the most common types of queries. If being... - [SQL SERVER - SQL Basics: Data and Information in Businesses - Day 1 of 10](https://blog.sqlauthority.com/2013/08/06/sql-server-sql-basics-data-and-information-in-businesses-day-1-of-10/): This is the 1st post out of my 10 post series of my 10th book – SQL Basics. Today will show the importance of data and information. - [SQLAuthority News - Releasing Author's 10th Book - SQL Basics Joes 2 Pros: A Getting Started Guide to Administering and Developing SQL Server Databases for Beginners](https://blog.sqlauthority.com/2013/08/05/sqlauthority-news-releasing-authors-10th-book-sql-basics-joes-2-pros-a-getting-started-guide-to-administering-and-developing-sql-server-databases-for-beginners/): I authored 10 books so far and my 10th book is released today. You can get that in Paperback (USA) and Kindle (Worldwide) . Idea of the Book I have been blogging for over 6 years now and have been receiving over 1000s email every day since last year. I have been keeping every day two hours to just answer emails. I have been building a small wiki for myself where I keep on writing down all the questions which are asked more than 10 times. In recent times that wiki has literally quite big. The interesting part was that I was getting almost same questions... - [SQL SERVER - Understanding Restrict Access to Restricted_User Database Property](https://blog.sqlauthority.com/2013/08/04/sql-server-understanding-restrict-access-to-restricted_user-database-property/): Recently I received an empty email with the subject “Question for you”. I was bit surprised as the email had no content at all. It was absolutely empty. I wrote back to user asking if he has missed the text in the email. He responded that there was an image already attached to the email and I needed to “enable display image in the email.” When I did the same, I found following image and the question from a user was inbuilt the image as well. The question was in database property what does Restrict Access = Restricted_User means? It is... - [SQL SERVER - Weekly Series - Memory Lane - #040](https://blog.sqlauthority.com/2013/08/03/sql-server-weekly-series-memory-lane-040/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 Complete Series of SQL Server Interview Questions and Answers Data Warehousing Interview Questions and Answers – Introduction Data Warehousing Interview Questions and Answers – Part 1 Data Warehousing Interview Questions and Answers – Part 2 Data Warehousing Interview Questions and Answers – Part 3 Data... - [SQL SERVER - Disk Space Monitoring - Detecting Low Disk Space on Server](https://blog.sqlauthority.com/2013/08/02/sql-server-disk-space-monitoring-detecting-low-disk-space-on-server/): A very common question I often receive is how to detect if the disk space is running low on SQL Server. - [SQL - Crossword Puzzle Based on Course Building Successful High Traffic Profitable Blog](https://blog.sqlauthority.com/2013/08/01/sql-crossword-puzzle-based-on-course-building-successful-high-traffic-profitable-blog/): Do you like Crossword Puzzles? I personally love it. Everytime I open the newspaper, I try to resolve at least one crossword or sudoku. It is just fun to tease a brain little and stretch its limits. Regular readers of the blogs are aware that I have recently published two courses on how to build successful high traffic profitable blog. - [SQL SERVER - How to Compare the Schema of Two Databases with Schema Compare](https://blog.sqlauthority.com/2013/07/31/sql-server-how-to-compare-the-schema-of-two-databases-with-schema-compare/): Earlier I wrote about An Efficiency Tool to Compare and Synchronize SQL Server Databases and it was very much well received. Since the blog post I have received quite a many question that just like data how we can also compare schema and synchronize it. If you think about comparing the schema manually, it is almost impossible to do so. Table Schema has been just one of the concept but if you really want the all the schema of the database (triggers, views, stored procedure and everything else) it is just impossible task. Let us learn about Schema Compare. - [SQL - Download NuoDB and Qualify for FREE Amazon Gift Cards](https://blog.sqlauthority.com/2013/07/30/sql-download-nuodb-and-qualify-for-free-amazon-gift-cards/): July has been a fantastic month and Team NuoDB has really appreciated the active participation of the SQLAuthority.com active reader base. Earlier we had launched two contests with NuoDB and both of them are very much appreciated by readers. There are constant demands of more contests and team NuoDB is very much excited to support more contests. Here are the details to constests ran earlier: What ACID stands in the Database? – Contest to Win 24 Amazon Gift Cards and Joes 2 Pros 2012 Kit What is the latest Version of NuoDB? – A Quick Contest to Get Amazon Gift Cards Based on the earlier... - [SQL - Building a High Traffic, Profitable Blog - A Unique Gift on Author's Birthday](https://blog.sqlauthority.com/2013/07/30/sql-building-a-high-traffic-profitable-blog-a-unique-gift-on-authors-birthday/): Every July 30th, I like to do something new. It is my birthday and I like to give gifts to everyone this day. Last year, at this time I had written an article A Year Older and 3 SQL Server Books and 3 Video Courses – 33. I had written a total of 3 books by that time and had published total of  3 Pluralsight courses. When I look back the year, I feel that I gave my best to last year. Sine Last July 30th, I have written 6 more books and 5 more video courses. The total is now 9... - [SQL SERVER - Example of Performance Tuning for Advanced Users with DB Optimizer](https://blog.sqlauthority.com/2013/07/29/sql-server-example-of-performance-tuning-for-advanced-users-with-db-optimizer/): Performance tuning is such a subject that everyone wants to master it. In beginning everybody is at a novice level and spend lots of time learning how to master the art of performance tuning. However, as we progress further the tuning of the system keeps on getting very difficult. I have understood in my early career there should be no need of ego in the technology field. There are always better solutions and better ideas out there and we should not resist them. Instead of resisting the change and new wave I personally adopt it. Let us learn about DB Optimizer. - [SQLAuthority News - 5 days of SQL Server Reporting Service (SSRS) Summary](https://blog.sqlauthority.com/2013/07/28/sqlauthority-news-5-days-of-sql-server-reporting-service-ssrs-summary/): Earlier this week, I wrote five days series on SQL Server Reporting Service. The series is based on the book Beginning SSRS by Kathi Kellenberger. Supporting files are available with a free download from thewww.Joes2Pros.com web site. I just completed reading the book – it is a fantastic book and I am loving every bit of it. I new SSRS and I also knew how it is working however, I did not know was fine details of how I can get maximum out of the SSRS subject. This book has personally enabled me with the knowledge that I was missing in my knowledge back. Here... - [SQL SERVER - Weekly Series - Memory Lane - #039](https://blog.sqlauthority.com/2013/07/27/sql-server-weekly-series-memory-lane-039/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 FQL – Facebook Query Language Facebook list following advantages of FQL: Condensed XML reduces bandwidth and parsing costs. More complex requests can reduce the number of requests necessary. Provides a single consistent, unified interface for all of your data. It’s fun! UDF – Get the... - [SQL SERVER - How to an Add Identity Column to Table in SQL Server](https://blog.sqlauthority.com/2013/07/27/sql-server-how-to-an-add-identity-column-to-table-in-sql-server/): Here is the question I received on SQLAuthority Fan Page. “How do I add an identity column to Table in SQL Server? “ Sometime the questions are very very simple but the answer is not easy to find. Scenario 1: If you are table does not have identity column, you can simply add the identity column by executing following script: ALTER TABLE MyTable ADD ID INT IDENTITY(1,1) NOT NULL Scenario 2: If your table already has a column which you want to convert to identity column, you can’t do that directly. There is a workaround for the same which I have... - [SQL SERVER - Data Sources and Data Sets in Reporting Services SSRS](https://blog.sqlauthority.com/2013/07/26/sql-server-data-sources-and-data-sets-in-reporting-services-ssrs/): This example is from the Beginning SSRS by Kathi Kellenberger. Supporting files are available with a free download from the www.Joes2Pros.com web site. - [SQL - What is the latest Version of NuoDB? - A Quick Contest to Get Amazon Gift Cards](https://blog.sqlauthority.com/2013/07/26/sql-what-is-the-latest-version-of-nuodb-a-quick-contest-to-get-amazon-gift-cards/): We had a great contest earlier last week – What ACID stands in the Database? – Contest to Win 24 Amazon Gift Cards and Joes 2 Pros 2012 Kit. It has received quite a few responses. Just like any other contest, not everyone was winner. The kind folks at NuoDB decided to give another chance to everyone who have not won in the last contest. This means if you have missed to take part in the earlier contest or if you have taken part and not won, you still have one more chance to win Amazon Gift Card. Here is the quick... - [SQL SERVER - Create a Very First Report with the Report Wizard](https://blog.sqlauthority.com/2013/07/25/sql-server-create-a-very-first-report-with-the-report-wizard/): This example is from the Beginning SSRS by Kathi Kellenberger. Supporting files are available with a free download from the www.Joes2Pros.com web site. What is the report Wizard? In today’s world automation is all around you. Henry Ford began building his Model T automobiles on a moving assembly line a century ago and changed the world. The moving assembly line allowed Ford to build identical cars quickly and cheaply. Henry Ford said in his autobiography “Any customer can have a car painted any color that he wants so long as it is black.” Today you can buy a car straight from the factory... - [SQL SERVER - Installing SQL Server Data Tools and SSRS](https://blog.sqlauthority.com/2013/07/24/sql-server-installing-sql-server-data-tools-and-ssrs/): This example is from the Beginning SSRS by Kathi Kellenberger. Supporting files are available with a free download from the www.Joes2Pros.com web site. If you have installed SQL Server, but are missing the Data Tools or Reporting Services Double-click the SQL Server 2012 installation media. Click the Installation link on the left to view the Installation options. Click the top link New SQL Server stand-alone installation or add features to an existing installation. Follow the SQL Server Setup wizard until you get to the Installation Type screen. At that screen, select Add features to an existing instance of SQL Server 2012. Click Next to move to the Feature Selection page. Select Reporting Services –... - [SQL SERVER - Determine if SSRS 2012 is Installed on your SQL Server](https://blog.sqlauthority.com/2013/07/23/sql-server-determine-if-ssrs-2012-is-installed-on-your-sql-server/): This example is from the Beginning SSRS by Kathi Kellenberger. Let us learn about SSRS. Determine if SSRS 2012 is Installed on your SQL Server - [SQL SERVER - What is SSRS and Why SSRS is asked for in many Job Opening?](https://blog.sqlauthority.com/2013/07/22/sql-server-what-is-ssrs-and-why-ssrs-is-asked-for-in-many-job-opening/): This example is from the Beginning SSRS by Kathi Kellenberger. Supporting files are available with a free download from the www.Joes2Pros.com web site. This will be a 5 day blog post in getting started with SSRS. Today will show the importance of SSRS in the business. Why is SSRS asked for in so many job openings? If you talk to an SSRS expert it’s very clear to them exactly why companies really need this invention and how it saves time and adds business value. You don’t have to be an SSRS expert to know its value or to start using it. For example you... - [SQL SERVER - What is the Maximum Relational Database Size Supported by Single Instance?](https://blog.sqlauthority.com/2013/07/21/sql-server-what-is-the-maximum-relational-database-size-supported-by-single-instance/): I often get asked following question? “How much data SQL Server can handle?” Every single time when I get this question – I ask back following question – “How much data your storage system can handle?” The reason I ask this question back is because in reality for enterprise systems the limitation of storage is no more an issue. The Matter of the fact most of the database is now a days limited by the size of the storage system. SQL Server is enterprise system and it is very mature product. Even though if you still want to know what is... - [SQL SERVER - Weekly Series - Memory Lane - #038](https://blog.sqlauthority.com/2013/07/20/sql-server-weekly-series-memory-lane-038/): Here is the list of selected articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2007 CASE Statement in ORDER BY Clause – ORDER BY using Variable This article is as per request from the Application Development Team Leader of my company. His team encountered code where the application was preparing string for ORDER BY clause of the SELECT statement. Application... - [SQL SERVER - Database in RESTORING State for Long Time](https://blog.sqlauthority.com/2013/07/19/sql-server-database-in-restoring-state-for-long-time/): A very interesting question I received the other day. “Our database has been in restoring stage for a long time. We have already restored all the necessary files there. After restoring the files we are expecting that  the database will be in operational mode, however, it is continuously in the restoring mode. Any suggestion?” The question is very common. I sent user follow up emails to understand what is actually going on with the user. I realized after restoring their bak files and log files their database was in the restoring state because they had not restored the latest log file with... - [SQL SERVER - Auditing and Profiling Database Made Easy with ApexSQL Trigger and ApexSQL Audit](https://blog.sqlauthority.com/2013/07/18/sql-server-auditing-and-profiling-database-made-easy-with-apexsql-trigger-and-apexsql-audit/): Do you like auditing your database, or can you think of about a million other things you’d rather do? Unfortunately, auditing is incredibly important. As with tax audits, it is important to audit databases to ensure they are following all the rules, but they are also important for troubleshooting and security. Let us learn about Profiling Database. - [SQL SERVER - Delay Command in SQL Server - SQL in Sixty Seconds #055](https://blog.sqlauthority.com/2013/07/17/sql-server-delay-command-in-sql-server-sql-in-sixty-seconds-055/): Have you ever needed WAIT or DELAY function in SQL Server?  Well, I personally have never needed it but I see lots of people asking for the same. It seems the need of the function is when developers are working with asynchronous applications or programs. When they are working with an application where user have to wait for a while for another application to complete the processing. If you are programming language developer, it is very easy for you to make the application wait for command however, in SQL I personally have rarely used this feature.  However, I have seen lots... - [SQL - Difference Between INNER JOIN and JOIN](https://blog.sqlauthority.com/2013/07/16/sql-difference-between-inner-join-and-join/): Here is the follow up question to my earlier question SQL – Difference between != and Operator used for NOT EQUAL TO Operation. There was a pretty good discussion about this subject earlier and lots of people participated with their opinion. Though the answer was very simple but the conversation was indeed delightful and was indeed very informative. In this blog post I have another following up question to all of you. What is the difference between INNER JOIN and JOIN? - [SQL SERVER - Free eBook Download - EPUB, MOBI, PDF Format](https://blog.sqlauthority.com/2012/06/15/sql-server-free-ebook-download-epub-mobi-pdf-format/): Microsoft has released recently free eBooks on various Microsoft Technology. The best part is that all these books are available in ePub, Mobi and PDF. You can download them to your local machine or eBook reader and read them. This is a great start as many important subjects are now covered and converted into an eBook. I personally read through a few of the books and found they are very comprehensive and and detailed. The goal is not to cover complete technology in a single book but rather pick a single topic and discuss it in detail. The source of the... - [SQL SERVER - Solution of Puzzle - Swap Value of Column Without Case Statement](https://blog.sqlauthority.com/2012/06/14/sql-server-solution-of-puzzle-swap-value-of-column-without-case-statement/): Earlier this week I asked a question where I asked how to Swap Values of the column without using CASE Statement. Read here: SQL SERVER – A Puzzle – Swap Value of Column Without Case Statement. I have proposed 3 different solutions in the blog posts itself. I had requested the help of the community to come up with alternate solutions and honestly I am stunned and amazed by the qualified entries. I will be not able to cover every single solution which is posted as a comment, however, I would like to for sure cover few interesting entries. However, I am selecting... - [SQL SERVER - Video - Beginning Performance Tuning with SQL Server Execution Plan](https://blog.sqlauthority.com/2012/06/13/sql-server-video-beginning-performance-tuning-with-sql-server-execution-plan/): Traveling can be most interesting or most exhausting experience. However, traveling is always the most enlightening experience one can have. While going to long journey one has to prepare a lot of things. Pack necessary travel gears, clothes and medicines. However, the most essential part of travel is the journey to the destination. There are many variations one prefer but the ultimate goal is to have a delightful experience during the journey. Let us learn about Performance Tuning with SQL Server Execution Plan. - [SQL SERVER - A Quick Look at Logging and Ideas around Logging](https://blog.sqlauthority.com/2012/06/12/sql-server-a-quick-look-at-logging-and-ideas-around-logging/): This blog post is written in response to the T-SQL Tuesday post on Logging. When someone talks about logging, personally I get lots of ideas about it. I have seen logging as a very generic term. Let me ask you this question first before I continue writing about logging. What is the first thing comes to your mind when you hear word “Logging”? Now ask the same question to the guy standing next to you. I am pretty confident that you will get  a different answer from different people. I decided to do this activity and asked 5 SQL Server person... - [SQL SERVER - Developer Training Resources and Summary Roundup](https://blog.sqlauthority.com/2012/06/11/sql-server-developer-training-resources-and-summary-roundup/): It is always pleasure for any author when other renowned authors in the industry write about you. Earlier I wrote a five part blog series on Developer Training and I have received a phenomenal response to the series. I have received plenty of comments, questions and feedback. I thought it would be nice to sum up the whole series as well answer a few of the questions received. Quick Recap Developer Training – Importance and Significance – Part 1 In this part we discussed the importance of training in the real world. The most important and valuable resource any company is its employee.... - [SQL SERVER - Finding Size of a Columnstore Index Using DMVs](https://blog.sqlauthority.com/2012/06/10/sql-server-finding-size-of-a-columnstore-index-using-dmvs/): Columnstore Index is one of my favorite enhancement in SQL Server 2012. A columnstore index stores each column in a separate set of disk pages, rather than storing multiple rows per page as data traditionally has been stored. In case of the row store indexes multiple pages will contain multiple rows of the columns spanning across multiple pages. Whereas in case of column store indexes multiple pages will contain (multiple) single columns.  Columnstore Indexes are compressed by default and occupies much lesser space than regular row store index by default. One of the very common question I often see is need of the... - [SQL SERVER - Service Broker and CAP_CPU_PERCENT - Limiting SQL Server Instances to CPU Usage](https://blog.sqlauthority.com/2012/06/09/sql-server-service-broker-and-cap_cpu_percent-limiting-sql-server-instances-to-cpu-usage/): I have mentioned several times on this blog that the best part of blogging is the questions I receive from readers. They are often very interesting. The questions from readers give me a good idea what other readers might be thinking as well. After reading my earlier article Simple Example to Configure Resource Governor – Introduction to Resource Governor – I received an email from a reader and we exchanged a few emails. After exchanging emails we both figured out what is going on. It was indeed interesting and reader suggested to that I should blog about it.  I asked for... - [SQL SERVER - A Puzzle - Swap Value of Column Without Case Statement](https://blog.sqlauthority.com/2012/06/08/sql-server-a-puzzle-swap-value-of-column-without-case-statement/): For the last few weeks, I have been doing Friday Puzzles and I am really loving it. Yesterday I received a very interesting question by Navneet Chaurasia on Facebook Page. He was asked this question in one of the interview questions for job. Please read the original thread for a complete idea of the conversation. I am presenting the same question here. Puzzle Let us assume there is a single column in the table called Gender. The challenge is to write a single update statement which will flip or swap the value in the column. For example if the value in the... - [SQL SERVER - Load Generator - Free Tool](https://blog.sqlauthority.com/2012/06/07/sql-server-load-generator-free-tool-from-codeplex/): One of the most common questions I receive is if there any tool available to generate load on SQL Server. Absolutely there is a fabulous free tool available to generate load on SQL Server. - [SQL SERVER - Tricks to Replace SELECT * with Column Names - SQL in Sixty Seconds #017 - Video](https://blog.sqlauthority.com/2012/06/06/sql-server-tricks-to-replace-select-with-column-names-sql-in-sixty-seconds-017-video/): You might have heard many times that one should not use SELECT * as there are many disadvantages to the usage of the SELECT *. I also believe that there are always rare occasion when we need every single column of the query. In most of the cases, we only need a few columns of the query and we should retrieve only those columns. SELECT * has many disadvantages. Let me list a few and remaining you can add as a comment.  Retrieves unnecessary columns and increases network traffic When a new columns are added views needs to be refreshed manually... - [SQL SERVER - Fix: Error: 10920 Cannot drop user-defined function. It is being used as a resource governor classifier](https://blog.sqlauthority.com/2012/06/05/sql-server-fix-error-10920-cannot-drop-user-defined-function-it-is-being-used-as-a-resource-governor-classifier/): If you have not read my SQL SERVER – Simple Example to Configure Resource Governor – Introduction to Resource Governor yesterday’s detailed primer on Resource Governor, I suggest you go ahead and read it before continuing this article. After reading the article the very first email I received was as follows: “Pinal, I configured resource governor on my development server and it worked fine with tests I ran. After doing some tests, I decided to remove the resource governor and as a first step I disabled it however, I was not able to drop the classification function during the process of the clean... - [SQL SERVER - Simple Example to Configure Resource Governor - Introduction to Resource Governor](https://blog.sqlauthority.com/2012/06/04/sql-server-simple-example-to-configure-resource-governor-introduction-to-resource-governor/): Let us jump right away with question and answer mode. What is resource governor? Resource Governor is a feature which can manage SQL Server Workload and System Resource Consumption. We can limit the amount of CPU and memory consumption by limiting /governing /throttling on the SQL Server. - [SQL SERVER - Fix: Error 147 An aggregate may not appear in the WHERE clause](https://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/): Everybody was a beginner once and I always like to get involved in the questions from beginners. There is a big difference between the question for beginner and question from advanced user. I have noticed that if an advanced user gets an error, they usually need just a small hint to resolve the problem. Let us learn about how to fix Error 147 in this blog post. - [SQL SERVER - A Puzzle Part 4 - Fun with SEQUENCE in SQL Server 2012 - Guess the Next Value](https://blog.sqlauthority.com/2012/06/02/sql-server-a-puzzle-part-4-fun-with-sequence-in-sql-server-2012-guess-the-next-value/): It seems like every weekend I get a new puzzle in my mind. Before continuing I suggest you read my previous posts here where I have shared earlier puzzles. A Puzzle – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value  A Puzzle Part 2 – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value A Puzzle Part 3 – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value After reading above three posts, I am very confident that you all will be ready for the next set of puzzles now. First execute the script which... - [Developer Training - A Conclusive Summary- Part 5](https://blog.sqlauthority.com/2012/06/01/developer-training-a-conclusive-summary-part-5/): We have now reached the end of our series about developer training. I hope you have come away thinking that training is the best way to advance in your company and that you are looking for training opportunities right now. If you’re still not convinced here are a few things to keep in mind: Training benefits the employer and the employee. A well trained employee is a happy employee, and a happy employee is more efficient and productive. Training an employee might be expensive, but it is less expensive than hiring a new person. - [Developer Training - Various Options for Maximum Benefit - Part 4](https://blog.sqlauthority.com/2012/05/31/developer-training-various-options-for-maximum-benefit-part-4/): If you have been reading this series, by now you are aware of all the pros and cons that can come along with training. We’ve asked and answered hard questions, and investigated them “whys” and “hows” of training. Now it is time to talk about all the different kinds of developer training that are out there! - [Developer Training - Difficult Questions and Alternative Perspective - Part 3](https://blog.sqlauthority.com/2012/05/30/developer-training-difficult-questions-and-alternative-perspective-part-3/): Congratulations! You are now a fully trained developer! You spent hours in a classroom, watching webinars, and reading materials. You are now more educated and more prepared than ever before. Now what? Let us learn more about Developer Training - Difficult Questions and Alternative Perspective. - [Developer Training - Employee Morals and Ethics - Part 2](https://blog.sqlauthority.com/2012/05/29/developer-training-employee-morals-and-ethics-part-2/): If you have been reading this series of posts about Developer Training, you can probably determine where my mind lies in the matter – firmly “pro.” There are many reasons to think that training is an excellent idea for the company. In the end, it may seem like the company gets all the benefits and the employee has just wasted a few hours in a dark, stuffy room. However, don’t let yourself be fooled, this is not the case! - [Developer Training - Importance and Significance - Part 1](https://blog.sqlauthority.com/2012/05/28/developer-training-importance-and-significance-part-1/): Can anyone remember their final day of schooling? This is probably a silly question because – of course you can! Many people mark this as the most exciting, happiest day of their life. It marks the end of testing, the end of following rules set by teachers, and the beginning of finally being able to earn money and work in your chosen field. Let us read more about Developer Training Importance and Significance. - [SQL SERVER - A Puzzle Part 3 - Fun with SEQUENCE in SQL Server 2012 - Guess the Next Value](https://blog.sqlauthority.com/2012/05/27/sql-server-a-puzzle-part-3-fun-with-sequence-in-sql-server-2012-guess-the-next-value/): Before continuing this blog post – please read the two part of the SEQUENCE Puzzle here A Puzzle – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value and A Puzzle Part 2 – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value Where we played a simple guessing game about predicting next value. The answers the of puzzle is shared on the blog posts as a comment. Now here is the next puzzle based on yesterday’s puzzle. I recently shared the puzzle of the blog post on local user group and it was appreciated by attendees. First execute the script which... - [SQL SERVER - A Puzzle Part 2 - Fun with SEQUENCE in SQL Server 2012 - Guess the Next Value](https://blog.sqlauthority.com/2012/05/26/sql-server-a-puzzle-part-2-fun-with-sequence-in-sql-server-2012-guess-the-next-value/): Before continuing this blog post – please read the first part of the SEQUENCE Puzzle here A Puzzle – Fun with SEQUENCE in SQL Server 2012 – Guess the Next Value. Where we played a simple guessing game about predicting next value. The answers the of puzzle is shared on the blog posts as a comment. Now here is the next puzzle based on yesterday’s puzzle. First execute the script which I have written here. The only difference between yesterday’s script is that I have removed the MINVALUE as 1 from the syntax. Now guess what will be the next value as requested... - [SQL SERVER - A Puzzle - Fun with SEQUENCE in SQL Server 2012 - Guess the Next Value](https://blog.sqlauthority.com/2012/05/25/sql-server-a-puzzle-fun-with-sequence-in-sql-server-2012-guess-the-next-value/): Yesterday my friend Vinod Kumar wrote excellent blog post on SQL Server 2012: Using SEQUENCE. I personally enjoyed reading the content on this subject. While I was reading the blog post, I thought of very simple new puzzle. Let us see if we can try to solve it and learn a bit more about Sequence. Here is the script, which I executed. USE TempDB GO -- Create sequence CREATE SEQUENCE dbo.SequenceID AS BIGINT START WITH 3 INCREMENT BY 1 MINVALUE 1 MAXVALUE 5 CYCLE NO CACHE; GO -- Following will return 3 SELECT next value FOR dbo.SequenceID; -- Following will return 4 SELECT next... - [SQL SERVER - A Puzzle - Fun with NULL - Fix Error 8117](https://blog.sqlauthority.com/2012/05/24/sql-server-a-puzzle-fun-with-null-fix-error-8117/): During my 8 years of career, I have been involved in many interviews. Quite often, I act as the interview. If I am the interviewer, I ask many questions - from easy questions to difficult ones. When I am the interviewee, I frequently get an opportunity to ask the interviewer some questions back. Regardless of the my capacity in attending the interview, I always make it a point to ask the interviewer at least one question. Let's learn how to fix Error 8117. - [SQL SERVER - Standard Reports from SQL Server Management Studio - SQL in Sixty Seconds #016 - Video](https://blog.sqlauthority.com/2012/05/23/sql-server-standard-reports-from-sql-server-management-studio-sql-in-sixty-seconds-016-video/): SQL Server management Studio 2012 is wonderful tool and has many different features. Many times, an average user does not use them as they are not aware about these features. Today, we will learn one such feature. SSMS comes with many inbuilt performance and activity reports, but we do not use it to the full potential. Connect to SQL Server Node >> Right Click on it >> Go to Reports >> Click on Standard Reports >> Pick Any Report. [youtube=http://www.youtube.com/watch?v=ORtv29rxXJI] Please note that some of the reports can be IO intensive and not suggested to run during business hours! More on... - [SQL SERVER - SmallDateTime and Precision - A Continuous Confusion](https://blog.sqlauthority.com/2012/05/22/sql-server-smalldatetime-and-precision-a-continuous-confusion/): Some kinds of confusion never go away. Here is one of the ancient confusing things in SQL. The precision of the SmallDateTime is one concept that confuses a lot of people, proven by the many messages I receive everyday relating to this subject. Let me start with the question: What is the precision of the SMALLDATETIME datatypes? What is your answer? Write it down on your notepad. Now if you do not want to continue reading the blog post, head to my previous blog post over here: SQL SERVER – Precision of SMALLDATETIME. A Social Media Question Since the increase of social media conversations,... - [SQL SERVER - Renaming Index - Index Naming Conventions](https://blog.sqlauthority.com/2012/05/21/sql-server-renaming-index-index-naming-conventions/): If you are regular reader of this blog, you must be aware of that there are two kinds of blog posts 1) I share what I learn recently 2) I share what I learn and request your participation. Today’s blog post is where I need your opinion to make this blog post a good reference for future. Background Story Recently I came across system where users have changed the name of the few of the table to match their new standard naming convention. The name of the table should be self explanatory and they should have explain their purpose without either opening it... - [SQL SERVER - New Look for CodePlex Project - Hosting for Open Source Software](https://blog.sqlauthority.com/2012/05/20/sql-server-new-look-for-codeplexproject-hosting-for-open-source-software/): Codeplex is my favorite site. CodePlex is Microsoft's free open source project hosting site. You can create projects to share with the world, collaborate with others on their projects, and download open source software. It is a great place to find so many open source project available to explore. All the software are the free and open source. I often go there at intervals to check what is new in SQL Server field as well on other technologies. Yesterday when I visited it, I had a nice surprise as it has a total makeover and looks very decent as well elegant at the same time. - [SQL SERVER - Saturday Fun Puzzle with SQL Server DATETIME2 and CAST](https://blog.sqlauthority.com/2012/05/19/sql-server-saturday-fun-puzzle-with-sql-server-datetime2-and-cast/): Note: I have used SQL Server 2012 for this small fun experiment. Here is what we are going to do. We will run the script one at time instead of running them all together and try to guess the answer. I am confident that many will get it correct but if you do not get correct, you learn something new. Let us create database and sample table. CREATE DATABASE DB2012 GO USE DB2012 GO CREATE TABLE TableDT (DT1 VARCHAR(100), DT2 DATETIME2, DT1C AS DT1, DT2C AS DT2); INSERT INTO TableDT (DT1, DT2) SELECT GETDATE(), GETDATE() GO There are four columns in... - [SQL SERVER - Thinking about Deprecated, Discontinued Features and Breaking Changes while Upgrading to SQL Server](https://blog.sqlauthority.com/2012/05/18/sql-server-thinking-about-deprecated-discontinued-features-and-breaking-changes-while-upgrading-to-sql-server-2012-guest-post-by-nakul-vachhrajani/): In this blog post we Nakul will talk about Thinking about Deprecated, Discontinued Features and Breaking Changes while Upgrading to SQL Server. - [SQLAuthority News - SQL Server 2012 Upgrade Technical Guide - A Comprehensive Whitepaper - (454 pages - 9 MB)](https://blog.sqlauthority.com/2012/05/17/sqlauthority-news-sql-server-2012-upgrade-technical-guide-a-comprehensive-whitepaper-454-pages-9-mb/): Microsoft has just released SQL Server 2012 Upgrade Technical Guide. This guide is very comprehensive and covers the subject of upgrade in-depth. This is indeed a helpful detailed white paper. Even writing a summary of this white paper would take over 100 pages. This further proves that SQL Server 2012 is quite an important release from Microsoft. This white paper discusses how to upgrade from SQL Server 2008/R2 to SQL Server 2012. I love how it starts with the most interesting and basic discussion of upgrade strategies: 1) In-place upgrades, 2) Side by side upgrade, 3) One-server, and 4) Two-server. This whitepaper is... - [SQL SERVER - SQL in Sixty Seconds - 5 Videos from Joes 2 Pros Series - SQL Exam Prep Series 70-433](https://blog.sqlauthority.com/2012/05/16/sql-server-sql-in-sixty-seconds-5-videos-from-joes-2-pros-series-sql-exam-prep-series-70-433/): Joes 2 Pros SQL Server Learning series is indeed fun. Joes 2 Pros series is written for beginners and who wants to build expertise for SQL Server programming and development from fundamental. In the beginning of the series author Rick Morelan is not shy to explain the simplest concept of how to open SQL Server Management Studio. Honestly the book starts with that much basic but as it progresses further Rick discussing about various advanced concepts from query tuning to Core Architecture. This five part series is written with keeping SQL Server Exam 70-433. Instead of just focusing on what will... - [SQL SERVER - Get Schema Name from Object ID using OBJECT_SCHEMA_NAME](https://blog.sqlauthority.com/2012/05/15/sql-server-get-schema-name-from-object-id-using-object_schema_name/): Sometime a simple solution have even simpler solutions but we often do not practice it as we do not see value in it or find it useful. Well, today’s blog post is also about something which I have seen not practiced much in codes. We are so much comfortable with alternative usage that we do not feel like switching how we query the data. I was going over forums and I noticed that at one place user has used following code to get Schema Name from ObjectID. USE AdventureWorks2012 GO SELECT s.name AS SchemaName, t.name AS TableName, s.schema_id, t.OBJECT_ID FROM sys.Tables... - [SQL SERVER - Columnstore Index and sys.dm_db_index_usage_stats](https://blog.sqlauthority.com/2012/05/14/sql-server-columnstore-index-and-sys-dm_db_index_usage_stats/): As you know I have been writing on Columnstore Index for quite a while. Recently my friend Vinod Kumar wrote about SQL Server 2012: ColumnStore Characteristics. A fantastic read on the subject if you have yet not caught up on that subject. After the blog post I called him and asked what should I write next on this subject. He suggested that I should write on DMV script which I have prepared related to Columnstore when I was writing our SQL Server Questions and Answers book. When we were writing this book SQL Server 2012 CTP versions were available. I had written few scripts related to SQL Server columnstore Index. I like Vinod’s idea and I decided to write about DMV, which we did not cover in the book as SQL Server 2012 was not released yet. We did not want to talk about the product which was not yet released. - [SQLAuthority News - Download Whitepaper - Choosing a Tabular or Multidimensional Modeling Experience in SQL Server 2012 Analysis Services](https://blog.sqlauthority.com/2012/05/13/sqlauthority-news-download-whitepaper-choosing-a-tabular-or-multidimensional-modeling-experience-in-sql-server-2012-analysis-services/): Data modeling is the most important task for any BI professional. Matter of the fact, the biggest challenge is to organizing disparate data into an analytic model that effectively and efficiently supports the reporting and analysis. SQL Server 2012 introduces BI Semantic Model (BISM), a single model that can support a broad range of reporting and analysis while blending two Analysis Services modeling experiences behind the scenes. Multidimensional modeling – enables BI professionals to create sophisticated multidimensional cubes using traditional online analytical processing (OLAP). Tabular modeling – provides self-service data modeling capabilities to business and data analysts. As data modeling is evolving and business needs... - [SQL SERVER - Developer Training Kit for SQL Server 2012](https://blog.sqlauthority.com/2012/05/12/sql-server-developer-training-kit-for-sql-server-2012/): Developer Training Kit is my favorite part of any product. The reason behind is very simple because it give the single resource which gives complete overview of the product in nutshell. A developer can learn from many places – books, webcasts, tutorials, blogs, etc. However, I have found that developer training kits are the best starting point for any product. Start with them first, see what are the new features as well what is the new message a product is coming up with. Once it is learned the very next step should be to identify the right learning material to explore... - [SQL SERVER - Quiz and Video - Introduction to Discovering XML Data Type Methods](https://blog.sqlauthority.com/2012/05/11/sql-server-quiz-and-video-introduction-to-discovering-xml-data-type-methods/): This blog post is inspired from SQL Interoperability Joes 2 Pros: A Guide to Integrating SQL Server with XML, C#, and PowerShell – SQL Exam Prep Series 70-433 – Volume 5. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] This is follow up blog post of my earlier blog post on the same subject – SQL SERVER – Introduction to Discovering XML Data Type Methods – A Primer. In the article we discussed various basics terminology of the XML. The article further covers following important concepts of XML. What are XML Data Type Methods The query() Method The value() Method The exist() Method The modify()... - [SQL SERVER - Quiz and Video - Introduction to SQL Error Actions](https://blog.sqlauthority.com/2012/05/10/sql-server-quiz-and-video-introduction-to-sql-error-actions/): This blog post is inspired from SQL Programming Joes 2 Pros: Programming and Development for Microsoft SQL Server 2008 – SQL Exam Prep Series 70-433 – Volume 4. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] This is follow up blog post of my earlier blog post on the same subject – SQL SERVER – Introduction to SQL Error Actions – A Primer. In the article we discussed various basics terminology of the error handling. The article further covers following important concepts of error handling. Introduction to SQL Error Actions Statement Termination Scope Abortion Batch Termination Above three are the most important concepts related to error handling and SQL... - [SQL SERVER - Quiz and Video - Introduction to Basics of a Query Hint](https://blog.sqlauthority.com/2012/05/09/sql-server-quiz-and-video-introduction-to-basics-of-a-query-hint/): This blog post is inspired from SQL Architecture Basics Joes 2 Pros: Core Architecture concepts – SQL Exam Prep Series 70-433 – Volume 3. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] This is follow up blog post of my earlier blog post on the same subject – SQL SERVER – Introduction to Basics of a Query Hint – A Primer. In the article we discussed various basics terminology of the query hints. The article further covers following important concepts of query hints. Expecting Seek and getting a Scan Creating an index for improved optimization Implementing the query hint Above three are the most important concepts... - [SQL SERVER - Quiz and Video - Introduction to Hierarchical Query using a Recursive CTE](https://blog.sqlauthority.com/2012/05/08/sql-server-quiz-and-video-introduction-to-hierarchical-query-using-a-recursive-cte/): This is followed up a blog post of my earlier blog post on the same subject - Introduction to Hierarchical Query using a Recursive CTE – A Primer. In the article we discussed various basic terminology of the CTE. The article further covers following important concepts of common table expression. Let us learn in this video how to do Hierarchical Query using a Recursive CTE. What is a Common Table Expression (CTE) Building a Recursive CTE Identify the Anchor and Recursive Query Add the Anchor and Recursive query to a CTE Add an expression to track hierarchical level Add a self-referencing INNER JOIN statement - [SQL SERVER - Quiz and Video - Introduction to SQL Server Security](https://blog.sqlauthority.com/2012/05/07/sql-server-quiz-and-video-introduction-to-sql-server-security/): This blog post is inspired from Beginning SQL Joes 2 Pros: The SQL Hands-On Guide for Beginners – SQL Exam Prep Series 70-433 – Volume 1. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] This is follow up blog post of my earlier blog post on the same subject – SQL SERVER – Introduction to SQL Server Security – A Primer. In the article we discussed various basics terminology of the security. The article further covers following important concepts of security. Granting Permissions Denying Permissions Revoking Permissions Above three are the most important concepts related to security and SQL Server.  There are many more things one... - [SQL SERVER - Four Tutorial for SQL Server 2012 New Features](https://blog.sqlauthority.com/2012/05/06/sql-server-four-tutorial-for-sql-server-2012-new-features/): One of the very common question I receive on my facebook is that if there is any tutorial for SQL Server 2012 new enhanced features and solutions. I see this demand a bit increasing as the SQL Server 2012 is more and more being adopted. Here is the list of four tutorial which is specifically created for SQL Server 2012 by Microsoft. - [SQL SERVER - Migrate a SQL Server Reports from one server to another server](https://blog.sqlauthority.com/2012/05/05/sql-server-migrate-a-sql-server-reports-from-one-server-to-another-server/): How many time you have felt that there should be need of the tool which help you to migrate SQL Server Reports from one server to another server. Well, I am glad to see this migration tool for migrating reports from SQL Server 2008 R2 and later version. This tool uses powershell for migration  script. Here is the requirement of source server and target server. Source server must be native mode using Windows authentication. Target server must be SharePoint integrated mode. The web application must be using Windows classic authentication mode. You can migrate it using any of the following methods. Command-line tool (RSMigrationTool.exe)... - [SQL SERVER - Identify Columnstore Index Usage from Execution Plan](https://blog.sqlauthority.com/2012/05/04/sql-server-identify-columnstore-index-usage-from-execution-plan/): I think there was a time when lots of questions were coming via either email or blog comments. Nowadays, the trend seems to change. Most of the question I receive is through social media. Here is the latest question I received through Twitter. The best or worst part of Twitter is that it allows only 140 characters, so I’ve noticed that a question is easy to ask on Twitter, but an answer is difficult to provide using this social network. The question I received at https://mobile.twitter.com/pinaldave is as follows: “How do I know if columnstore index is used by query through execution... - [SQL SERVER - A Tricky Question and Even Trickier Answer - Index Intersection - Partition Function](https://blog.sqlauthority.com/2012/05/03/sql-server-a-tricky-question-and-even-trickier-answer-index-intersection-partition-function/): During yesterday’s evening, I asked a very simple question on my Facebook Page. The question was written in a jiffy and in a very light mood. While writing the question, I left a few things out, and the question did miss a few details about setup. However, as the question was not complete, it created an extremely interesting conversation in the following thread. Here is the question: Write a select statement using a single table, using single table single time only without using join keywords, which generate execution plan with 2 join operators. Use AdventureWorks as a sample database. I got many interesting... - [SQL SERVER - Video - Step by Step Installation of SQL Server 2012](https://blog.sqlauthority.com/2012/05/02/sql-server-video-step-by-step-installation-of-sql-server-2012/): SQL Server 2012 launched on March 7, 2012. SQL Server 2012 was available on April 1, 2012 for General Availability. Recently I have received quite a few queries that they are facing issues with SQL Server 2012 installation. I have tried to solve quite a few problems and I figured out really there is no big problem but most of the problem are faced by people who are attempting to install it first time and have no previous experience about installing SQL Server. I decided to create a quick video with voice instruction regarding how to install SQL Server 2012. It... - [SQL SERVER - Maximum Allowable Length of Characters for Temp Objects is 116 - Guest Post by Balmukund Lakhani](https://blog.sqlauthority.com/2012/05/01/sql-server-maximum-allowable-length-of-characters-for-temp-objects-is-116-guest-post-by-balmukund-lakhani/): Balmukund Lakhani (B | T | S) is currently working as Technical Lead in SQL Support team with Microsoft India GTSC. In past 7+ years with Microsoft he was also a part of the Premier Field Engineering Team for 18 months. During that time he was a part of rapid on-site support (ROSS) team. Prior to joining Microsoft in 2005, he worked as SQL developer, SQL DBA and also got a chance to wear his other hat as an ERP Consultant. Let us learn about Maximum Allowable Length of Characters for Temp Objects is 116. - [SQL SERVER - A Brief Introduction to expressor Studio 3.6](https://blog.sqlauthority.com/2012/04/30/sql-server-a-brief-introduction-to-expressor-studio-3-6/): Data is powerful. Data drives businesses. Data supports decision making and fuels progress. But managing data—making data work for us—isn’t inherently easy. And if there is one thing that is certain, it’s change—meaning that data systems created yesterday will need to be adapted to fit ever evolving needs. Since we can’t design our databases, data warehouses, and BI systems with every possible contingency in mind, we need data integration software that is smart enough to simplify the process and allow us to build more flexible solutions that can adapt to change and can let us focus on the value of our... - [SQL SERVER - Microsoft Certification - SQL Server 2012](https://blog.sqlauthority.com/2012/04/29/sql-server-microsoft-certification-sql-server-2012/): Microsoft has recently introduced a few changes in how the certification works. I have tried to simplify the same thing over here. The new certification line is called Microsoft cloud-built Certifications. Let us read more about Microsoft Certification. The mapping of the certifications is here. Exam 70-461: Querying Microsoft SQL Server 2012 Exam 70-462: Administering Microsoft SQL Server 2012 Databases Exam 70-463: Implementing a Data Warehouse with Microsoft SQL Server 2012 - [SQLAuthority News - Migration Guide: Migrating to SQL Server 2012 Failover Clustering and Availability Groups from Prior Clustering and Mirroring Deployments - Part 1](https://blog.sqlauthority.com/2012/04/28/sqlauthority-news-migration-guide-migrating-to-sql-server-2012-failover-clustering-and-availability-groups-from-prior-clustering-and-mirroring-deployments-part-1/): Migration is always a challenge. How many times we have stayed away from migrating product to another server or next version because we are worried what will happen once we migrate. There are two main reasons we stay away from migration 1) Everything is working fine at this moment. 2) Fear of everything will not work fine after migration. Let us address two of this fear in brief words. 1) Everything is working fine Even though everything is working fine there are need to upgrade to next version because new version often brings improved features as well new enhancement which can help in... - [SQL SERVER - Introduction to Discovering XML Data Type Methods - A Primer](https://blog.sqlauthority.com/2012/04/27/sql-server-introduction-to-discovering-xml-data-type-methods-a-primer/): This blog post is inspired from SQL Interoperability Joes 2 Pros: A Guide to Integrating SQL Server with XML, C#, and PowerShell – SQL Exam Prep Series 70-433 – Volume 5. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] What are XML Data Type Methods The XML data type was first introduced with SQL Server 2005. This data type continues with SQL Server 2008 where expanded XML features are available, most notably is the power of the XQuery language to analyze and query the values contained in your XML instance. There are five XML data type methods available in SQL Server 2008: query() – Used... - [SQL SERVER - Introduction to SQL Error Actions - A Primer](https://blog.sqlauthority.com/2012/04/26/sql-server-introduction-to-sql-error-actions-a-primer/): This blog post is inspired from SQL Programming Joes 2 Pros: Programming and Development for Microsoft SQL Server 2008 – SQL Exam Prep Series 70-433 – Volume 4. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] Introduction to SQL Error Actions Most people believe that when SQL Server encounters an error severity level 11 or higher the remaining SQL statements will not get executed. In addition, people also believe that if any error severity level of 11 or higher is hit inside an explicit transaction, then the whole statement will fail as a unit. While both of these beliefs are true 99% of the... - [SQL SERVER - Introduction to Basics of a Query Hint - A Primer](https://blog.sqlauthority.com/2012/04/25/sql-server-introduction-to-basics-of-a-query-hint-a-primer/): This blog post is inspired from SQL Architecture Basics Joes 2 Pros: Core Architecture concepts – SQL Exam Prep Series 70-433 – Volume 3. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] Basics of a Query Hint Query hints specify that the indicated hints should be used throughout the query. Query hints affect all operators in the statement and are implemented using the OPTION clause. The basic syntax structure for a Query Hint is shown below: DECLARE @Type VARCHAR ( 50 ) SET @Type = 'Business' SELECT * FROM Customer WHERE CustomerType = @Type OPTION ( OPTIMIZE FOR ( @Type = 'Business' )); Cautionary... - [SQL SERVER - Introduction to Hierarchical Query using a Recursive CTE - A Primer](https://blog.sqlauthority.com/2012/04/24/sql-server-introduction-to-hierarchical-query-using-a-recursive-cte-a-primer/): This blog post is inspired from SQL Queries Joes 2 Pros: SQL Query Techniques For Microsoft SQL Server 2008 – SQL Exam Prep Series 70-433 – Volume 2. [Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] What is a Common Table Expression (CTE) A CTE can be thought of as a temporary result set and are similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. A CTE is generally considered to be more readable than a derived table and does not require the extra effort of declaring a Temp Table... - [SQL SERVER - Introduction to SQL Server Security - A Primer](https://blog.sqlauthority.com/2012/04/23/sql-server-introduction-to-sql-server-security-a-primer/): Let’s get some basic definitions down first about SQL Server Security. Take the workplace example where “Tom” needs “Read” access to the “Financial Folder”. What are the Securable, Principal, and Permissions from that last sentence? A Securable is a resource that someone might want to access (like the Financial Folder). A Principal is anything that might want to gain access to the securable (like Tom). A Permission is the level of access a principal has to a securable (like Read). - [Fast Track Data Warehouse Reference Guide for SQL Server - SQLAuthority News](https://blog.sqlauthority.com/2012/04/22/sqlauthority-news-fast-track-data-warehouse-reference-guide-for-sql-server-2012/): The goal of a Fast Track Data Warehouse reference architecture is to achieve an efficient resource balance between SQL Server data processing. - [SQL SERVER - Working with FileTables in SQL Server 2012 - Part 3 - Retrieving Various FileTable Properties](https://blog.sqlauthority.com/2012/04/21/sql-server-working-with-filetables-in-sql-server-2012-part-3-retrieving-various-filetable-properties/): Read Part 1 Working with FileTables in SQL Server 2012 – Part 1 – Setting Up Environment Read Part 2 Working with FileTables in SQL Server 2012 – Part 2 – Methods to Insert Data Into Table In this third part of the series, we will see how we can retrieve various information from the FileTable database. - [SQL SERVER - Performance Tuning - Part 2 of 2 - Analysis, Detection, Tuning and Optimizing](https://blog.sqlauthority.com/2012/04/20/sql-server-performance-tuning-part-2-of-2-analysis-detection-tuning-and-optimizing/): This second part of Performance Tuning – Part 1 of 2 – Getting Started and Configuration. I suggest you read the first part before continuing on this second part. Analysis and Detection If you have noticed that configuration of the data source and profile is a very easy task and if you are familiar with the tool, this can be done in less than 2 minutes. However, while configuration is an important aspect, appropriate analysis of the data is more important since that is what leads us to appropriate results. Once configuration is over, the screen shows the results of the profiling session.... - [SQL SERVER - Performance Tuning - Part 1 of 2 - Getting Started and Configuration](https://blog.sqlauthority.com/2012/04/19/sql-server-performance-tuning-part-1-of-2-getting-started-and-configuration/): Performance tuning is always a complex subject whenever one has to deal with it. When I was beginning with SQL Server, this was the most difficult area for me. However, there is a saying that if one has to overcome their fear one has to face the fear first. So I did exactly this. I started to practice performance tuning. Early in my career I often failed when I had to deal with performance tuning tasks. However, each failure taught me something. It took a quite a while and about 100+ various projects before I started to consider myself a guy... - [SQLAuthority News - Select the Best SQL in Sixty Seconds Episode - Help us Improve](https://blog.sqlauthority.com/2012/04/18/sqlauthority-news-select-the-best-sql-in-sixty-seconds-episode-help-us-improve/): It has been more than 3 months since we have started experimenting with a new concept in  SQL in Sixty Seconds. Every Wednesday, we putt a fresh new interesting concept out via video. Rick Morelan, Vinod Kumar and myself – the three of us decided to do something new and something exciting. We decided to create a short video which will consider the attention span of the viewer, keep them focused and help them learn something new through our teaching. We all liked the idea of SQL in Sixty Seconds. As the name suggests, you will not watch content for more than a minute. We did... - [SQL SERVER Cheatsheet - Released for SQL Server 2012 Edition](https://blog.sqlauthority.com/2012/04/17/sql-server-cheatsheet-released-for-sql-server-2012-edition/): SQL Server Cheatsheet has been extremely popular download from my blog. There are plenty of request for me to update it with SQL Server 2012 features. I have finally upgraded the cheatsheet with SQL Server 2012 features. The new cheatsheet has following updates - [SQLAuthority News - Presenting at Great Indian Developer Summit 2012 - SQL Server Misconception and Resolutions](https://blog.sqlauthority.com/2012/04/16/sqlauthority-news-presenting-at-great-indian-developer-summit-2012-sql-server-misconception-and-resolutions/): Earlier during TechEd 2012, I presented a session on SQL Server Misconception and Resolutions. It was a pleasure to present this session with Vinod Kumar during the event. Great Indian Developer Summit is around the corner and I will be presenting there once again with the same topic. We had an excellent response during the last event; the hall was so filled, but there were plenty who were not able to get into the session as there was no place for them to sit or stand inside. Well, here is another chance for all who missed the presentation. New Additions During... - [SQL SERVER - Working with FileTables in SQL Server 2012 - Part 2 - Methods to Insert Data Into Table ](https://blog.sqlauthority.com/2012/04/15/sql-server-working-with-filetables-in-sql-server-2012-part-2-methods-to-insert-data-into-table/): Read Part 1 Working with FileTables in SQL Server 2012 – Part 1 – Setting Up Environment In this second part of the series, we will see how we can insert the files into the FileTables. There are two methods to insert the data into FileTables: Method 1: Copy Paste data into the FileTables folder First, find the folder where FileTable will be storing the files. Go to Databases >> Newly Created Database (FileTableDB) >> Expand Tables. Here you will see a new folder which says “FileTables”. When expanded, it gives the name of the newly created “FileTableTb”. Right click on the newly created table,... - [SQL SERVER - Working with FileTables in SQL Server 2012 - Part 1 - Setting Up Environment](https://blog.sqlauthority.com/2012/04/14/sql-server-working-with-filetables-in-sql-server-2012-part-1-setting-up-environment/): Filestream is a very interesting feature, and an enhancement of FileTable with Filestream is equally exciting. Today in this post, we will learn how to set up the FileTable Environment in SQL Server. The major advantage of FileTable is it has Windows API compatibility for file data stored within an SQL Server database. In simpler words, FileTables remove a barrier so that SQL Server can be used for the storage and management of unstructured data that are currently residing as files on file servers. Another advantage is that the Windows Application Compatibility for their existing Windows applications enables to see these data as files in... - [SQLAuthority News - Social Media Series - LinkedIn and Professional Profile](https://blog.sqlauthority.com/2012/04/13/sqlauthority-news-social-media-series-linkedin-and-professional-profile/): Pinal Dave on LinkedIn! It seems like a few year ago, there was a big “boom” in social media websites.  All of a sudden there were so many sites to choose from.  MySpace or Orkut?  Blogging websites for your business or a LinkedIn account?  The nature of the internet is to always be changing, but I believe that out of this huge growth of websites, a few have come to stay.  Facebook is obviously the leader in social media networking, especially for your personal life.  Blogging is great, but it can be more of a way to get your ideas out... - [SQLAuthority News - Social Media Series - YouTube and Movies](https://blog.sqlauthority.com/2012/04/12/sqlauthority-news-social-media-series-youtube-and-movies/): Pinal Dave on Youtube! Some people might not know it, but YouTube is actually more than a place to watch funny cat videos and people singing their favorite pop songs – it’s actually a social media site.  When you are a member of YouTube you can follow people who regularly post videos, post video responses of your own, and even gain a following for your own videos.  I myself was not aware of YouTube’s potential until recently, when I started to make SQL Server in Sixty Seconds videos. YouTube is very different than other types of social media, and a big... - [SQL SERVER - Installing AdventureWorks Sample Database - SQL in Sixty Seconds #010 - Video](https://blog.sqlauthority.com/2012/04/11/sql-server-installing-adventureworks-sample-database-sql-in-sixty-seconds-010-video/): SQL Server has so many enhancements and features that quite often I feel like playing with various features and try out new things. I often come across situation where I want to try something new but I do not have sample data to experiment with. Also just like any sane developer I do not try any of my new experiments on production server. Additionally, when it is about new version of the SQL Server, there are cases when there is no relevant sample data even available on development server. In this kind of scenario sample database can be very much handy. Additionally, in many SQL Books and online blogs... - [SQLAuthority News - Social Media Series - Facebook and Google+](https://blog.sqlauthority.com/2012/04/10/sqlauthority-news-social-media-series-facebook-and-google/): Unless you have been living under a rock for the last few years, you know that Facebook is the first and last word in social networking. Everyone has a Facebook account – from your local store with the 10-year old school child. Because of this ability to be completely connected to everyone in your entire life, keeping a Facebook page for a professional business can be tricky. Let us learn a bit more about social media. - [SQLAuthority News - Social Media Series - Twitter and Myself](https://blog.sqlauthority.com/2012/04/09/sqlauthority-news-social-media-series-twitter-and-myself/): Pinal Dave on Twitter! Frequent readers of my blog might know that I am trying to get more involved in all social media sites, both professionally and personally.  Readers might also know that I have often struggled with finding the purpose of some social media sites – Twitter especially.  One of the great uses of social media is to stay connected and updated with followers.  Twitter’s 140 character limit means that Twitter is a great place to get quick updates from the world, but not a lot of deep information.  In fact, I have the feeling that Twitter’s form might actually... - [SQLAuthority News - Download SQL Azure Labs Codename "Data Explorer" Client](https://blog.sqlauthority.com/2012/04/08/sqlauthority-news-download-sql-azure-labs-codename-data-explorer-client/): Microsoft SQL Azure labs has recently released Data Explorer client. I was looking forward to visualizing tool for quite a while and I am delighted to see this tool. I will be trying out this tool in coming week and will post here my experience. I have listed few of the resources which are related to Data Explorer at the end. Please let me know if I have missed any and I will add the same. With “Data Explorer” you can: Identify the data you care about from the sources you work with (e.g. Excel spreadsheets, files, SQL Server databases). Discover relevant data... - [SQL SERVER - DMV sys.dm_exec_describe_first_result_set_for_object - Describes the First Result Metadata for the Module](https://blog.sqlauthority.com/2012/04/07/sql-server-dmv-sys-dm_exec_describe_first_result_set_for_object-describes-the-first-result-metadata-for-the-module/): Here is another interesting follow up blog post of SQL SERVER – sp_describe_first_result_set New System Stored Procedure in SQL Server 2012. While I was writing earlier blog post I had come across DMV sys.dm_exec_describe_first_result_set_for_object as well. I found that SQL Server 2012 is providing all this quick and new features which quite often we miss  to learn it and when in future someone demonstrates the same to us, we express our surprise on the subject. DMV sys.dm_exec_describe_first_result_set_for_object returns result set which describes the columns used in the stored procedure. Here is the quick example. Let us first create stored procedure. USE [AdventureWorks] GO ALTER PROCEDURE [dbo].[CompSP] AS... - [SQLAuthority News - Reliving TechEd at Bangalore User Groups](https://blog.sqlauthority.com/2012/04/06/sqlauthority-news-reliving-teched-bangalore-user-groups/): TechEd India 2012 was held in Bangalore last March 21 to 23, 2012. Just like every year, this event is bigger, grander and inspiring. Here is my blog post reviewing the event SQLAuthority News – #TechEdIn – TechEd India 2012 Memories and Photos. For me this is a family event - I get to meet my friends who are dear as my family. I like to call User Groups as family too. Family shares life's personal happiness and experience - the same way User Group shares professional experiences and quite often UG members become just like a family member. - [SQLAuthority News - #TechEdIn - TechEd India 2012 Memories and Photos](https://blog.sqlauthority.com/2012/04/05/sqlauthority-news-techedin-teched-india-2012-memories-and-photos/): TechEd India 2012 was held in Bangalore last March 21 to 23, 2012. Just like every year, this event is bigger, grander and inspiring. Family Event Every single year, TechEd is a special affair for my entire family.  Four months before the start of TechEd, I usually start to build the mental image of the event. I start to think  about various things. For the most part, what excites me most is presenting a session and meeting friends. Seriously, I start thinking about presenting my session 4 months earlier than the event!  I work on my presentation day and night. I... - [SQL SERVER - Cleaning Up SQL Server Indexes - Defragmentation, Fillfactor - Video](https://blog.sqlauthority.com/2012/04/04/sql-server-cleaning-up-sql-server-indexes-defragmentation-fillfactor-video/): Storing data non-contiguously on disk is known as fragmentation. Before learning to eliminate fragmentation, you should have a clear understanding of the types of fragmentation. When records are stored non-contiguously inside the page, then it is called internal fragmentation. When on disk, the physical storage of pages and extents is not contiguous. We can get both types of fragmentation using the DMV: sys.dm_db_index_physical_stats. Here is the generic advice for reducing the fragmentation. If avg_fragmentation_in_percent > 5% and < 30%, then use ALTER INDEX REORGANIZE: This statement is replacement for DBCC INDEXDEFRAG to reorder the leaf level pages of the index in a logical order.... - [SQL SERVER - FIX: ERROR Msg 5169, Level 16: FILEGROWTH cannot be greater than MAXSIZE for file](https://blog.sqlauthority.com/2012/04/03/sql-server-fix-error-msg-5169-level-16-filegrowth-cannot-be-greater-than-maxsize-for-file/): I am writing this blog post right after I resolve this error for one of the system. Recently one of the my friend who is expert in infrastructure as well private cloud was working on SQL Server installation. Please note he is seriously expert in what he does but he has never worked SQL Server before and have absolutely no experience with its installation. He was modifying database file and keep on getting following error. As soon as he saw me he asked me where is the maxfile size setting so he can change. Let us quickly re-create the scenario he was facing.... - [SQL SERVER - Use ROLL UP Clause instead of COMPUTE BY](https://blog.sqlauthority.com/2012/04/02/sql-server-use-roll-up-clause-instead-of-compute-by/): Note: This upgrade was test performed on development server with using bits of SQL Server 2012 RC0 (which was available at in public) when this test was performed. However, SQL Server RTM (GA on April 1) is expected to behave similarly. I recently observed an upgrade from SQL Server 2005 to SQL Server 2012 with compatibility keeping at SQL Server 2012 (110). After upgrading the system and testing the various modules of the application, we quickly observed that few of the reports were not working. They were throwing error. When looked at carefully I noticed that it was using COMPUTE BY clause,... - [SQL SERVER - A Puzzle - Illusion - Confusion - April Fools' Day](https://blog.sqlauthority.com/2012/04/01/sql-server-a-puzzle-illusion-confusion-april-fools-day/): Today is April 1st and just like every other year, I like to bring something interesting and light for the day. Atleast there should be days in every one’s life when they should feel easy. Here is a quick puzzle for you and I believe it will make you feel extremely smart if you can figure out the result behind the same. Run following in SQL Server Management Studio and observe the output: SELECT 30.0/(-2.0)/5.0; SELECT 30.0/-2.0/5.0; Here are few questions for you: 1) What will be the result of above two queries? 2) Why? If you think you can figure... - [SQL SERVER - sp_describe_first_result_set New System Stored Procedure in SQL Server 2012](https://blog.sqlauthority.com/2012/03/31/sql-server-sp_describe_first_result_set-new-system-stored-procedure-in-sql-server-2012/): I might have said this earlier many times but I will say it again – SQL Server never stops to amaze me. Here is the example of it sp_describe_first_result_set. I stumbled upon it when I was looking for something else on BOL. This new system stored procedure did attract me to experiment with it. This SP does exactly what its names suggests – describes the first result set. Let us see very simple example of the same. Please note that this will work on only SQL Server 2012. EXEC sp_describe_first_result_set N'SELECT * FROM AdventureWorks.Sales.SalesOrderDetail', NULL, 1 GO Here is the partial... - [SQL SERVER - Online Index Rebuilding Index Improvement in SQL Server 2012](https://blog.sqlauthority.com/2012/03/30/sql-server-online-index-rebuilding-index-improvement-in-sql-server-2012/): Have you ever faced a situation where you see something working but you feel it should not be working? Well, I had similar moments a few days ago. I knew that SQL Server 2008 supports online indexing. However, I also knew that I could not rebuild index ONLINE if I used VARCHAR(MAX), NVARCHAR(MAX) or a few other data types. While I was strongly holding on to my belief, I came across with that situation where I had to go online and do a little bit of reading at Book Online.  Here is an example showing the situation I’ve gone through: First... - [SQL SERVER - Difference between DATABASEPROPERTY and DATABASEPROPERTYEX](https://blog.sqlauthority.com/2012/03/29/sql-server-difference-between-databaseproperty-and-databasepropertyex/): Earlier I asked a simple question on Facebook regarding difference between DATABASEPROPERTY and DATABASEPROPERTYEX in SQL Server. You can view the original conversation there over here. The conversion immediately became very interesting and lots of healthy discussion happened on facebook page. The best part of having conversation on facebook page is the comfort it provides and leaner commenting interface. Question Question from SQLAuthority.com: What is the difference between DATABASEPROPERTY and DATABASEPROPERTYEX in SQL Server? Answer Answer from Rakesh Kumar: DATABASEPROPERTY is supported for backward compatibility but does not provide information about the properties added in this release. Also, many properties supported by DATABASEPROPERTY... - [SQL SERVER - T-SQL Constructs - *= and += - SQL in Sixty Seconds #009 - Video](https://blog.sqlauthority.com/2012/03/28/sql-server-t-sql-constructs-and-sql-in-sixty-seconds-009-video/): There were plenty of request for Vinod Kumar to come back with SQL in Sixty Seconds with T-SQL constructs after his very first well received construct video T-SQL Constructs – Declaration and Initialization – SQL in Sixty Seconds #003 – Video. Vinod finally comes up with this new episode where he demonstrates how dot net developer can write familiar syntax using T-SQL constructs. T-SQL has many enhancements which are less explored. In this quick video we learn how T-SQL Constructions works. We will explore Declaration and Initialization of T-SQL Constructions. We can indeed improve our efficiency using this kind of simple tricks. I strongly suggest... - [SQL SERVER - Right Aligning Numerics in SQL Server Management Studio (SSMS)](https://blog.sqlauthority.com/2012/03/27/sql-server-right-aligning-numerics-in-sql-server-management-studio-ssms/): SQL Server Management Studio is my most favorite tool and the comfort it provides to user is sometime very amazing. Recently I was retrieving numeric data in SSMS and I found it is very difficult to read them as they were all right aligned. Please pay attention to following image, you will notice that it is not easier to read the digits as we are used to read the numbers which are right aligned. I immediately thought before I go for any other tricks I should check the query properties. I right clicked on query properties and I found following option.... - [SQL SERVER - Partition Parallelism Support in expressor 3.6](https://blog.sqlauthority.com/2012/03/26/sql-server-partition-parallelism-support-in-expressor-3-6/): I am very excited to learn that there is a new version of expressor’s data integration platform coming out in March of this year. It includes Partition Parallelism Support. It will be version 3.6, and I look forward to using it and telling everyone about it. Let me describe a little bit more about what will be so great in expressor 3.6: Greatly enhanced user interface Parallel Processing Bulk Artifact Upgrading - [SQL SERVER - Download Free eBook - Introducing Microsoft SQL Server 2012](https://blog.sqlauthority.com/2012/03/25/sql-server-download-free-ebook-introducing-microsoft-sql-server-2012/): Database Administration and Business Intelligence is indeed very key area of the SQL Server. My very good friend Ross Mistry and Stacia Misner has recently wrote book which is for SQL Server 2012. The best part of the book is it is totally FREE! Well, this book assumes that you have certain level of SQL Server Administration as well Business Intelligence understanding. So if you are absolutely beginner I suggest you read other books of Ross as well attend Pluralsight course of Stacia Misner. Personally I read this book in last 10 days and I find it very easy to read... - [SQL SERVER - Transcript of Learning SQL Server Performance: Indexing Basics - Interview of Vinod Kumar by Pinal Dave](https://blog.sqlauthority.com/2012/03/24/sql-server-transcript-of-learning-sql-server-performance-indexing-basics-interview-of-vinod-kumar-by-pinal-dave/): Recently I just wrote a blog post on about Learning SQL Server Performance: Indexing Basics and I received lots of request that if we can share some insight into the course. Here is 200 seconds interview of Vinod Kumar I took right after completing the course. We have few free codes to watch the course, please your comment at and we will few of first ones, we will send the code. [youtube=http://www.youtube.com/watch?v=EdLaN9bYdDU] There are many people who said they would like to read the transcript of the video. Here I have generated the same. Pinal: Vinod, we recently released this course, SQL Server... - [SQL SERVER - Using MAXDOP 1 for Single Processor Query - SQL in Sixty Seconds #008 - Video](https://blog.sqlauthority.com/2012/03/23/sql-server-using-maxdop-1-for-single-processor-query-sql-in-sixty-seconds-008-video/): Today’s SQL in Sixty Seconds video is inspired from my presentation at TechEd India 2012 on Speed up! – Parallel Processes and Unparalleled Performance. There are always special cases when it is about SQL Server. There are always few queries which gives optimal performance when they are executed on single processor and there are always queries which gives optimal performance when they are executed on multiple processors. I will be presenting the how to identify such queries as well what are the best practices related to the same. In this quick video I am going to demonstrate if the query is... - [SQL SERVER - #TechEdIn - Presenting Tomorrow on Speed Up! - Parallel Processes and Unparalleled Performance at TechEd India 2012](https://blog.sqlauthority.com/2012/03/22/sql-server-techedin-presenting-tomorrow-on-speed-up-parallel-processes-and-unparalleled-performance-at-teched-india-2012/): Performance tuning is always a very hot topic when it is about SQL Server. SQL Server Performance Tuning is a very challenging subject that requires expertise in Database Administration and Database Development. I always have enjoyed talking about SQL Server Performance tuning subject. However, in India, it’s actually the very first time someone is presenting on this interesting subject, so this time I had the biggest challenge to present this session. Frequently enough, we get these two kind of questions: How to turn off parallelism as it is reducing performance? How to turn on parallelism as I want more performance? The... - [SQL SERVER - Table Variables and Transactions - SQL in Sixty Seconds #007 - Video](https://blog.sqlauthority.com/2012/03/21/sql-server-table-variables-and-transactions-sql-in-sixty-seconds-007-video/): Today’s SQL in Sixty Seconds video is inspired from my presentation at TechEd India 2012 on Misconception and Resolution. Quite often I have seen people getting confused with certain behavior of the T-SQL. They expect SQL to behave certain way and SQL Server behave differently. This kind of issue often creates confusion and frustration. Sometime I have seen them also confusing it with bug and submitting the bug, where reality is totally different. Similar concept which are going to see today. I have seen quite commonly developer assuming that table various will be rolled back when transaction is rolled back. This... - [SQL SERVER - #TechEdIn - Presenting Tomorrow on SQL Server Misconception and Resolution with Vinod Kumar at TechEd India 2012](https://blog.sqlauthority.com/2012/03/20/sql-server-techedin-presenting-tomorrow-on-sql-server-misconception-and-resolution-with-vinod-kumar-at-teched-india-2012/): I am excited AND nervous at the same time. I am going to present a very interesting topic tomorrow at an SQL Server track in India. This will be my fourth time presenting at TechEd India. So far, I have received so much feedback about this one session. It seems like every single person out there has their own wishes and requests. I am sure that it is going to very challenging experience to satisfy everyone who attends the event through my presentation. Surprise Element Here is the good news: I am going to co-present this session with Vinod Kumar, my... - [SQLAuthority News - #TechEDIn - TechEd India 2012 - Things to Do and Explore for SQL Enthusiast](https://blog.sqlauthority.com/2012/03/19/sqlauthority-news-techedin-teched-india-2012-things-to-do-and-explore-for-sql-enthusiast/): TechEd India 2012 is just 48 hours away and I have been receiving lots of requests regarding how SQL enthusiasts can maximize their time they’ll be spending at TechEd India 2012. Trust me – TechEd is the biggest Tech Event in India and it is much larger in magnitude than we can imagine. There are plenty of tracks there and lots of things to do. Honestly, we need clone ourselves multiple times to completely cover the event. However, I am going to talk about SQL enthusiasts only right now. In this post, I’ll share a few things they can do in this big... - [SQL SERVER - Finding Shortest Distance between Two Shapes using Spatial Data Classes - Ramsetu or Adam's Bridge](https://blog.sqlauthority.com/2012/03/18/sql-server-finding-shortest-distance-between-two-shapes-using-spatial-data-classes-ramsetu-or-adams-bridge/): Recently I was reading excellent blog post by Lenni Lobel on Spatial Database. He has written very interesting function ShortestLineTo in Spatial Data Classes. I really loved this new feature of the finding shortest distance between two shapes in SQL Server. Following is the example which is same as Lenni talk on his blog article . DECLARE @Shape1 geometry = 'POLYGON ((-20 -30, -3 -26, 14 -28, 20 -40, -20 -30))' DECLARE @Shape2 geometry = 'POLYGON ((-18 -20, 0 -10, 4 -12, 10 -20, 2 -22, -18 -20))' SELECT @Shape1 UNION ALL SELECT @Shape2 UNION ALL SELECT @Shape1.ShortestLineTo(@Shape2).STBuffer(.25) GO When you run this... - [SQL SERVER - TechEd India 2012 - Content, Speakers and a Lots of Fun](https://blog.sqlauthority.com/2012/03/17/sql-server-teched-india-2012-content-speakers-and-a-lots-of-fun/): TechEd is one event which every developers and IT professionals are looking forward to attend. It is opportunity of life time and no matter how many time one gets chance to engage with it, it is never enough. I still remember every single moment of every TechEd I have attended so far. We are less than 100 hours away from TechEd India 2012 event.This event is the one must attend event for every Technology Enthusiast. Fourth time in the row I am going to attend this event and I am equally excited as the first time of the event. There are... - [SQL SERVER - SQL Server Misconceptions and Resolution - A Practical Perspective - TechEd 2012 India](https://blog.sqlauthority.com/2012/03/16/sql-server-sql-server-misconceptions-and-resolution-a-practical-perspective-teched-2012-india/): TechEd India 2012 is just around the corner and I will be presenting there in two different sessions. On the very first day of this event, my presentation will be all about SQL Server Misconceptions and Resolution – A Practical Perspective. The dictionary tells us that a “misconception” means a view or opinion that is incorrect and is based on faulty thinking or understanding. In SQL Server, there are so many misconceptions. In fact, when I hear some of these misconceptions, I feel like fainting at that very moment! Seriously, at one time, I came across the scenario where instead of using INSERT INTO…SELECT, the... - [SQL SERVER - Install Samples Database AdventureWorks for SQL Server](https://blog.sqlauthority.com/2012/03/15/sql-server-install-samples-database-adventure-works-for-sql-server-2012/): AdventureWorks is a Sample Database shipped with SQL Server and it can be downloaded from GitHub site. AdventureWorks has replaced Northwind and Pubs from the sample database in SQL Server 2005. The Microsoft team keeps updating the sample database as they release new versions. - [SQL SERVER - SQL Server Performance: Indexing Basics - SQL in Sixty Seconds #006 - Video](https://blog.sqlauthority.com/2012/03/14/sql-server-sql-server-performance-indexing-basics-sql-in-sixty-seconds-006-video/): A DBA’s role is critical, because a production environment has to run 24×7, hence maintenance, trouble shooting, and quick resolutions are the need of the hour.  The first baby step into any performance tuning exercise in SQL Server involves creating, analyzing, and maintaining indexes. Though we have learnt indexing concepts from our college days, indexing implementation inside SQL Server can vary.  Understanding this behavior and designing our applications appropriately will make sure the application is performed to its highest potential. Vinod Kumar and myself we often thought about this and realized that practical understanding of the indexes is very important. One can... - [SQL SERVER - Speed Up! - Parallel Processes and Unparalleled Performance - TechEd 2012 India](https://blog.sqlauthority.com/2012/03/13/sql-server-speed-up-parallel-processes-and-unparalleled-performance-teched-2012-india/): TechEd India 2012 is just around the corner and I will be presenting there on two different session. SQL Server Performance Tuning is a very challenging subject that requires expertise in Database Administration and Database Development. I always have enjoyed talking about SQL Server Performance tuning subject. Just like doctors I like to call my every attempt to improve the performance of SQL Server queries and database server as a practice too. I have been working with SQL Server for more than 8 years and I believe that many of the performance tuning concept I have mastered. However, performance tuning is not a simple... - [SQL Server - Learning SQL Server Performance: Indexing Basics - Interview of Vinod Kumar by Pinal Dave](https://blog.sqlauthority.com/2012/03/12/sql-server-learning-sql-server-performance-indexing-basics-interview-of-vinod-kumar-by-pinal-dave/): Recently I just wrote a blog post on about Learning SQL Server Performance: Indexing Basics and I received lots of request that if we can share some insight into the course. Every single time when Performance is discussed, Indexes are mentioned along with it. In recent times, data and application complexity is continuously growing.  The demand for faster query response, performance, and scalability by organizations is increasing and developers and DBAs need to now write efficient code to achieve this. When we developed the course – we made sure that this course remains practical and demo heavy instead of just theories on this... - [SQL SERVER - All Download Links in Single Page - SQL Server 2012](https://blog.sqlauthority.com/2012/03/11/sql-server-2012-all-download-links-in-single-page-sql-server-2012/): As feedback, I received suggestions to have a single page where everything about SQL Server 2012 is listed. Let us learn. - [SQLAuthority News - SQL Server 2012 - Microsoft Learning Training and Certification](https://blog.sqlauthority.com/2012/03/10/sqlauthority-news-sql-server-2012-microsoft-learning-training-and-certification/): Here is the conversion I had right after I had posted my earlier blog post about Download Microsoft SQL Server 2012 RTM Now. Rajesh: So SQL Server is available for me to download? Pinal: Yes, sure check the link here. Rajesh: It is trial do you know when it will be available for everybody? Pinal: I think you mean General Availability (GA) which is on April 1st, 2012. Rajesh: I want to have head start with SQL Server 2012 examination and I want to know every single Exam 70-461: Querying Microsoft SQL Server 2012 This exam is intended for SQL Server database administrators,... - [SQLAuthority News - Download Microsoft SQL Server 2012 RTM Now](https://blog.sqlauthority.com/2012/03/09/sqlauthority-news-download-microsoft-sql-server-2012-rtm-now/): SQL Server 2012 enables a cloud-ready information platform that will help organizations unlock breakthrough insights across the organization as well as quickly build solutions and extend data across on-premises and public cloud backed by capabilities for mission critical confidence: Deliver required uptime and data protection with AlwaysOn Gain breakthrough & predictable performance with ColumnStore Index Help enable security and compliance with new User-defined Roles and Default Schema for Groups Enable rapid data discovery for deeper insights across the organization with ColumnStore Index Ensure more credible, consistent data with SSIS improvements, a Master Data Services add-in for Excel, and new Data Quality... - [SQL Server - Learning SQL Server Performance: Indexing Basics - Video](https://blog.sqlauthority.com/2012/03/08/sql-server-learning-sql-server-performance-indexing-basics-video/): Today I remember one of my older cartoon years ago created for Indexing and Performance. Every single time when Performance is discussed, Indexes are mentioned along with it. In recent times, data and application complexity is continuously growing.  The demand for faster query response, performance, and scalability by organizations is increasing and developers and DBAs need to now write efficient code to achieve this. DBA and Developers A DBA’s role is critical, because a production environment has to run 24×7, hence maintenance, trouble shooting, and quick resolutions are the need of the hour.  The first baby step into any performance tuning... - [SQL SERVER - What is Page Life Expectancy (PLE) Counter](https://blog.sqlauthority.com/2010/12/13/sql-server-what-is-page-life-expectancy-ple-counter/): During performance tuning consultationconsultation, there are plenty of counters and values, I often come across. Today we will quickly talk about Page Life Expectancy counter, which is commonly known as PLE as well. You can find the value of the PLE by running the following query. SELECT [object_name], [counter_name], [cntr_value] FROM sys.dm_os_performance_counters WHERE [object_name] LIKE '%Manager%' AND [counter_name] = 'Page life expectancy' The recommended value of the PLE counter is (updated: minimum of) 300 seconds. I have seen on busy system this value to be as low as even 45 seconds and on unused system as high as 1250 seconds. Page... - [SQL SERVER - Activity Monitor and Performance Issue](https://blog.sqlauthority.com/2010/12/12/sql-server-activity-monitor-and-performance-issue/): We had a wonderful SQLAuthority News – Community Tech Days – December 11, 2010 event yesterday. During this event SQL Expert Jacob shared a very interesting story related to activity monitor. - [SQLAuthority News - SQL Server 2008 R2 System Views Map](https://blog.sqlauthority.com/2010/12/11/sqlauthority-news-sql-server-2008-r2-system-views-map/): SQL Server 2008 R2 System Views Map is released. I am very proud that my organization (Solid Quality Mentors) is part of making this possible. This map shows the key system views included in SQL Server 2008 and 2008 R2, and the relationships between them. SQL Server 2008 R2 System Views Map Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SEVER - Finding Memory Pressure - External and Internal](https://blog.sqlauthority.com/2010/12/10/sql-sever-finding-memory-pressure-external-and-internal/): The following query will provide details of external and internal memory pressure. It will return the data how much portion in the existing memory is assigned to what kind of memory type. - [SQLAuthority News - Community Tech Days - SharePoint Server](https://blog.sqlauthority.com/2010/12/09/sqlauthority-news-community-tech-days-sharepoint-server/): Community Tech Days are very close on December 11. I will be speaking in the following session. Best Database Practice for SharePoint Server. - [SQL SERVER - Installing AdventureWorks for SQL Server](https://blog.sqlauthority.com/2010/12/08/sql-server-installing-adventureworks-for-sql-server-2011/): I just began with SQL Server 2012. The very first thing, I realized that there is no AdventureWorks Sample Database available for Denali. I quickly searched online and reached to Microsoft documentation where it provides information on the how to install (restore) AdventureWorks for SQL Server . - [SQLAuthority News - A Successful Performance Tuning Seminar at Pune - Dec 4-5, 2010](https://blog.sqlauthority.com/2010/12/07/sqlauthority-news-a-successful-performance-tuning-seminar-at-pune-dec-4-5-2010/): This is report to my third of very successful seminar event on SQL Server Performance Tuning. SQL Server Performance Tuning Seminar in Colombo was oversubscribed with total of 35 attendees. You can read the details over hereSQLAuthority News – SQL Server Performance Optimizations Seminar – Grand Success – Colombo, Sri Lanka – Oct 4 – 5, 2010. SQL Server Performance Tuning Seminar in Hyderabad was oversubscribed with total of 25 attendees. You can read the details over here SQL SERVER – A Successful Performance Tuning Seminar – Hyderabad – Nov 27-28, 2010. The same Seminar was offered in Pune on December... - [SQL SERVER - Solution - Challenge - Puzzle - Usage of FAST Hint](https://blog.sqlauthority.com/2010/12/06/sql-server-solution-challenge-puzzle-usage-of-fast-hint/): Earlier I had posted quick puzzle and I had received wonderful response to the same from Brad Schulz. Today we will go over the solution. The puzzle was posted here: SQL SERVER – Challenge – Puzzle – Usage of FAST Hint The question was in what condition the hint FAST will be useful. In the response to this puzzle blog post here is what SQL Server Expert Brad Schulz has pointed me to his blog post where he explain how FAST hint can be useful. I strongly recommend to read his blog post over here. With the permission of the Brad,... - [SQL SERVER - Puzzle - Error While Converting Money to Decimal](https://blog.sqlauthority.com/2010/12/05/sql-server-solution-puzzle-challenge-error-while-converting-money-to-decimal/): Earlier I had posted quick puzzle about Converting Money and I had received a wonderful response to the same. Let us go over the solution. The puzzle was posted here: SQL SERVER – Puzzle – Challenge – Error While Converting Money to Decimal - [SQLAuthority News - Statistics Used by the Query Optimizer in Microsoft SQL Server 2008 - Microsoft Whitepaper](https://blog.sqlauthority.com/2010/12/04/sqlauthority-news-statistics-used-by-the-query-optimizer-in-microsoft-sql-server-2008-microsoft-whitepaper/): I recently presented session on Statistics and Best Practices in Virtual Tech Days on Nov 22, 2010. The sessions was very popular and I got many questions right after the sessions. The number question I had received was where everybody can get the further information. I am very much happy that my sessions created some curiosity for one of the most important feature of the SQL Server. Statistics are the heart of the SQL Server. Let us read about Statistics Used by the Query Optimizer in Microsoft SQL Server 2008. - [SQL SERVER - A Successful Performance Tuning Seminar - Hyderabad - Nov 27-28, 2010 - Next Pune](https://blog.sqlauthority.com/2010/12/03/sql-server-a-successful-performance-tuning-seminar-hyderabad-nov-27-28-2010-next-pune/): My recent SQL Server Performance Tuning Seminar in Colombo was oversubscribed with total of 35 attendees. You can read the details over here SQLAuthority News – SQL Server Performance Optimizations Seminar – Grand Success – Colombo, Sri Lanka – Oct 4 – 5, 2010. I had recently completed another seminar in Hyderabad which was again blazing success. We had 25 attendees to the seminar and had wonderful time together. There is one thing very different between usual class room training and this seminar series. In this seminar series we go 100% demo oriented and real world scenario deep down. We do not... - [SQLAuthority News - Community Tech Days - A SQL Legends in Ahmedabad - December 11, 2010](https://blog.sqlauthority.com/2010/12/02/sqlauthority-news-community-tech-days-a-sql-legends-in-ahmedabad-december-11-2010/): Ahmedabad is going to be fortunate city again on December 11. We are going to have SQL Server Legends present at the prestigious event of Community Tech Days in Ahmedabad. The venue details are as following: H K Hall, H K College Campus, Near Handloom House, Opp. Natraj Cinema, Ashram Road, Ahmedabad – 380009 Click here to Registration for the event. Agenda of the event is as following. 10:15am – 10:30am     Welcome – Pinal Dave 10:30am – 11:15am     SQL Tips and Tricks for .NET Developers by Jacob Sebastian 11:15am – 11:30am     Tea Break 11:30am – 12:15pm     Best... - [SQL SERVER - 3 Simple Puzzles - Need Your Suggestions](https://blog.sqlauthority.com/2010/12/01/sql-server-3-simple-puzzles-need-your-suggestions/): Last Month, I have posted three Simple Puzzles and I got very good response. I think there can be many interesting answers there. I would like to request all of you to take part the puzzles and provide your answer. I plant to consolidate answers and publish all the valid answers on this blog with due credit. SQL SERVER – Challenge – Puzzle – Usage of FAST Hint SQL SERVER – Puzzle – Challenge – Error While Converting Money to Decimal SQL SERVER – Challenge – Puzzle – Why does RIGHT JOIN Exists I am also thinking that after such a... - [SQL SERVER - Automated Type Conversion using Expressor Studio](https://blog.sqlauthority.com/2010/11/30/sql-server-automated-type-conversion-using-expressor-studio/): Recently I had an interesting situation during my consultation project. Let me share to you how I solved the problem using Expressor Studio. Consider a situation in which you need to read a field, such as customer_identifier, from a text file and pass that field into a database table. In the source file’s metadata structure, customer_identifier is described as a string; however, in the target database table, customer_identifier is described as an integer. Legitimately, all the source values for customer_identifier are valid numbers, such as “109380”. To implement this in an ETL application, you probably would have hard-coded a type conversion... - [SQL SERVER - DBA or DBD? - Database Administrator or Database Developer](https://blog.sqlauthority.com/2010/11/29/sql-server-dba-or-dbd-database-administrator-or-database-developer/): Earlier this month, I had poll on this blog where I asked question – Are you a Database Administrator or Database Developer? The word DBA (Database Administrator) is very common but DBD (Database Developer) is not common at all. This made me think – what is the ratio of the same. Here the result of the poll: Database Administrator 36.6% (254 votes) Database Developer 63.4% (440 votes) Total Votes: 694 This is open poll, if you want you can still participate here. Vote your Voice – DBD or DBA? I think it is the time when DBD word for Database Developer... - [SQL SERVER - Challenge - Puzzle - Why does RIGHT JOIN Exists](https://blog.sqlauthority.com/2010/11/28/sql-server-challenge-puzzle-why-does-right-join-exists/): I had interesting conversation with the attendees of the my SQL Server Performance Tuning course. I was asked if LEFT JOIN can do the same task as RIGHT JOIN by reserving the order of the tables in join, why does RIGHT JOIN exists? The definitions are as following: Left Join – select all the records from the LEFT table and then pick up any matching records from the RIGHT table   Right Join – select all the records from the RIGHT table and then pick up any matching records from the LEFT table Most of us read from LEFT to RIGHT... - [SQL SERVER - Puzzle - Challenge - Error While Converting Money to Decimal](https://blog.sqlauthority.com/2010/11/27/sql-server-puzzle-challenge-error-while-converting-money-to-decimal/): Earlier I wrote SQL SERVER – Challenge – Puzzle – Usage of FAST Hint and I did receive some good comments. Here is another question to tease your mind. Run following script and you will see that it will thrown an error. DECLARE @mymoney MONEY; SET @mymoney = 12345.67; SELECT CAST(@mymoney AS DECIMAL(5,2)) MoneyInt; GO The datatype of money is also visually look similar to the decimal, why it would throw following error: Msg 8115, Level 16, State 8, Line 3 Arithmetic overflow error converting money to data type numeric. Please leave a comment with explanation and I will post a your... - [SQL SERVER - Challenge - Puzzle - Usage of FAST Hint](https://blog.sqlauthority.com/2010/11/26/sql-server-challenge-puzzle-usage-of-fast-hint/): I was recently working with various SQL Server Hints. After working for a day on various hints, I realize that for one hint, I am not able to come up with good example. The hint is FAST. Let us look at the definition of the FAST hint from the Book On-Line. FAST number_rows Specifies that the query is optimized for fast retrieval of the first number_rows. This is a nonnegative integer. After the first number_rows are returned, the query continues execution and produces its full result set. Now the question is in what condition this hint can be useful. I have... - [SQL SERVER - Concat Function in SQL Server - SQL Concatenation](https://blog.sqlauthority.com/2010/11/25/sql-server-concat-function-in-sql-server-sql-concatenation/): Earlier this week, I was delivering Advanced BI training on the subject of “SQL Server 2008 R2”. I had a great time delivering the session. During the session, we talked about SQL Server 2012 Denali. Suddenly one of the attendees suggested his displeasure for the product. He said, even though, SQL Server is now in moving very fast and have proved many times a better enterprise solution, it does not have some basic functions. I naturally asked him for an example and he suggested CONCAT() which exists in MySQL and Oracle. The answer is very simple – the equivalent function in... - [SQLAuthority News - What's New in SQL Server "Denali"](https://blog.sqlauthority.com/2010/11/24/sqlauthority-news-whats-new-in-sql-server-denali/): I was today doing SQL Server Advanced Training at Bangalore and I had few attendees asked me if I can give them review of the SQL Server Denali. I had not downloaded Denali on my work computer so I could not do demonstration of the same. However, I promised to blog about with additional details very next day. Denali is also known as SQL 11 and the compatibility mode number is 110. Here are few details about it. What is new in SQL Server “Denali” Download CTP1 Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQLPASS Nov 8-11, 2010-Seattle - An Alternative Look at Experience](https://blog.sqlauthority.com/2010/11/23/sqlauthority-news-sqlpass-nov-8-11-2010-seattle-an-alternative-look-at-experience/): I recently attended most prestigious SQL Server event SQLPASS between Nov 8-11, 2010 at Seattle. I have only one expression for the event – Best Summit Ever This year the summit was at its best. Instead of writing about my usual routine or the event, I am going to write about the interesting things I did and how I felt about it! Trip to Seattle! This was my second trip to Seattle this year and the journey is always long. Here is the travel stats on how long it takes to get to Seattle: 24 hours official air time 36 hours... - [SQLAuthority News - Statistics and Best Practices - Virtual Tech Days - Nov 22, 2010](https://blog.sqlauthority.com/2010/11/22/sqlauthority-news-statistics-and-best-practices-virtual-tech-days-nov-22-2010/): I am honored that I have been invited to speak at Virtual TechDays on Nov 22, 2010 by Microsoft. I will be speaking on my favorite subject of Statistics and Best Practices. This exclusive online event will have 80 deep technical sessions across 3 days – and, attendance is completely FREE. There are dedicated tracks for Architects, Software Developers/Project Managers, Infrastructure Managers/Professionals and Enterprise Developers. So, REGISTER for this exclusive online event TODAY. Statistics and Best Practices Timing: 11:45am-12:45pm Statistics are a key part of getting solid performance. In this session we will go over the basics of the statistics and... - [SQL SERVER - Change Database Access to Single User Mode Using SSMS](https://blog.sqlauthority.com/2010/11/21/sql-server-change-database-access-to-single-user-mode-using-ssms/): I have previously written about how using T-SQL Script we can convert the database access to single user mode before backup. I was recently asked if the same can be done using SQL Server Management Studio. Yes! You can do it from database property (Write click on database and select database property) and follow image. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Book Review - Beginning T-SQL 2008 by Kathi Kellenberger](https://blog.sqlauthority.com/2010/11/20/sqlauthority-news-book-review-beginning-t-sql-2008-by-kathi-kellenberger/): Beginning T-SQL 2008 by Kathi Kellenberger Amazon Link Detail Review: Beginning T-SQL 2008 is one of the best books on the market if you are just beginning to work with Microsoft SQL, or have a little bit of experience and need to learn more quickly. Each chapter of the book introduces a new subject, and builds upon topics covered in previous chapters.  The author of the book, Kathi Kellenberger understands that you need to form a solid foundation of knowledge before moving on to new topics, and sets up each subject nicely.  Because the chapters move in an orderly progression, you... - [SQLAuthority News - Blog Stats Revealed ](https://blog.sqlauthority.com/2010/11/19/sqlauthority-news-blog-stats-revealed/): I often receive praises, questions, suggestions and skeptical emails regarding my blog stats. Let me put everything aside and open up my stats page for all. I use wordpress.com and stats are maintained by them. Every month, I will put the blog stats on the following page for every one’s consumption. View SQLAuthority Stats If you still have question – do ask me :) Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - SQL Server Performance Series Hyderabad / Pune - Nov/Dec 2010](https://blog.sqlauthority.com/2010/11/18/sqlauthority-news-sql-server-performance-series-hyderabad-pune-novdec-2010/): Just a quick note that SQL Server Performance Tuning and Optimizations Seminar series which I am offering at Hyderabad and Pune are almost all sold out. Read the details of the earlier successful seminar conducted at Colombo, Sri Lanka over here. Hyderabad Nov 27-28, 2010 (Last 3 Seats Left) Best Western Amrutha Castle 5-9-16, Opp. Secretriat, Saifabad, Khairatabad Hyderabad, Andhra Pradesh Pune Dec 04-05, 2010 (Last 6 Seats Left) Location TBA as we are looking for larger capacity room. I promise that this is going to be great fun as this sessions are very different then any usual sessions you have... - [SQL SERVER - History of SQL Server Database Encryption](https://blog.sqlauthority.com/2010/11/17/sql-server-history-of-sql-server-database-encryption/): I recently met Michael Coles and Rodeney Landrum the author of one of the kind book Expert SQL Server 2008 Encryption at SQLPASS in Seattle. During the conversation we ended up how Microsoft is evolving encryption technology. The same discussion lead to talking about history of encryption tools in SQL Server. Michale pointed me to page 18 of his book of encryption. He explicitly give me permission to re-produce relevant part of history from his book. Encryption in SQL Server 2000 Built-in cryptographic encryption functionality was nonexistent in SQL Server 2000 and prior versions. In order to get server-side encryption in... - [SQLAuthority News - Download Whitepaper - Understanding and Controlling Parallel Query Processing in SQL Server](https://blog.sqlauthority.com/2010/11/16/sqlauthority-news-download-whitepaper-understanding-and-controlling-parallel-query-processing-in-sql-server/): My recently article SQL SERVER – Reducing CXPACKET Wait Stats for High Transactional Database has received many good comments regarding MAXDOP 1 and MAXDOP 0. I really enjoyed reading the comments as the comments are received from industry leaders and gurus. I was further researching on the subject and I end up on following white paper written by Microsoft. Understanding and Controlling Parallel Query Processing in SQL Server Data warehousing and general reporting applications tend to be CPU intensive because they need to read and process a large number of rows. To facilitate quick data processing for queries that touch a large... - [SQL SERVER - Information Related to DATETIME and DATETIME2](https://blog.sqlauthority.com/2010/11/15/sql-server-information-related-to-datetime-and-datetime2/): I recently received interesting comment on the blog regarding workaround to overcome the precision issue while dealing with DATETIME and DATETIME2. I have written over this subject earlier over here. SQL SERVER – Difference Between GETDATE and SYSDATETIME SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE SQL SERVER – Difference Between DATETIME and DATETIME2 SQL Expert Jing Sheng Zhong has left following comment: The issue you found in SQL server new datetime type is related time source function precision. Folks have found the root reason of the problem – when data time values are converted (implicit or explicit)... - [SQL SERVER – FIX ERROR 3702 Cannot drop database “MyDBName” because it is currently in use](https://blog.sqlauthority.com/2010/11/14/sql-server-error-fix-msg-3702-level-16-state-3-line-1-cannot-drop-database-mydbname-because-it-is-currently-in-use/): I often go to do various seminars and presentations at various organizations. During presentations I often create and drop various databases for the demonstration's purpose. Recently in one of the presentations, I tried to remove my recently created database, I got following error 3702 which is related to user cannot drop database. - [SQL SERVER - Reducing CXPACKET Wait Stats for High Transactional Database](https://blog.sqlauthority.com/2010/11/13/sql-server-reducing-cxpacket-wait-stats-for-high-transactional-database/): While engaging in a performance tuning consultation for a client, a situation occurred where they were facing a lot of CXPACKET Waits Stats. The client asked me if I could help them reduce this huge number of wait stats. I usually receive this kind of request from other client as well, but the important thing to understand is whether this question has any merits or benefits, or not. Before we continue the resolution, let us understand what CXPACKET Wait Stats are. The official definition suggests that CXPACKET Wait Stats occurs when trying to synchronize the query processor exchange iterator. You may... - [SQL SERVER - Get All the Information of Database using sys.databases](https://blog.sqlauthority.com/2010/11/12/sql-server-get-all-the-information-of-database-using-sys-databases/): Earlier I wrote blog article SQL SERVER – Finding Last Backup Time for All Database. In the response of this article I have received very interesting script from SQL Server Expert Matteo as a comment in the blog. He has written script using sys.databases which provides plenty of the information about database. I suggest you can run this on your database and know unknown of your databases as well. SELECT database_id, CONVERT(VARCHAR(25), DB.name) AS dbName, CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, 'status')) AS [Status], state_desc, (SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'rows') AS DataFiles, (SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id)... - [SQLAuthority News - SQL Server Denali CTP1 - Release Date November 9, 2010](https://blog.sqlauthority.com/2010/11/11/sqlauthority-news-sql-server-2011-release-date-november-9-2010/): I am very excited as I was about to witness SQL Server 2011 – Code Named “Denali” is released on November 11, 2010 at SQLPASS. I will write a detail report for the same in future. You can download CTP1 right away right now and install on your machine. The major features of the new products are as following: Enhanced Mission-Critical Platform: an enhanced highly available and scalable platform. Developer and IT Productivity: new innovative productivity tools and features. Pervasive Insight: expanding the reach of BI to business users and end-to-end data integration and management. I am going to download the... - [SQL SERVER - Get Database Backup History for a Single Database](https://blog.sqlauthority.com/2010/11/10/sql-server-get-database-backup-history-for-a-single-database/): I recently wrote article SQL SERVER – Finding Last Backup Time for All Database and requested blog readers to respond with their own script which they use it Database Backup. Here is the script suggested by SQL Expert aasim abdullah, who has written excellent script which goes back and retrieves the history of any single database. USE AdventureWorks GO -- Get Backup History for required database SELECT TOP 100 s.database_name, m.physical_device_name, CAST(CAST(s.backup_size / 1000000 AS INT) AS VARCHAR(14)) + ' ' + 'MB' AS bkSize, CAST(DATEDIFF(second, s.backup_start_date, s.backup_finish_date) AS VARCHAR(4)) + ' ' + 'Seconds' TimeTaken, s.backup_start_date, CAST(s.first_lsn AS VARCHAR(50)) AS... - [SQL SERVER - Recycle Error Log - Create New Log file without Server Restart](https://blog.sqlauthority.com/2010/11/09/sql-server-recycle-error-log-create-new-log-file-without-server-restart/): The job of a consultant is always interesting – sometimes one becomes very busy and at times, over busy. I have been overwhelmed with recent performance tuning engagements. In one of the recent engagements, a large number of errors were found in the server. I noticed that their error log filled up very quickly. I also noticed a very interesting action by their DBA. I observed that after we make some changes in the server to avoid the errors, the DBA restarted the server. I asked him the reason for doing so. He explained every time that when he restarts the server, a new error log file is created. The current log file is renamed as errorlog.1; errorlog.1 becomes errorlog.2, and in a similar way, it continues. This way, after making some change, we can watch the error file from the beginning. - [SQLAuthority News – Why I am Going to Attend PASS Summit Unite 2010 – Seattle](https://blog.sqlauthority.com/2010/11/08/sqlauthority-news-why-i-am-going-to-attend-pass-summit-unite-2010-seattle/): I am once again attending SQLPASS this year.When I told this to my friend that I am going to SQL PASS again, he has the same question, which quite often many people ask. WHY? I had earlier wrote article on this subject. I am writing it again the same. The reason is simple – I love it! Why should I attend PASS Summit There is not one or two but a number of reasons regarding why I should be a part of PASS Summit. First, it is a good platform to learn the latest skills and strategies through over 160 expert-led... - [SQLAuthority News – Presenting at South East Asia SharePoint Conference – Oct 26, 27, 2010 – Singapore](https://blog.sqlauthority.com/2010/11/07/sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference/): Every SharePoint site runs on SQL Server and most of the SharePoint sites face issues with performance due to suboptimal configuration of underlying SQL Server. Recently, I presented a session on SharePoint and SQL Server Performance at Singapore on Oct 26-27, 2010. It was South East Asia SharePoint Conference, and I must say, the event was a blast! Pinal Dave presenting at SharePoint Conference at Singapore This was very a unique event in Asian Sub-Continent and also one of the best managed conferences that I have attended thus far. The location of the event was very good, and the rooms were... - [SQLAuthority News - Last Day to Participate in my Questions at SQL Quiz](https://blog.sqlauthority.com/2010/11/06/sqlauthority-news-last-day-to-participate-in-my-questions-at-sql-quiz/): My very good friend, Jacob Sebastian, is running a month-long SQL Quiz Series where the best-of-the-best experts from around the globe would be the quiz masters. They will ask one question every day, and users are expected to answer them correctly. The winning prizes include cool gadgets like iPAD, Kindle and many more. I am one of the quiz masters, and my question is published here: The View, The Table and The Clustered Index Confusion. I have asked there three questions. Q1. Does the table use an index created on itself? Q2. Does the view use an index created on itself?... - [SQLAuthority News - Happy Deepavali and Happy News Year](https://blog.sqlauthority.com/2010/11/05/sqlauthority-news-happy-deepavali-and-happy-news-year/): Diwali (also spelled Divali in other countries) or Deepavali is popularly known as the festival of lights. It literally means “array of light”. Diwali is the most important festival of the year and is celebrated with families performing traditional activities together in their homes. Deepavali is an official holiday in India. I pretty much work every day except today. I dedicate this day to my family. This is their day. Every year on Deepavali I share a database tips with all of my blog readers. I quite often get ask if I can help people with their systems performance. I am... - [SQL SERVER - Finding Last Backup Time for All Database](https://blog.sqlauthority.com/2010/11/04/sql-server-finding-last-backup-time-for-all-database/): Here is the quick script I use find last backup time for all the database in my server instance. - [SQL SERVER - Fix: Error: MS Jet OLEDB 4.0 cannot be used for distributed queries because the provider is used to run in apartment mode.](https://blog.sqlauthority.com/2010/11/03/sql-server-fix-error-ms-jet-oledb-4-0-cannot-be-used-for-distributed-queries-because-the-provider-is-used-to-run-in-apartment-mode/): I recently got email from blog reader with following error. MS Jet OLEDB 4.0 cannot be used for distributed queries because the provider is used to run in apartment mode. The fix of the same is very easy. Fix/Workaround/Resolution: sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ad Hoc Distributed Queries', 1; GO RECONFIGURE; GO If you are still facing the error after running above statement please leave a comment here and I will do my best to help you out. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - Are you a Database Administrator or a Database Developer?](https://blog.sqlauthority.com/2010/11/02/sql-server-are-you-a-database-administrator-or-a-database-developer/): This blog post is written in response to T-SQL Tuesday hosted by Paul Randal. I think following questions has been always very interesting question for everybody who is working with SQL Server. Are you a Database Administrator or Database Developer? The answer of this question varies from organizations to organizations and to countries to countries. Quite often I see people call them developer and doing tasks of backup and restore of the database. Often I see Administrator writing efficient code in application development. I totally understand that it is almost impossible to draw a line and quite often we are comfortable... - [SQLAuthority News - 4th Birthday of Blog - 20 Million Views - Blog Anniversary - A Milestone](https://blog.sqlauthority.com/2010/11/01/sqlauthority-news-4th-birthday-of-blog-blog-anniversary-a-milestone/): Today is Nov 1, 2010. Four years ago, on the same day of the year 2006,  I wrote my first blog without thinking or even understanding where this blog was going to. The reason I started blogging was very simple- I just wanted to keep a note of what I learn every day. It was really that simple. This blog also have completed 20 Million Views! I will post a detail statistics very soon in separate post. Today is this blog’s 4th birthday. It has completed the long journey of 4 years. I previously explained the reason of the origin of... - [SQLAuthority News – New Banner of Blog](https://blog.sqlauthority.com/2010/10/31/sqlauthority-news-new-banner-of-blog/): As this blog is approaching 4th anniversary, I have decided to change few things in this blog. I have finally decided to change the blog banner and I have created internal poll for the blog banner. I have uploaded the winning banner as the title of the blog and I liked it a lot. I would like to know your opinion about the same. The changes I have done from the previous banners are Bigger Images Bigger Logo A cleaning up edges Please visit the site https://blog.sqlauthority.com/ and give me your opinion about banner. Reference: Pinal Dave (https://blog.sqlauthority.com)   - [SQL SERVER - Minimum Maximum Memory - Server Memory Options](https://blog.sqlauthority.com/2010/10/30/sql-server-minimum-maximum-memory-server-memory-options/): I was recently reading about SQL Server Memory Options over here. While reading this one line really caught my attention is minimum value allowed for maximum memory options. The default setting for min server memory is 0, and the default setting for max server memory is 2147483647. The minimum amount of memory you can specify for max server memory is 16 megabytes (MB). This was very interesting to me as I was not familiar with this details. This was one interesting detail for me. In reality I will never set up my max server memory to 16 MB, it will be right... - [SQL SERVER - List of all the Views from Database](https://blog.sqlauthority.com/2010/10/29/sql-server-list-of-all-the-views-from-database/): My earlier article SQL SERVER – The Limitations of the Views – Eleven and more… has lots of popularity and I have been asked many questions on the view. Many emails I received suggesting that they have hundreds of the view and now have no clue what is going on and how many of them have indexes and how many does not have an index. Some even asked me if there is any way they can get a list of the views with the property of Index along with it. - [SQLAuthority News – Blog of Nupur Dave on Windows Live](https://blog.sqlauthority.com/2010/10/28/sqlauthority-news-blog-of-nupur-dave-on-windows-live/): Blog are way to express ourselves; Blogs are bookmarks of my learning process and blogs reflects us. My Wife Nupur, an avid user of Windows Live, has decided to start blogging on the subject. There was lots of discussion between us regarding if she really wants to blog or keep her learning offline. One of the discussions we had was regarding what new she can add to the world which is already populated and overloaded with information. Her answer was very simple: “My perspective“. I respect her for the same and that is why she is blogging now. The blog is just... - [SQL SERVER - SQL Challenge - SQL Puzzle - Query Creating Most TempDB IO Usage](https://blog.sqlauthority.com/2010/10/27/sql-server-sql-challenge-sql-puzzle-query-creating-most-tempdb-io-usage/): Recently, there have been a lot of interesting concepts in various challenges. My friend Jacob Sebastian is running the SQLQuiz for the entire month, and it has been very popular and going just great. So here I thought I would put something very similar to the quiz bee. The award here is simple, all valid answers will be published on this blog with due credit to you, plus the credit would link back to your desired profile. Now the question is: What are the queries which are creating lots of IO operations in TempDB? You can use any DMV to answer... - [SQLAuthority News - Database Performance for SharePoint Sites - Session Tomorrow in Singapore](https://blog.sqlauthority.com/2010/10/26/sqlauthority-news-database-performance-for-sharepoint-sites-session-tomorrow-in-singapore/): I am all excited to present my very first session on Database Performance for SharePoint Sites. Here is the details for my session which is planned for tomorrow. Grand Copthorne Waterfront Hotel Singapore 392 Havelock Road Singapore 169663 My Sessions details: Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site! Date: Oct 27, 2010 Time: 1:30 PM Venue: Grand Copthorne Waterfront Hotel (Waterfront Conference Centre) During the session I will be presenting three demos. I have worked hard to come up with this demos. Here is the details for the same. SQLAuthority News – SQLAuthority News – Presenting at... - [SQL SERVER – A Brief Introduction to DW 2.0](https://blog.sqlauthority.com/2010/10/25/sql-server-a-brief-introduction-to-dw-2-0/): The traditional form of storing digital data has been disk storage.  However, the huge advances in technology means that there has been a huge need for data storage to evolve to keep up with the fast-changing times.  Microsoft SQL Server has gone through a huge overhaul in order to keep up with the amount of data storage that is necessary, and that is where data warehousing comes into play. For many online applications, there is a need to not only access small amount of information from disk storage, but large amounts in the forms of sets.  SQL Server allows access to... - [SQL SERVER - Corrupted Backup File and Unsuccessful Restore](https://blog.sqlauthority.com/2010/10/24/sql-server-corrupted-backup-file-and-unsuccessful-restore/): If you are an SQL Server Consultant, there is never a single dull moment in your life. Quite often you are called in for fixing something, but then you always end up fixing something else! I was recently working on an offshore project where I was called in to tune high transaction OLTP server. During work, I demanded that I should have a server which is very similar to live database so I could inspect all the settings and data. I may end up running a few queries which may or may not change the server settings. The Sr. DBA agreed... - [SQL SERVER - Taking Multiple Backup of Database in Single Command - Mirrored Database Backup](https://blog.sqlauthority.com/2010/10/23/sql-server-taking-multiple-backup-of-database-in-single-command-mirrored-database-backup/): I recently had a very interesting experience. In one of my recent consultancy works, I was told by our client that they are going to take the backup of the database and will also a copy of it at the same time. I expressed that it was surely possible if they were going to use a mirror command. In addition, they told me that whenever they take two copies of the database, the size of the database, is always reduced. Now this was something not clear to me, I said it was not possible and so I asked them to show... - [SQLAuthority News – SQLAuthority News – Presenting at South East Asia SharePoint Conference – Demo Details](https://blog.sqlauthority.com/2010/10/22/sqlauthority-news-sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference-demo-details/): I will be Presenting at South East Asia SharePoint Conference – Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site. I am very excited beuse this is going to be my very first series of presentations at SharePoint Conference. Since I posted details about the event, I have been asked many times about the kind of demo I will be having in the session. If you are a regular reader of this blog, you know that my core area is performance tuning. I am going to focus on the same subject when I present at the SharePoint Conference. I... - [SQLAuthority News - Book Review - Beginning SQL Joes 2 Pros: The SQL Hands-On Guide for Beginners](https://blog.sqlauthority.com/2010/10/21/sqlauthority-news-book-review-beginning-sql-joes-2-pros-the-sql-hands-on-guide-for-beginners/): Beginning SQL Joes 2 Pros: The SQL Hands-On Guide for Beginners Rick A Morelan, Doug Fritz Link to Amazon Short Review: This is one book that provides a solid fundamental to the reader along with hands-on experience  and in-depth learning. Right now, an error-free book that is closer to real world scenarios is very much in need. This one fundamental book can take the reader for a wonderful ride, where he/she can learn the advanced aspects of the subject very quickly. Instead of pure theory, this book focuses on real diagrams, examples or just a pure old–school-style exercise, which appeals the... - [SQL SERVER – Could not connect to TCP error code 10061: No connection could be made because the target machine actively refused it](https://blog.sqlauthority.com/2010/10/20/sql-server-could-not-connect-to-tcp-error-code-10061-no-connection-could-be-made-because-the-target-machine-actively-refused-it/): I was recently getting following error in my StreamInsight Application. Could not connect to  TCP error code 10061: No connection could be made because the target machine actively refused it. The solution was very simple, I had to enable exception of the my port in my windows firewall. The way I figured it out  was by quickly disabling the firewall (it was not a production server). Once I disabled it, the application just worked fine; this was a sign that the firewall was the cause of the issue, I right away enabled firewall and added my port as exception. So many... - [SQLAuthority News - SQL Server Performance Optimizations Seminar - Grand Success - Colombo, Sri Lanka - Oct 4 - 5, 2010](https://blog.sqlauthority.com/2010/10/19/sqlauthority-news-sql-server-performance-optimizations-seminar-grand-success-colombo-sri-lanka-oct-4-5-2010/): I have been on world tour on SQL Server Performance Optimizations Seminar. The latest seminar was conducted in Colombo, Sri Lanka on Oct 4 – Oct 5. I had previously written about this event over SQLAuthority News – SQL Server Seminar at Colombo Full. This event was oversubscribed and we could not accommodate the last few nominations due to the restrictions of the place. We had total of 35 attendees and the event offered lots of fun. The attendees were a perfect combination – all had few years of experience and many of them were responsible for performance for their server.... - [SQL SERVER - Change Column DataTypes](https://blog.sqlauthority.com/2010/10/18/sql-server-change-column-datatypes/): There are times when I feel like writing that I am a day older in SQL Server. In fact, there are many who are looking for a solution that is simple enough. Have you ever searched online for something very simple. I often do and enjoy doing things which are straight forward and easy for change. In this blog post, we will see to Change Column DataTypes - [SQL SERVER - System Stored Procedure sys.sp_tables](https://blog.sqlauthority.com/2010/10/17/sql-server-system-stored-procedure-sys-sp_tables/): I have seen people running the following script quite often, to know the list of the tables from the database: SELECT * FROM sys.tables GO The script above provides various information from create date to file stream, and many other important information. If you need all those information, that script is the one for you. However, if you do not need all those information, I suggest that you run the following script: EXEC sys.sp_tables GO The script above will give all the tables in the table with schema name and qualifiers. Additionally, this will return all the system catalog views together... - [SQL SERVER - StreamInsight and SQL Server 2008 R2](https://blog.sqlauthority.com/2010/10/16/sql-server-streaminsight-and-sql-server-2008-r2/): I was recently called into create POC (Proof of Concept) for a project which was being planned for use StreamInsight. When I was there, I was also asked to give overview of the this feature to their CTO (who had only 15 minutes to spare). Usually I do not like sudden change of plans but the dynamic nature of consultation always gives me motivation to work more. I quickly talked few things in the session. In the evening, I had received the minutes of the meeting and had brief note regarding my discussion on StreamInsight. I am copy pasting the same brief note over here. - [SQLAuthority News – Microsoft WhitePaper on PowerPivot Data Refresh](https://blog.sqlauthority.com/2010/10/15/sqlauthority-news-microsoft-whitepaper-on-powerpivot-data-refresh/): I was recently working at customer location on PowerPivot project. It was quite complected as this is relatively new technology and we all are exploring what this technology can do and what it can bring to us on table in real life experience. During this implementation the project design document needed specification regarding Data Refresh rates. It was a bit complected as there were various components and modules to the project and selecting the refresh rates means understand all of the requirement as well understanding our implementation in and out. I referred following white paper from Microsoft before I move further... - [SQL SERVER - 1500 Posts - A MileStone - Origin of Blog Name Revealed](https://blog.sqlauthority.com/2010/10/14/sql-server-1500-posts-a-milestone-original-of-blog-name-revealed/): This is my 1500th blog post. I am very happy. In my earlier 1400th blog post mile stone, I made a promise that I would explain why I have chosen SQLAuthority.com as my blog’s name. Let me share with you the story about how I came up with the name. In my earlier career days, I was used to code in ColdFusion programming language, and there was a site called Fusion Authority. I was always referring to it whenever I had to get any latest details of the subject. The name inspired me so I started checking out if there were... - [SQL SERVER - Visiting Alma Mater - Delivering Session on Database Performance and Career - Nirma Institute of Technology](https://blog.sqlauthority.com/2010/10/13/sql-server-visiting-alma-mater-delivering-session-on-database-performance-and-career-nirma-institute-of-technology/): Everyone always dream of visiting their school and college, where they have had studied once. It is a great feeling to see the college once again – where you have spent the wonderful golden years of your time. College time is filled with studies, education, emotions and several plans to build future. I consider myself fortunate as I got the opportunity to study at some of the best places in the world. I have earned my Bachelors in Engineering in Electronics and Communication from Nirma Institute of the Technology (NIT), Ahmedabad, India. I must say that this is one of the... - [SQL SERVER - Indexed View always Use Index on Table](https://blog.sqlauthority.com/2010/10/12/sql-server-indexed-view-always-use-index-on-index/): This blog post is written in response to T-SQL Tuesday hosted by Shankar Reddy. I have been recently writing about Views and their Limitations. While writing this article series, I got inspired to write about SQL Server Quiz Questions. You can view the Quiz Question posted over here. In SQL Server 2005, a single table can have maximum 249 non clustered indexes and 1 clustered index. In SQL Server 2008, a single table can have maximum 999 non clustered indexes and 1 clustered index. It is widely believed that a table can have only 1 clustered index, and this belief is... - [SQLAuthority News - Presenting at South East Asia SharePoint Conference - Maintaining SQL Server at Optimal Performance for Blazing Fast SharePoint Site](https://blog.sqlauthority.com/2010/10/11/sqlauthority-news-presenting-at-south-east-asia-sharepoint-conference-maintaining-sql-server-at-optimal-performance-for-blazing-fast-sharepoint-site/): I am delighted and very excited as I am going to attend very first time SharePoint Conference. Even though I will be attending SP conference, I will be presenting on my favorite subject – SQL Server Performance. Every SharePoint site runs on SQL Server and most of the SharePoint sites face issues with performance due to suboptimal configuration of underlying SQL Server. This session will be very unique. I will be starting with a bit pessimistic talk about how one cannot many things in SQL Server when SharePoint Server is installed. I will go over in the details for the reasons... - [SQL SERVER - Encrypted Stored Procedure and Activity Monitor](https://blog.sqlauthority.com/2010/10/10/sql-server-encrypted-stored-procedure-and-activity-monitor/): I recently had received question if any stored procedure is encrypted can we see its definition in Activity Monitor. - [SQLAuthority News - SQL Server 2008 Add-ins and Feature Pack Downloads](https://blog.sqlauthority.com/2010/10/09/sqlauthority-news-sql-server-2008-add-ins-and-feature-pack-downloads/): Here are few of the latest Microsoft Add-ins and downloads recently announced. SQL Server Reporting Services Add-in for SharePoint Technologies The Microsoft SQL Server 2008 SP2 Reporting Services Add-in for Microsoft SharePoint Technologies is a Web download that provides features for running a report server within a larger deployment of Windows SharePoint Services 3.0 or Microsoft Office SharePoint Server 2007. SQL Server Data Mining Add-ins for Office 2007 Download SQL Server 2008 Data Mining Add-ins for Office 2007. This package includes two add-ins for Microsoft Office Excel 2007 (Table Analysis Tools and Data Mining Client) and one add-in for Microsoft Office... - [SQL SERVER - Simple Explanation of Data Type Precedence](https://blog.sqlauthority.com/2010/10/08/sql-server-simple-explanation-of-data-type-precedence/): While I was working on creating a question for SQL SERVER – SQL Quiz – The View, The Table and The Clustered Index Confusion, I had actually created yet another question along with this question. However, I felt that the one which is posted on the SQL Quiz is much better than this one because what makes that question more challenging is that it has a multiple answer. Here is the question regarding Simple Explanation of Data Type Precedence: Run the following example first and then observe the query execution plan. USE tempdb GO CREATE TABLE FirstTable (ID INT, Col VARCHAR(100))... - [SQL SERVER - SQL Quiz - The View, The Table and The Clustered Index Confusion](https://blog.sqlauthority.com/2010/10/07/sql-server-sql-quiz-the-view-the-table-and-the-clustered-index-confusion/): My very good friend, Jacob Sebastian, is running a month-long SQL Quiz Series where the best-of-the-best experts from around the globe would be the quiz masters. They will ask one question every day, and users are expected to answer them correctly. The winning prizes include cool gadgets like iPAD, Kindle and many more. I am one of the quiz masters, and my question is published here: The View, The Table and The Clustered Index Confusion. I have asked there three questions. However, the real important question is: Bonus Question: Does this mean that my table has two effective clustered indexes now?... - [SQL SERVER – Quickest Way to Identify Blocking Query and Resolution – Dirty Solution](https://blog.sqlauthority.com/2010/10/06/sql-server-quickest-way-to-identify-blocking-query-and-resolution-dirty-solution/): As the title suggests, this is quite a dirty solution; it’s not as elegant as you expect. The Story: I got a phone call at night (11 PM) from one of my old friends, requesting a hand. He asked me if I could help him with a very strange situation. He was facing a condition where he was not able to delete data from a table. He already tried to TRUNCATE, DELETE and DROP on the table, but still no luck. I demanded him to let me access it; however, he had to say “No” due to security reasons. Even though... - [SQL SERVER - Error : Fix : Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file failed with the operating system error 2(The system cannot find the file specified.)](https://blog.sqlauthority.com/2010/10/05/sql-server-error-fix-msg-5133-level-16-state-1-line-2-directory-lookup-for-the-file-failed-with-the-operating-system-error-2the-system-cannot-find-the-file-specified/): I recently got email from friend who had suffered from following error. Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.). Msg 1802, Level 16, State 1, Line 2 CREATE DATABASE failed. Some file names listed could not be created. Check related errors. Msg 5133, Level 16, State 1, Line 2 Directory lookup for the file “filepath” failed with the operating system error 2(The system cannot find the file specified.). Msg 1802, Level 16, State 1, Line 2 CREATE DATABASE failed. Some file... - [SQL SERVER - Find Total Number of Transactions on Interval](https://blog.sqlauthority.com/2010/10/04/sql-server-find-total-number-of-transaction-on-interval/): In one of my recent Performance Tuning assignment I was asked how do someone know how many transactions are happening on server during certain interval. I had handy script for the same. Following script displays transactions happened on server at the interval of one minute. You can change the WAITFOR DELAY to any other interval and it should work. - [SQL SERVER - The Limitations of the Views - Eleven and more...](https://blog.sqlauthority.com/2010/10/03/sql-server-the-limitations-of-the-views-eleven-and-more/): I had earlier written, interesting article series on the limitations of the views. I had a great time writing this series. I got many many requests. - [SQLAuthority News - SQL Server Seminar at Colombo Full - Hyderabad Few Seats Available](https://blog.sqlauthority.com/2010/10/02/sqlauthority-news-sql-server-seminar-at-colombo-full-hyderabad-few-seats-available/): If you are familiar with my blog, you might be aware of that I am doing world-wide seminar on SQL Server Seminars. I have lots of request to do the event in various cities, now our plan is very simple and to do this in very few cities. Our current seminar at Colombo is sold out and we have 40 confirmed registrations over 35 available spaces. We have also waiting list of the 10 students and we will see if we can accommodate the same. I have received many request from India for the same seminar, here is the quick update... - [SQL SERVER – Get Query Running in Session](https://blog.sqlauthority.com/2010/10/01/sql-server-get-query-running-in-session/): I was recently looking for syntax where I needed a query running in any particular session. I always remembered the syntax and ha d actually written it down before, but somehow it was not coming to mind quickly this time. I searched online and I ended up on my own article written last year SQL SERVER – Get Last Running Query Based on SPID. I felt that I am getting old because I forgot this really simple syntax. This post is a refresher to me. I knew it was something so familiar since I have used this syntax so many times... - [SQL SERVER - Microsoft SQL Server 2008 Service Pack 2 Download](https://blog.sqlauthority.com/2010/09/30/sql-server-microsoft-sql-server-2008-service-pack-2-download/): Microsoft SQL Server 2008 Service Pack 2 (SP2) is now available for download. You can download your preferred version from link here. The major enhancements are as following: 15K partitioning Improvement. Reporting Services in SharePoint Integrated Mode. SQL Server 2008 R2 Application and Multi-Server Management Compatibility with SQL Server 2008. SQL Server 2008 Instance Management. Data-tier Application (DAC) Support. Reference: Pinal Dave (https://blog.sqlauthority.com) - [SQLAuthority News - Monthly Roundup of SQLAuthority Blog Posts](https://blog.sqlauthority.com/2010/09/30/sqlauthority-news-monthly-roundup-of-sqlauthority-blog-posts/): Since I started the monthly round up of the blog post, I have received many positive feedback. I plan to continue doing this month refresher every month now. This rounds ups are my mirror and informs me what I have been doing whole month. Here is quick look at the last month. The month started very interesting with my daughter’s birthday SQLAuthority News – Fathers and Daughters. As this was very first birthday it was very special for me. I had great time enjoying with her quality time and it was all fun. I am an MVP and I am one... - [SQL SERVER - View Over the View Not Possible with Index View - Limitations of the View 11](https://blog.sqlauthority.com/2010/09/29/sql-server-view-over-the-view-not-possible-with-index-view-limitations-of-the-view-11/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… When I wrote the article about SQL SERVER – Adding Column is Expensive by Joining Table Outside View – Limitation of the Views Part 2, I had received a comment that said: “If joining column is expensive to the view, why can’t I create a view over the view and create an index on it?” The answer is simple: It’s actually another limitation of the View. You cannot create an Index on a nested View situation. The following example where... - [SQLAuthority News - SQL Health Check and SQL Seminars](https://blog.sqlauthority.com/2010/09/28/sqlauthority-news-sql-health-check-and-sql-seminars/): After announcing the SQL Seminar series and SQL Health Check series, there has been a great response from them. I already have signed up assignments until December 2010 Mid Week for doing various health checks for different organizations. One thing that I noticed is that there’s something common and popular in many  health check services– the Wait Stats. SQL Server Resource Wait Stats Analysis Wait Stat Analysis is very crucial for optimizing databases, but it is often overlooked due to lack of understanding. We perform advanced resource Wait Statistics Analysis and provide you with suggestions to optimize your database server. We... - [SQL SERVER - Keywords View Definition Must Not Contain for Indexed View - Limitation of the View 10](https://blog.sqlauthority.com/2010/09/27/sql-server-keywords-view-definition-must-not-contain-for-indexed-view-limitation-of-the-view-10/): I have recently written many articles on the limitation of the views. I have tried to sum up all the keywords which are not allowed in the indexed view. - [SQL SERVER – SELF JOIN Not Allowed in Indexed View – Limitation of the View 9](https://blog.sqlauthority.com/2010/09/26/sql-server-self-join-not-allowed-in-indexed-view-limitation-of-the-view-9/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… Previously, I wrote an article about SQL SERVER – The Self Join – Inner Join and Outer Join, and that blog post seems very popular because of its interesting points. It is quite common to think that Self Join is also only Inner Join, but the reality is that it can be anything. The concept of Self Join is very useful that we use it quite often in our coding. However, this is not allowed... - [SQL SERVER – Get Numeric Value From Alpha Numeric String – Get Numbers Only](https://blog.sqlauthority.com/2010/09/25/sql-server-get-numeric-value-from-alpha-numeric-string-get-numbers-only/): I have earlier wrote article about SQL SERVER – Get Numeric Value From Alpha Numeric String – UDF for Get Numeric Numbers Only and it was very handy tool for me. Recently blog reader and SQL Expert Christofer has left excellent improvement to this logic. Here is his contribution. He has provided Stored Procedure and the same can be easily converted to Function. CREATE PROCEDURE [dbo].[CleanDataFromAlpha] @alpha VARCHAR(50), @decimal DECIMAL(14, 5) OUTPUT AS BEGIN SET NOCOUNT ON; DECLARE @ErrorMsg VARCHAR(50) DECLARE @Pos INT DECLARE @CommaPos INT DECLARE @ZeroExists INT DECLARE @alphaReverse VARCHAR(50) DECLARE @NumPos INT DECLARE @Len INT -- 1 Reverse... - [SQL SERVER - Outer Join Not Allowed in Indexed Views - Limitation of the View 8](https://blog.sqlauthority.com/2010/09/24/sql-server-outer-join-not-allowed-in-indexed-views-limitation-of-the-view-8/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… This blog post was previously published over here. I am republishing it in the series Limitation of the Views with a few modifications. While reading the white paper Improving Performance with SQL Server 2008 Indexed Views, I noticed that it says outer joins are NOT allowed in the indexed views. Here, I have created an example to demonstrate why this is so. Rows can logically disappear from an Indexed View based on OUTER JOIN when... - [SQL SERVER - Cross Database Queries Not Allowed in Indexed View - Limitation of the View 7](https://blog.sqlauthority.com/2010/09/23/sql-server-cross-database-queries-not-allowed-in-indexed-view-limitation-of-the-view-7/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… One of the requirements of Indexed View is that it has to be created ‘WITH SCHEMABINDING’. If the View is not created with that clause, it would not let you create an index on that View. Moreover, if you try to create a View with schemabinding, it would not allow you to create the database. -- Create DB USE MASTER GO CREATE DATABASE TEST1 CREATE DATABASE TEST2 GO -- Table1 USE Test1 GO CREATE TABLE... - [SQL SERVER - UNION Not Allowed but OR Allowed in Index View - Limitation of the View 6](https://blog.sqlauthority.com/2010/09/22/sql-server-union-not-allowed-but-or-allowed-in-index-view-limitation-of-the-view-6/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… If you want to create an Indexed View, you ought to know that UNION Operation is not allowed in Indexed View. It is quite surprising at times when the UNION operation looks very innocent and seems that it cannot be used in the View. Before an in-depth understanding this subject, let me show you a script where UNION is not allowed in Indexed View: USE tempdb GO IF EXISTS (SELECT * FROM sys.views WHERE OBJECT_ID =... - [SQL SERVER - COUNT(*) Not Allowed but COUNT_BIG(*) Allowed - Limitation of the View 5](https://blog.sqlauthority.com/2010/09/21/sql-server-count-not-allowed-but-count_big-allowed-limitation-of-the-view-5/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… One of the most prominent limitations of the View it is that it does not support COUNT(*); however, it can support COUNT_BIG(*) operator. In the following case, you see that if View has COUNT (*) in it already, it cannot have a clustered index on it. On the other hand, a similar index would be created if we change the COUNT (*) to COUNT_BIG (*).For an easier understanding of this topic, let us see the... - [SQL SERVER - How to Stop Growing Log File Too Big](https://blog.sqlauthority.com/2010/09/20/sql-server-how-to-stop-growing-log-file-too-big/): I was recently engaged in Performance Tuning Engagement in Singapore. The organization had a huge database and had more than a million transactions every hour. During the assignment, I noticed that they were truncating the transactions log. This really alarmed me so I informed them this should not be continued anymore because there’s really no need of truncating or shortening the database log. The reason why they were truncating the database log was that it was growing too big and they wanted to manage its large size. I provided two different solutions for them. Now let’s venture more on these solutions.... - [SQL SERVER - SSRS 2008 R2 - MapGallery - World Map](https://blog.sqlauthority.com/2010/09/19/sql-server/): SQL Server 2008 R2 has negatively integrated ability to work with maps. There are few ways how one can select map and use them in their projects. The one I recently came across was MapGallery. By default SQL Server 2008 R2 is enabled for USA maps. This is quite a common request from developers around the globe that they want the same feature available in their own country. - [SQL SERVER - 2008 R2 - PowerPivot for Microsoft Excel 2010 - RTM](https://blog.sqlauthority.com/2010/09/18/sql-server-2008-r2-powerpivot-for-microsoft-excel-2010-rtm/): Microsoft PowerPivot for Microsoft Excel 2010 provides ground-breaking technology, such as fast manipulation of large data sets (often millions of rows), streamlined integration of data, and the ability to effortlessly share your analysis through Microsoft SharePoint 2010. I have recently started to work with SQL Server 2008 R2 and find the product extremely stable and feature complete. I have installed PowerPivot and I am finding it to be also integrating very well with the product. I recently did one presentations using this two technology and worked very well. Let me know if you are using PowerPivot for your power BI users.... - [SQLAuthority News - How to Subscribe to this Blog?](https://blog.sqlauthority.com/2010/09/17/sqlauthority-news-how-to-subscribe-to-this-blog/): How do I subscribe to this blog? I have received this question quite a few times, and have answered them accordingly. As we all know, blogs are part of a social network, and the whole social networking thing is very interesting as everything in it is interwoven together. Let us see in how many different ways you can stay connected with this blog. 1. Email Subscription. If you go to the home page of this blog and scroll down a bit, you will see the following image. Simply enter your email address where you wish to receive notifications of new blog... - [SQLAuthority News - What is an MVP? - How to become an MVP?](https://blog.sqlauthority.com/2010/09/16/sqlauthority-news-what-is-an-mvp-how-to-become-an-mvp/): There are a lot of basic questions I get that inquires about being an MVP. - [SQL SERVER – SELECT * and Adding Column Issue in View – Limitation of the View 4](https://blog.sqlauthority.com/2010/09/15/sql-server-select-and-adding-column-issue-in-view-limitation-of-the-view%c2%a04/): Update: Please read the summary post of all the 11 Limitations of the view SQL SERVER – The Limitations of the Views – Eleven and more… - [SQL SERVER - Disabled Index and Index Levels and B-Tree](https://blog.sqlauthority.com/2010/09/14/sql-server-disabled-index-and-index-levels-and-b-tree/): This blog post is written in response to T-SQL Tuesday hosted by Michael J. Swart. Recently, I presented a session at the Microsoft Bangalore office. Everybody eagerly wanted to learn more, to the extent that they wanted a mentor to train each of them in order to move on to the next level. I have many mentors worldwide as I keep on traveling, in addition to being already a part of Solid Quality Mentors. However, if I have to take one name in India, I will take the name of Vinod Kumar, who has given me many insights and helped me... - [SQL SERVER - What are Wait Types, Wait Stats and its Importance](https://blog.sqlauthority.com/2010/09/13/sql-server-what-are-wait-types-wait-stats-and-its-importance/): Earlier last month Solid Quality India announced SQL Server Health Check Service and since then, it has got very good response from the industry. However, the only question we are be asked all the time is: “What is “SQL Server Resource Wait Stats Analysis” and how can it be useful?”What caught my attention is that it seems everyone understood what the other details on the page mean, but most of them have a query regarding Wait Stats and their importance. For such a long time, even I wasn’t sure what Wait Stats are. Later on, I learned Wait Stats from Andrew... - [SQL SERVER - Soft Delete Conversation - Your Opinion Needed](https://blog.sqlauthority.com/2010/09/12/sql-server-soft-delete-conversation-your-opinion-needed/): Last Week I wrote article about SQL SERVER – Soft Delete – IsDelete Column – Your Opinion and this article has got excellent community response. There have been some very interesting feedback on both the side. There are few opinions where expert have explained the conversation very balanced way. I am listing today here few of the conversations. You are welcome to provide further input on the same subject. I am listening here only abstract of the comment, click on the name to read the complete comment. jonmcrawford – She has very first very good explanation and votes for no, suggesting... - [SQLAuthority News - Download - Microsoft SQL Server 2008 R2 Best Practices Analyzer Whitepaper](https://blog.sqlauthority.com/2010/09/11/sqlauthority-news-download-microsoft-sql-server-2008-r2-best-practices-analyzer-whitepaper/): I had previously written article on SQL SERVER – Introduction to Best Practices Analyzer – Quick Tutorial. Microsoft has come up with white paper regarding same Best Practice Analyzer. In the new R2 version the SQL BPA introduces advanced capabilities in conjunction with the PowerShell architecture and also raises the bar for prerequisites and cross dependencies. Microsoft has just released white paper which discuses the best practices to use Best Practices Analyzer. This white paper covers very important aspects of the tools. They talk about Installations, Usage and Troubleshooting. Additionally this white paper covers Engine Rules and Powershell methodology. I suggest... - [SQL SERVER - Find Automatically Created Statistics - T-SQL](https://blog.sqlauthority.com/2010/09/10/sql-server-find-automatically-created-statistics-t-sql/): Earlier, I wrote about my experience at an organization here: SQL SERVER – Plan Cache – Retrieve and Remove – A Simple Script. This blog post briefly narrates another experience I had at the same organization. When I was there, I also looked at the statistics and found something that I would like to bring into the limelight. As the developers ran many non-production queries on the production server, many statistics were automatically created on the table. These stats were not useful as they were created by several queries which ran one-time or ad-hoc. Because of this, we really had to... - [SQL SERVER - Quickly Upgrade Your SQL Server](https://blog.sqlauthority.com/2010/09/09/sql-server-quickly-upgrade-your-sql-server/): In this blog post, I will talk about how you can use Docker to quickly upgrade your SQL Server. I discuss docker in this blog post. - [SQL SERVER – Find Row Count in Table – Find Largest Table in Database – Part 2](https://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/): Last Year I wrote article on the subject SQL SERVER – Find Row Count in Table – Find Largest Table in Database – T-SQL. It is very good to see excellent participation there. In my script I had not taken care of table schema. SQL Server Expert Ameena has modified the same script to include the schema. Here is the new modified script. SELECT sc.name +'.'+ ta.name TableName ,SUM(pa.rows) RowCnt FROM sys.tables ta INNER JOIN sys.partitions pa ON pa.OBJECT_ID = ta.OBJECT_ID INNER JOIN sys.schemas sc ON ta.schema_id = sc.schema_id WHERE ta.is_ms_shipped = 0 AND pa.index_id IN (1,0) GROUP BY sc.name,ta.name ORDER... - [SQL SERVER - Index Levels and Delete Operations - Page Level Observation](https://blog.sqlauthority.com/2010/09/07/sql-server-index-levels-and-delete-operations-page-level-observation/): I wrote an article before on SQL SERVER – Index Levels, Page Count, Record Count and DMV – sys.dm_db_index_physical_stats. In that article, I promised that I would give a follow up post with a few more interesting details. I suggest that you go over the earlier article first to understand the details on B-Tree and Index Level. Today we will see one of the fascinating aspects of Delete Operations. Update: This blog post contained few factual errors and they were clearly pointed out by Hrvoje Piasevoli over here. Based on his comment, I have modified this blog post. I will include... - [SQL SERVER - Index Created on View not Used Often - Limitation of the View 3](https://blog.sqlauthority.com/2010/09/06/sql-server-index-created-on-view-not-used-often-limitation-of-the-view-3/): Update: Please read the summary post of all the 11 Limitation of the view SQL SERVER – The Limitations of the Views – Eleven and more… Let us learn about Index Created on View not Used Often. - [SQL SERVER - 2008 - Server Consolidation WhitePaper Download](https://blog.sqlauthority.com/2007/10/28/sql-server-2008-server-consolidation-whitepaper-download/): Server Consolidation with SQL Server 2008 Writer: Martin Ellis Reviewer: Prem Mehra,Lindsey Allen, Tiffany Wissner, Sambit Samal Published: March 2009 Microsoft SQL Server 2008 supports multiple options for server consolidation, which provides organizations with the flexibility to choose the consolidation approach that best meets their requirements to centralize data services management and reduce hardware and maintenance costs. By providing centralized management, auditing, and monitoring capabilities, SQL Server 2008 makes it easy to manage multiple databases and data services, which significantly reduces administrative overheads in large enterprises. Finally, SQL Server 2008 provides the reassurance of industry-leading performance and scalability, and unprecedented control... - [SQL SERVER - 2005 - Get Current User - Get Logged In User](https://blog.sqlauthority.com/2007/10/27/sql-server-2005-get-current-user-get-logged-in-user/): Interesting enough Jr. DBA asked me how he can get current user for any particular query is ran. He said he wants it for debugging purpose as well for security purpose. I totally understand the need of this request. Knowing the current user can be extremely helpful in terms of security. To get current user run following script in Query Editor SELECT SYSTEM_USER SYSTEM_USER will return current user. From Book On-Line – SYSTEM_USER returns the name of the currently executing context. If the EXECUTE AS statement has been used to switch context, SYSTEM_USER returns the name of the impersonated context. Reference... - [SQL SERVER - Deterministic Functions and Nondeterministic Functions](https://blog.sqlauthority.com/2007/10/26/sql-server-deterministic-functions-and-nondeterministic-functions/): Deterministic functions always returns the same output result all the time it is executed for same input values. i.e. ABS, DATEDIFF, ISNULL etc. Nondeterministic functions may return different results each time they are executed. i.e. NEWID, RAND, @@CPU_BUSY etc. Functions that call extended stored procedures are nondeterministic. User-defined functions that create side effects on the database are not recommended. Reference : Pinal Dave (https://blog.sqlauthority.com) - [SQL SERVER - 2005 - Forced Parameterization and Simple Parameterization - T-SQL and SSMS](https://blog.sqlauthority.com/2007/10/25/sql-server-2005-forced-parameterization-and-simple-parameterization-t-sql-and-ssms/): SQL Server compiles query and saves the procedures cache plans in the datab