Shawn Weisfeld

I find when I talk to myself nobody listens. - Shawn Weisfeld
posts - 365, comments - 180, trackbacks - 34

My Links


Shawn Weisfeld's Facebook profile

The views expressed in this blog are mine and mine alone, not that of my employer, Microsoft, or anyone else’s. No warrantee is given for the quality of any material on this site.


Post Categories

April 2008 Entries

Need to delete lots of data, do it in small chunks

By adding a top clause to your delete statement you can delete a chunk of records at a time. By combining it with a while you can put it in a loop and wipe the entire table. WHILE EXISTS (SELECT * FROM Foo) BEGIN DELETE TOP(100) FROM Foo END Had someone send me an email telling me that it might be better to use a TRUNCATE TABLE command then this method, and in most cases this is preferable. Conversly not always do us "evil" developers get TRUNCATE permissions from our DBA's. You can read more about TRUNCATE here (

posted @ Friday, April 25, 2008 6:55 PM | Feedback (0) | Filed Under [ SQL ]

Chage the colors on a button

Got a question from an attendee at the Orlando Launch Event, he wanted to know how to change the colors of a button from code (i.e. the click event). Both of these items are properties on the button and can be changed easily with the following code.   button1.ForeColor = System.Drawing.Color.Blue;button1.BackColor = System.Drawing.Color.Yellow;

posted @ Friday, April 25, 2008 3:51 PM | Feedback (0) | Filed Under [ .NET C# ]

Forcing Windows Auth on WCF services

At the last ONETUG meeting a question came up how to force WCF to use Windows Auth (i.e. Kerberos). By default WCF is in negotiate mode. While this is good for many cases where you cannot ensure that Kerberos will be available if you are in an intranet environment where you know it will be you can speed up your service by skipping the negotiation phase.  Matevz Gacnik has a good sample in his blog (,guid,4b5f46cd-3c15-4213-9570-1a235c4a615e.aspx) using certificates, the only change is to set the clientCredentialType to “Windows”. <bindings>   <wsHttpBinding>      <binding name="MySecureBinding">         <security mode ="Message">            <message clientCredentialType="Windows" negotiateServiceCredential="false"/>         </security>      </binding>   </wsHttpBinding></bindings>

posted @ Wednesday, April 23, 2008 1:26 PM | Feedback (0) | Filed Under [ WCF ]

Drop Me!

I was trying to get rid of all the objects (tables, procedures, views) in my database and whipped up this little script and while it is far from perfect it is well worth sharing. . . SELECT  CASE WHEN type = 'P' THEN 'DROP PROCEDURE ' + name       WHEN type = 'U' THEN 'DROP TABLE ' + name   WHEN type = 'V' THEN 'DROP VIEW ' + name      WHEN type = 'FN' THEN 'DROP FUNCTION ' + name    ELSE '' END AS dropSQL, * FROM sys.objects WHERE type != 'S' AND type != 'IT' AND type != 'SQ'

posted @ Saturday, April 12, 2008 10:03 PM | Feedback (0) | Filed Under [ SQL ]

Powered by: