<?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-6274021835416509041</id><updated>2012-02-16T11:26:10.794-08:00</updated><category term='tranlog'/><category term='Microsoft'/><category term='SQL'/><category term='xp_sqllitespeed_version'/><category term='Powershell'/><category term='alter trace'/><category term='granting rights'/><category term='Sybase MSSQL'/><category term='create table'/><category term='count(*)'/><category term='Pass'/><category term='net start'/><category term='xp_restore_database'/><category term='Oracle'/><category term='restore backup'/><category term='What is Normalization'/><category term='test'/><category term='identiy error'/><category term='database file sizes'/><category term='sqlserver'/><category term='delete'/><category term='DBCC Shrinkfile'/><category term='Backup'/><category term='getting started in SQL'/><category term='uptime'/><category term='DBCC Opentran'/><category term='serice broker'/><category term='Software'/><category term='SQL2005'/><category term='count'/><category term='cu5 service pack 3'/><category term='sqltext'/><category term='Truncate'/><category term='transactional'/><category term='MSSQL'/><category term='table'/><category term='shrink log'/><category term='dbo'/><category term='select'/><category term='shrinklog'/><category term='CODE CAMP'/><category term='primary key'/><category term='authentication'/><category term='walkthrough'/><category term='trigger'/><category term='simple compare'/><category term='Postgress'/><category term='Sybase'/><category term='RDBMS'/><category term='create database'/><category term='tempdb'/><category term='2005'/><category term='TSQL'/><category term='Transaction Log'/><category term='Economy'/><category term='interview'/><category term='latest full. xp_restore'/><category term='Install'/><category term='errors'/><category term='Down Turn'/><category term='DBA'/><category term='DBCC'/><category term='litespeed'/><category term='no snapshot'/><category term='CAMP'/><category term='shrinkdb'/><category term='sp'/><category term='replication'/><category term='cu6'/><title type='text'>SQL2005Help</title><subtitle type='html'>This Blog Is to help you find out more about becoming a dba and to share my knowledge</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-7108706572905801890</id><published>2010-12-22T21:30:00.000-08:00</published><updated>2010-12-22T21:40:58.380-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='identiy error'/><title type='text'>Table ' does not have the identity property. Cannot perform SET operation.</title><content type='html'>Error Message:&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;System.Data.SqlClient.SqlException: Cannot find the object "table" because it does not exist or you do not have permissions.&lt;br /&gt;&lt;br /&gt;try again&lt;br /&gt;System.Data.SqlClient.SqlException: Table table does not have the identity property. Cannot perform SET operation.&lt;br /&gt;   at table.DatabaseIO.UpdateKey(Key key, KeyGroup keyGroup)&lt;br /&gt;   at table.Interface.AddKey.btnSave_Click(Object sender, EventArgs e)&lt;br /&gt;   at System.Windows.Forms.Control.OnClick(EventArgs e)&lt;br /&gt;   at DevExpress.XtraEditors.BaseButton.OnClick(EventArgs e)&lt;br /&gt;Description:&lt;br /&gt;This error message appears when you try to use the SET IDENTITY_INSERT setting for a table that does not contain a column, for which the IDENTITY property was declared.&lt;br /&gt;&lt;br /&gt;Consequences:&lt;br /&gt;The T-SQL statement can be parsed, but causes the error at runtime.&lt;br /&gt;&lt;br /&gt;Resolution:&lt;br /&gt;Error of the Severity level 16 are generated by the user and are corrigible by the user. The SET IDENTITY_INSERT setting cannot be used on such a table.&lt;br /&gt;&lt;br /&gt;Versions:&lt;br /&gt;All versions of SQL Server.&lt;br /&gt;&lt;br /&gt;Example(s):&lt;br /&gt;USE test&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE TABLE test2&lt;br /&gt;(&lt;br /&gt; test1 int)&lt;br /&gt;GO &lt;br /&gt;SET IDENTITY_INSERT t ON&lt;br /&gt;INSERT INTO test1  SELECT 1&lt;br /&gt;SET IDENTITY_INSERT test1 OFF&lt;br /&gt;DROP TABLE test1&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;Remarks:&lt;br /&gt;In the above example we try to turn on the IDENTITY_INSERT setting für the table test1 to insert an explicite value into a column for which the IDENTITY property was declared. Because there no such column in table test1, the error is raised.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-7108706572905801890?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/7108706572905801890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/12/table-does-not-have-identity-property.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7108706572905801890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7108706572905801890'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/12/table-does-not-have-identity-property.html' title='Table &apos; does not have the identity property. Cannot perform SET operation.'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-876905574636370729</id><published>2010-12-22T21:27:00.000-08:00</published><updated>2010-12-22T21:29:40.193-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='granting rights'/><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='alter trace'/><title type='text'>How to enable access to sql proflier without sysadmin</title><content type='html'>If a member of your team wants to have trace rights to diag a issue you can grant alter trace.&lt;br /&gt;&lt;br /&gt;grant Alter trace to username&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;to stop this right&lt;br /&gt;&lt;br /&gt;deny alter trace to username &lt;br /&gt;go&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-876905574636370729?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/876905574636370729/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/12/how-to-enable-access-to-sql-proflier.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/876905574636370729'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/876905574636370729'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/12/how-to-enable-access-to-sql-proflier.html' title='How to enable access to sql proflier without sysadmin'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-7459098733479253483</id><published>2010-12-04T05:05:00.000-08:00</published><updated>2010-12-04T05:34:09.571-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='transactional'/><category scheme='http://www.blogger.com/atom/ns#' term='no snapshot'/><category scheme='http://www.blogger.com/atom/ns#' term='replication'/><title type='text'>Setting up transactional replication without a snapshot</title><content type='html'>We had a case where a client needed replication from London to Hong Kong and New York, needless to say we setup the transaction replication we a snapshot and due to the latency issues the snapshot never worked. I decedied to set up replication without the snapshotm heres how to do it if you need to know. &lt;br /&gt;&lt;br /&gt;Normally its very easy to setup the publisher and subscriber by default. Thanks to the handy Wizard interface. However, we faced a tiny bit of a problem when using the wizard.&lt;br /&gt;&lt;br /&gt;If you are replicating on the same domain and in the same country using the wizzard is great but this is probably only a small about of situations.&lt;br /&gt;&lt;br /&gt;I had a problem with the initial snapshot creation as said above when setting up the transactional replication. This is using SQL Server 2008. The initial snapshot creation took a very long time and would not complete. Even after running it over a weekend, for 48 hours, it did not complete. The thing is, while the snapshot agent was running, the database was not accessible to other users. Is there a way to make the snapshot run under low priority? &lt;br /&gt;&lt;br /&gt;Since I had to allow users access to the database, I had to stop the snapshot job. Will it start from scratch if restarted or will it continue from where it stopped? I tested and it seemed to start from scratch once again. Another 8+ hours? I don’t think so. Thus, I set out to find a way to create a transactional replication without a snapshot.&lt;br /&gt;&lt;br /&gt;I did a little bit of checking around to find out how to do this as we are all DBAs but a DBA does not know everything hence why you are also reading this site. I found a stored procedure called sp_addsubscription(), this will allow one to initialize a subscription without the need to create a snapshot of the publishing database. sp_addsubscription()you will be able to run and create replication with a backup with this and without the snapshot ment not many hours of waiting. I said to myself. So I did. I did the first test in dev and then in prod after it worked,&lt;br /&gt;&lt;br /&gt;Here is how to do it&lt;br /&gt;Following are the steps to create a SQL Server 2005 Transactional Replication without an initial snapshot. &lt;br /&gt;&lt;br /&gt;1. Create a new publication using the New Publication Wizard. you are able to still do this by using the wizard to create the publication. Just apply the right information  in the fields and settings as required according to your environment. However, when you reach the SnapShot Agent dialog, you will need to leave all the checkboxes unticked. The reason being is that you dont want a snapshot remember this? That’s the only thing to note while going through the New Publication Wizard dialogs. &lt;br /&gt;&lt;br /&gt;2. Upon completion of the New Publication Wizard, open the property dialog to your publication. You now need to modify a property setting on the publication. You need to set the publication to allow initialization from backup files. Yeah, that’s all there is to it. Just set this setting to True. It really would have been even more dandier if this could be performed within the New Publication Wizard though.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. you will now need to Perform a full backup of your database.  Backup the database to a directory or drive accessible by the SQL Server, such as e:\ted\ted.bak in my case.&lt;br /&gt;&lt;br /&gt;4. Restore the backup into the  subscriber sql server instance. Don’t know &lt;br /&gt;how to restore from a SQL backup? Google it up. Easy way to restore is from the managemt studio.&lt;br /&gt;&lt;br /&gt;5. Run the following stored procedure in the SQL Server Management Studio Query Window on your publisher server.&lt;br /&gt;&lt;br /&gt;sp_addsubscription &lt;br /&gt;@publication ='YourPublicationName', --ie tedpub&lt;br /&gt;@subscriber='SubscriberServerDBInstance', --servername in my case tedserver02@destination_db='SubscriberDatabase',  -- teddb&lt;br /&gt;@sync_type = 'initialize with backup',&lt;br /&gt;@backupdevicetype = 'disk',&lt;br /&gt;@backupdevicename = d:\ted.bak'&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You will need to disable or change the job of the cleanup job to run as SA, I would just disable this job before you run the above command as you may encounter an error. &lt;br /&gt;&lt;br /&gt;you will now see a new job in the sql agent just go to the job and right click go to properties and then set the job to run as sa.&lt;br /&gt;&lt;br /&gt;round up&lt;br /&gt;backup publication database &lt;br /&gt;copy backup to subscriber server &lt;br /&gt;restoring subscriber database &lt;br /&gt;The transactional replication is now happily running between the two servers. Of course, the above process creates only a basic full database transactional replication. If your requirements are a litte bit more complicated, you might want to take a look at the options you can configure in the sp_addsubscription stored procedure.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-7459098733479253483?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/7459098733479253483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/12/setting-up-transactional-replication.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7459098733479253483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7459098733479253483'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/12/setting-up-transactional-replication.html' title='Setting up transactional replication without a snapshot'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-1571046854604013127</id><published>2010-06-28T20:29:00.001-07:00</published><updated>2010-06-28T20:29:35.239-07:00</updated><title type='text'>checking sql2005 replication</title><content type='html'>select la.name,la.publisher_db, &lt;br /&gt;case lh.runstatus &lt;br /&gt;when 1 then 'Start' &lt;br /&gt;when 2 then 'Succeed' &lt;br /&gt;when 3 then 'In progress' &lt;br /&gt;when 4 then 'Idle' &lt;br /&gt;when 5 then 'Retry' &lt;br /&gt;when 6 then 'Fail' &lt;br /&gt;else 'Unknown' &lt;br /&gt;end as runstatus &lt;br /&gt;, lh.time, lh.comments &lt;br /&gt;from distribution..MSlogreader_history lh &lt;br /&gt;inner join distribution..MSlogreader_agents la on lh.agent_id = la.id &lt;br /&gt;inner join ( &lt;br /&gt;select lh.agent_id, max(lh.time) as LastTime &lt;br /&gt;from distribution..MSlogreader_history lh &lt;br /&gt;inner join distribution..MSlogreader_agents la on lh.agent_id = la.id &lt;br /&gt;group by lh.agent_id) r &lt;br /&gt;on r.agent_id = lh.agent_id &lt;br /&gt;and r.LastTime = lh.time &lt;br /&gt;where lh.runstatus not in (3,4) -- 3:In Progress, 4: Idle &lt;br /&gt;&lt;br /&gt;select * from distribution..MSlogreader_history&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-1571046854604013127?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/1571046854604013127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/06/checking-sql2005-replication.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1571046854604013127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1571046854604013127'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/06/checking-sql2005-replication.html' title='checking sql2005 replication'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-2597720226204360328</id><published>2010-06-08T23:11:00.000-07:00</published><updated>2010-06-08T23:12:56.739-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='database file sizes'/><title type='text'>SIZE OF THE DATABASE FILES</title><content type='html'>SELECT name AS [File Name] , file_id, physical_name AS [Physical Name],&lt;br /&gt;size/128 AS [Total Size in MB],&lt;br /&gt;size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0&lt;br /&gt;AS [Available Space In MB]&lt;br /&gt;FROM sys.database_files;&lt;br /&gt;&lt;br /&gt;OUTPUT&lt;br /&gt;File Name                                                                                                                        file_id     Physical Name                                                                                                                                                                                                                                                    Total Size in MB Available Space In MB&lt;br /&gt;-------------------------------------------------------------------------------------------------------------------------------- ----------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------- ---------------------------------------&lt;br /&gt;master                                                                                                                           1           D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf                                                                                                                                                                                              80               71.625000&lt;br /&gt;mastlog                                                                                                                          2           D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf                                                                                                                                                                                             1                0.640625&lt;br /&gt;&lt;br /&gt;(2 row(s) affected)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-2597720226204360328?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/2597720226204360328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/06/size-of-database-files.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/2597720226204360328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/2597720226204360328'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/06/size-of-database-files.html' title='SIZE OF THE DATABASE FILES'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-4489850660768105823</id><published>2010-06-08T23:03:00.000-07:00</published><updated>2010-06-08T23:04:54.083-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='authentication'/><title type='text'>How to find the authentication methord used</title><content type='html'>This script will help you find the authentication method of logins in sql 2005.&lt;br /&gt;&lt;br /&gt;SELECT 'Authentication Method'=(&lt;br /&gt; CASE &lt;br /&gt;  WHEN nt_user_name IS not null THEN 'Windows Authentication' &lt;br /&gt;  ELSE 'SQL Authentication' &lt;br /&gt; END),&lt;br /&gt;   login_name AS 'Login Name', ISNULL(nt_user_name,'-') AS 'Windows Login Name',&lt;br /&gt;   COUNT(session_id) AS 'Session Count'&lt;br /&gt;   FROM sys.dm_exec_sessions&lt;br /&gt;   GROUP BY login_name,nt_user_name&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-4489850660768105823?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/4489850660768105823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/06/how-to-find-authentication-methord-used.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4489850660768105823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4489850660768105823'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/06/how-to-find-authentication-methord-used.html' title='How to find the authentication methord used'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-5080765649387384482</id><published>2010-05-30T22:18:00.000-07:00</published><updated>2010-05-30T22:22:54.442-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='shrink log'/><title type='text'>quick and dirty shrinklogs for all databases</title><content type='html'>This is a real quick and dirty way to shink all the database logs in all the databases please makesure you want to shrink the master, msdb,tempdb and so on before running this. &lt;br /&gt;&lt;br /&gt;EXEC SP_MSFOREACHDB 'dbcc shrinkfile(2,1)'&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-5080765649387384482?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/5080765649387384482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/05/quick-and-dirty-shrinklogs-for-all.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/5080765649387384482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/5080765649387384482'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/05/quick-and-dirty-shrinklogs-for-all.html' title='quick and dirty shrinklogs for all databases'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-1822945362355708310</id><published>2010-05-26T23:08:00.000-07:00</published><updated>2010-05-26T23:09:54.620-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sqltext'/><category scheme='http://www.blogger.com/atom/ns#' term='tempdb'/><title type='text'>Script to check whats running in tempdb and want statements its running</title><content type='html'>This will help deturming what is running in tempdb this will give you the sql text. &lt;br /&gt;&lt;br /&gt;use tempdb&lt;br /&gt;SELECT tst.[session_id],&lt;br /&gt;s.[login_name] AS [Login Name],&lt;br /&gt;DB_NAME (tdt.database_id) AS [Database],&lt;br /&gt;tdt.[database_transaction_begin_time] AS [Begin Time],&lt;br /&gt;tdt.[database_transaction_log_record_count] AS [Log Records],&lt;br /&gt;tdt.[database_transaction_log_bytes_used] AS [Log Bytes Used],&lt;br /&gt;tdt.[database_transaction_log_bytes_reserved] AS [Log Bytes Rsvd],&lt;br /&gt;SUBSTRING(st.text, (r.statement_start_offset/2)+1, &lt;br /&gt;((CASE r.statement_end_offset&lt;br /&gt;WHEN -1 THEN DATALENGTH(st.text)&lt;br /&gt;ELSE r.statement_end_offset&lt;br /&gt;END - r.statement_start_offset)/2) + 1) AS statement_text,&lt;br /&gt;st.[text] AS [Last T-SQL Text],&lt;br /&gt;qp.[query_plan] AS [Last Plan]&lt;br /&gt;FROM sys.dm_tran_database_transactions tdt&lt;br /&gt;JOIN sys.dm_tran_session_transactions tst&lt;br /&gt;ON tst.[transaction_id] = tdt.[transaction_id]&lt;br /&gt;JOIN sys.[dm_exec_sessions] s&lt;br /&gt;ON s.[session_id] = tst.[session_id]&lt;br /&gt;JOIN sys.dm_exec_connections c&lt;br /&gt;ON c.[session_id] = tst.[session_id]&lt;br /&gt;LEFT OUTER JOIN sys.dm_exec_requests r&lt;br /&gt;ON r.[session_id] = tst.[session_id]&lt;br /&gt;CROSS APPLY sys.dm_exec_sql_text (c.[most_recent_sql_handle]) AS st&lt;br /&gt;OUTER APPLY sys.dm_exec_query_plan (r.[plan_handle]) AS qp&lt;br /&gt;where DB_NAME (tdt.database_id) = 'tempdb'&lt;br /&gt;ORDER BY [Log Bytes Used] DESC;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-1822945362355708310?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/1822945362355708310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/05/script-to-check-whats-running-in-tempdb.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1822945362355708310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1822945362355708310'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/05/script-to-check-whats-running-in-tempdb.html' title='Script to check whats running in tempdb and want statements its running'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-7979897121214889437</id><published>2010-05-17T20:01:00.000-07:00</published><updated>2010-05-17T20:08:19.250-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='simple compare'/><category scheme='http://www.blogger.com/atom/ns#' term='table'/><category scheme='http://www.blogger.com/atom/ns#' term='trigger'/><title type='text'>Check which tables have triggers and compare</title><content type='html'>This is useful if you have 2 or more databases in different sites. &lt;br /&gt;&lt;br /&gt;Script to check which tables have triggers&lt;br /&gt;&lt;br /&gt;SELECT s1.name as tablename, s2.name as triggername FROM sysobjects s1 &lt;br /&gt;JOIN sysobjects s2 ON &lt;br /&gt;s1.id =s2.parent_obj &lt;br /&gt;AND s2.xtype = 'TR' &lt;br /&gt;WHERE s1.xtype = 'U' &lt;br /&gt;ORDER BY s1.name&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;output&lt;br /&gt;&lt;br /&gt;tablename                                                                                                                        triggername&lt;br /&gt;-------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;AccruedDivis                                                                                                                     trAccrueddivisAuditQueueInsert&lt;br /&gt;AccruedDivis                                                                                                                     trAccrueddivisAuditQueueUpdate&lt;br /&gt;AccruedDivis                                                                                                                     trAccrueddivisAuditQueueDelete&lt;br /&gt;AlertMessages                                                                                                                    trAlertMessagesInsert&lt;br /&gt;Run this on both of the servers and in the databases required&lt;br /&gt;copy the data to an excel worksheet&lt;br /&gt;I have two databases one in London and one in Hong Kong in this sample&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/__zFxCqPcmaI/S_IERyG9MmI/AAAAAAAABU0/ERPSyMOrIU4/s1600/output.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 302px;" src="http://1.bp.blogspot.com/__zFxCqPcmaI/S_IERyG9MmI/AAAAAAAABU0/ERPSyMOrIU4/s320/output.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472441200763810402" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;use a vlookup to compare like this and the copy the formula down&lt;br /&gt;&lt;br /&gt;=VLOOKUP(B115,'sheet.name'!B:B,1,FALSE)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-7979897121214889437?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/7979897121214889437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/05/check-which-tables-have-triggers-and.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7979897121214889437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7979897121214889437'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/05/check-which-tables-have-triggers-and.html' title='Check which tables have triggers and compare'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/__zFxCqPcmaI/S_IERyG9MmI/AAAAAAAABU0/ERPSyMOrIU4/s72-c/output.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-8633642190718304829</id><published>2010-05-02T19:52:00.001-07:00</published><updated>2010-05-02T19:52:44.594-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='serice broker'/><title type='text'>How to start service broker on a database</title><content type='html'>enable service broker&lt;br /&gt;-- Alter the database to enable ServiceBroker functionality&lt;br /&gt;&lt;br /&gt;DECLARE @dbname VARCHAR(30)&lt;br /&gt;&lt;br /&gt;SELECT @dbname=db_name()&lt;br /&gt;&lt;br /&gt;PRINT 'Setting up service broker on ' + @dbname&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;EXEC ('ALTER DATABASE ' + @dbname + ' SET SINGLE_USER WITH ROLLBACK IMMEDIATE')&lt;br /&gt;&lt;br /&gt;EXEC ('ALTER DATABASE ' + @dbname + ' set NEW_BROKER')&lt;br /&gt;&lt;br /&gt;EXEC ('ALTER DATABASE ' + @dbname + ' SET ENABLE_BROKER')&lt;br /&gt;&lt;br /&gt;EXEC ('ALTER DATABASE ' + @dbname + ' SET MULTI_USER')&lt;br /&gt;&lt;br /&gt;IF (SELECT is_broker_enabled FROM sys.databases WHERE name = @dbname) = 0&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;--    PRINT 'The Service broker wasn''t enabled !!'&lt;br /&gt;&lt;br /&gt;      RAISERROR ('The Service broker wasn''t enabled !!', 1,      1)&lt;br /&gt;&lt;br /&gt;END&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-8633642190718304829?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/8633642190718304829/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/05/how-to-start-service-broker-on-database.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/8633642190718304829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/8633642190718304829'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/05/how-to-start-service-broker-on-database.html' title='How to start service broker on a database'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-4868060924032872511</id><published>2010-04-25T22:33:00.000-07:00</published><updated>2010-04-25T22:34:38.767-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='uptime'/><category scheme='http://www.blogger.com/atom/ns#' term='2005'/><category scheme='http://www.blogger.com/atom/ns#' term='sqlserver'/><title type='text'>a few ways to check server uptime</title><content type='html'>Here are a few ways to check your sqlserver2005 uptime&lt;br /&gt;&lt;br /&gt;SELECT @@servername as ServerName, datediff(mi, login_time, getdate()) as SQLServer_UpTime_Minutes&lt;br /&gt;FROM master..sysprocesses WHERE spid = 1&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;SELECT @@servername as ServerName,   getdate() - login_time as SQLServer_UpDateTime_1900_01_01&lt;br /&gt;FROM master..sysprocesses &lt;br /&gt;WHERE spid = 1&lt;br /&gt;go&lt;br /&gt;&lt;br /&gt;SELECT @@servername as ServerName,  Year( SQLServer_UpTime) - 1900 - case when month( SQLServer_UpTime) - 1 - case when day( SQLServer_UpTime) - 1 &lt; 0 then 1 else 0 end &lt; 0 then 1 else 0 end as Years&lt;br /&gt;, month( SQLServer_UpTime) - 1 - case when day( SQLServer_UpTime) - 1 &lt; 0 then 1 else 0 end  as Months&lt;br /&gt;, day( SQLServer_UpTime) - 1 as Days&lt;br /&gt;, substring(convert(varchar(25), SQLServer_UpTime,121),12,8) as Timepart&lt;br /&gt;from (&lt;br /&gt;SELECT  getdate() - login_time as SQLServer_UpTime  -- opgepast start vanaf 1900-01-01&lt;br /&gt;FROM master..sysprocesses &lt;br /&gt;WHERE spid = 1&lt;br /&gt;) a&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-4868060924032872511?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/4868060924032872511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/few-ways-to-check-server-uptime.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4868060924032872511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4868060924032872511'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/few-ways-to-check-server-uptime.html' title='a few ways to check server uptime'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-7018787097307895167</id><published>2010-04-24T22:09:00.000-07:00</published><updated>2010-04-24T22:11:50.399-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='net start'/><title type='text'>How to restart your sqlserver inside of SQL server</title><content type='html'>Restarting your SQL service within SQL&lt;br /&gt; &lt;br /&gt;we need to bounce the service so that all the tempdb files get created, the agent knows the database config, etc.&lt;br /&gt;&lt;br /&gt;The trick isn't stopping the server: "net stop mssqlserver" will do that. The real trick is starting it back up, once you've shut down the SQL server. Since our solution is all done via SQLCMD we needed a way, within SQL itself, to start back up.&lt;br /&gt;&lt;br /&gt;Our secret is the ampersand; when the command line interpreter catches it, it views it as you hitting the "Enter" key. So, even though the SQL service is off, the job continues.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;declare @sqlcmd varchar(8000)select @sqlcmd = 'net stop SQLSERVERAGENT &amp; ping -n 15 127.0.0.1 &amp; '+ 'net stop MSSQLSERVER &amp; ping -n 15 127.0.0.1 &amp; ' + 'net start MSSQLSERVER &amp; ping -n 15 127.0.0.1 &amp; ' + 'net start SQLSERVERAGENT'EXEC xp_cmdshell (@sqlcmd)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-7018787097307895167?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/7018787097307895167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/how-to-restart-your-sqlserver-inside-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7018787097307895167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7018787097307895167'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/how-to-restart-your-sqlserver-inside-of.html' title='How to restart your sqlserver inside of SQL server'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-6637142657271425694</id><published>2010-04-23T17:55:00.000-07:00</published><updated>2010-04-23T18:06:54.936-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latest full. xp_restore'/><category scheme='http://www.blogger.com/atom/ns#' term='restore backup'/><title type='text'>Creating a automated backup and restore with litespeed</title><content type='html'>Copy this code into a sqljob for and set time to whatever time you would like the backup taken this will work for daily backups and delete weekly. &lt;br /&gt;&lt;br /&gt;SET QUOTED_IDENTIFIER ON&lt;br /&gt; &lt;br /&gt;DECLARE @lastweekfiletime char(10)&lt;br /&gt;, @dircmd varchar(500)&lt;br /&gt;, @delcmd varchar(500)&lt;br /&gt;, @filetime char(19)&lt;br /&gt;, @sqlcmd varchar(500)&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;SELECT @lastweekfiletime = convert(char(4),dateadd(dd,-7,getdate()),112)+ '-' + substring(convert(char(8),dateadd(dd,-7,getdate()),112),5,2) + '-' &lt;br /&gt;+  substring(convert(char(8),dateadd(dd,-7,getdate()),112),7,2);&lt;br /&gt; &lt;br /&gt;PRINT @lastweekfiletime;&lt;br /&gt; &lt;br /&gt;SELECT @dircmd = 'EXEC master..xp_cmdshell ''DIR d:\dir\database_' + @lastweekfiletime + '*.lsb.dmp''';&lt;br /&gt; &lt;br /&gt;EXEC(@dircmd);&lt;br /&gt;-- deletes older files&lt;br /&gt;SELECT @delcmd = 'EXEC master..xp_cmdshell ''DEL d:\dir\database_' + @lastweekfiletime + '*.lsb.dmp /Q''';&lt;br /&gt; &lt;br /&gt;print @delcmd;&lt;br /&gt; &lt;br /&gt;EXEC(@delcmd);&lt;br /&gt; &lt;br /&gt;EXEC(@dircmd);&lt;br /&gt; &lt;br /&gt;SELECT @filetime = (&lt;br /&gt;SELECT  convert(char(4),getdate(),112) + '-' &lt;br /&gt;+  substring(convert(char(8),getdate(),112),5,2) + '-' &lt;br /&gt;+  substring(convert(char(8),getdate(),112),7,2) + '_' + &lt;br /&gt;CASE len(datename(hh, getdate())) &lt;br /&gt;WHEN 1 THEN&lt;br /&gt;'0' + datename(hh, getdate())&lt;br /&gt;ELSE &lt;br /&gt;datename(hh, getdate())&lt;br /&gt;END +  '-' + &lt;br /&gt;CASE len(datename(mi, getdate()))&lt;br /&gt;WHEN 1 THEN&lt;br /&gt; CASE datename(mi, getdate())&lt;br /&gt; WHEN 0 THEN&lt;br /&gt;  datename(mi, getdate()) + '0'&lt;br /&gt; ELSE &lt;br /&gt; '0' + datename(mi, getdate())&lt;br /&gt; END&lt;br /&gt;ELSE&lt;br /&gt; datename(mi, getdate())&lt;br /&gt;END + '-' + &lt;br /&gt;CASE len(datename(ss, getdate()))&lt;br /&gt;WHEN 1 THEN&lt;br /&gt; CASE datename(ss, getdate())&lt;br /&gt; WHEN 0 THEN&lt;br /&gt;  datename(ss, getdate()) + '0'&lt;br /&gt; ELSE &lt;br /&gt; '0' + datename(ss, getdate())&lt;br /&gt; END&lt;br /&gt;ELSE&lt;br /&gt; datename(ss, getdate())&lt;br /&gt;END);&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;SET @sqlcmd = 'exec master..xp_backup_database @database = ''database'', @filename = ''d:\dir\database_' + @filetime + '_1of1.lsb.dmp''';&lt;br /&gt; &lt;br /&gt;EXEC(@sqlcmd);&lt;br /&gt;&lt;br /&gt;Restore if you would like to restore daily to another database on the same server you can us this job to pick up the latest full database. &lt;br /&gt;Or create a copy job to copy the backup accross to another server and use this to restore daily. &lt;br /&gt;SET NOCOUNT ON&lt;br /&gt;declare @RestoreDateTime varchar(20)&lt;br /&gt;declare @stmt varchar(500)&lt;br /&gt;declare @restore_stmt varchar(1000)&lt;br /&gt;declare @latest_full varchar(255)&lt;br /&gt; &lt;br /&gt;create table #SrcFilesRAW&lt;br /&gt;(&lt;br /&gt; SrcFName varchar(200)&lt;br /&gt;)&lt;br /&gt; &lt;br /&gt;select @stmt = 'dir D:\dir\*database_*.dmp /b' &lt;br /&gt; &lt;br /&gt;insert into #SrcFilesRAW&lt;br /&gt;exec master..xp_cmdshell @stmt&lt;br /&gt; &lt;br /&gt;select * from #SrcFilesRAW&lt;br /&gt;set rowcount 1&lt;br /&gt;select @latest_full = SrcFName from #SrcFilesRAW &lt;br /&gt;where SrcFName like 'database_20%' order by SrcFName desc&lt;br /&gt;set rowcount 0&lt;br /&gt;select * from #SrcFilesRAW&lt;br /&gt;drop table #SrcFilesRAW&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;select @restore_stmt = 'exec master..xp_restore_database @database = ''database1''&lt;br /&gt;,@FILENAME = ''D:\dir\'+ @latest_full + '''&lt;br /&gt;,@WITH = ''REPLACE'''&lt;br /&gt; &lt;br /&gt;exec (@restore_stmt)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-6637142657271425694?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/6637142657271425694/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/creating-automated-backup-and-restore.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6637142657271425694'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6637142657271425694'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/creating-automated-backup-and-restore.html' title='Creating a automated backup and restore with litespeed'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-6795669230996496212</id><published>2010-04-16T08:21:00.000-07:00</published><updated>2010-04-16T08:23:52.765-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='shrinkdb'/><category scheme='http://www.blogger.com/atom/ns#' term='shrinklog'/><category scheme='http://www.blogger.com/atom/ns#' term='sp'/><title type='text'></title><content type='html'>Useful SQL Server Scripts&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here are some usefull sqlserver scripts&lt;br /&gt;&lt;br /&gt;Useful for telling what version of SQL Server is being run, including which service pack has been applied. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT  SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'),&lt;br /&gt;SERVERPROPERTY ('edition')&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;How Much Space Per Table&lt;br /&gt;For each table in the current database, how much space is being used? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Count All Table Records&lt;br /&gt;Count the number of rows in each table in a database. How to use sysindexes and sysobjects. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT so.[name] as [table name], CASE WHEN si.indid between 1 and 254&lt;br /&gt;THEN si.[name] ELSE NULL END AS [Index Name], si.rowcnt&lt;br /&gt;FROM sysindexes si INNER JOIN sysobjects so ON si.id = so.id&lt;br /&gt;WHERE si.indid &lt; 2 AND so.type = 'U' AND so.[name] != 'dtproperties'&lt;br /&gt;ORDER BY so.[name]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;List All SQL Databases&lt;br /&gt;A simple example of cursors and using the master database catalog to find all databases on the server. &lt;br /&gt;&lt;br /&gt;Declare @database varchar(255)&lt;br /&gt;Declare DatabaseCursor Cursor&lt;br /&gt;Local&lt;br /&gt;Static&lt;br /&gt;For&lt;br /&gt;select name from master.dbo.sysdatabases&lt;br /&gt;open DatabaseCursor&lt;br /&gt;fetch next from DatabaseCursor into @database&lt;br /&gt;&lt;br /&gt;while @@fetch_status = 0&lt;br /&gt;begin&lt;br /&gt; print 'database:' + @database&lt;br /&gt; fetch next from DatabaseCursor into @database&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;close DatabaseCursor&lt;br /&gt;&lt;br /&gt;deallocate DatabaseCursor&lt;br /&gt;&lt;br /&gt;Reindex All Indexes on All Tables in a Database&lt;br /&gt;Run this in the database you want to reindex. &lt;br /&gt;&lt;br /&gt;DECLARE @tn varchar(255)&lt;br /&gt;&lt;br /&gt;DECLARE tc CURSOR FOR&lt;br /&gt;SELECT table_name FROM information_schema.tables&lt;br /&gt;WHERE table_type = 'base table'&lt;br /&gt;&lt;br /&gt;OPEN tc&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM tc INTO @tn&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;BEGIN&lt;br /&gt;DBCC DBREINDEX(@tn,' ',90)&lt;br /&gt;FETCH NEXT FROM tc INTO @tn&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE tc&lt;br /&gt;&lt;br /&gt;DEALLOCATE tc&lt;br /&gt;&lt;br /&gt;Trim SQL Database Space&lt;br /&gt;use my_database&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if object_id( 'sp_force_shrink_log' ) is not null drop proc sp_force_shrink_log&lt;br /&gt;go&lt;br /&gt;create proc sp_force_shrink_log&lt;br /&gt;    @target_percent tinyint = 0,&lt;br /&gt;    @target_size_MB int = 10,&lt;br /&gt;    @max_iterations int = 1000,&lt;br /&gt;    @backup_log_opt nvarchar(1000) = 'with truncate_only'&lt;br /&gt;as&lt;br /&gt;set nocount on&lt;br /&gt;&lt;br /&gt;declare @db         sysname,&lt;br /&gt;        @last_row   int,&lt;br /&gt;        @log_size   decimal(15,2),&lt;br /&gt;        @unused1    decimal(15,2),&lt;br /&gt;        @unused     decimal(15,2),&lt;br /&gt;        @shrinkable decimal(15,2),&lt;br /&gt;        @iteration  int,&lt;br /&gt; @file_max   int,&lt;br /&gt; @file     int,&lt;br /&gt; @fileid     varchar(5)&lt;br /&gt;&lt;br /&gt;select  @db = db_name(),&lt;br /&gt;        @iteration = 0&lt;br /&gt;&lt;br /&gt;create table #loginfo (&lt;br /&gt;    id          int identity,&lt;br /&gt;    FileId      int,&lt;br /&gt;    FileSize    numeric(22,0),&lt;br /&gt;    StartOffset numeric(22,0),&lt;br /&gt;    FSeqNo      int,&lt;br /&gt;    Status      int,&lt;br /&gt;    Parity      smallint,&lt;br /&gt;    CreateTime  numeric(22,0)&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;create unique clustered index loginfo_FSeqNo on #loginfo ( FSeqNo, StartOffset )&lt;br /&gt;&lt;br /&gt;create table #logfiles ( id int identity(1,1), fileid varchar(5) not null )&lt;br /&gt;insert #logfiles ( fileid ) select convert( varchar, fileid ) from sysfiles where status &amp; 0x40 = 0x40&lt;br /&gt;select @file_max = @@rowcount&lt;br /&gt;&lt;br /&gt;if object_id( 'table_to_force_shrink_log' ) is null&lt;br /&gt; exec( 'create table table_to_force_shrink_log ( x nchar(3000) not null )' )&lt;br /&gt;&lt;br /&gt;insert  #loginfo ( FileId, FileSize, StartOffset, FSeqNo, Status, Parity, CreateTime ) exec ( 'dbcc loginfo' )&lt;br /&gt;select  @last_row = @@rowcount&lt;br /&gt;&lt;br /&gt;select  @log_size = sum( FileSize ) / 1048576.00,&lt;br /&gt;        @unused = sum( case when Status = 0 then FileSize else 0 end ) / 1048576.00,&lt;br /&gt;        @shrinkable = sum( case when id &lt; @last_row - 1 and Status = 0 then FileSize else 0 end ) / 1048576.00&lt;br /&gt;from    #loginfo&lt;br /&gt;&lt;br /&gt;select  @unused1 = @unused -- save for later&lt;br /&gt;&lt;br /&gt;select  'iteration'          = @iteration,&lt;br /&gt;        'log size, MB'       = @log_size,&lt;br /&gt;        'unused log, MB'     = @unused,&lt;br /&gt;        'shrinkable log, MB' = @shrinkable,&lt;br /&gt;        'shrinkable %'       = convert( decimal(6,2), @shrinkable * 100 / @log_size )&lt;br /&gt;&lt;br /&gt;while @shrinkable * 100 / @log_size &gt; @target_percent&lt;br /&gt;  and @shrinkable &gt; @target_size_MB&lt;br /&gt;  and @iteration &lt; @max_iterations begin&lt;br /&gt;    select  @iteration = @iteration + 1 -- this is just a precaution&lt;br /&gt;&lt;br /&gt;    exec( 'insert table_to_force_shrink_log select name from sysobjects&lt;br /&gt;           delete table_to_force_shrink_log')&lt;br /&gt;&lt;br /&gt;    select @file = 0&lt;br /&gt;    while @file &lt; @file_max begin&lt;br /&gt;        select @file = @file + 1&lt;br /&gt;        select @fileid = fileid from #logfiles where id = @file&lt;br /&gt;        exec( 'dbcc shrinkfile( ' + @fileid + ' )' )&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    exec( 'backup log [' + @db + '] ' + @backup_log_opt )&lt;br /&gt;&lt;br /&gt;    truncate table #loginfo&lt;br /&gt;    insert  #loginfo ( FileId, FileSize, StartOffset, FSeqNo, Status, Parity, CreateTime ) exec ( 'dbcc loginfo' )&lt;br /&gt;    select  @last_row = @@rowcount&lt;br /&gt;&lt;br /&gt;    select  @log_size = sum( FileSize ) / 1048576.00,&lt;br /&gt;            @unused = sum( case when Status = 0 then FileSize else 0 end ) / 1048576.00,&lt;br /&gt;     @shrinkable = sum( case when id &lt; @last_row - 1 and Status = 0 then FileSize else 0 end ) / 1048576.00&lt;br /&gt;    from    #loginfo&lt;br /&gt;&lt;br /&gt;    select  'iteration'          = @iteration,&lt;br /&gt;            'log size, MB'       = @log_size,&lt;br /&gt;            'unused log, MB'     = @unused,&lt;br /&gt;            'shrinkable log, MB' = @shrinkable,&lt;br /&gt;            'shrinkable %'       = convert( decimal(6,2), @shrinkable * 100 / @log_size )&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;if @unused1 &lt; @unused&lt;br /&gt;select  'After ' + convert( varchar, @iteration ) +&lt;br /&gt;        ' iterations the unused portion of the log has grown from ' +&lt;br /&gt;        convert( varchar, @unused1 ) + ' MB to ' +&lt;br /&gt;        convert( varchar, @unused ) + ' MB.'&lt;br /&gt;union all&lt;br /&gt;select 'Since the remaining unused portion is larger than 10 MB,' where @unused &gt; 10&lt;br /&gt;union all&lt;br /&gt;select 'you may try running this procedure again with a higher number of iterations.' where @unused &gt; 10&lt;br /&gt;union all&lt;br /&gt;select 'Sometimes the log would not shrink to a size smaller than several Megabytes.' where @unused &lt;= 10&lt;br /&gt;&lt;br /&gt;else&lt;br /&gt;select  'It took ' + convert( varchar, @iteration ) +&lt;br /&gt;        ' iterations to shrink the unused portion of the log from ' +&lt;br /&gt;        convert( varchar, @unused1 ) + ' MB to ' +&lt;br /&gt;        convert( varchar, @unused ) + ' MB'&lt;br /&gt;&lt;br /&gt;exec( 'drop table table_to_force_shrink_log' )&lt;br /&gt;go&lt;br /&gt;sp_force_shrink_log&lt;br /&gt;go&lt;br /&gt;drop proc sp_force_shrink_log&lt;br /&gt;go&lt;br /&gt;dbcc loginfo&lt;br /&gt;go&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-6795669230996496212?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/6795669230996496212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/useful-sql-server-scripts-here-are-some.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6795669230996496212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6795669230996496212'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/useful-sql-server-scripts-here-are-some.html' title=''/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-2254572165933330874</id><published>2010-04-16T08:19:00.001-07:00</published><updated>2010-04-16T08:19:40.676-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='interview'/><category scheme='http://www.blogger.com/atom/ns#' term='errors'/><title type='text'>interview questions</title><content type='html'>(Q) What is a Database or Database Management System (DBMS)? &lt;br /&gt;Twist: What is the difference between a file and a database? Can files qualify as a database?&lt;br /&gt;&lt;br /&gt;Note: Probably these questions are too basic for experienced SQL SERVER guys. But from a fresher�s point of view, it can be a difference between getting a job and being jobless. &lt;br /&gt;&lt;br /&gt;1.Database provides a systematic and organized way of storing, managing and retrieving from a collection of logically related information. &lt;br /&gt;2.Secondly, the information has to be persistent, that means even after the application is closed the information should be persisted. &lt;br /&gt;3.Finally, it should provide an independent way of accessing data and should not be dependent on the application to access the information. &lt;br /&gt;Ok, let me spend a few more sentences on explaining the third aspect. Below is a simple figure of a text file that has personal detail information. The first column of the information is Name, second Address and finally Phone Number. This is a simple text file, which was designed by a programmer for a specific application. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.1: Non-Uniform Text File&lt;br /&gt;It works fine in the boundary of the application. Now, some years down the line a third party application has to be integrated with this file. In order for the third party application to be integrated properly, it has the following options:&lt;br /&gt;&lt;br /&gt;•Use the interface of the original application.&lt;br /&gt;•Understand the complete details of how the text file is organized, example the first column is Name, then Address and finally Phone Number. After analyzing, write a code which can read the file, parse it etc. Hmm, lot of work, right.&lt;br /&gt;That�s what the main difference is between a simple file and a database; database has an independent way (SQL) of accessing information while simple files do not (That answers my twisted question defined above). File meets the storing, managing and retrieving part of a database, but not the independent way of accessing data.&lt;br /&gt;&lt;br /&gt;Note: Many experienced programmers think that the main difference is that file cannot provide multi-user capabilities which a DBMS provides. But if you look at some old COBOL and C programs where files were the only means of storing data, you can see functionalities like locking, multi-user etc. provided very efficiently. So it�s a matter of debate. If some interviewers think of this as a main difference between files and database, accept it� going in to debate means probably losing a job.&lt;br /&gt;&lt;br /&gt;(Just a note for fresher�s: Multi-user capabilities mean that at one moment of time more than one user should be able to add, update, view and delete data. All DBMS' provides this as in-built functionalities, but if you are storing information in files, it�s up to the application to write logic to achieve these functionalities).&lt;br /&gt;&lt;br /&gt;(Q) What is the Difference between DBMS and RDBMS?&lt;br /&gt;As mentioned before, DBMS provides a systematic and organized way of storing, managing and retrieving from a collection of logically related information. RDBMS also provides what DBMS provides, but above that, it provides relationship integrity. So in short, we can say:&lt;br /&gt;&lt;br /&gt;RDBMS = DBMS + REFERENTIAL INTEGRITY&lt;br /&gt;&lt;br /&gt;For example, in the above Figure 1.1, every person should have an Address. This is a referential integrity between Name and Address. If we break this referential integrity in DBMS and files, it will not complain, but RDBMS will not allow you to save this data if you have defined the relation integrity between person and addresses. These relations are defined by using �Foreign Keys� in any RDBMS.&lt;br /&gt;&lt;br /&gt;Many DBMS companies claimed that their DBMS product was RDBMS compliant, but according to industry rules and regulations, if the DBMS fulfills the twelve CODD rules, it�s truly a RDBMS. Almost all DBMS (SQL SERVER, ORACLE etc.) fulfill all the twelve CODD rules and are considered truly as RDBMS.&lt;br /&gt;&lt;br /&gt;Note: One of the biggest debates is whether Microsoft Access is an RDBMS? We will be answering this question in later section. &lt;br /&gt;&lt;br /&gt;(DB)What are CODD Rules? &lt;br /&gt;Twist: Does SQL SERVER support all the twelve CODD rules?&lt;br /&gt;&lt;br /&gt;Note: This question can only be asked on two conditions when the interviewer is expecting you to be at a DBA job or you are complete fresher, yes and not to mention the last one he treats CODD rules as a religion. We will try to answer this question from the perspective of SQL SERVER. &lt;br /&gt;&lt;br /&gt;In 1969, Dr. E. F. Codd laid down 12 rules, which a DBMS should adhere to in order to get the logo of a true RDBMS.&lt;br /&gt;&lt;br /&gt;Rule 1: Information Rule&lt;br /&gt;"All information in a relational database is represented explicitly at the logical level and in exactly one way - by values in tables."&lt;br /&gt;&lt;br /&gt;In SQL SERVER, all data exists in tables and are accessed only by querying the tables. &lt;br /&gt;&lt;br /&gt;Rule 2: Guaranteed Access Rule&lt;br /&gt;"Each and every datum (atomic value) in a relational database is guaranteed to be logically accessible by resorting to a combination of table name, primary key value and column name."&lt;br /&gt;&lt;br /&gt;In flat files, we have to parse and know the exact location of field values. But if a DBMS is truly an RDBMS, you can access the value by specifying the table name, field name, for instance Customers.Fields [�Customer Name�].&lt;br /&gt;&lt;br /&gt;SQL SERVER also satisfies this rule. In ADO.NET we can access field information using table name and field names.&lt;br /&gt;&lt;br /&gt;Rule 3: Systematic Treatment of Null Values&lt;br /&gt;"Null values (distinct from the empty character string or a string of blank characters and distinct from zero or any other number) are supported in fully relational DBMS for representing missing information and inapplicable information in a systematic way, independent of data type.� &lt;br /&gt;&lt;br /&gt;In SQL SERVER, if there is no data existing, NULL values are assigned to it. Note NULL values in SQL SERVER do not represent spaces, blanks or a zero value; it is a distinct representation of missing information and thus satisfies rule 3 of CODD.&lt;br /&gt;&lt;br /&gt;Rule 4: Dynamic On-line Catalog Based on the Relational Model&lt;br /&gt;"The database description is represented at the logical level in the same way as ordinary data, so that authorized users can apply the same relational language to its interrogation as they apply to the regular data."&lt;br /&gt;&lt;br /&gt;The Data Dictionary is held within the RDBMS. Thus, there is no need for off-line volumes to tell you the structure of the database.&lt;br /&gt;&lt;br /&gt;Rule 5: Comprehensive Data Sub-language Rule&lt;br /&gt;"A relational system may support several languages and various modes of terminal use (for example, the fill-in-the-blanks mode). However, there must be at least one language whose statements are expressible, per some well-defined syntax, as character strings and that is comprehensive in supporting all the following items: &lt;br /&gt;&lt;br /&gt;•Data Definition &lt;br /&gt;•View Definition &lt;br /&gt;•Data Manipulation (Interactive and by program)&lt;br /&gt;•Integrity Constraints &lt;br /&gt;•Authorization&lt;br /&gt;•Transaction boundaries ( Begin, commit and rollback)"&lt;br /&gt;SQL SERVER uses SQL to query and manipulate data, which has a well-defined syntax and is being accepted as an international standard for RDBMS.&lt;br /&gt;&lt;br /&gt;Note: According to this rule, CODD has only mentioned that some language should be present to support it, but not necessary that it should be SQL. Before the 80�s, different�s database vendors were providing their own flavor of syntax until in 1980, ANSI-SQL came in to standardize this variation between vendors. As ANSI-SQL is quite limited, every vendor including Microsoft introduced their additional SQL syntax in addition to the support of ANSI-SQL. You can see SQL syntax varying from vendor to vendor.&lt;br /&gt;&lt;br /&gt;Rule 6: View-updating Rule&lt;br /&gt;"All views that are theoretically updatable are also updatable by the system."&lt;br /&gt;&lt;br /&gt;In SQL SERVER, not only views can be updated by the user, but also by SQL SERVER itself.&lt;br /&gt;&lt;br /&gt;Rule 7: High-level Insert, Update and Delete&lt;br /&gt;"The capability of handling a base relation or a derived relation as a single operand applies not only to the retrieval of data, but also to the insertion, update and deletion of data."&lt;br /&gt;&lt;br /&gt;SQL SERVER allows you to update views that in turn affect the base tables.&lt;br /&gt;&lt;br /&gt;Rule 8: Physical Data Independence&lt;br /&gt;"Application programs and terminal activities remain logically unimpaired whenever any changes are made in either storage representations or access methods."&lt;br /&gt;&lt;br /&gt;Any application program (C#, VB.NET, VB6, VC++ etc) does not need to be aware of where the SQL SERVER is physically stored or what type of protocol it is using, the database connection string encapsulates everything.&lt;br /&gt;&lt;br /&gt;Rule 9: Logical Data Independence&lt;br /&gt;"Application programs and terminal activities remain logically unimpaired when information-preserving changes of any kind that theoretically permit un-impairment are made to the base tables."&lt;br /&gt;&lt;br /&gt;Application programs written in C# or VB.NET do not need to know about any structure changes in SQL SERVER database. Example: adding of new field etc.&lt;br /&gt;&lt;br /&gt;Rule 10: Integrity Independence&lt;br /&gt;"Integrity constraints specific to a particular relational database must be definable in the relational data sub-language and storable in the catalog, not in the application programs."&lt;br /&gt;&lt;br /&gt;In SQL SERVER, you can specify data types (integer, nvarchar, Boolean etc.) which put in data type checks in SQL SERVER rather than through application programs.&lt;br /&gt;&lt;br /&gt;Rule 11: Distribution Independence&lt;br /&gt;"A relational DBMS has distribution independence."&lt;br /&gt;&lt;br /&gt;SQL SERVER can spread across more than one physical computer and across several networks; but from application programs, it has not a big difference but just specifying the SQL SERVER name and the computer on which it is located.&lt;br /&gt;&lt;br /&gt;Rule 12: Non-subversion Rule&lt;br /&gt;"If a relational system has a low-level (single-record-at-a-time) language, that low level cannot be used to subvert or bypass the integrity Rules and constraints expressed in the higher level relational language (multiple-records-at-a-time)."&lt;br /&gt;&lt;br /&gt;In SQL SERVER whatever integrity rules are applied on every record are also applicable when you process a group of records using application program in any other language (example: C#, VB.NET, J# etc.).&lt;br /&gt;&lt;br /&gt;Readers can see from the above explanation that SQL SERVER satisfies all the CODD rules, some database gurus consider SQL SERVER as not truly being an RDBMS, but that�s a matter of debate.&lt;br /&gt;&lt;br /&gt;(Q) Is Access Database a RDBMS?&lt;br /&gt;Access fulfills all rules of CODD, so from this point of view, yes it�s truly an RDBMS. However, many people can contradict it as a large community of Microsoft professionals think that Access is not an RDBMS.&lt;br /&gt;&lt;br /&gt;(Q) What is the Main Difference between ACCESS and SQL SERVER?&lt;br /&gt;As mentioned before, Access fulfills all the CODD rules and behaves as a true RDBMS. But there�s a huge difference from an architecture perspective, due to which many developers prefer to use SQL SERVER as the major database rather than Access. Following is the list of architecture differences between them:&lt;br /&gt;&lt;br /&gt;•Access uses file server design and SQL SERVER uses the Client / Server model. This forms the major difference between SQL SERVER and ACCESS.&lt;br /&gt;Note: Just to clarify what is client server and file server I will make a quick description of widely accepted architectures. There are three types of architectures:&lt;br /&gt;◦Main frame architecture (This is not related to the above explanation but just mentioned as it can be useful during an interview and also for comparing with other architectures)&lt;br /&gt;◦File sharing architecture (Followed by ACCESS)&lt;br /&gt;◦Client Server architecture (Followed by SQL SERVER).&lt;br /&gt;In Main Frame architecture, all the processing happens on central host server. User interacts through a dumb terminal that only sends keystrokes and information to the host. All the main processing happens on the central host server. So the advantage in such type of architecture is that you need least configuration clients. But the disadvantage is that you need a robust central host server like Main Frames.&lt;br /&gt;&lt;br /&gt;In File sharing architecture, which is followed by Access database, all the data is sent to the client terminal and then processed. For instance, if you want to see customers who stay in India, in File Sharing architecture all customer records will be sent to the client PC regardless whether the customer belongs to India or not. On the client PC customer records from India are sorted/filtered out and displayed, in short all processing logic happens on the client PC. Therefore, in this architecture, the client PC should have heavy configuration and it increases network traffic as a lot of data is sent to the client PC. However, the advantage of this architecture is that your server can be of a low configuration.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.2: File Server Architecture of Access&lt;br /&gt;In client server architecture, the above limitation of the file server architecture is removed. In client server architecture, you have two entities, client and the database server. File server is now replaced by database server. Database server takes up the load of processing any database related activity and the client does any validation aspect of database. As the work is distributed between the entities it increases scalability and reliability. Second, the network traffic also comes down as compared to file server. For example if you are requesting customers from India, database server will sort/ filter and send only Indian customer details to the client, thus bringing down the network traffic tremendously. SQL SERVER follows the client-server architecture.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.3: Client Server Architecture of SQL SERVER&lt;br /&gt;•The second issue comes in terms of reliability. In Access, the client directly interacts with the Access file, in case there is some problem in the middle of a transaction, there are chances that an Access file can get corrupt. But in SQL SERVER, the engine sits in between the client and the database, so in case of any problems in the middle of a transaction, it can revert back to its original state.&lt;br /&gt;Note: SQL SERVER maintains a transaction log by which you can revert back to your original state in case of any crash.&lt;br /&gt;•When your application has to cater to a huge load demand, highly transactional environment and high concurrency, then its better to go for SQL SERVER or MSDE.&lt;br /&gt;•But when it comes to cost and support, Access stands better than SQL SERVER. In case of SQL SERVER, you have to pay for per client license, but Access runtime is free.&lt;br /&gt;Summarizing: SQL SERVER gains points in terms of network traffic, reliability and scalability whereas Access gains points in terms of cost factor.&lt;br /&gt;&lt;br /&gt;(Q) What is the Difference between MSDE and SQL SERVER 2000?&lt;br /&gt;MSDE is a royalty free, redistributable and cut short version of the giant SQL SERVER database. It is primarily provided as a low cost option for developers who need a database server, which can easily be shipped and installed. It can serve as a good alternative for Microsoft Access database as it overcomes quite a few problems which Access has. &lt;br /&gt;&lt;br /&gt;Below is a complete list, which can give you a good idea of the differences:&lt;br /&gt;&lt;br /&gt;•Size of database: Microsoft Access and MSDE have a limitation of 2GB while SQL SERVER has 1,048,516 TB1.&lt;br /&gt;•Performance degrades in MSDE 2000 when maximum number of concurrent operations goes above 8 or is equal to 8. It does not mean that you cannot have more than eight concurrent operations but the performance degrades. Eight-connection performance degradation is implemented by using SQL SERVER 2000 workload governor (we will be looking into more detail of how it works). As compared to SQL SERVER 2000, you can have 32,767 concurrent connections.&lt;br /&gt;•MSDE does not provide OLAP and Data warehousing capabilities.&lt;br /&gt;•MSDE does not have support facility for SQL mail.&lt;br /&gt;•MSDE 2000 does not have GUI administrative tool such as enterprise manager, Query analyzer or Profiler. But there are roundabout ways by which you can manage MSDE 2000:&lt;br /&gt;◦Old command line utility OSQL.EXE&lt;br /&gt;◦VS.NET IDE Server Explorer: Inside VS.NET IDE, you have a functionality which can give you a nice GUI administrative tool to manage IDE.&lt;br /&gt;◦SQL SERVER WEB Data administrator installs a web based GUI which you can use to manage your database. &lt;br /&gt;For any details refer here.&lt;br /&gt;•SQL-DMO objects can be used to build your custom UI&lt;br /&gt;•There are many third party tools, which provide administrative capability GUI, which is out of scope of the book as it is only meant for interview questions. &lt;br /&gt;•MSDE does not support Full text search.&lt;br /&gt;Summarizing: There are two major differences: The first is the size limitation (2 GB) of the database and second is the concurrent connections (eight concurrent connections) which are limited by using the workload governor. During an interview, this answer will suffice if the interviewer is really testing your knowledge.&lt;br /&gt;&lt;br /&gt;(Q) What is SQL SERVER Express 2005 Edition?&lt;br /&gt;Twist: What is the difference between SQL SERVER Express 2005 and MSDE 2000?&lt;br /&gt;&lt;br /&gt;Note: Normally comparison is when the product is migrating from one version to other version. When SQL SERVER 7.0 was migrating to SQL 2000, asking differences was one of the favorite questions. &lt;br /&gt;&lt;br /&gt;SQL SERVER Express edition is a scaled down version of SQL SERVER 2005 and the next evolution of MSDE. &lt;br /&gt;&lt;br /&gt;Listed below are some major differences between them:&lt;br /&gt;&lt;br /&gt;•MSDE maximum database size is 2GB while SQL SERVER Express has around 4GB.&lt;br /&gt;•In terms of programming language support MSDE has only TSQL, but SQLSERVER Express has TSQL and .NET. In SQL SERVER Express 2005, you can write your stored procedures using .NET.&lt;br /&gt;•SQL SERVER Express does not have connection limitation, which MSDE had and was controlled through the workload governor.&lt;br /&gt;•There was no XCOPY support for MSDE, SQL SERVER Express has it.&lt;br /&gt;•DTS is not present in SQL SERVER express while MSDE has it.&lt;br /&gt;•SQL SERVER Express has reporting services while MSDE does not.&lt;br /&gt;•SQL SERVER Express has native XML support and MSDE does not.&lt;br /&gt;Note: Native XML support means now in SQL SERVER 2005:&lt;br /&gt;&lt;br /&gt;•You can create a field with data type XML.&lt;br /&gt;•You can provide SCHEMA to the SQL SERVER fields with XML data type.&lt;br /&gt;•You can use new XML manipulation techniques like XQUERY also called as XML QUERY.&lt;br /&gt;There is a complete chapter on SQL SERVER XML Support, so till then this will suffice.&lt;br /&gt;&lt;br /&gt;Summarizing: The major difference is the database size (2 GB and 4 GB), support of .NET support in stored procedures and native support for XML. This much can convince the interviewer that you are clear about the differences.&lt;br /&gt;&lt;br /&gt;(DB) What is SQL Server 2000 Workload Governor?&lt;br /&gt;Workload governor limits the performance of SQL SERVER Desktop engine (MSDE) if the SQL engine receives more load than what is meant for MSDE. MSDE was always meant for trial purpose and non-critical projects. Microsoft always wanted companies to buy their full blow version of SQL SERVER, so in order that they can put limitation on MSDE performance and number of connections, they introduced Workload governor.&lt;br /&gt;&lt;br /&gt;Workload governor sits between the client and the database engine and counts the number of connections per database instance. If Workload governor finds that the number of connections exceeds eight connections, it starts stalling the connections and slowing down the database engine. &lt;br /&gt;&lt;br /&gt;Note: It does not limit the number of connections but makes the connection request go slow. By default 32,767 connections are allowed both for SQL SERVER and MSDE. But it just makes the database engine go slow above eight connections.&lt;br /&gt;&lt;br /&gt;What is the Difference between SQL SERVER 2000 and 2005?&lt;br /&gt;Twist: What is the difference between Yukon and SQL SERVER 2000? &lt;br /&gt;&lt;br /&gt;Note: This question will be one of the favorites during SQL SERVER interviews. I have marked the points which should be mentioned by developers as PG and DBA for Database Administrator.&lt;br /&gt;&lt;br /&gt;Following are some major differences between the two versions:&lt;br /&gt;&lt;br /&gt;•(PG) The most significant change is the .NET integration with SQL SERVER 2005. Stored procedures, user-defined functions, triggers, aggregates, and user-defined types can now be written using your own favorite .NET language (VB.NET, C#, J# etc.). This support was not there in SQL SERVER 2000 where the only language was T-SQL. In SQL 2005, you have support for two languages T-SQL and .NET.&lt;br /&gt;•(PG) SQL SERVER 2005 has reporting services for reports which is a newly added feature and does not exist for SQL SERVER 2000. It was a separate installation for SQL Server 2000.&lt;br /&gt;•(PG) SQL SERVER 2005 has introduced two new data types varbinary (max) and XML. If you remember in SQL SERVER 2000, we had image and text data types. Problem with image and text data types is that they assign the same amount of storage irrespective of what the actual data size is. This problem is solved using varbinary (max) which acts depending on amount of data. One more new data type is included XML which enables you to store XML documents and does schema verification. In SQL SERVER 2000, developers used varchar or text data type and all validation had to be done programmatically.&lt;br /&gt;•(PG) SQL SERVER 2005 can now process direct incoming HTTP request without IIS Web server. In addition, stored procedure invocation is enabled using the SOAP protocol.&lt;br /&gt;•(PG) Asynchronous mechanism is introduced using server events. In Server event model the server posts an event to the SQL Broker service, later the client can come and retrieve the status by querying the broker.&lt;br /&gt;•For huge databases, SQLSERVER has provided a cool feature called �Data partitioning�. In data partitioning, you break a single database object such as a table or an index into multiple pieces. But for the client application accessing the single database object, �partitioning� is transparent.&lt;br /&gt;•In SQL SERVER 2000, if you rebuilt clustered indexes even the non-clustered indexes where rebuilt. But in SQL SERVER 2005 building the clustered indexes does not build the non-clustered indexes.&lt;br /&gt;•Bulk data uploading in SQL SERVER 2000 was done using BCP (Bulk copy program�s) format files. Now in SQL SERVER 2005 bulk, data uploading uses XML file format.&lt;br /&gt;•In SQL SERVER 2000 there were maximum 16 instances, but in 2005 you can have up to 50 instances.&lt;br /&gt;•SERVER 2005 has support of �Multiple Active Result Sets� also called as �MARS�. In previous versions of SQL SERVER 2000 in one connection, you could only have one result set. Now in one SQL connection, you can query and have multiple results set.&lt;br /&gt;•In previous versions of SQL SERVER 2000, system catalog was stored in the master database. In SQL SERVER 2005, it�s stored in a resource database which is stored as sys object. You cannot access the sys object directly as in the older version we were accessing the master database.&lt;br /&gt;•This is one of the hardware benefits which SQL SERVER 2005 has over SQSERVER 2000 � support of hyper threading. WINDOWS 2003 supports hyper threading; SQL SERVER 2005 can take advantage of the feature unlike SQL SERVER 2000 which did not support hyper threading.&lt;br /&gt;Note: Hyper threading is a technology developed by INTEL which creates two logical processors on a single physical hardware processor.&lt;br /&gt;•SMO will be used for SQL Server Management.&lt;br /&gt;•AMO (Analysis Management Objects) to manage Analysis Services servers, data sources, cubes, dimensions, measures, and data mining models. You can mapm AMO in old SQL SERVER with DSO (Decision Support Objects).&lt;br /&gt;•Replication is now managed by RMO (Replication Management Objects).&lt;br /&gt;Note: SMO, AMO and RMO are all using .NET Framework.&lt;br /&gt;•SQL SERVER 2005 uses current user execution context to check rights rather than ownership link chain, which was done in SQL SERVER 2000.&lt;br /&gt;Note: There is a question on this later see for execution context questions.&lt;br /&gt;•In previous versions of SQL SERVER the schema and the user name was same, but in current, the schema is separated from the user. Now the user owns schema.&lt;br /&gt;Note: There are questions on this, refer �Schema� later.&lt;br /&gt;Note: Ok below are some GUI changes.&lt;br /&gt;•Query analyzer is now replaced by query editor.&lt;br /&gt;•Business Intelligence development studio will be used to create Business intelligence solutions.&lt;br /&gt;•OSQL and ISQL command line utility is replaced by SQLCMD utility.&lt;br /&gt;•SQL SERVER Enterprise manager is now replaced by SQL SERVER Management studio.&lt;br /&gt;•SERVER Manager which was running in system tray is now replaced by SQL Computer manager.&lt;br /&gt;•Database mirror concept is supported in SQL SERVER 2005, which was not present in SQL SERVER 2000.&lt;br /&gt;•In SQL SERVER 2005 Indexes can be rebuilt online when the database is in actual production. If you look back in SQL SERVER 2000, you cannot do insert, update, and delete operations when you are building indexes.&lt;br /&gt;•(PG) Other than Serializable, Repeatable Read, Read Committed, and Read Uncommitted isolation levels, there is one more new isolation level �Snapshot Isolation level�.&lt;br /&gt;Note: We will see �Snapshot Isolation level� in detail in the coming questions.&lt;br /&gt;Summarizing: The major significant difference between SQL SERVER 2000 and SQL SERVER 2005 is in terms of support of .NET Integration, Snap shot isolation level, Native XML support, handling HTTP request, Web service support and Data partitioning. You do not have to really say all the above points during an interview. A sweet summary and you will rock.&lt;br /&gt;&lt;br /&gt;(Q) What are E-R diagrams?&lt;br /&gt;E-R diagram also termed as Entity-Relationship diagram shows the relationship between various tables in the database. Example: Tables Customer and Customer Addresses have a one to many relationship (i.e. one customer can have multiple addresses) this can be shown using the ER diagram. ER diagrams are drawn during the initial stages of a project to forecast how the database structure will shape up. Below is a screen shot of a sample ER diagram of �Asset Management� which ships free with Access.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.4: Asset management ER diagram.&lt;br /&gt;(Q) How many Types of Relationship Exist in Database Designing?&lt;br /&gt;There are three major relationship models:&lt;br /&gt;&lt;br /&gt;•One-to-one &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.5: One-to-One relationship ER diagram&lt;br /&gt;•One-to-many&lt;br /&gt;In this many records in one table correspond to the one record in another table. &lt;br /&gt;Example: Every one customer can have multiple sales. So there exist one-to-many relationships between customer and sales table. &lt;br /&gt;One Asset can have multiple Maintenance. So Asset entity has one-to-many relationship between them as the ER model shows below. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.6: One-to-Many Relationship ER diagram&lt;br /&gt;•Many-to-many&lt;br /&gt;In this, one record in one table corresponds to many rows in another table and also vice-versa. &lt;br /&gt;For instance: In a company, one employee can have many skills like Java , C# etc. and also one skill can belong to many employees. &lt;br /&gt;Given below is a sample of many-to-many relationship. One employee can have knowledge of multiple Technology. So in order to implement this, we have one more table Employee Technology which is linked to the primary key of Employee and Technology table.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.7: Many-to-Many Relationship ER diagram&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-2254572165933330874?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/2254572165933330874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/interview-questions.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/2254572165933330874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/2254572165933330874'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/interview-questions.html' title='interview questions'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-1680309153927676215</id><published>2010-04-16T08:16:00.000-07:00</published><updated>2010-04-16T08:17:28.876-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='What is Normalization'/><title type='text'>What is Normalization</title><content type='html'>(Q) What is Normalization? What are the Different Types of Normalization?&lt;br /&gt;Note: A regular .NET programmer working on projects often stumbles on this question, which is but obvious. The bad part is sometimes the interviewer can take this as a very basic question to be answered and it can be a turning point for the interview. So let's cram it.&lt;br /&gt;&lt;br /&gt;It is set of rules that have been established to aid in the design of tables that are meant to be connected through relationships. This set of rules is known as Normalization.&lt;br /&gt;&lt;br /&gt;Benefits of Normalizing your database include:&lt;br /&gt;&lt;br /&gt;•Avoiding repetitive entries &lt;br /&gt;•Reducing required storage space &lt;br /&gt;•Preventing the need to restructure existing tables to accommodate new data&lt;br /&gt;•Increased speed and flexibility of queries, sorts, and summaries&lt;br /&gt;Note: During an interview, people expect to answer a maximum of three normal forms and that's what is expected practically. Actually you can normalize database to fifth normal form. But believe this book, answering three normal forms will put you in a decent shape during an interview.&lt;br /&gt;&lt;br /&gt;The three normal forms as follows:&lt;br /&gt;&lt;br /&gt;First Normal Form&lt;br /&gt;For a table to be in first normal form, data must be broken up into the smallest units possible. In addition to breaking data up into the smallest meaningful values, tables in first normal form should not contain repetitions groups of fields. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.8: Repeating groups example&lt;br /&gt;In the above example, city1 and city2 are repeating. In order for these tables to be in First normal form, you have to modify the table structure as follows. Also note that the Customer Name is now broken down to first name and last name (First normal form data should be broken down to the smallest unit).&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.9: Customer table normalized to first normal form&lt;br /&gt;Second Normal Form&lt;br /&gt;The second normal form states that each field in a multiple field primary key table must be directly related to the entire primary key. In other words, each non-key field should be a fact about all the fields in the primary key.&lt;br /&gt;&lt;br /&gt;In the above table of customer, city is not linked to any primary field.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.10: Normalized customer table.&lt;br /&gt; &lt;br /&gt;Figure 1.11: City is now shifted to a different master table.&lt;br /&gt;That takes our database to a second normal form.&lt;br /&gt;&lt;br /&gt;Third Normal Form&lt;br /&gt;A non-key field should not depend on another Non-key field. The field Total is dependent on Unit price and qty.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.12: Fill third normal form&lt;br /&gt;So now the Total field is removed and is the multiplication of Unit price * Qty.&lt;br /&gt;&lt;br /&gt;(Q) What is Denormalization? &lt;br /&gt;Denormalization is the process of putting one fact in numerous places (it is vice-versa of normalization). Only one valid reason exists for denormalizing a relational design - to enhance performance. The sacrifice to performance is that you increase redundancy in a database.&lt;br /&gt;&lt;br /&gt;(DB) Can you Explain Fourth Normal Form?&lt;br /&gt;Note: Whenever the interviewer is trying to go above the third normal form, there can be two reasons, ego or to fail you. Three normal forms are really enough, practically anything more than that is an overdose.&lt;br /&gt;&lt;br /&gt;In fourth normal form, it should not contain two or more independent multi-valued facts about an entity and it should satisfy �Third Normal form�. &lt;br /&gt;&lt;br /&gt;So let us try to see what multi-valued facts are. If there are two or more many-to-many relationship in one entity and they tend to come to one place, it is termed as �multi-valued facts�.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.13: Multi-valued facts&lt;br /&gt;In the above table, you can see that there are two many-to-many relationships between Supplier / Product and �Supplier / Location (or in short multi-valued facts). In order for the above example to satisfy the fourth normal form, both the many-to-many relationships should go in different tables.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.14: Normalized to Fourth Normal form.&lt;br /&gt;(DB) Can you Explain Fifth Normal Form?&lt;br /&gt;Note: UUUHHH if you get this question after joining the company, do ask him if he himself really uses it?&lt;br /&gt;&lt;br /&gt;Fifth normal form deals with reconstructing information from smaller pieces of information. These smaller pieces of information can be maintained with less redundancy.&lt;br /&gt;&lt;br /&gt;Example: Dealers sell Product which can be manufactured by various Companies. Dealers in order to sell the Product should be registered with the Company. So these three entities have a mutual relationship within them.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.15: Not in Fifth Normal Form.&lt;br /&gt;The above table shows some sample data. If you observe closely, a single record is created using lot of small information. For instance: JM Associate can sell sweets under the following two conditions:&lt;br /&gt;&lt;br /&gt;•JM Associate should be an authorized dealer of Cadbury&lt;br /&gt;•Sweets should be manufactured by Cadbury company&lt;br /&gt;These two smaller bits of information form one record of the above given table. So in order for the above information to be �Fifth Normal Form� all the smaller information should be in three different places. Below is the complete fifth normal form of the database.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.16: Complete Fifth Normal Form&lt;br /&gt;(DB) What is the Difference between Fourth and Fifth normal form?&lt;br /&gt;Note: There is a huge similarity between Fourth and Fifth normal form, i.e. they address the problem of �Multi-Valued facts�.&lt;br /&gt;&lt;br /&gt;�Fifth normal form� multi-valued facts are interlinked and �Fourth normal form� values are independent. For instance in the above two questions Supplier/Product and Supplier/Location are not linked. While in fifth form, the Dealer/Product/Companies are completely linked.&lt;br /&gt;&lt;br /&gt;(DB) Have you Heard about Sixth Normal Form?&lt;br /&gt;Note: Arrrrggghhh yes there exists a sixth normal form also. But note guys you can skip this statement. Just in case you want to impress the interviewer...&lt;br /&gt;&lt;br /&gt;If you want a relational system in conjunction with time, you use sixth normal form. At this moment SQL Server does not support it directly.&lt;br /&gt;&lt;br /&gt;(Q) What is Extent and Page?&lt;br /&gt;Twist: What is the relationship between Extent and Page?&lt;br /&gt;&lt;br /&gt;Extent is a basic unit of storage to provide space for tables. Every extent has a number of data pages. As new records are inserted new data, pages are allocated. There are eight data pages in an extent. So as soon as the eight pages are consumed, it allocates a new extent with data pages. &lt;br /&gt;&lt;br /&gt;While extent is basic unit storage from a database point of view, page is a unit of allocation within extent.&lt;br /&gt;&lt;br /&gt;(DB) What are the Different Sections in Page?&lt;br /&gt;Page has three important sections: &lt;br /&gt;&lt;br /&gt;•Page header&lt;br /&gt;•Actual data i.e. Data row&lt;br /&gt;•Row pointers or Row offset&lt;br /&gt;Page header has information like timestamp, next page number, previous page number etc. &lt;br /&gt;&lt;br /&gt;Data rows are where your actual row data is stored. For every data row, there is a row offset which points to that data row.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.17: General view of a Extent&lt;br /&gt;(Q) What are Page Splits?&lt;br /&gt;Pages are contained in extent. Every extent will have around eight data pages. But all the eight data pages are not created at once; they are created depending on data demand. So when a page becomes full it creates a new page, this process is called as �Page Split�.&lt;br /&gt;&lt;br /&gt;(Q) In which Files does SQL Server Actually Store Data?&lt;br /&gt;Any SQL Server database is associated with two kinds of files: *.mdf and *.ldf. *.mdf files are actual physical database files where your data is stored finally. *.ldf (LOG) files are actually data, which is recorded from the last time data was committed in the database.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.18: MDF and LDF files.&lt;br /&gt;(Q) What is Collation in SQL Server?&lt;br /&gt;Collation refers to a set of rules that determine how data is sorted and compared. Character data is sorted using rules that define the correct character sequence, with options for specifying case-sensitivity, accent marks, kana character types, and character width.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 1.19: Collation according to language&lt;br /&gt;Note: Different languages will have different sort orders.&lt;br /&gt;&lt;br /&gt;Case Sensitivity&lt;br /&gt;If A and a, B and b, etc. are treated in the same way, then it is case-insensitive. A computer treats A and a differently because it uses ASCII code to differentiate the input. The ASCII value of A is 65, while a is 97. The ASCII value of B is 66 and b is 98.&lt;br /&gt;&lt;br /&gt;Accent Sensitivity&lt;br /&gt;If a and A, o and O are treated in the same way, then it is accent-insensitive. A computer treats a and A differently because it uses ASCII code for differentiating the input. The ASCII value of a is 97 and A 225. The ASCII value of o is 111 and O is 243.&lt;br /&gt;&lt;br /&gt;Kana Sensitivity&lt;br /&gt;When Japanese kana characters Hiragana and Katakana are treated differently, it is called Kana sensitive. &lt;br /&gt;&lt;br /&gt;Width Sensitivity&lt;br /&gt;When a single-byte character (half-width) and the same character when represented as a double-byte character (full-width) are treated differently then it is width sensitive.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-1680309153927676215?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/1680309153927676215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/what-is-normalization.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1680309153927676215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1680309153927676215'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/what-is-normalization.html' title='What is Normalization'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-2535356267054823580</id><published>2010-04-16T06:40:00.000-07:00</published><updated>2010-04-16T06:59:14.764-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xp_sqllitespeed_version'/><category scheme='http://www.blogger.com/atom/ns#' term='errors'/><category scheme='http://www.blogger.com/atom/ns#' term='litespeed'/><title type='text'>Backups vdi and stack dumping</title><content type='html'>When using litespeed version 4.8.3 with sql2005 we found that we recieved the below errors. &lt;br /&gt;&gt;  Title:&lt;br /&gt;&gt;  "State: nn\n.SqlDumpExceptionHandler: Process nn generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process"&lt;br /&gt;&gt;  &lt;br /&gt;&gt;   &lt;br /&gt;&gt;  Problem Description:&lt;br /&gt;&gt;  Backing up transaction logs for multiple databases can result in the generation of a stack dump error with the below logs: &lt;br /&gt;&gt;  &lt;br /&gt;&gt;  - State: 0\015.Stored function 'xp_sqllitespeed_version' in the library 'xpSLS.dll' generated an access violation. SQL Server is terminating process 62. &lt;br /&gt;&gt;  - State: 0\015.SqlDumpExceptionHandler: Process 52 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process. &lt;br /&gt;&gt;  - Job 'DBA - Backup TranLogs - LiteSpeed - ReportServerTempDB' &lt;br /&gt;&gt; (0xBC7DB5449E405941A11F84897255D32E) - Status: Failed - Invoked on: &lt;br /&gt;&gt; 2009-03-16 20:00:04 - Message: The job failed. The Job was invoked by &lt;br /&gt;&gt; Schedule 691&lt;br /&gt;&gt;  - State: 0\015.Stored function 'xp_sqllitespeed_version' in the library 'xpSLS.dll' generated an access violation. SQL Server is terminating process 60. &lt;br /&gt;&gt;  - Job 'DBA - Backup TranLogs - LiteSpeed - UIPState' &lt;br /&gt;&gt; (0x5EBFFF7592D92F479BF9D5613CAEF565) - Status: Failed - Invoked on: &lt;br /&gt;&gt; 2009-03-16 20:00:00 - Message: The job failed. The Job was invoked by &lt;br /&gt;&gt; Schedule 694 (Every 30&lt;br /&gt;&gt;  - State: 0\015.SqlDumpExceptionHandler: Process 60 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process. &lt;br /&gt;&gt;  - Job 'DBA - Backup TranLogs - LiteSpeed - ClientValuationService' &lt;br /&gt;&gt; (0x62F11A3F9A73AC4081B1AD8F5C42EAC8) - Status: Failed - Invoked on: &lt;br /&gt;&gt; 2009-03-16 20:00:01 - Message: The job failed. The Job was invoked by &lt;br /&gt;&gt; Schedule&lt;br /&gt;&gt;  &lt;br /&gt;&gt;  &lt;br /&gt;&gt;  Cause:&lt;br /&gt;&gt;  Insufficient memory as a result of defect in product. &lt;br /&gt;&gt;  See example stats below: &lt;br /&gt;&gt;  &lt;br /&gt;&gt;  Memory&lt;br /&gt;&gt;  MemoryLoad = 68%&lt;br /&gt;&gt;  Total Physical = 3839 MB&lt;br /&gt;&gt;  Available Physical = 1198 MB&lt;br /&gt;&gt;  Total Page File = 7778 MB&lt;br /&gt;&gt;  Available Page File = 4455 MB&lt;br /&gt;&gt;  Total Virtual = 3071 MB&lt;br /&gt;&gt;  Available Virtual = 213 MB&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;in doing some research and lo0king at the stackdump. It looks like we are in the stack when a deallocation goes sideways on heap corruption.&lt;br /&gt;&lt;br /&gt;&lt;snipped&gt;&lt;br /&gt;ntdll!RtlpExecuteHandlerForException+0xd&lt;br /&gt;ntdll!RtlDispatchException+0x1b4&lt;br /&gt;ntdll!KiUserExceptionDispatcher+0x2d&lt;br /&gt;ntdll!DbgBreakPoint&lt;br /&gt;ntdll!RtlpDphReportCorruptedBlock+0x239&lt;br /&gt;ntdll!RtlpDphNormalHeapFree+0x45&lt;br /&gt;ntdll!RtlpDebugPageHeapFree+0x203&lt;br /&gt;ntdll!RtlDebugFreeHeap+0x3b&lt;br /&gt;ntdll!RtlFreeHeapSlowly+0x4e&lt;br /&gt;ntdll!RtlFreeHeap+0x15e&lt;br /&gt;xpSLS+0xc0350&lt;br /&gt;0x7eea8f70&lt;br /&gt;xpSLS+0x149b18&lt;br /&gt;0xffffffff&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Based on the inital exception message,&lt;br /&gt;&lt;br /&gt;Exception happened when running extended stored procedure "xp_sqllitespeed_version" in the library "xpSLS.dll". &lt;br /&gt;SQL Server is terminating process 164. Exception type: Win32 exception; Exception code: 0x80000003.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We know this has to do with LiteSpeed's xpSLS.dll. xpSLS.dll implements LiteSpeed's extended stored procedures, and is loaded into the address space of the SQL Server engine. This is tied to the implementation of our extended stored procedures.&lt;br /&gt;&lt;br /&gt;we suspected this to be a memory corruption.&lt;br /&gt;&lt;br /&gt;and we looked at upgrading to 5.0.1 as we read on quests website tthat there were some bugs in older versions of litespeed.&lt;br /&gt;here is a work around if you see the same issues.&lt;br /&gt;&lt;br /&gt;&gt;  Schedule backups to run in serial instead of in parallel or upgrade to the latest version of Litespeed for sql server. &lt;br /&gt;&gt;  &lt;br /&gt;&gt;  &lt;br /&gt;here's some additional information about the the memory consumption of LiteSpeed, in particular which memory area would it compete (use) on SQL Server.  &lt;br /&gt;&gt;  &lt;br /&gt;&gt;  VDI uses the area set by the SQL Server mem to leave setting. When SQL Server starts up it allocates mem-to-leave amount of memory. It then allocates its buffer pool and a number of other memory allocations needed for the database to run. Then when it is finished allocating all of the memory required at the end of start up it then *releases*/frees the memory it had just allocated for the mem to leave. It does this  in this manner so that it will have a contiguous  mem to leave area separate from the buffer pool and such. One can see this behavior by injecting into sqlservr.exe and detouring malloc and such. THEN as third party apps execute extended stored procedures or connect and use VDI to perform backups, any memory that SQL Server allocates just using normal malloc or AllocateVirtualMemory will come out of that mem-to-leave area. SQL Server native backups do not use VDI and do not allocate extra memory from that area themselves when doing native backups. &lt;br /&gt;&lt;br /&gt;In order to fix these errors, I would suggest to install 5.0.1 or later. to install the package so you dont see this error&lt;br /&gt; State: 0\015.Stored function 'xp_sqllitespeed_version' in the library 'xpSLS.dll' generated an access violation. SQL Server is terminating process &lt;br /&gt;&lt;br /&gt;Reinstalling litespeed&lt;br /&gt;&lt;br /&gt;Phase I: Before upgrade, steps to take.&lt;br /&gt;&lt;br /&gt;a.       Stop all your backup jobs.&lt;br /&gt;&lt;br /&gt;b.      Close out your LiteSpeed console.&lt;br /&gt;&lt;br /&gt;c.       Logon with system administrator privilege to perform the installation.&lt;br /&gt;&lt;br /&gt;d.      Copy LiteSpeed.msi to C or D drive locally.&lt;br /&gt;&lt;br /&gt;e.       Run your installation and press next at the license registration to complete (it will pick up the existing license key)&lt;br /&gt;&lt;br /&gt;f.       If all is good, go to phase IV, else proceed next steps below.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Phase II: In the event, you may get an error like xpSLS.dll or slssqlmaint.exe is being used.&lt;br /&gt;&lt;br /&gt;a.       Go to your SQLServer\binn\ rename name xpSLS.dll to *.old and slssqlmaint.exe *.old&lt;br /&gt;&lt;br /&gt;b.      Try your installation again, if it is still fail with the same error, then try to restart your SQLServer services.&lt;br /&gt;&lt;br /&gt;a.       In the event, it may still lock on the file, reboot the server is the last option (not very likely, but I have seen it, and fyi only.)&lt;br /&gt;&lt;br /&gt;c.       Then, you can run through phase I again.&lt;br /&gt;&lt;br /&gt;d.      If all is good, go to phase IV, else proceed next steps below.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Phase III: Other scenarios for cluster that you may get an error like, fail to create director or access is denied. Perform the step below;&lt;br /&gt;&lt;br /&gt;1. Copy your LiteSpeed.msi to the active node.&lt;br /&gt;&lt;br /&gt;2. Logon with system administrator account equivalent.&lt;br /&gt;&lt;br /&gt;3. Double click to begin the setup.&lt;br /&gt;&lt;br /&gt;4. Get to the screen where it gives you the option to SELECT all instances for the same login and show ACTION (INSTALL) for your instances.&lt;br /&gt;&lt;br /&gt;5. Click the INSTALL | change it to IGNORE for all.&lt;br /&gt;&lt;br /&gt;6. Click next to get to the license registration | select demo for now.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;It should pass the error, if you are still getting the same error, then copy LiteSpeed.msi, and run the setup from your failing node to create the directory. Then, follow the step above from 2 to 6.  Once, it is done with the installation, and you should be able to run the INSTANCE CONFIGURATION to populate the binary files, &lt;br /&gt;&lt;br /&gt;see steps below;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;   a. Select Start | all programs | Quest Software | LiteSpeed | Instance Configuration.&lt;br /&gt;&lt;br /&gt;   b. Leave the INSTALL intact this time.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Phase IV: Confirm your LiteSpeed engine is in place.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;a.       Open a query analyzer | select master | type EXEC XP_SQLLITESPEED_VERSION&lt;br /&gt;&lt;br /&gt;a.       It should return with product and engine match the value for both parameter.&lt;br /&gt;&lt;br /&gt;b.      In the event, it did not match, please restart your SQLServer services.&lt;br /&gt;&lt;br /&gt;b.      Test your backup from a LiteSpeed console against a small database.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-2535356267054823580?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/2535356267054823580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/backups-vdi-and-stack-dumping.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/2535356267054823580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/2535356267054823580'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/backups-vdi-and-stack-dumping.html' title='Backups vdi and stack dumping'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-4690906554911631337</id><published>2010-04-16T06:12:00.000-07:00</published><updated>2010-04-16T06:31:03.379-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cu6'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='cu5 service pack 3'/><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>Spin locks in sql 2005 crashing sql2005</title><content type='html'>how  to resolve spinlocks in 2005 as you can see below this version of sql2005 has service pack 3 and cu5 on it.&lt;br /&gt;I've documented in red what is going on with the system.&lt;br /&gt;0:005&gt; lmv msqlservr&lt;br /&gt;&lt;br /&gt;start end module name&lt;br /&gt;&lt;br /&gt;00000000`01000000 00000000`03662000 sqlservr (deferred)&lt;br /&gt;&lt;br /&gt;Mapped memory image file: D:\SymCache\sqlservr.exe\4A7245F62662000\sqlservr.exe&lt;br /&gt;&lt;br /&gt;Image path: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe&lt;br /&gt;&lt;br /&gt;Image name: sqlservr.exe&lt;br /&gt;&lt;br /&gt;Timestamp: Fri Jul 31 09:16:38 2009 (4A7245F6)&lt;br /&gt;&lt;br /&gt;CheckSum: 025DBEE2&lt;br /&gt;&lt;br /&gt;ImageSize: 02662000&lt;br /&gt;&lt;br /&gt;File version: 2005.90.4230.0&lt;br /&gt;&lt;br /&gt;Product version: 9.0.4230.0&lt;br /&gt;&lt;br /&gt;File flags: 0 (Mask 3F)&lt;br /&gt;&lt;br /&gt;File OS: 40000 NT Base&lt;br /&gt;&lt;br /&gt;File type: 1.0 App&lt;br /&gt;&lt;br /&gt;File date: 00000000.00000000&lt;br /&gt;&lt;br /&gt;Translations: 0409.04e4&lt;br /&gt;&lt;br /&gt;CompanyName: Microsoft Corporation&lt;br /&gt;&lt;br /&gt;ProductName: Microsoft SQL Server&lt;br /&gt;&lt;br /&gt;InternalName: SQLSERVR&lt;br /&gt;&lt;br /&gt;OriginalFilename: SQLSERVR.EXE&lt;br /&gt;&lt;br /&gt;ProductVersion:&lt;span style="color:#ff0000;"&gt; 9.00.4230.00&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;FileVersion: 2005.090.4230.00&lt;br /&gt;&lt;br /&gt;FileDescription: SQL Server Windows NT - 64 Bit&lt;br /&gt;&lt;br /&gt;LegalCopyright: © Microsoft Corp. All rights reserved.&lt;br /&gt;&lt;br /&gt;LegalTrademarks: Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation&lt;br /&gt;&lt;br /&gt;Comments: NT AMD64&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And you have 8 CPUs there installed on the server, while all of them were executing the following:&lt;br /&gt;&lt;br /&gt;SOS_Scheduler:3BA4080 m_id:0 status:VISIBLE ONLINE&lt;br /&gt;&lt;br /&gt;m_pCurrentWorker:9FF61C0 Debug id:147&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# Child-SP RetAddr Call Site&lt;br /&gt;&lt;br /&gt;00 00000000`48c4ba58 00000000`77d705d6 ntdll!ZwDelayExecution+0xa&lt;br /&gt;&lt;br /&gt;01 00000000`48c4ba60 00000000`0193a631 kernel32!SleepEx+0xaf&lt;br /&gt;&lt;br /&gt;02 00000000`48c4bb00 00000000`0168aeb7 sqlservr!SpinlockBase::Sleep+0x1566c1&lt;br /&gt;&lt;br /&gt;03 00000000`48c4bc80 00000000`01dc31c6 sqlservr!SpinlockBase::SpinToAcquire+0x117&lt;br /&gt;&lt;br /&gt;04 00000000`48c4bcd0 00000000`02173ddc sqlservr!TSyncHashTable_EntryAccessor&lt;cqsindexstats,cqsindexident,spinlock&lt;163,1&gt;,0,16,&amp;amp;CQSIndexIdent::UlIndexIdentHash&gt;::TSyncHashTable_EntryAccessor&lt;cqsindexstats,cqsindexident,spinlock&lt;163,1&gt;,0,16,&amp;amp;CQSIndexIdent::UlIndexIdentHash&gt;+0x76&lt;br /&gt;&lt;br /&gt;05 00000000`48c4bd10 00000000`019e2cc9 sqlservr!CQSIndexStatsMgr::AddNewMissingIndex+0x7c&lt;br /&gt;&lt;br /&gt;06 00000000`48c4bda0 00000000`016df878 sqlservr!CIdxSuggestion::Register+0x18a819&lt;br /&gt;&lt;br /&gt;07 00000000`48c4bfb0 00000000`0173b192 sqlservr!COptExpr::PqteConvert+0x1d8&lt;br /&gt;&lt;br /&gt;08 00000000`48c4c040 00000000`016df77d sqlservr!CPhyOp_RestrRemap::PqteConvert+0xc2&lt;br /&gt;&lt;br /&gt;09 00000000`48c4c2b0 00000000`0173ab18 sqlservr!COptExpr::PqteConvert+0xdd&lt;br /&gt;&lt;br /&gt;0a 00000000`48c4c340 00000000`016ef4f7 sqlservr!COptExpr::PqteConvertTree+0x78&lt;br /&gt;&lt;br /&gt;0b 00000000`48c4c4d0 00000000`01712037 sqlservr!COptContext::PcxteOptimizeQuery+0x7c7&lt;br /&gt;&lt;br /&gt;0c 00000000`48c4e880 00000000`0170658d sqlservr!CQuery::Optimize+0x217&lt;br /&gt;&lt;br /&gt;0d 00000000`48c4ea10 00000000`01509e87 sqlservr!CQuery::PqoBuild+0x54d&lt;br /&gt;&lt;br /&gt;0e 00000000`48c4ee50 00000000`014f0c0a sqlservr!CStmtQuery::InitQuery+0x167&lt;br /&gt;&lt;br /&gt;0f 00000000`48c4eef0 00000000`01724abd sqlservr!CStmtSelect::Init+0x8a&lt;br /&gt;&lt;br /&gt;10 00000000`48c4ef80 00000000`0157f15b sqlservr!CCompPlan::FCompileStep+0x3ed&lt;br /&gt;&lt;br /&gt;11 00000000`48c4f040 00000000`014e8af1 sqlservr!CSQLSource::FCompile+0x6eb&lt;br /&gt;&lt;br /&gt;12 00000000`48c4f2d0 00000000`016786f7 sqlservr!CSQLSource::FCompWrapper+0x121&lt;br /&gt;&lt;br /&gt;13 00000000`48c4f390 00000000`01669db2 sqlservr!CSQLSource::Transform+0x377&lt;br /&gt;&lt;br /&gt;14 00000000`48c4f450 00000000`0166ae92 sqlservr!CSQLSource::Execute+0x292&lt;br /&gt;&lt;br /&gt;15 00000000`48c4f5a0 00000000`0166a9ad sqlservr!process_request+0x312&lt;br /&gt;&lt;br /&gt;16 00000000`48c4f830 00000000`0167139e sqlservr!process_commands+0x3fd&lt;br /&gt;&lt;br /&gt;17 00000000`48c4faf0 00000000`01670b89 sqlservr!SOS_Task::Param::Execute+0xee&lt;br /&gt;&lt;br /&gt;18 00000000`48c4fc00 00000000`01676ca4 sqlservr!SOS_Scheduler::RunTask+0xc9&lt;br /&gt;&lt;br /&gt;19 00000000`48c4fc90 00000000`017afcb7 sqlservr!SOS_Scheduler::ProcessTasks+0xb4&lt;br /&gt;&lt;br /&gt;1a 00000000`48c4fd00 00000000`014c5a79 sqlservr!SchedulerManager::WorkerEntryPoint+0xe7&lt;br /&gt;&lt;br /&gt;1b 00000000`48c4fda0 00000000`017b02c0 sqlservr!SystemThread::RunWorker+0x59&lt;br /&gt;&lt;br /&gt;1c 00000000`48c4fde0 00000000`017f9b88 sqlservr!SystemThreadDispatcher::ProcessWorker+0x130&lt;br /&gt;&lt;br /&gt;1d 00000000`48c4fe80 00000000`781337a7 sqlservr!SchedulerManager::ThreadEntryPoint+0x128&lt;br /&gt;&lt;br /&gt;1e 00000000`48c4ff20 00000000`78133864 msvcr80!_callthreadstartex+0x17&lt;br /&gt;&lt;br /&gt;1f 00000000`48c4ff50 00000000`77d6b6da msvcr80!_threadstartex+0x84&lt;br /&gt;&lt;br /&gt;20 00000000`48c4ff80 00000000`00000000 kernel32!BaseThreadStart+0x3a&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;0:270&gt; ub 00000000`0168aeb7&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ffff66;"&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;sqlservr!&lt;strong&gt;SpinlockBase::SpinToAcquire+0xf4:&lt;/strong&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;00000000`0168ae94 e970ffffff jmp sqlservr!SpinlockBase::SpinToAcquire+0x69 (00000000`0168ae09)&lt;br /&gt;&lt;br /&gt;00000000`0168ae99 458bcd mov r9d,r13d&lt;br /&gt;&lt;br /&gt;00000000`0168ae9c 458bc6 mov r8d,r14d&lt;br /&gt;&lt;br /&gt;00000000`0168ae9f 498bd4 mov rdx,r12&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;00000000`0168aea2 488bcf mov rcx,rdi&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;00000000`0168aea5 4889742428 mov qword ptr [rsp+28h],rsi&lt;br /&gt;&lt;br /&gt;00000000`0168aeaa c744242001000000 mov dword ptr [rsp+20h],1&lt;br /&gt;&lt;br /&gt;00000000`0168aeb2 e8b9901500 call sqlservr!SpinlockBase::Sleep (00000000`017e3f70)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;0:147&gt; u sqlservr!SpinlockBase::Sleep&lt;br /&gt;&lt;br /&gt;sqlservr!SpinlockBase::Sleep:&lt;br /&gt;&lt;br /&gt;00000000`017e3f70 4053 push rbx&lt;br /&gt;&lt;br /&gt;00000000`017e3f72 55 push rbp&lt;br /&gt;&lt;br /&gt;00000000`017e3f73 56 push rsi&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;00000000`017e3f74 57 push rdi&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;00000000`017e3f75 4154 push r12&lt;br /&gt;&lt;br /&gt;00000000`017e3f77 4155 push r13&lt;br /&gt;&lt;br /&gt;00000000`017e3f79 4157 push r15&lt;br /&gt;&lt;br /&gt;00000000`017e3f7b 4881ec40010000 sub rsp,140h&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;0:147&gt; dq 00000000`48c4bb00+0x140+8+8+8&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;00000000`48c4bc58 00000000`801c3428 00000000`03ba0508&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;00000000`48c4bc68 00000000`00001e68 00000000`00002710&lt;br /&gt;&lt;br /&gt;00000000`48c4bc78 00000000`0168aeb7 00000000`00000000&lt;br /&gt;&lt;br /&gt;00000000`48c4bc88 00000002`0f7e0a20 00000000`801b82c8&lt;br /&gt;&lt;br /&gt;00000000`48c4bc98 00000000`01c5c471 00000000`00000001&lt;br /&gt;&lt;br /&gt;00000000`48c4bca8 00000000`03ba0508 00000000`0009001f&lt;br /&gt;&lt;br /&gt;00000000`48c4bcb8 00000000`48c4bdd8 00000000`00000001&lt;br /&gt;&lt;br /&gt;00000000`48c4bcc8 00000000`01dc31c6 00000000`801c3418&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So the rdi is on the stack, and we found it to be 00000000`801c3428, and it told us the spin lock was owned by the thread whose id is 7396,&lt;br /&gt;&lt;br /&gt;0:147&gt; ~~[0n7396]s&lt;br /&gt;&lt;br /&gt;ntdll!ZwSignalAndWaitForSingleObject+0xa:&lt;br /&gt;&lt;br /&gt;00000000`77ef1b5a c3 ret&lt;br /&gt;&lt;br /&gt;0:270&gt; kL&lt;br /&gt;&lt;br /&gt;Child-SP RetAddr Call Site&lt;br /&gt;&lt;br /&gt;00000000`5f3bbab8 00000000`77d44ebb ntdll!ZwSignalAndWaitForSingleObject+0xa&lt;br /&gt;&lt;br /&gt;00000000`5f3bbac0 00000000`0165de56 kernel32!SignalObjectAndWait+0x133&lt;br /&gt;&lt;br /&gt;00000000`5f3bbb70 00000000`01662d87 sqlservr!SOS_Scheduler::SwitchContext+0x316&lt;br /&gt;&lt;br /&gt;00000000`5f3bbe60 00000000`0166f5a0 sqlservr!SOS_Scheduler::Suspend+0x97&lt;br /&gt;&lt;br /&gt;00000000`5f3bbea0 00000000`019518a1 sqlservr!SOS_Event::Wait+0x150&lt;br /&gt;&lt;br /&gt;00000000`5f3bbf00 00000000`01673a40 sqlservr!SOS_UnfairMutexPair::LongWait+0x3fef51&lt;br /&gt;&lt;br /&gt;00000000`5f3bbf80 00000000`01676b20 sqlservr!CMemThread::Free+0x4e0&lt;br /&gt;&lt;br /&gt;00000000`5f3bbfe0 00000000`02173e1d sqlservr!commondelete+0x30&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;0000000`5f3bc010 00000000`019e2cc9 sqlservr!&lt;span style="color:#ff0000;"&gt;QSIndexStatsMgr::AddNewMissingIndex+0xbd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;00000000`5f3bc0a0 00000000`016df878 sqlservr!CIdxSuggestion::Register+0x18a819&lt;br /&gt;&lt;br /&gt;00000000`5f3bc2b0 00000000`0173ab18 sqlservr!COptExpr::PqteConvert+0x1d8&lt;br /&gt;&lt;br /&gt;00000000`5f3bc340 00000000`016ef4f7 sqlservr!COptExpr::PqteConvertTree+0x78&lt;br /&gt;&lt;br /&gt;00000000`5f3bc4d0 00000000`01712037 sqlservr!COptContext::PcxteOptimizeQuery+0x7c7&lt;br /&gt;&lt;br /&gt;00000000`5f3be880 00000000`0170658d sqlservr!CQuery::Optimize+0x217&lt;br /&gt;&lt;br /&gt;00000000`5f3bea10 00000000`01509e87 sqlservr!CQuery::PqoBuild+0x54d&lt;br /&gt;&lt;br /&gt;00000000`5f3bee50 00000000`014f0c0a sqlservr!CStmtQuery::InitQuery+0x167&lt;br /&gt;&lt;br /&gt;00000000`5f3beef0 00000000`01724abd sqlservr!CStmtSelect::Init+0x8a&lt;br /&gt;&lt;br /&gt;00000000`5f3bef80 00000000`0157f15b sqlservr!CCompPlan::FCompileStep+0x3ed&lt;br /&gt;&lt;br /&gt;00000000`5f3bf040 00000000`014e8af1 sqlservr!CSQLSource::FCompile+0x6eb&lt;br /&gt;&lt;br /&gt;00000000`5f3bf2d0 00000000`016786f7 sqlservr!CSQLSource::FCompWrapper+0x121&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When the query optimizer of SQL Server 2005 generates a query plan, the query optimizer may wait for a spinlock to be released. The spinlock is used to access internal structure to record information about the missing indexes for the query plan. While the query optimizer is waiting for the spinlock, the query optimizer does not release the scheduler. The query optimizer does not obtain the spinlock and keeps holding the scheduler. All the threads blocked in the spin lock, which cause the SQL Server cannot respond to the CheckServcieAlive request from the Windows cluster, which resulted in the SQL Server resource failure and SQL group failover.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We can see it hit a known issue in this build of SQL Server:&lt;br /&gt;&lt;br /&gt;974205 FIX: Error message in the Errorlog file of SQL Server 2005 or of SQL Server 2008 after the SQL Server service stops responding: "Timeout occurred while waiting for latch"&lt;br /&gt;&lt;br /&gt;http://support.microsoft.com/default.aspx?scid=kb;EN-US;974205&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It was fixed in the SQL Server 2005 SP3 CU6. You can download it from the following URL:&lt;br /&gt;&lt;br /&gt;http://support.microsoft.com/kb/974648/LN/&lt;br /&gt;&lt;br /&gt;If you get this error or similar install the SQL Server 2005 SP3 CU6 at your earliest convenience.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-4690906554911631337?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/4690906554911631337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/spin-locks-in-sql-2005.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4690906554911631337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4690906554911631337'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2010/04/spin-locks-in-sql-2005.html' title='Spin locks in sql 2005 crashing sql2005'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-615576106316365464</id><published>2009-06-07T07:41:00.000-07:00</published><updated>2009-06-07T07:43:05.281-07:00</updated><title type='text'>whos blocking</title><content type='html'>&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-- A quick little standalone script that tells you what process is blocking and what processes the blocking processing actually blocking.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-- When running this script in QA, change your output to "Results in Text" ( CTRL-T ).  Utilizes the blocking info in sp_who2 combined with dbcc inputbuffer and a little cursor to wrap it all up.  Formatting needs a little work, but the info is all there.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set nocount on&lt;/div&gt;&lt;div&gt;declare @spid varchar(10)&lt;/div&gt;&lt;div&gt;declare @blkby varchar(10)&lt;/div&gt;&lt;div&gt;declare @stmt varchar(100)&lt;/div&gt;&lt;div&gt;if not exists ( select top 1 name from tempdb..sysobjects where name like '#temp%' )&lt;/div&gt;&lt;div&gt;begin&lt;/div&gt;&lt;div&gt;   create table #temp ( spid integer, status varchar(100), login varchar(50), hostname varchar(25), blkby varchar(10), &lt;/div&gt;&lt;div&gt;                        dbname varchar(25), command varchar(100), cputime integer, diskio integer, lastbatch varchar(25), &lt;/div&gt;&lt;div&gt;                        programname varchar(255), spid2 integer )&lt;/div&gt;&lt;div&gt;end&lt;/div&gt;&lt;div&gt;else&lt;/div&gt;&lt;div&gt;begin&lt;/div&gt;&lt;div&gt;   truncate table #temp&lt;/div&gt;&lt;div&gt;end&lt;/div&gt;&lt;div&gt;insert into #temp&lt;/div&gt;&lt;div&gt;exec sp_who2&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;declare curs cursor for&lt;/div&gt;&lt;div&gt;select convert(varchar(10),spid), blkby from #temp where blkby not like '%.%'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;open curs&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;fetch next from curs into @spid, @blkby&lt;/div&gt;&lt;div&gt;while @@fetch_status = 0&lt;/div&gt;&lt;div&gt;begin&lt;/div&gt;&lt;div&gt;   set @stmt = 'dbcc inputbuffer(' + @blkby + ')'&lt;/div&gt;&lt;div&gt;   raiserror('SPID:%s is Blocking with the following statement',0,1,@blkby) with nowait&lt;/div&gt;&lt;div&gt;   exec (@stmt)&lt;/div&gt;&lt;div&gt;   raiserror('SPID that is Blocked:%s',0,1,@spid) with nowait&lt;/div&gt;&lt;div&gt;   set @stmt = 'dbcc inputbuffer(' + convert(varchar(10), @spid) + ')'&lt;/div&gt;&lt;div&gt;   exec (@stmt)&lt;/div&gt;&lt;div&gt;   fetch next from curs into @spid, @blkby&lt;/div&gt;&lt;div&gt;end&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;close curs &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;deallocate curs&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-615576106316365464?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/615576106316365464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/06/whos-blocking.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/615576106316365464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/615576106316365464'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/06/whos-blocking.html' title='whos blocking'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-4885381308172662987</id><published>2009-06-07T07:39:00.000-07:00</published><updated>2009-06-07T07:41:54.215-07:00</updated><title type='text'>script out logins for 2000 to 2005 servers</title><content type='html'>&lt;div&gt;USE master &lt;/div&gt;&lt;div&gt;GO &lt;/div&gt;&lt;div&gt;IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL &lt;/div&gt;&lt;div&gt;DROP PROCEDURE sp_hexadecimal &lt;/div&gt;&lt;div&gt;GO &lt;/div&gt;&lt;div&gt;CREATE PROCEDURE sp_hexadecimal &lt;/div&gt;&lt;div&gt;@binvalue varbinary(256), &lt;/div&gt;&lt;div&gt;@hexvalue varchar(256) OUTPUT &lt;/div&gt;&lt;div&gt;AS &lt;/div&gt;&lt;div&gt;DECLARE @charvalue varchar(256) &lt;/div&gt;&lt;div&gt;DECLARE @i int &lt;/div&gt;&lt;div&gt;DECLARE @length int &lt;/div&gt;&lt;div&gt;DECLARE @hexstring char(16) &lt;/div&gt;&lt;div&gt;SELECT @charvalue = '0x' &lt;/div&gt;&lt;div&gt;SELECT @i = 1 &lt;/div&gt;&lt;div&gt;SELECT @length = DATALENGTH (@binvalue) &lt;/div&gt;&lt;div&gt;SELECT @hexstring = '0123456789ABCDEF' &lt;/div&gt;&lt;div&gt;WHILE (@i &lt;= @length) &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;DECLARE @tempint int &lt;/div&gt;&lt;div&gt;DECLARE @firstint int &lt;/div&gt;&lt;div&gt;DECLARE @secondint int &lt;/div&gt;&lt;div&gt;SELECT @tempint = CONVERT(int, SUBSTRING(@binvalue,@i,1)) &lt;/div&gt;&lt;div&gt;SELECT @firstint = FLOOR(@tempint/16) &lt;/div&gt;&lt;div&gt;SELECT @secondint = @tempint - (@firstint*16) &lt;/div&gt;&lt;div&gt;SELECT @charvalue = @charvalue + &lt;/div&gt;&lt;div&gt;SUBSTRING(@hexstring, @firstint+1, 1) + &lt;/div&gt;&lt;div&gt;SUBSTRING(@hexstring, @secondint+1, 1) &lt;/div&gt;&lt;div&gt;SELECT @i = @i + 1 &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;SELECT @hexvalue = @charvalue &lt;/div&gt;&lt;div&gt;GO &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF OBJECT_ID ('sp_help_revlogin_2000_to_2005') IS NOT NULL &lt;/div&gt;&lt;div&gt;DROP PROCEDURE sp_help_revlogin_2000_to_2005 &lt;/div&gt;&lt;div&gt;GO &lt;/div&gt;&lt;div&gt;CREATE PROCEDURE sp_help_revlogin_2000_to_2005 &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;@login_name sysname = NULL, &lt;/div&gt;&lt;div&gt;@include_db bit = 0, &lt;/div&gt;&lt;div&gt;@include_role bit = 0 &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;AS &lt;/div&gt;&lt;div&gt;DECLARE @name sysname &lt;/div&gt;&lt;div&gt;DECLARE @xstatus int &lt;/div&gt;&lt;div&gt;DECLARE @binpwd varbinary (256) &lt;/div&gt;&lt;div&gt;DECLARE @dfltdb varchar (256) &lt;/div&gt;&lt;div&gt;DECLARE @txtpwd sysname &lt;/div&gt;&lt;div&gt;DECLARE @tmpstr varchar (256) &lt;/div&gt;&lt;div&gt;DECLARE @SID_varbinary varbinary(85) &lt;/div&gt;&lt;div&gt;DECLARE @SID_string varchar(256) &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF (@login_name IS NULL) &lt;/div&gt;&lt;div&gt;DECLARE login_curs CURSOR STATIC FOR &lt;/div&gt;&lt;div&gt;SELECT sid, [name], xstatus, password, isnull(db_name(dbid), 'master') &lt;/div&gt;&lt;div&gt;FROM master.dbo.sysxlogins &lt;/div&gt;&lt;div&gt;WHERE srvid IS NULL AND &lt;/div&gt;&lt;div&gt;[name] &lt;&gt; 'sa' &lt;/div&gt;&lt;div&gt;ELSE &lt;/div&gt;&lt;div&gt;DECLARE login_curs CURSOR FOR &lt;/div&gt;&lt;div&gt;SELECT sid, [name], xstatus, password, isnull(db_name(dbid), 'master') &lt;/div&gt;&lt;div&gt;FROM master.dbo.sysxlogins &lt;/div&gt;&lt;div&gt;WHERE srvid IS NULL AND &lt;/div&gt;&lt;div&gt;[name] = @login_name &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;OPEN login_curs &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF (@@fetch_status = -1) &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;PRINT 'No login(s) found.' &lt;/div&gt;&lt;div&gt;CLOSE login_curs &lt;/div&gt;&lt;div&gt;DEALLOCATE login_curs &lt;/div&gt;&lt;div&gt;RETURN -1 &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SET @tmpstr = '/* sp_help_revlogin script ' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;SET @tmpstr = '** Generated ' &lt;/div&gt;&lt;div&gt;+ CONVERT (varchar, GETDATE()) + ' on ' + @@SERVERNAME + ' */' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '/***** CREATE LOGINS *****/' &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;WHILE @@fetch_status = 0 &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;SET @tmpstr = '-- Login: ' + @name &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF (@xstatus &amp;amp; 4) = 4 &lt;/div&gt;&lt;div&gt;BEGIN -- NT authenticated account/group &lt;/div&gt;&lt;div&gt;IF (@xstatus &amp;amp; 1) = 1 &lt;/div&gt;&lt;div&gt;BEGIN -- NT login is denied access &lt;/div&gt;&lt;div&gt;SET @tmpstr = '' --'EXEC master..sp_denylogin ''' + @name + '''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;ELSE &lt;/div&gt;&lt;div&gt;BEGIN -- NT login has access &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE [name] = ''' + @name + ''')' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;SET @tmpstr = CHAR(9) + 'CREATE LOGIN [' + @name + '] FROM WINDOWS' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;ELSE &lt;/div&gt;&lt;div&gt;BEGIN -- SQL Server authentication &lt;/div&gt;&lt;div&gt;EXEC sp_hexadecimal @SID_varbinary, @SID_string OUT &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF (@binpwd IS NOT NULL) &lt;/div&gt;&lt;div&gt;BEGIN -- Non-null password &lt;/div&gt;&lt;div&gt;EXEC sp_hexadecimal @binpwd, @txtpwd OUT &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'CREATE LOGIN [' + @name + '] WITH PASSWORD=' + @txtpwd + ' HASHED' &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;ELSE &lt;/div&gt;&lt;div&gt;BEGIN -- Null password &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'CREATE LOGIN [' + @name + '] WITH PASSWORD=''''' &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SET @tmpstr = @tmpstr + ', CHECK_POLICY=OFF, SID=' + @SID_string &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @include_db = 1 &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '/***** SET DEFAULT DATABASES *****/' &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;FETCH FIRST FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;WHILE @@fetch_status = 0 &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;SET @tmpstr = '-- Login: ' + @name &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SET @tmpstr = 'ALTER LOGIN [' + @name + '] WITH DEFAULT_DATABASE=[' + @dfltdb + ']' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @include_role = 1 &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;PRINT '/***** SET SERVER ROLES *****/' &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;FETCH FIRST FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;WHILE @@fetch_status = 0 &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;PRINT '' &lt;/div&gt;&lt;div&gt;SET @tmpstr = '-- Login: ' + @name &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @xstatus &amp;amp;16 = 16 -- sysadmin &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''sysadmin''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @xstatus &amp;amp;32 = 32 -- securityadmin &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''securityadmin''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @xstatus &amp;amp;64 = 64 -- serveradmin &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''serveradmin''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @xstatus &amp;amp;128 = 128 -- setupadmin &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''setupadmin''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @xstatus &amp;amp;256 = 256 --processadmin &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''processadmin''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @xstatus &amp;amp;512 = 512 -- diskadmin &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''diskadmin''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @xstatus &amp;amp;1024 = 1024 -- dbcreator &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''dbcreator''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;IF @xstatus &amp;amp;4096 = 4096 -- bulkadmin &lt;/div&gt;&lt;div&gt;BEGIN &lt;/div&gt;&lt;div&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''bulkadmin''' &lt;/div&gt;&lt;div&gt;PRINT @tmpstr &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;END &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;CLOSE login_curs &lt;/div&gt;&lt;div&gt;DEALLOCATE login_curs &lt;/div&gt;&lt;div&gt;RETURN 0 &lt;/div&gt;&lt;div&gt;GO&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;exec sp_help_revlogin_2000_to_2005 @login_name=NULL, @include_db=1, @include_role=1&lt;/div&gt;&lt;div&gt;GO&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-4885381308172662987?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/4885381308172662987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/06/script-out-logins-for-2000-to-2005.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4885381308172662987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4885381308172662987'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/06/script-out-logins-for-2000-to-2005.html' title='script out logins for 2000 to 2005 servers'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-6917760533984315447</id><published>2009-06-07T07:38:00.000-07:00</published><updated>2009-06-07T07:39:03.704-07:00</updated><title type='text'>Reading a SQL Profiler Trace file</title><content type='html'>&lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%;mso-outline-level:3"&gt;&lt;b&gt;&lt;span style="font-size:14.0pt; line-height:140%;font-family:Calibri;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;; mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;;color:#393594;letter-spacing:.1pt"&gt;Reading a SQL Profiler Trace file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;In SQL Profiler you can open data from a file or a table with File -&gt; Open menu option. If you have your data in multiple rolled over files SQL profiler will ask you if you'd like to open the next file after it reaches the end of the current file. You can also replay your trace using the Replay menu in which you can even set breakpoints.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;Personally I like to analyze my trace files with SQL. To do that you have to have the data in a trace table. If you have a file you should import that file into the table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;The only way to do that is by using the &lt;/span&gt;&lt;span style="font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;;letter-spacing: .1pt"&gt;fn_trace_gettable&lt;/span&gt;&lt;span style="font-size:9.0pt;line-height:140%; font-family:Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family: &amp;quot;MS PGothic&amp;quot;;letter-spacing:.1pt"&gt; built-in table valued function:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="mso-element:para-border-div;border:dotted windowtext 1.0pt; mso-border-alt:dotted windowtext .75pt;padding:8.0pt 8.0pt 8.0pt 8.0pt; background:#F7F7E6"&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;select&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; * &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;from&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; fn_trace_gettable(&lt;span style="color:red"&gt;'c:\MyTraceFile.trc'&lt;/span&gt;, &lt;span style="color:blue"&gt;default&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;b&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;The first parameter is obviously the path to the trace file on the server's disk. The second parameter is the number of rolled over files to be read. The default value is -1 which means all files are read.&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family:Verdana;mso-fareast-font-family: &amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;;letter-spacing:.1pt"&gt; If you want to read just one of many rolled over files use 1 as your parameter value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;Although you could use the function to read the trace file each time, the better way is to simply import the trace into a table and query the table itself since reading the file each time is slow. A simple way to do this is:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="mso-element:para-border-div;border:dotted windowtext 1.0pt; mso-border-alt:dotted windowtext .75pt;padding:8.0pt 8.0pt 8.0pt 8.0pt; background:#F7F7E6"&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;select&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; &lt;span style="color:blue"&gt;IDENTITY&lt;/span&gt;(BIGINT, 1, 1) &lt;span style="color:blue"&gt;AS&lt;/span&gt; RowNumber, * &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;into&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; MyTraceTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;from&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; fn_trace_gettable(&lt;span style="color:red"&gt;'c:\MyTraceFile.trc'&lt;/span&gt;, &lt;span style="color:blue"&gt;default&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;where&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; 1 = 0 &lt;span style="color:green"&gt;-- just create the table without any data&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;After you have the table definition you can index it to your liking and then simply use insert to populate the table:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="mso-element:para-border-div;border:dotted windowtext 1.0pt; mso-border-alt:dotted windowtext .75pt;padding:8.0pt 8.0pt 8.0pt 8.0pt; background:#F7F7E6"&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;insert&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; &lt;span style="color:blue"&gt;into&lt;/span&gt; MyTraceTable(&lt;columnstoinsertinto&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;select&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; &lt;columnstoinsert&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:140%;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; background:#F7F7E6;border:none;mso-border-alt:dotted windowtext .75pt; padding:0in;mso-padding-alt:8.0pt 8.0pt 8.0pt 8.0pt"&gt;&lt;span style="font-family: &amp;quot;Lucida Console&amp;quot;;mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; color:blue;letter-spacing:.1pt"&gt;from&lt;/span&gt;&lt;span style="font-family:&amp;quot;Lucida Console&amp;quot;; mso-fareast-font-family:&amp;quot;MS Gothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS Gothic&amp;quot;; letter-spacing:.1pt"&gt; fn_trace_gettable(&lt;span style="color:red"&gt;'c:\MyTraceFile.trc'&lt;/span&gt;, &lt;span style="color:blue"&gt;default&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%;mso-outline-level:3"&gt;&lt;b&gt;&lt;span style="font-size:14.0pt; line-height:140%;font-family:Calibri;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;; mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;;color:#393594;letter-spacing:.1pt"&gt;Combining SQL Profiler Trace file and PerfMon log file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;Start SQL Profiler and open a trace file in it. The SQL Trace file and the PerfMon log file must be time synchronized. So either you have to be gathered on the same machine or the 2 machines have to be time synchronized. Wait until the SQL Trace file is fully loaded. Then go to File -&gt; Import Performance Data...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;Choose the PerfMon log file (.BLG, .CSV) that correlates with the SQL trace file. A dialog will open asking you to select the counters you'd like to display. Click OK and you should get a screen looking similar to this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;  &lt;v:stroke joinstyle="miter"&gt;  &lt;v:formulas&gt;   &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;   &lt;v:f eqn="sum @0 1 0"&gt;   &lt;v:f eqn="sum 0 0 @1"&gt;   &lt;v:f eqn="prod @2 1 2"&gt;   &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;   &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @0 0 1"&gt;   &lt;v:f eqn="prod @6 1 2"&gt;   &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;   &lt;v:f eqn="sum @8 21600 0"&gt;   &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @10 21600 0"&gt;  &lt;/v:formulas&gt;  &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;  &lt;o:lock ext="edit" aspectratio="t"&gt; &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" alt="Combine SQL Profiler Trace file and PerfMon counters log file" style="'width:453pt;height:260.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\jagot\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" href="http://www.sqlteam.com/itemimages/26988_4.gif"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;img width="604" height="347" src="file:///C:/DOCUME~1/jagot/LOCALS~1/Temp/msohtml1/01/clip_image001.gif" alt="Combine SQL Profiler Trace file and PerfMon counters log file" shapes="_x0000_i1025" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;i&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;Picture 4: Combine SQL Profiler Trace file and PerfMon counters log file&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size:9.0pt;line-height:140%; font-family:Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family: &amp;quot;MS PGothic&amp;quot;;letter-spacing:.1pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:140%"&gt;&lt;span style="font-size:9.0pt;line-height:140%;font-family: Verdana;mso-fareast-font-family:&amp;quot;MS PGothic&amp;quot;;mso-bidi-font-family:&amp;quot;MS PGothic&amp;quot;; letter-spacing:.1pt"&gt;By clicking on the PerfMon graph you can see that the selected row in your trace changes. The PerfMon counter has the minimum polling interval of 1 second so you will get more than one sql event per PerfMon counter and the selected row in the trace is the row that best corresponds with the PerfMon counter at that time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-6917760533984315447?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/6917760533984315447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/06/reading-sql-profiler-trace-file.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6917760533984315447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6917760533984315447'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/06/reading-sql-profiler-trace-file.html' title='Reading a SQL Profiler Trace file'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-7690208274260228439</id><published>2009-06-07T07:37:00.000-07:00</published><updated>2009-06-07T07:38:03.007-07:00</updated><title type='text'>Shrink a named transaction log file belonging to a database</title><content type='html'>&lt;div&gt;/*&lt;/div&gt;&lt;div&gt;Shrink a named transaction log file belonging to a database&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Originally found at;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;http://support.microsoft.com/support/kb/articles/q256/6/50.asp&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Changes:&lt;/div&gt;&lt;div&gt;28.08.2001&lt;/div&gt;&lt;div&gt;Modified the inner loop so it tested the dx time so long overruns did not happen&lt;/div&gt;&lt;div&gt;Modified the inner loop so it had a fixed minimum quantity so there was no skip in skip out&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;29.08.2001&lt;/div&gt;&lt;div&gt;Modified the inner loop so it had a dynamic minimum quantity to allow faster shrinkage&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;24.01.2002&lt;/div&gt;&lt;div&gt;Modified the USE statement so it uses brackets around the dbname&lt;/div&gt;&lt;div&gt;Modified the @TruncLog variable so it uses brackets around the dbname&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;31.05.2002&lt;/div&gt;&lt;div&gt;Modified the code to use PRINT instead of SELECT in several cases&lt;/div&gt;&lt;div&gt;Modified the code to use @MaxCount instead of two unclear rules &lt;/div&gt;&lt;div&gt;Modified the code to use @Factor instead of several hard-coded values &lt;/div&gt;&lt;div&gt;Commented the use of @Factor&lt;/div&gt;&lt;div&gt;Moved the configuration and @Counter init code to before the start of the first loop to avoid repetition&lt;/div&gt;&lt;div&gt;Modified the code to display the process runtime in seconds rather than minutes&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;*/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SET NOCOUNT ON&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;DECLARE @LogicalFileName SYSNAME,&lt;/div&gt;&lt;div&gt;        @MaxMinutes INT,&lt;/div&gt;&lt;div&gt;        @NewSize INT,&lt;/div&gt;&lt;div&gt;        @Factor FLOAT&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/*&lt;/div&gt;&lt;div&gt;  The process has several control parameters, most of the time you only need to worry about the first four&lt;/div&gt;&lt;div&gt;    as these are the big controls whereas the fifth is simply a fine tuning control which rarely needs to &lt;/div&gt;&lt;div&gt;    come into play.&lt;/div&gt;&lt;div&gt;*/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;--This is the name of the database for which the log will be shrunk.&lt;/div&gt;&lt;div&gt;USE [Speqs]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;--Use sp_helpfile to identify the logical file name that you want to shrink.&lt;/div&gt;&lt;div&gt;SET @LogicalFileName = 'Speqs_Log';&lt;/div&gt;&lt;div&gt;--Limit on time allowed to wrap log in minutes&lt;/div&gt;&lt;div&gt;SET @MaxMinutes = 5;&lt;/div&gt;&lt;div&gt;--Ideal size of logfile in MB&lt;/div&gt;&lt;div&gt;SET @NewSize =100;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/*&lt;/div&gt;&lt;div&gt;  Factor determining maximum number of pages to pad out based on the original number of pages in use &lt;/div&gt;&lt;div&gt;    (single page = 8K).  Values in the range 1.0 - 0.8 seems to work well for many databases.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  Increasing the number will increase the maximum number of pages allowed to be padded, which should&lt;/div&gt;&lt;div&gt;    force larger amounts of data to be dropped before the process finishes.  Often speeds up shrinking&lt;/div&gt;&lt;div&gt;    very large databases which are going through the process before the timer runs out.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  Decreasing the number will decrease the maximum number of pages allowed to be padded, which should&lt;/div&gt;&lt;div&gt;    force less work to be done.  Often aids with forcing smaller databases to shrink to minimum size&lt;/div&gt;&lt;div&gt;    when larger values were actually expanding them.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;*/&lt;/div&gt;&lt;div&gt;SET @Factor = 1.0;                        &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/*&lt;/div&gt;&lt;div&gt;  All code after this point is driven by these parameters and will not require editing unless you need to &lt;/div&gt;&lt;div&gt;    fix a bug in the padding/shrinking process itself.&lt;/div&gt;&lt;div&gt;*/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-- Setup / initialize&lt;/div&gt;&lt;div&gt;DECLARE @OriginalSize INT,&lt;/div&gt;&lt;div&gt;        @StringData VARCHAR(500)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SELECT @OriginalSize = size -- in 8K pages&lt;/div&gt;&lt;div&gt;FROM sysfiles&lt;/div&gt;&lt;div&gt;WHERE name = @LogicalFileName;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SELECT @StringData = 'Original Size of ' + db_name() + ' LOG is ' + &lt;/div&gt;&lt;div&gt;    CONVERT(VARCHAR(30),@OriginalSize) + ' 8K pages or ' + &lt;/div&gt;&lt;div&gt;    CONVERT(VARCHAR(30),(@OriginalSize*8/1024)) + 'MB'&lt;/div&gt;&lt;div&gt;FROM sysfiles&lt;/div&gt;&lt;div&gt;WHERE name = @LogicalFileName;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;PRINT @StringData;&lt;/div&gt;&lt;div&gt;PRINT ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;--Drop the temporary table if it already exists&lt;/div&gt;&lt;div&gt;IF ( OBJECT_ID('[dbo].[DummyTrans]') IS NOT NULL )&lt;/div&gt;&lt;div&gt;  DROP TABLE [DummyTrans]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;CREATE TABLE [DummyTrans]( [DummyColumn] CHAR(8000) NOT NULL );&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-- Wrap log and truncate it.&lt;/div&gt;&lt;div&gt;DECLARE @Counter   INT,&lt;/div&gt;&lt;div&gt;        @MaxCount  INT,&lt;/div&gt;&lt;div&gt;        @StartTime DATETIME,&lt;/div&gt;&lt;div&gt;        @TruncLog  VARCHAR(500)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-- Try an initial shrink.&lt;/div&gt;&lt;div&gt;DBCC SHRINKFILE (@LogicalFileName, @NewSize)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SET @TruncLog = 'BACKUP LOG [' + db_name() + '] WITH TRUNCATE_ONLY';&lt;/div&gt;&lt;div&gt;EXEC (@TruncLog)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-- Configure limiter&lt;/div&gt;&lt;div&gt;IF @OriginalSize / @Factor &gt; 50000&lt;/div&gt;&lt;div&gt;    SET @MaxCount = 50000&lt;/div&gt;&lt;div&gt;ELSE&lt;/div&gt;&lt;div&gt;    SET @MaxCount = @OriginalSize * @Factor&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-- Attempt to shrink down the log file&lt;/div&gt;&lt;div&gt;PRINT 'Minimum Quantity : '+CAST( @MaxCount AS VARCHAR(10) )&lt;/div&gt;&lt;div&gt;PRINT 'Maximum Time : '+CAST( @MaxMinutes AS VARCHAR(10) )+' minutes ('+CAST( @MaxMinutes*60 AS VARCHAR(10) )+' seconds)'&lt;/div&gt;&lt;div&gt;PRINT ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SET @Counter = 0;&lt;/div&gt;&lt;div&gt;SET @StartTime = GETDATE();&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;--loop the padding code to reduce the log while&lt;/div&gt;&lt;div&gt;-- within time limit and &lt;/div&gt;&lt;div&gt;-- log has not been shrunk enough&lt;/div&gt;&lt;div&gt;WHILE (&lt;/div&gt;&lt;div&gt;    (@MaxMinutes*60 &gt; DATEDIFF(ss, @StartTime, GETDATE())) AND&lt;/div&gt;&lt;div&gt;    (@OriginalSize = (SELECT size FROM sysfiles WHERE name = @LogicalFileName)) AND&lt;/div&gt;&lt;div&gt;    ((@OriginalSize * 8 / 1024) &gt; @NewSize)&lt;/div&gt;&lt;div&gt;)&lt;/div&gt;&lt;div&gt;BEGIN --Outer loop.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    --pad out the logfile a page at a time while&lt;/div&gt;&lt;div&gt;    -- number of pages padded does not exceed our maximum page padding limit&lt;/div&gt;&lt;div&gt;    -- within time limit and &lt;/div&gt;&lt;div&gt;    -- log has not been shrunk enough&lt;/div&gt;&lt;div&gt;    WHILE (&lt;/div&gt;&lt;div&gt;        (@Counter &lt; @MaxCount) AND &lt;/div&gt;&lt;div&gt;        (@MaxMinutes*60 &gt; DATEDIFF(ss, @StartTime, GETDATE())) AND&lt;/div&gt;&lt;div&gt;        (@OriginalSize = (SELECT size FROM sysfiles WHERE name = @LogicalFileName)) AND&lt;/div&gt;&lt;div&gt;        ((@OriginalSize * 8 / 1024) &gt; @NewSize)&lt;/div&gt;&lt;div&gt;    )&lt;/div&gt;&lt;div&gt;    BEGIN --Inner loop&lt;/div&gt;&lt;div&gt;        &lt;/div&gt;&lt;div&gt;        INSERT INTO DummyTrans VALUES ('Fill Log')  -- Because it is a char field it inserts 8000 bytes.&lt;/div&gt;&lt;div&gt;        DELETE FROM DummyTrans&lt;/div&gt;&lt;div&gt;        SELECT @Counter = @Counter + 1&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        --Every 1,000 cycles tell the user what is going on&lt;/div&gt;&lt;div&gt;        IF ROUND( @Counter , -3 ) = @Counter&lt;/div&gt;&lt;div&gt;        BEGIN&lt;/div&gt;&lt;div&gt;            PRINT 'Padded '+LTRIM( CAST( @Counter*8 AS VARCHAR(10) ) )+'K @ '+LTRIM( CAST( DATEDIFF( ss, @StartTime, GETDATE() ) AS VARCHAR(10) ) )+' seconds';&lt;/div&gt;&lt;div&gt;        END&lt;/div&gt;&lt;div&gt;    END&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    --See if a trunc of the log shrinks it.&lt;/div&gt;&lt;div&gt;    EXEC( @TruncLog )&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;END&lt;/div&gt;&lt;div&gt;PRINT ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SELECT @StringData = 'Final Size of ' + db_name() + ' LOG is ' +&lt;/div&gt;&lt;div&gt;   CONVERT(VARCHAR(30),size) + ' 8K pages or ' + &lt;/div&gt;&lt;div&gt;   CONVERT(VARCHAR(30),(size*8/1024)) + 'MB'&lt;/div&gt;&lt;div&gt;FROM sysfiles &lt;/div&gt;&lt;div&gt;WHERE name = @LogicalFileName;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;PRINT @StringData&lt;/div&gt;&lt;div&gt;PRINT ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;DROP TABLE DummyTrans;&lt;/div&gt;&lt;div&gt;PRINT '*** Perform a full database backup ***'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SET NOCOUNT OFF&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-7690208274260228439?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/7690208274260228439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/06/shrink-named-transaction-log-file.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7690208274260228439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7690208274260228439'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/06/shrink-named-transaction-log-file.html' title='Shrink a named transaction log file belonging to a database'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-6621451786069833622</id><published>2009-01-27T22:29:00.000-08:00</published><updated>2009-02-16T05:06:50.080-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Install'/><category scheme='http://www.blogger.com/atom/ns#' term='litespeed'/><category scheme='http://www.blogger.com/atom/ns#' term='xp_restore_database'/><title type='text'>Tools for helping to backup databases</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;I find litespeed the best backup too by far for mssql products, Why might you ask do I need a backup tool when mssql has sqlbackup built in. Well the main reason is that mssql backup until now did not have a compression tool 2008 now does. However, if you are on sql2005 or below then I would recommend litespeed.&lt;br /&gt;&lt;br /&gt;here is how to install litespeed and a small guide to using it to back up.&lt;br /&gt;&lt;br /&gt;SQL Lite Speed Installation Guide&lt;br /&gt;&lt;br /&gt;Installation Steps&lt;br /&gt;&lt;br /&gt;1. Put in the CD brows the cd&lt;br /&gt;2. Launch the install by double clicking on the file litespeedforsqlserver32bit_45000157_1.msi&lt;br /&gt;&lt;br /&gt;The screen below will be shown once the installer starts&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/__zFxCqPcmaI/SX_-cNAkhFI/AAAAAAAAADs/LLmCKF0rHPE/s1600-h/firstscreen.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296231447292838994" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://2.bp.blogspot.com/__zFxCqPcmaI/SX_-cNAkhFI/AAAAAAAAADs/LLmCKF0rHPE/s320/firstscreen.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Choose Next&gt; to move to the next screen&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/__zFxCqPcmaI/SX__w2K4hzI/AAAAAAAAAD0/U9OZrg5p9_8/s1600-h/secondscreen.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296232901450958642" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://1.bp.blogspot.com/__zFxCqPcmaI/SX__w2K4hzI/AAAAAAAAAD0/U9OZrg5p9_8/s320/secondscreen.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Choose Next&gt; to move to the next screen&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Accept the License Agreement and choose Next&gt; to move to the next screen&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Enter the User Name and Organization as above. This is the default and should already be filled in. Ensure the application is installed for anyone who uses the computer and choose Next &gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/__zFxCqPcmaI/SX__9EhYtXI/AAAAAAAAAD8/NwxXQGNrZog/s1600-h/thirdscreen.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296233111461868914" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://2.bp.blogspot.com/__zFxCqPcmaI/SX__9EhYtXI/AAAAAAAAAD8/NwxXQGNrZog/s320/thirdscreen.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/__zFxCqPcmaI/SYAADjCTXbI/AAAAAAAAAEE/R3w0WhwKE60/s1600-h/4th+screen.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296233222732209586" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://4.bp.blogspot.com/__zFxCqPcmaI/SYAADjCTXbI/AAAAAAAAAEE/R3w0WhwKE60/s320/4th+screen.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The default destination folder will be on the C: drive. This needs to be changed to reside on the E: drive.&lt;br /&gt;Choose the Change… button&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/__zFxCqPcmaI/SYAA2IM_WpI/AAAAAAAAAEU/tBCk4mDYj0A/s1600-h/5th.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296234091702606482" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://2.bp.blogspot.com/__zFxCqPcmaI/SYAA2IM_WpI/AAAAAAAAAEU/tBCk4mDYj0A/s320/5th.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Enter the folder name as E:\Imceda\LiteSpeed\SQL Server\ and click OK&lt;br /&gt;&lt;br /&gt;If the destination folder is defined correctly choose Next &gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/__zFxCqPcmaI/SYAAPb-c5bI/AAAAAAAAAEM/e2jtqn--pt8/s1600-h/5th.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296233426995439026" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://4.bp.blogspot.com/__zFxCqPcmaI/SYAAPb-c5bI/AAAAAAAAAEM/e2jtqn--pt8/s320/5th.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Select Complete setup and choose Next &gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/__zFxCqPcmaI/SYAA2KRzLrI/AAAAAAAAAEc/XkeQ99-jc-I/s1600-h/6th.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296234092259651250" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://2.bp.blogspot.com/__zFxCqPcmaI/SYAA2KRzLrI/AAAAAAAAAEc/XkeQ99-jc-I/s320/6th.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Click the Install button to begin the installation&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Choose Next &gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/__zFxCqPcmaI/SYAA2q8artI/AAAAAAAAAEk/BHouLQoQvo0/s1600-h/7th.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296234101028335314" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://3.bp.blogspot.com/__zFxCqPcmaI/SYAA2q8artI/AAAAAAAAAEk/BHouLQoQvo0/s320/7th.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Select the “Use Same login details for all instances” and ensure Install is listed as the Install Action against all SQL Instances on the server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We do not perform activity logging so ensure that Activity Logging is not setup and choose Next &gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/__zFxCqPcmaI/SYAA2kCnENI/AAAAAAAAAEs/5gBaIBvI8c8/s1600-h/8th.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296234099175264466" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 256px" alt="" src="http://4.bp.blogspot.com/__zFxCqPcmaI/SYAA2kCnENI/AAAAAAAAAEs/5gBaIBvI8c8/s320/8th.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The following screen will summarise what will be installed. Choose Next &gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Installation has now completed. Choose Finish.&lt;br /&gt;&lt;br /&gt;The Registration process will now be launched.&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/__zFxCqPcmaI/SYAA2oFDJfI/AAAAAAAAAE0/mcqYlg960ZE/s1600-h/9th.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296234100259235314" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 239px" alt="" src="http://4.bp.blogspot.com/__zFxCqPcmaI/SYAA2oFDJfI/AAAAAAAAAE0/mcqYlg960ZE/s320/9th.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Choose Next &gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/__zFxCqPcmaI/SYABBUiePfI/AAAAAAAAAFE/qz2SC1-jsWU/s1600-h/10th.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296234283992497650" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 239px" alt="" src="http://2.bp.blogspot.com/__zFxCqPcmaI/SYABBUiePfI/AAAAAAAAAFE/qz2SC1-jsWU/s320/10th.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Select “Register your copy of LiteSpeed 2005” and choose Next &gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Select “Load Registration Key From File”. The file you have to load is called GlobalLiteSpeedLicenseKey.txt and is located in the same folder as the installation software.&lt;br /&gt;&lt;br /&gt;Choose Next &gt; to proceed&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/__zFxCqPcmaI/SYABBgOt3oI/AAAAAAAAAFM/7MkDJtjheHY/s1600-h/11th.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5296234287130861186" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 239px" alt="" src="http://2.bp.blogspot.com/__zFxCqPcmaI/SYABBgOt3oI/AAAAAAAAAFM/7MkDJtjheHY/s320/11th.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Once the Registration process has been completed, the installation is now complete.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to backup the database use&lt;br /&gt;xp_backup_database&lt;br /&gt;@database = database&lt;br /&gt;,@filename = '\path\backup\database.bak'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To restore a database with litespeed us this command&lt;br /&gt;How to restore a file with litespeed if you get the error this is not a vaild backup file.&lt;br /&gt;&lt;br /&gt;xp_restore_database&lt;br /&gt;@database = 'database'&lt;br /&gt;,@filename = '\path\backup\database.BAK'&lt;br /&gt;&lt;br /&gt;or you could create a job to do this for you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-6621451786069833622?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/6621451786069833622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/tools-for-helping-to-backup-databases.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6621451786069833622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6621451786069833622'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/tools-for-helping-to-backup-databases.html' title='Tools for helping to backup databases'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/__zFxCqPcmaI/SX_-cNAkhFI/AAAAAAAAADs/LLmCKF0rHPE/s72-c/firstscreen.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-1211038385182230356</id><published>2009-01-08T15:15:00.000-08:00</published><updated>2009-02-16T05:07:06.691-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='count(*)'/><category scheme='http://www.blogger.com/atom/ns#' term='count'/><category scheme='http://www.blogger.com/atom/ns#' term='test'/><category scheme='http://www.blogger.com/atom/ns#' term='select'/><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>Select Tutorial</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;There are many ways to select data from tables I will go through them.&lt;br /&gt;&lt;br /&gt;Counting rows&lt;br /&gt;&lt;br /&gt;Counting Rows :&lt;br /&gt;&lt;br /&gt;    COUNT(*) counts the number of rows in a table.&lt;br /&gt;&lt;br /&gt;The syntax is &lt;br /&gt;select count(*) from table name&lt;br /&gt;here is an Example &lt;br /&gt;&lt;br /&gt;select count(*) from test;&lt;br /&gt;+----------+&lt;br /&gt;| count(*) |&lt;br /&gt;+----------+&lt;br /&gt;|       148|&lt;br /&gt;+----------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;This query shows the number of rows in the test table&lt;br /&gt;&lt;br /&gt;The most basic of querys in the &lt;br /&gt;&lt;br /&gt;select everything query&lt;br /&gt;and now you learned how to insert data into the table, we should probably check the datas is stored correctly. To do so, we use the SELECT statement.&lt;br /&gt;&lt;br /&gt;The Select syntax is &lt;br /&gt;&lt;br /&gt;SELECT what_to_select from table name;&lt;br /&gt;&lt;br /&gt;    To view all the data from the table, we use the below query.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;select * from test;&lt;br /&gt;OfficeCode AccountCode AccountName SecType&lt;br /&gt;1111             084534334        Test            1&lt;br /&gt;1112             3434343435        3434           2&lt;br /&gt;2 rows in set (0.00 sec)&lt;br /&gt;    The above example query will list the complete details of the test table. Here * will select all the columns from the &lt;br /&gt;&lt;br /&gt;To also limit your select &lt;br /&gt;use&lt;br /&gt;&lt;br /&gt;select top 10 * from test &lt;br /&gt;&lt;br /&gt;this will show the top 10 rows&lt;br /&gt;&lt;br /&gt;OfficeCode AccountCode AccountName&lt;br /&gt;6 6670708 test&lt;br /&gt;6 6610108 test2&lt;br /&gt;6 6044208 test3 &lt;br /&gt;6 6045208 test4 &lt;br /&gt;6 6049208 test5 &lt;br /&gt;6 6046208 test6 &lt;br /&gt;6 6050208 test7  &lt;br /&gt;6 6047208 test8 &lt;br /&gt;6 6048208 test9 &lt;br /&gt;6 6041208 test10&lt;br /&gt;&lt;br /&gt;&lt;!-- AddThis Button BEGIN --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;var addthis_pub="terryjago";&lt;/script&gt;&lt;br /&gt;&lt;a onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" href="http://www.addthis.com/bookmark.php" onclick="return addthis_sendto()"&gt;&lt;img border="0" width="125" alt="Bookmark and Share" style="border:0" src="http://s7.addthis.com/static/btn/lg-bookmark-en.gif" height="16"/&gt;&lt;/a&gt;&lt;script src="http://s7.addthis.com/js/152/addthis_widget.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;&lt;!-- AddThis Button END --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-1211038385182230356?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/1211038385182230356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/select-tutorial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1211038385182230356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1211038385182230356'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/select-tutorial.html' title='Select Tutorial'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-7962623569953604429</id><published>2009-01-07T22:27:00.000-08:00</published><updated>2009-02-16T05:07:20.527-08:00</updated><title type='text'>Inserting in to a table</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;Now you have created your table here is a basic insert statement to show you how to insert data.&lt;br /&gt;&lt;br /&gt;INSERT INTO dbo.BRIAN ( a, b )    VALUES ( 1, 21 )&lt;br /&gt;go&lt;br /&gt;INSERT INTO dbo.BRIAN ( a, b )    VALUES ( 39, 21 )&lt;br /&gt;go&lt;br /&gt;INSERT INTO dbo.BRIAN ( a, b )    VALUES ( 1998, 2001 )&lt;br /&gt;go&lt;br /&gt;INSERT INTO dbo.BRIAN ( a, b )    VALUES ( 26, 2817 )&lt;br /&gt;go&lt;br /&gt;INSERT INTO dbo.BRIAN ( a, b )    VALUES ( 21, 2938 )&lt;br /&gt;go&lt;br /&gt;INSERT INTO dbo.BRIAN ( a, b )    VALUES ( 12, 21 )&lt;br /&gt;go&lt;br /&gt;INSERT INTO dbo.BRIAN ( a, b )    VALUES ( 3939, 4848 )&lt;br /&gt;go&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-7962623569953604429?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/7962623569953604429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/inserting-in-to-table.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7962623569953604429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7962623569953604429'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/inserting-in-to-table.html' title='Inserting in to a table'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-2724232528340466737</id><published>2009-01-07T21:46:00.000-08:00</published><updated>2009-02-16T05:07:32.845-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dbo'/><category scheme='http://www.blogger.com/atom/ns#' term='DBA'/><category scheme='http://www.blogger.com/atom/ns#' term='primary key'/><category scheme='http://www.blogger.com/atom/ns#' term='create table'/><category scheme='http://www.blogger.com/atom/ns#' term='getting started in SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='create database'/><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>creating a table</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;Now you know how to create a database here is an example of creating a table.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;USE [test]&lt;br /&gt;GO&lt;br /&gt;/****** Object:  Table [&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;dbo&lt;/span&gt;].[Audit]    ******/SET ANSI_NULLS ON&lt;br /&gt;GO&lt;br /&gt;SET QUOTED_IDENTIFIER ON&lt;br /&gt;GO&lt;br /&gt;CREATE TABLE [&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;dbo&lt;/span&gt;].[test]( [id] [int] IDENTITY(1,1) NOT NULL, [&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;tracename&lt;/span&gt;] [&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;nvarchar&lt;/span&gt;](100) NULL, [enable] [int] NULL) ON [PRIMARY]&lt;br /&gt;&lt;br /&gt; If NULL is specified, the field is allowed to be left empty. If NOT NULL is specified, the field must be given a value. In the absence of either a NULL or NOT NULL, NULL is assumed.&lt;br /&gt;&lt;br /&gt;The above query will create the table student with fields ID and Name.PRIMARY KEY :    A PRIMARY KEY is a field in a table that uniquely identifies a record. This attribute is used to define the field name to create a primary key.&lt;br /&gt;&lt;br /&gt;PRIMARY KEY(id)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-2724232528340466737?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/2724232528340466737/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/creating-table.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/2724232528340466737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/2724232528340466737'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/creating-table.html' title='creating a table'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-116748391578929317</id><published>2009-01-07T21:37:00.000-08:00</published><updated>2009-02-16T05:07:50.981-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Install'/><category scheme='http://www.blogger.com/atom/ns#' term='DBA'/><category scheme='http://www.blogger.com/atom/ns#' term='Software'/><category scheme='http://www.blogger.com/atom/ns#' term='Backup'/><title type='text'>What is a Database Administrator(DBA)</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;here are too types of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;DBA&lt;/span&gt;, A Production &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;DBA&lt;/span&gt; and Software &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;DBA&lt;/span&gt; Software &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;DBA's&lt;/span&gt;  &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_4"&gt;mainly&lt;/span&gt; help with designing databases and schemers where as a Production &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;DBA&lt;/span&gt; will help to keep a system tight design what permissions a use has, Backup maintain the databases and perform code &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_6"&gt;releases&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The best way to become a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;DBA&lt;/span&gt; is to take the relevant classes and familiarize yourself with the specific, popular databases that are in demand. Becoming certified in a specific database program is a good way to show your skill level. Internships are often a great start to a Database Administrator career. Other technical support roles, such as System Administrators and Network Administrators, may easily transition into a Database Administration role by becoming certified as a Database Administrator&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-116748391578929317?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/116748391578929317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/what-is-database-administratordba.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/116748391578929317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/116748391578929317'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/what-is-database-administratordba.html' title='What is a Database Administrator(DBA)'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-1086100572235366395</id><published>2009-01-07T21:26:00.000-08:00</published><updated>2009-01-07T21:34:39.727-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sybase MSSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Postgress'/><category scheme='http://www.blogger.com/atom/ns#' term='getting started in SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><category scheme='http://www.blogger.com/atom/ns#' term='RDBMS'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>What is SQL?</title><content type='html'>&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;SQL&lt;/span&gt; stands for Structured Query &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;Language&lt;/span&gt; and is used to &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;communicate&lt;/span&gt; with Databases, this is the standard &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_3"&gt;language&lt;/span&gt; for use on relational database management systems(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;RDBMS&lt;/span&gt;). &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;SQL&lt;/span&gt; statements are used for such commands as selecting from tables updates and deletes. Selects &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_6"&gt;retrieve&lt;/span&gt; data from the database tables. The most common &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;RDBMS&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;system&lt;/span&gt; are &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;Sybase&lt;/span&gt;, Oracle, Microsoft &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;SQL&lt;/span&gt; server, MYSQL, Access, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;Postgress&lt;/span&gt; and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;Informix&lt;/span&gt;. Although most Databases systems use &lt;span style="color:#ffff00;"&gt;SQL&lt;/span&gt; some databases have there own software. The &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_14"&gt;standard&lt;/span&gt; commands in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;SQL&lt;/span&gt; as mentioned before are Select", "Insert", "Update", "Delete", "Create", and "Drop" these commands can accomplish most tasks that one needs to do with a database.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-1086100572235366395?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/1086100572235366395/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/what-is-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1086100572235366395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1086100572235366395'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/what-is-sql.html' title='What is SQL?'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-6309444318784320521</id><published>2009-01-07T20:25:00.000-08:00</published><updated>2009-02-16T05:08:33.687-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Down Turn'/><category scheme='http://www.blogger.com/atom/ns#' term='DBA'/><category scheme='http://www.blogger.com/atom/ns#' term='CAMP'/><category scheme='http://www.blogger.com/atom/ns#' term='Economy'/><category scheme='http://www.blogger.com/atom/ns#' term='CODE CAMP'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Sybase'/><category scheme='http://www.blogger.com/atom/ns#' term='Pass'/><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL'/><title type='text'>Economic Down Turn</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;I am now living in Japan, I am a DBA for a contract company contracting to a bigger company.&lt;br /&gt;With the downturn I am always worried about my job, I guess I am lucky as I still have my job, However, it is funny as I am told there is always work for DBA's and DBA's are still in demand. &lt;br /&gt;&lt;br /&gt;I am upset that the govenment has not done anything to protect the people that are laid off and are bailing out the people that caused all the trouble.&lt;br /&gt;&lt;br /&gt;What we can do during these times is try to make our skills count.  And, instead of worrying about or jobs and letting our work suffer is try to reduced the change of us getting laid off try to make your job so valuble that you wont get cut. How you might ask?&lt;br /&gt;firstly I would say try to boost your DBA and IT skills how you might ask again? My Training budget has been cut. &lt;br /&gt;&lt;br /&gt;Well I would say use the internet there are a number of resources out there.&lt;br /&gt;try sites like&lt;br /&gt;&lt;a href="http://www.databasejournal.com/"&gt;http://www.databasejournal.com&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.sqlservercentral.com/"&gt;http://www.sqlservercentral.com&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.sybase.com/"&gt;www.sybase.com&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.oracle.com/"&gt;www.oracle.com&lt;/a&gt;&lt;br /&gt;all these sites have good techical questions and also Oracle and Sybase have great online books free to download.&lt;br /&gt;&lt;br /&gt;Start new projects maybe a migration or try new technologies if you are using database backup try litespeed, have a look what else is out there you may get free downloads you can practise with add it too your skill set so if you do get laid off then you can show these skills.&lt;br /&gt;&lt;br /&gt;Try to find events some of these have free training, i know SQL PASS and code Camps do.&lt;br /&gt;&lt;br /&gt;So in other words dont sit around moping, invest in yourself. this may cost nothing but your time but you will reap there rewards in the end.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-6309444318784320521?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/6309444318784320521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/economic-down-turn.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6309444318784320521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/6309444318784320521'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/economic-down-turn.html' title='Economic Down Turn'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-7051262256375986409</id><published>2009-01-07T19:57:00.001-08:00</published><updated>2009-02-16T05:09:02.534-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='delete'/><category scheme='http://www.blogger.com/atom/ns#' term='tranlog'/><category scheme='http://www.blogger.com/atom/ns#' term='DBCC Shrinkfile'/><title type='text'>if you delete your transaction log</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;a name="_Toc219088843"&gt;If you delete the transactionlog by mistake try this script&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This script should fix a databases where the transaction log has been deleted or croupted. You will have do do some of this manually as explained it will take a while depending on the databases size.&lt;br /&gt;/*&lt;br /&gt;Stop SQL service, rename mydb.mdf to mydbBad.mdf.&lt;br /&gt;started SQL service, created fake mydb db (with log etc)&lt;br /&gt;Stopped SQL service&lt;br /&gt;Deleted mydb.mdf&lt;br /&gt;Renamed mydbBad.MDF to mydb.MDF&lt;br /&gt;Started SQL service.&lt;br /&gt;Ran following script:&lt;br /&gt;*/&lt;br /&gt;ALTER DATABASE mydb SET EMERGENCY&lt;br /&gt;sp_dboption 'mydb', 'single user', 'true'&lt;br /&gt;DBCC CHECKDB ('mydb', REPAIR_ALLOW_DATA_LOSS)&lt;br /&gt;sp_dboption 'mydb', 'single user', 'false'&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-7051262256375986409?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/7051262256375986409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/if-you-delete-your-transaction-log.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7051262256375986409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7051262256375986409'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/if-you-delete-your-transaction-log.html' title='if you delete your transaction log'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-4224538165461869930</id><published>2009-01-07T19:55:00.000-08:00</published><updated>2009-01-07T19:56:54.085-08:00</updated><title type='text'>scripting out logins from 2000 to 2005</title><content type='html'>&lt;a name="_Toc219088848"&gt;SQL 2000 to SQL 2005: Where have all the old features gone?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.sqlmag.com/Articles/ArticleID/16090/16090.html"&gt;http://www.sqlmag.com/Articles/ArticleID/16090/16090.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Introduction where have all the good features goine in sql2005&lt;br /&gt;As more DBAs across the planet begin using SQL 2005 Tools, but still manage SQL 2000 servers with them, I suspect there will be lots of muffled moaning and wondering where have all the good old features gone. Although Management Studio has some very nice long-awaited features, some of the good old stuff just isn’t there.&lt;br /&gt;Where are my tried and true tools, such as taskpad? Where’s the IF EXISTS DROP option when I script out the stored procedures? Could someone pinch me and tell me this is just a bad dream?&lt;br /&gt;The aspirin industry will profit enormously from that sort of thing.&lt;br /&gt;To name a few good old pals that have all but disappeared into obscurity:&lt;br /&gt;•       Taskpad&lt;br /&gt;•        Ability to quickly script permissions on stored procedures&lt;br /&gt;•        Ability to quickly see disk space in database properties&lt;br /&gt;•        Time of creation of stored procedures&lt;br /&gt;Sure, if you're connecting to an instance of SQL Server 2005 with Management Studio you get colorful reports and plethora of professional-looking graphs at your disposal, but what about the majority of us that still did not migrate our servers to SQL 2005, but already upgraded the tools?&lt;br /&gt;The good news is this will tend to convert many GUI DBAs into hardened command-line pros, improve they're typing skills, etc. In the next section I will show how to still take advantage of the old tools functionality.&lt;br /&gt;Taskpad functionality&lt;br /&gt;I don't know about you all, but I really like the Taskpad and use it all the time. I am used to it like to an old slipper; it fits my needs. And even if it did throw a vague error now and then I forgive it now that it's done….forever. But how can we get its functionality back?&lt;br /&gt;The General tab in Database section is now in database properties under the same heading.&lt;br /&gt;Maintenance section-like information can be found by querying the backupset table in msdb:&lt;br /&gt;select max(backup_start_date) from backupset&lt;br /&gt;where database_name = ‘my_db'&lt;br /&gt;Note: Database options, Number of Users, Date Created and Owner can still be found in database properties in the SQL 2005 tools.&lt;br /&gt;Space allocated section info can be found by running this T-SQL:&lt;br /&gt;select * from sysfiles&lt;br /&gt;or if you just need to find the space used by you log, execute:&lt;br /&gt;DBCC SQLPERF (LOGSPACE)&lt;br /&gt;Table Info tab&lt;br /&gt;I don't use this one very often, but you can get similar functionality by running:&lt;br /&gt;Exec sp_spaceused ‘your_table_name'&lt;br /&gt;To script multiple stored procedures including permissions:&lt;br /&gt;Right-click the database-&gt;Tasks-&gt;Generate Scripts, pick your database. Set Include object Level Permissions to True. Note: If you set the Include if NOT EXISTS option to true, the script will not create the stored procedure if it already exists on target database.&lt;br /&gt;Click Next, and select Stored Procedures only. Next select which procs you want to script, review you final options and click Finish.&lt;br /&gt;Unfortunately, if you want to drop/recreate the procedures if they exist on the target server, you will need to manually include the following script in the beginning of each procedure:&lt;br /&gt;IF EXISTS (SELECT name FROM sysobjects&lt;br /&gt;            WHERE name = 'your_proc_name' AND type = 'P')&lt;br /&gt; DROP PROCEDURE 'your_proc_name'&lt;br /&gt;GO&lt;br /&gt;This one is truly beyond me, for reasons known only to Microsoft and the CEO of Bayer (or whoever is the biggest headache drug company these days) this option was excluded from final SQL 2005 RTM.&lt;br /&gt;Check disk space&lt;br /&gt;If you're like I am, you're used to clicking on database properties, and the ellipsis in order to see the free disk space on the server. In SQL Server 2005 you can get this in the report, but until then you can run undocumented extended stored procedure:&lt;br /&gt;exec xp_fixeddrives&lt;br /&gt;The result would look something like this:&lt;br /&gt;&lt;br /&gt;Time of creation of stored procedures:&lt;br /&gt;For some reason the time part of the Create Date column in the Summary tab of SQL 2005 is depreciated. Why? I guess someone thought DBAs don't need it any longer (rolling eyes). The good news is you can still get this information by querying the sysobjects table, like:&lt;br /&gt;Select crdate as DateCreated&lt;br /&gt; From dbo.sysobjects&lt;br /&gt; where name = 'your_proc_name'&lt;br /&gt;&lt;br /&gt;Note: make sure NOT to specify the owner, as in dbo.your_proc_name, but simply the procedure name. The result is:&lt;br /&gt;&lt;br /&gt;Summary&lt;br /&gt;I've shown you here how to get by with available SQL 2005 Tools until you upgrade your servers to SQL 2005 Server edition. People get used to their favorite ways to get the job done, and sometimes get “surprised” when their tools get taken away, and now they have to hammer the nail with the handle of a screwdriver. Hopefully the ways to attain old functionality will increase productivity, and hopefully the tools will continue to improve.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MSSQL How to transfer logins&lt;br /&gt;http://support.microsoft.com/kb/246133&lt;br /&gt;•            You transfer logins and passwords from SQL Server 7.0 to SQL Server 2005.&lt;br /&gt;•            You transfer logins and passwords from SQL Server 2000 to SQL Server 2005.&lt;br /&gt;•            You assign logins to roles.&lt;br /&gt;To transfer logins and passwords between different versions of SQL Server and then assign logins to roles, follow these steps:&lt;br /&gt;1.           Run the following script on the source SQL Server.&lt;br /&gt;USE master&lt;br /&gt;GO&lt;br /&gt;IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL&lt;br /&gt;DROP PROCEDURE sp_hexadecimal&lt;br /&gt;GO&lt;br /&gt;CREATE PROCEDURE sp_hexadecimal&lt;br /&gt;@binvalue varbinary(256),&lt;br /&gt;@hexvalue varchar(256) OUTPUT&lt;br /&gt;AS&lt;br /&gt;DECLARE @charvalue varchar(256)&lt;br /&gt;DECLARE @i int&lt;br /&gt;DECLARE @length int&lt;br /&gt;DECLARE @hexstring char(16)&lt;br /&gt;SELECT @charvalue = '0x'&lt;br /&gt;SELECT @i = 1&lt;br /&gt;SELECT @length = DATALENGTH (@binvalue)&lt;br /&gt;SELECT @hexstring = '0123456789ABCDEF'&lt;br /&gt;WHILE (@i &lt;= @length)&lt;br /&gt;BEGIN&lt;br /&gt;DECLARE @tempint int&lt;br /&gt;DECLARE @firstint int&lt;br /&gt;DECLARE @secondint int&lt;br /&gt;SELECT @tempint = CONVERT(int, SUBSTRING(@binvalue,@i,1))&lt;br /&gt;SELECT @firstint = FLOOR(@tempint/16)&lt;br /&gt;SELECT @secondint = @tempint - (@firstint*16)&lt;br /&gt;SELECT @charvalue = @charvalue +&lt;br /&gt;SUBSTRING(@hexstring, @firstint+1, 1) +&lt;br /&gt;SUBSTRING(@hexstring, @secondint+1, 1)&lt;br /&gt;SELECT @i = @i + 1&lt;br /&gt;END&lt;br /&gt;SELECT @hexvalue = @charvalue&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;IF OBJECT_ID ('sp_help_revlogin_2000_to_2005') IS NOT NULL&lt;br /&gt;DROP PROCEDURE sp_help_revlogin_2000_to_2005&lt;br /&gt;GO&lt;br /&gt;CREATE PROCEDURE sp_help_revlogin_2000_to_2005&lt;br /&gt;&lt;br /&gt;@login_name sysname = NULL,&lt;br /&gt;@include_db bit = 0,&lt;br /&gt;@include_role bit = 0&lt;br /&gt;&lt;br /&gt;AS&lt;br /&gt;DECLARE @name sysname&lt;br /&gt;DECLARE @xstatus int&lt;br /&gt;DECLARE @binpwd varbinary (256)&lt;br /&gt;DECLARE @dfltdb varchar (256)&lt;br /&gt;DECLARE @txtpwd sysname&lt;br /&gt;DECLARE @tmpstr varchar (256)&lt;br /&gt;DECLARE @SID_varbinary varbinary(85)&lt;br /&gt;DECLARE @SID_string varchar(256)&lt;br /&gt;&lt;br /&gt;IF (@login_name IS NULL)&lt;br /&gt;DECLARE login_curs CURSOR STATIC FOR&lt;br /&gt;SELECT sid, [name], xstatus, password, isnull(db_name(dbid), 'master')&lt;br /&gt;FROM master.dbo.sysxlogins&lt;br /&gt;WHERE srvid IS NULL AND&lt;br /&gt;[name] &lt;&gt; 'sa'&lt;br /&gt;ELSE&lt;br /&gt;DECLARE login_curs CURSOR FOR&lt;br /&gt;SELECT sid, [name], xstatus, password, isnull(db_name(dbid), 'master')&lt;br /&gt;FROM master.dbo.sysxlogins&lt;br /&gt;WHERE srvid IS NULL AND&lt;br /&gt;[name] = @login_name&lt;br /&gt;&lt;br /&gt;OPEN login_curs&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb&lt;br /&gt;&lt;br /&gt;IF (@@fetch_status = -1)&lt;br /&gt;BEGIN&lt;br /&gt;PRINT 'No login(s) found.'&lt;br /&gt;CLOSE login_curs&lt;br /&gt;DEALLOCATE login_curs&lt;br /&gt;RETURN -1&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;SET @tmpstr = '/* sp_help_revlogin script '&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;SET @tmpstr = '** Generated '&lt;br /&gt;+ CONVERT (varchar, GETDATE()) + ' on ' + @@SERVERNAME + ' */'&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT '/***** CREATE LOGINS *****/'&lt;br /&gt;&lt;br /&gt;WHILE @@fetch_status = 0&lt;br /&gt;BEGIN&lt;br /&gt;PRINT ''&lt;br /&gt;SET @tmpstr = '-- Login: ' + @name&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;&lt;br /&gt;IF (@xstatus &amp;amp; 4) = 4&lt;br /&gt;BEGIN -- NT authenticated account/group&lt;br /&gt;IF (@xstatus &amp;amp; 1) = 1&lt;br /&gt;BEGIN -- NT login is denied access&lt;br /&gt;SET @tmpstr = '' --'EXEC master..sp_denylogin ''' + @name + ''''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;ELSE&lt;br /&gt;BEGIN -- NT login has access&lt;br /&gt;SET @tmpstr = 'IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE [name] = ''' + @name + ''')'&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;SET @tmpstr = CHAR(9) + 'CREATE LOGIN [' + @name + '] FROM WINDOWS'&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;END&lt;br /&gt;ELSE&lt;br /&gt;BEGIN -- SQL Server authentication&lt;br /&gt;EXEC sp_hexadecimal @SID_varbinary, @SID_string OUT&lt;br /&gt;&lt;br /&gt;IF (@binpwd IS NOT NULL)&lt;br /&gt;BEGIN -- Non-null password&lt;br /&gt;EXEC sp_hexadecimal @binpwd, @txtpwd OUT&lt;br /&gt;SET @tmpstr = 'CREATE LOGIN [' + @name + '] WITH PASSWORD=' + @txtpwd + ' HASHED'&lt;br /&gt;END&lt;br /&gt;ELSE&lt;br /&gt;BEGIN -- Null password&lt;br /&gt;SET @tmpstr = 'CREATE LOGIN [' + @name + '] WITH PASSWORD='''''&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;SET @tmpstr = @tmpstr + ', CHECK_POLICY=OFF, SID=' + @SID_string&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @include_db = 1&lt;br /&gt;BEGIN&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT '/***** SET DEFAULT DATABASES *****/'&lt;br /&gt;&lt;br /&gt;FETCH FIRST FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb&lt;br /&gt;&lt;br /&gt;WHILE @@fetch_status = 0&lt;br /&gt;BEGIN&lt;br /&gt;PRINT ''&lt;br /&gt;SET @tmpstr = '-- Login: ' + @name&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;&lt;br /&gt;SET @tmpstr = 'ALTER LOGIN [' + @name + '] WITH DEFAULT_DATABASE=[' + @dfltdb + ']'&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb&lt;br /&gt;END&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @include_role = 1&lt;br /&gt;BEGIN&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT ''&lt;br /&gt;PRINT '/***** SET SERVER ROLES *****/'&lt;br /&gt;&lt;br /&gt;FETCH FIRST FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb&lt;br /&gt;&lt;br /&gt;WHILE @@fetch_status = 0&lt;br /&gt;BEGIN&lt;br /&gt;PRINT ''&lt;br /&gt;SET @tmpstr = '-- Login: ' + @name&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;&lt;br /&gt;IF @xstatus &amp;amp;16 = 16 -- sysadmin&lt;br /&gt;BEGIN&lt;br /&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''sysadmin'''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @xstatus &amp;amp;32 = 32 -- securityadmin&lt;br /&gt;BEGIN&lt;br /&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''securityadmin'''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @xstatus &amp;amp;64 = 64 -- serveradmin&lt;br /&gt;BEGIN&lt;br /&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''serveradmin'''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @xstatus &amp;amp;128 = 128 -- setupadmin&lt;br /&gt;BEGIN&lt;br /&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''setupadmin'''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @xstatus &amp;amp;256 = 256 --processadmin&lt;br /&gt;BEGIN&lt;br /&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''processadmin'''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @xstatus &amp;amp;512 = 512 -- diskadmin&lt;br /&gt;BEGIN&lt;br /&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''diskadmin'''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @xstatus &amp;amp;1024 = 1024 -- dbcreator&lt;br /&gt;BEGIN&lt;br /&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''dbcreator'''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;IF @xstatus &amp;amp;4096 = 4096 -- bulkadmin&lt;br /&gt;BEGIN&lt;br /&gt;SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''bulkadmin'''&lt;br /&gt;PRINT @tmpstr&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb&lt;br /&gt;END&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE login_curs&lt;br /&gt;DEALLOCATE login_curs&lt;br /&gt;RETURN 0&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;exec sp_help_revlogin_2000_to_2005 @login_name=NULL, @include_db=1, @include_role=1&lt;br /&gt;GO&lt;br /&gt;2.           Save the output, and then paste and run the output in SQL Server Management Studio on the destination SQL Server 2005.&lt;br /&gt;Note If the source SQL Server contains a login that has a blank password, the output contains a statement that resembles the following.&lt;br /&gt;CREATE LOGIN LoginName WITH PASSWORD = '', CHECK_POLICY = OFF, SID = MySID&lt;br /&gt; Back to the top&lt;br /&gt;Remarks&lt;br /&gt; •           Review the output script carefully before you run it on the destination SQL Server. If you have to transfer logins to an instance of SQL Server in a different domain than the source instance of SQL Server, edit the script generated by the sp_help_revlogin procedure, and replace the domain name with the new domain in the sp_grantlogin statements. Because the integrated logins granted access in the new domain will not have the same SID as the logins in the original domain, the database users will be orphaned from these logins. To resolve these orphaned users, see the articles referenced in the following bullet item. If you transfer integrated logins between instances of SQL Servers in the same domain, the same SID is used and the user is not likely to be orphaned.&lt;br /&gt;•            After you move the logins, users may not have permissions to access databases that have also been moved. This problem is described as an "orphaned user". If you try to grant the login access to the database, it may fail indicating the user already exists:&lt;br /&gt;Microsoft SQL-DMO (ODBC SQLState: 42000) Error 15023: User or role '%s' already exists in the current database.&lt;br /&gt;For instructions about how to map the logins to the database users to resolve orphaned SQL Server logins and integrated logins, see the following article in the Microsoft Knowledge Base:&lt;br /&gt;240872 (http://support.microsoft.com/kb/240872/) How to resolve permission issues when you move a database between servers that are running SQL Server&lt;br /&gt;For instructions about using the sp_change_users_login stored procedure to correct the orphaned users one-by-one (this will only address users orphaned from standard SQL logins), see the following article in the Microsoft Knowledge Base:&lt;br /&gt;274188 (http://support.microsoft.com/kb/274188/) "Troubleshooting Orphaned Users" topic in Books Online is incomplete&lt;br /&gt;•            If the transfer of logins and passwords is part of a move of databases to a new server running SQL Server, see the following article in the Microsoft Knowledge Base for a description of the workflow and steps involved:&lt;br /&gt;314546 (http://support.microsoft.com/kb/314546/) How to move databases between computers that are running SQL Server&lt;br /&gt;•            You can do this because of the @encryptopt parameter in the sp_addlogin system stored procedure, that allows a login to be created by using the encrypted password. For more information about this procedure, see the "sp_addlogin (T-SQL)" topic in SQL Server Books Online.&lt;br /&gt;•            By default, only members of the sysadminfixed server role can select from the sysxlogins table. Unless a member of the sysadmin role grants the necessary permissions, end users cannot create or run these stored procedures.&lt;br /&gt;•            This approach does not try to transfer the default database information for a particular login because the default database may not always exist on the destination server. To define the default database for a login, you can use the sp_defaultdb system stored procedure by passing it the login name and the default database as arguments. For more information about using this procedure, see the "sp_defaultdb" topic in SQL Server Books Online.&lt;br /&gt;•            During a transfer of logins between instances of SQL Server, if the sort order of the source server is case-insensitive and the sort order of the destination server is case-sensitive, you must enter all alphabetical characters in passwords as uppercase characters after the transfer of logins to the destination server. If the sort order of the source server is case-sensitive and the sort order of the destination server is case-insensitive, you will not be able to log in with the logins transferred using the procedure outlined in this article, unless the original password contains no alphabetical characters or unless all alphabetical characters in the original password are uppercase characters. If both servers are case-sensitive or both servers are case-insensitive, you will not experience this problem. This is a side effect of the way that SQL Server handles passwords. For more information, see the "Effect on Passwords of Changing Sort Orders" topic in SQL Server 7.0 Books Online.&lt;br /&gt;•            When you run the output from the sp_help_revlogin script on the destination server, if the destination server already has a login defined with the same name as one of the logins on the script output, you may see the following error upon execution of the output of the sp_help_revlogin script:&lt;br /&gt;Server: Msg 15025, Level 16, State 1, Procedure sp_addlogin, Line 56&lt;br /&gt;The login 'test1' already exists.&lt;br /&gt;Likewise, if a different login exists with the same SID value on this server as the one you are trying to add, you receive the following error message:&lt;br /&gt;Server: Msg 15433, Level 16, State 1, Procedure sp_addlogin, Line 93&lt;br /&gt;Supplied parameter @sid is in use.&lt;br /&gt;Therefore, you must carefully review the output from these commands, examine the contents of the sysxlogins table, and address these errors accordingly.&lt;br /&gt;•            The SID value for a particular login is used as the basis for implementing database level access in SQL Server. Therefore, if the same login has two different values for the SID at the database level (in two different databases on that server), the login will only have access to that database whose SID matches the value in syslogins for that login. Such a situation might occur if the two databases in question have been consolidated from two different servers. To resolve this problem, the login in question would have to be manually removed from the database that has a SID mismatch by using the sp_dropuser stored procedure, and then added again by using the sp_adduser stored procedure.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-4224538165461869930?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/4224538165461869930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/scripting-out-logins-from-2000-to-2005.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4224538165461869930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/4224538165461869930'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/scripting-out-logins-from-2000-to-2005.html' title='scripting out logins from 2000 to 2005'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-5998447231655025905</id><published>2009-01-07T19:53:00.000-08:00</published><updated>2009-01-07T19:55:10.492-08:00</updated><title type='text'>logshipping</title><content type='html'>&lt;a name="_Toc219088846"&gt;Log shipping:&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc219088847"&gt;Using the log shipping wizard&lt;/a&gt;&lt;br /&gt;To use the log shipping wizard in SQL Server 2005, right click on your database and select Tasks and Ship Transaction Logs as illustrated in Figure 1.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_1.jpg" target="_blank"&gt;&lt;/a&gt;Figure 1: Accessing the log shipping wizard. (Click on image for enlarged view.)&lt;br /&gt;You may get the dialog you see displayed in Figure 2. SQL Server is telling you that this database is not a full or bulk logged recovery model.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_2.jpg" target="_blank"&gt;&lt;/a&gt;Figure 2: Dialog displayed if your database is in the simple recovery model. (Click on image for enlarged view.)&lt;br /&gt;To change the recovery model for your database, right click on your database, select properties and in the Options tab, click on the Recovery Model drop down list box and select Full or Bulk logged recovery model. This is illustrated in Figure 3. Then click OK.&lt;br /&gt;Note: If you do select these recovery models and you back up your database or have already backed up the database, you will need to maintain your transaction logs by scheduling a backup of them. The log shipping wizard will configure this for you.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_3.jpg" target="_blank"&gt;&lt;/a&gt;Figure 3: Changing the recovery model for your database. (Click on image for enlarged view.)&lt;br /&gt;Once you've set the correct recovery model for your database, right click on your database and select Ship Transaction Logs again. You will receive the dialog box illustrated in Figure 4.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_4.jpg" target="_blank"&gt;&lt;/a&gt;Figure 4: Configuring log shipping. (Click on image for enlarged view.)&lt;br /&gt;Note: In this figure, I selected the check box that enables this as a primary database in a log shipping configuration. Make sure you select this check box as well. Clicking on the Backup Settings button will display the Transaction Log Backup Settings as displayed in Figure 5.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_5.jpg" target="_blank"&gt;&lt;/a&gt;Figure 5: Transaction Log Backup Settings and options. (Click on image for enlarged view.)&lt;br /&gt;There are two options to backup the transaction log to:&lt;br /&gt;Network path&lt;br /&gt;Local path&lt;br /&gt;If you are backing up to a network path, there will be some increase in the transaction log backup times and you will decrease the space requirements on your primary server. The network path should go to the location where you want store the transaction log backups on the secondary server. Most DBAs use a network share to back up the files to&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Because they want the transaction log backup files on the secondary server to protect them in the event that the primary server goes down.&lt;br /&gt;The local path option will back up the transaction logs to a path on your primary server. Make sure the transaction log backups are not backed up to the same physical drive where your database data files or log files exist. Should they be backed up to the same physical drive, it would cause I/O contention and overall SQL Server performance degradation.&lt;br /&gt;Figure 6 illustrates a completed Transaction Log Backup Settings dialog. Note that the share name has a dollar sign after it. This has the effect of hiding the share from users, and only users who know the share name will be able to access it. This is considered a good security practice.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_6.jpg" target="_blank"&gt;&lt;/a&gt;Figure 6: Transaction Log Backup Settings illustrating a hidden share for the network path. (Click on image for enlarged view.)&lt;br /&gt;There is an option for how long to retain your transaction log backups and an option for the threshold to raise an alert if there is no backup within a specific period. I've found the default for transaction log backup retention of three days to be adequate. I normally set a much smaller alert, like 20 minutes, but while a database backup is occurring, no log backups can occur, so if your database backups take more than an hour, you will get frequent alerts. Set this to a value that works for you. And remember: Too frequent alerts will result in your ignoring critical ones.&lt;br /&gt;Once you have set the transaction log backup location, the retention period, the alerting threshold and the schedule, click OK. You will return to the Database Properties dialog box as illustrated in Figure 4. Click on the Next button to display the secondary Database Settings dialog displayed in Figure 7.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_7.jpg" target="_blank"&gt;&lt;/a&gt;Figure 7: The secondary database settings. (Click on image for enlarged view.)&lt;br /&gt;In this dialog box, you can select the secondary server (the server you'll be copying the transaction logs to) as well as the secondary database (the name of the database you will be log shipping to). Notice these options for Initialize Secondary Database:&lt;br /&gt;Yes, generate a full backup of the primary and restore it into the secondary database. This option creates a backup of the database you wish to log ship and restores it on the secondary server.&lt;br /&gt;Yes, restore an existing backup of the primary database. Use this option if you want to use a previously backed up database. There is an option to select the path and backup name.&lt;br /&gt;No, the secondary database is initialized. Use this option if:&lt;br /&gt;A copy of the database you wish to log ship has already been restored on the secondary.&lt;br /&gt;The primary database is already in the full or bulk logged recovery model.&lt;br /&gt;No transaction log backups have been done on the primary database since the backup was done, or if they have been done, they have been restored on the secondary.&lt;br /&gt;The secondary database has been restored with the no-recovery option.&lt;br /&gt;Once you have configured the options that work best for you, click on the Copy Files tab, to display the dialog, as illustrated in Figure 8.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_8.jpg" target="_blank"&gt;&lt;/a&gt;Figure 8: Copy Files dialog. (Click on image for enlarged view.)&lt;br /&gt;In the Copy Files tab, select where you copied the files from primary to the secondary. If you selected a network path in the Transaction Log Backup Settings (as illustrated in Figure 1), the network path should map to a physical location on your secondary server, and you should enter that path here (i.e., if \\ServerName\ShareName$ is the share name for the local path C:\Backup, enter this path here.)&lt;br /&gt;You can also use a network path where the transaction log backups are stored on the primary server. Select how long you wish to retain the transaction log backups – understanding, of course, that the retention period might conflict with what you set in the Transaction Log Backup Settings dialog box (Figure 1).&lt;br /&gt;You can also select how frequently you want the logs to be copied to the secondary server.&lt;br /&gt;Once you have configured the copying of the transaction log backup files, click on the Restore Transaction Log tab as illustrated in Figure 9.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_9.jpg" target="_blank"&gt;&lt;/a&gt;Figure 9: Restore Transaction Log tab. (Click on image for enlarged view.)&lt;br /&gt;The database recovery state options are:&lt;br /&gt;No Recovery Mode – This is the default option. In this option, the destination database will be inaccessible.&lt;br /&gt;Standby Mode – In this option, the destination database will be read only until the next transaction log backup is applied. After the transaction log is applied, the database will be returned to read-only mode again. This allows read-only access and users will not be able to make any changes to the database (i.e., create indexes) and they will be disconnected when the next database backup is applied.&lt;br /&gt;There is also an option to delay restoring the transaction log backups by a set number of hours or minutes. Some enterprises like to keep their standby server several hours out of sync from their source server.&lt;br /&gt;By default, if the transaction logs are not restored within the interval defined in the "Alert if no restore occurs within" setting, an alert will be raised. Most frequently this alert is raised during a backup operation on the primary.&lt;br /&gt;You also have an option to set how frequently the transaction log restores will take place. These settings are made in the Restore job dialog.&lt;br /&gt;Once you make those settings, click OK and you'll see the Transaction Log Shipping dialog of the Database Properties dialog box (as illustrated in Figure 10).&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_10.jpg" target="_blank"&gt;&lt;/a&gt;Figure 10: Transaction Log Shipping tab. (Click on image for enlarged view.)&lt;br /&gt;In this dialog, notice how we have configured server F as our secondary server and that database p2p3 is the database we are log shipping the Northwind database to. You can also log ship to a second secondary/standby server – this could be another secondary server in your DR site.&lt;br /&gt;In any enterprise with a large number of log ship databases, you may want to create a monitor server. To create a monitor server, select "Use a monitor server instance" (Figure 10) and click on the settings button to configure a Log Shipping Monitor server. That option is illustrated in Figure 11.&lt;br /&gt;&lt;a href="http://media.techtarget.com/digitalguide/images/Misc/log_shipping_11.jpg" target="_blank"&gt;&lt;/a&gt;Figure 11: Create a monitor server. (Click on image for enlarged view.)&lt;br /&gt;In the connect button, connect to the server you wish to use as your monitor. Define how to make the connection, either through Windows authentication or through a SQL Server login. You can define the job history retention and the default is normally a good choice, and then defines how you want to send the alerts. The default option (Start Automatically when SQL Server Agent starts) is the best choice as alerts will be near real time. You can alternatively select an hourly schedule or whatever time interval you choose.&lt;br /&gt;Summary&lt;br /&gt;This completes our look at using the log shipping dialog in SQL Server 2005. This wizard has many options to it and can be quite bewildering to the new user. But the defaults are generally optimal in most cases and I've noted the cases where it's best to use non-&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-5998447231655025905?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/5998447231655025905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/logshipping.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/5998447231655025905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/5998447231655025905'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/logshipping.html' title='logshipping'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-1413409583171039094</id><published>2009-01-07T17:43:00.000-08:00</published><updated>2009-01-07T19:52:49.221-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='walkthrough'/><category scheme='http://www.blogger.com/atom/ns#' term='getting started in SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='create database'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>A post for the beginners, How to create a database?</title><content type='html'>Creating a Database&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is a very simple task, however, one must ask themselves a few questions before doing this.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;how much space do we need?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;How many concurrent users do we expect on the server?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Always look at more users that you think or will use the database for expation.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What is the DB going to be used for?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I.E Office, Intranet, Internet,&lt;br /&gt;&lt;br /&gt;If its going to be used for the internet, intranet we need to think about security because we'll need to utilze predefind zones within the firewall.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Do we need to configure IPSEC or SSL?&lt;br /&gt;&lt;br /&gt;Do we know when we can do maitanance esp if the db needs to be up all the time?&lt;br /&gt;&lt;br /&gt;Backing up the database?&lt;br /&gt;&lt;br /&gt;Creating a db with sql management studio&lt;a href="http://1.bp.blogspot.com/__zFxCqPcmaI/SWVpQsz3koI/AAAAAAAAACc/CFASY9jxn0w/s1600-h/new+database.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5288749073044050562" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 228px" alt="" src="http://1.bp.blogspot.com/__zFxCqPcmaI/SWVpQsz3koI/AAAAAAAAACc/CFASY9jxn0w/s320/new+database.JPG" 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;select databases then right click and click create&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/__zFxCqPcmaI/SWVpYxSHVdI/AAAAAAAAACk/HpAi3tCtohI/s1600-h/new+db.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5288749211683608018" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 230px" alt="" src="http://2.bp.blogspot.com/__zFxCqPcmaI/SWVpYxSHVdI/AAAAAAAAACk/HpAi3tCtohI/s320/new+db.JPG" 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;you will now see this screen after you cleck create&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/__zFxCqPcmaI/SWVqD3vlZWI/AAAAAAAAAC8/EpbSkAt18Dc/s1600-h/setting+size+of+db.JPG"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/__zFxCqPcmaI/SWV0tY4t6yI/AAAAAAAAADE/PEMK65jX0vk/s1600-h/newdbname.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5288761660539792162" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 287px" alt="" src="http://2.bp.blogspot.com/__zFxCqPcmaI/SWV0tY4t6yI/AAAAAAAAADE/PEMK65jX0vk/s320/newdbname.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When creating a database one rule you should always follow is the database should not contain spaces. Putting spaces in the name requires surrounding it with brackets [My Database] in TSQL to avoid syntax errors and I prefer not to have to use the brackets. I follow that by almost always setting the owner of the database to SA. In most cases on systems I administer changes will always be made by someone in the sysadmin group, rarely we might put someone into the db_owner role to let them make whatever changes are needed. The only value derived from being the database owner rather than a member of db_owner is that the owner is also dbo, which means that if they don't qualify objects with a schema when created they will be owned by dbo by default. Members of db_owner can use two part syntax to put objects into the dbo schema (create table dbo.employess...). Note that you can always change the database owner later using sp_changedbowner.&lt;br /&gt;Full text indexing isn't commonly used, but we can activate now if we know it will be needed, or it can activated later.&lt;br /&gt;As you can see in the next image I'm going to call my database Test, and it has automatically generated the logical names for the two files that get created by default (one MDF and one LDF). I never change these names as the generated one works fine. Moving to the right I've taken a guess at my database usage and increased the database size to 100 MB and the log size to 10 MB. It's just a guess though, so why bother? Mainly to avoid fragmentation by allocating a good chunk of space at once.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/__zFxCqPcmaI/SWV1QGexMeI/AAAAAAAAADM/UyearFOASpM/s1600-h/setting+size+of+db.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5288762256894538210" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 287px" alt="" src="http://1.bp.blogspot.com/__zFxCqPcmaI/SWV1QGexMeI/AAAAAAAAADM/UyearFOASpM/s320/setting+size+of+db.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/__zFxCqPcmaI/SWVpDfPkQlI/AAAAAAAAACU/uw274JX8lR0/s1600-h/scddb.JPG"&gt;&lt;/a&gt;&lt;/div&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;Once you have selected the databases name in this case you will need to change the default values for autogrow to do this click on the 3 dots next to the autogrowth it will look like bt 1mb, unrestricted growth ... you will then see this screen&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5288763170030096770" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 320px; CURSOR: hand; HEIGHT: 256px; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/__zFxCqPcmaI/SWV2FQLQEYI/AAAAAAAAADU/9tv86oNyi4s/s320/setautogrow.JPG" border="0" /&gt;&lt;br /&gt;I rarely turn autogrow off, and contrary to what many recommend I typically let the database grow if and when it's needed, not deliberately resizing the database to maintain a given amount of free space. The advantage to doing it deliberately is that you avoid the performance hit of waiting for the file to grow if it happens during production hours, but that penalty has been greatly reduced in SQL 2005 with &lt;a href="http://msdn.microsoft.com/en-us/library/ms175935.aspx"&gt;instant initialization&lt;/a&gt;, a feature change that causes SQL to initialize pages on first write instead of during the auto grow. The advantage of doing it my way is less time spent on a very mundane task. The more important decision is whether to grow in percent or megabytes, and how much. There's no right answer, but in general we want to grow in as large a chunk as makes sense to avoid physical fragmentation on the drive. For this example I'm going to set both to grow at 10%, and leave file growth unrestricted.&lt;br /&gt;&lt;br /&gt;Click on the tab next to path&lt;br /&gt;and change the db bath where you would like the data and log to go and the click cilck ok this will create the database you can also change the name of the file here if you like.&lt;br /&gt;&lt;br /&gt;Here is also the code to create this db.&lt;br /&gt;&lt;br /&gt;REATE DATABASE [SCD] ON PRIMARY ( NAME = N'SCD', FILENAME = N'G:\MSSQL2K5\MSSQL.1\MSSQL\DATA\SCD.mdf' , SIZE = 102400KB , FILEGROWTH = 1024KB ) LOG ON ( NAME = N'SCD_log', FILENAME = N'G:\MSSQL2K5\MSSQL.1\MSSQL\DATA\SCD_log.ldf' , SIZE = 10240KB , FILEGROWTH = 10%)GOEXEC dbo.sp_dbcmptlevel @dbname=N'SCD', @new_cmptlevel=90GOALTER DATABASE [SCD] SET ANSI_NULL_DEFAULT OFF GOALTER DATABASE [SCD] SET ANSI_NULLS OFF GOALTER DATABASE [SCD] SET ANSI_PADDING OFF GOALTER DATABASE [SCD] SET ANSI_WARNINGS OFF GOALTER DATABASE [SCD] SET ARITHABORT OFF GOALTER DATABASE [SCD] SET AUTO_CLOSE OFF GOALTER DATABASE [SCD] SET AUTO_CREATE_STATISTICS ON GOALTER DATABASE [SCD] SET AUTO_SHRINK OFF GOALTER DATABASE [SCD] SET AUTO_UPDATE_STATISTICS ON GOALTER DATABASE [SCD] SET CURSOR_CLOSE_ON_COMMIT OFF GOALTER DATABASE [SCD] SET CURSOR_DEFAULT GLOBAL GOALTER DATABASE [SCD] SET CONCAT_NULL_YIELDS_NULL OFF GOALTER DATABASE [SCD] SET NUMERIC_ROUNDABORT OFF GOALTER DATABASE [SCD] SET QUOTED_IDENTIFIER OFF GOALTER DATABASE [SCD] SET RECURSIVE_TRIGGERS OFF GOALTER DATABASE [SCD] SET AUTO_UPDATE_STATISTICS_ASYNC OFF GOALTER DATABASE [SCD] SET DATE_CORRELATION_OPTIMIZATION OFF GOALTER DATABASE [SCD] SET PARAMETERIZATION SIMPLE GOALTER DATABASE [SCD] SET READ_WRITE GOALTER DATABASE [SCD] SET RECOVERY FULL GOALTER DATABASE [SCD] SET MULTI_USER GOALTER DATABASE [SCD] SET PAGE_VERIFY CHECKSUM GOUSE [SCD]GOIF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = N'PRIMARY') ALTER DATABASE [SCD] MODIFY FILEGROUP [PRIMARY] DEFAULTGO&lt;br /&gt;go&lt;br /&gt;sp_changedbowner 'sa'&lt;br /&gt;go&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-1413409583171039094?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/1413409583171039094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/post-for-beginners-how-to-create.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1413409583171039094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/1413409583171039094'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/post-for-beginners-how-to-create.html' title='A post for the beginners, How to create a database?'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/__zFxCqPcmaI/SWVpQsz3koI/AAAAAAAAACc/CFASY9jxn0w/s72-c/new+database.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-7600591743455861893</id><published>2009-01-07T17:16:00.000-08:00</published><updated>2009-02-16T05:08:21.333-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Truncate'/><category scheme='http://www.blogger.com/atom/ns#' term='DBCC'/><category scheme='http://www.blogger.com/atom/ns#' term='Transaction Log'/><category scheme='http://www.blogger.com/atom/ns#' term='DBCC Shrinkfile'/><category scheme='http://www.blogger.com/atom/ns#' term='DBCC Opentran'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>What to do if your transaction log feels up</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;In MSSQL your Tranlog will only fill out if your hard drive is full&lt;br /&gt;&lt;br /&gt;Before I show you how to shrink the Tran log I will explain a little about it and what the tranlog is for.&lt;br /&gt;&lt;br /&gt;The Transaction Log is Probably the most underutilized and underpperciated part of SQL. this is probably due to its simplicity.&lt;br /&gt;&lt;br /&gt;The transaction log can actually help to lower the server’s resources, increase productivity, all the while providing a method of an additional safety layer for you to fall back on!&lt;br /&gt;&lt;br /&gt;Why does the tran log exist?&lt;br /&gt;&lt;br /&gt;This history of the existence of the transaction log is difficult to trace; and is to a small degree controversial due to certain aspects are based on other applications. An example is the method to use transaction logs to restore databases is primarily based on proven methods used in Microsoft Access, which in turn is based on other application(s) and standards. This means there is no single document that states the history of Transaction Logs and most current documentation is partially based on personal experience, knowledge, and/or interpretations.&lt;br /&gt;I’ll make no attempt to determine the exact history of transaction logs. I just want to point out that transaction logs are largely based on Microsoft Access methods to store information for transactions. This is important to know because it has become a common misunderstanding that using the TRUNCATE command should not only remove old transaction information, but also should SHRINK the file down. This is absolutely, without a doubt…WRONG! I’ll get into this more as this article progresses. First, to be able to understand why TRUNCATE will not make the log smaller in physical size you will need to understand how the transactions are inserted into the log; both physically and logically.&lt;br /&gt;The primary purpose the transaction log is to provide a method to be able to restore a database to a point-in-time when necessary. This can include rolling back transactions to a certain time, or to roll forward transactions from a full backup restoration.&lt;br /&gt;In recent years the transaction log is starting to be used for additional purposes. They are being used in mirroring databases, quickly importing data from old database versions to a new database version, and security audits. This is just the tip of the iceberg for the way these logs are being utilized to gain “useful” information. The last point, security audits, is a more relatively new and undocumented (officially, that is) use of transaction logs. Information stored within transaction logs can be very powerful, but also tricky to learn at first while the structure and information being stored is new to you. If you take your time to learn what you can get out of the transaction log, you can produce very useful information that can help to increase your productivity (especially in the Security Audits area)!&lt;br /&gt;An example of how to use these logs for security audits is that you can view a transaction log and be able to detect transactions that have occurred and whom (what user or system account) had produced the transaction (this is no trivial task to accomplish); and if you know your database very well you can quickly deduce if someone is accessing parts of the database they shouldn't’t be; or even worse, if an unauthorized user has accessed your database! The techniques to use the transaction logs for security audits go beyond the scope of this article; the preceding is intended to provide a broader understanding of methods being used to obtain useful information. You can search sites such as MSDN, SQLServerCentral.com, and Google for discussions and articles detailing many different ways to audit the logs and obtain additional useful information. It is also worthwhile to note that there are 3rd party applications that utilize the transaction logs for security auditing, data movement, and many other purposes. As always, evaluate any 3rd party application when possible; and test on TEST servers before ever using new techniques or applications in a production environment.&lt;br /&gt;&lt;br /&gt;How the Transaction Log Works&lt;br /&gt;As mentioned in the “Logical Architecture (Concept)” portion, transactions are recorded into the log in a sequential manner. The LSN for each transaction will have a value that is higher than the previously written transaction. It’s actually just that simple; no complicated mathematical methods are used. There is no clever programming to add new transactions. It’s literally the same as taking a piece of paper and writing in each event that has happened in your day and using an ID number starting with 1 and increasing by 1 for each event occurring to give the order of the sequence. And just like your day, the next event that occurs to you must happen after the previous event; thus you’d give the next event a higher ID number than the previous. It’s safe to say that most of the following events have happened in this order for you to read this article:&lt;br /&gt;1) You told your computer to go to the link, or to open a document, containing this article.&lt;br /&gt;2) Your device displayed the article on your display, or printed the article to another format to be viewed.&lt;br /&gt;3) You started reading this article.&lt;br /&gt;As with these events, you can’t have the 2nd and 3rd events occur without first event obtaining the article, and you can’t read the article unless you view/print it (thus #3 can’t occur without #2 occurring first). As you can see, you can’t have these steps logged out of order to recreate this process; so each step has a higher ID number than the previous step.&lt;br /&gt;A transaction log is just exactly that in concept, a journal of events that occur within your database. The main points to remember here is that each event is given a LSN that is higher than the previous LSN (to keep track of what event happened in what sequence), and that there is enough information being stored so that SQL Server may recreate the event should a restore of the database be required.&lt;br /&gt;&lt;br /&gt;Microsoft Recommendations&lt;br /&gt;The Transaction Log is recommended, by Microsoft, to be located on a mirrored drive in a fault-tolerant storage system. It is also recommended, by many experts, to ensure that the log is located on its own physical hard drive. These two recommendations are based on the idea that should the database (or the hard drive holding the database) become corrupt that you can ensure that you have access to the Transaction Log during your recovery operation. Also, this setup will help to ensure you have minimal impact on your database performance due to the consistent writing to the Transaction Log; obviously to have a hard drive write to the database and then to write to the Transaction Log would require it to physically write twice. If the database and hard drive are on separate drives then each drive can only write once, thus improving your performance&lt;br /&gt;&lt;br /&gt;My recommendations&lt;br /&gt;&lt;br /&gt;I would recommend that you create a database and run allot of tests with large and small amounts of data to mimic a real life situation.&lt;br /&gt;I’d recommend starting off with a modest amount of space for your transaction log (ranging from 5% to 10% of the database size). The objective is to get a picture of how big the transaction log will need to be from regular usage. Assuming there are not any drastic unusual amounts of data being passed through the system, after about 3 full backups (using your regularly scheduled intervals) with NOT shrinking the log file, you can feel fairly confident in knowing the size the transaction log needs to be.&lt;br /&gt;&lt;br /&gt;It is common to use the log size being produced after the database has had enough regular usage data passed through plus another 10 – 20% of the transaction log size for small abnormal transactions and maintenance; such as a small number of records being archived (if archiving is done on a more regular basis, such as monthly or quarterly), additional tables are added later to hold new data requirements, or reports are being created and stored within the database. These are all concerns that are best addressed earlier in the development cycle; however, if the transaction log needs to be increased later that can always be accomplished by the administrator (or by SQL Server if left at defaults).&lt;br /&gt;Keep track of the log file size throughout the life span of the database; if you notice it grow suddenly then look into the cause. The highest concern would be a massive amount of data being modified (either from archiving, or even worse deleting); if either of these are the case then make sure that the transaction log is not truncated. You may find that you will need this to rollback that large transaction, if this occurred during a non-planned time (such as a misuse of the DELETE or DROP commands by a database user). This is where the transaction log can literally save your job!&lt;br /&gt;The last and probably most helpful recommendation I can give is to take a proactive approach to sizing your database’s transaction log file. Be generous in the amount of space you reserve for the transaction log. And most importantly if you expect (or even suspect) the log will need to be increased do this as soon as possible during off-peak hours; this will have the least amount of impact on your system and will result in the optimal performance of the system (while avoiding any unexpected performance degrading that might occur during peak hours!); remember that the less resources you utilize means the more resources that can be given to help your queries and reports!&lt;br /&gt;&lt;br /&gt;Ok so now you are thinking how do I shrink the log down here is how you do it.&lt;br /&gt;&lt;br /&gt;firstly you will need to kill the processes that are attached to the db.&lt;br /&gt;&lt;br /&gt;The process for clearing this is as follows&lt;br /&gt;&lt;br /&gt;1) dbcc opentran(database) - this will show the oldest open transaction&lt;br /&gt;&lt;br /&gt;2) Kill this process&lt;br /&gt;&lt;br /&gt;3) backup log database with no_log&lt;br /&gt;&lt;br /&gt;4) use database&lt;br /&gt;&lt;br /&gt;5) dbcc shrinkfile(database,100) - shrinks the log back to 100mb&lt;br /&gt;&lt;br /&gt;additional resources if needed&lt;br /&gt;TechNet: Working with Transaction Log Backups - &lt;a href="http://technet.microsoft.com/en-us/library/ms190440.aspx"&gt;http://technet.microsoft.com/en-us/library/ms190440.aspx&lt;/a&gt;TechNet: Restoring a Database to a Point Within a Backup - &lt;a href="http://technet.microsoft.com/en-us/library/ms190244.aspx"&gt;http://technet.microsoft.com/en-us/library/ms190244.aspx&lt;/a&gt;TechNet: Recovering to a Log Sequence Number (LSN) - &lt;a href="http://technet.microsoft.com/en-us/library/ms191459.aspx"&gt;http://technet.microsoft.com/en-us/library/ms191459.aspx&lt;/a&gt;TechNet: Best Practices for Recovering a Database to a Specific Recovery Point - &lt;a href="http://technet.microsoft.com/en-us/library/ms191468.aspx"&gt;http://technet.microsoft.com/en-us/library/ms191468.aspx&lt;/a&gt;TechNet: Security Considerations for Backup and Restore - &lt;a href="http://technet.microsoft.com/en-us/library/ms190964.aspx"&gt;http://technet.microsoft.com/en-us/library/ms190964.aspx&lt;/a&gt;MSDN: DBCC SHRINKFILE (Transact-SQL): &lt;a href="http://msdn.microsoft.com/en-us/library/ms189493.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms189493.aspx&lt;/a&gt;MSDN: DBCC SQLPERF (Transact-SQL): &lt;a href="http://msdn.microsoft.com/en-us/library/ms189768.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms189768.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-7600591743455861893?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/7600591743455861893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/what-to-do-if-your-transaction-log.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7600591743455861893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/7600591743455861893'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/what-to-do-if-your-transaction-log.html' title='What to do if your transaction log feels up'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6274021835416509041.post-3349654551999117829</id><published>2009-01-07T17:03:00.000-08:00</published><updated>2009-02-16T05:08:06.145-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL2005'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Sybase'/><title type='text'>SQL with Powershell</title><content type='html'>&lt;script type="text/javascript"&gt;&lt;br /&gt;var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");&lt;br /&gt;document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;try{&lt;br /&gt;var pageTracker = _gat._getTracker("UA-xxxxxx-x");&lt;br /&gt;pageTracker._trackPageview();&lt;br /&gt;} catch(err) {}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/__zFxCqPcmaI/SWVTLrHapEI/AAAAAAAAACM/-n_u01ceyxI/s1600-h/1504.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5288724797434012738" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 213px" alt="" src="http://4.bp.blogspot.com/__zFxCqPcmaI/SWVTLrHapEI/AAAAAAAAACM/-n_u01ceyxI/s320/1504.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;In this blog I will show you how you can connect to all your instances of sql within powershell. &lt;/div&gt;&lt;br /&gt;&lt;div&gt;Powershell is nice and seems to be popular these days. So I wrote a handy little tool to connect to instances through it. I think it is much quicker and easier to use this tool rather than remote desktop or open enterprise manager or sql server manager if you are just checking a server.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;here is the code&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;$file = get-content "file.txt"&lt;br /&gt;# checks file if not found then terminates&lt;br /&gt;if (-not($file)) { write-error($file+ " not found. Terminating .... "); exit}# matches the string ie type in any string for yout instance&lt;br /&gt;$match = $file Select-String (Read-Host "search string") # if the match is found then this will run the select if ($match.count -gt 0) { $inst = @() for ($i = 0; $i -lt $match.count; $i++) { $temp = "" $line = $match[$i].tostring() for ($j = $line.length-1; $j -ge 0; $j--) { if ($line[$j] -eq ":") { break } $temp = $line[$j] + $temp } $inst = $inst + $temp write-output ("Press "+($i+1)+" for : " + $inst[$i]) } $inp = "" $flag = "true" do { $inp = read-host("Enter choice : 1 - "+$match.count) if ($inp -lt 1 -or $inp -gt $match.count) { $flag = "false"; write-error ("Invalid entry. Enter between 1 - "+$match.count) } else { $flag = "true"; } } while ($flag -eq "false") write-output ("Logging on to the SQLSERVER you requested: "+$inst[$inp-1])      if ($inst[$inp-1] -ne "") {        $inst[$inp-1] + ""; sqlcmd -S $inst[$inp-1] -E    } }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Instructions&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;This Powershell script well allow you to search for any instance or sql server you have or have enterned in to the file. once you run this powershell script it will ask you for a string type in what ever instance you want it mssql then it will give you a number of instances you can then press 1 to what ever number the server is on and it will log you in. &lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;PS C:\CheckSQLServer\sql&gt; ./loginsql.ps1search string: IBTKYPSP32Press 1 for : IBTKYPSP32A006Press 2 for : IBTKYPSP32A017Press 3 for : IBTKYPSP32A021Press 4 for : IBTKYPSP32A026Press 5 for : IBTKYPSP32A028Press 6 for : IBTKYPSP32A031Press 7 for : IBTKYPSP32A100Press 8 for : IBTKYPSP32B017Press 9 for : IBTKYPSP32B026Press 10 for : IBTKYPSP32B031Press 11 for : IBTKYPSP32A034Press 12 for : IBTKYPSP32B034\HOSTED_P1Press 13 for : IBTKYPSP32A036\HOSTED_P1Press 14 for : IBTKYPSP32B037\HOSTED_P1Enter choice : 1 - 14: 14Logging on to the SQLSERVER you requested: IBTKYPSP32B037\HOSTED_P1IBTKYPSP32B037\HOSTED_P11&gt; sp_who2&gt; gospid ecid status loginamehostnamecmd requ------ ------ ------------------------------ -------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------- ----1 0 background sa&lt;br /&gt;RESOURCE MONITOR2 0 background sa&lt;br /&gt;RESOURCE MONITOR3 0 background sa&lt;br /&gt;RESOURCE MONITOR4 0 background sa&lt;br /&gt;RESOURCE MONITOR5 0 background sa&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6274021835416509041-3349654551999117829?l=sql2005ted.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sql2005ted.blogspot.com/feeds/3349654551999117829/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/sql-with-powershell.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/3349654551999117829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6274021835416509041/posts/default/3349654551999117829'/><link rel='alternate' type='text/html' href='http://sql2005ted.blogspot.com/2009/01/sql-with-powershell.html' title='SQL with Powershell'/><author><name>JapanGuide</name><uri>http://www.blogger.com/profile/16876114767286535250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/__zFxCqPcmaI/SWVE3iOxX3I/AAAAAAAAABw/JJEqyZUYOZE/S220/n223201339_466465_2377.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/__zFxCqPcmaI/SWVTLrHapEI/AAAAAAAAACM/-n_u01ceyxI/s72-c/1504.jpg' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
