开发者

i want to store size of the log file in a temp table

开发者 https://www.devze.com 2023-02-11 02:51 出处:网络
what is the wrong with insert into #tempA(MailSize) EXEC sp_foreachdb_dev @command = N\' USE ? SELECT(size * 8)/1024.0 AS size_in_mb FROM

what is the wrong with

insert into #tempA(MailSize) EXEC sp_foreachdb_dev @command = N' USE ? SELECT (size * 8)/1024.0 AS size_in_mb FROM

sys.database_files WHERE

data_space_id = 0', @user_only = '开发者_开发百科1' select * from #tempA

i want to store size of the log file in a temp table


Numerous problems:

  • The procedure you want is sp_msforeachdb
  • That procedure takes parameter @command1
  • There is no @user_only parameter.

The version below works:

create table #tempA (
    MailSize decimal
)

insert into #tempA(MailSize) 
    EXEC sp_msforeachdb 
        @command1 = N' USE ? 
                       SELECT (size * 8)/1024.0 AS size_in_mb 
                       FROM sys.database_files 
                       WHERE data_space_id = 0'

select * from #tempA

drop table #tempA
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号