Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 How to replace existing text file in sql server

Author  Topic 

mpolaiah
Starting Member

24 Posts

Posted - 2009-08-05 : 23:55:22
Hi All,

i am execute the command
declare @SQLCmd varchar(500),
@FilePath varchar(200),
@nRequestid varchar(100)
set @nRequestid=186
--set @DBName='SMS'
--set @TableName='AH_PRE_REQUEST_DETAILS'
set @FilePath='F:\polo\'+@nRequestid+'.txt'

--set @Separator='#'
SET @SQLCmd ='sqlcmd -d SMS -Q "set nocount on;Select * From AH_PRE_REQUEST_DETAILS where nrequestid='+@nRequestid +'" -o"' + @FilePath + '" -W -s "' + '#' + '" -h -1'
EXEC master..xp_cmdshell @SQLCmd

it get the output

once agani i run the
same command
declare @SQLCmd varchar(500),
@FilePath varchar(200),
@nRequestid varchar(100)
set @nRequestid=186
--set @DBName='SMS'
--set @TableName='AH_PRE_REQUEST_DETAILS'
set @FilePath='F:\polo\'+@nRequestid+'.txt'

--set @Separator='#'
SET @SQLCmd ='sqlcmd -d SMS -Q "set nocount on;Select * From AH_PRE_REQUEST_DETAILS where nrequestid='+@nRequestid +'" -o"' + @FilePath + '" -W -s "' + '#' + '" -h -1'
EXEC master..xp_cmdshell @SQLCmd

i am get anothe output

How to replace these two outputs at a one text file

it is possible

plase help meeeee........................
   

- Advertisement -