Sunday, 1 July 2012

CHECK constraint



SQL CHECK constraint

The SQL CHECK constraint bounds/limits the value range that can be placed in a column.

For example, the range of values for a salary column can be limited by creating a CHECK constraint that allows for only data that ranges from $15,000 through $100,000. This prevents salaries from being entered beyond the regular salary range.

Example of SQL CHECK constraint

The following SQL query creates a CHECK constraint on the "Emp_ID" column when the "Employees" table is created. The CHECK constraint specifies that the column "Emp_ID" must only include integers greater than 0.


CREATE TABLE Employees
(
Emp_ID int NOT NULL CHECK (Emp_ID>0),
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255)
)

Wednesday, 13 June 2012

SQL PRIMARY KEY Constraint




SQL PRIMARY KEY Constraint - same as UNIQUE Constraint except that Primary Key constraints does not allow null values (whether or not the column definition specifies NOT NULL) and only one primary key constraint can be defined for each table.

Example of SQL PRIMARY KEY Constraint


CREATE TABLE Sells (
  bar   CHAR(20),
  beer  VARCHAR(20) DEFAULT 'Kingfisher',
  price REAL  NOT NULL,
  PRIMARY KEY (bar,beer)
 );

Tuesday, 29 May 2012

life cycle of an ASP.NET web page?


1. PreInit
2. Init
3. InitComplete
4. PreLoad
5. Load
6. Control Events
7. LoadComplete
8. PreRender
9. PreRenderComplete
10. SaveState
11. SaveStateComplete
12. Render
13. Unload

What is the difference between asp.net server controls and html servercontrols?


  1. ASP.NET Server Control is more advanced control these have more properties compared to HTML Server Controls,
  2. .NET Server controls will have events, where as HTML server controls does not have events. Both controls memory is created at Server.

Thursday, 19 April 2012

How to get a random row from a table in SQL server ?


Select Top 1 columName from Tablename Order by newid()

Where the session is stored ?


<sessionState  mode =”InProc” cookieless=”False” timeout=”20”/>


By default Cookieless is set to false – so the session Id is stored in Cookies so as long as user navigating the page you can get the session from cookies.

If you set the cookieless =”True” the session id is stored on the browser url before the file name

Ex: http://yourserver/folder/(sessionid)/default.aspx


Drawback is if the user working on the site it has assigned some sessionId on the url  , by giving the different url on Address bar and do some process once the user type same url at that time it will give different sessionid, the previous session will be lost and lost all of previous state.

Default timeout for session is 20 Mins.

Default timeout for Form authentication 30 Mins.

Difference between timestamp and uniqueidentifier ?


TimeStamp:

Size – 8 bytes.
Note based on system date or time
To track the operation in tables on the database level.

Uniqueidentifier

16 – bytes.
Value is based on the computer MAC Addresss and system datetime.
It remains unique in any system in the world.

IE7 Issues Text Indent

                 Unfortunately IE 7 is still widespread among the users hence while theming we have to give special importance to the grea...