Database tutorials

SQL Server 2005: How To Enable xp_cmdshell

contributed by Rob Rogers on January 24, 2007 under Database

As a security safeguard, Microsoft has turned off the use of xp_cmdshell by default in the latest version of SQL Server. This built-in extended stored procedure can come in quite handy as it gives you the ability to run any command line process from a stored procedure or job. To enable xp_cmdshell, do the following…

 

SQL Server 2005: Include Column Headers When Copying Grid Query Results

contributed by Rob Rogers on under Database

Previous versions of SQL Server have featured the ability to create grid result sets from queries so that one can easily copy and paste the data into another application. Unfortunately, the column headers were not copied, so you then would have to go into the application and add the header by hand. SQL Server 2005 provides a new option that will allow you to copy the column headers with the data. Here is how to activate this handy option…

 

SQL Server 2005: Return a Comma Delimited Result Set from Queries

contributed by Rob Rogers on under Database

One almost always runs into a situation that requires a comma delimited result set from a query so that the data can be utilized by other software. Luckily, this is a native feature in the Query Editor.

 

SQL Server 2005: Configure Max Number of Characters Displayed in Each Column

contributed by Rob Rogers on under Database

It is sometimes necessary to modify the number of characters displayed in a query result set, especially when you are dealing with results containing a large number of columns. To configure the maximum number of characters displayed, do the following…

 

Mimic The MySQL LIMIT Feature in Microsoft SQL Server

contributed by johnnythawte on November 20, 2006 under Database

MySQL includes a nifty feature that lets you select only rows 1-10, 11-20, or any set you want. Microsoft SQL Server does not include this feature. This recipe will show you how to mimic the same feature easily without stored procedures.

 

SQL Server 2005: How to Attach (or Reattach) a Database Missing the LDF

contributed by Rob Rogers on under Database

If you need to attach a database that has no log file (.LDF), or have deleted the log file because it was too big and need to reattach the database, SQL Server 2005 does allow you to do this. You can attach the database by following this Tech-Recipe:

 

SQL Server – Get Physical Names and Attributes of Database Files

contributed by Rob Rogers on October 17, 2006 under Database

You can get the file location, size, maxsize, growth and usage attributes of a database without leaving your Enterprise Manager or Management Studio. To do this:

 

Microsoft SQL Server: Determining CD Key

contributed by Rob Rogers on October 16, 2006 under Database

You can easily determine your CD key for your SQL Server software by just typing a few lines into the query window. To do this: