master..xp_cmdshell

Last Post 08 Jul 2010 03:48 AM by rm. 7 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
river1
New Member
New Member

--
07 Jul 2010 05:47 AM

Hi Masters,

   Hi have the stored procedure bellow:


USE [DB]

GO

/****** Object: StoredProcedure [dbo].[DBCCCheckDB] Script Date: 07/06/2010 15:40:18 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER procedure [dbo].[DBCCCheckDB] (@DB as varchar(100), @User as varchar(100), @pass as varchar (250))

as

BEGIN

declare @FileNameOut as varchar(250)

declare @cmd as varchar(8000)

set @FileNameOut ='OutputConsistencia_'+@DB+'.txt'

select @cmd = 'osql -U'+@user+' -P'+@pass+' -S -Q"dbcc checkdb ('''+@DB+''') with no_infomsgs" -o"'+@FileNameOut+'" -w500'

Exec master..xp_cmdshell @cmd

 

 

END

 

END


When i execute this stored procedure i receive errors:


one error is this:

the system could not locate the specified file.


Can someone help, please?

Thnak you

river1
New Member
New Member

--
07 Jul 2010 05:50 AM
if i change the ....  inside the stored procedure to:


set @FileNameOut ='OutputConsistencia_'+@DB+'.txt' select @cmd = 'osql -U'+@user+' -P'+@pass+' -S -Q"dbcc checkdb ('''+@DB+''') with no_infomsgs" -o"c:\'+@FileNameOut+'" -w500' Exec master..xp_cmdshell @cmd


I still receive the same error...
river1
New Member
New Member

--
07 Jul 2010 05:56 AM
Other error that i receive is this:

'iJ7Wwn4'' is not recog. as an internal or external command.
 
when the password is like:

exec DBCCCheckDB 'AdventureWorks' ,'novatech','n:?=Txl|iJ7Wwn4'
russellb
New Member
New Member

--
07 Jul 2010 06:16 AM
What do u see if you print @cmd?

Why are you doing it this way anyway?
river1
New Member
New Member

--
07 Jul 2010 06:40 AM
If i print the @cmd, the result is this:


osql -Uusername -Ppassword -S -Q"dbcc checkdb ('AdventureWorks') with no_infomsgs" -o"c:\OutputConsistencia_AdventureWorks.txt" -w500

river1
New Member
New Member

--
07 Jul 2010 06:42 AM
what is the meaning of "-W500"?
russellb
New Member
New Member

--
07 Jul 2010 07:06 AM
Column width in the output.

see here: http://msdn.microsoft.com/en-us/lib...L.80).aspx

not sure why you're using osql though. anyway, does it work if u enter osql -Uusername -Ppassword -S -Q"dbcc checkdb ('AdventureWorks') with no_infomsgs" -o"c:\OutputConsistencia_AdventureWorks.txt" -w500 at the command prompt?
rm
New Member
New Member

--
08 Jul 2010 03:48 AM
Don't have server name after -S?
You are not authorized to post a reply.

Acceptable Use Policy