Microsoft SQL Server - oldest to most recentMicrosoft SQL Server - oldest to most recent

Help and howtos for Microsoft SQL Server

Microsoft SQL Server is Microsoft's relational database management system (RDBMS). Microsoft originally worked with Sybase on earlier versions but later parted company and Sybase renamed their version more recently to Sybase Adaptive Server Enterprise. The current version of SQL Server is SQL Server 2008 R2.

Post sort order: Post Date (Newest First) | Post Date (Oldest First) | Alphabetical | Date Updated

The user is not associated with a trusted SQL Server connectionThe user is not associated with a trusted SQL Server connection

Posted June 21st, 2008 in Microsoft SQL Server

Microsoft SQL Server allows you to connect using "windows authentication mode", which means using Windows logins, and "SQL Server AND windows authentication mode". In you create a SQL Server user and don't have the SQL Server authentication mode enabled, you won't be able to log in using that login, and will get error message 18452: "The user is not associated with a trusted SQL Server connection". This post looks at the error message and how to enable the appropriate authentication mode.

Read more »

Get a list of tables with MS SQL ServerGet a list of tables with MS SQL Server

Posted July 16th, 2008 in Microsoft SQL Server

I've recently been doing some work with Microsoft SQL Server but the server itself for this particular customer is behind a firewall and I have no way currently of connecting with the SQL Server tools, so have to access it via some PHP scripts running on a webserver inside the network. This is the first in a series of three posts about using the sp_tables, sp_columns and sp_stored_procedures stored proecedures about SQL Server databases. This first post looks at sp_tables.

Read more »

Describe table structure with MS SQL ServerDescribe table structure with MS SQL Server

Posted July 23rd, 2008 in Microsoft SQL Server

This is the second in a series of three posts about using the sp_tables, sp_columns and sp_stored_procedures stored procedures with Microsoft SQL Server databases. This post is about sp_columns which is used to describe the table structure of a SQL Server table.

Read more »

List stored procedures with MS SQL ServerList stored procedures with MS SQL Server

Posted July 30th, 2008 in Microsoft SQL Server

This is the third and final post in a series about using the sp_tables, sp_columns and sp_stored_procedures stored procedures with Microsoft SQL Server databases. This post is about sp_stored_procedures which is used to get a list of stored procedures in a SQL Server database.

Read more »

Unable to modify table, timeout expired errors with Microsoft SQL ServerUnable to modify table, timeout expired errors with Microsoft SQL Server

Posted August 12th, 2008 in Microsoft SQL Server

While modifying a table in Microsoft SQL Server with about 10 million records in it, I got the error message "unable to modify table - timeout expired..." and the table was not able to be modified. The solution was to change the timeout settings which is covered in this post.

Read more »

Check Index Fragmentation with SQL Server 2000/2005Check Index Fragmentation with SQL Server 2000/2005

Posted August 22nd, 2008 in Microsoft SQL Server

This post looks at how to check if an index is fragmented in a Microsoft SQL Server table and how to rebuild the index. The advice offered in this post works for both SQL Server 2000 and SQL Server 2005 although the methods are deprecated for SQL Server 2005 and are likely to be dropped in the next release. I will look at the alternate way of doing this for SQL Server 2005 in a later post.

Read more »

Export data from SQL Server to a tab file with bcpExport data from SQL Server to a tab file with bcp

Posted September 8th, 2008 in Microsoft SQL Server

The bcp command line tool allows you to import and export data from a SQL Server database into a text file. There is also a freebcp tool from the FreeTDS library so you can do this from Linux/Unix boxes as well. This post looks at how to export data from SQL Server into a tab file using bcp/freebcp.

Read more »

Export selected data from SQL Server to a tab file with bcpExport selected data from SQL Server to a tab file with bcp

Posted September 9th, 2008 in Microsoft SQL Server

This post is a follow up to yesterday's post titled "Export data from SQL Server to a tab file with bcp". In this post we will again export data from a SQL Server table into a tab file but this time will select which data we want to export. This means you can export just a subset of data from a large table. You could also join multiple tables and export to one file.

Read more »

Using Cursors with Microsoft SQL ServerUsing Cursors with Microsoft SQL Server

Posted September 19th, 2008 in Microsoft SQL Server

Just about everything I've ever read about cursors for Microsoft SQL Server say not to use them for a variety of reasons. There are some cases where using a cursor is a lot simpler or faster etc than using another method and so I've decided to quickly document an examaple of a SQL Server cursor here for my own reference.

Read more »

Using dateadd in SQL Server to add intervals to datesUsing dateadd in SQL Server to add intervals to dates

Posted October 4th, 2008 in Microsoft SQL Server

Last week I posted how to use date_add() in MySQL to add intervals to dates and today I will do the same but for Microsoft SQL Server using the dateadd() function.

Read more »

Connect to a different port with SQL Server Management StudioConnect to a different port with SQL Server Management Studio

Posted December 31st, 2011 in Microsoft SQL Server

Microsoft's SQL Server Management Studio will connect by default to port 1433 and there's nowhere in the connect dialog to specify a different port from the default. To connect using a different port specify the servername, a comma, and then the port number as shown in this post.

Read more »

Connect to SQL Server through an SSH tunnelConnect to SQL Server through an SSH tunnel

Posted January 4th, 2012 in Microsoft SQL Server

I recently needed to connect to a Microsoft SQL Server which I couldn't reach directly, but which is visible from a web facing Linux machine. I've covered how to create an SSH tunnel on Windows with PuTTY already and then it's simply a matter of connecting through the tunnel on the localhost to the SQL Server at the other end.

Read more »

SQL Server Express 2008 did not install successfullySQL Server Express 2008 did not install successfully

Posted December 18th, 2012 in Microsoft SQL Server

While attempting to install Visual Web Developer Express 2010 SP1 on Windows 2003 Server I got the error message "SQL Server Express 2008 R2 - This product did not install successfully."

Read more »