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.
| Author |
Topic |
|
Donm
Starting Member
1 Post |
Posted - 2009-12-23 : 11:20:30
|
| I have the statement:sqlcmd -E -dCostrollup -h-1 -s"," -W -i "D:\Customers\DCM\Products\LabelPrint\LabelPrint.txt" –XThe contents of LabelPrint.txt are:EXEC [dbo].[dcm_sp_labeltext]and the stored procedure is:ALTER procedure [dbo].[dcm_sp_labeltext] asbegin set NOCOUNT ON declare @docnum int, @remarks varchar(max), @filename varchar(250), @result int, @db varchar(200), @query varchar(max), @cmd varchar(1000), @cmdshell varchar(max) declare mainloop cursor for select distinct u_docnum from [@dcmlabels] where u_update <> 'U' open mainloop fetch mainloop into @docnum while @@fetch_status = 0 begin select top 1 @filename = u_labeltextdir from [@dcmsetup] /* dcmsetup.u_labeltextdir stores the directory where the text file is to be placed */ select @filename = @filename + convert(varchar(10),@docnum) + '.txt' /* full text file name is the directory + document number + extension of .txt */ EXEC @Result = sp_DoesFileExist @filename IF @Result <> 0 -- file does not already exist begin select @db = DB_Name() -- this gets the database name select @query = '"select u_remarks from ' select @query = @query + @db select @query = @query + '..[@dcmlabels] where u_docnum = ' select @query = @query + convert(varchar(10),@docnum) select @query = @query + ' "' SET @cmd = 'sqlcmd -E -h-1 -Q' set @cmd = @cmd + @query set @cmd = @cmd + ' -s"," -W -o"' SET @cmd = @cmd + @FileName + '"' select @cmdshell = @db + '..xp_cmdshell ' EXEC @cmdshell @cmd update [@dcmlabels] set u_update = 'U' where u_docnum = @docnum end fetch mainloop into @docnum end close mainloop deallocate mainloop delete [@dcmlabels] where u_update ='U' and u_date < getdate()-30 set NOCOUNT OFFendI expected to not see the 'x records processed', but it is present in the text file created. How do I eliminate this? |
|
|
|
|
|
|
|