Hi All,
I am trying to grab disk free space information from all the SQL server instances and dump into central server database.
I am using openrowset for all the versions and it works well for SQL 2005, 2008 and 2008 R2.
But when it comes to SQL 2012, it throws following error.
Msg 11519, Level 16, State 1, Server , Procedure sp_describe_first_result_set, Line 1
The metadata could not be determined because statement 'exec master.dbo.xp_fixeddrives' invokes an extended stored procedure.
My script is as following.
USE
[DBAdmin]
GO
/****** Object: StoredProcedure [dbo].[usp_DiskSpace_Information_2012_to_2014] Script Date: 6/29/2015 4:25:59 PM ******/
SET
ANSI_NULLSON
GO
SET
QUOTED_IDENTIFIERON
GO
ALTER
PROC[dbo].[usp_DiskSpace_Information_2012_to_2014]
AS
SET
NOCOUNTON
BEGIN
declare@srvr varchar(100)
declare@SQL varchar(max)
declare@QueryFlag varchar(1)
declareServerName cursorforselectServerName,QueryFlag fromDBAdmin.dbo.ServerList whereVersionin('2012','2014')
and ([Accessible] IN('Y'))
--(StatusFlag NOT IN ('Decommissioned') or QueryFlag NOT IN ('N'))
openServerName
fetchnextfromServerName into@srvr,@QueryFlag
while@@fetch_status=0
begin
if@QueryFlag ='L' -- Local domain server
begin
SET@SQL='insert into DBAdmin.dbo.DiskSpace_Information
SELECT '''
+@srvr+''',*
FROM OPENROWSET(''SQLNCLI'', ''Server='
+@srvr+';Trusted_Connection=yes;'',
''exec master.dbo.xp_fixeddrives
'')'
EXEC (@SQL)
end
fetchnextfromServerName into@srvr,@QueryFlag
end
closeServerName
deallocateServerName
END
------------------------------------------------------------------
I also tried to use
SET FMTONLY OFF but it is still same.
Can you please let me know how to solve the issue?
I have 150 instances so can not create linked server for all the server.
Thanks for your help in advance.
Regards,
Naman