Archive for March, 2011

Renaming a SQL constraint

Yes, it happens to all of us – we spell a SQL constraint incorrectly. But luckily, it’s an easy fix, as I found on SQL Server Torque:

EXEC sp_rename N'[dbo].[MyTable].[PK_WrongSpelling]', N'PK_RightSpelling', N'INDEX' GO

That’s it, not more tears.

Advertisements

Leave a comment

Formatting a time to show zero hours in a GridBoundColumn

I had an issue where the time inside a Telerik GridBoundColumn control was displaying the incorrect time. The value from the database was correct, and was 3/6/2011 00:00. However, in the control, the value was being displayed at 3/6/2011 12:00. That’s, like, twelve hours off! That’s no good.

The issue was the DataFormatString value of the GridBoundColumn. It was set to {0}. Instead, I changed it to:

{0:M/d/yyyy HH:mm}

This explicitly set the time, and the value was then showing correctly as 3/6/2011 00:00.

BTW, the final GridBoundColumn definition looked like this:

<telerik:GridBoundColumn UniqueName="LastUpdateDate" DataField="LastUpdateDate" 
DataFormatString="{0:M/d/yyyy HH:mm}"></telerik:GridBoundColumn>

Leave a comment