Once you have renamed your server from ServerA to ServerB you will notice that if you run the following:
SELECT @@SERVERNAME
You will still see that SQL thinks it is still called ServerA.
To resolve this you will need to run the following:
sp_dropserver ServerA
GO
sp_addserver ServerB, local
GO
This blog is mostly a blog for me with hints to remember those little bits of code etc where ever I am. Please be aware of this when reading any of the posts as they are mainly reminders for me. When I get time I will try to flesh out those sections that are a little ambiguous.
Friday, 21 January 2011
Listing SQL Database File Locations
CREATE TABLE #Files (
[DatabaseName] sysname NOT NULL,
[name] [nchar] (128) NOT NULL,
[physical_name] [nchar] (260) NOT NULL
)
EXEC sp_msforeachdb 'Use [?]
INSERT #Files
SELECT "?", name, physical_name FROM sys.database_files'
SELECT * FROM #Files
ORDER BY #Files.DatabaseName
DROP TABLE #Files
[DatabaseName] sysname NOT NULL,
[name] [nchar] (128) NOT NULL,
[physical_name] [nchar] (260) NOT NULL
)
EXEC sp_msforeachdb 'Use [?]
INSERT #Files
SELECT "?", name, physical_name FROM sys.database_files'
SELECT * FROM #Files
ORDER BY #Files.DatabaseName
DROP TABLE #Files
Subscribe to:
Posts (Atom)