sql server遍历用户表导出所有表数据到文本

树叶云

sql server遍历用户表相信大家都有一些了解,下面为您介绍的是sql server遍历用户表导出所有表数据到文本文件的方法,希望对您学习sql server遍历用户表方面能有所帮助。

  1. -- To allow advanced options to be changed.  
  2. EXEC sp_configure 'show advanced options', 1  
  3. GO  
  4. -- To update the currently configured value for advanced options.  
  5. RECONFIGURE  
  6. GO  
  7. -- To enable the feature.  
  8. EXEC sp_configure 'xp_cmdshell', 1  
  9. GO  
  10. -- To update the currently configured value for this feature.  
  11. RECONFIGURE  
  12. GO  
  13.  
  14. ---xp_cmdshell 'cd C:Program FilesMicrosoft SQL Server90ToolsBin'  
  15. xp_cmdshell 'dir *.exe'  
  16.  
  17.  
  18. SELECT NAME,NAME FROM SYS.OBJECTS  
  19. xp_cmdshell 'bcp northwind.dbo.orders out c:mytest -T -c'  
  20.  
  21. declare @sql nvarchar(max)  
  22. set @sql='' 
  23. select @sql=@sql+' xp_cmdshell '+'''bcp northwind.dbo.'+quotename(name)+' out c:'+name+'.dat -T -c '+''' ' from sys.objects    
  24. where type='u';  
  25. select @sql  
  26. exec (@sql) 

 

 

 

 

【编辑推荐】

SQL Server系统表的应用

Sql Server全文索引的迁移

SQL SERVER全文检索的实现

SQL Server删除用户失败的解决方法

sql server系统表说明

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/231815.html<

(0)
运维的头像运维
上一篇2025-04-19 21:18
下一篇 2025-04-19 21:19

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注