simple SQL Test for Beginner

This is a simple SQL Test for Beginner, for our regular reader I need some of your time to attempt the test and reply the answer.
Thanks  

A.  Which is the right syntax to convert date to varchar value

a.  SELECT Convert(varchar(20),GETDATE(),107)
b.  SELECT CAST(GETDATE() as varchar(20),102)
c.  SELECT Convert(GETDATE(),varchar(20),107)
d.  SELECT CAST(GETDATE() as varchar(20),107)


B.  What will be the output of the following query

SELECT LEN(CAST(LEFT(('0124-124'),3) as INT))

a.  4
b.  2
c.  3
d.  0

C.  What will be the output of the following query

SELECT IIF(1=1,'EQUAL','NOT-EQUAL')

a.  EQUAL
b.  NOT-EQUAL
c.  ERROR IN QUERY
d.  INCORRECT SYNTAX ERROR
D.  Which are the correct answer below

a.  SELECT DATENAME(DW,getdate())
b.  SELECT DATENAME(DD,getdate())
c.  SELECT DATENAME(DAY,getdate())
d.  SELECT DATENAME(WEEKDAY,getdate())
1.     a and b 2. b and c 3. c and d 4. a and d

E.  What will be the output of the following query

 SELECT DATENAME(MM,getdate())

a.  Full Month Name of current date
b.  Month Number of current date
c.  ERROR IN QUERY
d.  Short Month Name of current date

F.  What will be the output of the following query

DECLARE @Cntr AS INT

SET @Cntr=1

WHILE (@Cntr <=5)
      
       BEGIN
             
              PRINT @Cntr         
              SET @Cntr = @Cntr+1
       END

a.  12345
b.  54321
c.  0
d.  1
G.  What will be the output of the following query

DECLARE @CurrDate AS DATE
DECLARE @Cntr AS INT

SET @CurrDate = GETDATE()
SET @Cntr=0


WHILE (@Cntr <7)
      
       BEGIN
             
              PRINT DATEADD(DD,@Cntr,@CurrDate)       
              SET @Cntr = @Cntr+1
       END

a.  A week date from start date to end date
b.  A week date from end date to start date
c.  Alternate one week date
d.  Random one week date
H.  What will be the output of the following query

SELECT CHOOSE(3,'C#','Java','SQL','AZURE')

a.  C#
b.  Java
c.  SQL

d.  AZURE

Comments