Monday, January 18, 2010

Difference between javascripts,jquery and ajax

1. Javascript

A language that comes with your browser. It allows you to show an alert box, the one that you need to press Ok, validate forms, on the client, or without change the page. Usually, it is stopped by an alert, confirm, etc box.

2. jQuery

A library code made with Javascript, that make easier to program Javascript and AJAX. You can download it on jquery.com .

3. AJAX

Asynchronous Javascript And XML. Which means that with a help from a programming language like PHP, ASP.NET and etc. it can work changing data without refresh the whole page, just the part of the data will be refreshed.

Friday, January 8, 2010

Sql Syntax

Select Statement
SELECT "column_name" FROM "table_name"

Distinct
SELECT DISTINCT "column_name"
FROM "table_name"

Where
SELECT "column_name"
FROM "table_name"
WHERE "condition"

And/Or
SELECT "column_name"
FROM "table_name"
WHERE "simple condition"
{[AND|OR] "simple condition"}+

In
SELECT "column_name"
FROM "table_name"
WHERE "column_name" IN ('value1', 'value2', ...)

Between
SELECT "column_name"
FROM "table_name"
WHERE "column_name" BETWEEN 'value1' AND 'value2'

Like
SELECT "column_name"
FROM "table_name"
WHERE "column_name" LIKE {PATTERN}

Order By
SELECT "column_name"
FROM "table_name"
[WHERE "condition"]
ORDER BY "column_name" [ASC, DESC]

Count
SELECT COUNT("column_name")
FROM "table_name"

Group By
SELECT "column_name1", SUM("column_name2")
FROM "table_name"
GROUP BY "column_name1"

Having
SELECT "column_name1", SUM("column_name2")
FROM "table_name"
GROUP BY "column_name1"
HAVING (arithematic function condition)

Create Table Statement
CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",
... )

Drop Table Statement
DROP TABLE "table_name"

Truncate Table Statement
TRUNCATE TABLE "table_name"

Insert Into Statement
INSERT INTO "table_name" ("column1", "column2", ...)
VALUES ("value1", "value2", ...)

Update Statement
UPDATE "table_name"
SET "column_1" = [new value]
WHERE {condition}

Delete From Statement
DELETE FROM "table_name"
WHERE {condition}

Thursday, January 7, 2010

Substring

SUBSTRING(expression,start,length)

DECLARE @SampleString VARCHAR(11)


SELECT SUBSTRING(@SampleString,-11,22)
Start = -11
Length = 22
Result is : (-11 + 22) - 1 = 10, So that it returns 10 Chanacters : Dotnetfund

Difference bewtween SCOPE_IDENTITY() and @@IDENTITY

Both SCOPE_IDENTITY() and @@IDENTITY will return the last identity value generated in the table. but there is some difference between the two:

SCOPE_IDENTITY() will return the Identity value generated in a table that is currently in scope.

@@IDENTITY will return the Identity value generated in a table irrespective of the scope.

Example
Let us suppose we have two tables named table1 & table2... and we have one trigger defined on table1 that is insert a record in table2 when new record will be inserted into table1.

in this case the Output of Both SCOPE_IDENTITY() and @@IDENTITY will be different.
SCOPE_IDENTITY() will return the identity value of table1 that is in current scope.
while @@IDENTITY will return the identity value of table2.