The SQL Server developer T-SQL functions interview questions
Written by: Jeremy kadlec
From:
Http://www.mssqltips.com/tip.asp? Tip = 1588
Problem
In the latest installment of the mssqltips
Interview question series we are going to cover questions on T-SQL
Functions. The questions are categorized as either easy, moderate or
Difficult with the question available to read, but the answers are
Hidden to challenge yourself. Once you have your answer formulated
Then highlight the answer To see how you have done. Good luck!
Solution
Question Difficulty = easy
- Question 1-True or false-T-SQL is the only programming language in SQL Server with functions.
- False-these SQL Server versions ages have functions:
- XQuery
- SQL Server integration services
- Common Language Runtime
- Reporting Services
- Mdx
- Question 2-what are the positional functions in T-SQL and what value do they provide?
- Left-returns the left part of a character string with the specified number of characters.
- Right-returns the right part of a character string with the specified number of characters.
- Substring-returns the portion of the string.
- Additional information-
Web SQL Server 2000 text data manipulation
- Question 3-what are the rounding functions in SQL Server and what value do they provide?
- Round-rounds a positive or negative value to a specific length.
- Ceiling-returns the smallest integer greater than, or equal to, the specified numeric expression.
- Floor-returns the largest integer less than or equal to the specified numeric expression.
- Question 4-what are the two functions that can change the data type of a column or a variable for additional manipulation?
- Question 5-what is the function that will change the format of a date?
- Convert
- Additional information-
Date/time conversions using SQL Server
Question Difficulty = moderate
- Question 1-True or false-all of the T-SQL functions are mathematical.
- False-below outlines the types of T-SQL functions:
- Manipulate strings.
- System functions.
- Dynamic management functions
.
- Security functions.
- Cursor functions.
- Meta data functions.
- Ranking functions.
- User defined functions can be created in T-SQL or the SQL Server CLR.
- Additional information-
Web SQL Server 2000 text data manipulation
- Question 2-name 5 or more string manipulation functions and their functionality.
- Charindex (findtextdata, textdata, [startingposition])
- Left (character_expression, integer_expression)
- Len (textdata)
- Lower (character_expression)
- Ltrim (textdata)
- Patindex (findtextdata, textdata)
- Replace (textdata, findtextdata, replacewithtextdata)
- Replicate (character_expression, integer_expression)
- Reverse (character_expression)
- Rtrim (textdata)
- Space (numberofspaces)
- Stuff (textdata, start, length, inserttextdata)
- Substring (textdata, startposition, length)
- Upper (character_expression)
- Additional information-
Web SQL Server 2000 text data manipulation
- Question 3-name 5 or more of the properties that can be used with the indexproperty function.
- Indexdepth
- Indexfillfactor
- Indexid
- Isautostatistics
- Isclustered
- Isfulltextkey
- Ishypothetical
- Ispadindex
- Ispagelockdisallowed
- Isrowlockdisallowed
- Isstatistics
- Isunique
- Additional information-
Retrieving SQL Server Index properties with indexproperty
- Question 4-what is a common use case for the OpenRowSet function?
- Import from Excel to SQL Server or export data from SQL Server to excel.
- Additional information-
Export data from SQL Server to excel
- Question 5-What function can determine the number of rows inserted, updated or deleted?
- The @ rowcount function can be used to determine the changes from the previous statement in Stored Procedure or script.
Question Difficulty = difficult
- Question 1-True or false-the Len () function returns the length for any data type.
- False-the Len () function will return an error message for text, ntext and image columns in SQL Server.
- Additional information-
How to Get length of data in text, ntext and image columns in SQL Server
- Question 2-with the new error handling paradigm in SQL Server 2005 and beyond what are the new system commands available?
- With the new try and catch commands, the following system functions are available:
- Error_line
- Error_message
- Error_procedure
- Error_severity
- Error_state
- Additional information-
SQL Server 2005 try and catch Exception Handling
And
Standardized SQL Server Error Handling and centralized Logging
- Question 3-What function can be used in a trigger to determine if a specific column was updated?
- The Update () function can be used in
Trigger to determine if a column has been updated or not, then further
Logic can conditionally executed.
- Question 4-what is the difference between a deterministic and non deterministic function?
- Deterministic functions always return
Same result any time they are called with a specific set of input
Values and given the same state of the database.
- Nondeterministic functions may return
Different results each time they are called with a specific set
Input values even if the database state that they access remains
Same.
- Source-SQL Server 2005 books online-deterministic and Nondeterministic Functions
- Question 5-what are some of the functions that will assist in determining which user is executing a specific piece of code?
- CURRENT_USER
- Host_id
- Host_name
- Original_login
- Session_user
- System_user
- User_name
Next steps
- As you prepare for a DBA or developer interview be sure to have your bases covered by reviewing the SQL Server interview questions
On mssqltips.
- Functions offer a great deal of value to simplify and
Standardize T-SQL code. Having a firm handle on the built-in and
Custom options guest SS T-SQL, the CLR, reporting services, etc.
- Do you have some common SQL Server interview questions that
Were not supported ded in this tip that you ask as a portion of your
Interviews? Feel free to post them in the forum below.