exec master..xp_cmdshell 'echo hello > c:\file.txt'
exec master..xp_cmdshell 'echo appended data >> c:\file.txt'
exec master..xp_cmdshell 'echo more data >> c:\file.txt'
master..xp_cmdshell 'bcp master..sysobjects out c:\file.bcp -S -U -P -c '
/* using dynamic sql */
declare @cmd varchar(1000)
select @cmd = 'osql -U -P -S -Q"select * from master..sysobjects" -o"c:\osqloutput.txt" -w500'
exec master..xp_cmdshell @cmd
if exists(select 1 from sysobjects
where name = 'sp_reindex' and type = 'P' )
drop procedure sp_reindexgo
create procedure sp_reindexasbegin
declare @cmd varchar(255)
declare ic insensitive cursor for
select 'dbcc dbreindex (' + name + ')'
from sysobjects
where type = 'U'
open ic
fetch next from ic into @cmd
while @@fetch_status = 0
begin exec (@cmd)
fetch next from ic into @cmd end
close ic
deallocate ic
end