<?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: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-3759083553109072454</id><updated>2011-11-28T00:49:47.504+01:00</updated><category term='logging'/><category term='Distributed Transaction Coordinator'/><category term='SQL Server Agent'/><category term='Enable mail profile'/><category term='pound sign'/><category term='move clause'/><category term='full recovery'/><category term='wireless zero configuration'/><category term='replication error'/><category term='resolution'/><category term='insert'/><category term='drop constraint'/><category term='SSMS'/><category term='shortcut'/><category term='t-sql'/><category term='restore'/><category term='starting time'/><category term='test-path'/><category term='schema owner'/><category term='row_number'/><category term='WGA'/><category term='function'/><category term='Dell'/><category term='full backup'/><category term='norecovery'/><category term='macro'/><category term='performance'/><category term='collation'/><category term='SSIS'/><category term='double quotes'/><category term='file exist'/><category term='laptop'/><category term='backup'/><category term='viewing'/><category term='execution permission'/><category term='foreign key'/><category term='case sensitive'/><category term='SQLServerManager10.msc'/><category term='foreach'/><category term='DAC'/><category term='restore database'/><category term='object variable'/><category term='transaction log backup'/><category term='IIS'/><category term='common table expression'/><category term='resultset'/><category term='system stored procedure'/><category term='reste remote desktop session'/><category term='wireless network'/><category term='remote desktop'/><category term='statistics'/><category term='database publishing wizard'/><category term='character map'/><category term='linked server'/><category term='table variable'/><category term='windows server 2008'/><category term='database diagram'/><category term='server name'/><category term='SQL Server'/><category term='log visits'/><category term='full screen'/><category term='bcp'/><category term='isnumeric'/><category term='bulk insert'/><category term='database files'/><category term='Connection String'/><category term='cmdlet'/><category term='duplicate'/><category term='PowerShell'/><category term='sp_helpdb'/><category term='monitor'/><category term='restoring'/><category term='change instance name'/><category term='restorehistory'/><category term='catalog view'/><category term='recovery'/><category term='checkdb'/><category term='SQL Server Configuration Manager'/><category term='drop database'/><category term='stored procedures'/><category term='stored procedure'/><category term='alter authorization'/><category term='logical file'/><category term='scripting schema'/><category term='tempdb'/><category term='Job Notification'/><category term='dm_db_index_usage_stats'/><category term='num lock'/><category term='csv export'/><category term='disk space'/><category term='temp table'/><category term='Edition Upgrade'/><category term='Window Genuine Advantage'/><category term='Integrated Security'/><category term='identity'/><category term='enable network DTC access'/><category term='index'/><category term='DBCC'/><category term='command line'/><category term='distributed transaction'/><category term='progress'/><category term='replication'/><title type='text'>SQLNovice</title><subtitle type='html'>From novice to professional on SQL Server technology</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>51</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-7936826396040445991</id><published>2010-09-14T11:46:00.002+02:00</published><updated>2010-09-14T11:51:07.627+02:00</updated><title type='text'>Where to find how many CPU's there are in your server?</title><content type='html'>Some simple hints:&lt;br /&gt;&lt;br /&gt;for version 2000+: exec xp_msver 'ProcessorCount'&lt;br /&gt;&lt;br /&gt;for version 2005+ : sys.dm_os_sys_info&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-7936826396040445991?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/7936826396040445991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/09/where-to-find-how-many-cpus-there-are.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7936826396040445991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7936826396040445991'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/09/where-to-find-how-many-cpus-there-are.html' title='Where to find how many CPU&apos;s there are in your server?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-6817580261577210169</id><published>2010-09-10T10:15:00.004+02:00</published><updated>2010-09-10T10:36:43.825+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='system stored procedure'/><category scheme='http://www.blogger.com/atom/ns#' term='sp_helpdb'/><title type='text'>Flaw in sp_helpdb system stored procedure</title><content type='html'>Well, it is the first time ever for me to encounter this problem, so I documented it here with 3external links which explain the cause and solution pertty well already: &lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/125488/flaw-in-sp-helpdb"&gt;link1&lt;/a&gt;, &lt;a href="http://www.mssqltips.com/tip.asp?tip=1217"&gt;link2&lt;/a&gt;, &lt;a href="http://fogcreek.com/FogBugz/kb/errors/CannotinsertthevalueNULLi.html"&gt;link3&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The script to quickly locate databases without owners is:&lt;br /&gt;&lt;br /&gt;select name from master..sysdatabases&lt;br /&gt;where suer_sname(sid) is null&lt;br /&gt;go&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-6817580261577210169?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/6817580261577210169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/09/flaw-in-sphelpdb-system-stored.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6817580261577210169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6817580261577210169'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/09/flaw-in-sphelpdb-system-stored.html' title='Flaw in sp_helpdb system stored procedure'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4394836401377762058</id><published>2010-08-10T17:32:00.003+02:00</published><updated>2010-08-10T17:35:34.359+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='isnumeric'/><category scheme='http://www.blogger.com/atom/ns#' term='function'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Watch out function isnumeric!</title><content type='html'>You might get hit hard when you try to use it in some conditional clauses.&lt;br /&gt;&lt;br /&gt;select isnumeric('.') --&gt;1&lt;br /&gt;&lt;br /&gt;select isnumeric(',') --&gt;1&lt;br /&gt;&lt;br /&gt;select isnumeric('1,1,1') --&gt;1&lt;br /&gt;&lt;br /&gt;select isnumeric('1,1.1') --&gt;1&lt;br /&gt;&lt;br /&gt;select isnumeric('1.1.1') --&gt;0&lt;br /&gt;&lt;br /&gt;select isnumeric('1D1') --&gt;1&lt;br /&gt;&lt;br /&gt;select isnumeric('1d1') --&gt;1&lt;br /&gt;&lt;br /&gt;select isnumeric('1E1') --&gt;1&lt;br /&gt;&lt;br /&gt;select isnumeric('1d1') --&gt;1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4394836401377762058?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4394836401377762058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/08/watch-out-function-isnumeric.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4394836401377762058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4394836401377762058'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/08/watch-out-function-isnumeric.html' title='Watch out function isnumeric!'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-1077352169562398108</id><published>2010-03-24T13:54:00.005+01:00</published><updated>2010-03-29T16:18:44.199+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='duplicate'/><category scheme='http://www.blogger.com/atom/ns#' term='common table expression'/><category scheme='http://www.blogger.com/atom/ns#' term='row_number'/><title type='text'>Removing full duplicates by using row_number() function and common table expression</title><content type='html'>This blog article is inspired by another very informative &lt;a href="http://www.databasejournal.com/features/mssql/article.php/3572301/RowNumber-function-in-SQL-Server-2005.htm"&gt;one&lt;/a&gt; which explains really well the meaning of  the new row_number() function introduced since SQL2005. Since the original article did not give a full answer to how to delete multiple fully duplicated rows in a table, I am putting my code here for the test.&lt;br /&gt;&lt;br /&gt;The good thing about row_number() function is that it can be based on partition of columns. New row number count starts for each partition of full duplicates and those rows with row number bigger than 1 can be easily spotted and removed. Here is the example that explains everything I am talking about here.&lt;br /&gt;&lt;br /&gt;First of all, create a table in a test db&lt;br /&gt;&lt;span style="font-style: italic;font-size:78%;" &gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;USE [test_db]&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-size:78%;" &gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;CREATE TABLE [dbo].[Employee](&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    [EMPID] [int] NULL,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    [FNAME] [varchar](50) NULL,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    [LNAME] [varchar](50) NULL&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;) ON [PRIMARY]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then let's insert many duplicated rows:&lt;br /&gt;&lt;span style="color: rgb(51, 204, 255);font-size:85%;" &gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (2021110, 'MICHAEL', 'POLAND')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (2021110, 'MICHAEL', 'POLAND')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (2021115, 'JIM', 'KENNEDY')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (2021115, 'JIM', 'KENNEDY')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (2021115, 'JIM', 'KENNEDY')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (2121000, 'JAMES', 'SMITH')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (2121000, 'JAMES', 'SMITH')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (2011111, 'ADAM', 'ACKERMAN')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (3015670, 'MARTHA', 'LEDERER')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (3015670, 'MARTHA', 'LEDERER')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (3015670, 'MARTHA', 'LEDERER')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (3015670, 'MARTHA', 'LEDERER')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;INSERT INTO EMPLOYEE  (EMPID, FNAME, LNAME) &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;VALUES (1021710, 'MARIAH', 'MANDEZ')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);font-size:78%;" &gt;GO&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;If you selete everything from this table now, the following should be there:&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-size:85%;" &gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;EMPID    FNAME    LNAME&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;1021710    MARIAH    MANDEZ&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2011111    ADAM    ACKERMAN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2021110    MICHAEL    POLAND&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2021110    MICHAEL    POLAND&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2021115    JIM    KENNEDY&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2021115    JIM    KENNEDY&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2021115    JIM    KENNEDY&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2121000    JAMES    SMITH&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2121000    JAMES    SMITH&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;3015670    MARTHA    LEDERER&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;3015670    MARTHA    LEDERER&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;3015670    MARTHA    LEDERER&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;3015670    MARTHA    LEDERER&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;And here comes the de-dup script with the help of common table expression:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-size:78%;" &gt;with temp_employee as&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-size:78%;" &gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;(    select row_number() over (partition by EMPID, FNAME, LNAME order by EMPID) as rowid, * from EMPLOYEE)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;delete  temp_employee where rowid &gt; 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hope this article is illustrative enough.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-1077352169562398108?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/1077352169562398108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/removing-full-duplicates-by-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1077352169562398108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1077352169562398108'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/removing-full-duplicates-by-using.html' title='Removing full duplicates by using row_number() function and common table expression'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-2368605496647871025</id><published>2010-03-18T10:34:00.003+01:00</published><updated>2010-03-18T12:06:52.176+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='t-sql'/><title type='text'>Several tips about query performance optimization</title><content type='html'>The original article is &lt;a href="http://www.sql-programmers.com/Blog/tabid/153/EntryId/21/SQL-Server-Query-Performance-Optimization.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The 4 following tips are particularly  helpful and can be immediately put into daily use:&lt;br /&gt;&lt;br /&gt;&lt;span id="dnn_ctr496_MainView_ViewEntry_lblEntry"&gt;&lt;h3&gt;Views and Stored  Procedures&lt;/h3&gt; &lt;p&gt;We can avoid using heavy duty queries by using stored procedures and  views. Stored procedures are commonly used flexible database programming  objects.  Stored procedures are compiled once, so it will not create  the execution plan every time, thus reducing your network traffic. Views  give more security. For example, you have a table containing sensitive  data; you might wish to hide those columns from certain users, you can  use views.&lt;/p&gt;&lt;p&gt;&lt;span id="dnn_ctr496_MainView_ViewEntry_lblEntry"&gt;&lt;h3&gt;Table Variables&lt;/h3&gt; &lt;p&gt;Avoid temporary tables if you don’t need transactions on that table.  In that case you can use Table variables. When you create the temporary  table, it will create the physical table in the tempdb database.  However, if you create a table variable, it only resides in the memory.  It will be much faster than temporary tables, and table variables reduce  the recompilation of the code.&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Notes: a good practice is to use table variable where you need a small table to operate on, loading big table variable into memory simply erodes its performance gain by interfering with other in-memory activities of SQL Server.&lt;/p&gt;&lt;p&gt;&lt;span id="dnn_ctr496_MainView_ViewEntry_lblEntry"&gt;&lt;h3&gt;Row Count&lt;/h3&gt; &lt;p&gt;If you’re in the situation to use the count(*), then use the  following query. This is way faster than function count(), especially for huge tables with millions of rows&lt;span&gt;&lt;span class="keyword"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt;&lt;span&gt;&lt;span class="keyword"&gt;SELECT&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="keyword"&gt;rows&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class="keyword"&gt;FROM&lt;/span&gt;&lt;span&gt; sysindexes  &lt;/span&gt;&lt;span class="keyword"&gt;WHERE&lt;/span&gt;&lt;span&gt; id = OBJECT_ID(&lt;/span&gt;&lt;span class="string"&gt;'table_name'&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span class="op"&gt;AND&lt;/span&gt;&lt;span&gt; (indid &lt; 2) &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span id="dnn_ctr496_MainView_ViewEntry_lblEntry"&gt;&lt;h3&gt;Set No Count On&lt;/h3&gt; &lt;p&gt;If the No Count is off in your stored procedures, then the number of  rows affected value will be returned.  It will increase the network  traffic. Set No Count should be &lt;strong&gt;On&lt;/strong&gt; in your stored  procedures. Hence the number of rows affected will not return.&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-2368605496647871025?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/2368605496647871025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/several-tips-about-query-performance.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/2368605496647871025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/2368605496647871025'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/several-tips-about-query-performance.html' title='Several tips about query performance optimization'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-1409304405176003826</id><published>2010-03-15T11:23:00.003+01:00</published><updated>2010-03-15T11:31:54.014+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tempdb'/><title type='text'>How to move tempdb?</title><content type='html'>Today I got a call from our Window system admin that our production server is running low on C: drive. The cause turns out that the tempdb was bloated up and ate a huge chunk of disk space on our system drive. Since we have a separate drive F with plenty of free space, the task became how to move our tempdb from C: to F:. &lt;a href="http://www.sqlteam.com/article/moving-the-tempdb-database"&gt;Here&lt;/a&gt; is an article that sheds much light on this solution. I am giving a more detailed action path here.&lt;br /&gt;&lt;br /&gt;First of all, locate tempdb's files:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;use tempdb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;go&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;select * from sys.sysfiles&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;go&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then you'll have something like this:&lt;br /&gt;&lt;br /&gt;fileid    groupid    size    maxsize    growth    status    perf    name    filename&lt;br /&gt;1    1    1024    -1    10    1048578    0    tempdev    c:\temp\tempdb.mdf&lt;br /&gt;2    0    64    -1    10    1048642    0    templog    c:\temp\templog.ldf&lt;br /&gt;&lt;br /&gt;And the following script will move the database files to the designated locations:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;alter database tempdb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;modify file (name = tempdev, filename = 'F:\SQLDATA\tempdb.mdf')&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;go&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;alter database tempdb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;modify file (name = templog, filename = 'F:\SQLDATA\templog.ldf')&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;go&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But you'll also get a message saying:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;The file "tempdev" has been modified in the system catalog. The new path will be used the next time the database is started.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;The file "templog" has been modified in the system catalog. The new path will be used the next time the database is started.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The final step will be to restart SQL Sever service either from the SSMS directly or through windows services. Probably it is a better idea to do it outside working hours.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-1409304405176003826?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/1409304405176003826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/how-to-move-tempdb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1409304405176003826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1409304405176003826'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/how-to-move-tempdb.html' title='How to move tempdb?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-3141474661873997251</id><published>2010-03-10T11:29:00.004+01:00</published><updated>2010-03-10T11:31:46.802+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SSMS'/><category scheme='http://www.blogger.com/atom/ns#' term='DAC'/><title type='text'>DAC connection problem from SSMS</title><content type='html'>Here is a common error when using SQL Server's Dedicated Administrator Connection:&lt;br /&gt;&lt;br /&gt;'Dedicated administrator connections are not supported. (ObjectExplorer)'&lt;br /&gt;&lt;br /&gt;A quick answer is to NOT use 'new query' button, but instead use 'new database engine query' button.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://chopeen.blogspot.com/2006/08/dedicated-administrator-connections-are.html"&gt;Here&lt;/a&gt; is a more detailed article regarding this issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-3141474661873997251?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/3141474661873997251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/dac-connection-problem-from-ssms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3141474661873997251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3141474661873997251'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/dac-connection-problem-from-ssms.html' title='DAC connection problem from SSMS'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-3586614534391782180</id><published>2010-03-02T16:53:00.002+01:00</published><updated>2010-03-02T16:58:51.788+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='database diagram'/><category scheme='http://www.blogger.com/atom/ns#' term='viewing'/><title type='text'>How to grant viewing privileges of database diagrams to a user?</title><content type='html'>This is a biting question that I just bumped into today, it turns out MS has not supplied with established mechanisms to support distributing viewing privileges for database diagrams at least for SQL 2005 or 2008.  According to BOL:&lt;br /&gt;&lt;br /&gt;"Although any user with access to a database can create a diagram once it&lt;br /&gt;has been created, the only users who can see it are the diagram's creator and&lt;br /&gt;any member of the db_owner role."&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-3586614534391782180?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/3586614534391782180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/how-to-grant-viewing-privileges-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3586614534391782180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3586614534391782180'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/03/how-to-grant-viewing-privileges-of.html' title='How to grant viewing privileges of database diagrams to a user?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4270351693978206608</id><published>2010-02-26T10:41:00.002+01:00</published><updated>2010-02-26T10:47:54.935+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='schema owner'/><category scheme='http://www.blogger.com/atom/ns#' term='alter authorization'/><title type='text'>Drop User: The database principal owns a schema in the database, and cannot be dropped</title><content type='html'>This is a common error when dropping a user from a database when it owns some schema. Usually you can use SSMS UI to uncheck the user from the owned schema.&lt;br /&gt;&lt;br /&gt;After locating the owned schema by the user, the correct sql statement to change the owner of a schema is:&lt;br /&gt;&lt;br /&gt;alter authorization on schema::&lt;span style="font-style: italic;"&gt;schema_name&lt;/span&gt; to &lt;span style="font-style: italic;"&gt;user_name&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4270351693978206608?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4270351693978206608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/02/drop-user-database-principal-owns.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4270351693978206608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4270351693978206608'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/02/drop-user-database-principal-owns.html' title='Drop User: The database principal owns a schema in the database, and cannot be dropped'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-3873448513578280517</id><published>2010-02-18T15:37:00.001+01:00</published><updated>2010-02-18T15:39:30.981+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='reste remote desktop session'/><title type='text'>How to reset a remote desktop session when you can't remote desktop to the target server</title><content type='html'>A refusing remote server can be annoying when you have ever tried to connect to it because of some urgent issue.&lt;br /&gt;&lt;br /&gt;Solution is in this &lt;a href="http://www.howtogeek.com/howto/windows/command-line-hack-for-terminal-server-has-exceeded-the-maximum-number-of-allowed-connections/"&gt;link&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-3873448513578280517?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/3873448513578280517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/02/how-to-reset-remote-desktop-session.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3873448513578280517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3873448513578280517'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/02/how-to-reset-remote-desktop-session.html' title='How to reset a remote desktop session when you can&apos;t remote desktop to the target server'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-871315256012860270</id><published>2010-02-18T11:24:00.003+01:00</published><updated>2010-02-18T13:12:49.991+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='identity'/><category scheme='http://www.blogger.com/atom/ns#' term='insert'/><title type='text'>Understanding the Identity column</title><content type='html'>&lt;a href="http://www.sqlteam.com/article/understanding-identity-columns"&gt;Here&lt;/a&gt; is the original article.&lt;br /&gt;&lt;br /&gt;A common problem encountered by most DBA's is to insert values into a table with an identity column and "set identity_insert on &lt;span style="font-style: italic;"&gt;table_name&lt;/span&gt; on" should be used.&lt;br /&gt;&lt;br /&gt;Three quick ways to show the last identity value that was just inserted:&lt;br /&gt;&lt;br /&gt;select SCOPE_IDENTITY()&lt;br /&gt;&lt;br /&gt;select @@IDENTITY&lt;br /&gt;&lt;br /&gt;select ident_current('&lt;span style="font-style: italic;"&gt;table_name&lt;/span&gt;')&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The differences between them are stated in the above linked article.&lt;br /&gt;&lt;br /&gt;Another important command for reseeding the identity column is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;DBCC CHECKIDENT('&lt;span style="font-style: italic;"&gt;table_name&lt;/span&gt;', RESEED, 1)&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-871315256012860270?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/871315256012860270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/02/understanding-identity-column.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/871315256012860270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/871315256012860270'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/02/understanding-identity-column.html' title='Understanding the Identity column'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-6534032233489333882</id><published>2010-01-29T16:07:00.002+01:00</published><updated>2010-01-29T16:09:04.929+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='database files'/><category scheme='http://www.blogger.com/atom/ns#' term='disk space'/><title type='text'>Check available disk space in all the database files</title><content type='html'>Here is the script:&lt;br /&gt;&lt;br /&gt;use [db_name]&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;select name, size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') as int)/128.0 as AvailableSpaceInMB&lt;br /&gt;from sys.database_files&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;Knowing this info is a good guide for file shrinking operations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-6534032233489333882?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/6534032233489333882/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/check-available-disk-space-in-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6534032233489333882'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6534032233489333882'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/check-available-disk-space-in-all.html' title='Check available disk space in all the database files'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4616643380240645159</id><published>2010-01-29T12:06:00.002+01:00</published><updated>2010-01-29T12:09:46.479+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bcp'/><category scheme='http://www.blogger.com/atom/ns#' term='bulk insert'/><title type='text'>The link between bcp utility and the bulk insert statement</title><content type='html'>Just tried to find out the real difference between bcp utility and bulk insert statement and &lt;a href="http://msdn.microsoft.com/en-us/library/aa196743%28SQL.80%29.aspx"&gt;here&lt;/a&gt; is the article from Microsoft's official site.&lt;br /&gt;&lt;br /&gt;Quoted too: "The BULK INSERT statement allows you to bulk copy data to an instance of SQL Server using the functionality of the &lt;b&gt;bcp&lt;/b&gt; utility with a Transact-SQL statement, rather than from the command prompt."&lt;br /&gt;&lt;br /&gt;Therefore, it seems the whole "bulk insert" statement is purely another way of "bcp in" command.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4616643380240645159?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4616643380240645159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/link-between-bcp-utility-and-bulk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4616643380240645159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4616643380240645159'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/link-between-bcp-utility-and-bulk.html' title='The link between bcp utility and the bulk insert statement'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-3499361946772464674</id><published>2010-01-25T11:05:00.003+01:00</published><updated>2010-01-25T11:19:37.578+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='foreach'/><category scheme='http://www.blogger.com/atom/ns#' term='SSIS'/><category scheme='http://www.blogger.com/atom/ns#' term='object variable'/><category scheme='http://www.blogger.com/atom/ns#' term='resultset'/><title type='text'>The use of object varaibles, resultset and foreach loop in SSIS</title><content type='html'>I've recently been involved in documenting an SSIS package made by our lead developer and there is a foreach loop that he used to loop through a resultest from a query. An object variable is used to hold the resultset temporarily and the foreach loops through this result to repeat some actions. Since this trick is pretty new to me, I hence document a very good tutorial &lt;a href="http://www.sqlservercentral.com/articles/Integration+Services+%28SSIS%29/64014/"&gt;here&lt;/a&gt; to keep a memo.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-3499361946772464674?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/3499361946772464674/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/use-of-object-varaibles-resultset-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3499361946772464674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3499361946772464674'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/use-of-object-varaibles-resultset-and.html' title='The use of object varaibles, resultset and foreach loop in SSIS'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4885369083920063062</id><published>2010-01-12T11:36:00.001+01:00</published><updated>2010-01-12T11:37:19.105+01:00</updated><title type='text'>A very good article about the concept of filegroup</title><content type='html'>Here is the &lt;a href="http://www.mssqltips.com/tip.asp?tip=1112"&gt;link&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4885369083920063062?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4885369083920063062/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/very-good-article-about-concept-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4885369083920063062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4885369083920063062'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/very-good-article-about-concept-of.html' title='A very good article about the concept of filegroup'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-931452887969022335</id><published>2010-01-12T10:20:00.003+01:00</published><updated>2010-01-12T10:25:14.957+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='index'/><category scheme='http://www.blogger.com/atom/ns#' term='dm_db_index_usage_stats'/><title type='text'>Script to see index usage stats</title><content type='html'>&lt;p&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;SELECT&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:85%;" &gt;object_name&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;(&lt;/span&gt;&lt;span style="font-size:85%;"&gt;s&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:85%;" &gt;object_id&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;)&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;AS&lt;/span&gt;&lt;span style="font-size:85%;"&gt; ObjectName&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; s&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:85%;" &gt;object_id&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;name&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;as&lt;/span&gt;&lt;span style="font-size:85%;"&gt; IndexName&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;index_id&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_seeks&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_scans&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_lookups&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_updates&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;FROM&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);font-size:85%;" &gt;sys.dm_db_index_usage_stats&lt;/span&gt;&lt;span style="font-size:85%;"&gt; s &lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;INNER&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;JOIN&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);font-size:85%;" &gt;sys.indexes&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;ON&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:85%;" &gt;object_id&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; s&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:85%;" &gt;object_id&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;AND&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;index_id &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; s&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;index_id&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;WHERE&lt;/span&gt;&lt;span style="font-size:85%;"&gt; database_id &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:85%;" &gt;db_id&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;()&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;AND&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:85%;" &gt;objectproperty&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;(&lt;/span&gt;&lt;span style="font-size:85%;"&gt;s&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;.&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:85%;" &gt;object_id&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;,&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;'IsUserTable'&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;)&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 1&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;ORDER&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;BY&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;(&lt;/span&gt;&lt;span style="font-size:85%;"&gt;user_seeks &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_scans &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_lookups &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_updates&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);font-size:85%;" &gt;)&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;ASC&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#008000;"&gt; &lt;p&gt;-- Possible bad Indexes (writes &gt; reads)&lt;/p&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size:85%;"&gt; @dbid &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:85%;"&gt; @dbid &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt;db_id&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;()&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'Table Name'&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt;object_name&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;(&lt;/span&gt;&lt;span style="font-size:85%;"&gt;s&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt;object_id&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;),&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'Index Name'&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt;i&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;name&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;index_id&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;,&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'Total Writes'&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_updates&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'Total Reads'&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_seeks &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_scans &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_lookups&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;,&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'Difference'&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_updates &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;-&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;(&lt;/span&gt;&lt;span style="font-size:85%;"&gt;user_seeks &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_scans &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_lookups&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;)&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;FROM&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#008000;"&gt;sys.dm_db_index_usage_stats&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;AS&lt;/span&gt;&lt;span style="font-size:85%;"&gt; s &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;color:#808080;"&gt;INNER&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;JOIN&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#008000;"&gt;sys.indexes&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;AS&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;ON&lt;/span&gt;&lt;span style="font-size:85%;"&gt; s&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt;object_id&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt;object_id&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#808080;"&gt;AND&lt;/span&gt;&lt;span style="font-size:85%;"&gt; i&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;index_id &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; s&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;index_id&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt;objectproperty&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;(&lt;/span&gt;&lt;span style="font-size:85%;"&gt;s&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt;object_id&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;,&lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'IsUserTable'&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;)&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 1&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;color:#808080;"&gt;AND&lt;/span&gt;&lt;span style="font-size:85%;"&gt; s&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;database_id &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;"&gt; @dbid&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;color:#808080;"&gt;AND&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_updates &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;(&lt;/span&gt;&lt;span style="font-size:85%;"&gt;user_seeks &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_scans &lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;+&lt;/span&gt;&lt;span style="font-size:85%;"&gt; user_lookups&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;)&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;ORDER&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;BY&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'Difference'&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;DESC&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'Total Writes'&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;DESC&lt;/span&gt;&lt;span style="font-size:85%;color:#808080;"&gt;,&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;'Total Reads'&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;ASC&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-931452887969022335?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/931452887969022335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/script-to-see-index-usage-stats.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/931452887969022335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/931452887969022335'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/script-to-see-index-usage-stats.html' title='Script to see index usage stats'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-3891248941506952567</id><published>2010-01-06T15:36:00.002+01:00</published><updated>2010-01-06T15:38:38.582+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='collation'/><category scheme='http://www.blogger.com/atom/ns#' term='case sensitive'/><title type='text'>Case sensitive search query</title><content type='html'>To view the full list of all collocation ino, you can run the following query:&lt;br /&gt;&lt;br /&gt;SELECT * FROM fn_helpcollations()&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;For the real technique of enable case-sensitive search query, carry on and read &lt;a href="http://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/"&gt;this&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-3891248941506952567?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/3891248941506952567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/case-sensitive-search-query.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3891248941506952567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3891248941506952567'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/case-sensitive-search-query.html' title='Case sensitive search query'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-126604164088749825</id><published>2010-01-06T13:10:00.002+01:00</published><updated>2010-01-06T13:11:20.699+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bcp'/><title type='text'>bcp utility quick ref</title><content type='html'>I found the -c argument is interesting for dumping data out of database and then being open in Excel easily.&lt;br /&gt;&lt;br /&gt;The original post is &lt;a href="http://www.databasejournal.com/features/mssql/article.php/3391761/Utilize-BCP-with-SQL-Server-2000.htm"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-126604164088749825?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/126604164088749825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/bcp-utility-quick-ref.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/126604164088749825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/126604164088749825'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/bcp-utility-quick-ref.html' title='bcp utility quick ref'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-9007205373596074200</id><published>2010-01-06T12:19:00.001+01:00</published><updated>2010-01-06T12:20:17.202+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DBCC'/><category scheme='http://www.blogger.com/atom/ns#' term='checkdb'/><title type='text'>DBCC checkdb primer</title><content type='html'>&lt;a href="http://www.sql-server-pro.com/dbcc-checkdb.html"&gt;This&lt;/a&gt; is another very good article.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-9007205373596074200?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/9007205373596074200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/dbcc-checkdb-primer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/9007205373596074200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/9007205373596074200'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/dbcc-checkdb-primer.html' title='DBCC checkdb primer'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-474772343315117866</id><published>2010-01-05T15:25:00.002+01:00</published><updated>2010-01-05T15:26:47.619+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistics'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>You can add statistics on columns that don't have statistics in order to boost query performance.</title><content type='html'>This trick is totally something new to me. Please read further &lt;a href="http://www.sql-server-performance.com/tips/update_statistics_p1.aspx"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-474772343315117866?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/474772343315117866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/you-can-add-statistics-on-columns-that.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/474772343315117866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/474772343315117866'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2010/01/you-can-add-statistics-on-columns-that.html' title='You can add statistics on columns that don&apos;t have statistics in order to boost query performance.'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-5635280542765058532</id><published>2009-12-15T14:39:00.001+01:00</published><updated>2009-12-15T14:41:36.677+01:00</updated><title type='text'>How to script SQL Server 2008 diagrams and restore them</title><content type='html'>I got a recent request of restoring diagrams from one database to another and found an awesome solution in &lt;a href="http://www.conceptdevelopment.net/Database/ScriptDiagram2008/"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-5635280542765058532?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/5635280542765058532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/12/how-to-script-sql-server-2008-diagrams.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/5635280542765058532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/5635280542765058532'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/12/how-to-script-sql-server-2008-diagrams.html' title='How to script SQL Server 2008 diagrams and restore them'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-6038627710675283378</id><published>2009-12-13T14:26:00.002+01:00</published><updated>2009-12-13T14:27:09.892+01:00</updated><title type='text'>What SQL Statements Are Currently Executing?</title><content type='html'>&lt;a href="http://www.sqlservercentral.com/articles/DMV/64425/"&gt;This&lt;/a&gt; is a fundamentally useful script.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-6038627710675283378?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/6038627710675283378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/12/what-sql-statements-are-currently.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6038627710675283378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6038627710675283378'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/12/what-sql-statements-are-currently.html' title='What SQL Statements Are Currently Executing?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-7463183128642993132</id><published>2009-12-01T10:32:00.003+01:00</published><updated>2009-12-01T10:39:43.123+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stored procedure'/><category scheme='http://www.blogger.com/atom/ns#' term='execution permission'/><title type='text'>How to grant execute permission of all stored procedures to a user?</title><content type='html'>One recent request from our testers is that they need to execute all stored procedures on the testing database. And the simplest solution is to create a database role which is granted the execute privilege and add the testers' database users into this role.&lt;br /&gt;&lt;br /&gt;Here it goes the script:&lt;br /&gt;&lt;br /&gt;use [testing_db]&lt;br /&gt;go&lt;br /&gt;create role  [testers]&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;grant exec to [testers]&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;exec sp_addrolemember N'testers', N'tester_db_user_account'&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;By running the above script, not only the execute rights of stored procedures, but also those of scalar functions are granted to the user.&lt;br /&gt;&lt;br /&gt;Here are the two links that you might find interesting as well regarding this topic:&lt;br /&gt;&lt;a href="http://www.sqldbatips.com/showarticle.asp?ID=8"&gt;1&lt;/a&gt; and &lt;a href="http://dba.fyicenter.com/faq/sql_server/GRANT_EXECUTE_Statements_Granting_EXECUTE_permission.html"&gt;2&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-7463183128642993132?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/7463183128642993132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/12/how-to-grant-execute-permission-of-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7463183128642993132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7463183128642993132'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/12/how-to-grant-execute-permission-of-all.html' title='How to grant execute permission of all stored procedures to a user?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4202814240597220297</id><published>2009-11-25T15:12:00.001+01:00</published><updated>2009-11-25T15:14:01.613+01:00</updated><title type='text'>Once you can't remote desktop your server, you can try to reset the session like this</title><content type='html'>See the original post &lt;a href="http://www.howtogeek.com/howto/windows/command-line-hack-for-terminal-server-has-exceeded-the-maximum-number-of-allowed-connections/"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4202814240597220297?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4202814240597220297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/11/once-you-cant-remote-desktop-your.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4202814240597220297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4202814240597220297'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/11/once-you-cant-remote-desktop-your.html' title='Once you can&apos;t remote desktop your server, you can try to reset the session like this'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-7085305643761099217</id><published>2009-10-07T15:49:00.003+02:00</published><updated>2009-10-07T15:57:15.554+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Configuration Manager'/><category scheme='http://www.blogger.com/atom/ns#' term='SQLServerManager10.msc'/><category scheme='http://www.blogger.com/atom/ns#' term='shortcut'/><title type='text'>Command to open SQL Server Configuration Manager</title><content type='html'>I believe most of us already know to type "ssms" (for 2008) or "sqlwb" (for 2005) or "isqlw" (for 2000) in the "Run" command box from the start menu to open SSMS studio or Query Analyzer.&lt;br /&gt;&lt;br /&gt;Here is one more, to open SQL Server Configuration Manager, you need to type "SQLServerManager10.msc" to get there. If you want to see the list of all the windows services, "services.msc" is the command you need.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-7085305643761099217?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/7085305643761099217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/10/command-to-open-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7085305643761099217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7085305643761099217'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/10/command-to-open-sql-server.html' title='Command to open SQL Server Configuration Manager'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-6322818311485441977</id><published>2009-10-06T10:13:00.009+02:00</published><updated>2009-10-06T11:04:35.109+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='distributed transaction'/><category scheme='http://www.blogger.com/atom/ns#' term='Distributed Transaction Coordinator'/><category scheme='http://www.blogger.com/atom/ns#' term='linked server'/><category scheme='http://www.blogger.com/atom/ns#' term='enable network DTC access'/><title type='text'>Error: The partner transaction manager has disabled its support for remote/network transactions</title><content type='html'>I bumped into this error message when our developers created a trigger on a Windows 2003 server that updates a table in a linked server (a Windows 2008 server). The second part of the error message is: "linked server was unable to begin a distributed transaction". I put the whole error message text here purely for the sake of Google keywords and the essential issue behind is actually how to enable  the distributed transaction function on a Windows server.&lt;br /&gt;&lt;br /&gt;If you Google the title, there is a useful &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/7172223f-acbe-4472-8cdf-feec80fd2e64"&gt;link&lt;/a&gt; from MSDN, which provides the following solution:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;First verify the "Distributed Transaction Coordinator" Service is&lt;br /&gt;running on both database server computer and client computers&lt;br /&gt;1.      Go to "Administrative Tools &gt; Services"&lt;br /&gt;2.      Turn on the "Distributed Transaction Coordinator" Service if it is not running&lt;br /&gt;&lt;br /&gt;If it is running and client application is not on the same computer as&lt;br /&gt;the database server, on the computer running database server&lt;br /&gt;1.      Go to "Administrative Tools &gt; Component Services"&lt;br /&gt;2.      On the left navigation tree, go to "Component Services &gt; Computers&lt;br /&gt;&gt; My Computer" (you may need to double click and wait as some nodes&lt;br /&gt;need time to expand)&lt;br /&gt;3.      Right click on "My Computer", select "Properties"&lt;br /&gt;4.      Select "MSDTC" tab&lt;br /&gt;5.      Click "Security Configuration"&lt;br /&gt;6.      Make sure you check "Network DTC Access", "Allow Remote Client",&lt;br /&gt;"Allow Inbound/Outbound", "Enable TIP" (Some option may not be&lt;br /&gt;necessary, have a try to get your configuration)&lt;br /&gt;7.      The service will restart&lt;br /&gt;8.      BUT YOU MAY NEED TO REBOOT YOUR SERVER IF IT STILL DOESN'T WORK(In my case, we didn't reboot the server)&lt;br /&gt;&lt;br /&gt;On your client computer use the same above procedure to open the&lt;br /&gt;"Security Configuration" setting, make sure you check "Network DTC&lt;br /&gt;Access", "Allow Inbound/Outbound" option, restart service and computer&lt;br /&gt;if necessary.&lt;br /&gt;&lt;br /&gt;On you SQL server service manager, click "Service" dropdown, select&lt;br /&gt;"Distribute Transaction Coordinator", it should be also running on&lt;br /&gt;your server computer.&lt;/blockquote&gt;Basically speaking, to enable distributed transaction for linked server, besides making sure the Distributed Transaction Coordinator service is up and running, you have to enable network DTC access. And there is a &lt;a href="http://support.microsoft.com/kb/817064"&gt;very good article&lt;/a&gt; (for Windows server 2003) from Microsoft's knowledge base officially documenting exactly the same set of actions.&lt;br /&gt;&lt;br /&gt;Here are the screen shots you have to encounter during the settings for Windows server 2003:&lt;br /&gt;&lt;br /&gt;Component Services:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Qh5rivXmiTU/SssEY9sj4JI/AAAAAAAAABc/3C14J3qPiBk/s1600-h/Component_Services.JPG"&gt;&lt;img style="cursor: pointer; width: 320px; height: 243px;" src="http://4.bp.blogspot.com/_Qh5rivXmiTU/SssEY9sj4JI/AAAAAAAAABc/3C14J3qPiBk/s320/Component_Services.JPG" alt="" id="BLOGGER_PHOTO_ID_5389406206003765394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;My Computer Properties&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Qh5rivXmiTU/SssEn4_0NoI/AAAAAAAAABk/SnBdLtIOOEs/s1600-h/Security_Configuration.JPG"&gt;&lt;img style="cursor: pointer; width: 275px; height: 320px;" src="http://1.bp.blogspot.com/_Qh5rivXmiTU/SssEn4_0NoI/AAAAAAAAABk/SnBdLtIOOEs/s320/Security_Configuration.JPG" alt="" id="BLOGGER_PHOTO_ID_5389406462440388226" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Security Configuration&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Qh5rivXmiTU/SssE1cpdRzI/AAAAAAAAABs/2NbiKc6XJpo/s1600-h/Security_Configuration_Details.JPG"&gt;&lt;img style="cursor: pointer; width: 320px; height: 313px;" src="http://4.bp.blogspot.com/_Qh5rivXmiTU/SssE1cpdRzI/AAAAAAAAABs/2NbiKc6XJpo/s320/Security_Configuration_Details.JPG" alt="" id="BLOGGER_PHOTO_ID_5389406695348586290" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you tried to enable network DTC access for Windows server 2008 (or Windows vista if you are fan of it), Microsoft has already provided another &lt;a href="http://technet.microsoft.com/en-us/library/cc753510%28WS.10%29.aspx"&gt;article&lt;/a&gt; in its knowledge base for your viewing pleasure as well. The settings are almost the same as those for Windows Server 2003, the slight change lies in where you can find the "Security Configuration" dialog box; in Windows Server 2008, it is in the "Local DTC" properties instead of "My Computer" properties in the component services MMC.&lt;br /&gt;&lt;br /&gt;One screen shot speaks more than 1000 words.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Qh5rivXmiTU/SssHCsPmhzI/AAAAAAAAAB0/FNBQzQBHfeM/s1600-h/Security_Configuration_2008.JPG"&gt;&lt;img style="cursor: pointer; width: 320px; height: 271px;" src="http://2.bp.blogspot.com/_Qh5rivXmiTU/SssHCsPmhzI/AAAAAAAAAB0/FNBQzQBHfeM/s320/Security_Configuration_2008.JPG" alt="" id="BLOGGER_PHOTO_ID_5389409121896662834" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-6322818311485441977?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/6322818311485441977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/10/error-partner-transaction-manager-has.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6322818311485441977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6322818311485441977'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/10/error-partner-transaction-manager-has.html' title='Error: The partner transaction manager has disabled its support for remote/network transactions'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Qh5rivXmiTU/SssEY9sj4JI/AAAAAAAAABc/3C14J3qPiBk/s72-c/Component_Services.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-1570133700422644871</id><published>2009-10-01T13:24:00.002+02:00</published><updated>2009-10-01T16:04:13.439+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='transaction log backup'/><category scheme='http://www.blogger.com/atom/ns#' term='full backup'/><category scheme='http://www.blogger.com/atom/ns#' term='full recovery'/><title type='text'>Good tutorial script for full recovery and transaction log backup</title><content type='html'>--Creating the database for the demo&lt;br /&gt;create database DemoDB&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--Make sure that the database is in full recovery model&lt;br /&gt;alter database DemoDB set recovery  full&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--Making the first full backup.  From now on I can use log backups&lt;br /&gt;backup database DemoDB to disk = 'c:\DemoDB_1.bak' with init&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--Creating a new object in the database&lt;br /&gt;use DemoDB&lt;br /&gt;go&lt;br /&gt;create table DemoTable (i int)&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--backup the log&lt;br /&gt;backup log DemoDB to disk = 'c:\DemoDB_1.trn' with init&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--Inserting a record that doesn't exist in all the backups that were taken into the table&lt;br /&gt;insert into DemoTable (i) values (1)&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--Creating a second full backup. I won't be using this backup when I'll restore the database&lt;br /&gt;backup database DemoDB to disk = 'c:\DemoDB_2.bak' with init&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;insert into DemoTable (i) values (2)&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--Creating the second log backup that includes the second record in DemoTable&lt;br /&gt;backup log DemoDB to disk = 'c:\DemoDB_2.trn' with init&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--Dropping the table (to mimic an error)&lt;br /&gt;drop table DemoTable&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;--Now I'll restore the database.  I'll use only the first full backup&lt;br /&gt;--with the 2 log backups.  This proves that I don't need to use the&lt;br /&gt;--copy_only switch, if I have a full backup with all log backups that&lt;br /&gt;--were taken since then even if another full backup was taken between&lt;br /&gt;--the log backups&lt;br /&gt;use master&lt;br /&gt;go&lt;br /&gt;restore database DemoDB from disk = 'C:\DemoDB_1.bak' with norecovery, replace&lt;br /&gt;restore log DemoDB from disk = 'c:\DemoDB_1.trn' with norecovery&lt;br /&gt;restore log DemoDB from disk = 'c:\DemoDB_2.trn' with recovery&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;Use DemoDB&lt;br /&gt;go&lt;br /&gt;--Notice that I have the table with 2 records&lt;br /&gt;select * from DemoTable&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--cleanup&lt;br /&gt;use master&lt;br /&gt;go&lt;br /&gt;drop database DemoDB&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-1570133700422644871?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/1570133700422644871/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/10/good-tutorial-script-for-full-recovery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1570133700422644871'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1570133700422644871'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/10/good-tutorial-script-for-full-recovery.html' title='Good tutorial script for full recovery and transaction log backup'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-3789491883532437295</id><published>2009-10-01T10:54:00.003+02:00</published><updated>2009-10-01T11:03:36.706+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='logical file'/><category scheme='http://www.blogger.com/atom/ns#' term='restore'/><category scheme='http://www.blogger.com/atom/ns#' term='move clause'/><title type='text'>How to know the logical files' names from a database backup?</title><content type='html'>To use the "move" clause in a restore script, we need first to know the logical files inside the backup. The following sql command can do the trick:&lt;br /&gt;&lt;br /&gt;restore filelistonly&lt;br /&gt;from disk = N'&lt;span style="font-style: italic;"&gt;the backup location&lt;/span&gt;'&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-3789491883532437295?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/3789491883532437295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/10/how-to-know-logical-files-names-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3789491883532437295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3789491883532437295'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/10/how-to-know-logical-files-names-from.html' title='How to know the logical files&apos; names from a database backup?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-5877257864957231617</id><published>2009-09-10T14:40:00.003+02:00</published><updated>2009-09-10T14:43:19.792+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='csv export'/><category scheme='http://www.blogger.com/atom/ns#' term='macro'/><category scheme='http://www.blogger.com/atom/ns#' term='double quotes'/><title type='text'>How to export from Excel to a CSV file with double quotes on each field</title><content type='html'>The default "save as CSV" option from Excel does not include any quotes on the fields, therefore a macro is needed in this case:&lt;br /&gt;&lt;br /&gt;Sub CSVFile()&lt;br /&gt;&lt;br /&gt;Dim SrcRg As Range&lt;br /&gt;Dim CurrRow As Range&lt;br /&gt;Dim CurrCell As Range&lt;br /&gt;Dim CurrTextStr As String&lt;br /&gt;Dim ListSep As String&lt;br /&gt;Dim FName As Variant&lt;br /&gt;FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")&lt;br /&gt;&lt;br /&gt;If FName &lt;&gt; False Then&lt;br /&gt;ListSep = Application.International(xlListSeparator)&lt;br /&gt;If Selection.Cells.Count &gt; 1 Then&lt;br /&gt;Set SrcRg = Selection&lt;br /&gt;Else&lt;br /&gt;Set SrcRg = ActiveSheet.UsedRange&lt;br /&gt;End If&lt;br /&gt;Open FName For Output As #1&lt;br /&gt;For Each CurrRow In SrcRg.Rows&lt;br /&gt;CurrTextStr = ""&lt;br /&gt;For Each CurrCell In CurrRow.Cells&lt;br /&gt;CurrTextStr = CurrTextStr &amp;amp; """" &amp;amp; CurrCell.Value &amp;amp; """" &amp;amp; ListSep&lt;br /&gt;Next&lt;br /&gt;While Right(CurrTextStr, 1) = ListSep&lt;br /&gt;CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)&lt;br /&gt;Wend&lt;br /&gt;Print #1, CurrTextStr&lt;br /&gt;Next&lt;br /&gt;Close #1&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;The original post can be retrieved &lt;a href="http://www.mrexcel.com/forum/showthread.php?t=320531"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-5877257864957231617?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/5877257864957231617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/09/how-to-export-from-excel-to-csv-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/5877257864957231617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/5877257864957231617'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/09/how-to-export-from-excel-to-csv-file.html' title='How to export from Excel to a CSV file with double quotes on each field'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-767482558419902182</id><published>2009-09-07T16:45:00.004+02:00</published><updated>2009-09-10T14:40:15.740+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='temp table'/><category scheme='http://www.blogger.com/atom/ns#' term='table variable'/><title type='text'>The two most important differences between temp table and table variable</title><content type='html'>Since this can be one of the mostly asked interview questions, I better have the answers here instead of doing another round of Googling.&lt;br /&gt;&lt;br /&gt;1. table variable does not support transaction while temp table does&lt;br /&gt;2. table variable does not support constraints while temp table does&lt;br /&gt;&lt;br /&gt;A full expiation is &lt;a href="http://www.sqlservercentral.com/articles/63472/"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-767482558419902182?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/767482558419902182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/09/two-most-important-differences-between.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/767482558419902182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/767482558419902182'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/09/two-most-important-differences-between.html' title='The two most important differences between temp table and table variable'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-1491745789700655616</id><published>2009-09-07T13:06:00.003+02:00</published><updated>2009-09-07T13:28:49.703+02:00</updated><title type='text'>SourceSafe plug-in setting for Visual Studio</title><content type='html'>This might sound very stupid, but it took quite some time for me to figure out why my Visual Studio failed to connect to our SourceSafe database on which it turns out that the internet connection is switched off by default(On Server, when installing VSS, select Custom Install and make sure you select the "Server     Components" or at least the HTTP Remote Access component; they are not     installed in Default installation confuguration). While the Visual Studio by default connects to internet SSL connection based database, my multiple attempts failed without providing me too much of a clue since a VNC and a URL in a LAN setting do not vary from each other too much. So after checking an interesting &lt;a href="http://alinconstantin.members.winisp.net/webdocs/scc/VSS_Internet.htm"&gt;article&lt;/a&gt;, the solution is plain simple as shown in the below screen shot in Visual Studio's options.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Qh5rivXmiTU/SqTsk-tJ59I/AAAAAAAAAA0/fWUk9yd6Kc8/s1600-h/SourceSafe+Plug-in+Option.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 184px;" src="http://3.bp.blogspot.com/_Qh5rivXmiTU/SqTsk-tJ59I/AAAAAAAAAA0/fWUk9yd6Kc8/s320/SourceSafe+Plug-in+Option.jpg" alt="" id="BLOGGER_PHOTO_ID_5378683975039051730" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-1491745789700655616?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/1491745789700655616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/09/sourcesafe-plug-in-setting-for-visual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1491745789700655616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1491745789700655616'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/09/sourcesafe-plug-in-setting-for-visual.html' title='SourceSafe plug-in setting for Visual Studio'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Qh5rivXmiTU/SqTsk-tJ59I/AAAAAAAAAA0/fWUk9yd6Kc8/s72-c/SourceSafe+Plug-in+Option.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-8065188557860173868</id><published>2009-08-28T10:38:00.004+02:00</published><updated>2009-08-28T11:00:52.566+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='restoring'/><category scheme='http://www.blogger.com/atom/ns#' term='recovery'/><category scheme='http://www.blogger.com/atom/ns#' term='restore database'/><category scheme='http://www.blogger.com/atom/ns#' term='norecovery'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How to bring a restored database from the  "restoring" state back to operational</title><content type='html'>If you are trying to find a solution to bring your database out of the "restoring" state after a restore, this is the right place you should be.&lt;br /&gt;&lt;br /&gt;When you use restore statement the with the "with norecovery" option, after the restore, the database will be put into a 'restoring' state. To bring it back online and operational, you need the follow script:&lt;br /&gt;&lt;br /&gt;restore database &lt;span style="font-style: italic;"&gt;db_name&lt;/span&gt; with recovery&lt;br /&gt;&lt;br /&gt;To avoid yourself from this situation, always run the restore with the "with recovery" option.&lt;br /&gt;&lt;br /&gt;More info about recovery state after a restore operation can be found at the "&lt;a href="http://msdn.microsoft.com/en-us/library/ms188223.aspx"&gt;Restore Database (Options Page)&lt;/a&gt;" at MSDN.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-8065188557860173868?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/8065188557860173868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-bring-restored-database-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/8065188557860173868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/8065188557860173868'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-bring-restored-database-from.html' title='How to bring a restored database from the  &quot;restoring&quot; state back to operational'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-3103901195801689589</id><published>2009-08-26T14:53:00.002+02:00</published><updated>2009-08-26T15:22:12.711+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='monitor'/><category scheme='http://www.blogger.com/atom/ns#' term='restore'/><category scheme='http://www.blogger.com/atom/ns#' term='progress'/><category scheme='http://www.blogger.com/atom/ns#' term='backup'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Script to monitor backup and restore progress</title><content type='html'>I have been recently busy with tuning the restore performance on a testing server. The original disk array was configure to be RAID5 and the restore process was super slow which cost 16 hours to restore a 300 GB database backed up from prod. I've also double-checked CPU and memory stats, none is believed to be the bottleneck. So we decided to downgrade RAID5 to RAID0 since our testing environment doesn't require fault tolerance.&lt;br /&gt;&lt;br /&gt;Right now, I am testing the restore again to see if the RAID0 can actually bring the expected performance benefits. However, the restore script I am using was accidentally set to have the argument with "stats = 100" (should've used stats = 1) which will not report progress info until the full restore is finished. So the questions becomes how to monitor a restore process when it is running in the background.&lt;br /&gt;&lt;br /&gt;Luckily enough, there are at least two scripts that can be found through Google to monitor the progress of a backup/restore process. The first one is hidden in a &lt;a href="http://www.sqlservercentral.com/Forums/Topic666268-146-1.aspx"&gt;thread&lt;/a&gt; in SQLServerCentral's forum and the other one is &lt;a href="http://www.wisesoft.co.uk/articles/tsql_backup_restore_progress.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Needless to say, I would like to post them in this post as well.&lt;br /&gt;&lt;br /&gt;The first script can only monitor "restore" progress:&lt;br /&gt;&lt;br /&gt;&lt;div style="line-height: normal;"&gt;&lt;span style=";font-size:10pt;color:blue;"  &gt;SELECT&lt;br /&gt;   A.name,&lt;br /&gt;   B.total_elapsed_time/60000 AS [Running Time in minutes],&lt;br /&gt;   B.estimated_completion_time/60000 AS [Remaining in minutes],&lt;br /&gt;   B.percent_complete as [% of completion],&lt;br /&gt;   (SELECT TEXT FROM sys.dm_exec_sql_text(B.sql_handle))AS Command&lt;br /&gt;FROM&lt;br /&gt;   MASTER.sys.sysdatabases A inner join sys.dm_exec_requests B&lt;br /&gt;   on A.dbid = B.database_id&lt;br /&gt;WHERE&lt;br /&gt;   B.command LIKE '%RESTORE%'&lt;br /&gt;order by B.percent_complete desc,B.total_elapsed_time/60000 desc&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The second script give more general info about both "restore" and "backup".&lt;br /&gt;&lt;span style=";font-size:10pt;color:blue;"  &gt;&lt;br /&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10pt;"&gt; command&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;            s&lt;span style="color:gray;"&gt;.&lt;/span&gt;text&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;            start_time&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;            percent_complete&lt;span style="color:gray;"&gt;,&lt;/span&gt; &lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;            &lt;span style="color:fuchsia;"&gt;CAST&lt;/span&gt;&lt;span style="color:gray;"&gt;(((&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;DATEDIFF&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;s&lt;span style="color:gray;"&gt;,&lt;/span&gt;start_time&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;GetDate&lt;/span&gt;&lt;span style="color:gray;"&gt;()))/&lt;/span&gt;3600&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color:blue;"&gt;varchar&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:red;"&gt;' hour(s), '&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;                  &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;CAST&lt;/span&gt;&lt;span style="color:gray;"&gt;((&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;DATEDIFF&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;s&lt;span style="color:gray;"&gt;,&lt;/span&gt;start_time&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;GetDate&lt;/span&gt;&lt;span style="color:gray;"&gt;())%&lt;/span&gt;3600&lt;span style="color:gray;"&gt;)/&lt;/span&gt;60 &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color:blue;"&gt;varchar&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:red;"&gt;'min, '&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;                  &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;CAST&lt;/span&gt;&lt;span style="color:gray;"&gt;((&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;DATEDIFF&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;s&lt;span style="color:gray;"&gt;,&lt;/span&gt;start_time&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;GetDate&lt;/span&gt;&lt;span style="color:gray;"&gt;())%&lt;/span&gt;60&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color:blue;"&gt;varchar&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:red;"&gt;' sec'&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; running_time&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;            &lt;span style="color:fuchsia;"&gt;CAST&lt;/span&gt;&lt;span style="color:gray;"&gt;((&lt;/span&gt;estimated_completion_time&lt;span style="color:gray;"&gt;/&lt;/span&gt;3600000&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color:blue;"&gt;varchar&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:red;"&gt;' hour(s), '&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;                  &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;CAST&lt;/span&gt;&lt;span style="color:gray;"&gt;((&lt;/span&gt;estimated_completion_time &lt;span style="color:gray;"&gt;%&lt;/span&gt;3600000&lt;span style="color:gray;"&gt;)/&lt;/span&gt;60000 &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color:blue;"&gt;varchar&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:red;"&gt;'min, '&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;                  &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;CAST&lt;/span&gt;&lt;span style="color:gray;"&gt;((&lt;/span&gt;estimated_completion_time &lt;span style="color:gray;"&gt;%&lt;/span&gt;60000&lt;span style="color:gray;"&gt;)/&lt;/span&gt;1000 &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color:blue;"&gt;varchar&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:red;"&gt;' sec'&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; est_time_to_go&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style="font-size:10pt;"&gt;            &lt;span style="color:fuchsia;"&gt;dateadd&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:blue;"&gt;second&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt;estimated_completion_time&lt;span style="color:gray;"&gt;/&lt;/span&gt;1000&lt;span style="color:gray;"&gt;,&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;getdate&lt;/span&gt;&lt;span style="color:gray;"&gt;())&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; est_completion_time &lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style=";font-size:10pt;color:blue;"  &gt;FROM&lt;/span&gt;&lt;span style="font-size:10pt;"&gt; &lt;span style="color:green;"&gt;sys.dm_exec_requests&lt;/span&gt; r&lt;/span&gt;&lt;/div&gt; &lt;div style="line-height: normal;"&gt;&lt;span style=";font-size:10pt;color:gray;"  &gt;CROSS&lt;/span&gt;&lt;span style="font-size:10pt;"&gt; &lt;span style="color:gray;"&gt;APPLY&lt;/span&gt; sys.dm_exec_sql_text&lt;span style="color:gray;"&gt;(&lt;/span&gt;r&lt;span style="color:gray;"&gt;.&lt;/span&gt;sql_handle&lt;span style="color:gray;"&gt;)&lt;/span&gt; s&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0cm 0cm 10pt;"&gt;&lt;span style="line-height: 115%;font-size:10pt;color:blue;"  &gt;WHERE&lt;/span&gt;&lt;span style="line-height: 115%;font-size:10pt;" &gt; r&lt;span style="color:gray;"&gt;.&lt;/span&gt;command &lt;span style="color:gray;"&gt;in&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:red;"&gt;'RESTORE DATABASE'&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt; &lt;span style="color:red;"&gt;'BACKUP DATABASE'&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt; &lt;span style="color:red;"&gt;'RESTORE LOG'&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt; &lt;span style="color:red;"&gt;'BACKUP LOG'&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-3103901195801689589?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/3103901195801689589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/script-to-monitor-backup-and-restore.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3103901195801689589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/3103901195801689589'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/script-to-monitor-backup-and-restore.html' title='Script to monitor backup and restore progress'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-2390770543422483191</id><published>2009-08-24T15:54:00.002+02:00</published><updated>2009-08-24T15:58:08.468+02:00</updated><title type='text'>How to rename a database?</title><content type='html'>sp_renamedb is the stored proc that can be used. The problem you might encountered is the exclusive lock might not be assigned properly. The best practice is to set the db to single user mode before changing its name and back to multi-user mode afterwards.&lt;br /&gt;&lt;br /&gt;ALTER DATABASE &lt;span style="font-style: italic;"&gt;old_db_name&lt;/span&gt; &lt;br /&gt;SET SINGLE_USER WITH ROLLBACK IMMEDIATE&lt;br /&gt;GO&lt;br /&gt;SP_RENAMEDB &lt;span style="font-style: italic;"&gt;old_db_name&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;new_db_name&lt;/span&gt;&lt;br /&gt;Go&lt;br /&gt;ALTER DATABASE &lt;span style="font-style: italic;"&gt;new_db_name&lt;/span&gt; &lt;br /&gt;SET MULTI_USER&lt;br /&gt;GO&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-2390770543422483191?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/2390770543422483191/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-rename-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/2390770543422483191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/2390770543422483191'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-rename-database.html' title='How to rename a database?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-461406701056480397</id><published>2009-08-13T10:20:00.003+02:00</published><updated>2009-08-13T11:01:43.402+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='foreign key'/><category scheme='http://www.blogger.com/atom/ns#' term='drop constraint'/><category scheme='http://www.blogger.com/atom/ns#' term='catalog view'/><title type='text'>How to drop all the foreign key constraints in a database</title><content type='html'>Sometimes, foreign keys become annoying in a secondary database where reporting is the main purpose while integrity is not. So dropping all the foreign keys may become a user request from time to time.&lt;br /&gt;&lt;br /&gt;The keyword to this question is the catalog view "sys.foreignkeys". And you can go to &lt;a href="http://blog.sqlauthority.com/2007/09/04/sql-server-2005-find-tables-with-foreign-key-constraint-in-database/"&gt;here&lt;/a&gt; to read about about how to retrieve all the foreign key constraints from a database and why catalog view is preferred.&lt;br /&gt;&lt;br /&gt;Here is the script to delete all the foreign keys from a database.&lt;br /&gt;&lt;br /&gt;use &lt;span style="font-style: italic;"&gt;db_name&lt;/span&gt;&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;declare @fk_name varchar(100)&lt;br /&gt;declare @tb_name varchar(100)&lt;br /&gt;declare @cmd varchar(200)&lt;br /&gt;&lt;br /&gt;declare cur_fk cursor&lt;br /&gt;for&lt;br /&gt;select name as ForeignKey_Name, OBJECT_NAME(parent_object_id) as Table_Name from sys.foreign_keys&lt;br /&gt;order by Table_Name&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;open cur_fk&lt;br /&gt;&lt;br /&gt;fetch next from cur_fk into @fk_name, @tb_name&lt;br /&gt;while @@FETCH_STATUS = 0&lt;br /&gt;begin&lt;br /&gt;    set @cmd = 'alter table ' + @tb_name + ' drop constraint ' + @fk_name&lt;br /&gt;    select @cmd&lt;br /&gt;    exec (@cmd)&lt;br /&gt;    fetch next from cur_fk into @fk_name, @tb_name&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;close cur_fk&lt;br /&gt;deallocate cur_fk&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-461406701056480397?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/461406701056480397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-find-out-all-foreign-key.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/461406701056480397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/461406701056480397'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-find-out-all-foreign-key.html' title='How to drop all the foreign key constraints in a database'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-1014024909486392956</id><published>2009-08-10T18:08:00.004+02:00</published><updated>2009-08-11T10:07:23.806+02:00</updated><title type='text'>How to drop all the user stored procedures from a database</title><content type='html'>A very informative script is &lt;a href="http://www.sqlmusings.com/2009/03/15/how-to-drop-all-stored-procedures-in-your-database/"&gt;here&lt;/a&gt;. But since the original posted script has very annoying line numbers, I would rather re-post the same code here again. And now you can copy and paste it to SSMS very easily. Also something worth mentioning is that the INFORMATION_SCHEMA.ROUTINES view actually contains user defined functions' info, so the SQL command "Drop procedure" will fail if you have any function defined in your target database. Therefore, I changed the following script to use sys.sysobjects view to retrieve the full list of names of user stored procedures.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-- this sets up the test database&lt;br /&gt;&lt;br /&gt;-- Drop the database if it already existt&lt;br /&gt;&lt;br /&gt;USE master&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;IF  EXISTS (&lt;br /&gt;   SELECT name&lt;br /&gt;   FROM sys.databases&lt;br /&gt;   WHERE name = N'testdb'&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;DROP DATABASE testdb&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE DATABASE testdb&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;USE testdb&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE PROC UserStoredProcedure_Sample1&lt;br /&gt;AS&lt;br /&gt;   SELECT 'SQL Server rocks'&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE PROC UserStoredProcedure_Sample2&lt;br /&gt;AS&lt;br /&gt;   SELECT 'SQL Server rocks'&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;SET NOCOUNT ON&lt;br /&gt;-- to do this we have to use EXEC instead of sp_executesql&lt;br /&gt;&lt;br /&gt;-- sp_executesql does not accept a DROP command in the SQL String&lt;br /&gt;&lt;br /&gt;DECLARE @UserStoredProcedure    VARCHAR(100)&lt;br /&gt;DECLARE @Command                    VARCHAR(100)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;DECLARE UserStoredProcedureCursor CURSOR SCROLL STATIC READ_ONLY FOR&lt;br /&gt;select name from sys.sysobjects where xtype = 'P'&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;SELECT&lt;br /&gt;   SPECIFIC_NAME&lt;br /&gt;FROM&lt;br /&gt;   INFORMATION_SCHEMA.ROUTINES&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;OPEN UserStoredProcedureCursor&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM UserStoredProcedureCursor&lt;br /&gt;INTO @UserStoredProcedure&lt;br /&gt;WHILE (@@FETCH_STATUS = 0) BEGIN&lt;br /&gt;      SET @Command = 'DROP PROCEDURE ' + @UserStoredProcedure&lt;br /&gt;        -- display; visual check&lt;br /&gt;&lt;br /&gt;        SELECT @Command&lt;br /&gt;      -- when you are ready to execute, uncomment below&lt;br /&gt;&lt;br /&gt;      EXEC (@Command)&lt;br /&gt;&lt;br /&gt;      FETCH NEXT FROM UserStoredProcedureCursor&lt;br /&gt;&lt;br /&gt;      INTO @UserStoredProcedure&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE UserStoredProcedureCursor&lt;br /&gt;&lt;br /&gt;DEALLOCATE UserStoredProcedureCursor&lt;br /&gt;&lt;br /&gt;SET NOCOUNT OFF&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-1014024909486392956?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/1014024909486392956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-drop-all-user-stored-procedures.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1014024909486392956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1014024909486392956'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-drop-all-user-stored-procedures.html' title='How to drop all the user stored procedures from a database'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-8805445449118483</id><published>2009-08-09T21:47:00.006+02:00</published><updated>2009-08-09T23:47:17.666+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Job Notification'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Agent'/><category scheme='http://www.blogger.com/atom/ns#' term='Enable mail profile'/><title type='text'>Job notification fails to send emails</title><content type='html'>This may be another rookie mistake, but I believe it is worth mentioning it here. I have two servers under my administration and one uses maintenance plan to send out emails after a backup operation is done and on the other one I tried to use job notification to send out email to my account when a "move database copies" PowerShell script job is complete. Both servers' email profiles have been set up properly and test emails have been sent successfully too. However, the one with the maintenance plan does send emails successfully every night while the other one with job notification kept silent for quite a few days in a row and I was suspecting the connectivity of the smtp server it uses. But after some research, the reason actually turned out to be a missed configuration check box on the "Alert System" tab of SQL Server Agent Properties. Strangely, on the first server where the maintenance plan is located and used to send out notification emails, this check box is left empty too. So the conclusion is that maintenance plan, which in essence is an SSIS package, does not require this "Enable mail profile" option to be turned on but email-sending jobs do. Also don't forget to restart SQL Server Agent service after the setting is changed.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Qh5rivXmiTU/Sn9B2OeVkdI/AAAAAAAAAAs/OL5KUpCZ_bc/s1600-h/Enable_mail_profile.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 287px;" src="http://3.bp.blogspot.com/_Qh5rivXmiTU/Sn9B2OeVkdI/AAAAAAAAAAs/OL5KUpCZ_bc/s320/Enable_mail_profile.JPG" alt="" id="BLOGGER_PHOTO_ID_5368081680703001042" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-8805445449118483?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/8805445449118483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/job-notification-fails-to-send-emails.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/8805445449118483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/8805445449118483'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/job-notification-fails-to-send-emails.html' title='Job notification fails to send emails'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Qh5rivXmiTU/Sn9B2OeVkdI/AAAAAAAAAAs/OL5KUpCZ_bc/s72-c/Enable_mail_profile.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-7635348636510314478</id><published>2009-08-07T20:02:00.003+02:00</published><updated>2009-08-09T23:50:22.350+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='test-path'/><category scheme='http://www.blogger.com/atom/ns#' term='cmdlet'/><category scheme='http://www.blogger.com/atom/ns#' term='file exist'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><title type='text'>How to determine whether a file exists or not in PowerShell script?</title><content type='html'>This is purely for  my personal note, cmdlet "test-path" is the keyword:&lt;br /&gt;&lt;br /&gt;if (Test-Path "&lt;span style="font-style: italic;"&gt;file_lccation&lt;/span&gt;")&lt;br /&gt;{&lt;br /&gt;   write-host "the file is there"&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;   Write-Host "the file is missing"&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-7635348636510314478?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/7635348636510314478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-determine-whether-file-exists-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7635348636510314478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7635348636510314478'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/how-to-determine-whether-file-exists-or.html' title='How to determine whether a file exists or not in PowerShell script?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-1956109728445444925</id><published>2009-08-07T14:52:00.004+02:00</published><updated>2009-08-08T02:01:06.281+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stored procedures'/><category scheme='http://www.blogger.com/atom/ns#' term='scripting schema'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><title type='text'>PowerShell script to script all tables and stored procedures in a database</title><content type='html'>The script to script all the tables is available &lt;a href="http://blogs.msdn.com/buckwoody/archive/2009/07/02/powershell-and-sql-server-script-all-tables.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here I made my part of scripting all the stored procedures (excluding system stored procedures) from the ubiquitous database "pubs".&lt;br /&gt;&lt;br /&gt;#the full path of the file that you want to script the stored procs to&lt;br /&gt;$scriptfile = "C:\temp\StoredProcs.sql"&lt;br /&gt;&lt;br /&gt;#if the script file already exists, remove it&lt;br /&gt;if (Test-Path $scriptfile)&lt;br /&gt;{&lt;br /&gt;    Remove-Item -Path $scriptfile&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null&lt;br /&gt;&lt;br /&gt;$MyScripter=new-object ("Microsoft.SqlServer.Management.Smo.Scripter")&lt;br /&gt;$srv=New-Object "Microsoft.SqlServer.Management.Smo.Server" "localhost"&lt;br /&gt;$procs = $srv.databases["pubs"].StoredProcedures&lt;br /&gt;$MyScripter.Server=$srv&lt;br /&gt;&lt;br /&gt;$MyScripter.Options.FileName = $scriptfile&lt;br /&gt;#AppendTofile has to be 'true' in order that all the procs' scripts will be appended at the end&lt;br /&gt;$MyScripter.Options.AppendToFile = "true"&lt;br /&gt;&lt;br /&gt;foreach ($proc in $procs)&lt;br /&gt;{&lt;br /&gt;  #Assuming that all non-system stored procs have proper naming convention and don't use prefixes like "sp_" or "xp_"&lt;br /&gt;  if ( $proc.Name.IndexOf("sp_") -eq -1 -and $proc.Name.IndexOf("xp_") -eq -1 )&lt;br /&gt; {&lt;br /&gt;          $MyScripter.Script($proc)|out-null&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-1956109728445444925?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/1956109728445444925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/powershell-script-to-script-all-tables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1956109728445444925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1956109728445444925'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/powershell-script-to-script-all-tables.html' title='PowerShell script to script all tables and stored procedures in a database'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-7458462285032780367</id><published>2009-08-07T14:15:00.006+02:00</published><updated>2009-08-07T14:34:56.938+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Integrated Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Connection String'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>SQL Server connection string format for PowerShell scripting</title><content type='html'>This might look very primitive, but since I am a newbie to PowerShell scripting, it does no harm to write them down here and reference them in a later time when needed.&lt;br /&gt;&lt;br /&gt;For sql server authentication:&lt;br /&gt;"Server=&lt;server_name&gt;&lt;span style="font-style: italic;"&gt;server_name or server_ip&lt;/span&gt;;Database=&lt;span style="font-style: italic;"&gt;db_name&lt;/span&gt;;Integrated Security=False;UID=&lt;i&gt;login_name&lt;/i&gt;;Password=&lt;i&gt;&lt;password&gt;&lt;/password&gt;password&lt;/i&gt;"&lt;br /&gt;&lt;br /&gt;For windows authentication:&lt;br /&gt;"Server=&lt;server_name&gt;&lt;/server_name&gt;&lt;/server_name&gt;&lt;span style="font-style: italic;"&gt;server_name or server_ip&lt;/span&gt;&lt;server_name&gt;&lt;server_name&gt;;Database=&lt;db_name&gt;&lt;span style="font-style: italic;"&gt;db_name&lt;/span&gt;;Integrated Security=True"&lt;br /&gt;&lt;br /&gt;Another website which is dedicated to connection strings might also come in handy, the link is &lt;a href="http://www.connectionstrings.com/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;But shockingly, I can't find the above PowerShell script connection strings on the website.&lt;/db_name&gt;&lt;/server_name&gt;&lt;/server_name&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-7458462285032780367?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/7458462285032780367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/sql-server-connection-string-format-for.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7458462285032780367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7458462285032780367'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/sql-server-connection-string-format-for.html' title='SQL Server connection string format for PowerShell scripting'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4957673074730575196</id><published>2009-08-04T16:01:00.004+02:00</published><updated>2009-08-04T16:46:43.003+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='starting time'/><category scheme='http://www.blogger.com/atom/ns#' term='restorehistory'/><category scheme='http://www.blogger.com/atom/ns#' term='restore'/><title type='text'>Where to find the staring time of a sql server database restore?</title><content type='html'>I just encountered this problem today. And composed a post on SCC:&lt;br /&gt;&lt;span id="_ctl6_ctlTopic_ctlPanelBar_ctlTopicsRepeater__ctl7_lblFullMessage"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span id="_ctl6_ctlTopic_ctlPanelBar_ctlTopicsRepeater__ctl7_lblFullMessage"&gt;Hello everyone&lt;br /&gt;&lt;br /&gt;This might sound very silly due to my novice to DB administration work. Yesterday I started restoring a database with a size of 350GB from a 75GB backup on a testing server from 11pm, and this afternoon at 3pm, when I remote-desktoped the server I found the restore has already finished. I then checked the sql server log in the log file viewer but can't see anything has been logged around 11pm yesterday and there are only two records around 6am early this morning saying that "Starting up database &lt;span style="font-style: italic;"&gt;db_name&lt;/span&gt;&lt;db_name&gt;&lt;database_name&gt;" and "The database &lt;db_name&gt; &lt;database_name&gt; is marked RESTORING and is in a state that does not allow recovery to run". Also, there is another log around 2:20pm today stating that "Restore is complete on database &lt;span style="font-style: italic;"&gt;db_name&lt;/span&gt;&lt;db_name&gt;&lt;database_name&gt;. The database is now available".&lt;br /&gt;&lt;br /&gt;So my question is whether this restore started around 11pm yesterday when I starting running the restore script or it actually happened around 6am this morning? How to determine the starting time of a restore then? Or did I totally miss something really important here? Thanks very much in advance for your advice!&lt;br /&gt;&lt;br /&gt;regards,&lt;br /&gt;Ning&lt;/database_name&gt;&lt;/db_name&gt;&lt;/database_name&gt;&lt;/db_name&gt;&lt;/database_name&gt;&lt;/db_name&gt;&lt;/span&gt;&lt;/blockquote&gt;Feed-backs came surprisingly quick that the msdb.dbo.restorehistory is the table I need to look at to retrieve the starting time info for all the restore actions against all the databases in the instance. But it still seems strange to me that SQL Server log does not record the staring time of a restore action.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4957673074730575196?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4957673074730575196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/where-to-find-staring-time-of-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4957673074730575196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4957673074730575196'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/08/where-to-find-staring-time-of-sql.html' title='Where to find the staring time of a sql server database restore?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-7044170131009286194</id><published>2009-07-27T19:55:00.005+02:00</published><updated>2009-07-28T00:47:15.698+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='replication error'/><category scheme='http://www.blogger.com/atom/ns#' term='change instance name'/><category scheme='http://www.blogger.com/atom/ns#' term='server name'/><category scheme='http://www.blogger.com/atom/ns#' term='replication'/><title type='text'>Change instance name of SQL Server</title><content type='html'>It turns out that after you've changed the Windows Server's name, the underlying SQL Server's instance name is not changed accordingly, although you can see an instance name same with the Windows Server's is displayed in the SSMS.&lt;br /&gt;&lt;br /&gt;Everything else might work fine until you want to set up replication/distribution on this server. An error message like "SQL Server replication requires the actual server name to make a connection to the server. Connections through a server alias, IP address, or any other alternate name are not supported. Specify the actual server name, ‘old_name’. (Replication.Utilities)" is popped right into your eyes.&lt;br /&gt;&lt;br /&gt;To see the old instance name, you can use "sp_helpserver" or "select @@servername" and to change the instance name once and for all, the following script has to be executed:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;sp_dropserver &lt;/span&gt;&lt;span class="string"&gt;'old_name'&lt;/span&gt;&lt;span&gt;&lt;br /&gt;go&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;sp_addserver &lt;span class="string"&gt;'new_name'&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class="string"&gt;'local'&lt;br /&gt;go&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;br /&gt;A detailed and better formatted how-to article can be retrieved from &lt;a href="http://www.coderjournal.com/2008/02/how-to-change-instance-name-of-sql-server/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-7044170131009286194?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/7044170131009286194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/change-instance-name-of-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7044170131009286194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7044170131009286194'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/change-instance-name-of-sql-server.html' title='Change instance name of SQL Server'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-1828191977641786976</id><published>2009-07-24T15:41:00.001+02:00</published><updated>2009-07-24T15:53:23.416+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='resolution'/><category scheme='http://www.blogger.com/atom/ns#' term='remote desktop'/><category scheme='http://www.blogger.com/atom/ns#' term='full screen'/><category scheme='http://www.blogger.com/atom/ns#' term='command line'/><title type='text'>Remote desktop resolution problem</title><content type='html'>Here is the thing, I use command line short cuts (%windir%\system32\mstsc.exe /v: &lt;server_ip&gt;) on my desktop to connect to our multiple database server environment and for two days a week, I go to my company and have my laptop docked to a much bigger monitor at the office. So from the bigger screen, the remote session's resolution becomes (automatically) much bigger than my 12 inch laptop's but displays beautifully on the 22 inch LCD screen. But when I come back and start working from home, the RDP session's resolution somehow "remembers" its latest setting and becomes more than my small screen can handle and I have to scroll up and down, from left to right to locate the things I have to work on.&lt;br /&gt;&lt;br /&gt;A little bit of &lt;a href="http://ss64.com/nt/mstsc.html"&gt;research&lt;/a&gt; shows that one of mstsc.exe's command line options gives a default full screen setting by using "/f" and I changed all my short cuts on my desktop according to this, and they are all working fine now. So the best practice to use mstsc command line is always put the "/f" argument at the end to ensure the remote resolution is in sync with your local ones in a full screen mode.&lt;br /&gt;&lt;/server_ip&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-1828191977641786976?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/1828191977641786976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/remote-desktop-resolution-problem.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1828191977641786976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/1828191977641786976'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/remote-desktop-resolution-problem.html' title='Remote desktop resolution problem'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4565776974915288537</id><published>2009-07-24T11:24:00.000+02:00</published><updated>2009-07-24T12:31:18.431+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='log visits'/><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><category scheme='http://www.blogger.com/atom/ns#' term='logging'/><title type='text'>IIS logging problem</title><content type='html'>Although my official title is DBA, but at a small start-up, an "IT dude" is supposed to be capable of solving all kinds of problems which may be way beyond the database realm. And to please our big boss, I happily accepted a task to investigate why one of our IIS websites fails to generate any logging records in the log file directory. What entails is a significant amount of hours which only leads to a simple and stupid overlook by a previous "IT dude" who actually set up the whole website.&lt;br /&gt;&lt;br /&gt;The following screen shot from tab "Web Site" on the IIS site properties is a must-go place for checking all the logging settings for IIS and it surely looks perfect on our server.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Qh5rivXmiTU/SmmAZUWkyYI/AAAAAAAAAAc/Jsbee5cGY0w/s1600-h/Enable_logging_screenshot.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 313px;" src="http://1.bp.blogspot.com/_Qh5rivXmiTU/SmmAZUWkyYI/AAAAAAAAAAc/Jsbee5cGY0w/s320/Enable_logging_screenshot.JPG" alt="" id="BLOGGER_PHOTO_ID_5361958003809765762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However, the other missing check box on the "Home Directory" tab turned out to be the ultimate cause for this site failing to deliver any log files.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Qh5rivXmiTU/SmmBN1QLe4I/AAAAAAAAAAk/XTDt6f-C9Ks/s1600-h/Log_visits_screenshot.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 309px;" src="http://2.bp.blogspot.com/_Qh5rivXmiTU/SmmBN1QLe4I/AAAAAAAAAAk/XTDt6f-C9Ks/s320/Log_visits_screenshot.JPG" alt="" id="BLOGGER_PHOTO_ID_5361958905994509186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Qh5rivXmiTU/SmmAZUWkyYI/AAAAAAAAAAc/Jsbee5cGY0w/s1600-h/Enable_logging_screenshot.JPG"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4565776974915288537?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4565776974915288537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/iis-logging-problem.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4565776974915288537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4565776974915288537'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/iis-logging-problem.html' title='IIS logging problem'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Qh5rivXmiTU/SmmAZUWkyYI/AAAAAAAAAAc/Jsbee5cGY0w/s72-c/Enable_logging_screenshot.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-7851531619418520838</id><published>2009-07-22T23:15:00.000+02:00</published><updated>2009-07-23T11:26:39.161+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='num lock'/><category scheme='http://www.blogger.com/atom/ns#' term='character map'/><category scheme='http://www.blogger.com/atom/ns#' term='laptop'/><category scheme='http://www.blogger.com/atom/ns#' term='pound sign'/><category scheme='http://www.blogger.com/atom/ns#' term='Dell'/><title type='text'>Two tricks discovered on Dell's Latitude E4300 laptop</title><content type='html'>The first one is pretty straight forward and probably more Dell-related. I just found out that you can turn off battery charging by pressing Fn+F2 which is an awesome feature because I usually prefer to have my battery on all the time in case there is a power outage, but at the same time, I don't wanna make too much over-charging which might cause a shortened battery life. So having the option of stopping charging the battery is definitely something nice to have. Big applause to Dell's engineers.&lt;br /&gt;&lt;br /&gt;The second one is how to type in special signs for example the pound sign £ through a US-layout keyboard. The solution is pretty simple although I've spent quite a load of time Googling for it.  First of all, turn on the num lock of the numeric keypad by press Fn+F4 (at least on Dell's Latitude E4300, you can find other key combinations on products from other manufacturers); after this, the num lock blue indicator will be lit up on the upper verge of the keyboard. And then, you can type the key stroke combination Alt+Fn+mjol (for the pound sign) which can be looked up in the "Programs-&gt;Accessories-&gt;System Tools-&gt;Character Map"; combination "mjol" from the normal keyboard is the same as "0163" from the numeric keypad. The second trick comes in handy especially when you have to type such a rarely used character in the password field of windows log-on screen where normal copy and paste does not work.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;font-size:11pt;"  &gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-7851531619418520838?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/7851531619418520838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/two-tricks-discovered-about-dells.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7851531619418520838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7851531619418520838'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/two-tricks-discovered-about-dells.html' title='Two tricks discovered on Dell&apos;s Latitude E4300 laptop'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-6883070335052709720</id><published>2009-07-17T03:30:00.000+02:00</published><updated>2009-07-17T03:36:04.756+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Window Genuine Advantage'/><category scheme='http://www.blogger.com/atom/ns#' term='WGA'/><title type='text'>How to Remove the Windows Genuine Advantage (WGA) Notification Installation Wizard</title><content type='html'>I am not against Microsoft at all, actually I am pretty much a big fan of MS's products, e.g. SQL Server. But when Windows tries to annoy me with the WGA notification installation wizard, I have to strike back a bit. Here is the link to the video instructions on youtube.&lt;br /&gt;&lt;br /&gt;http://www.youtube.com/watch?v=-OaC_9GStUo&lt;br /&gt;&lt;br /&gt;Note: this is only for disabling the installation wizard, if you have already installed the WGA notification on your system, then please Google for other solutions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-6883070335052709720?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/6883070335052709720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/how-to-remove-windows-genuine-advantage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6883070335052709720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/6883070335052709720'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/how-to-remove-windows-genuine-advantage.html' title='How to Remove the Windows Genuine Advantage (WGA) Notification Installation Wizard'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4094861534186208857</id><published>2009-07-13T13:11:00.001+02:00</published><updated>2009-07-17T03:37:23.207+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scripting schema'/><category scheme='http://www.blogger.com/atom/ns#' term='database publishing wizard'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How to script the schema and/or data from database objects?</title><content type='html'>Recently, I have been facing an requirement to replicate the same data structure from production to a testing environment in a VM machine. And the data in the production db is too large to be hosed in the VM and only the schema is of more interest for my assignment. Therefore, I did some research into how to actually replicate a database schema from one place to another, which put it another can be referred to as "publishing a database".&lt;br /&gt;&lt;br /&gt;A complete answers lies &lt;a href="http://blogs.msdn.com/blogdoezequiel/archive/2008/11/07/how-to-script-all-my-database-objects-here-is-the-answer.aspx"&gt;here&lt;/a&gt;, but for now I've only tested Microsoft's official "&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=56E5B1C5-BF17-42E0-A410-371A838E570A&amp;amp;displaylang=en"&gt;database publishing wizard&lt;/a&gt;". Strangely, this wizard does not officially support SQL Server 2008 version yet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4094861534186208857?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4094861534186208857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/list-of-useful-sql-server-how-tos.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4094861534186208857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4094861534186208857'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/list-of-useful-sql-server-how-tos.html' title='How to script the schema and/or data from database objects?'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-8154323973131724350</id><published>2009-07-10T17:51:00.000+02:00</published><updated>2009-07-17T03:38:54.075+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Edition Upgrade'/><category scheme='http://www.blogger.com/atom/ns#' term='SSMS'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How to upgrade an expired evaluation edition of SQL Server 2008</title><content type='html'>I recently tried to upgrade SQL Server 2008's evaluation edition to Developer Edition. Since it has been an expired copy, the upgrade although finished with success, the SSMS still kept popping up expiration message. I later did some research on Google and SQLServerCentral, just to find out that no edition upgrade actually upgrade the SSMS and there is some registry modification need to be done for a workaround. &lt;a href="http://sqlblog.com/blogs/jonathan_kehayias/archive/2009/02/20/sql-server-2008-evaluation-edition-expiration-woes.aspx"&gt;This article&lt;/a&gt; from Jonathan Kehayias gives a better step-by-step guide to change the registry and after the change is made, you can use the "Edition Upgrade" function from the "Maintenance" page that you can access from the SQL Server Installation Center. One thing to bear in mind is that you have to change the registry first and then run the Edition Upgrade. The sequence can not be reversed.&lt;br /&gt;&lt;br /&gt;Two of the most important screen shots are as follows:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Qh5rivXmiTU/SldlWy2p-FI/AAAAAAAAAAU/WHBkwygEL8s/s1600-h/Edition+Upgrade.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_Qh5rivXmiTU/SldlWy2p-FI/AAAAAAAAAAU/WHBkwygEL8s/s320/Edition+Upgrade.JPG" alt="" id="BLOGGER_PHOTO_ID_5356861724063037522" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://sqlblog.com/blogs/jonathan_kehayias/WindowsLiveWriter/SQLServer2008EvaluationEditionExpiration_831E/image_thumb_1.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 270px;" src="http://sqlblog.com/blogs/jonathan_kehayias/WindowsLiveWriter/SQLServer2008EvaluationEditionExpiration_831E/image_thumb_1.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="file:///C:/DOCUME%7E1/nxu/LOCALS%7E1/Temp/moz-screenshot.png" alt="" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-8154323973131724350?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/8154323973131724350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/how-to-upgrade-expired-evaluation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/8154323973131724350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/8154323973131724350'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/how-to-upgrade-expired-evaluation.html' title='How to upgrade an expired evaluation edition of SQL Server 2008'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Qh5rivXmiTU/SldlWy2p-FI/AAAAAAAAAAU/WHBkwygEL8s/s72-c/Edition+Upgrade.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-4607751147725332934</id><published>2009-07-06T22:58:00.001+02:00</published><updated>2009-07-17T03:40:28.525+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wireless zero configuration'/><category scheme='http://www.blogger.com/atom/ns#' term='wireless network'/><title type='text'>How to get  Windows to manage wireless network</title><content type='html'>This is a strange issue that I met recently on my company's laptop that every time I wanna configure in the way that Windows is used to manage the wireless network, the tab "Wireless Networks" on the "Wireless Network Connection Properties" window simply disappears; even after several reboots, it refuses to reveal itself.&lt;br /&gt;&lt;img src="file:///C:/DOCUME%7E1/NINGXU%7E1.NIN/LOCALS%7E1/Temp/moz-screenshot-3.jpg" alt="" /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Qh5rivXmiTU/SlJmeo9qj0I/AAAAAAAAAAM/PjXn-OxPAEw/s1600-h/Wireless+Network+Connection+Properties.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 265px; height: 320px;" src="http://1.bp.blogspot.com/_Qh5rivXmiTU/SlJmeo9qj0I/AAAAAAAAAAM/PjXn-OxPAEw/s320/Wireless+Network+Connection+Properties.JPG" alt="" id="BLOGGER_PHOTO_ID_5355455583475109698" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A quick Google search redirects to a forum &lt;a href="http://www.pixalo.com/community/computer-hardware-software-networking-internet/how-get-windows-manage-wireless-microsoft-871122-a-13713.html"&gt;post&lt;/a&gt; and the solution is pretty simple too: just start the Wireless Zero Configuration service either manually or reset it as automatic.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-4607751147725332934?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/4607751147725332934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/how-to-get-windows-to-manage-wireless.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4607751147725332934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/4607751147725332934'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/07/how-to-get-windows-to-manage-wireless.html' title='How to get  Windows to manage wireless network'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Qh5rivXmiTU/SlJmeo9qj0I/AAAAAAAAAAM/PjXn-OxPAEw/s72-c/Wireless+Network+Connection+Properties.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-7081330763478928066</id><published>2009-06-08T19:56:00.000+02:00</published><updated>2009-07-17T03:38:26.114+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='drop database'/><category scheme='http://www.blogger.com/atom/ns#' term='t-sql'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>"cannot drop database because it is currently in use"</title><content type='html'>A common mistake is usually made when executing the "drop database &lt;db_name&gt;&lt;span style="font-style: italic;"&gt;db_name&lt;/span&gt;" statement is forgetting to terminate the current session connected to the target database. A quick solution is to switch to master db and then drop it.&lt;br /&gt;&lt;br /&gt;use master&lt;br /&gt;drop database &lt;span style="font-style: italic;"&gt;db_name&lt;/span&gt;&lt;db_name&gt;&lt;br /&gt;&lt;br /&gt;Most of the time, this can succeed. If the same error message still pops up, disconnect query analyzer or management studio from the SQL Server and reconnect to it and run the above t-sql command again.&lt;/db_name&gt;&lt;/db_name&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-7081330763478928066?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/7081330763478928066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/06/cannot-drop-database-because-it-is.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7081330763478928066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/7081330763478928066'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/06/cannot-drop-database-because-it-is.html' title='&quot;cannot drop database because it is currently in use&quot;'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3759083553109072454.post-5032719453886767601</id><published>2009-05-16T12:04:00.000+02:00</published><updated>2009-07-17T03:37:53.968+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Start from being a novice at SQL</title><content type='html'>This is the first post on this blog which will document the growth of my technological knowledge regarding MS Sql Server database management system. Since I don't have either the edge or the age advantage anymore, hopefully the road from a novice to a true professional can be shortened by my dedicated efforts. We'll see in the next couple of months how this blog is maintained and updated. Anyhow, I am still a technical person who is determined to shine no matter what I am made of. If anyone ever bumps into this blog while trying to google a technical solution to SQL problems, he/she is welcome to leave a footprint here which will be highly appreciated.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3759083553109072454-5032719453886767601?l=sqlnovice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlnovice.blogspot.com/feeds/5032719453886767601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlnovice.blogspot.com/2009/05/start-from-being-novice-at-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/5032719453886767601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3759083553109072454/posts/default/5032719453886767601'/><link rel='alternate' type='text/html' href='http://sqlnovice.blogspot.com/2009/05/start-from-being-novice-at-sql.html' title='Start from being a novice at SQL'/><author><name>Ning Xu</name><uri>http://www.blogger.com/profile/00345117794642410336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
