Question 61: How to generate number from 1 to 100 using SQL Server?
Answer - Find the below SQL query -
;With CTE
As
(
Select 1 [Row_Sequence]
Union all
Select [Row_Sequence] + 1 from CTE where [Row_Sequence] < 99
)
Select *from CTE
Question 62: In the below table, how to get the maximum value from a row with the corresponding Id column ?
CREATE TABLE #T1 (IID INT IDENTITY(1,1), SAL1 INT, SAL2 INT )INSERT INTO #T1 VALUES (NULL,100),(200,400),(300,600)
Answer - Find the below SQL query -
Select IID, Max(Salary) from (
Select IID, SAL1 as [Salary] from #T1
Union All
Select IID, SAL2 as [Salary] from #T1
)x
Group by IID
Question 63: What is the out put for the below query ?
Declare @a int
Select @a + 100
Answer - NULL
Question 64: What is the query compilation in SQL server ?
Answer - Query compilation is the process to choose the fastest execution plan among the multiple plans created by SQL server.
Question 65: What is the role of query optimizer in SQL server ?
Answer - There are following main functionalities of query optimizer in SQL server -
1. Validate the query syntax
2. Parse a query into the tree representation
3. Evaluate the possible query execution plans
4. Finalize the 'Good Enough' query plan based on the cost
Question 66: Mention at least 5 mathematical functions in SQL server ?
Answer - Five mathematical functions in SQL server are as mentioned below -
1. SQRT - It use to get a square root of any float, it's return type is float.
2. SQUARE - It use to get the square value of any float, it's return type is float.
3. ROUND - It use to round a numeric expression to a specified length, It's return type is expression type only.
4. POWER - It use to get the specified power of a numeric expression, It's return type is expression type only.
5. FLOOR - It use to get the largest integer of a numeric expression, It's return type is expression type only.
For more mathematical functions, visit here
0 Comments