Thursday, February 4, 2010

SQL InterviewQuestions-Part3

21) What is select into command?
a. It selects values from one table and inserts them into another table at the same time
ex: SELECT column1, column2,
INTO table2
FROM table1

22) Why we use DISTINCT command?
a. This is used to return only distinct values. It is used only with Select command.
ex: Select DISTINCT column(s)
From table

23) What are the wild cards?
a. These are used to substitute one or more characters when searching for data in a database
% is used to substitute zero or more characters
[charlist] any single character in charlist
_ substitute for exactly single character
[^charlist] any single character not in list

24) Can we create indexes on views?
a. Yes

25) what is the first index that we can create on a view?
a. It must be unique clustered index

26) what are temporary stored procedures?
a. Temporary stored procedures are like temporary tables and are dropped automatically when you disconnect. They are stored in tempdb and are useful when connected to earlier versions of SQL Server.They can be used when an application builds dynamic t-sql statements that are executed several times.Rather than have the t-sql statements recompiled each time, you can create a temporary stored procedure that is compiled on the first execution and then execute the precompiled plan multiple times.

27) What is referential integrity?
a. It indicates that the relationships between tables have been properly maintained

28) what is Default constraint?
a. It is used to insert default value in to a column

29) How many bytes a currency datatype requires?
a. 8 bytes

30) Can we use Where clause with aggrigate functions?
a. No