• 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 3
SQL Server Interview Questions and Answers – Part 5 »

SQL Server Interview Questions and Answers – Part 4

April 18, 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 is SQL Profiler?
SQL Profiler is a graphical tool that allows system administrators to monitor events in an instance of Microsoft SQL Server. You can capture and save data about each event to a file or SQL Server table to analyze later. For example, you can monitor a production environment to see which stored procedures are hampering performance by executing too slowly.

Use SQL Profiler to monitor only the events in which you are interested. If traces are becoming too large, you can filter them based on the information you want, so that only a subset of the event data is collected. Monitoring too many events adds overhead to the server and the monitoring process and can cause the trace file or trace table to grow very large, especially when the monitoring process takes place over a long period of time.

What is User Defined Functions?
User-Defined Functions allow to define its own T-SQL functions that can accept 0 or more parameters and return a single scalar data value or a table data type.

What kind of User-Defined Functions can be created?
There are three types of User-Defined functions in SQL Server 2000 and they are Scalar, Inline Table-Valued and Multi-statement Table-valued.

Scalar User-Defined Function
A Scalar user-defined function returns one of the scalar data types. Text, ntext, image and timestamp data types are not supported. These are the type of user-defined functions that most developers are used to in other programming languages. You pass in 0 to many parameters and you get a return value.

Inline Table-Value User-Defined Function
An Inline Table-Value user-defined function returns a table data type and is an exceptional alternative to a view as the user-defined function can pass parameters into a T-SQL select command and in essence provide us with a parameterized, non-updateable view of the underlying tables.

Multi-statement Table-Value User-Defined Function
A Multi-Statement Table-Value user-defined function returns a table and is also an exceptional alternative to a view as the function can support multiple T-SQL statements to build the final result where the view is limited to a single SELECT statement. Also, the ability to pass parameters into a T-SQL select command or a group of them gives us the capability to in essence create a parameterized, non-updateable view of the data in the underlying tables. Within the create function command you must define the table structure that is being returned. After creating this type of user-defined function, It can be used in the FROM clause of a T-SQL command unlike the behavior found when using a stored procedure which can also return record sets.

Which TCP/IP port does SQL Server run on? How can it be changed?
SQL Server runs on port 1433. It can be changed from the Network Utility TCP/IP properties –> Port number.both on client and the server.

What are the authentication modes in SQL Server? How can it be changed?
Windows mode and mixed mode (SQL & Windows).

To change authentication mode in SQL Server click Start, Programs, Microsoft SQL Server and click SQL Enterprise Manager to run SQL Enterprise Manager from the Microsoft SQL Server program group. Select the server then from the Tools menu select SQL Server Configuration Properties, and choose the Security page.

Where are SQL server users names and passwords are stored in sql server?
They get stored in master db in the sysxlogins table.

Which command using Query Analyzer will give you the version of SQL server and operating system?
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'),
What is SQL server agent?
SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose is to ease the implementation of tasks for the DBA, with its full-function scheduling engine, which allows you to schedule your own jobs and scripts.

Can a stored procedure call itself or recursive stored procedure? How many level SP nesting possible?
Yes. Because Transact-SQL supports recursion, you can write stored procedures that call themselves. Recursion can be defined as a method of problem solving wherein the solution is arrived at by repetitively applying it to subsets of the problem. A common application of recursive logic is to perform numeric computations that lend themselves to repetitive evaluation by the same processing steps. Stored procedures are nested when one stored procedure calls another or executes managed code by referencing a CLR routine, type, or aggregate. You can nest stored procedures and managed code references up to 32 levels.

What is @@ERROR?
The @@ERROR automatic variable returns the error code of the last Transact-SQL statement. If there was no error, @@ERROR returns zero. Because @@ERROR is reset after each Transact-SQL statement, it must be saved to a variable if it is needed to process it further after checking it.

What is Raiseerror?
Stored procedures report errors to client applications via the RAISERROR command. RAISERROR doesn’t change the flow of a procedure; it merely displays an error message, sets the @@ERROR automatic variable, and optionally writes the message to the SQL Server error log and the NT application event log.

What is log shipping?
Log shipping is the process of automating the backup of database and transaction log files on a production SQL server, and then restoring them onto a standby server. Enterprise Editions only supports log shipping. In log shipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db can be used this as the Disaster Recovery plan. The key feature of log shipping is that is will automatically backup transaction logs throughout the day and automatically restore them on the standby server at defined interval.

What is the difference between a local and a global variable?
A local temporary table exists only for the duration of a connection or, if defined inside a compound statement, for the duration of the compound statement.

A global temporary table remains in the database permanently, but the rows exist only within a given connection. When connection are closed, the data in the global temporary table disappears. However, the table definition remains with the database for access when database is opened next time.

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 DBA, Pinal Dave, SQL, SQL Authority, SQL Download, SQL Function, SQL Interview Questions and Answers, SQL Joins, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQL Trigger, T SQL, Technology | 17 Comments

17 Responses

  1. on April 18, 2007 at 8:29 am srisailam

    what is query execution plan


  2. on April 18, 2007 at 8:58 am pinaldave

    srisailam,
    A query execution plan outlines how the SQL Server query optimizer actually ran a specific query. This information if very valuable when it comes time to find out why a specific query is running slow.
    Thank you,
    Pinal Dave
    (http://www.SQLAuthority.com)


  3. on July 10, 2007 at 12:34 pm Vikram P

    Hi Pinal ,
    We are trying to print some logs from an MS SQL function.
    Since it trows error for print, tried inserting to a table declared within the function. I think the scope of the table that is used to create logs ends when the functions stops.

    Would you have any idea what we could do to print the logs?


  4. on July 10, 2007 at 9:26 pm pinaldave

    Vikram,

    I always used log to restore database in point of time, I never tried to print them. You may search for third party tool to do that.

    Regards,
    Pinal Dave (http://www.SQLAuthority.com)


  5. on July 20, 2007 at 2:47 am Mallika

    excellent reply


  6. on August 3, 2007 at 12:26 am Priyanka

    Excellent interview questions.


  7. on August 19, 2007 at 8:33 am Saeed Tabrizi

    Hi Dear
    Im using sql server 2005 in my network .
    But I have a problem with it .
    Sql server 2005 is too slow on windows authentication mode .
    For Example , my administrator account connect to server by 15 second’s delay .
    Did You know any thing about this problem ?
    I tried by mix mode( sql authentication ), all things is Ok .
    Thanks .


  8. on September 4, 2007 at 6:51 am Surj

    Hi Pinal,
    I am tryng to write a trigger in SQL server 2000 to capture the NT usernames updating a databasev table .Can you please let me know how can I do that ?
    Thanks
    Surj


  9. on October 5, 2007 at 3:59 am Rahul

    Excellent Answers

    Thanx
    Rahul


  10. on January 20, 2008 at 5:06 am Max

    Hello Pinal.
    I have SQL server 2000 with SQL Authentication. Can I test user’s login and IP when he is connecting to the server. Our network doesn’t use Domain. Maybe you know some intresting links where I’ll find the answer.
    All what I want is just – “User can logging only from his computer”.

    Thanks


  11. on April 21, 2008 at 2:58 pm Ignatius

    hi Pin,
    Very good work ! I wish you to do more!
    may GOD bless you

    by
    IGNATIUS


  12. on April 24, 2008 at 5:53 pm Sharad Agarwal

    HII Mr. Dave,

    Sir i have a question which was asked to me in an interview.
    plz telll me the solution :

    if i fire a set of queries or a single query in database, and after that want to know the status of database means, how much rows are affected.how much aredeleted how much are updated and how much are untouched.and how much are inserted.

    I think thr is a property in sqlserver by which we can know that staus of database.

    Sir Plz help me.

    Thank you

    Sharad Agarwal


  13. on July 8, 2008 at 8:16 pm mani

    I need to know whether we can create single user for two different database in sql 2005


  14. on July 15, 2008 at 2:24 am Pratap

    I read all the question-answers. It was great to have this kind of knowledge. However, I got confused with the following question-answer.

    I do not know whether you made a typo in the question. Even if you made a typo, I am not satisfied with the answer of the question about the temp tables. Please let all know about the real answer.

    Thanks.

    Pratap.

    What is the difference between a local and a global variable?
    A local temporary table exists only for the duration of a connection or, if defined inside a compound statement, for the duration of the compound statement.

    A global temporary table remains in the database permanently, but the rows exist only within a given connection. When connection are closed, the data in the global temporary table disappears. However, the table definition remains with the database for access when database is opened next time.


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


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



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,407,747 (63 Million+)
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 44,149 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: