set @curTables=Cursor for
select name from sysobjects
where xType='u'
Open #curTables
--get first table
Fetch next from @curTables
into @chvTable
While(@@fetch_status=0)
Begin
set @chvCommand='bcp "myDataBase..['+@chvTable +']" out c:\sql\backup\'+ @chvTable+'.txt -c -a -Sservername -Usa -Ppassword'
if @debug<>0
select @chvCommand chvCommmand
if @debug=0
execute xp_command @chvCommand,no_output
fetch next from @curTables
into @chvTable
end
close @curTables
Deallocate @curTables
return 0
set @temp1='select @value1='''',@value2='''' select @value1=@value1+'',''''''+a.name+''''+char(39)+'' [''+a.name+'']'',@value2=@value2+'',cast(''+''[''+a.name+'']''+ '' as varchar(200))'' from '+@库名+'..syscolumns a,'+@库名+'..sysobjects d where a.id=d.id and d.name='''+@表名+''''+' order by a.colorder'