Tsql Database - Quiz -5

10 Questions | Total Attempts: 60

SettingsSettingsSettings
Please wait...
Database Quizzes & Trivia

This is your description.


Questions and Answers
  • 1. 
    Out of 4 statements namely 1,2,3,4,5, which of the statement/statements will execute successfully? if object_id('test2') is not null  drop table test2 if object_id('test1') is not null  drop table test1   create table test1 (a int not null primary key); create table test2 (b int,a int  ) GO   --statement 1 insert into test1  output inserted.a  select 1 GO   --statement 2 create trigger trig_test1  on test1 after insert as  select 2 GO   --statement 3 insert into test1  select 3 GO   --statement 4 insert into test1  output inserted.a  select 4 GO   --statement 5 declare @temp as table (b int)   insert into test1  output inserted.a  into @temp  select 5   select * from @temp GO  
    • A. 

      1

    • B. 

      2

    • C. 

      3

    • D. 

      4

    • E. 

      5

  • 2. 
    If "order by" clause is not used in a query then in which order is the result set returned?
    • A. 

      Insertion Order

    • B. 

      Primary key order

    • C. 

      Clustered Index order

    • D. 

      No guarantee of order

  • 3. 
    What is returned by select statement? CREATE TABLE Test ( Ident INT NOT NULL IDENTITY (1,1) , varfield varchar(100) );   INSERT INTO Test VALUES ('abc')   DBCC CHECKIDENT ('Test',RESEED,100)   truncate table Test   INSERT INTO Test VALUES ('def')   SELECT Ident FROM Test  GO drop table Test
    • A. 

      100

    • B. 

      101

    • C. 

      1

    • D. 

      2

  • 4. 
    What is the result of this batch? (select two) --batch ONE select 1 return select 2 select 3 go --batch TWO select 4 return (select 5)
    • A. 

      Batch ONE returns 1

    • B. 

      Batch ONE returns 2

    • C. 

      Batch ONE returns 3

    • D. 

      Batch ONE returns "A RETURN statement with a return value cannot be used in this context."

    • E. 

      Batch TWO returns 4

    • F. 

      Batch TWO returns 5

    • G. 

      Batch TWO returns "A RETURN statement with a return value cannot be used in this context."

  • 5. 
    Create table test(a int)   insert into test values (null) insert into test values (2) insert into test values (3) insert into test values (1) insert into test values (null)   select *from test order by a What will be the order of null values?
    • A. 

      In the begining of the result set

    • B. 

      At the end of the result set

    • C. 

      No particular order

    • D. 

      One null in the begining and one at the last of result set

  • 6. 
     You have a table named Product with three columns: ProductID, Name and Color. Which of the following queries runs successfully based on this information? (select 3)
    • A. 

      SELECT ProductID,Name,Color FROM Product

    • B. 

      SELECT ProductID Name Color FROM Product

    • C. 

      SELECT ProductID, Name FROM Product

    • D. 

      SELECT ProductID Name FROM Product

  • 7. 
    What will be the output of the select statement? CREATE TABLE [dbo].[IndexTable]( [ID] [int] NOT NULL, [Value] [varchar](50) NULL, CONSTRAINT [PK_IndexTable] PRIMARY KEY CLUSTERED ([ID] ASC) ) GO INSERT INTO [dbo].[IndexTable] VALUES(1, 'value1'), (2, 'value2') GO ALTER INDEX [PK_IndexTable] ON [dbo].[IndexTable] DISABLE Go INSERT INTO [dbo].[IndexTable] VALUES(3, 'Value3') GO ALTER INDEX [PK_IndexTable] ON [dbo].[IndexTable] REORGANIZE GO INSERT INTO [dbo].[IndexTable] VALUES(4, 'Value4') GO ALTER INDEX [PK_IndexTable] ON [dbo].[IndexTable] REBUILD GO INSERT INTO [dbo].[IndexTable] VALUES(5, 'Value5') GO SELECT * FROM indextable
    • A. 

      Value1,value2,value3,value4,value5

    • B. 

      Value1,value2,value3,value5

    • C. 

      Value1,value2,value4,value6

    • D. 

      Value1,value2,value5

  • 8. 
     I create the following two (2) tables , and insert the data as shown. CREATE TABLE t1(x INT,A INT IDENTITY(1,1));  INSERT INTO t1 VALUES (10),(20),(4),(20),(10);  CREATE TABLE t2(y INT,B INT IDENTITY(15,15) PRIMARY KEY);  INSERT INTO t2 VALUES (1),(20),(3); I then execute the following T-SQL statenent SELECT x AS 'Answer' FROM t1 EXCEPT SELECT y FROM t2 The question is: How many rows are returned by the SELECT statment ?
    • A. 

      1 row is returned by the SELECT statement

    • B. 

      2 row is returned by the SELECT statement

    • C. 

      3 row is returned by the SELECT statement

    • D. 

      4 row is returned by the SELECT statement

    • E. 

      5 row is returned by the SELECT statement

  • 9. 
    What is EBS Database recovery Model?
    • A. 

      SIMPLE

    • B. 

      FULL

    • C. 

      BULK_LOGGED

  • 10. 
    What is returned from #tblTrans when you run the below code.   CREATE TABLE #tblTrans(RowId TINYINT) GO BEGIN TRAN         DECLARE @getId TINYINT         SET @getId=100         INSERT INTO #tblTrans (RowId) VALUES(@getId)         IF @getId >10         RAISERROR('RowId should not be greater than 10',11,16)         PRINT @@ERROR IF @@ERROR = 0 BEGIN         COMMIT TRAN         PRINT 'I am here at commit!' END ELSE BEGIN         ROLLBACK TRAN         PRINT 'I am here at rollback!' END GO SELECT * FROM #tblTrans
    • A. 

      No rows were returned

    • B. 

      100

    • C. 

      NULL

Related Topics
Back to Top Back to top