SQL Server TSQLquiz - 8

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Guna24x7
G
Guna24x7
Community Contributor
Quizzes Created: 4 | Total Attempts: 3,226
| Attempts: 336 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. What is a table called, if it does not have either aClustered or a nonclustered index?

Explanation

A table without either a clustered or a nonclustered index is called a heap. In a heap, the data is stored in an unordered manner, without any specific organization or sorting. This can result in slower data retrieval and manipulation compared to tables with indexes. However, heaps can be useful in certain scenarios, such as when the table is frequently modified or when the data is accessed in a sequential manner.

Submit
Please wait...
About This Quiz
SQL Server TSQLquiz - 8 - Quiz

The SQL Server TSQLQuiz - 8 assesses knowledge on T-SQL queries, data types, transaction durability, and command configurations within SQL Server environments, focusing on practical applications and system... see moreunderstanding. see less

2. What is the difference between the following 2 queries:    -- 1 SELECT ROW_NUMBER() OVER (ORDER BY NEWID())  FROM sys.all_columns   -- 2 SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NEWID()))  FROM sys.all_columns  

Explanation

not-available-via-ai

Submit
3. NTILE returns what?

Explanation

NTILE returns the rows in an ordered partition into a specified number of groups. This means that it divides the result set into equal-sized groups based on the specified number. Each row is assigned a sequential number representing the group it belongs to. This function is useful for analyzing data distribution and creating percentiles or quartiles.

Submit
4. True or False: sparse Columns can have the Filestream attribute defined on them?

Explanation

Sparse columns cannot have the Filestream attribute defined on them. The Filestream attribute is used to store large binary data outside the database, while sparse columns are used to optimize storage for columns that contain mostly NULL values. These two features serve different purposes and cannot be used together.

Submit
5. What will be the values returned by the COUNT(*) statements ? (select the answer that show the 3 values in correct order) CREATE TABLE #TempTable (RowID INT) CREATE TABLE UserTable (RowID INT)     BEGIN TRAN  INSERT UserTable (RowID) VALUES (1) ROLLBACK   INSERT UserTable (RowID) VALUES (2)   BEGIN TRAN  INSERT #TempTable (RowID) VALUES (1) ROLLBACK   INSERT #TempTable (RowID) VALUES (2)   DECLARE @TableVariable TABLE (RowID INT)   BEGIN TRAN  INSERT @TableVariable (RowID) VALUES (1) ROLLBACK   INSERT @TableVariable (RowID) VALUES (2)   SELECT COUNT(*) FROM UserTable  SELECT COUNT(*) FROM #TempTable SELECT COUNT(*) FROM @TableVariable   DROP TABLE #TempTable DROP TABLE UserTable

Explanation

The first INSERT statement is rolled back, so no rows are actually inserted into the UserTable. The second INSERT statement inserts one row with a value of 2 into the UserTable. Therefore, the COUNT(*) statement for the UserTable will return a value of 1.

The first INSERT statement for the #TempTable is also rolled back, so no rows are inserted. The second INSERT statement inserts one row with a value of 2 into the #TempTable. Therefore, the COUNT(*) statement for the #TempTable will return a value of 1.

The first INSERT statement for the @TableVariable is rolled back, so no rows are inserted. The second INSERT statement inserts one row with a value of 2 into the @TableVariable. Therefore, the COUNT(*) statement for the @TableVariable will return a value of 1.

Submit
6. What will be the output of these SELECT queries? DECLARE @var money = 123457756 Declare @dec decimal =12345 Declare @dec1 Decimal(10,2) = 12345   --Select 1 SELECT LEN(@var)   --Select 2 SELECT LEN(@dec)   --Select 3 SELECT LEN(@dec1)

Explanation

The first SELECT query returns the length of the string representation of the @var variable, which is 12.

The second SELECT query returns the length of the string representation of the @dec variable, which is 5.

The third SELECT query returns the length of the string representation of the @dec1 variable, which is 8.

Submit
7. Declare @value int set @value = 5555555 PRINT CONVERT(varchar(6), @value)  What will be the output?  

Explanation

The code snippet sets the value of the variable @value to 5555555 and then tries to convert it to a varchar(6) data type. However, since the value is too large to fit within 6 characters, it causes an arithmetic overflow error. Therefore, the correct answer is "*".

Submit
8. You wish to enable xp_cmdshell. You run the following code:   EXECUTE sys.sp_configure      @configname = 'show advanced options'     ,@configvalue = 1 GO RECONFIGURE GO EXECUTE sys.sp_configure      @configname = 'dsh'     ,@configvalue = 1 GO RECONFIGURE GO

Explanation

The first call to sp_configure succeeds because it sets the value of the 'show advanced options' configuration option to 1. This allows the system to display advanced configuration options. The second call to sp_configure also succeeds because it sets the value of the 'dsh' configuration option to 1, enabling the xp_cmdshell feature.

Submit
9. I have a table, Sales, with the Notes field having the Filestream attribute. I run this query: select  salesmen, notes  into #salestemp  from Sales What is the data type of the Notes field in the temporary table?  

Explanation

The data type of the Notes field in the temporary table is varbinary(max) because the original Notes field in the Sales table has the Filestream attribute, which indicates that the data is stored as binary data. Therefore, when the data is copied into the temporary table, it retains the varbinary(max) data type.

Submit
10. What technique is used by the SQL Server to maintain Durability of Transactions?

Explanation

Write Ahead Logging is a technique used by SQL Server to maintain Durability of Transactions. This technique ensures that all changes made by a transaction are first written to a log file before being written to the database. This log file serves as a record of all the changes made, allowing for recovery in case of system failure or crash. By using Write Ahead Logging, SQL Server ensures that committed transactions are durable and can be recovered even in the event of a failure.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 22, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 06, 2013
    Quiz Created by
    Guna24x7
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is a table called, if it does not have either aClustered or a...
What is the difference between the following 2 queries: ...
NTILE returns what?
True or False: sparse Columns can have the Filestream attribute...
What will be the values returned by the COUNT(*) statements ? (select...
What will be the output of these SELECT queries? ...
Declare @value int ...
You wish to enable xp_cmdshell. You run the following code: ...
I have a table, Sales, with the Notes field having the Filestream...
What technique is used by the SQL Server to maintain Durability of...
Alert!

Advertisement