• Subscribe to this RSS feed
  • Receive updates as soon as they are posted.

SQL Server Category

I came upon a strange situation, that I had to really work with, to get it done. My website databases were all done in 2008, and backups would not work across hosts in my case (using .bak or detaching and getting .mdf files). So I went about learning to downgrade, since my new host used [...]

February 10 , 2011 | | In: SQL Server, SQL Server Tips

Renaming SQL 2008 Database

For quite a while, to rename a database, you could just execute the system stored procedure called ‘sp_renamedb’: EXEC sp_renamedb ‘OldName’, ‘NewName’ At one point though, as I understood it, the word was that it would not be supported after 2005.

Scenario: Your new table doesn’t exist, but you have a complicated (or not) TSQL statement that you’d like to run and have it all inserted into a new table.

If you ever get this error, whether it is in a SharePoint app or ASP.Net app, or directly in SQL Server, never delete the files directly. This will most likely cripple your application. Instead, truncate the database transaction logs directly from SQL Server Management Studio.

September 24 , 2010 | | In: SQL Server, SQL Server Tips

DateName Function in T-SQL

As you probably know, the month function runs against a date and returns numerically, giving you the number of the month of the year. For instance, if your date is in August, it will return an 8. If you want the name of the month, you need to use DateName, which uses 2 parameters, including [...]

September 14 , 2010 | | In: SQL Server, SQL Server Tips

SQL Statements followed by Semi-colon

You might see some examples on the net in which a semi-colon is used as a separator between multiple sql statements. This is still a requirement in some databases, but not generally, in SQL Server or MS Access. It can be used and recognized, but it is not necessary in most cases. In one case, [...]

August 25 , 2010 | | In: SQL Server, SQL Server Tips

Get a Week’s Start and End Dates

To be able to use any date, and based on that date, get the start (Sunday) and end (Saturday) dates, use the following T-SQL:

-->