sql server遍歷用戶表導(dǎo)出所有表數(shù)據(jù)到文本
作者:佚名
sql server數(shù)據(jù)庫(kù)中,遍歷用戶表是經(jīng)常會(huì)用到的,下文對(duì)sql server遍歷用戶表導(dǎo)出所有表數(shù)據(jù)到文本的方法作了詳細(xì)的介紹,供您參考。
sql server遍歷用戶表相信大家都有一些了解,下面為您介紹的是sql server遍歷用戶表導(dǎo)出所有表數(shù)據(jù)到文本文件的方法,希望對(duì)您學(xué)習(xí)sql server遍歷用戶表方面能有所幫助。
- -- To allow advanced options to be changed.
- EXEC sp_configure 'show advanced options', 1
- GO
- -- To update the currently configured value for advanced options.
- RECONFIGURE
- GO
- -- To enable the feature.
- EXEC sp_configure 'xp_cmdshell', 1
- GO
- -- To update the currently configured value for this feature.
- RECONFIGURE
- GO
- ---xp_cmdshell 'cd C:Program FilesMicrosoft SQL Server90ToolsBin'
- xp_cmdshell 'dir *.exe'
- SELECT NAME,NAME FROM SYS.OBJECTS
- xp_cmdshell 'bcp northwind.dbo.orders out c:mytest -T -c'
- declare @sql nvarchar(max)
- set @sql=''
- select @sql=@sql+' xp_cmdshell '+'''bcp northwind.dbo.'+quotename(name)+' out c:'+name+'.dat -T -c '+''' ' from sys.objects
- where type='u';
- select @sql
- exec (@sql)
【編輯推薦】
責(zé)任編輯:段燃
來(lái)源:
互聯(lián)網(wǎng)