Click here to get free chapters (PDF) in the mailbox
SQL SERVER – 2008 – Interview Questions and Answers Complete List Download
What is Data Compression?
In SQL SERVE 2008 Data Compression comes in two flavors:
- Row Compression
- Page Compression
Row Compression
Row compression changes the format of physical storage of data. It minimize the metadata (column information, length, offsets etc) associated with each record. Numeric data types and fixed length strings are stored in variable-length storage format, just like Varchar. (Read More Here)
Page Compression
Page compression allows common data to be shared between rows for a given page. Its uses the following techniques to compress data:
- Row compression.
- Prefix Compression. For every column in a page duplicate prefixes are identified. These prefixes are saved in compression information headers (CI) which resides after page header. A reference number is assigned to these prefixes and that reference number is replaced where ever those prefixes are being used.
Dictionary Compression.
Dictionary compression searches for duplicate values throughout the page and stores them in CI. The main difference between prefix and dictionary compression is that prefix is only restricted to one column while dictionary is applicable to the complete page.
What is use of DBCC Commands?
The Transact-SQL programming language provides DBCC statements that act as Database Console Commands for SQL Server. DBCC commands are used to perform following tasks.
- Maintenance tasks on database, index, or filegroup.
- Tasks that gather and display various types of information.
- Validation operations on a database, table, index, catalog, filegroup, or allocation of database pages.
- Miscellaneous tasks such as enabling trace flags or removing a DLL from memory.
How to find tables without Indexes?
Run following query in Query Editor.
USE <database_name>;
GO
SELECT SCHEMA_NAME(schema_id) AS schema_name
,name AS table_name
FROM sys.tables
WHERE OBJECTPROPERTY(OBJECT_ID,'IsIndexed') = 0
ORDERÂ BY schema_name, table_name;
GO
How to copy the tables, schema and views from one SQL Server to another?
There are multiple ways to do this.
- “Detach Database” from one server and “Attach Database” to another server.
- Manually script all the objects using SSMS and run the script on new server.
- Use Wizard of SSMS. (Read More Here)
How to copy data from one table to another table?
There are multiple ways to do this.
1) INSERT INTO SELECT
This method is used when table is already created in the database earlier and data is to be inserted into this table from another table. If columns listed in insert clause and select clause are same, they are not required to list them.
2) SELECT INTO
This method is used when table is not created earlier and needs to be created when data from one table is to be inserted into newly created table from another table. New table is created with same data types as selected columns.
What is Catalog Views?
Catalog views return information that is used by the SQL Server Database Engine. Catalog Views are the most general interface to the catalog metadata and provide the most efficient way to obtain, transform, and present customized forms of this information. All user-available catalog metadata is exposed through catalog views.
What is PIVOT and UNPIVOT?
A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table.
UNPIVOT table is reverse of PIVOT Table. (Read More Here)
What is Filestream?
Filestream allows you to store large objects in the file system and have these files integrated within the database. It enables SQL Server based applications to store unstructured data such as documents, images, audios, videos etc. in the file system. FILESTREAM basically integrates the SQL Server Database Engine with New Technology File System (NTFS); it basically stores the data in varbinary (max) data type. Using this data type, the unstructured data is stored in the NTFS file system and the SQL Server Database Engine manages the link between the Filestream column and the actual file located in the NTFS. Using Transact SQL statements users can insert, update, delete and select the data stored in FILESTREAM enabled tables.
What is Dirty Read ?
A dirty read occurs when two operations say, read and write occurs together giving the incorrect or unedited data. Suppose, A has changed a row, but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong so that is Dirty Read.
What is SQLCMD?
sqlcmd is enhanced version of the isql and osql and it provides way more functionality than other two options. In other words sqlcmd is better replacement of isql (which will be deprecated eventually) and osql (not included in SQL Server 2005 RTM). sqlcmd can work two modes – i) BATCH and ii) interactive modes. (Read More)
What is Aggregate Functions?
Aggregate functions perform a calculation on a set of values and return a single value. Aggregate functions ignore NULL values except COUNT function. HAVING clause is used, along with GROUP BY, for filtering query using aggregate values.
Following functions are aggregate functions.
AVG, MIN, CHECKSUM_AGG, SUM, COUNT, STDEV, COUNT_BIG, STDEVP, GROUPING, VAR, MAX, VARP (Read More Here )
What do you mean by Table Sample?
TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set. (Read More Here)
What is Row_Number()?
ROW_NUMBER() returns a column as an expression that contains the row’s number within the result set. This is only a number used in the context of the result set, if the result changes, the ROW_NUMBER() will change.
What are Ranking Functions?
Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. Different Ranking functions are:
ROW_NUMBER () OVER ([<partition_by_clause>] <order_by_clause>)
Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.
RANK () OVER ([<partition_by_clause>] <order_by_clause>)
Returns the rank of each row within the partition of a result set.
DENSE_RANK () OVER ([<partition_by_clause>] <order_by_clause>)
Returns the rank of rows within the partition of a result set, without any gaps in the ranking. (Read More Here )
What is the difference between UNION and UNION ALL?
UNION
The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.
UNION ALL
The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.
The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table. (Read More Here)
What is B-Tree?
The database server uses a B-tree structure to organize index information. B-Tree generally has following types of index pages or nodes:
- root node: A root node contains node pointers to branch nodes which can be only one.
- branch nodes: A branch node contains pointers to leaf nodes or other branch nodes which can be two or more.
- leaf nodes: A leaf node contains index items and horizontal pointers to other leaf nodes which can be many.
© Copyright 2000-2009 Pinal Dave. All Rights Reserved. SQLAuthority.com
Reference : Pinal Dave (https://blog.sqlauthority.com)
19 Comments. Leave new
re: How to copy the tables, schema and views from one SQL Server to another?
There is one more interesting product: “SQL Server Database Publishing Wizard”. It is available for download at: http://www.microsoft.com/en-us/download/details.aspx?id=5498
Pinal,
Thanks for this web site full of good information. This helped me.
Best wishes,
Pavan.
Thanks for Quastions .
hi..
plz give me 2008 link
Hi,
Sometimes, I checked sql server log, I see these message:
“SQL is getting paged out ”
Could I monitor these events by script. All memory issue in sql log file should sent to my email account.
Could you share me an idea how to write a script?
could you explain about OLAP,OLTP?
Hi Pinal,
This is Kiran here, i am knew to the SQL and i like to know the solutions for the following queries.
1) Retrive the Even & Odd number from the Column.
2) Retrive the alternate records from the column(table).
Looking forward for your solution and thanks in advance.
Regards,
Kiran
select * from product where (qty%2) =0 –even
select * from product where (qty%2) 0 –odd
Also both query you can use as alter row fetching..
i want to know that is there any function for removing white spaces form in image data from SQL. if than how can i do this.
Thanks
Umesh Kumar
Hi Dave,
This is sreenivas,I am very much thankful to you for providing everything for us.i had downloaded material from “Download SQL Server 2008 Interview Questions and Answers Complete List
Reference : Pinal Dave (http://blog.SQLAuthority.com)”.coming to theory it is very good.But better to give examples for each topic it may help to understand each topic easily and it is very much use full in interviews.(if it is not possible to put in web site kindly forward to my mail id)
Regards
sreenivas
Nice Blog
Very very useful.Good stuff.Thank you a lot
Very good article
Hello Sir,
i would like to alots of thanks for,
This is the very good wesite for sql interview quest or helped me
Thanks & Regards
Ritesh Kumar
Software Engineer
Wonderful website with apt information on SQL server 2008. Helping a lot for my class with Set Focus. NJ USA
thanks
Ambuji
Excellent Site
Very Good Points Mentioned , thank you sir
Excellent site..thak u sir
Excellent Side for Pl/SQL Developer Interview