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
 Transact-SQL (2005)
 xp_cmdshell

Author  Topic 

Babli
Yak Posting Veteran

53 Posts

Posted - 2008-08-14 : 03:15:10
Hi,

I am trying to excecute a xp_cmdshell command i am getting this error

" The name xp_xmdshell..... is a valid identifier "

Looks like a syntax error

Below is my query:

declare @path nvarchar(255)

select @path = 'xp_cmdshell ''\logparser.exe "select cs-uri-stem,cs-username from LogFiles\W3SVC1741176974\*.log to IISReports..loggingdir" -i:iisw3c -q:on -o:sql'''

exec @path


Thanks in advance,
Babli

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-08-14 : 03:19:06
Are you running it in master db ?
Go to Top of Page

Babli
Yak Posting Veteran

53 Posts

Posted - 2008-08-14 : 04:22:28
No I am running it in the correct DB "IISReports"

When I print it to a csv file it is working fine which shows there is something wrong with the quotation or something in sql server.Can you please find out what it is?

quote:
Originally posted by sakets_2000

Are you running it in master db ?

Go to Top of Page

Babli
Yak Posting Veteran

53 Posts

Posted - 2008-08-14 : 04:54:41
It should be "exec(@path)" , I gave a space between exec and @path.

Its working fine now.

Thanks.

quote:
Originally posted by Babli

No I am running it in the correct DB "IISReports"

When I print it to a csv file it is working fine which shows there is something wrong with the quotation or something in sql server.Can you please find out what it is?

quote:
Originally posted by sakets_2000

Are you running it in master db ?



Go to Top of Page
   

- Advertisement -