SP gets the database file path for violent migration server

Source: Internet
Author: User

ALTER PROCEDURE [dbo]. [Usp_showallfilename]
As
BEGIN

DECLARE @px INT = 0
DECLARE @dbname VARCHAR (30)
DECLARE @sql VARCHAR (MAX)
IF object_id (' tempdb.. #dbs ', ' U ') is not NULL
DROP TABLE #dbs
IF object_id (' tempdb.. #tbfname ', ' U ') is not NULL
DROP TABLE #tbfname
CREATE TABLE #tbfname
(
ID INT IDENTITY (1, 1),
dbname VARCHAR (40),
FName VARCHAR (200)
)
SELECT id = IDENTITY (INT, +),
Name
Into #dbs
From Master.sys.databases DB
WHERE db.database_id > 4
and Db.name not in (' ReportServer ',
' ReportServerTempDB ')
while (@px < (SELECT MAX (ID)
From #dbs
) )
BEGIN
SELECT TOP 1
@dbname = #dbs. Name
From #dbs
SET @sql = ' use ' + @dbname
+ ' SELECT ' [email protected] + ', filename from Sys.sysfiles '
INSERT #tbfname EXEC (@sql)
SET @px = @px + 1
DELETE #dbs
WHERE name = @dbname
END
SELECT *
From #tbfname
END

SP gets the database file path for violent migration server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.