Saturday, August 30, 2008
What is a concatenated primary key
Each table has one and only one primary key, which can consist of one or many columns. A concatenated primary key comprises two or more columns. In a single table, you might find several columns, or groups of columns, that might serve as a primary key and are called candidate keys. A table can have more than one candidate key, but only one candidate key can become the primary key for that table
Labels:
Inerview Questions,
SQL Server,
SQL Server Tips
Tuesday, August 19, 2008
differnce between @@sqlstatus and @@fetch_status
The @@sqlstatus global variable holds status information (warning exceptions) resulting from the execution of a fetch statement. Its value reflects the last cursor fetched.
The @@fetch_status global variable provides information about whether fetch is executed successfully in a scrollable cursor
The @@fetch_status global variable provides information about whether fetch is executed successfully in a scrollable cursor
Friday, August 15, 2008
Generics
Generics
Generics are classes or methods that work uniformly on values of different typesGenerics also called as Parametric Polymorphism, it is similar to the concept of Templates in c++, which is lacked in .Net frame work1.1 and is new feature ofC# 2.0. Generics allow you to realize type safety at compile time. They allow you to create a data structure without committing to a specific data type. When the data structure is used. Even though C# 2.0 Generics are similar to Templates in c++, but we can’t compare both because generics have some additional benefits and it solved the problems like Developer Confusion.
Generics are useful for writing efficient type independent code particularly where the type might include value types .the obvious application is container classes.The .Net 2.0 class library includes a suite of generic container classes in the System.Collection.Generic namespace
Generics are classes or methods that work uniformly on values of different typesGenerics also called as Parametric Polymorphism, it is similar to the concept of Templates in c++, which is lacked in .Net frame work1.1 and is new feature ofC# 2.0. Generics allow you to realize type safety at compile time. They allow you to create a data structure without committing to a specific data type. When the data structure is used. Even though C# 2.0 Generics are similar to Templates in c++, but we can’t compare both because generics have some additional benefits and it solved the problems like Developer Confusion.
Generics are useful for writing efficient type independent code particularly where the type might include value types .the obvious application is container classes.The .Net 2.0 class library includes a suite of generic container classes in the System.Collection.Generic namespace
Sunday, August 10, 2008
New Features in C#2.0
New Features in c# 2.0
The following are the new features in c# 2.0
1. Generics
2. Partial Classes
3. Iterators
4. Anonymous Methods
5. Property Visibility
6. Static Classes
The following are the new features in c# 2.0
1. Generics
2. Partial Classes
3. Iterators
4. Anonymous Methods
5. Property Visibility
6. Static Classes
Friday, August 8, 2008
Sql Server Exception Handling using Try..Catch
Even though @@Error is good for handling errors, it cannot handle exceptions, indeed in sql server 2000, there are no ways to do this. In SQL server 2005, Microsoft introduced a new feature “try catch” dedicated for this purpose. For example the divide by zero exception, even before the @@Error returns the error id, SQL throws an exception.
DECLARE @i int , @j int
SELECT @i =100, @j =0
SELECT @i/@j
Print @@Error
Now let us see, how to handle this is SQL Server 2005. SQL server 2005 introduces new Statements to handle this.
BEGIN TRY
END TRYBEGIN CATCH
END CATCH
Don’t put any other statements in between the “End TRY and the ‘Begin catch’ statements. For example consider the modified version of the above code.
DECLARE @i int , @j int
SELECT @i =100, @j =0
BEGIN TRY
SELECT @i/@j
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() as ErrorNo,
ERROR_MESSAGE() as ErrMessage
END CATCH
DECLARE @i int , @j int
SELECT @i =100, @j =0
SELECT @i/@j
Print @@Error
Now let us see, how to handle this is SQL Server 2005. SQL server 2005 introduces new Statements to handle this.
BEGIN TRY
END TRYBEGIN CATCH
END CATCH
Don’t put any other statements in between the “End TRY and the ‘Begin catch’ statements. For example consider the modified version of the above code.
DECLARE @i int , @j int
SELECT @i =100, @j =0
BEGIN TRY
SELECT @i/@j
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() as ErrorNo,
ERROR_MESSAGE() as ErrMessage
END CATCH
Saturday, August 2, 2008
What is a join and explain different types of joins
Joins are used in queries to explain how different tables are related.Joins also let you select data from a table depending upon data from another table.
Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs.OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.
Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs.OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.
Friday, August 1, 2008
Differences between primarykey and uniquekey
The Major differences between Primary Key and Unique Key are:
1) Primary Key doesn't allow null values, But Unique key does all nulls(Only One per key).
2) You can have No.Of Unique Keys on a single table, but you can have atmost only one primary key.
3) Primary Keys are used to define Referential Integrity Constraints.
1) Primary Key doesn't allow null values, But Unique key does all nulls(Only One per key).
2) You can have No.Of Unique Keys on a single table, but you can have atmost only one primary key.
3) Primary Keys are used to define Referential Integrity Constraints.
Subscribe to:
Posts (Atom)