• Home
  • Resume
  • All Articles
  • Jobs
  • Copyright
  • SQL Interview Q & A
  • Contact Me
  • Hire Me

Journey to SQL Authority with Pinal Dave

Notes of a SQL Server MVP and Database Administrator

Feeds:
Posts
Comments

SQL Server Interview Questions and Answers – Part 5

April 19, 2007 by pinaldave

UPDATE : Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. New Location : SQL Server 2008 Interview Questions and Answers.

What command do we use to rename a db?
sp_renamedb ‘oldname’ , ‘newname’
If someone is using db it will not accept sp_renmaedb. In that case first bring db to single user using sp_dboptions. Use sp_renamedb to rename database. Use sp_dboptions to bring database to multi user mode.

What is sp_configure commands and set commands?
Use sp_configure to display or change server-level settings. To change database-level settings, use ALTER DATABASE. To change settings that affect only the current user session, use the SET statement.

What are the different types of replication? Explain.
The SQL Server 2000-supported replication types are as follows:

  • Transactional
  • Snapshot
  • Merge

Snapshot replication distributes data exactly as it appears at a specific moment in time and does not monitor for updates to the data. Snapshot replication is best used as a method for replicating data that changes infrequently or where the most up-to-date values (low latency) are not a requirement. When synchronization occurs, the entire snapshot is generated and sent to Subscribers.

Transactional replication, an initial snapshot of data is applied at Subscribers, and then when data modifications are made at the Publisher, the individual transactions are captured and propagated to Subscribers.

Merge replication is the process of distributing data from Publisher to Subscribers, allowing the Publisher and Subscribers to make updates while connected or disconnected, and then merging the updates between sites when they are connected.

What are the OS services that the SQL Server installation adds?
MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac co-ordinator)

What are three SQL keywords used to change or set someone’s permissions?
GRANT, DENY, and REVOKE.

What does it mean to have quoted_identifier on? What are the implications of having it off?
When SET QUOTED_IDENTIFIER is ON, identifiers can be delimited by double quotation marks, and literals must be delimited by single quotation marks. When SET QUOTED_IDENTIFIER is OFF, identifiers cannot be quoted and must follow all Transact-SQL rules for identifiers.

What is the STUFF function and how does it differ from the REPLACE function?
STUFF function to overwrite existing characters. Using this syntax, STUFF(string_expression, start, length, replacement_characters), string_expression is the string that will have characters substituted, start is the starting position, length is the number of characters in the string that are substituted, and replacement_characters are the new characters interjected into the string.
REPLACE function to replace existing characters of all occurance. Using this syntax REPLACE(string_expression, search_string, replacement_string), where every incidence of search_string found in the string_expression will be replaced with replacement_string.

Using query analyzer, name 3 ways to get an accurate count of the number of records in a table?
SELECT *
FROM table1
SELECT COUNT(*)
FROM table1
SELECT rows
FROM sysindexes
WHERE id = OBJECT_ID(table1)
AND
indid < 2

How to rebuild Master Database?
Shutdown Microsoft SQL Server 2000, and then run Rebuildm.exe. This is located in the Program Files\Microsoft SQL Server\80\Tools\Binn directory.
In the Rebuild Master dialog box, click Browse.
In the Browse for Folder dialog box, select the \Data folder on the SQL Server 2000 compact disc or in the shared network directory from which SQL Server 2000 was installed, and then click OK.
Click Settings. In the Collation Settings dialog box, verify or change settings used for the master database and all other databases.
Initially, the default collation settings are shown, but these may not match the collation selected during setup. You can select the same settings used during setup or select new collation settings. When done, click OK.
In the Rebuild Master dialog box, click Rebuild to start the process.
The Rebuild Master utility reinstalls the master database.
To continue, you may need to stop a server that is running.
Source: http://msdn2.microsoft.com/en-us/library/aa197950(SQL.80).aspx

What is the basic functions for master, msdb, model, tempdb databases?
The Master database holds information for all databases located on the SQL Server instance and is the glue that holds the engine together. Because SQL Server cannot start without a functioning master database, you must administer this database with care.
The msdb database stores information regarding database backups, SQL Agent information, DTS packages, SQL Server jobs, and some replication information such as for log shipping.
The tempdb holds temporary objects such as global and local temporary tables and stored procedures.
The model is essentially a template database used in the creation of any new user database created in the instance.

What are primary keys and foreign keys?
Primary keys are the unique identifiers for each row. They must contain unique values and cannot be null. Due to their importance in relational databases, Primary keys are the most fundamental of all keys and constraints. A table can have only one Primary key.
Foreign keys are both a method of ensuring data integrity and a manifestation of the relationship between tables.

What is data integrity? Explain constraints?
Data integrity is an important feature in SQL Server. When used properly, it ensures that data is accurate, correct, and valid. It also acts as a trap for otherwise undetectable bugs within applications.

A PRIMARY KEY constraint is a unique identifier for a row within a database table. Every table should have a primary key constraint to uniquely identify each row and only one primary key constraint can be created for each table. The primary key constraints are used to enforce entity integrity.

A UNIQUE constraint enforces the uniqueness of the values in a set of columns, so no duplicate values are entered. The unique key constraints are used to enforce entity integrity as the primary key constraints.

A FOREIGN KEY constraint prevents any actions that would destroy links between tables with the corresponding data values. A foreign key in one table points to a primary key in another table. Foreign keys prevent actions that would leave rows with foreign key values when there are no primary keys with that value. The foreign key constraints are used to enforce referential integrity.

A CHECK constraint is used to limit the values that can be placed in a column. The check constraints are used to enforce domain integrity.

A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to enforce domain integrity, as the check constraints.

Complete Series of SQL Server Interview Questions and Answers
SQL Server Interview Questions and Answers – Introduction
SQL Server Interview Questions and Answers – Part 1
SQL Server Interview Questions and Answers – Part 2
SQL Server Interview Questions and Answers – Part 3
SQL Server Interview Questions and Answers – Part 4
SQL Server Interview Questions and Answers – Part 5
SQL Server Interview Questions and Answers – Part 6
SQL Server Interview Questions and Answers Complete List Download

Reference : Pinal Dave (http://blog.SQLAuthority.com)


Posted in Database, Pinal Dave, SQL, SQL Authority, SQL Cursor, SQL Download, SQL Interview Questions and Answers, SQL Performance, SQL Query, SQL Scripts, SQL Security, SQL Server, SQL Stored Procedure, SQL Tips and Tricks, SQL Trigger, T SQL, Technology | 16 Comments

16 Responses

  1. on April 30, 2007 at 2:00 am Microsoft Blog Archives SQL Server and vBulletin - vBulletin Community Forum

    [...] The SQL Server 2000-supported replication types are as follows: Transactional; Snapshot; Merge It also acts as a trap for otherwise undetectable bugs within applications. A PRIMARY KEY Continue [...]


  2. on May 14, 2007 at 11:27 am Ashutosh

    HI Dave,

    No doubt that this web site is ultimate place for SQL stuff, I got a lot of information in this website, If you can provide information about DTS then it would be nice.

    thanks,


  3. on July 6, 2007 at 10:23 pm raju singh

    this website is so good, No doubt but i want to description with example, if u explain with example then it is very useful for me.

    From :
    Raju Singh


  4. on July 23, 2007 at 8:28 am Praveen Barath

    Really good stuff ,well versed explained and with a simple language .

    I would like to explore about CLUSTRING if you have some good stuff .Mail me

    Cheers
    Praveen


  5. on August 31, 2007 at 1:20 pm senthil.c

    hi,
    why we declare the variable for constraint……


  6. on November 4, 2007 at 12:21 pm Raju

    Hi ,

    How can we find 5 th record in a colomn..


  7. on November 6, 2007 at 11:38 am Mahesh

    Hi ..can anyone tell me how to return last 99 rows out of 100 rows in ms sql..thanks in advance


  8. on November 15, 2007 at 9:26 pm ScottPletcher

    Very, very nice (again).

    But, for this command:

    SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2

    to give an “accurate” count, don’t you need to update usage on the table first?

    [
    DBCC UPDATEUSAGE (0, 'table1')
    SELECT rows ...
    ]


  9. on January 4, 2008 at 1:25 am Pappu

    ONE OF THE BEST WEBSITE FOR FRESHER
    KNOWLEDGE


  10. on January 5, 2008 at 1:21 am Vijay

    Pinal, in addition to primary and foreign keys there is composite keys which is formed by a combination of more than one column.


  11. on March 8, 2008 at 10:22 pm Saju

    How to set a composite primary key in SQLSERVER 2005?

    Thanks,


  12. on April 21, 2008 at 9:55 am Atul

    Hi Friends,

    I am looking for SQL documents which can help me to clear the interview. please can anyone provide me SQL PDF ?

    Warm regards
    Atul


  13. on June 28, 2008 at 3:34 pm Prakash

    I want SQL Interviw Questions and Answers.

    Prakash


  14. on September 12, 2008 at 10:32 am kasikumar

    Respected Sir,

    I need details about extented stored procedure.

    With regards,
    Kasikumar


  15. on September 20, 2008 at 11:35 am pinaldave

    UPDATE : Interview Questions and Answers are now updated with SQL Server 2008 Questions and its answers. New Location : SQL Server 2008 Interview Questions and Answers.

    Please continue with your questions and answers at new location.


  16. on February 24, 2009 at 6:23 pm SQL SERVER - Database Interview Questions and Answers Complete List Journey to SQL Authority with Pinal Dave

    [...] Server Interview Questions and Answers – Part 3 SQL Server Interview Questions and Answers – Part 4 SQL Server Interview Questions and Answers – Part 5 SQL Server Interview Questions and Answers – Part 6 SQL Server Interview Questions and Answers [...]



Comments are closed.

  • Search
  • About Pinal Dave

    Pinalkumar Dave is Microsoft SQL Server MVP, Solid Quality Mentor and a prominent author of over 1000 SQL Server articles at SQLAuthority. He is a dynamic and proficient Principal Database Architect, Corporate Trainer and Project Manager specializing in SQL Server Programming with over 7 years of hands-on experience. He holds a degree in Masters of Science and has accomplished a number of certifications including MCDBA and MCAD (.NET). He has also been awarded Regional Mentor for PASS Asia.


    LinkedIn - Pinal Dave Twitter - Pinal Dave facebook
    Feed Email

  • Blog Stats

    • 8,412,516 Readers
  • SQLAuthority Links


    My Homepage
    My Resume
    My Other Blog
           --------------------
    Top Downloads
       PDF Downloads
       Script Downloads

    Script Bank
       Favorite Scripts
       All Scripts - 1
       All Scripts - 2

    Top Articles
       Best Articles
       Favorite Articles - 1
       Favorite Articles - 2
           --------------------
    SQL Interview Q & A
    SQL Coding Standards
    SQL FAQ Download
           --------------------
    Jobs @ SQLAuthority
    Bookmark and Share
    AddThis Feed Button
  • Categories

    • About Me (49)
    • Best Practices (82)
    • Business Intelligence (6)
    • Data Warehousing (27)
    • Database (257)
    • DBA (121)
    • DigiCorp (7)
    • MVP (81)
    • Poll (5)
    • Readers Contribution (22)
    • Readers Question (28)
    • Software Development (62)
    • SQL Add-On (88)
    • SQL Backup and Restore (48)
    • SQL BOL (8)
    • SQL Coding Standards (21)
    • SQL Constraint and Keys (49)
    • SQL Cursor (30)
    • SQL Data Storage (36)
    • SQL DateTime (36)
    • SQL Documentation (193)
    • SQL Download (198)
    • SQL Error Messages (116)
    • SQL Function (104)
    • SQL Humor (22)
    • SQL Index (82)
    • SQL Interview Questions and Answers (54)
    • SQL Joins (61)
    • SQL Optimization (51)
    • SQL Performance (204)
    • SQL Puzzle (18)
    • SQL Security (115)
    • SQL Server DBCC (42)
    • SQL Server Management Studio (17)
    • SQL Stored Procedure (97)
    • SQL String (17)
    • SQL System Table (27)
    • SQL Trigger (27)
    • SQL User Group (41)
    • SQL Utility (116)
    • SQL White Papers (8)
    • SQLAuthority (308)
      • SQLAuthority Author Visit (62)
      • SQLAuthority Book Review (19)
      • SQLAuthority News (278)
      • SQLAuthority Website Review (23)
    • SQLServer (42)
    • Tech (773)
      • Pinal Dave (762)
      • SQL Scripts (490)
    • Technology (1024)
      • SQL (1024)
      • SQL Authority (1024)
      • SQL Query (1024)
      • SQL Server (1024)
      • SQL Tips and Tricks (1024)
      • T SQL (1024)
  • Top Posts

    • SQL SERVER - Insert Data From One Table to Another Table - INSERT INTO SELECT - SELECT INTO TABLE
    • SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL
    • SQL SERVER - Import CSV File Into SQL Server Using Bulk Insert - Load Comma Delimited File Into SQL Server
    • SQL SERVER - Retrieve Current Date Time in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}
    • SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects
    • SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT
    • SQL Server Interview Questions and Answers Complete List Download
    • SQL SERVER - Restore Database Backup using SQL Script (T-SQL)
    • SQL SERVER - 2005 List All Tables of Database
    • SQL SERVER - 2008 - Interview Questions and Answers Complete List Download
    • SQL SERVER - Shrinking Truncate Log File - Log Full
    • SQL SERVER - TRIM() Function - UDF TRIM()
  • Authors

    • pinaldave
      • SQLAuthority News – Request SQLAuthority.com Stickers and SQL Server Cheat Sheet
      • SQLAuthority News – Authors Visit – K-MUG TechEd Trivandrum on June 27, 2009
      • SQLAuthority News – Book Review – Murach’s SQL Server 2008 for Developers
      • SQLAuthority News – Authors Visit – DotNet Buzz Delhi TechEd Delhi on July 11, 2009
      • SQL SERVER – Languages for BI – MDX, DMX, XMLA
      • SQLAuthority News – FIX : Error : HP OfficeJet Scanning and Printing Gray or Pink Shades
      • SQL SERVER – Disk Partition Alignment Best Practices
      • SQLAuthority News – Book Review – The Rational Guide to Building Technical User Communities (Rational Guides)
      • SQLAuthority News – MVP Award Renewed
      • SQL SERVER – Difference between Line Feed (\n) and Carriage Return (\r) – T-SQL New Line Char
  • Archives

    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • February 2007
    • January 2007
    • December 2006
    • November 2006
  • Pages

    • Resume
    • All Articles
    • Jobs
    • Copyright
    • SQL Interview Q & A
    • Contact Me
      • googledceeba0da7ad381a.html
      • Contact Me – Archive 1
      • Contact Me – Archive 2
    • Hire Me
  • Category Cloud

    About Me Best Practices Database DBA MVP Pinal Dave Software Development SQL SQL Add-On SQL Authority SQLAuthority Author Visit SQLAuthority News SQL Documentation SQL Download SQL Error Messages SQL Function SQL Index SQL Interview Questions and Answers SQL Joins SQL Optimization SQL Performance SQL Query SQL Scripts SQL Security SQL Server SQL Stored Procedure SQL Tips and Tricks SQL Utility Technology T SQL
  •  

    April 2007
    M T W T F S S
    « Mar   May »
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  
  • Add to Technorati Favorites
    Software blogs Blogarama - The Blog Directory
    Technology blogs Programming Blogs - BlogCatalog Blog Directory TopOfBlogs
    Page copy protected against web site content infringement by Copyscape Blog Directory
    Visit blogadda.com to discover Indian blogs

Blog at WordPress.com.

Theme: Mistylook by Sadish.