Monthly Archives: August 2007

Temporary Tables vs. Table Variables and Their Effect on SQL Server Performance

Temporary Tables vs. Table Variables and Their Effect on SQL Server Performance There are three major theoretical differences between temporary tables: create table #T (…) And table variables: declare @T table (…) The first difference is that transaction logs are not recorded for the table variables. Hence, they are out of scope of the transaction […]

Assigning Attributes to child controls of a CheckBoxList

  Step 1:   Create a class library project   Step 2:   using System;   using System.Collections.Generic; using System.Text; using System.Globalization; using System.Web.UI; using System.Web.UI.WebControls;     namespace CheckBoxListExCtrl {  public class CheckBoxListExCtrl :CheckBoxList, IRepeatInfoUser {   void IRepeatInfoUser.RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)  {      writer.WriteBeginTag(“input”);      writer.WriteAttribute(“type”, “checkbox”);      writer.WriteAttribute(“name”, […]

Return in C#

Methods can return a value to the caller. If the return type, the type listed before the method name, is not void, then the method can return the value using the return keyword. A statement with the keyword return followed by a value that matches the return type will return that value to the method […]

Count(*) and Count(columnName)

COUNT(*) returns the total number of rows in the table, while COUNT(expression) returns the number of rows where the result of the expression is not NULL. Naturally, COUNT(DISTINCT expression) means that duplicates are only counted once. This means that COUNT( ) can return different results depending on how you write it

SQL JOIN

–drop table t1,t2,t3 create table t1(f1 int)create table t2(f1 int)create table t3(f1 int)–=========================== set nocountondeclare @j intset @j = 1while @j <= 10begin insertinto t1 values(@j)set @j = @j + 1end –=========================== set nocountondeclare @k intset @k = 6while @k <= 15begin insertinto t2 values(@k)set @k = @k + 1end –=========================== insert into t3 values(6)insert […]

SQL Server Tips

    query based on Table:tblemp(eid,mid,sal)   Q:write a query to Select Manager Name and emplyee Name from tblemp table Ans:select e1.[name] ename,e2.[name] mnane from tblemp e1,tblemp e2 where e1.mid=e2.eid   Q:Write a query where employee earns more than their managers. Ans:select e1.[name] ename,e2.[name] mnane from tblemp e1,tblemp e2 where e1.mid=e2.eid and e1.sal>e2.sal     […]

CustomValidator in asp.net 2.0

The ValidateEmptyText property, new in ASP.NET 2.0, fixes an issue with CustomValidator. In ASP.NET 1.0 custom validation would not fire if ValidationText was empty. You can set this property to true to cause custom validation to occur for empty input values. ex: <asp:TextBox ID=”txtno” runat=”server”></asp:TextBox> <asp:CustomValidator ID=”CV1″ ValidateEmptyText=”true” ValidationGroup=”reg” runat=”server” ClientValidationFunction=”ValidateNo” ControlToValidate=”txtno” ErrorMessage=”*”></asp:CustomValidator> <script type=”text/javascript”> […]