Sunday, July 18, 2010

Find output

What will be the output of the following scripts?

CREATE TABLE #tblTest(TestValue VARCHAR(2) COLLATE French_CI_AI) 
DECLARE @Var1 CHAR(1), @Var2 CHAR(1)
SET @Var1='A'

WHILE @Var1 <= 'Z' 
BEGIN
 SET @Var2='A'
 WHILE @Var2 <= 'Z'
 BEGIN
  INSERT INTO #tblTest SELECT @Var1 + @Var2
  SET @Var2 = CHAR(ASCII(@Var2) + 1)
 END
 SET @Var1 = CHAR(ASCII(@Var1) + 1)
END

SELECT DISTINCT TestValue FROM #tblTest
WHERE TestValue LIKE '_'

DROP TABLE #tblTest
A. 0
B. 1
C. 26
D. 676 = 26*26
E. It depends on tempdb collation
F. Error is generated

Answer:[A]
Highlight to find out the answer.

No comments:

Post a Comment