0

当我在 SQL Server 2008 中使用此语句时:

    --INSERT INTO #tmp_file EXEC ('restore_database_proc N''' + @database_bak_path + '''')
    INSERT INTO #tmp_file EXEC ('RESTORE FILELISTONLY FROM DISK = N''' + @database_bak_path + '''') 
    set @database_mdf_oldname = (select LogicalName from #tmp_file where Type = 'D')
    set @database_log_oldname = (select LogicalName from #tmp_file where Type = 'L')

调试过程时变量 没有值,所以我想检查临时表是否有值以及为什么结果没有给出变量@database_mdf_oldname@database_log_oldname

4

1 回答 1

0

您可以添加一条选择语句select * from #tmp_file,并在 sql server 上显示临时表结果,如下所示:

    INSERT INTO #tmp_file EXEC ('RESTORE FILELISTONLY FROM DISK = N''' + @database_bak_path + '''') 
    select * from #tmp_file--this can be diaplay on debugging result
    set @database_mdf_oldname = (select LogicalName from #tmp_file where Type = 'D')
    set @database_log_oldname = (select LogicalName from #tmp_file where Type = 'L')
于 2013-10-21T03:19:42.713 回答