• Home
  • All Articles
  • SQL Interview Q & A
  • Blog Stats
  • Contact
    • Resume
    • Performance
    • Community Rules
    • Copyright
  • Tools
    • Pluralsight
    • NuoDB
    • Idera
    • Embarcadero
    • Red Gate
    • Devart SQL Server Tools
    • Melissadata
    • Koenig Solutions
    • Manage Engine
    • SQL Backup and FTP
  • SQL Books
    • SQL Interview Q & A
    • SQL Wait Stats
    • SQL 2012 J2P Vol 1
    • SQL 2012 J2P Vol 2
    • SQL 2012 J2P Vol 3
    • SQL 2012 J2P Vol 4
    • SQL 2012 J2P Vol 5
    • SQL Queries 2012 Joes 2 Pros Combo Kit
    • Learn SQL Server 2008
      • SQL Joes 2 Pros Vol 1
      • SQL Joes 2 Pros Vol 2
      • SQL Joes 2 Pros Vol 3
      • SQL Joes 2 Pros Vol 4
      • SQL Joes 2 Pros Vol 5
      • SQL Joes 2 Pros – Combo 5 Books
  • >>Search<<

SQL Server Journey with SQL Authority

Personal Notes of Pinal Dave

Feeds:
Posts
Comments
« SQL Server Interview Questions and Answers – Part 4
SQL Server Interview Questions and Answers – Part 6 »

SQL Server Interview Questions and Answers – Part 5

April 19, 2007 by pinaldave

SQL Server Interview Questions and Answers
Print Book Available (207 Pages) | Sample Chapters

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)

About these ads

Share:

  • More

Like this:

Like Loading...

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 | 17 Comments

17 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 [...]


  17. on April 20, 2013 at 7:01 am SQL SERVER – Weekly Series – Memory Lane – #025 | SQL Server Journey with SQL Authority

    [...] 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.

  • Community Initiatives

    pluralsight
    SQL Complete
    Idera
    RedGate
    Embarcadero
    koenig-solutions
    Melissa Data
    ManageEngine
    SQL Backup and FTP
  • About Pinal Dave

    Pinal Dave is a Pluralsight Developer Evangelist. He has authored 9 SQL Server database books and have written over 2500 articles on the database technology on his blog at a http://blog.sqlauthority.com. Along with 9+ years of hands on experience he holds a Masters of Science degree and a number of certifications, including MCTS, MCDBA and MCAD (.NET). His past work experiences include Technology Evangelist at Microsoft and Sr. Consultant at SolidQ. Prior to joining Microsoft he was awarded the Microsoft MVP award for three continuous years for his contribution in the community. Here is the list of the Pinal Dave's books.
    Twitter - Pinal Dave facebook Feed LinkedIn - Pinal Dave Youtube

    Follow @pinaldave
    Send +Pinal Dave an email at pinal@sqlauthority.com

    • 63,527,936 (63 Million+)
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 44,159 other followers

  • SQL in Sixty Seconds

  • SQL Books

    Amazon | 1 | 2 | 3 | 4 | 5
    Flipkart | 1 | 2 | 3 | 4 | 5

    SQL Interview Q and A
    Amazon | Kindle Flipkart
    SQL Wait Stats
    Amazon | Kindle Flipkart
  • Funny Index Video

  • SQLAuthority Links

    My Homepage
    Windows Live Blog
           --------------------
    Top Downloads
       PDF Downloads
       Script Downloads

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

    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
  • About Nupur Dave

    Nupur Dave loves technology simply because it makes life more convenient. She is devoted to technology because it touches our heart makes our daily lives easier. Among the many technological programs she uses and embraces Windows Live most because she can do lots of things with ease – from photo management to movies; business emails to personal social media connections.

  • Top 3 Commenters

      2857 - Madhivanan
      474 - Imran Mohammed
      301 - Ramdas Jaya
  • Page copy protected against web site content infringement by Copyscape

Blog at WordPress.com.

Theme: Customized MistyLook by WPThemes.


loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.
%d bloggers like this: