Search

IT Depends

a database administration blog

Month

July 2015

Modifying Logical Filenames in SQL Server (T-SQL)

So this is syntax I generally struggle to remember but since I perform quite a few restore operations to multiple development/staging servers and I’m quite particular about my neatness, I like to modify the logical file names for the database and log files.  It’s a simple script and it looks like this

ALTER DATABASE [DBNAME]
MODIFY FILE (NAME = Logical_filename1, NEWNAME = Locical_filename2);
GO

ALTER DATABASE [DBNAME]
MODIFY FILE (NAME = Logical_filename1_log, NEWNAME = Logical_filename2_log);
GO

According to Books Online (filespec being the modify file option)

Only one <filespec> property can be changed at a time. NAME must always be specified in the <filespec> to identify the file to be modified.

This is the reason for the two separate statements to modify the logical name of the database file and the log file.

Advertisements

Implicit Transactions and Try/Catch blocks

When I first came across SQL Server’s Try/Catch implementation back in 2005, one of the first things I tested was how transactions worked within them and whether or not both the try and catch blocks created implied transactions.

If you have no interest in any detail and you’re just after a quick answer, the answer is, No.  SQL Server Try/Catch blocks do not create implicit transactions as a result of their use.

If you didn’t want the details but now you’re thinking ‘Prove it’ then please read on.

Continue reading “Implicit Transactions and Try/Catch blocks”

Blog at WordPress.com.

Up ↑