<?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-2087645504317960940</id><updated>2012-02-16T06:19:36.961-08:00</updated><category term='Analysis Services'/><category term='DropBox'/><category term='BAM Tools'/><category term='google app engine'/><category term='MOSS 2007'/><category term='Create item'/><category term='Discussion Board'/><category term='BizTalk'/><category term='rough counter'/><category term='sharded counter'/><category term='distributed computing'/><category term='WSS'/><category term='Installation'/><category term='Configuration'/><title type='text'>Albert's notes on development and performance</title><subtitle type='html'>My personal notes and development and performance tuning. Maybe you can find something interesting here too?</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>29</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-7110622619086430167</id><published>2011-05-15T07:05:00.000-07:00</published><updated>2011-05-15T07:25:37.237-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sharded counter'/><category scheme='http://www.blogger.com/atom/ns#' term='rough counter'/><category scheme='http://www.blogger.com/atom/ns#' term='google app engine'/><title type='text'>Rough counters on Google App Engine</title><content type='html'>On Google App Engine the maximum frequency of updates for a single database entity is limited. If you need to count something with high frequency such as page views on a web site or similar you need to do some magic to manage it.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The solution found in documents by Google is to use &lt;b&gt;sharded counters&lt;/b&gt;. The principle is that you have several database entities, pick one at random and update that entity. The number of updates possible scales with the number of entities you use. However to get the value of the counter you need to get all entities and sum them. Also the code to do this is a bit complex. You pay for that complexity with cpu-resources.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you need a counter that allows a high update frequency but don't want the fuzz of &lt;b&gt;sharded counters&lt;/b&gt; and it doesn't matter if you occasionally miss a count or two there is a better solution. For some of my applications I instead use &lt;b&gt;rough counters&lt;/b&gt;. The basic principle is that you let your instance cache the counts locally and occasionally write the counter to the database. You'll waste far less resources, you can read the value of the counter directly.&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Note: If your instance shuts down you loose the current counter value, the error whill likely be less than a tenth of a percent, but it isn't exact.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import javax.jdo.JDOObjectNotFoundException;&lt;br /&gt;import javax.jdo.PersistenceManager;&lt;br /&gt;import javax.jdo.annotations.IdGeneratorStrategy;&lt;br /&gt;import javax.jdo.annotations.NotPersistent;&lt;br /&gt;import javax.jdo.annotations.PersistenceCapable;&lt;br /&gt;import javax.jdo.annotations.Persistent;&lt;br /&gt;import javax.jdo.annotations.PrimaryKey;&lt;br /&gt;&lt;br /&gt;@PersistenceCapable(detachable="true")&lt;br /&gt;public class RoughCounter {&lt;br /&gt; @PrimaryKey&lt;br /&gt; @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)&lt;br /&gt; private String mName;&lt;br /&gt; &lt;br /&gt; @Persistent&lt;br /&gt; private long mRoughCount;&lt;br /&gt; &lt;br /&gt; @NotPersistent&lt;br /&gt; private long mLastUpdate;&lt;br /&gt; &lt;br /&gt; public RoughCounter(String name) {&lt;br /&gt;  mName = name;&lt;br /&gt;  mRoughCount = 0;&lt;br /&gt;  mLastUpdate = 0;&lt;br /&gt; }&lt;br /&gt;    &lt;br /&gt; public void increase() {&lt;br /&gt;      mRoughCount += 1;&lt;br /&gt;      if (mLastUpdate &gt; System.currentTimeMillis() - 10 * 1000) return;&lt;br /&gt;      mLastUpdate = System.currentTimeMillis();&lt;br /&gt;     &lt;br /&gt;      long count = mRoughCount;&lt;br /&gt;      mRoughCount -= count;&lt;br /&gt;     &lt;br /&gt;  PersistenceManager pm = PMF.get().getPersistenceManager();&lt;br /&gt;  try {&lt;br /&gt;   RoughCounter rc = pm.getObjectById(RoughCounter.class, mName);&lt;br /&gt;   rc.mRoughCount += count;&lt;br /&gt;   pm.makePersistent(rc);&lt;br /&gt;  } catch (JDOObjectNotFoundException ex) {&lt;br /&gt;   RoughCounter c = new RoughCounter(mName);&lt;br /&gt;   c.mRoughCount += count;&lt;br /&gt;   pm.makePersistent(c);&lt;br /&gt;  } finally {&lt;br /&gt;   pm.close();&lt;br /&gt;  }&lt;br /&gt; }    &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This counter writes the results to the database around once every ten seconds. The counting can occur at &lt;b&gt;ANY&lt;/b&gt; speed, this is not depending on database performance, only on execution speed which is extremely high in comparison to database update performance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-7110622619086430167?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/7110622619086430167/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2011/05/rough-counters-on-google-app-engine.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7110622619086430167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7110622619086430167'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2011/05/rough-counters-on-google-app-engine.html' title='Rough counters on Google App Engine'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-7617241265668900176</id><published>2011-04-19T03:50:00.000-07:00</published><updated>2011-04-19T03:52:31.894-07:00</updated><title type='text'>Key value store on Google App Engine</title><content type='html'>Just created a quick hack to use Google App Engine (GAE) as a simple key value store with a nice rest api. This allows usage as a data store for web applications and also a flexible way to serve web sites. It can also be used as an application server with similar thinking to CouchApp.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Have a look at:&lt;/div&gt;&lt;div&gt;&lt;a href="https://github.com/AlbertBertilsson/GAE-KVS"&gt;https://github.com/AlbertBertilsson/GAE-KVS&lt;/a&gt;&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/2087645504317960940-7617241265668900176?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/7617241265668900176/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2011/04/key-value-store-on-google-app-engine.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7617241265668900176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7617241265668900176'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2011/04/key-value-store-on-google-app-engine.html' title='Key value store on Google App Engine'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-4501727442242223268</id><published>2011-01-20T04:10:00.000-08:00</published><updated>2011-01-20T04:14:47.209-08:00</updated><title type='text'>Sums in Microsoft Excel</title><content type='html'>I often use MS Excel (2007) to evaluate data... simple and convenient for many cases...&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Unless you try to sum several integer values and they exceed 1'000'000'000'000'000. By then Excel starts losing precision. I'd expect 64bit integer math to work correctly, but it doesn't!&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/2087645504317960940-4501727442242223268?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/4501727442242223268/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2011/01/sums-in-microsoft-excel.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4501727442242223268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4501727442242223268'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2011/01/sums-in-microsoft-excel.html' title='Sums in Microsoft Excel'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-1504762171011907781</id><published>2010-11-23T04:01:00.000-08:00</published><updated>2010-11-23T04:33:55.165-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='distributed computing'/><category scheme='http://www.blogger.com/atom/ns#' term='DropBox'/><title type='text'>DropBox distributed computing</title><content type='html'>Nothing beats a free lunch. One tool that is getting more and more important to me is DropBox. Great tool to use for storing and sharing your files across many desktops and project members.&lt;br /&gt;&lt;br /&gt;Anything else... yes why not use it as a distributed computer? Because after all we all know that if you can leave GUI-stuff and infrastructure out of it many things are really simple.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;What I did:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Create one folder DistributedComputer&lt;br /&gt;This will be shared with everybody that runs a node. Share this with all persons trusted to run a computing node for you.&lt;br /&gt;&lt;br /&gt;In it place all the stuff you need to pick a job start an executable that does the processing and then write the stuff to a directory.&lt;br /&gt;&lt;br /&gt;I used one large text-file to contain all the parts of the problem and two directories for tracking: Started and Done. A simple program picks a random problem (important to make it random) and starts another program that then starts the calculation, a file is created in the Started folder with the problem id as name. When the calculation is finished a file is created in the Done folder with the problem id as name and the output as content.&lt;br /&gt;&lt;br /&gt;Super simple and it works!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Some notes:&lt;/span&gt;&lt;br /&gt;Picking a random problem is important. If a node loses network connection it can still keep work on randomly selected problems with small risk of duplicating work. If picking the problems in sequence all nodes without network connection would duplicate their work.&lt;br /&gt;&lt;br /&gt;The program that picks the problem and starts the program to solve the program should of course verify that the problem isn't already started (known by checking the Started directory) or done. If there are no problems left that aren't started pick a problem that at least isn't done already.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The real beauty of it:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Coding some simple commandline tools that works with files is really simple. It is also much less work to make them platform independent if needed.&lt;/li&gt;&lt;li&gt;DropBox will handle tracking for you. Can see which computer created the file and when a problem started and was done.&lt;/li&gt;&lt;li&gt;You can easily continue with refinements and optimization of your program to solve the problem, each time a new problem is picked the executable is reloaded, all you need to do is put a new executable in the shared folder.&lt;/li&gt;&lt;li&gt;Zero code for communication and synchronization, only two directories to check for status.&lt;/li&gt;&lt;li&gt;All members can easily follow the project and participate. This is really nice since it makes it easy for everybody to follow the project and contribute with improvements.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;Issues:&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Size limits, 2GB isn't huge but it should cover a decent set of problems. For the results, if they are big just have two files in the done folder one to mark the problem done and one with the actual results. Then you can gather all the results and process them as they appear and then delete them.&lt;/li&gt;&lt;li&gt;Since the files are shared there is potential for users grab the komplete results.&lt;/li&gt;&lt;li&gt;There is also a risk for users to wreck your files and data, not very nice in a internet project with thousands of users, but quite ok if you are doing this with some friends.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-1504762171011907781?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/1504762171011907781/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2010/11/dropbox-distributed-computing.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/1504762171011907781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/1504762171011907781'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2010/11/dropbox-distributed-computing.html' title='DropBox distributed computing'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-7123945472647905853</id><published>2010-09-24T08:51:00.001-07:00</published><updated>2010-09-24T08:54:06.288-07:00</updated><title type='text'>jQuery download performance</title><content type='html'>Bandwidth for free and more speed for everyone! Don't put the jQuery scripts on your own server, trust in Google and let them serve the scripts.&lt;br /&gt;&lt;br /&gt;Link too:&lt;br /&gt;&lt;a href="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Ref:&lt;br /&gt;&lt;a href="http://softwareas.com/google-jquery-cdn"&gt;http://softwareas.com/google-jquery-cdn&lt;/a&gt;&lt;br /&gt;&lt;a href="http://royal.pingdom.com/2010/05/11/cdn-performance-downloading-jquery-from-google-microsoft-and-edgecast-cdns/"&gt;http://royal.pingdom.com/2010/05/11/cdn-performance-downloading-jquery-from-google-microsoft-and-edgecast-cdns/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-7123945472647905853?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/7123945472647905853/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2010/09/jquery-download-performance.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7123945472647905853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7123945472647905853'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2010/09/jquery-download-performance.html' title='jQuery download performance'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-1478323808442760785</id><published>2009-09-23T12:00:00.000-07:00</published><updated>2009-09-23T12:15:22.361-07:00</updated><title type='text'>BusinessConnectorTest</title><content type='html'>Warning! This note only makes sense for the Dynamics Ax developers out there. Specifically if you are setup up Enterprise Portal or something similar that uses the .Net Business Connector to connect to Ax.&lt;br /&gt;&lt;br /&gt;A simple tool for verifying if you have a working Business Connector .Net setup.&lt;br /&gt;&lt;br /&gt;Download it &lt;a href="http://www.albert.nu/programs/businessconnectortest/BusinessConnectorTest.zip"&gt;here&lt;/a&gt;. To run it you need the 13MB Microsoft.Dynamics.BusinessConnectorNet.dll, version 5.0.1 (2009, SP1) in the program directory.&lt;br /&gt;&lt;br /&gt;Basically the code looks like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using Microsoft.Dynamics.BusinessConnectorNet;&lt;br /&gt;&lt;br /&gt;namespace BusinessConnectorTest&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                Microsoft.Dynamics.BusinessConnectorNet.Axapta DynAx = new Microsoft.Dynamics.BusinessConnectorNet.Axapta();&lt;br /&gt;                Microsoft.Dynamics.BusinessConnectorNet.AxaptaRecord DynRec;&lt;br /&gt;&lt;br /&gt;                DynAx.Logon(null, null, null, null);&lt;br /&gt;                Console.WriteLine("Logon successful!");&lt;br /&gt;                &lt;br /&gt;                DynRec = DynAx.CreateAxaptaRecord("CustTable");&lt;br /&gt;                Console.WriteLine("Create record successful!");&lt;br /&gt;                &lt;br /&gt;                DynRec.ExecuteStmt("select firstonly * from %1");&lt;br /&gt;                Console.WriteLine("Select successful!");&lt;br /&gt;                Console.WriteLine(string.Format("Recid: {0}", DynRec.get_Field("RECID")));&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine(ex.Message);&lt;br /&gt;                Console.WriteLine(ex.StackTrace);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Very simple, but still handy to have. The catch is the good part :). Gives you an idea of what is wrong.&lt;br /&gt;&lt;br /&gt;This code uses the current user to logon. Use "runas" to change user.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-1478323808442760785?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/1478323808442760785/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/09/businessconnectortest.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/1478323808442760785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/1478323808442760785'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/09/businessconnectortest.html' title='BusinessConnectorTest'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-8549157110150152844</id><published>2009-09-11T02:02:00.000-07:00</published><updated>2009-09-11T02:04:27.999-07:00</updated><title type='text'>Find out the name of the AD server</title><content type='html'>Ever wondered which machine is the AD server of the machine you are using?&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;echo %logonserver%&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Will tell you the machine name of the AD server or simply give you the current machine name back if you are not connected to a domain.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-8549157110150152844?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/8549157110150152844/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/09/find-out-name-of-ad-server.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/8549157110150152844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/8549157110150152844'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/09/find-out-name-of-ad-server.html' title='Find out the name of the AD server'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-6732884781710815152</id><published>2009-09-10T08:42:00.000-07:00</published><updated>2009-09-10T08:46:19.426-07:00</updated><title type='text'>SetSPN</title><content type='html'>The lovely little tool setspn...&lt;br /&gt;&lt;br /&gt;It has different command for different versions (new commands in windows server 2008).&lt;br /&gt;&lt;br /&gt;It has very little error checking so it allows you to register duplicate SPN's which will ruin your kerberos authentication.&lt;br /&gt;&lt;br /&gt;The nice view command "setspn -l &lt;argument&gt;" allows you to specify both a machine or a user as argument. The results are different and does not show the same information.&lt;br /&gt;&lt;br /&gt;Beware!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-6732884781710815152?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/6732884781710815152/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/09/setspn.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/6732884781710815152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/6732884781710815152'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/09/setspn.html' title='SetSPN'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-7571870517656045934</id><published>2009-09-08T07:30:00.000-07:00</published><updated>2009-09-08T07:34:00.639-07:00</updated><title type='text'>Verify Kerberos in a SQL Server installation</title><content type='html'>Use the SQL Server Management Studio, connect to the server (note you must NOT do this locally on the server). Execute this T-SQL:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SELECT auth_scheme FROM sys.dm_exec_connections WHERE session_id = @@spid;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;It will return either "NTLM" or "KERBEROS".&lt;br /&gt;&lt;br /&gt;More on Kerberos will follow...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-7571870517656045934?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/7571870517656045934/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/09/verify-kerberos-in-sql-server.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7571870517656045934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7571870517656045934'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/09/verify-kerberos-in-sql-server.html' title='Verify Kerberos in a SQL Server installation'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-4351404565589765326</id><published>2009-04-04T11:32:00.001-07:00</published><updated>2009-04-04T11:35:36.195-07:00</updated><title type='text'>DYM - Did You Mean?</title><content type='html'>&lt;a href="http://1.bp.blogspot.com/_sKECuCnAYoA/SdeoCbo2NQI/AAAAAAAAAAw/UnoUv90EjH4/s1600-h/search.PNG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5320906244493817090" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 201px" alt="" src="http://1.bp.blogspot.com/_sKECuCnAYoA/SdeoCbo2NQI/AAAAAAAAAAw/UnoUv90EjH4/s320/search.PNG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I coded a web part to present the user with "Did you mean ...?" suggestions in Microsoft Search Server Express. For more information see the complete web part information at my home page. &lt;a href="http://www.albert.nu/programs/dym"&gt;http://www.albert.nu/programs/dym&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-4351404565589765326?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/4351404565589765326/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/04/dym-did-you-mean.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4351404565589765326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4351404565589765326'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/04/dym-did-you-mean.html' title='DYM - Did You Mean?'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_sKECuCnAYoA/SdeoCbo2NQI/AAAAAAAAAAw/UnoUv90EjH4/s72-c/search.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-8120229207092385661</id><published>2009-04-01T00:39:00.000-07:00</published><updated>2009-04-01T00:45:09.829-07:00</updated><title type='text'>WSS safe upload hack</title><content type='html'>Find the upload.aspx file in 12\TEMPLATE\LAYOUTS and change the "OverwriteSingle" checkbox to this:&lt;br /&gt;&lt;br /&gt;...asp:CheckBox id="OverwriteSingle" &lt;strong&gt;Visible="false" Checked="false"&lt;/strong&gt;...&lt;br /&gt;&lt;br /&gt;The checkbox will not be visible and if a duplicate document is selected the user will get an error instead of overwriting the existing file.&lt;br /&gt;&lt;br /&gt;NOTE: This is hack of the standard out of the box solution.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-8120229207092385661?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/8120229207092385661/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/04/wss-safe-upload-hack.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/8120229207092385661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/8120229207092385661'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/04/wss-safe-upload-hack.html' title='WSS safe upload hack'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-4642554350530731396</id><published>2009-03-18T14:18:00.000-07:00</published><updated>2009-03-18T14:22:50.819-07:00</updated><title type='text'>Stored procedure result into a table...</title><content type='html'>Needed to kill a large range of spid's today... but how can that be done in a simple and flexible way?&lt;br /&gt;&lt;br /&gt;Well, put the result of sp_who2 into a table, do a select from that table to generate one column with the text 'kill &lt;spid&gt;'. And then copy paste the result and run it.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;declare @sp_who table&lt;/em&gt;&lt;br /&gt;&lt;em&gt;(&lt;/em&gt;&lt;br /&gt;&lt;em&gt;spid  smallint, &lt;/em&gt;&lt;br /&gt;&lt;em&gt;status nchar(30), &lt;/em&gt;&lt;br /&gt;&lt;em&gt;loginame nchar(128), &lt;/em&gt;&lt;br /&gt;&lt;em&gt;hostname nchar(128),&lt;/em&gt;&lt;br /&gt;&lt;em&gt;blkby  char(5),&lt;/em&gt;&lt;br /&gt;&lt;em&gt;dbname nchar(128),&lt;/em&gt;&lt;br /&gt;&lt;em&gt;cmd  nchar(16),&lt;/em&gt;&lt;br /&gt;&lt;em&gt;cputime int,&lt;/em&gt;&lt;br /&gt;&lt;em&gt;diskio int,&lt;/em&gt;&lt;br /&gt;&lt;em&gt;lastbatch varchar(20),&lt;/em&gt;&lt;br /&gt;&lt;em&gt;program nchar(128),&lt;/em&gt;&lt;br /&gt;&lt;em&gt;spid2  smallint,&lt;/em&gt;&lt;br /&gt;&lt;em&gt;requestid int&lt;/em&gt;&lt;br /&gt;&lt;em&gt;)&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;insert into @sp_who execute sp_who2&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;select * from @sp_who&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Modify the final select to suit your needs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-4642554350530731396?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/4642554350530731396/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/03/stored-procedure-result-into-table.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4642554350530731396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4642554350530731396'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/03/stored-procedure-result-into-table.html' title='Stored procedure result into a table...'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-2906816813325169814</id><published>2009-03-07T06:19:00.000-08:00</published><updated>2009-03-07T06:26:37.674-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Discussion Board'/><category scheme='http://www.blogger.com/atom/ns#' term='Create item'/><category scheme='http://www.blogger.com/atom/ns#' term='WSS'/><category scheme='http://www.blogger.com/atom/ns#' term='MOSS 2007'/><title type='text'>WSS Create Discussion Board item</title><content type='html'>Creating and manipulating ordinary lists in WSS through the object model is easy, and finding examples on the web is also easy. But what about discussion boards?&lt;br /&gt;&lt;br /&gt;Turns out that they are not as easily manipulated, and examples are very hard to find. After much browsing I found this information though:&lt;br /&gt;&lt;a href="http://blogs.msdn.com/sfellman/archive/2007/12/17/issue-programmatically-posting-wss-2007-discussion-list-items-shows-sender-as-system-account-in-outlook-2007.aspx"&gt;http://blogs.msdn.com/sfellman/archive/2007/12/17/issue-programmatically-posting-wss-2007-discussion-list-items-shows-sender-as-system-account-in-outlook-2007.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Use this code:&lt;br /&gt;&lt;em&gt;using Microsoft.Sharepoint.Utilities;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;SPListItem item = SPUtility.CreateNewDiscussion(&lt;list&gt;.Items, "&lt;subject&gt;");&lt;/em&gt;&lt;br /&gt;&lt;em&gt;item["Body"] = "&lt;text&gt;";&lt;/em&gt;&lt;br /&gt;&lt;em&gt;item.Update();&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;There is a corresponding method to add discussion replies:&lt;br /&gt;&lt;em&gt;SPUtility.CreateNewDiscussionReply(item);&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-2906816813325169814?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/2906816813325169814/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/03/wss-create-discussion-board-item.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/2906816813325169814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/2906816813325169814'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/03/wss-create-discussion-board-item.html' title='WSS Create Discussion Board item'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-7753981590189201475</id><published>2009-03-03T23:46:00.000-08:00</published><updated>2009-03-03T23:57:27.416-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BizTalk'/><category scheme='http://www.blogger.com/atom/ns#' term='BAM Tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Configuration'/><category scheme='http://www.blogger.com/atom/ns#' term='Analysis Services'/><category scheme='http://www.blogger.com/atom/ns#' term='Installation'/><title type='text'>BizTalk installation/configuration</title><content type='html'>During the installation of BAM Tools you have an option to "Enable Analysis Services for BAM aggregations". When I tried to configure BizTalk the other day this part simply wouldn't work.&lt;br /&gt;&lt;br /&gt;The error displayed looked like this:&lt;br /&gt;Either the '&lt;username&gt;' user does not have permission to create a new object in '&lt;database&gt;', or the object does not exist.&lt;br /&gt;&lt;br /&gt;This seemed odd to me because the previous parts of the configuration had successfully created several databases with the same user account.&lt;br /&gt;&lt;br /&gt;So what's the problem then? Almost embarrasing... analysis services uses its own port, not the standard 1433 sql server port. So after add the required port to the firewall rules everything worked as expected.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-7753981590189201475?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/7753981590189201475/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/03/biztalk-installationconfiguration.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7753981590189201475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7753981590189201475'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/03/biztalk-installationconfiguration.html' title='BizTalk installation/configuration'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-5419430542689164600</id><published>2009-01-21T00:22:00.000-08:00</published><updated>2009-03-03T23:34:15.269-08:00</updated><title type='text'>Use SQL Server trace to find problems on other servers!</title><content type='html'>The trace tool in SQL Server is mostly used to find performance problems related to SQL Server. But it is also a great tool to find performance problems in application servers and web servers.&lt;br /&gt;&lt;br /&gt;The general way of thinking is this: Even if your SQL Server is doing fine what impact does the information flow have on other parts of the system? It is not unusual that the SQL Server is the most powerful machine in the system, allowing it to cope with huge loads of requests.&lt;br /&gt;&lt;br /&gt;If you see either large amounts of requests to SQL Server or fewer requests but with large amounts of data try to figure out how the application manages this information. The life of an application server is not that simple, by knowing the SQL Server requests you can figure out what it is doing and maybe make it easier on both the application server and SQL Server.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-5419430542689164600?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/5419430542689164600/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2009/01/use-sql-server-trace-to-find-problems.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/5419430542689164600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/5419430542689164600'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2009/01/use-sql-server-trace-to-find-problems.html' title='Use SQL Server trace to find problems on other servers!'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-4186190435169994805</id><published>2008-11-13T03:02:00.000-08:00</published><updated>2009-03-03T23:34:15.376-08:00</updated><title type='text'>Filtered indexes in SQL Server 2008</title><content type='html'>Ok, a great feature as it is... a great performance booster when applied correctly. I'm not gonna repeat what others have written, google it!&lt;br /&gt;&lt;br /&gt;But what I really like about it is that is solves the age old problem of applying a uniqueness requirement to all but (and usually that is all but null values or something similar).&lt;br /&gt;&lt;br /&gt;The classic solution to this problem is of course to use a trigger to verify uniqueness, to make that trigger run fast it requires an index. Instead of the mess of a complete index (larger than we need) and extra code in the form of a trigger that adds complexity and steals more performance we simply apply a filtered index.&lt;br /&gt;&lt;br /&gt;Example, we want to make sure that socialid is unique if it is not null:&lt;br /&gt;&lt;em&gt;create table Person (id int identity(1,1) primary key, name nvarchar(100), socialid nvarchar(20))&lt;br /&gt;&lt;br /&gt;insert into Person (name, socialid) values ('Albert', '1234'), ('Bengt', null), ('Christian', '2341'), ('Dan', null)&lt;br /&gt;&lt;br /&gt;create unique index idx_socialid on Person (socialid) where socialid is not null&lt;br /&gt;&lt;br /&gt;select * from Person&lt;br /&gt;&lt;br /&gt;insert into Person (name, socialid) values ('Eric', '1234')&lt;/em&gt;&lt;br /&gt;Inserting the person named Eric will fail since the socialid is not unique.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-4186190435169994805?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/4186190435169994805/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2008/11/filtered-indexes-in-sql-server-2008.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4186190435169994805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4186190435169994805'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2008/11/filtered-indexes-in-sql-server-2008.html' title='Filtered indexes in SQL Server 2008'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-5853253840374034841</id><published>2008-06-24T06:08:00.000-07:00</published><updated>2009-03-03T23:34:15.391-08:00</updated><title type='text'>StatementCompare</title><content type='html'>Since I often do optimization of procedures or other changes it is nice to be able to verify if a stored procedure returns the same data now as compared to another version. So I wrote a quick hack to make that comparison.&lt;br /&gt;&lt;br /&gt;Checks select statements or multiple resultsets from stored procedures. Verifies order of tuples if checkbox option for that is checked. Doesn't verify return values or row counts from insert/update/delete.&lt;br /&gt;&lt;br /&gt;Can be found here:&lt;br /&gt;&lt;a href="http://albert.nu/programs/statementcompare"&gt;http://albert.nu/programs/statementcompare&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-5853253840374034841?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/5853253840374034841/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2008/06/statementcompare.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/5853253840374034841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/5853253840374034841'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2008/06/statementcompare.html' title='StatementCompare'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-4599677877041046319</id><published>2008-05-29T11:19:00.000-07:00</published><updated>2009-03-25T12:06:04.317-07:00</updated><title type='text'>When to optimize</title><content type='html'>When getting an optimization task for someone I always try to start as wide as possibly. What type of machine are you running on? What is displayed by the task manager etc... Quickly start a trace to see what is actually happening and then view some DMV's to spot issues.&lt;br /&gt;&lt;br /&gt;I've found that quite often the trace shows statements or procedures that by them selves eat up tons of resources. In case you find a top five of tasks that use in the range of 30% or more of cpu or io resources then optimize! Even if these tasks aren't causing locks or other problems it will be such a significant improvement to your client that they will notice.&lt;br /&gt;&lt;br /&gt;As a side effect the entire database will run much smoother afterwards and with less load the risk of locks etc will decrease. These tasks are often easy to optimize since you will almost always benefit from trading insert/update/delete cost to select cost by removing or adding indexes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-4599677877041046319?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/4599677877041046319/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2008/05/when-to-optimize.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4599677877041046319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4599677877041046319'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2008/05/when-to-optimize.html' title='When to optimize'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-4778492921205847399</id><published>2008-05-22T06:15:00.000-07:00</published><updated>2009-03-03T23:34:15.425-08:00</updated><title type='text'>Performance monitor doesn't lie!</title><content type='html'>Yesterday I worked on optimizing a database for a client... I had a pretty nice optimization of a stored proceedure in place... that's what I thought at least. Using a computed column with an index I could do direct lookups instead of searching large amounts of text data and when testing the procedure in management studio the execution plan was perfect and IO was reduced from 50k to less than 50 :). But server load didn't drop as expected so I fired up performance monitor and started a trace... guess what the procedure was still running with poor performance.&lt;br /&gt;&lt;br /&gt;After some tinkering it was obvious that the application code failed to get the correct execution plan for reasons still unknown (maybe access rights or some weird ansi-option related to the computed column, a did a simple workaround and it worked like out fine.&lt;br /&gt;&lt;br /&gt;Lesson learned: There is a difference between successful optimization when running the procedure in management studio and actually applying it to a running application.&lt;br /&gt;&lt;br /&gt;When in doubt trust performance monitor.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-4778492921205847399?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/4778492921205847399/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2008/05/performance-monitor-doesn-lie.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4778492921205847399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4778492921205847399'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2008/05/performance-monitor-doesn-lie.html' title='Performance monitor doesn&amp;#39;t lie!'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-4284178143135139854</id><published>2008-05-15T23:05:00.000-07:00</published><updated>2009-03-03T23:34:15.468-08:00</updated><title type='text'>Drop a database</title><content type='html'>The drop syntax is rarely useful since there is always someone using the database... and I always seem to forget the lines needed to set the database in single user mode.&lt;br /&gt;&lt;br /&gt;This works:&lt;br /&gt;&lt;br /&gt;ALTER DATABASE xxx SET SINGLE_USER WITH ROLLBACK IMMEDIATE &lt;br /&gt;&lt;br /&gt;USE master &lt;br /&gt;&lt;br /&gt;DROP DATABASE xxx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-4284178143135139854?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/4284178143135139854/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2008/05/drop-database.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4284178143135139854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4284178143135139854'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2008/05/drop-database.html' title='Drop a database'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-3294901182400680609</id><published>2008-05-15T05:54:00.000-07:00</published><updated>2009-03-03T23:34:15.481-08:00</updated><title type='text'>Really basic stuff...</title><content type='html'>Remember that:&lt;br /&gt;@Variable like Column&lt;br /&gt;Is not the same as:&lt;br /&gt;Column like @Variable&lt;br /&gt;&lt;br /&gt;Really basic, but sometimes even basic stuff can cause a mess.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-3294901182400680609?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/3294901182400680609/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2008/05/really-basic-stuff.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/3294901182400680609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/3294901182400680609'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2008/05/really-basic-stuff.html' title='Really basic stuff...'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-3350232615848718254</id><published>2008-04-04T05:12:00.000-07:00</published><updated>2009-03-03T23:34:15.495-08:00</updated><title type='text'>Comma separated string of values...</title><content type='html'>/*&lt;br /&gt;Note that if the values that are supposed to be comma separated can contain&lt;br /&gt;comma signs it is a good idea to replace those with something else before&lt;br /&gt;generating the list&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;declare @list nvarchar(max)&lt;br /&gt;set @list = ''&lt;br /&gt;select @list = @list + ',' + replace(ColumnName,',','.') from TableName&lt;br /&gt;set @list = substring( @list , 2, 10000000 )&lt;br /&gt;select @list&lt;br /&gt;&lt;br /&gt;--Simpler versions when handling id's&lt;br /&gt;--Quite quick&lt;br /&gt;declare @list varchar(max)&lt;br /&gt;set @list = ''&lt;br /&gt;select @list = @list + ',' + convert(varchar(10), ColumnName) from TableName&lt;br /&gt;set @list = substring( @list , 2, 10000000 )&lt;br /&gt;select @list&lt;br /&gt;&lt;br /&gt;--Much quicker version (notable only when generating very long lists)&lt;br /&gt;declare @list varchar(max)&lt;br /&gt;set @list = (select ',' + convert(varchar(10), ColumnName) from TableName for xml path(''))&lt;br /&gt;set @list = substring(@list , 2, 10000000 )&lt;br /&gt;select @list&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-3350232615848718254?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/3350232615848718254/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2008/04/comma-separated-string-of-values.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/3350232615848718254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/3350232615848718254'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2008/04/comma-separated-string-of-values.html' title='Comma separated string of values...'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-6222249938903120098</id><published>2008-01-14T09:38:00.000-08:00</published><updated>2009-03-03T23:34:15.526-08:00</updated><title type='text'>Reseeding those identity fields...</title><content type='html'>DBCC CHECKIDENT ( table_name, [reseed / noreseed], [new_seed_value])&lt;br /&gt;&lt;br /&gt;DBCC CHECKIDENT ( 'dbo.tTable', RESEED, 14000000)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-6222249938903120098?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/6222249938903120098/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2008/01/reseeding-those-identity-fields.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/6222249938903120098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/6222249938903120098'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2008/01/reseeding-those-identity-fields.html' title='Reseeding those identity fields...'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-7780716133647328689</id><published>2007-12-23T09:04:00.000-08:00</published><updated>2009-03-03T23:34:15.541-08:00</updated><title type='text'>Temporary tables again!</title><content type='html'>I seem to find myself optimizing lots and lots of old Sql Server 2k code. Often these procedures are relying heavily on temporary tables.&lt;br /&gt;&lt;br /&gt;Adding a clustered index to a temporary can be a real boost but sometimes other tools are needed. Indexes on temporary tables are possible by adding unique indexes during table definition. Unless the values are already unique this requires adding a duplicate key breaker example:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;create table #temp&lt;br /&gt;(&lt;br /&gt;   x int,&lt;br /&gt;   y int&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Transforms into:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;create table #temp&lt;br /&gt;(&lt;br /&gt;   id int identity(1,1) not null,&lt;br /&gt;   x int,&lt;br /&gt;   y int,&lt;br /&gt;   primary key clustered (id),&lt;br /&gt;   unique (x,id),&lt;br /&gt;   unique (y,id)&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-7780716133647328689?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/7780716133647328689/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2007/12/temporary-tables-again.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7780716133647328689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/7780716133647328689'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2007/12/temporary-tables-again.html' title='Temporary tables again!'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-4699306213135594690</id><published>2007-12-23T09:02:00.000-08:00</published><updated>2009-03-03T23:34:15.569-08:00</updated><title type='text'>Get reliable execution results</title><content type='html'>To get komparable results remember to execute:&lt;br /&gt;DBCC DROPCLEANBUFFERS&lt;br /&gt;(Empty data cache)&lt;br /&gt;&lt;br /&gt;and:&lt;br /&gt;DBCC FREEPROCCACHE&lt;br /&gt;(Empty SP cache)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-4699306213135594690?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/4699306213135594690/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2007/12/get-reliable-execution-results.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4699306213135594690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/4699306213135594690'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2007/12/get-reliable-execution-results.html' title='Get reliable execution results'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-2826751933888825471</id><published>2007-12-06T01:19:00.000-08:00</published><updated>2009-03-03T23:34:15.588-08:00</updated><title type='text'>Just a reminder!</title><content type='html'>&lt;p&gt;&lt;br /&gt;Don't forget that SQL server can work as your simple calculator or runtime environment to test out small pieces of code.&lt;br /&gt;&lt;br /&gt;As calculator:&lt;br /&gt;&lt;pre&gt;print 135 * 3.24&lt;br /&gt;&lt;br /&gt;Prints:&lt;br /&gt;437.40&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Or figuring out if your idea of calculating factorial is ok:&lt;br /&gt;&lt;pre&gt;declare @l int&lt;br /&gt;set @l = 0&lt;br /&gt;&lt;br /&gt;while @l &lt;= 100&lt;br /&gt;begin&lt;br /&gt; declare @res float&lt;br /&gt; set @res = 1.0&lt;br /&gt;&lt;br /&gt; declare @i int&lt;br /&gt; set @i = 1&lt;br /&gt; while @i &lt;= @l&lt;br /&gt; begin&lt;br /&gt;  set @res = @res * @i&lt;br /&gt;  set @i = @i + 1&lt;br /&gt; end&lt;br /&gt; print str(@l)+'! = ' + convert(varchar(50),@res)&lt;br /&gt; set @l = @l + 1&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Prints:&lt;br /&gt;         0! = 1&lt;br /&gt;         1! = 1&lt;br /&gt;         2! = 2&lt;br /&gt;         3! = 6&lt;br /&gt;         4! = 24&lt;br /&gt;         5! = 120&lt;br /&gt;         ...&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-2826751933888825471?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/2826751933888825471/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2007/12/just-reminder.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/2826751933888825471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/2826751933888825471'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2007/12/just-reminder.html' title='Just a reminder!'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-6874344296409323899</id><published>2007-12-02T07:40:00.000-08:00</published><updated>2009-03-03T23:34:15.609-08:00</updated><title type='text'>Batch aborting errors</title><content type='html'>Some errors are so serious that they can't be handled like normal errors. Example:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;begin try&lt;br /&gt;   -- Do something (the task you want to perform)&lt;br /&gt;end try&lt;br /&gt;begin catch&lt;br /&gt;   -- Do something (log error, rollback transaction etc)&lt;br /&gt;end catch&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You might think that any error will be caught in the catch-clause allowing you to log the error and rollback any open transaction. This is WRONG!!! Some errors are batch aborting, this means that immediatly when they are encountered they stop the processing, rollback any transaction and close the connection. An example of a batch aborting error is to access an object that doesn't exist.&lt;br /&gt;&lt;br /&gt;This shouldn't be an issue since SQL Server will do necessary cleaning, only problem is that your fancy code for logging the error will not be executed.&lt;br /&gt;&lt;br /&gt;I've seen one example when SQL Server for some reason doesn't manage to abort the transaction, this was a big problem. Taking a backup and restore it would solve this problem, strange... no errors where reported by DBCC CHECKDB but the restore helped.&lt;br /&gt;&lt;br /&gt;More information on:&lt;br /&gt;http://www.sommarskog.se/error-handling-I.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-6874344296409323899?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/6874344296409323899/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2007/12/batch-aborting-errors.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/6874344296409323899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/6874344296409323899'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2007/12/batch-aborting-errors.html' title='Batch aborting errors'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-185753203816760718</id><published>2007-11-22T12:22:00.000-08:00</published><updated>2009-03-03T23:34:15.624-08:00</updated><title type='text'>Temporary tables and primary keys!</title><content type='html'>Use primary keys without names for temporary tables!&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;pre&gt;create table #test&lt;br /&gt;(&lt;br /&gt;   id int,&lt;br /&gt;   data int,&lt;br /&gt;   primary key clustered (id)&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;drop table #test&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Naming the primary key causes issues because Sql Server can complain that the primary key already exists (funny for a temporary table).&lt;br /&gt;&lt;br /&gt;Try this example in two different sessions:&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Session 1:&lt;/u&gt;&lt;br /&gt;create table #test&lt;br /&gt;(&lt;br /&gt;id int,&lt;br /&gt;data int,&lt;br /&gt;constraint PK_test primary key clustered (id)&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Session 2:&lt;/u&gt;&lt;br /&gt;create table #test&lt;br /&gt;(&lt;br /&gt;id int,&lt;br /&gt;data int,&lt;br /&gt;constraint PK_test primary key clustered (id)&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;Without a name for the PK it will work though.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-185753203816760718?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/185753203816760718/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2007/11/temporary-tables-and-primary-keys.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/185753203816760718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/185753203816760718'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2007/11/temporary-tables-and-primary-keys.html' title='Temporary tables and primary keys!'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2087645504317960940.post-8977963479538098383</id><published>2007-11-22T12:01:00.000-08:00</published><updated>2009-03-03T23:34:15.640-08:00</updated><title type='text'>So this is.... what!?</title><content type='html'>A small set of useful notes for a particular Sql Server developer (me).&lt;br /&gt;&lt;br /&gt;The point?&lt;br /&gt;&lt;br /&gt;1. To have it easily accessible.&lt;br /&gt;2. To possibly get some comments on the issues, best case scenario is to get better solutions as comments than the ones I find myself.&lt;br /&gt;3. To spread some knowledge (who am I kidding?)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2087645504317960940-8977963479538098383?l=albertsnotes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://albertsnotes.blogspot.com/feeds/8977963479538098383/comments/default' title='Kommentarer till inlägget'/><link rel='replies' type='text/html' href='http://albertsnotes.blogspot.com/2007/11/so-this-is-what.html#comment-form' title='0 kommentarer'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/8977963479538098383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2087645504317960940/posts/default/8977963479538098383'/><link rel='alternate' type='text/html' href='http://albertsnotes.blogspot.com/2007/11/so-this-is-what.html' title='So this is.... what!?'/><author><name>Albert Bertilsson</name><uri>http://www.blogger.com/profile/07472414629222124990</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_sKECuCnAYoA/Sa4xGwRQsNI/AAAAAAAAAAM/vEG4EAnN2Io/S220/HS.jpg'/></author><thr:total>0</thr:total></entry></feed>
