October 25, 2007
HTML Tags------legend---fieldset---
http://www.w3schools.com/tags/tag_legend.asp
October 08, 2007
Sql Server User Define Funciton
Advantages of User Defined Function
One of the advantages of User Defined Functions over Stored Procedures, is the fact that a UDF can be used in a Select, Where, or Case statement. They also can be used to create joins. In addition, User Defined Functions are simpler to invoke than Stored Procedures from inside another SQL statement.Disadvantages of User Defined Functions
User Defined Functions cannot be used to modify base table information. The DML statements INSERT, UPDATE, and DELETE cannot be used on base tables. Another disadvantage is that SQL functions that return non-deterministic values are not allowed to be called from inside User Defined Functions. GETDATE is an example of a non-deterministic function. Every time the function is called, a different value is returned. Therefore, GETDATE cannot be called from inside a UDF you create.Types of User Defined Functions
There are three different types of User Defined Functions. Each type refers to the data being returned by the function. Scalar functions return a single value. In Line Table functions return a single table variable that was created by a select statement. The final UDF is a Multi-statement Table Function. This function returns a table variable whose structure was created by hand, similar to a Create Table statement. It is useful when complex data manipulation inside the function is required.
SQL Server Transaction
Transactions
Transactions group a set of tasks into a single execution unit. Each transaction begins with a specific task and ends when all the tasks in the group successfully complete. If any of the tasks fails, the transaction fails. Therefore, a transaction has only two results: success or failure. Incomplete steps result in the failure of the transaction.
Users can group two or more Transact-SQL statements into a single transaction using the following statements:
- Begin Transaction
- Rollback Transaction
- Commit Transaction
DECLARE @intErrorCode INT
BEGIN TRAN
UPDATE Authors
SET Phone = '415 354-9866'
WHERE au_id = '724-80-9391'
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEM
UPDATE Publishers
SET city = 'Calcutta', country = 'India'
WHERE pub_id = '9999'
SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEM
COMMIT TRAN
PROBLEM:
IF (@intErrorCode <> 0) BEGIN
PRINT 'Unexpected error occurred!'
ROLLBACK TRAN
END
UNION vs UNION ALL
UNION
The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type.
Note: With UNION, only distinct values are selected.
SQL Statement 1
UNION
SQL Statement 2
UNION ALL
The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.
SQL Statement 1
UNION ALL
SQL Statement 2
Count(*) Vs Count('column')
1. COUNT(*) returns the number of rows that match the search conditions specified in the query without eliminating duplicates.
SELECT COUNT(*)
FROM titles
2.COUNT(*) can be combined with other aggregate functions.SELECT COUNT(*), AVG(price)
FROM titles
WHERE advance > $1000SELECT COUNT(DISTINCT city)
FROM authorsRemark:
COUNT(*) returns the number of items in a group, including NULL values and duplicates.
COUNT(ALL expression) evaluates expression for each row in a group and returns the number of nonnull values.
COUNT(DISTINCT expression) evaluates expression for each row in a group and returns the number of unique, nonnull values.
October 07, 2007
Culster V/s Non-Cluster Index
There can be only 1 Clustered index in a table
where as nonclustered index can be upto 249
Clustered is physical sorted index..
non clustered index is faster than clustered index
Try..Catch...Finally....
{
int i = 4;
int j = 0;
int k = 0;
k = i / j;
}
catch (Exception)
{ }
catch (DivideByZeroException)
{ }
finally
{ }
This will give compile time error :: Error 1 A previous catch clause already catches all exceptions of this or of a super type ('System.Exception') ;
try
{
int i = 4;
int j = 0;
int k = 0;
k = i / j;
}
catch (DivideByZeroException)
{ }
catch (Exception)
{ }
finally
{ }
No Error;
Application Entry point in C#.Net 2005
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
1.)We can declare only one Main() method.
2.)Main method can't be override.
October 05, 2007
What is an HTTP Request?
With an HTTP request, a web page can make a request to, and get a response from a web server - without reloading the page. The user will stay on the same page, and he or she will not notice that scripts might request pages, or send data to a server in the background.
By using the XMLHttpRequest object, a web developer can change a page with data from the server after the page has loaded.
function loadXMLDoc(url)
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET",url,true)
xmlhttp.send(null)
}
else
{
alert("Your browser does not support XMLHTTP.")
}
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
// ...some code here...
}
else
{
alert("Problem retrieving XML data")
}
}
}