<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5371298094647745633</id><updated>2024-08-28T17:36:05.109-07:00</updated><category term="SQL Server"/><category term="SQL Server 2008"/><category term="SQL Server 2008 R2"/><category term="Database"/><category term="DB Articles"/><category term="SQL Scripts"/><category term="SQL Server 2011 (Denali)"/><category term="OS and SQL"/><category term="http://sqldbpool.com/"/><category term="MySQL"/><category term="Jugal Shah"/><category term="Networking"/><category term="SQL Server 2005"/><category term="Oracle"/><category term="Script"/><category term="Windows OS"/><category term="Database Mirroring"/><category term="Jshah"/><category term="Oracle Interview Questions"/><category term="Activity Monitor"/><category term="CMS"/><category term="Central Management Server"/><category term="Cluster"/><category term="DBA Roles and Responsibilities"/><category term="DBCC Shrinkfile"/><category term="Database Performance"/><category term="Errors"/><category term="INNODB"/><category term="Login Issue"/><category term="Networking Interview Questions"/><category term="Performance Tuning"/><category term="Policy Based Management"/><category term="Remote DBA"/><category term="SQL Server 2005 Interview Questions and Answers"/><category term="SQL Server 2005 Replication"/><category term="SQL Server 2005 Security"/><category term="SQL Server Interivew Questions"/><category term="SQL Server Interview Questions"/><category term="SQL Server Management Studio"/><category term="SSMS"/><category term="Surface Area Configuration"/><category term="Trace Flag 3226"/><category term="jshah143"/><category term=".NET INTEGRATION WITH SQL SERVER 2005"/><category term=".Net"/><category term=".TUF"/><category term="2000"/><category term="2005"/><category term="2005 security interview questions"/><category term="2008 Remote connection issue"/><category term="ALLOW_SNAPSHOT_ISOLATION"/><category term="Active-Passive Cluster installation"/><category term="Advantage and Disadvantage of MySQL table types"/><category term="Assembly"/><category term="Authentication Scheme"/><category term="Backup Options"/><category term="Blocking in SQL Server"/><category term="Bound Connections"/><category term="CDC"/><category term="CLR"/><category term="CPU bottleneck"/><category term="CTE"/><category term="Calculate Available DB Size"/><category term="Calculate DB Size"/><category term="Change Data Capture"/><category term="Change Log File Size"/><category term="Check CLR status"/><category term="Cluster Installation"/><category term="Codd&#39;s rule"/><category term="Collation"/><category term="Concurrency Control"/><category term="Conditions"/><category term="Create Alias"/><category term="DB Access Mode"/><category term="DBA Daily Activities"/><category term="DBA Duties"/><category term="DBA Tasks"/><category term="DBCC PAGE"/><category term="DBCC TRACEOFF"/><category term="DBCC TRACEON"/><category term="DBCC TRACESTATUS"/><category term="DBMS"/><category term="DCL"/><category term="DDL"/><category term="DHCP"/><category term="DMFs"/><category term="DML"/><category term="DMVs"/><category term="DNS"/><category term="DSPL"/><category term="Data Mart"/><category term="Data Modeling"/><category term="Data Page LSN"/><category term="Data Warehouse"/><category term="Database Architecture"/><category term="Database Coding Standars"/><category term="Database Coding Tips"/><category term="Database Concepts"/><category term="Database Mail using stored procedure in SQL Server 2005"/><category term="Database Properties"/><category term="Database Single User Mode"/><category term="Database Snapshot"/><category term="Database in Use"/><category term="Database restore history"/><category term="Databse Terminology"/><category term="Deadlock"/><category term="Denormalization"/><category term="Dimension"/><category term="Dimension Modeling"/><category term="Disaster Recovery"/><category term="Disconnect Users"/><category term="Disk Space Alert mails"/><category term="Do&#39;s and Don&#39;t in SQL Server"/><category term="Dowload SQL Server 2005 or SQL Server 2008 Samples"/><category term="Download Adventureworks database"/><category term="Download Sample Database AdventureWorks"/><category term="Drop DB Connections"/><category term="E-R Diagram"/><category term="Emergency Mode"/><category term="Error"/><category term="Error 18456"/><category term="Error Messages"/><category term="Error fix"/><category term="Exception Handling"/><category term="Execute As"/><category term="Execute Dos commands"/><category term="Execution Plan"/><category term="Extended Procedures"/><category term="Extent and Pages"/><category term="Facets"/><category term="Fact"/><category term="Features"/><category term="Filestream"/><category term="Fragmentation"/><category term="From Author&#39;s desk"/><category term="GIS"/><category term="GIS DataTypes in SQL Server 2008"/><category term="GO keyword"/><category term="Get Exclusive Connection DB"/><category term="Global.asax"/><category term="How to change sql server instance  name"/><category term="How to setup the Active-Passive Replication"/><category term="How to troubleshoot blocking"/><category term="Hyper-Threading"/><category term="IIS"/><category term="Import Export Registered Servers in SSMS"/><category term="Improve TempDB performance"/><category term="Index Covering in SQL Server"/><category term="Integrated Security"/><category term="Isolation Levels"/><category term="Java Interview Questions"/><category term="Kerberos"/><category term="Kiil Connections"/><category term="Locking Architecture"/><category term="Locking Granuality"/><category term="Log Sequence Number"/><category term="Log Shipping Permission"/><category term="Log Shipping Requirements"/><category term="Log-Shipping"/><category term="Logon Issues"/><category term="Logshipping"/><category term="MAXDOP"/><category term="MSDB"/><category term="MSQL_XP"/><category term="MSSQL Database Certification"/><category term="MVP"/><category term="MYISAM"/><category term="MYSQL Table Types"/><category term="Master"/><category term="Max Degree of Parallelism"/><category term="Memcached"/><category term="Microsoft SQL Server Certification Links"/><category term="Microsoft Technologies"/><category term="Min Max Memory Configuration in SQL Server"/><category term="Model"/><category term="Move Cluster Node"/><category term="Move System Database"/><category term="Mutiversion Concurrency"/><category term="MySQL Architecture"/><category term="MySQL Backup"/><category term="MySQL Interview Questions"/><category term="MySQL Optimization"/><category term="MySQL Performance amp; Tuning"/><category term="MySQL Replication"/><category term="MySQL Restore"/><category term="MySQL and Linux Commands"/><category term="MySQLDUMP"/><category term="NTLM"/><category term="Natural Key"/><category term="Network Troubleshooting Dos Commands"/><category term="Netwroking Terms"/><category term="Normalization"/><category term="Nvarchar"/><category term="Nvarchar(Max)"/><category term="OBDC DSN"/><category term="ODS"/><category term="OLAP"/><category term="OLTP"/><category term="OSI Model"/><category term="OSQL"/><category term="Online"/><category term="Open Systems Interconnection"/><category term="Operating System"/><category term="Operating System Error 112"/><category term="Orphaned User"/><category term="PORT"/><category term="Page Splits"/><category term="Peer-to-peer transactional replication"/><category term="Performance Monitor Counter using SSMS"/><category term="Pivot"/><category term="Points to Study to be SQL DBA"/><category term="Prerequisites for service pack installation"/><category term="Primary Key in MySQL"/><category term="Processes"/><category term="RAID Levels"/><category term="RDBMS"/><category term="READ_COMMITTED_SNAPSHOT"/><category term="Rank functions"/><category term="Ranking function Rank()"/><category term="Read Error Log"/><category term="Read Transaction Log Data"/><category term="Reclaim Space"/><category term="Recover MySQL Root Password"/><category term="Remove SQL Server Service"/><category term="Replication Error Messages"/><category term="Replication Setup MySQL 5.0"/><category term="Report Builder 3.0"/><category term="ReportServer"/><category term="ReportServerTempDB"/><category term="Republic Day"/><category term="Resource"/><category term="Resource Database"/><category term="Resource Governor in SQL Server 2008"/><category term="Restore"/><category term="Restore Headeronly"/><category term="Restore db to lower version"/><category term="Retrieve Current Date Time in SQL Server"/><category term="RollBack Options"/><category term="Row Versioning"/><category term="RowNumber"/><category term="SAND BOX"/><category term="SERVERPROPERTY(&#39;ErrorLogFileName&#39;)"/><category term="SPN"/><category term="SP_Rename"/><category term="SQL Complete"/><category term="SQL Injections"/><category term="SQL Profiler"/><category term="SQL Security Issue"/><category term="SQL Server 2000"/><category term="SQL Server 2000 Query Analyzer Shortcut"/><category term="SQL Server 2005 Database Mirroring"/><category term="SQL Server 2005 Editions"/><category term="SQL Server 2005 Schema"/><category term="SQL Server 2005 Server-Level Fixed Roles"/><category term="SQL Server 2008 Cluster Installation"/><category term="SQL Server 2008 Compression"/><category term="SQL Server 2008 Interivew Questions"/><category term="SQL Server 2008 R2 Airlift"/><category term="SQL Server 2008 R2 Airlift Event"/><category term="SQL Server 2008 R2 CTP"/><category term="SQL Server 2008 R2 Editions and Key Features"/><category term="SQL Server 2008 R2 System Views Map"/><category term="SQL Server 2008 Sparse column"/><category term="SQL Server 6.5 troubleshooting"/><category term="SQL Server Connection Error"/><category term="SQL Server Context SSPI Error"/><category term="SQL Server DBA Checklist"/><category term="SQL Server FAQ"/><category term="SQL Server Fixed Database-Level Roles"/><category term="SQL Server Installation"/><category term="SQL Server Installation Date"/><category term="SQL Server Level Roles"/><category term="SQL Server Protocols"/><category term="SQL Server Security"/><category term="SQL Server Security Interview Questions"/><category term="SQL Server Service Packs and Hotfixes"/><category term="SQL Server Services"/><category term="SQL Server Standard Reports"/><category term="SQL Server Start time"/><category term="SQL Server Startup time"/><category term="SQL Server TCP Ports"/><category term="SQL Server Versions"/><category term="SQL Server Windows Authentication"/><category term="SQL Server and Oralce"/><category term="SQLBrowser Service"/><category term="SQLPass"/><category term="SQLWB.exe"/><category term="SSMS Startup Options"/><category term="SSMS configuration"/><category term="SSPI"/><category term="Schema Properties"/><category term="Script to create folder using SSMS"/><category term="Secure SA Login"/><category term="Service Pack 3 Installation"/><category term="Service Principle Name"/><category term="Services.msc"/><category term="Sessions"/><category term="Setup Log-Shipping"/><category term="Severity 14: Login Failed States"/><category term="Shrink Database file"/><category term="Sp_validatelogins"/><category term="Split Backup files into multiple files"/><category term="Split brain"/><category term="Step by Step MySQL replication"/><category term="Stored Procedure"/><category term="Stored Procedure and System Tables"/><category term="Support Service"/><category term="Surrogate Key"/><category term="Sybase"/><category term="System Databases in SQL Server 2005"/><category term="System Stored Procedure List"/><category term="T-SQL"/><category term="T-SQL Script"/><category term="TCL"/><category term="Table Locking enhancement"/><category term="Tail Log Backup"/><category term="Targets"/><category term="Third Party Tool Review"/><category term="Tips for SQL Server Developer"/><category term="Tips for the DeadLock"/><category term="Top Features in SQL 2008"/><category term="Transaction Handling"/><category term="Transaction Log Backup"/><category term="Transaction Log LSN"/><category term="Transaction Undo file"/><category term="Trigger"/><category term="Troubleshooting DB Mirroring"/><category term="Troubleshooting Suspect database"/><category term="Try catch"/><category term="Types of DBA"/><category term="UDP"/><category term="Unlock User SQL Account"/><category term="Unpivot"/><category term="Update Statistics Date"/><category term="Update Statistics Script"/><category term="VIEW DEFINITION"/><category term="VarBinary(Max) Data Types"/><category term="Varchar"/><category term="Views"/><category term="WINS"/><category term="communication skills"/><category term="database Compatibility"/><category term="database mail"/><category term="database migration checklist"/><category term="delete .tmp and.bak files"/><category term="exception handling in sql server"/><category term="execute batch file with parameter"/><category term="fn_trace_gettable"/><category term="geographic information system"/><category term="how to be DBA?"/><category term="install service pack"/><category term="linked server"/><category term="litespeed"/><category term="log_reuse_wait_desc"/><category term="move database files"/><category term="output clause"/><category term="permission to read procedure text"/><category term="quest"/><category term="replication"/><category term="service status check"/><category term="sp_procoption"/><category term="spt_values system table"/><category term="sys.SP_SpaceUsed"/><category term="sys.SysObjects"/><category term="sys.dm_clr_properties"/><category term="sys.dm_io_cluster_shared_drives"/><category term="sys.dm_os_cluster_nodes"/><category term="sys.dm_os_schedulers"/><category term="sysmanagement_shared_registered_servers_internal"/><category term="sysmanagement_shared_server_groups_internal"/><category term="transfer logins from sql server 7.0"/><category term="varchar(MAX)"/><category term="verify backup"/><category term="xp_enumgroups"/><category term="xp_servicecontrol"/><title type='text'>SQL Server and MySQL Notes</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>313</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-2804650929275548450</id><published>2011-10-23T23:01:00.000-07:00</published><updated>2011-11-02T10:42:00.972-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>Standardize SQL Server Installations with Configuration Files</title><content type='html'>&lt;strong&gt;Problem&lt;/strong&gt;If you have a requirement to install multiple SQL Server instances with the same settings, you most likely want to do it without following the numerous manual installation steps. The below tip will guide you through how to install a SQL Server instance with less effort.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br/&gt;&lt;a href=&quot;http://www.mssqltips.com/sqlservertip/2511/standardize-sql-server-installations-with-configuration-files/&quot; target=&quot;_blank&quot;&gt;http://www.mssqltips.com/sqlservertip/2511/standardize-sql-server-installations-with-configuration-files/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/2804650929275548450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/standardize-sql-server-installations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2804650929275548450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2804650929275548450'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/standardize-sql-server-installations.html' title='Standardize SQL Server Installations with Configuration Files'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-5516864753035109090</id><published>2011-10-18T22:43:00.000-07:00</published><updated>2011-11-02T10:42:00.925-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>Script to get the CPU and Memory Information</title><content type='html'>You can execute the below script to get the processor and memory information.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;-- Scritp to get Processor Info from Registry&lt;br/&gt;EXEC xp_instance_regread&lt;br/&gt;&#39;HKEY_LOCAL_MACHINE&#39;,&lt;br/&gt;&#39;HARDWARE\DESCRIPTION\System\CentralProcessor&amp;#092;&amp;#048;&#39;,&lt;br/&gt;&#39;ProcessorNameString&#39;;&lt;br/&gt;&lt;br/&gt;-- Script to get CPU and Memory Info&lt;br/&gt;SELECT &lt;br/&gt; cpu_count AS [Number of Logical CPU]&lt;br/&gt;,hyperthread_ratio&lt;br/&gt;,cpu_count/hyperthread_ratio AS [Number of Physical CPU]&lt;br/&gt;,physical_memory_in_bytes/1048576 AS [Total Physical Memory IN MB]&lt;br/&gt;FROM sys.dm_os_sys_info OPTION (RECOMPILE);&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/10/image11.jpg&quot;&gt;&lt;img src=&quot;http://sqldbpool.files.wordpress.com/2011/10/image11.jpg&quot; alt=&quot;&quot; title=&quot;Image1&quot; width=&quot;630&quot; height=&quot;422&quot; class=&quot;aligncenter size-full wp-image-1436&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/5516864753035109090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/script-to-get-cpu-and-memory.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/5516864753035109090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/5516864753035109090'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/script-to-get-cpu-and-memory.html' title='Script to get the CPU and Memory Information'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-9222821313561498095</id><published>2011-10-18T09:23:00.000-07:00</published><updated>2011-11-02T10:42:00.887-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Central Management Server"/><category scheme="http://www.blogger.com/atom/ns#" term="CMS"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>Customizing the Status Bar for each SQL Server Instance registered in&#xa;CMS</title><content type='html'>&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br/&gt;Steps to distinguish production and non-production SQL Servers registered in CMS while executing the query. Below article will guide you how to use customize colors in CMS.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br/&gt;To identify the production and non-production SQL Instances registered in CMS within the same group; you can use the Custom Color feature. In this article I will guide how to use to the custom color feature of CMS.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;  Connect to Central Management Server (CMS) from SSMS.&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/10/image1.jpg&quot;&gt;&lt;img src=&quot;http://sqldbpool.files.wordpress.com/2011/10/image1.jpg&quot; alt=&quot;&quot; title=&quot;Image1&quot; width=&quot;284&quot; height=&quot;116&quot; class=&quot;aligncenter size-full wp-image-1427&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Right click on the registered CMS server and select &lt;strong&gt;properties&lt;/strong&gt;.&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/10/image2.jpg&quot;&gt;&lt;img src=&quot;http://sqldbpool.files.wordpress.com/2011/10/image2.jpg&quot; alt=&quot;&quot; title=&quot;Image2&quot; width=&quot;341&quot; height=&quot;333&quot; class=&quot;aligncenter size-full wp-image-1428&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;Go to Connection Properties tab, checked the Use &lt;strong&gt;Custom color box&lt;/strong&gt; and select the desired color. Click on Save to proceed.&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/10/image3.jpg&quot;&gt;&lt;img src=&quot;http://sqldbpool.files.wordpress.com/2011/10/image3.jpg&quot; alt=&quot;&quot; title=&quot;Image3&quot; width=&quot;610&quot; height=&quot;512&quot; class=&quot;aligncenter size-full wp-image-1429&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Right click on the SQL Instance and Open a new query window. You can see the blue color in the status bar.  This way we can identify the production and non-production box. By specifying the custom colors.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Ouput Image of SSMS&lt;/strong&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/10/image4.jpg&quot;&gt;&lt;img src=&quot;http://sqldbpool.files.wordpress.com/2011/10/image4.jpg&quot; alt=&quot;&quot; title=&quot;Image4&quot; width=&quot;630&quot; height=&quot;373&quot; class=&quot;aligncenter size-full wp-image-1430&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/9222821313561498095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/customizing-status-bar-for-each-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/9222821313561498095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/9222821313561498095'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/customizing-status-bar-for-each-sql.html' title='Customizing the Status Bar for each SQL Server Instance registered in&#xa;CMS'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-4728546008293131251</id><published>2011-10-17T04:45:00.000-07:00</published><updated>2011-11-02T10:42:00.862-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Question of the day!!!</title><content type='html'>[polldaddy poll=5590421]</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/4728546008293131251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/question-of-day.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4728546008293131251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4728546008293131251'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/question-of-day.html' title='Question of the day!!!'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-5125225951763852711</id><published>2011-10-10T01:11:00.000-07:00</published><updated>2011-11-02T10:42:00.834-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Scripts"/><title type='text'>T-SQL to Check SQL ErrorLog file location</title><content type='html'>At the start up of SQL Server records the startup parameter details into the error log.&lt;br/&gt;&lt;br/&gt;You can query the error log to check the error log file physical location.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;USE master&lt;br/&gt;GO&lt;br/&gt;xp_readerrorlog 0, 1, N&#39;Logging SQL Server messages in file&#39;, NULL, NULL, N&#39;asc&#39;&lt;br/&gt;GO&lt;br/&gt;[/sourcecode]</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/5125225951763852711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/t-sql-to-check-sql-errorlog-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/5125225951763852711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/5125225951763852711'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/10/t-sql-to-check-sql-errorlog-file.html' title='T-SQL to Check SQL ErrorLog file location'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-4072808073155395308</id><published>2011-09-28T05:25:00.000-07:00</published><updated>2011-11-02T10:42:00.801-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database Mirroring"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting DB Mirroring"/><title type='text'>Useful queries while troubleshooting Database Mirroring</title><content type='html'>&lt;strong&gt;Useful queries while troubleshooting Database Mirroring&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;&lt;em&gt;Query to check the associated ports with DB Mirroring&lt;/em&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;SELECT type_desc, port FROM sys.tcp_endpoints;&lt;br/&gt;GO&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;em&gt;Query to check the state of the DB Mirroring&lt;/em&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;SELECT state_desc FROM sys.database_mirroring_endpoints&lt;br/&gt;GO&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;em&gt;Query to check the service account connect permission on the DB Mirror endpoints&lt;/em&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;SELECT &#39;Metadata Check&#39;;&lt;br/&gt;SELECT EndPnt.name, SvrPerm.STATE,&lt;br/&gt;   CONVERT(nvarchar(38), suser_name(SvrPerm.grantor_principal_id))&lt;br/&gt;    AS GRANTOR,&lt;br/&gt;   SvrPerm.TYPE AS PERMISSION,&lt;br/&gt;   CONVERT(nvarchar(46),suser_name(SvrPerm.grantee_principal_id))&lt;br/&gt;    AS GRANTEE&lt;br/&gt;   FROM sys.server_permissions SvrPerm, sys.endpoints EndPnt&lt;br/&gt;   WHERE SvrPerm.major_id = EndPnt.endpoint_id&lt;br/&gt;   ORDER BY Permission, grantor, grantee;&lt;br/&gt;GO&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;em&gt;Query to check the DB Mirror timeout and resetting the DB Mirror timeout&lt;/em&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;SELECT mirroring_connection_timeout&lt;br/&gt;FROM&lt;br/&gt;sys.database_mirroring&lt;br/&gt;GO&lt;br/&gt;&lt;br/&gt;ALTER DATABASE SQLDBPOOL SET PARTNER TIMEOUT 15&lt;br/&gt;GO&lt;br/&gt;[/sourcecode]</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/4072808073155395308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/09/useful-queries-while-troubleshooting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4072808073155395308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4072808073155395308'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/09/useful-queries-while-troubleshooting.html' title='Useful queries while troubleshooting Database Mirroring'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-1491345325478917212</id><published>2011-09-22T01:01:00.000-07:00</published><updated>2011-11-02T10:42:00.774-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="OBDC DSN"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows OS"/><title type='text'>Create a 32-bit DSN on 64-bit machine for SQL Server</title><content type='html'>&lt;strong&gt;Problem&lt;/strong&gt;&lt;br/&gt;During the install of an application on a 64-bit Windows machine, the application was unable to list the ODBC System DSN because it had been setup as a 64-bit DSN and the application needed a 32-bit system DSN for connectivity to SQL Server.  In this tip, we cover how to create a 32-bit DSN on 64-bit machine.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br/&gt;&lt;a href=&quot;http://www.mssqltips.com/sqlservertip/2498/create-a-32bit-dsn-on-64bit-machine-for-sql-server/&quot; target=&quot;_blank&quot;&gt;http://www.mssqltips.com/sqlservertip/2498/create-a-32bit-dsn-on-64bit-machine-for-sql-server/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/1491345325478917212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/09/create-32-bit-dsn-on-64-bit-machine-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1491345325478917212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1491345325478917212'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/09/create-32-bit-dsn-on-64-bit-machine-for.html' title='Create a 32-bit DSN on 64-bit machine for SQL Server'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-4197145336082189032</id><published>2011-09-12T23:13:00.000-07:00</published><updated>2011-11-02T10:42:00.710-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server TCP Ports"/><title type='text'>How to configure SQL to listen on Multiple Ports?</title><content type='html'>&lt;strong&gt;Problem&lt;/strong&gt;&lt;br/&gt;Recently I came across a situation where an existing production SQL Server default instance was configured to use static TCP/IP port 48030 and the default 1433 port was disabled. A number of database applications are hosted on the same default SQL instance and these applications are connecting to SQL Server through port 48030.  As per a new business requirement we need to host a new application database on the same SQL instance, but the application is unable to connect to the SQL instance because it us hard corded to use the default port 1433.  In this tip we walk through how to configure a SQL instance to listen on multiple TCP/IP ports.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br/&gt;For solution please check &lt;a href=&quot;http://www.mssqltips.com/sqlservertip/2493/configuring-sql-server-to-use-multiple-ports/&quot; target=&quot;_blank&quot;&gt;http://www.mssqltips.com/sqlservertip/2493/configuring-sql-server-to-use-multiple-ports/&lt;/a&gt; URL.</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/4197145336082189032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/09/how-to-configure-sql-to-listen-on.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4197145336082189032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4197145336082189032'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/09/how-to-configure-sql-to-listen-on.html' title='How to configure SQL to listen on Multiple Ports?'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-4940400278762971084</id><published>2011-07-26T23:39:00.000-07:00</published><updated>2011-11-02T10:42:00.678-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>Script to Get Available and Free Disk Space for SQL Server</title><content type='html'>&lt;strong&gt;Problem&lt;/strong&gt;&lt;br/&gt;Often we face the situation where we need to check the total disk space and available disk space for both physical and LUN/Mount drives. The extended stored procedure XP_FixedDrives is unable to help us in this scenario, so we have to log into the machine to check the total and free disk space for each physical/LUN/mount drive.  In this tip, I show how this can be done using PowerShell.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br/&gt;&lt;a href=&quot;http://www.mssqltips.com/tip.asp?tip=2444&quot; title=&quot;SQLDBPool&quot; target=&quot;_blank&quot;&gt;http://www.mssqltips.com/tip.asp?tip=2444&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/4940400278762971084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/07/script-to-get-available-and-free-disk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4940400278762971084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4940400278762971084'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/07/script-to-get-available-and-free-disk.html' title='Script to Get Available and Free Disk Space for SQL Server'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-4488962703025002429</id><published>2011-07-25T06:40:00.000-07:00</published><updated>2011-11-02T10:42:00.657-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><title type='text'>Difference between temporary table and table variable</title><content type='html'>&lt;strong&gt;Temporary Tables&lt;/strong&gt;There are two types of temporary tables:&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Local Temporary Table:&lt;/strong&gt; Local temporary tables are visible only to their creators during the same connection to an instance of SQL Server as when the tables were first created or referenced. Local temporary tables are deleted after the user disconnects from the instance of SQL Server&lt;br/&gt;&lt;br/&gt;You can create local temporary table adding # sign again the table name&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Global Temporary Table:&lt;/strong&gt; Global temporary tables are visible to any user and any connection after they are created, and are deleted when all users that are referencing the table disconnect from the instance of SQL Server.&lt;br/&gt;&lt;br/&gt;You can create global temporary table adding ## sign again the table name&lt;br/&gt;&lt;br/&gt;What are the things you can do with the temporary tables?&lt;br/&gt;-Add/drop constraints except foreign key&lt;br/&gt;-You can perform DDL statements (Alter, Drop)&lt;br/&gt;-Create clustered and non-clustered indexes&lt;br/&gt;-Use identity columns&lt;br/&gt;-Use it in transaction and it support transaction&lt;br/&gt;-Perform any DML operations (SELECT, INSERT, UPDATE, DELETE)&lt;br/&gt;-Create the table with same name using different session; make sure constraint name must be different in the table.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;-- Adding the constraint primary key and unique key&lt;br/&gt;-- constraint will create the cluster and non-cluster index&lt;br/&gt;create table #temptbl&lt;br/&gt;(id int identity (100,1) Primary key,&lt;br/&gt;data varchar(20) constraint UK Unique&lt;br/&gt;)&lt;br/&gt;&lt;br/&gt;insert into #temptbl values (&#39;Jugal&#39;)&lt;br/&gt;insert into #temptbl values (&#39;Jugal1&#39;)&lt;br/&gt;insert into #temptbl values (&#39;Jugal2&#39;)&lt;br/&gt;&lt;br/&gt;select * from #temptbl&lt;br/&gt;sp_help #temptbl&lt;br/&gt;&lt;br/&gt;--Adding column to existing temporary table&lt;br/&gt;alter table #temptbl&lt;br/&gt;Add Name varchar(20) null&lt;br/&gt;&lt;br/&gt;-- Modifying column&lt;br/&gt;alter table #temptbl&lt;br/&gt;alter column name varchar(30)&lt;br/&gt;&lt;br/&gt;--adding index&lt;br/&gt;create nonclustered index UK2 on #temptbl (name)&lt;br/&gt;&lt;br/&gt;--checking indexes&lt;br/&gt;sp_helpindex #temptbl&lt;br/&gt;&lt;br/&gt;-- Supports transaction&lt;br/&gt;begin tran&lt;br/&gt;insert into #temptbl values(&#39;sqldbpool&#39;,&#39;sqldbpool&#39;)&lt;br/&gt;rollback&lt;br/&gt;&lt;br/&gt;select * from #temptbl&lt;br/&gt;&lt;br/&gt;--Checking for the foreign key&lt;br/&gt;create table #temptbl1&lt;br/&gt;(&lt;br/&gt;id int constraint FK1 references #temptbl1(id),&lt;br/&gt;value int&lt;br/&gt;)&lt;br/&gt;--Skipping FOREIGN KEY constraint &#39;FK1&#39; definition for temporary table. FOREIGN KEY constraints are not enforced on local or global temporary tables.&lt;br/&gt;&lt;br/&gt;insert into #temptbl1 values(2000,10)&lt;br/&gt;&lt;br/&gt;--DML Opertaions&lt;br/&gt;select * from #temptbl&lt;br/&gt;&lt;br/&gt;update #temptbl set data = &#39;SQLDBPool&#39;&lt;br/&gt;where id = 100&lt;br/&gt;&lt;br/&gt;select * from #temptbl&lt;br/&gt;&lt;br/&gt;delete from #temptbl where id = 101&lt;br/&gt;&lt;br/&gt;select * from #temptbl&lt;br/&gt;--dropping temporary table&lt;br/&gt;drop table #temptbl&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Table variable&lt;/strong&gt;The syntax for creating table variables is quite similar to creating either regular or temporary tables.  The only differences involve a naming convention unique to variables in general, and the need to declare the table variable as you would any other local variable in Transact SQL. Life span of the table variable is limited to life of the transaction. You can only create the cluster index on table variable.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;-- creating table variable&lt;br/&gt;declare @var table &lt;br/&gt;(id int identity(100,1) primary key, &lt;br/&gt; data varchar(20) default &#39;hi&#39;&lt;br/&gt; )&lt;br/&gt;&lt;br/&gt;--Checking DML Statement --working fine&lt;br/&gt;insert into @var values(&#39;jugal&#39;)&lt;br/&gt;insert into @var values(&#39;sqldbpool&#39;)&lt;br/&gt;delete from @var where id = 100&lt;br/&gt;update @var set data = &#39;sqldbpool-1&#39; where id = 101&lt;br/&gt;select * from @var&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;-- Checking transaction support/doesn&#39;t support transaction&lt;br/&gt;begin tran&lt;br/&gt;declare @var table &lt;br/&gt;(id int identity(100,1) primary key, &lt;br/&gt; data varchar(20) default &#39;hi&#39;&lt;br/&gt; )&lt;br/&gt;&lt;br/&gt;insert into @var values(&#39;jugal&#39;)&lt;br/&gt;insert into @var values(&#39;sqldbpool&#39;)&lt;br/&gt;insert into @var values (DEFAULT)&lt;br/&gt;delete from @var where id = 100&lt;br/&gt;update @var set data = &#39;sqldbpool-1&#39; where id = 101&lt;br/&gt;&lt;br/&gt;rollback&lt;br/&gt;select * from @var&lt;br/&gt;-- Checking alter failed/doesn&#39;t support DDL&lt;br/&gt;alter table @var&lt;br/&gt;alter column data varchar(30)&lt;br/&gt;&lt;br/&gt;alter table @var&lt;br/&gt;Add Name varchar(20) null&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Similarities between temporary tables and table variable:&lt;/strong&gt;- Both are created in tempdb &lt;br/&gt;- You can create constraint like primary key, default and check on both but the table variable has certain limitation for the default and check constrain where you can not use UDF&lt;br/&gt;- Clustered indexes can be created on table variables and temporary tables &lt;br/&gt;- Both are logged in the transaction log but the tempDB recovery model is SIMPLE, log will be truncated once the trasaction get complete.&lt;br/&gt;Just as with temp and regular tables, users can perform all Data Modification Language (DML) queries against a table variable:  SELECT, INSERT, UPDATE, and DELETE.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Differences&lt;/strong&gt;&lt;br/&gt;- You can not create non-cluster index and statistics on table variable but you can create it on temporary table.&lt;br/&gt;- You can not use DDL statement on table variable but you can use it on temporary table.&lt;br/&gt;- Table variable doesn&#39;t support transaction wheras temporary table supports.</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/4488962703025002429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/07/difference-between-temporary-table-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4488962703025002429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4488962703025002429'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/07/difference-between-temporary-table-and.html' title='Difference between temporary table and table variable'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-1918751128713834392</id><published>2011-07-06T23:28:00.000-07:00</published><updated>2011-11-02T10:42:00.582-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MySQL"/><category scheme="http://www.blogger.com/atom/ns#" term="Step by Step MySQL replication"/><title type='text'>MySQL Replication Setup</title><content type='html'>Mysql uses a &lt;strong&gt;Master-slave/Publisher-Subscriber&lt;/strong&gt; model for Replication. MySQL replication is an &lt;strong&gt;asynchronous&lt;/strong&gt; replication. In MySQL replication master keeps a log of all of the updates performed on the database. Then, one or more slaves connect to the Master(Publisher Server), read each log entry, and perform the indicated update on the slave (Subscriber) server databases. The master server is responsible for the track of log rotation and access control. &lt;br/&gt;&lt;br/&gt;Each slave server has to keep the track of current position within the server&#39;s transaction log. As new transactions occur on the server, they get logged on the master server and downloaded by each slave. Once the transaction has been committed by each slave, the slaves update their position in the server&#39;s transaction log and wait for the next transaction. &lt;br/&gt;&lt;br/&gt;In this article, I will show you the steps to configure the Master/Slave replication between two servers.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create a user on Master server which Slave server can use to connect. I have created the user named &quot;repl_user&quot;.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;--Connect to MySQL Master server&lt;br/&gt;mysql -u root -proot&lt;br/&gt;--Execute the below code&lt;br/&gt;GRANT REPLICATION SLAVE ON *.* TO &#39;repl_user&#39;@&#39;%&#39; IDENTIFIED BY &#39;password&#39;;&lt;br/&gt;FLUSH PRIVILEGES;&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; We have to change the MySQL configuration file usually in the /etc/mysql.cnf location. Here we will add the replication configuration parameters.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;log-bin – &lt;/strong&gt;will be used to write a log on the desired location&lt;br/&gt;&lt;strong&gt;binlog-do-db –&lt;/strong&gt; will be used to enabled the database for writing log. I have used Publisher_Database, you have to specify your database name.&lt;br/&gt;&lt;strong&gt;server-id –&lt;/strong&gt; Specify the ID of the Master server&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;log-bin = /home/mysql/logs/mysql-bin.log&lt;br/&gt;binlog-do-db=publisher_database&lt;br/&gt;server-id=1&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Once you have added the above configuration parameters into the My.cnf, next step is restart the MySQL Master Instance.&lt;br/&gt;You can use below command to restart the MySQl service.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;/etc/init.d/mysqld restart&lt;br/&gt;service mysqld restart&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; We have to configure the /etc/my.cnf file on the slave server. Here we will add the below parameters in the configuration file.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;server-id - &lt;/strong&gt;gives the Slave its unique ID&lt;br/&gt;&lt;strong&gt;master-host -&lt;/strong&gt; tells the Slave the I.P address of the Master server for connection. You can get the IP address using IPConfig command.&lt;br/&gt;&lt;strong&gt;master-connect-retry -&lt;/strong&gt; Here we will specify the connection retry interval.&lt;br/&gt;&lt;strong&gt;master-user -&lt;/strong&gt; Specify the user which has permission access the Master server&lt;br/&gt;&lt;strong&gt;master-password -&lt;/strong&gt; Specify the password of the replication user mentioned above&lt;br/&gt;&lt;strong&gt;replicate-do-db -&lt;/strong&gt; Specify the subscriber database name&lt;br/&gt;&lt;strong&gt;relay-log -&lt;/strong&gt; direct slave to use relay log&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;server-id=2&lt;br/&gt;master-host=128.20.30.1&lt;br/&gt;master-connect-retry=60&lt;br/&gt;master-user=repl_user&lt;br/&gt;master-password=password&lt;br/&gt;replicate-do-db=subscriber_slave&lt;br/&gt;relay-log = /var/lib/mysql/slave-relay.log&lt;br/&gt;relay-log-index = /var/lib/mysql/slave-relay-log.index&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Restart the slave MySQl instance&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;/etc/init.d/mysqld restart&lt;br/&gt;service mysqld restart&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; If your Master MySQL instance is live instance, you have to do the backup/restore using MySQLDump utility.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;--Connect to MySQL Master server&lt;br/&gt;mysql -u root -proot&lt;br/&gt;&lt;br/&gt;--Stop the write operation&lt;br/&gt;FLUSH TABLES WITH READ LOCK;&lt;br/&gt;&lt;br/&gt;--Generate the dump of the database (backup)&lt;br/&gt;--gzip command will compress the file and create the zip file name backup.sql.gz&lt;br/&gt;mysqldump publisher_master -u root -p &amp;gt; /home/my_home_dir/backup.sql;&lt;br/&gt;gzip /home/my_home_dir/backup.sql;&lt;br/&gt;&lt;br/&gt;--execute below copy command on slave to copy the backup file&lt;br/&gt;scp root@128.20.30.1:/home/my_home_dir/database.sql.gz /home/my_home_dir/&lt;br/&gt;&lt;br/&gt;--Once copied, extract the file using gunzip&lt;br/&gt;gunzip /home/my_home_dir/backup.sql.gz&lt;br/&gt;&lt;br/&gt;--restore the databsae&lt;br/&gt;mysql -u root -p subscriber_slave  &amp;lt;/home/my_home_dir/backup.sql&lt;br/&gt;&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 7:&lt;/strong&gt; Execute the SHOW MASTER STATUS command on Master server. It will give you the bin log file name and position which we will use specify the slave.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;SHOW MASTER STATUS;&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;code&gt;&lt;br/&gt;+------------------+----------+--------------+------------------+&lt;br/&gt;| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |&lt;br/&gt;+------------------+----------+--------------+------------------+&lt;br/&gt;| mysql-bin.000001 |      707 | exampledb    |                  |&lt;br/&gt;+------------------+----------+--------------+------------------+&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 8:&lt;/strong&gt; Execute the below commands on slave.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;--Connect to MySQL Slave server&lt;br/&gt;mysql -u root -proot&lt;br/&gt;--stop the slave&lt;br/&gt;slave stop;&lt;br/&gt;-- Execute the below command&lt;br/&gt;CHANGE MASTER TO MASTER_HOST=&#39;128.20.30.1&#39;, MASTER_USER=&#39;repl_user&#39;, MASTER_PASSWORD=&#39;password&#39;, MASTER_LOG_FILE=&#39;mysql-bin.000001&#39;, MASTER_LOG_POS=707;&lt;br/&gt;--Start the Slave&lt;br/&gt;slave start;&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 9:&lt;/strong&gt; Login to Master MySQL instance and unlock the tables.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;--Connect to MySQL Master server&lt;br/&gt;mysql -u root -proot&lt;br/&gt;-- unlock the tables if you have executed lock tables command&lt;br/&gt;unlock tables;&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;You are all set. Master to Slave replication has been started. Make sure while configuring the my.cnf file.&lt;br/&gt;1. Take the copy of my.cnf file before starting the replication configuration.&lt;br/&gt;2. Make sure skip-networking parameter is not enabled in the my.cnf file.</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/1918751128713834392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/07/mysql-replication-setup.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1918751128713834392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1918751128713834392'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/07/mysql-replication-setup.html' title='MySQL Replication Setup'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-2367001608291620469</id><published>2011-07-06T04:44:00.000-07:00</published><updated>2011-11-02T10:42:00.564-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>T-SQL Script to Check/Create directory</title><content type='html'>Recently I came across a situation where I need to check whether the directory is exists or not, in case if the directory does not exist, I have to create new one.&lt;br/&gt;&lt;br/&gt;As a solution, I have created below script to fix the issue.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;	declare @chkdirectory as nvarchar(4000)&lt;br/&gt;	declare @folder_exists as int&lt;br/&gt;	&lt;br/&gt;	set @chkdirectory = &#39;C:\SQLDBPool\SQL\Articles&#39;&lt;br/&gt;&lt;br/&gt;	declare @file_results table &lt;br/&gt;	(file_exists int,&lt;br/&gt;	file_is_a_directory int,&lt;br/&gt;	parent_directory_exists int&lt;br/&gt;	)&lt;br/&gt;&lt;br/&gt;	insert into @file_results&lt;br/&gt;	(file_exists, file_is_a_directory, parent_directory_exists)&lt;br/&gt;	exec master.dbo.xp_fileexist @chkdirectory&lt;br/&gt;	&lt;br/&gt;	select @folder_exists = file_is_a_directory&lt;br/&gt;	from @file_results&lt;br/&gt;	&lt;br/&gt;	--script to create directory		&lt;br/&gt;	if @folder_exists = 0&lt;br/&gt;	 begin&lt;br/&gt;		print &#39;Directory is not exists, creating new one&#39;&lt;br/&gt;		EXECUTE master.dbo.xp_create_subdir @chkdirectory&lt;br/&gt;		print @chkdirectory +  &#39;created on&#39; + @@servername&lt;br/&gt;	 end		&lt;br/&gt;	else&lt;br/&gt;	print &#39;Directory already exists&#39;&lt;br/&gt;GO [/sourcecode]</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/2367001608291620469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/07/t-sql-script-to-checkcreate-directory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2367001608291620469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2367001608291620469'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/07/t-sql-script-to-checkcreate-directory.html' title='T-SQL Script to Check/Create directory'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-4746840451286605566</id><published>2011-06-27T01:25:00.000-07:00</published><updated>2011-11-02T10:42:00.547-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DB Articles"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>Restoring a SQLServer database that uses Change Data Capture</title><content type='html'>&lt;strong&gt;Problem&lt;/strong&gt;&lt;br/&gt;When restoring a database that uses &lt;a class=&quot;zem_slink&quot; title=&quot;Change data capture&quot; href=&quot;http://en.wikipedia.org/wiki/Change_data_capture&quot; rel=&quot;wikipedia&quot;&gt;Change Data Capture&lt;/a&gt; (CDC), restoring a backup works differently depending on where the database is restored. In this tip we take a look at different scenarios when restoring a database when CDC is enabled.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br/&gt;For solution, please check my new article on &lt;a href=&quot;http://mssqltips.com/tip.asp?tip=2421&quot;&gt;MSSQLTips.com&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://mssqltips.com/tip.asp?tip=2421&quot; target=&quot;_blank&quot;&gt;http://mssqltips.com/tip.asp?tip=2421&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/4746840451286605566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/06/restoring-sqlserver-database-that-uses.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4746840451286605566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/4746840451286605566'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/06/restoring-sqlserver-database-that-uses.html' title='Restoring a SQLServer database that uses Change Data Capture'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-6711681318810398672</id><published>2011-06-14T09:25:00.000-07:00</published><updated>2011-11-02T10:42:00.525-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="Move System Database"/><category scheme="http://www.blogger.com/atom/ns#" term="Resource Database"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>How to Move Resource Database?</title><content type='html'>&lt;strong&gt;Resource Database:&lt;/strong&gt; Resource database is available from the SQL Server 2005 and higher level versions. Resource database is read only and hidden database. Resource database contains all the system objects that shipped with SQL Server. SQL Server system objects, such as &lt;strong&gt;sys.objects&lt;/strong&gt;, are physically persisted in the Resource database, but they logically appear in the sys schema of every database.&lt;br/&gt;&lt;br/&gt;Resource database will be very useful in doing &lt;strong&gt;upgrades&lt;/strong&gt; or in &lt;strong&gt;un-installing up-grades&lt;/strong&gt;. In the previous versions of SQL Server up-grade needs creating/dropping of the system objects. From the SQL Server 2005 version upgrade is just procedure to &lt;strong&gt;copying resource database file &lt;/strong&gt;to local server.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Name of Resource database data and log file.&lt;/strong&gt;&lt;br/&gt;mssqlsystemresource.mdf &lt;br/&gt;mssqlsystemresource.ldf&lt;br/&gt;&lt;br/&gt;Resource database data and log file location is &lt;strong&gt;same as the Master database location&lt;/strong&gt;. In case if you are moving Master database you have to move the Resource database as well to the same location.&lt;br/&gt;&lt;br/&gt;You can check the Resource database version and last up-grade time using the SERVERPROPERTY function.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;SELECT SERVERPROPERTY(‘RESOURCEVERSION’);&lt;br/&gt;GO&lt;br/&gt;SELECT SERVERPROPERTY(‘RESOURCELASTUPDATEDATETIME’);&lt;br/&gt;GO [/sourcecode]&lt;br/&gt;&lt;br/&gt;To move the resource database, you have to start the SQL Server service using either -m (single user mode) or -f (minimal configuration) and using -T3608 trace flag which will skip the recovery of all the databases other than the master database. &lt;br/&gt;&lt;br/&gt;You can do it either from the Configuration manager or from the command prompt using below command.&lt;br/&gt;&lt;strong&gt;Default Instance&lt;/strong&gt;&lt;br/&gt;&lt;code&gt;NET START MSSQLSERVER /f /T3608&lt;/code&gt;&lt;br/&gt;&lt;strong&gt;Named Instance&lt;/strong&gt;&lt;br/&gt;&lt;code&gt;NET START MSSQL$instancename /f /T3608&lt;/code&gt;&lt;br/&gt;&lt;br/&gt;Execute the below ALTER command once you have started the SQL Service by specifying the new location, location should be same as Master database location.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;ALTER DATABASE mssqlsystemresource MODIFY FILE (NAME=data, FILENAME= &#39;\mssqlsystemresource.mdf&#39;)&lt;br/&gt;ALTER DATABASE mssqlsystemresource MODIFY FILE (NAME=log, FILENAME= &#39;\mssqlsystemresource.ldf&#39;)[/sourcecode]</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/6711681318810398672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/06/how-to-move-resource-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/6711681318810398672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/6711681318810398672'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/06/how-to-move-resource-database.html' title='How to Move Resource Database?'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-1490380003624274015</id><published>2011-06-08T07:51:00.000-07:00</published><updated>2011-11-02T10:42:00.498-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="Kiil Connections"/><category scheme="http://www.blogger.com/atom/ns#" term="Processes"/><category scheme="http://www.blogger.com/atom/ns#" term="Sessions"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>How to kill all sessions that have open connection in a SQL Server&#xa;Database?</title><content type='html'>As SQL Server DBAs, many times we need to KILL all Open Sessions against the SQL Server Database to proceed with Maintenance Task, Restore and more...&lt;br/&gt;&lt;br/&gt;You can use below different techniques to KILL all open sessions against the database.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Technique - I&lt;/strong&gt;&lt;br/&gt;Here we will query the SysProcesses table to get the session running against the user database and prepare the dynamic SQL statement to KILL all the connection.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;DECLARE @DbName nvarchar(50)&lt;br/&gt;SET @DbName = N&#39;Write a DB Name here&#39;&lt;br/&gt;&lt;br/&gt;DECLARE @EXECSQL varchar(max)&lt;br/&gt;SET @EXECSQL = &#39;&#39;&lt;br/&gt;&lt;br/&gt;SELECT @EXECSQL = @EXECSQL + &#39;Kill &#39; + Convert(varchar, SPId) + &#39;;&#39;&lt;br/&gt;FROM MASTER..SysProcesses&lt;br/&gt;WHERE DBId = DB_ID(@DbName) AND SPId  @@SPId&lt;br/&gt;&lt;br/&gt;EXEC(@EXECSQL)&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Technique - II&lt;/strong&gt;&lt;br/&gt;Take the database into Single User Mode and execute all the task needs to perform against the databse.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]ALTER DATABASE [Database Name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE [/sourcecode]&lt;br/&gt;&lt;br/&gt;Once you are finish with all the required task make the database accessible to everyone.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]ALTER DATABASE [Database Name] SET MULTI_USER[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Technique - III&lt;/strong&gt;&lt;br/&gt;In case of restore the database by replacing existing database, you can take the database OFFLINE and restore it. Restore will bring the database online.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;ALTER DATABASE [Database Name] SET OFFLINE WITH ROLLBACK IMMEDIATE [/sourcecode]&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;ALTER DATABASE [Database Name] SET ONLINE&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Technique - IV&lt;/strong&gt;&lt;br/&gt;Go to Activity Monitor, Select the desired database and right click on the database to KILL the process.&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/activity.jpg&quot;&gt;&lt;img src=&quot;http://sqldbpool.files.wordpress.com/2011/06/activity.jpg&quot; alt=&quot;&quot; title=&quot;Activity&quot; width=&quot;270&quot; height=&quot;383&quot; class=&quot;aligncenter size-full wp-image-1333&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/1490380003624274015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/06/how-to-kill-all-sessions-that-have-open.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1490380003624274015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1490380003624274015'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/06/how-to-kill-all-sessions-that-have-open.html' title='How to kill all sessions that have open connection in a SQL Server&#xa;Database?'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-2562029065638944845</id><published>2011-06-01T10:13:00.000-07:00</published><updated>2011-11-02T10:42:00.422-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CDC"/><category scheme="http://www.blogger.com/atom/ns#" term="Change Data Capture"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>Change Data Capture in SQL Server 2008</title><content type='html'>&lt;strong&gt;Change Data Capture (CDC)&lt;/strong&gt; is a new feature in SQL Server 2008 which records insert, update and delete activity in SQL Server tables.&lt;br/&gt;&lt;br/&gt;CDC is intended to capture &lt;strong&gt;insert, update and delete&lt;/strong&gt; activity on a SQL table and place the information into a separate relational table.  It uses an &lt;strong&gt;asynchronous capture mechanism&lt;/strong&gt; that reads the transaction logs and populates the CDC table with the row&#39;s data which change.  The CDC table mirrors the column structure of the tracked table, together with metadata regarding the change.&lt;br/&gt;&lt;br/&gt;To use the CDC feature, first we have to enable it database level. You can use below query to retrieve the CDC enabled databases.&lt;br/&gt;&lt;br/&gt;&lt;h1&gt;&lt;strong&gt;Steps to Enable the CDC on database level&lt;/strong&gt;&lt;/h1&gt;&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;USE master&lt;br/&gt;GO&lt;br/&gt;SELECT [name], database_id, is_cdc_enabled &lt;br/&gt;FROM sys.databases where is_cdc_enabled &amp;amp;lt;&amp;amp;gt; 0     &lt;br/&gt;GO[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc1.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-1311&quot; title=&quot;CDC1&quot; src=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc1.jpg&quot; alt=&quot;&quot; width=&quot;435&quot; height=&quot;197&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;You can use below script to create the sample database and table&lt;br/&gt;&lt;br/&gt;&lt;code&gt;create database SQLDBPool&lt;br/&gt;go&lt;/code&gt;&lt;br/&gt;&lt;h2&gt;&lt;strong&gt;Sample DB and Table Creation Script&lt;/strong&gt;&lt;/h2&gt;&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;use sqldbpool&lt;br/&gt;create table Employee&lt;br/&gt;(&lt;br/&gt;empID int constraint PK_Employee primary key Identity(1,1)&lt;br/&gt;,empName varchar(20)&lt;br/&gt;,salary int&lt;br/&gt;)&lt;br/&gt;&lt;br/&gt;insert into Employee values(&#39;Jugal&#39;,&#39;50000000&#39;),(&#39;Abhinav&#39;,1000),(&#39;Sunil&#39;,2000)[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;To enable CDC on database SQLDBPool execute the below query.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;USE SQLDBPool&lt;br/&gt;GO&lt;br/&gt;EXEC sys.sp_cdc_enable_db[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Once you have enabled the CDC for the database, you can see the CDC schema, CDC User and CDC tables in the database. Please see the below images for more information.&lt;br/&gt;&lt;br/&gt;&lt;h2&gt;&lt;strong&gt;CDC Schema, CDC User and CDC system tables&lt;/strong&gt;&lt;/h2&gt;&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc21.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-1315&quot; title=&quot;CDC2&quot; src=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc21.jpg&quot; alt=&quot;&quot; width=&quot;232&quot; height=&quot;371&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc3.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-1313&quot; title=&quot;CDC3&quot; src=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc3.jpg&quot; alt=&quot;&quot; width=&quot;239&quot; height=&quot;181&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;cdc.captured_columns&lt;/strong&gt; – Returns list of captured column&lt;br/&gt;&lt;strong&gt;cdc.change_tables&lt;/strong&gt; – Returns list of all the CDC enabled tables&lt;br/&gt;&lt;strong&gt;cdc.ddl_history&lt;/strong&gt; – Records history of all the DDL changes since capture data enabled&lt;br/&gt;&lt;strong&gt;cdc.index_columns&lt;/strong&gt; – Contains indexes associated with change table&lt;br/&gt;&lt;strong&gt;cdc.lsn_time_mapping&lt;/strong&gt; – Maps LSN number and time&lt;br/&gt;&lt;br/&gt;&lt;h2&gt;&lt;strong&gt;Enable CDC on Table&lt;/strong&gt;&lt;/h2&gt;&lt;br/&gt;As CDC feature can be applied at the table-level to any CDC enabled database. You can run below query to enable the CDC on the table.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Please note:&lt;/strong&gt;&lt;br/&gt;- You must have database owner permission &lt;strong&gt;(db_Owner fixed role)&lt;/strong&gt;&lt;br/&gt;- SQL Agent Service must be running&lt;br/&gt;&lt;br/&gt;Using sys.sp_cdc_enable_table procedure we can enable the CDC at the table level. You can specify all the below different options as required.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;@source_schema&lt;/strong&gt; is the schema name of the table that you want to enable for CDC&lt;br/&gt;&lt;strong&gt;@source_name&lt;/strong&gt; is the table name that you want to enable for CDC&lt;br/&gt;&lt;strong&gt;@role_name&lt;/strong&gt; is a database role which will be used to determine whether a user can access the CDC data; the role will be created if it doesn&#39;t exist.&lt;br/&gt;&lt;strong&gt;@supports_net_changes&lt;/strong&gt; determines whether you can summarize multiple changes into a single change record; set to 1 to allow, 0 otherwise.&lt;br/&gt;&lt;strong&gt;@capture_instance&lt;/strong&gt; is a name that you assign to this particular CDC instance; you can have up two instances for a given table.&lt;br/&gt;&lt;strong&gt;@index_name&lt;/strong&gt; is the name of a unique index to use to identify rows in the source table; you can specify NULL if the source table has a primary key.&lt;br/&gt;&lt;strong&gt;@captured_column_list&lt;/strong&gt; is a comma-separated list of column names that you want to enable for CDC; you can specify NULL to enable all columns.&lt;br/&gt;&lt;strong&gt;@filegroup_name&lt;/strong&gt; allows you to specify the FILEGROUP to be used to store the CDC change tables.&lt;br/&gt;&lt;strong&gt;@partition_switch&lt;/strong&gt; allows you to specify whether the ALTER TABLE SWITCH PARTITION command is allowed&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;USE SQLDBPool&lt;br/&gt;GO&lt;br/&gt;EXEC sys.sp_cdc_enable_table&lt;br/&gt;@source_schema = N&#39;dbo&#39;,&lt;br/&gt;@source_name = N&#39;Employee&#39;,&lt;br/&gt;@role_name = NULL&lt;br/&gt;GO[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc4.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-1317&quot; title=&quot;CDC4&quot; src=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc4.jpg&quot; alt=&quot;&quot; width=&quot;361&quot; height=&quot;220&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;cdc.SQLDBPool_capture&lt;/strong&gt; – Capture the changes by doing log scan&lt;br/&gt;&lt;strong&gt;cdc. SQLDBPool _cleanup&lt;/strong&gt; –Clean Up the database changes tables.&lt;br/&gt;&lt;br/&gt;Once the above query executes successfully, it will create 1 more system table cdc.dbo.Employee_CT for the tracking purpose.&lt;br/&gt;&lt;br/&gt;See the result of the SELECT query on both the tables.&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc5.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-1319&quot; title=&quot;CDC5&quot; src=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc5.jpg&quot; alt=&quot;&quot; width=&quot;572&quot; height=&quot;241&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;Below 5 additional columns are available into cdc.dbo.Employee_CT table.&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc6.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-1321&quot; title=&quot;CDC6&quot; src=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc6.jpg&quot; alt=&quot;&quot; width=&quot;280&quot; height=&quot;164&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;__$operation&lt;/strong&gt; and &lt;strong&gt;__$update_mask &lt;/strong&gt;are very important columns. __$operation table contains the value against the DML operations.&lt;br/&gt;&lt;br/&gt;1 = Delete Statement&lt;br/&gt;2 = Insert Statement&lt;br/&gt;3 = Value before Update Statement&lt;br/&gt;4 = Value after Update Statement&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;__$update_mask &lt;/strong&gt;A bit mask with a bit corresponding to each captured column identified for the capture instance. This value has all defined bits set to 1 when __$operation = 1 or 2. When __$operation = 3 or 4, only those bits corresponding to columns that changed are set to 1.&lt;br/&gt;&lt;br/&gt;&lt;h2&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/h2&gt;Execute the below query on the SQLDBPool database.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;insert into Employee values(&#39;DJ&#39;,&#39;10000&#39;)&lt;br/&gt;delete Employee where empName = &#39;DJ&#39;&lt;br/&gt;update Employee set salary = 10 where Empname = &#39;Sunil&#39;[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;select * from Employee&lt;br/&gt;select * from cdc.dbo_Employee_CT[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc7.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-1323&quot; title=&quot;CDC7&quot; src=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc7.jpg&quot; alt=&quot;&quot; width=&quot;630&quot; height=&quot;342&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;You can get more information on the CDC configuration by executing sys.sp_cdc_help_change_data_capture stored procedure.&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc8.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-1324&quot; title=&quot;CDC8&quot; src=&quot;http://sqldbpool.files.wordpress.com/2011/06/cdc8.jpg&quot; alt=&quot;&quot; width=&quot;630&quot; height=&quot;144&quot; /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;You can disable the CDC either on the table level or the database level. Use below code to disable the CDC on table or database level.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Table Level&lt;/strong&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;exec sys.sp_cdc_disable_table&lt;br/&gt;@source_schema = &#39;dbo&#39;,&lt;br/&gt;@source_name = &#39;Employee&#39;,&lt;br/&gt;@capture_instance = &#39;dbo_Employee&#39; [/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Database Level&lt;/strong&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;use SQLDBPool;&lt;br/&gt;go&lt;br/&gt;sys.sp_cdc_disable_db[/sourcecode]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;CleanUp Job&lt;/strong&gt;&lt;br/&gt;As we checked in the above example that CDC is capturing all the changes at the table level which create the disk space issue. To resolve disk space issue we have clean up job which run every 3 days interval by default. We can schedule it to run as per our requirement.</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/2562029065638944845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/06/change-data-capture-in-sql-server-2008.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2562029065638944845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2562029065638944845'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/06/change-data-capture-in-sql-server-2008.html' title='Change Data Capture in SQL Server 2008'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-6118412620722181969</id><published>2011-05-30T06:26:00.000-07:00</published><updated>2011-11-02T10:42:00.403-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Click to Download</title><content type='html'>&lt;h2&gt;&lt;span style=&quot;text-decoration:underline;&quot;&gt;&lt;a href=&quot;https://sites.google.com/a/sqldbpool.com/consult-me/home&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;Download SQL Server Interview Question&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;br/&gt;&lt;br/&gt;&lt;h2&gt;&lt;span style=&quot;text-decoration:underline;&quot;&gt;&lt;a href=&quot;https://sites.google.com/a/sqldbpool.com/consult-me/home&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt; Download how to be Database Administrator PDF file&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/6118412620722181969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/click-to-download.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/6118412620722181969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/6118412620722181969'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/click-to-download.html' title='Click to Download'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-7574645944152944475</id><published>2011-05-23T04:40:00.000-07:00</published><updated>2011-11-02T10:42:00.382-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><category scheme="http://www.blogger.com/atom/ns#" term="sysmanagement_shared_registered_servers_internal"/><category scheme="http://www.blogger.com/atom/ns#" term="sysmanagement_shared_server_groups_internal"/><title type='text'>SQL Server Central Management Servers System Tables</title><content type='html'>&lt;strong&gt;Problem&lt;/strong&gt;I have SQL Server Central Management Servers setup in my environment. How can I get a list of the registered servers and their associated properties? Are there any queries I can issue? Check out this tip to learn more.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solutions&lt;/strong&gt;&lt;br/&gt;&lt;a href=&quot;http://www.mssqltips.com/tip.asp?tip=2397&quot; target=&quot;_blank&quot;&gt;http://www.mssqltips.com/tip.asp?tip=2397&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/7574645944152944475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/sql-server-central-management-servers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/7574645944152944475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/7574645944152944475'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/sql-server-central-management-servers.html' title='SQL Server Central Management Servers System Tables'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-7408979950127952794</id><published>2011-05-17T09:22:00.000-07:00</published><updated>2011-11-02T10:42:00.359-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Error fix"/><category scheme="http://www.blogger.com/atom/ns#" term="Restore"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><title type='text'>Bug Fix:The I/O operation has been aborted because of either a thread&#xa;exit or an application request</title><content type='html'>&lt;strong&gt;&lt;span style=&quot;text-decoration:underline;&quot;&gt;Error&lt;/span&gt;&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;&lt;span style=&quot;color:#800000;&quot;&gt;Read on &quot;VDI_FCA0B3E9&quot; failed: 995(The I/O operation has been aborted because of either a thread exit or an application request.)&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span style=&quot;color:#800000;&quot;&gt;The media family on device LiteSpeed for SQL Server backup file is incorrectly formed. SQL Server cannot process this media family.&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br/&gt;In recent times I came across the above error, while restoring the database. We are using the Quest LiteSpeed for the backup/restore. As per the request from the user we have started the restore of the database from the production box to development box.&lt;br/&gt;&lt;br/&gt;Restore Query is failing with the above error. I have follow the below checklist to fix the error.&lt;br/&gt;&lt;ol&gt;&lt;br/&gt;	&lt;li&gt;Check for the LiteSpeed version on both the boxes&lt;/li&gt;&lt;br/&gt;	&lt;li&gt;Verified the backup file&lt;/li&gt;&lt;br/&gt;	&lt;li&gt;Verified the backup file path&lt;/li&gt;&lt;br/&gt;&lt;/ol&gt;&lt;br/&gt;I got the positive result on all the above tests but still the restore is failing. At last I checked the one day old emails and found that, production box was migrated from SQL Server 2005 to SQL Server 2008. As you may know that we can&#39;t restore the database from &lt;strong&gt;higher version to lower version &lt;/strong&gt;because of that restore was failed.&lt;br/&gt;&lt;br/&gt;Finally I have restore the database on the different SQL Server 2008 development box and up-grade the SQL Server 2005 box with SQL Server 2008&lt;br/&gt;&lt;br/&gt;If you come across such kind of error, make sure you are checking the &lt;strong&gt;SQL Server version&lt;/strong&gt; and &lt;strong&gt;LiteSpeed version &lt;/strong&gt;on both source and destination machine.</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/7408979950127952794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/bug-fixthe-io-operation-has-been.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/7408979950127952794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/7408979950127952794'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/bug-fixthe-io-operation-has-been.html' title='Bug Fix:The I/O operation has been aborted because of either a thread&#xa;exit or an application request'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-2820343897770729632</id><published>2011-05-04T08:23:00.000-07:00</published><updated>2011-11-02T10:42:00.336-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><title type='text'>Customize SSMS query window for standard comment block and frequently&#xa;used commands</title><content type='html'>&lt;h2&gt;Problem&lt;/h2&gt;&lt;br/&gt;As a best practice, most companies follow a standard comment format at the beginning of stored procedures and functions. In addition, it is also a good idea to include comments in all scripts you write even if they are just save as .sql or .txt files.  Manually we often add a standard comment block to the header of our scripts using copy and paste, but in this tip we look at how to automate adding a standard comment block for every set of code we write using SSMS.&lt;br/&gt;&lt;h2&gt;Solution&lt;/h2&gt;&lt;br/&gt;&lt;a href=&quot;http://www.mssqltips.com/tip.asp?tip=2372&quot; target=&quot;_blank&quot;&gt;http://www.mssqltips.com/tip.asp?tip=2372&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/2820343897770729632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/customize-ssms-query-window-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2820343897770729632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2820343897770729632'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/customize-ssms-query-window-for.html' title='Customize SSMS query window for standard comment block and frequently&#xa;used commands'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-3292397893040389245</id><published>2011-05-01T23:13:00.000-07:00</published><updated>2011-11-02T10:42:00.319-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Remote DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><title type='text'>Bug Fix:Cannot find template file for the new query</title><content type='html'>&lt;strong&gt;Error&lt;/strong&gt;&lt;br/&gt;Cannot find template file for the new query (&#39;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\SQL\SQLFile.sql&#39;)&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br/&gt;&lt;strong&gt;Step 1:  &lt;/strong&gt;Go to C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\SQL\&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Create .SQL File named SQLFile.SQL</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/3292397893040389245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/bug-fixcannot-find-template-file-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/3292397893040389245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/3292397893040389245'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/05/bug-fixcannot-find-template-file-for.html' title='Bug Fix:Cannot find template file for the new query'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-1032508728036564777</id><published>2011-04-26T10:07:00.000-07:00</published><updated>2011-11-02T10:42:00.284-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Remote DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>DMV to identify database features restricted to specific edition of SQL&#xa;Server 2008</title><content type='html'>If you have configured the user database any of below feature of SQL Server 2008 Enterprise Edition &lt;br/&gt;&lt;br/&gt;-- Data Compression &lt;br/&gt;-- Partitioning&lt;br/&gt;-- Transparent Data Encryption &lt;br/&gt;-- Change Data Capture&lt;br/&gt;&lt;br/&gt;Above list of features will internally change the way the database engine stores information within the database files. If a database configured to use any of the above features which are specifically designed to be used in Enterprise Edition of SQL Server 2008, it cannot be moved to other editions of SQL Server 2008. &lt;br/&gt;&lt;br/&gt;You can check the above feature by querying the &lt;strong&gt;sys.dm_db_persisted_sku_features&lt;/strong&gt; DMV against database.&lt;br/&gt;&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;SELECT feature_name FROM sys.dm_db_persisted_sku_features ;&lt;br/&gt;GO[/sourcecode]</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/1032508728036564777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/04/dmv-to-identify-database-features.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1032508728036564777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1032508728036564777'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/04/dmv-to-identify-database-features.html' title='DMV to identify database features restricted to specific edition of SQL&#xa;Server 2008'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-1206317246125855003</id><published>2011-04-25T22:38:00.000-07:00</published><updated>2011-11-02T10:42:00.266-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>How to enable Dedicated Administrator Connection Feature in SQL Server&#xa;2008?</title><content type='html'>&lt;strong&gt;DAC&lt;/strong&gt; feature added from the SQL Server 2005 version. Using &lt;strong&gt;DAC&lt;/strong&gt; feature a &lt;em&gt;Database Administrator&lt;/em&gt; can connect to a SQL Server Instance when the database engine is not responding to regular connections and troubleshoot the issue.&lt;br/&gt;&lt;br/&gt;Advantage of using DAC is DBA can connect to a SQL Server Instance and execute T-SQL commands to troubleshoot and fix issues rather than rebooting the SQL Server which could lead to database corruption or other problems.&lt;br/&gt;&lt;br/&gt;By default &lt;strong&gt;DAC is disable&lt;/strong&gt;, it is a best practice to enable the DAC.&lt;br/&gt;We can enable the DAC using below T-SQL command.&lt;br/&gt;[sourcecode language=&quot;sql&quot;]&lt;br/&gt;Use master&lt;br/&gt;GO&lt;br/&gt;sp_configure &#39;show advanced options&#39; , 1&lt;br/&gt;GO&lt;br/&gt;sp_configure &#39;remote admin connections&#39;, 1&lt;br/&gt;GO&lt;br/&gt;RECONFIGURE&lt;br/&gt;GO&lt;br/&gt;[/sourcecode]&lt;br/&gt;&lt;br/&gt;In SQL Server 2008 to enable the  &lt;strong&gt;DAC&lt;/strong&gt;, right click on SQL Server and &lt;strong&gt;Select facets&lt;/strong&gt; and from facets drop down Select &lt;strong&gt;Surface Area Configuration&lt;/strong&gt;.&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://sqldbpool.files.wordpress.com/2011/04/dac.jpg&quot;&gt;&lt;img src=&quot;http://sqldbpool.files.wordpress.com/2011/04/dac.jpg&quot; alt=&quot;&quot; title=&quot;DAC&quot; width=&quot;614&quot; height=&quot;461&quot; class=&quot;aligncenter size-full wp-image-1271&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/1206317246125855003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/04/how-to-enable-dedicated-administrator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1206317246125855003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/1206317246125855003'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/04/how-to-enable-dedicated-administrator.html' title='How to enable Dedicated Administrator Connection Feature in SQL Server&#xa;2008?'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-2528596146465296965</id><published>2011-04-23T03:07:00.000-07:00</published><updated>2011-11-02T10:42:00.242-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008 R2"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2011 (Denali)"/><title type='text'>How to Turn Off SSMS Auto Recovery Feature</title><content type='html'>&lt;strong&gt;Problem&lt;/strong&gt;&lt;br/&gt;By default the Auto Recovery feature is enabled for SSMS and because of this when opening SSMS it may hang or become unresponsive for some time if the previous session was closed unexpectedly.  There is not a way to turn this feature off from within SSMS, but we will look at how this can be done by modifying some registry entries.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br/&gt;&lt;a href=&quot;http://www.mssqltips.com/tip.asp?tip=2352&quot; target=&quot;_blank&quot;&gt;http://www.mssqltips.com/tip.asp?tip=2352&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/2528596146465296965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/04/how-to-turn-off-ssms-auto-recovery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2528596146465296965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/2528596146465296965'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/04/how-to-turn-off-ssms-auto-recovery.html' title='How to Turn Off SSMS Auto Recovery Feature'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5371298094647745633.post-9104519109723495302</id><published>2011-04-12T23:16:00.000-07:00</published><updated>2011-11-02T10:42:00.191-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Steps to Learn Basic SQL</title><content type='html'>Problem: I have been often posted with a question that, I want to learn T-SQL and I don&#39;t know any basics of T-SQL.&lt;br/&gt;&lt;br/&gt;Solution:&lt;br/&gt;To start with the Basic T-SQL and practice, there is very good site &lt;strong&gt;W3Schools.com&lt;/strong&gt; You can learn and practice SQL there.&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://www.w3schools.com/sql/default.asp&quot;&gt;http://www.w3schools.com/sql/default.asp&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqldbguru.blogspot.com/feeds/9104519109723495302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqldbguru.blogspot.com/2011/04/steps-to-learn-basic-sql.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/9104519109723495302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5371298094647745633/posts/default/9104519109723495302'/><link rel='alternate' type='text/html' href='http://sqldbguru.blogspot.com/2011/04/steps-to-learn-basic-sql.html' title='Steps to Learn Basic SQL'/><author><name>AI based trading</name><uri>http://www.blogger.com/profile/01144956347104239199</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>