SQL Consolidate rows

I'm trying to consolidate the rows of this query

select CASE WHEN [type_desc] = 'ROWS' THEN [physical_name] ELSE NULL END as [database_path], CASE WHEN [type_desc] = 'LOG' THEN [physical_name] ELSE NULL END as [log_path] from sys.master_files 
WHERE [database_id] = 13

Open in new window

database_path      log_path
E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\Exchange_2013.mdf      NULL
NULL      L:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data\Exchange_2013_log.ldf

Should look like this

database_path                                                                                                                              log_path
E:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\Exchange_2013.mdf      L:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data\Exchange_2013_log.ldf
Any help much appreciated

Mauro CazabonnetSenior .NET Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
This may work but only if you've a single row for the transaction log and it will repeat it if you have more than one that file:
select [physical_name] as [database_path], 
	(SELECT [physical_name] 
	from sys.master_files 
	WHERE [database_id] = 13 AND [type_desc] = 'LOG') as [log_path] 
from sys.master_files
WHERE [database_id] = 13 AND [type_desc] = 'ROWS'

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mauro CazabonnetSenior .NET Software EngineerAuthor Commented:
Vitor MontalvãoMSSQL Senior EngineerCommented:
Correction: "it will repeat log files if you have more than one data file"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.