Friday, October 9, 2009

How to get the Column information for a Table using T-SQL

in this sample I am getting the column information for a table called ‘Account’:

SELECT     Columns.name AS ColumnName, ColumnTypes.name AS Type, Columns.prec AS Precision, Columns.scale AS Scale, 
Columns.isnullable AS IsNullable
FROM sys.sysobjects AS Tables INNER JOIN
sys.syscolumns AS Columns ON Columns.id = Tables.id INNER JOIN
sys.systypes AS ColumnTypes ON Columns.xtype = ColumnTypes.xtype
WHERE (Tables.type = 'U') AND (Tables.name = N'Account')
ORDER BY ColumnName

Why do ASP.NET control events fire more than once?

I’ve always wondered about this and here is the answer:

ASP.NET controls recreates their hierarchy (at a minimum) twice during a single request to the server:

  1. First when the control is being restored to a it's previous state.
  2. Second when all the required modifications are applied.