We help IT Professionals succeed at work.

SQL Consolidate rows

135 Views
Last Modified: 2017-04-05
Hi,
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

Regards,
M
Comment
Watch Question

IT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Mauro CazabonnetSenior Windows Automation Developer
CERTIFIED EXPERT
Top Expert 2015

Author

Commented:
thx!!!!
Vitor MontalvãoIT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Correction: "it will repeat log files if you have more than one data file"