Wednesday, January 23, 2008

I was reading this article from a http://www.digg.com link (sorry I lost the link to the article) about how to be a faster developer and at the top of the list is becoming very good at your editor.  The author pointed out that the hot keys (the ability to navigate and execute commands without using your mouse) where essential.  I agree with him, the more you have to move your mouse the less you can type and it is a real waste of time going between the mouse and the keyboard.  However, he was ranting about EMACS and of course the Windows programmer's editor of choice is Visual Studio.

My favorite hot keys right now in Visual Studio:

Ctrl K-D : To reformat the code.  Type whatever I want, not tabs, no enter. Ctrl K-D and it is formatted correctly.

Ctrl M-O : To collapse all the regions.  Finish a bug fix, Ctrl M-O to collapse, Run Unit Test, Handle Exception in Code (automatically expands) and ignore all the collapsed code.

Ctrl F : For Quick Find.  I use find so much -- just have to hot key.

Ctrl-Atl-F : For Find in Files.

Ctrl H : For Quick Replace

Ctrl-Atl H: For Replace in Files.

Home / Ctrl-Shift-End : For Selecting All.  This works in most Microsoft products.

Ctrl -Arrows : For moving by expression as compared to the arrows which move my character.  Walk the XML quickly scanning for what I want to edit.  Press the control key to highlight (while Ctrl-Arrowing), and then delete to remove that whole word.

Ctrl-J: Reactivate Intellisense.  I use this all the time, cut and paste some text into a case sensitive language like C#, Ctrl-J to find the class with the same name -- different case, and press Enter to select it from the Intellisense list.

/// : For adding comments to method and properties. Thanks Andy.

However, this one: Ctrl-Tab is awesome.  I read about it in this MSDN Blog: http://blogs.msdn.com/vbteam/archive/2008/01/09/3-did-you-know-ctrl-tab-to-navigate-windows-in-vs-lisa-feigenbaum.aspx.  It allows you to select any open window (much like Atl-Tab in Windows).

{6230289B-5BEE-409e-932A-2F01FA407A92}

Wednesday, January 23, 2008 11:19:39 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, January 22, 2008

In C# we can have nullable types, like this:

Boolean? isValid;

Which means that isValid can be true, null, or false.  It is like a three way switch.  I use it to represent a bit field in SQL Server that can have a null value.  For example I might have this table:

CREATE TABLE Account (IsValid bit)

Which creates me a table with a bit column that can be NULL.  I usually don't like to do this -- in fact I never do, however I am working with some people that don't bother to check the NOT NULL when they use the designer so I have to deal with it in my C# code.  So I ask the table designer what NULL means in the IsValid coulmn and he tells me it means false (not valid).

So I query the database and set the result to isValid, in the C# class above.  So now I need to check to see if the account is valid.  It might seem like this would work:

if (isValid) {...}

However, that throws a compiler error, becuase you can't have Nullable type default expression.  So I have to do this:

if (isValid == true) { }

Notice that the second statement is really saying that the expresion fails if the IsValid is false or null.  This is also the same but weak:

If ((isValid!=null) && (((Boolean)isValid)==true)) { }

{6230289B-5BEE-409e-932A-2F01FA407A92}

 

C# | Wayne
Tuesday, January 22, 2008 9:18:07 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
 Monday, January 21, 2008

"When you program by yourself do you use source control?"

What I want to hear is that they use source control.  Source control -- even by yourself -- is an important tool that helps you backtrack out of coding tangents that fail.  Hosted on another server it is a valuable form of backup off your own box.  It also shows that the person has programmed in a shop where source control was enforced (rightfully so) and understand how it beneficial it is.

 

Monday, January 21, 2008 7:28:36 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  | 
 Friday, January 18, 2008

Another programming tip in the article I read was to keep a task list for the work left in your programming project and work off it.  Most projects are so large that you can't keep track of all the loose ends.  I have never had trouble keeping track of the loose ends of a project when my head is in it -- however I know the day is coming soon.

Being a former Microsoft employee and Microsoft being an email culture (at least when I was there in 1997), I use my Inbox to keep track of all my tasks.  Ten years ago it was around 200 emails -- all that needed action.   I was alright with that since I got 100-400 emails a day I was keeping them under 200 and everything was good.  About 5 years ago the inbox topped 300 emails and I was still alright with that -- keeping them paired down and knowing I would never clear it completely -- remember all 300 required action.  At the end of 2007 I had 400 emails in the inbox and I knew there was a problem -- so I set about clearing my inbox.  I have only cleared my inbox once in the past.

I just got done today.  It took me 40 hours to clear all the emails, about 10 emails and hour.  40 hours performing the email task, replying or just making tough decisions and deleting them. 

My typical daily process: my inbox usually has newest at the top and everyday I work from the top down.  Most of the time I reach the last email I didn't take action on yesterday and then work ten or so farther down.  However most of those require a reply from someone and I get discourage.  On Monday I try to follow-up or work all of last weeks emails and all of Mondays. 

So here is my tip list for clearing your inbox:

  1. Start at the oldest email and work up.  The newer emails are ones that you are waiting for a reply.  The oldest ones (in my case a year old) are ones you are never getting a reply on, i.e. easier to delete.
  2. If you have a customer question you didn't answer within a month -- they are no longer a customer, delete the email.
  3. Delete all the emails forward by your mother-in-law which you didn't think of something witty to reply back.  Following up after 6-months will not earn you any points.
  4. Sort by subject -- sometimes there is a ten email thread that you already handled which you can delete.  It also allows you to easily scan for the same types of emails which you missed deleting the first time they came by.  It also breaks the reply mental block
  5. Delete the email you sent to yourself with articles you wanted to read -- you just don't have time obviously.
  6. If you really can't decide to delete it -- leave it for the end -- the more you do this the more you want to delete it.
  7. Finish the small tasks you meant to do however put off -- they are small will not take you long, and you can delete that task email.
  8. It is never to late to reply to a friend and go to lunch.  Reply with dates that work and delete -- you don't have to handle that task until they write back.
  9. Make well named folder and move the email.  If it is a reference article, customer feedback, or FAX you need to save get it organized.

Good Luck

{6230289B-5BEE-409e-932A-2F01FA407A92}

 

 

Friday, January 18, 2008 8:02:40 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

There is no reason, NONE WHATSOEVER, for updating SVN (or any other source code repository) with code that does not compile.  There are 2 rules for version control that are both #1:

1. Check code in frequently
1. Don't check projects in unless they compile

Some argue that this isn't a good practice (1 #2 above) but let me explain.  Let's say you are working on a distributed team and there are 3 people working on a project.  Team members 1 & 2 are working on a class library for a web project.  They figure they are done for the day and check in the code that they worked on. Team member 3 (me) wants to check out this class library when working on a new & unrelated project.

I add this library to my project, do my thing, build. WTF? 57 Errors and 2 warnings.  I should see 0 Errors and 2 warnings.  Warnings are usually harmless and a lot that I have seen lately stem from converting 1.x websites to 2.0, 3.5 projects and usually have something to do with obsolete code (which is still compatibile).  So now there are a couple of problems.  First of all, I have to get my project to compile, which means fixing YOUR code.  Then, I have to check the code in that I fixed. Then, I  have to recompile my project and continue to try and be in a good mood while I am pissed that I had to waste anywhere from 5 minutes to sometimes an hour or more (then I get really pissed!).

"Well I didn't want to write the method that reflects my object and creates an instance of T."

You don't have to. This will do:

public static T GetRecord<T>(List<IDbDataParameter> parameters, string commandText)
{
   return Activator.CreateInstance<T>();

Or the following if you don't want the possibility of bugs slipping through the cracks due to incomplete data (which will never happen if you implement some sort of Unit Testing Framework but that is a whole other topic).

public static T GetRecord<T>(List<IDbDataParameter> parameters, string commandText)
{
   throw new NotImplementedException("Not done yet");

Another beef is when people add references to .DLL's that will break the build.  Adding .DLL references is commonplace, especially if you use 3rd party solutions or existing class libraries.  This can break builds also.  I learned this after making a mistake once where I downloaded a control to my desktop and added the reference from there.  The next person to check out my code didn't have that assembly on his desktop and it broke his build.  A workaround for this is to have a Dependencies folder within a project that is the central location for all these add-on assemblies.  That way when a developer adds a reference the next person who checks the code out (or updates their existing codebase) will be able to hit the ground running.

Again, code doesn't have to be bug-free or work like it's supposed to.  As long as it compiles when I update my code I am happy.  It is impossible to check in code that works as it should every day (i.e. conversion projects).

Friday, January 18, 2008 12:20:25 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  | 
 Thursday, January 17, 2008

The ClientID property is my favorite property this week and will definitely reshape how I write asynchronous functionality in the future.  I learned about this while adding some functionality to a client's site earlier this week.  The original site was created off-shore and people like me are the ones who get to take care of it.  It's been fun so far and had I not been working on this site this week I would've totally overlooked this wonderful property.

First off, ClientID is a readonly property (as it should be!) that does nothing more than get you the id of the control that is rendered.  Take the following rendered RequiredFieldValidator.

<span id="datalistContent_ctl05_requiredDescription" style="color:Red;visibility:hidden;">I saw what you did there.</span> 

Not quite the same as my original "requiredDescription" ID set in the .aspx.  When this control was processed this original ID was appended to the UniqueID created for this control. ASP.NET does this to make sure that there are unique id's for controls and this process is especially prevalent in Repeaters, DataLists, and GridViews.  Most of you probably knew that.  As you can tell from the HTML above my "requiredDescription" was in my DataList called "datalistContent" in the 5th generated table cell ("ctl05").

So how will this help me with asynchronous programming, cleaner UI's, etc, etc?  If you're familiar with the ItemDataBound event of the Repeater, DataList, Gridview controls then you can probably see why. Let's say I have a DataList that contains a TextBox and a HyperLink.  The Description property of my object is displayed in a multi-line textbox with a CSS style attribute (see below) that makes it appear to be normal text (i.e. can't see the border, scrollbars, etc..).  The link that reads "Change Description" should enable the already-disabled textbox, hide the link, apply a TextBox-like style, and focus the cursor on this newly-enabled TextBox.  After editing the text the onblur event triggers a client-side function that disables the textbox and adds the disabled, plain-ole-text feeling CSS, then display the link again for changing the description.  It's actually easier than it sounds (demo below). Take the following example (ps. If this were production code I would use e.Item.FindControl("string") as Foo and check for null before adding attributes):

protected void ItemDataBound(object sender, DataListItemEventArgs e)
{
   TextBox text = (TextBox) e.Item.FindControl("textDescription");
   HtmlAnchor link = (HtmlAnchor) e.Item.FindControl("linkChangeDescription");

   text.Attributes.Add("style", "border: none 0px #fff; overflow: hidden; width: 250px;");   
   text.Attributes.Add("onblur", string.Format("Blur('{0}', '{1}');", text.ClientID, link.ClientID));   
   link.Attributes.Add("onclick", string.Format("Edit('{0}', '{1}');", text.ClientID, link.ClientID));
}

Those JavaScript functions consist of a whopping 6 lines so I won't paste here.  If you are curious, leave a comment and I will send you a download link to AspNetAjaxLolSike.csproj. Quick tangent, if you are into Internet memes check out LOLCode.  Chances are you you have been on the receiving end of an image such as this or this.  Think of a programming language with that vernacular. Try-Catch = Hai-KThnxBye.  ANYWAY, that's where the LolSike project name came from as I spent a good 2-3 hours laughing uncontrollably at the user-submitted codebase at LOLCode.  Some guys at Microsoft actually created a compiler for it, which I have yet to track down.

Anyway, that code will render as follows with the appropriate client-side id of the ASP.NET Control from our code-behind:

<a href="#" id="datalistContent_ctl04_linkChangeDescription" onclick="Edit('datalistContent_ctl04_textDescription', 'datalistContent_ctl04_linkChangeDescription');">Change Description</a><br />
<textarea name="datalistContent$ctl04$textDescription" rows="2" cols="20" id="datalistContent_ctl04_textDescription" disabled="disabled" class="hidden" onblur="Blur('datalistContent_ctl04_textDescription', 'datalistContent_ctl04_linkChangeDescription');" style="border: none 0px #fff; overflow: hidden; width: 250px;">Hai 5</textarea><br /> 

Moving on, I came across exploring this functionality after getting tired of finding solutions requiring a Postback (i.e. asp:LinkButton control).  This, as far as I'm concerned: sucks.  The next best option was to wrap the datalist in an UpdatePanel.  That is wrong on so many levels.  My general attitude towards the UpdatePanel is that it generally sucks 80% - 90% of the time.  80% - 90% may seem like a large number and I will explain my feelings.  The UpdatePanel is a slippery slope of bad practices (imho) for those that want to start with asynchronous technologies.  I say this because most of those that use it (80% - 90%) don't know WHEN to use it.  I can't tell you how many times I've seen someone wrap a DataGrid of 100+ records (with update, add, delete functionality) in an UpdatePanel.  Set up a project in Visual Studio that has a textbox and button in an update panel.  On "postback" set the textbox to the current date time (DateTime.Now) and use Firebug or Fiddler to check out the size of the response.  It will probaby surprise you.  I'm not saying that if you use an UpdatePanel you suck at AJAX.  By no means do I consider myself the authority figure on asynchronous programming.

You can add a button to this (hidden if there are no records in your IEnumerable<T>) to give your application "Update" functionality.  Your button OnClick event would then check all the DataListItem's in the DataList, cast your DataListItem.Item.DataItem to type T, interpret the data, and process accordingly by way of some class library. Easy.

Notice that there are no postbacks when I edit the descriptions in my DataList.

ClientID Demo

When I get some more time I will explore the avenue of asynchronous GridView paging.  I have never used the GridView so I'll have to be REALLY motivated to try.  I only used this in the DataList because I needed to display columns based on user input and treated the DataList as a Repeater with Columns functionality.

.net | C# | Will
Thursday, January 17, 2008 6:03:04 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

Intermitently my code was getting this Exception: "System.ArgumentException: An item with the same key has already been added."  The code looked like this:

if (!_roleTypeNameDict.ContainsKey(roleTypeName))
_roleTypeNameDict.Add(roleTypeName, ...)

Since I have done a lot of C++ programming right away I realized that I had a threading issue, however the question was why? It just so happens this was a static method, calling a static property, which means that more then one thread might be accessing _roleTypeNameDict at a time:

private static Dictionary<String, RoleTypes> _roleTypeNameDict
   = new Dictionary<string, RoleTypes>();

public static RoleTypes FindCachedRoleTypesFromRoleTypeName(String roleTypeName)
{

if (!_roleTypeNameDict.ContainsKey(roleTypeName))
       _roleTypeNameDict.Add(roleTypeName, ...);
...
}

To solve the issue you need to create a lock to protect the check to add from the add like this:

private static Dictionary<String, RoleTypes> _roleTypeNameDict
   = new Dictionary<string, RoleTypes>();
private
static object _roleTypeNameDictLock = new object(); public static RoleTypes FindCachedRoleTypesFromRoleTypeName(String roleTypeName) {    lock (_roleTypeNameDictLock) {    if (!_roleTypeNameDict.ContainsKey(roleTypeName))       _roleTypeNameDict.Add(roleTypeName, ...); }
   ...
}

However, you can make the code slightly faster if you assume that the ContainKey is less expense then the lock from a performance stand point:

private static Dictionary<String, RoleTypes> _roleTypeNameDict
   = new Dictionary<string, RoleTypes>();
private static object _roleTypeNameDictLock = new object();

public static RoleTypes FindCachedRoleTypesFromRoleTypeName(String roleTypeName)
{
   if (!_roleTypeNameDict.ContainsKey(roleTypeName))
   {
      lock (_roleTypeNameDictLock)
      {
         if (!_roleTypeNameDict.ContainsKey(roleTypeName))
            _roleTypeNameDict.Add(roleTypeName, ...);
      }
   }
   ...
}

What we are doing here is checking to see if we need to add, then locking, then checking again, then adding.  This prevents us from locking if we don't need to add-- the majoirty of the cases, however it also prevents two threads from trying to add at the same time.

I was just thinking the other day that threading, caching, and memory management skills where still needed in .NET even though the Microsoft PR machines is making C# out to be much easier then C++.  At the same time VBScript programmers in classic ASP don't have to worry about threading issues.

{6230289B-5BEE-409e-932A-2F01FA407A92}

 
 
C# | Wayne
Thursday, January 17, 2008 8:53:30 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, January 16, 2008

Let's say you forgot a WHERE clause and want to restore your backup database to recover the lost data.  However, you don't want to override the data that has accumulated since the last back-up.  What you need to do is restore the backup along side the newer database.  Here is how to do it:

RESTORE DATABASE backup
   FROM 'C:\temp\lastbackup.bak'
   WITH MOVE 'mydb_Data' TO 'C:\MySQLServer\backupdb.mdf',
   MOVE 'mydb_Log' TO 'C:\MySQLServer\backupdb.ldf';

This statement tells the SQL server to create a database called "backup", from the lastbackup.bak file and not to use the files stored in the back-up, but instead use: backupdb.mdf and backupdb.ldf.  Unless you remap your backup files, the RESTORE will try to override the old files that are in use by the newer database -- which will cause a SQL Server error (not data loss).


{6230289B-5BEE-409e-932A-2F01FA407A92}

Wednesday, January 16, 2008 7:43:40 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

Just finished a little app to have a treeview control the file system navigation for images to be displayed in the AJAX Slide Show provided in the Microsoft AJAX Control toolkit. A www.15seconds.com articles about the application will be posted soon.

.net | C# | Dina
Wednesday, January 16, 2008 10:22:55 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, January 15, 2008

Detaching a database in SQL Server doesn't delete the files (.ldf, .mdf, .ndf) where the data is stored.  Deleting a database is different then detaching a database.  Detaching allows you to move the files and reattach them to a different SQL Server.  However, once you detach a database it is not available to query.

{6230289B-5BEE-409e-932A-2F01FA407A92}

Tuesday, January 15, 2008 7:37:18 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, January 14, 2008

My brother called, he had forgotten a WHERE clause and had lost some data.  I felt really bad for him -- the kind of sinking feeling you get when someone you know has a death in the family.  I can relate -- I have forgotten a few WHERE clauses in the past couple of years.  Right after he called I checked my database backups to make sure they where still running every night.

This reminded me of one of my favorite interview questions: "Tell me about the last time you forgot a WHERE clause?"  I am looking for that sinking recognition that takes place when someone knows the question and can relate.  And if they have never forgotten a WHERE clause -- I just know they haven't programmed much T-SQL, cause we all do it from time to time.  I also want to hear how they recovered their data and what they are doing differently to prevent the problem.  A developer I know at work always writes the WHERE clause before he writes the DELETE or UPDATE line just to prevent the aforementioned.

Maybe SQL Management tool should have an optional warning that makes you confirm that you want to run a DELETE or UPDATE when there is no WHERE clause?

{6230289B-5BEE-409e-932A-2F01FA407A92}

 

T-SQL | Wayne
Monday, January 14, 2008 7:34:38 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, January 11, 2008

I've been reading a couple of renditions of this SessionWrapper class via DotNetKicks over the past couple of days.  While I must admit that this code isn't 100% original, I can say that I have given it a more generic feel and added a little bit of functionality.  With my implementation you can not only use any class, you can specify a name for the session object.  That way if you want to store say the Account and Order objects in Session you could use the same method without creating a wrapper for each type.

using System.Web;

namespace NamespaceNameGoesHere
{
   public class Session<T> where T: class
   
{
      private string _name = string.Empty;

      public string Name
      {
         get { return _name; }
         set { _name = value; }
      }

      public T Object
      {
         get { return HttpContext.Current.Session[Name] as T ?? null; }
         set { HttpContext.Current.Session[Name] = value; }
      }

      public Session(string name)
      {
         _name = name;
      }

      public Session()
      {
      }
   }
}

Pretty straight-forward. Here's how you would use it from a Page_Load for example:

Session<Foo> session = new Session<Foo>("Foo");

if (session.Object == null)
   session.Object = new Foo(-1, "hai guyz!");
else
{
   Foo foo = session.Object;

Not cutting-edge but could be useful if you want a type-safe session state.

.net | C# | Will
Friday, January 11, 2008 3:46:40 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

Lately I have doing a lot of SSRS and overall SQL work for a project.  In returning some data to process server-side my data retrieval method was returning null* which means that an exception was thrown. I did a little digging around and then decided to execute the stored procedure manually (i.e. Management Studio).  After debugging in Visual Studio and seeing what the values were and that they were in fact getting passed to the stored procedure I used the same signature to execute the proc in Management Studio.  Hmm, no dice.   My error message was of a "Divide-By-Zero" fashion.  This is the first time that I have ever seen this.  A little reading on the subject and I come to find out that the field used as the denominator allowed nulls.

Enter NULLIF. This is what saved the day.  This function will compare two values and return a null value if the expressions are equal.  For example, take the following dummy stored procedure.

CREATE Procedure SharesCalculateSharePrice
(
   
@shareId int,
   
@numberOfUnits decimal
)

AS

DECLARE @totalPrice decimal

SET @totalPrice = ( SELECT TotalPrice FROM Shares WHERE ShareId = @shareId )
DECLARE @returnValue decimal

SET @returnValue = ( @numberOfUnits / @totalPrice )
SELECT @returnValue 

Pretty basic. I'm selecting the total price from a table and using as the denominator.  I pass in number of units. To get price per unit (share price) I divide one by the other. What if the @totalPrice is 0? Then I get the dreaded Divide-By-Zero error.  Using NULLIF, we can make a trivial aleration to the above procedure and return a NULL value instead.

CREATE Procedure SharesCalculateSharePrice
(
   
@shareId int,
   
@numberOfUnits decimal
)

AS

DECLARE @totalPrice decimal

SET @totalPrice = ( SELECT SUM(TotalPrice) FROM Shares WHERE ShareId = @shareId )
DECLARE @returnValue decimal

SET @returnValue = ( @numberOfUnits / NULLIF(@totalPrice, 0) )
SELECT @returnValue 

Easy. If @totalPrice is 0 we will substitute with a null value.  This way the returnValue will be NULL and we can process accordingly from our .NET application.

public static object ExecuteScalar(List<IDbDataParameter> parameters, string commandText)
{
   using (DBManager manager = new DBManager(_provider, _connectionString))
   {
      manager.Open();
      manager.CreateParameters(parameters.Count);

      for (int i = 0; i < parameters.Count; ++i)
         manager.AddParameters(i, parameters[i].ParameterName, parameters[i].Value);

      object returnValue = manager.ExecuteScalar(CommandType.StoredProcedure, commandText);

      return returnValue == DBNull.Value || returnValue == null ? -1 : returnValue;
   }

There could be even more useful ways to use NULLIF but for me this has worked out fine.

T-SQL | Will
Friday, January 11, 2008 8:41:10 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  | 
 Thursday, January 10, 2008

If you have some legacy tables you where you want to convert from having a primary key of int to a primary key of uniqueidentifier, you need to do a lot of work.  Here are the steps:

1) Drop all forigen keys contraints that points to the table being modified.

2) Drop all views that reference the table being modified.

3) Drop all indexes that use the primary key or any forigen key column that points to the table being modified.

4) Rename all the old forigen key column that points to the table being modified, so that we can add a new column with the original name of type uniqueidentifier.

5) Drop the primary key contraints on the table being modified.

6) Add a new forigen key column to all tables where there was a forigen key column that points to the table being modified of the same name with a type of uniqueidentifier.  Make then NULL

7) Rename the primary key of the table being modified -- the int column.

8) Add a new column with the original primary key name of type of uniqueidentifier.

9) Fill all rows with the new primary key column using the function NewId()

10) Update all the new forigen key column with the new primary key using the old forigen key column bound to the old primary key on the new table.

11) Alter all the new forigen key column to NOT NULL where the original forigen key column was NULL.

12) Rebuild all indexes, including the primary key index on the new columns

13) Rebuild all forigen keys.

14) Rebuild all views.

Good Luck

{6230289B-5BEE-409e-932A-2F01FA407A92}

T-SQL | Wayne
Thursday, January 10, 2008 4:02:23 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |