如何恢复丢弃的表结构?

时间:2013-12-17 08:16:56

标签: sql sql-server sql-server-2008

我不小心丢了一张桌子,里面没有任何数据,只有一张大桌子。我能以某种方式获得表格的结构吗? 我试过了

SELECT TOP 5000 * 
FROM  (SELECT COALESCE(Object_name(s2.objectid), 'Ad-Hoc')       AS ProcName, 
              execution_count, 
              s2.objectid, 
              (SELECT TOP 1 Substring(s2.text, statement_start_offset / 2 + 1, ( 
                            ( 
                            CASE 
                              WHEN 
                            statement_end_offset = -1 THEN 
                              ( 
                                                        Len( 
                              CONVERT(NVARCHAR(max), s2.text)) * 
                                                        2 
                              ) 
                                                        ELSE 
                            statement_end_offset 
                            END 
                            ) 
                            - statement_start_offset ) / 2 + 1)) AS 
              sql_statement, 
              last_execution_time 
       FROM   sys.dm_exec_query_stats AS s1 
              CROSS apply sys.Dm_exec_sql_text(sql_handle) AS s2) x 
WHERE  sql_statement NOT LIKE 'SELECT TOP 50 * FROM(SELECT %' 
--and OBJECTPROPERTYEX(x.objectid,'IsProcedure') = 1 
ORDER  BY last_execution_time DESC 

但我无法获得创建表查询。救命啊!

1 个答案:

答案 0 :(得分:0)