How to Enable the SQL Server Agent XPs using T-SQL

If you’re creating a SQL Server Agent job for the first time, you might find that you need to enable the SQL Server Agent extended stored procedures (SQL Server Agent XPs) first.

When you use the SQL Server Management Studio (SSMS) tool to start the SQL Server Agent service, these extended stored procedures are enabled automatically.

When you use T-SQL, you can enable the SQL Server Agent XPs with the sp_configure stored procedure.

Read more

SQL Server Error 206: Operand type clash

SQL Server error Msg 206, Level 16 is a common error to get when inserting data into a table.

It happens when you’re trying to insert data into a column that is incompatible with the data type you’re trying to insert.

This could happen if you accidentally try to insert data into the wrong column (or even the wrong table). But it could also happen if you incorrectly assume that SQL Server will convert the data for you.

To fix this issue, make sure you’re inserting the correct data type.

Read more

How to Map Multiple Partitions to a Single Filegroup in SQL Server (T-SQL)

If you’re familiar with creating partitioned tables in SQL Server, you might be used to creating a separate filegroup for each partition. This has its benefits, and may very well be the method you would choose in most scenarios.

However, you also have the option of mapping multiple partitions to a single filegroup.

In this article I share two examples of mapping multiple partitions to a single filegroup.

  • Example 1 maps all partitions to a single filegroup.
  • Example 2 maps some partitions to one filegroup, and some to another.

Read more

How to Rename a Table in SQL

In SQL, most RDBMSs allow you to rename a table using the ALTER TABLE statement, which is the statement used to modify the definition of an existing table.

Some RDBMs also include a RENAME statement for renaming tables.

But if you use SQL Server, you’ll need to use the sp_rename stored procedure.

Read more