Category Archives: Sql Server Tutorials

SQL Server Management Studio scripting on TSQL commands

Scenario

With SQL Server Management Studio you have the ability to do just about everything you can do using T-SQL commands.  One problem with using the GUI is that it is difficult to remember everything you clicked on to reproduce the behavior a second time.  Another issue is that most of what you do through the GUI is done immediately which may not always be the best scenario.  How can I capture what SQL Server is doing so I can reproduce the behavior or run the commands at a later time.

Solution

A nice addition to SQL Server Management Studio is the ability to script out most of the commands and operations that you can do through the GUI.  Let’s take a look at doing a database backup as an example.  Continue reading SQL Server Management Studio scripting on TSQL commands

#SqlServer interview question: What are ranking functions?

Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. Each of the ranking functions also needs the OVER( ) clause.

The different ranking functions are as follows: Continue reading #SqlServer interview question: What are ranking functions?

How do you find the index size of a table?

We can use the following query to find the size of the index. Continue reading How do you find the index size of a table?

#SqlServer interview question: What is typed XML?

We can create variables, parameters, and columns of the xml datatype – if we associate a collection of XML schemas with a variable, parameter, or column of xml datatype. In this case, the xml datatype instance is called typed XML. Continue reading #SqlServer interview question: What is typed XML?

#SqlServer interview question: What is RAISEERROR?

SQL Server will raise errors when the code you have written cannot or should not execute.

For example, a table should not be created if one with the same name already exists. Suppose you have a stored procedure named UpdateOneRecord which changes one record at a time. Continue reading #SqlServer interview question: What is RAISEERROR?