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 2000 Forums
 Transact-SQL (2000)
 capture dos command retturn value

Author  Topic 

dasu
Posting Yak Master

104 Posts

Posted - 2004-08-17 : 10:35:33
hello every one
really i have one problem when i tried to capture the value which
following statement print.this same thing will be working at command
prompt how to capture the no of rows in that file which i specified in the filepath


SET @strTempCommand = 'type '+ @strPathName + ' | Find /C /V "TEXT!NOT!IN!RECORD"'

EXEC master..xp_cmdshell @strTempComman


please suggest me better solution

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-08-17 : 11:18:12
You could use a temp table. Create a table of one column of type varchar and width 1000. Then INSERT INTO the table your EXEC statemement. This will then give you one row per result from your command plus some header and footer rows you can ignore.


Raymond
Go to Top of Page

dasu
Posting Yak Master

104 Posts

Posted - 2004-08-17 : 11:48:51
i am more happy u send me detailed information

Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-08-17 : 11:59:08
--Create a table for the results. Include a id so you can determine original row numbers
Create Table #dirOutPut (id int identity(1,1) not null, nvarchar(2000))

SET @strTempCommand = 'type '+ @strPathName + ' | Find /C /V "TEXT!NOT!IN!RECORD"'

--Capture dos output during execute
Insert Into #dirOutPut
EXEC master..xp_cmdshell @strTempComman

--return captured output
Select * From #dirOutPut


Corey
Go to Top of Page

dasu
Posting Yak Master

104 Posts

Posted - 2004-08-17 : 23:01:46
Thank u
U r idea works for my case
Go to Top of Page
   

- Advertisement -