- 爱易网页
-
MSSQL教程
- 怎么用代码实现:把查询结果存放到特定的文件中
日期:2014-05-18 浏览次数:20498 次
如何用代码实现:把查询结果存放到特定的文件中
如何用代码实现:把查询结果存放到特定的文件中,比如txt文件?
比如:要把dbcc page命令的执行结果保存到a.txt文件中.
dbcc page命令示例:
DBCC TRACEON (3604)
DBCC PAGE (master, 1, 1)
在查询分析器中的执行结果:
DBCC 执行完毕。如果 DBCC 输出了错误信息,请与系统管理员联系。
PAGE: (1:1)
-----------
BUFFER:
-------
BUF @0x011325C0
---------------
bpage = 0x19A2E000 bhash = 0x00000000 bpageno = (1:1)
bdbid = 1 breferences = 1 bstat = 0xb
bspin = 0 bnext = 0x00000000
PAGE HEADER:
------------
Page @0x19A2E000
----------------
m_pageId = (1:1) m_headerVersion = 1 m_type = 11
m_typeFlagBits = 0x0 m_level = 0 m_flagBits = 0x0
m_objId = 99 m_indexId = 0 m_prevPage = (0:0)
m_nextPage = (0:0) pminlen = 0 m_slotCnt = 1
m_freeCnt = 2 m_freeData = 8188 m_reservedCnt = 0
m_lsn = (150:435:4) m_xactReserved = 0 m_xdesId = (0:0)
m_ghostRecCnt = 0 m_tornBits = 1
Allocation Status
-----------------
GAM (1:2) = ALLOCATED SGAM (1:3) = NOT ALLOCATED
PFS (1:1) = 0x44 ALLOCATED 100_PCT_FULL DIFF (1:6) = CHANGED
ML (1:7) = NOT MIN_LOGGED
DBCC 执行完毕。如果 DBCC 输出了错误信息,请与系统管理员联系。
------解决方案--------------------
spool c:\a.txt
......
spool off
------解决方案--------------------