Created
September 8, 2011 21:29
-
-
Save zippy1981/1204807 to your computer and use it in GitHub Desktop.
Demonstrating CREATE DATABASE file case insensitivity to @grrl_geek
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE master; | |
GO | |
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'dropMe') | |
DROP DATABASE [dropMe] | |
GO | |
CREATE DATABASE dropMe; | |
GO | |
DECLARE @fileName VARCHAR(MAX) | |
SELECT @fileName = LOWER(physical_name) from dropMe.sys.database_files WHERE type_desc='ROWS' | |
SELECT @fileName as [@fileName] | |
EXEC sp_detach_db 'dropMe' | |
DECLARE @strSql NVARCHAR(MAX) | |
SELECT @strSql = 'CREATE DATABASE dropme ON (FILENAME=''' + @fileName + ''') FOR ATTACH' | |
EXEC sp_executesql @strSql | |
GO | |
SELECT physical_name from dropMe.sys.database_files WHERE type_desc='ROWS' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment