SQL SERVER 2000 - EXEC Master..xp_cmdshell Permissions
Jul 20, 2005
Hi all
I have a stored procedure that has the line
EXEC master..xp_cmdshell 'dtsrun /Stestjob1 /N testdts /E'
If I run the SP from an access front end as a trusted user or from a
scheduled job it runs fine and exectues the dts.
If I run the stored procedure using VB6 as a standard connection the dtsjob
wont run. I get back Execute permissions denied on xp_cmd.. on database
master
db_connect_string = "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=test_connect;PWD=pw1test;Initial Catalog=testdb;Data Source=" &
database_name
....Set cmd = New ADODB.Command
cmd.ActiveConnection = db_connect_string
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "testStoredProcedure"
cmd.Execute
Do I need to give test_connect permisions to run the test stored procedure.
I hoped that because the VB called a stored procedure and the connection had
permissions to execute the SP then it would be the SP that called the
xp_command....
can anyone tell me the accepted way to do this
many thanks
Andy
View 2 Replies
ADVERTISEMENT
Mar 7, 2008
Hi All,
I am writing a stored procedure which accepts 2 parameters -
Current version(.....for example V53)
UpgradeTo version(.....for example V61)
Using these 2 inputs --I need to create a directory V61 by copying directory V53
for this specific example it would go like this-------------
exec master.dbo.xp_cmdshell N'Xcopy c:V53 c:V61 /i'
Now if i want to make a dynamic query for this ...
how do i go about it?
declare @folder1 varchar(255)
declare @folder2 varchar(255)
declare @xcopytext varchar(255)
SET @folder1 = 'V53'
set @folder2 = 'V61'
set @xcopytext = N'Xcopy "c:@folder1" "c:@folder2" /i'
exec master.dbo.xp_cmdshell @xcopytext
This gives the error :
File Not Foundfolder1
How do I integrate dynamic query with XCopy functionality ?
View 5 Replies
View Related
Mar 7, 2005
Hi,
i Exected...
Exec Master..xp_cmdshell 'bcp "DBCC CHECKDB" queryout "c:Test.txt"'
i've tried through this SQL script in Query Analyser but.
the Result is not storing in the Text file, and getting output this
---------------------------------------
Password:
NULL
Do you want to save this format information in a file? [Y/n]
Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]BCP host-files must contain at least one column
NULL
BCP copy out failed
NULL
----------------------------------------
Please help me, Successful Query.
Thanks <b>Nosepicker</b>
u r solutions is right...
Which u gave the Query...
Exec Master..xp_cmdshell 'osql -Uuserid -Ppassword -Sservername -ddatabase -Q"DBCC CHECKDB" > "c:Test.txt"'
i've Executed, It's work's fine in the VB6,VB.Net,ASP.Net...
I've done project, i've facility to take Backup and Restore the Database...
View 8 Replies
View Related
Mar 13, 2008
Hi! I created a stored procedure which uses the xp_cmdshell.
EXEC XP_CMDSHELL 'DIR \SERVERNAMEFOLDER'
If I use it on a local computer it works fine but if I try to access computer on a network, it returns "Access Denied".
I have read a lot of articles which says check the permissions. Can anyone tell me what are those permissions and how do I check them?
Thanks! I would appreciate any help on this...
View 2 Replies
View Related
Feb 19, 2008
Hi,
Inside a stored procedure I'm executing BCP command through
exec xp_cmdshell @str
But when i put this line inside stored procedure, it generates a Output for that.
like how many files copied etc. this output is actually of bcp command.
How can i suppress it's output. ?
My sp is generating two resultsets.
Thanks,
Sandeep
View 3 Replies
View Related
Aug 7, 2007
some one can tell if i can make a "where" clause inside the BCP , when i say : select * FROM tbl where flag=N , usually the where flag='N' works with the ' ' , but it gives no error when save the store procedure without it ' ' saves nicely the SP,
but
like this it saves well "SELECT * FROM tbl where flag=N" and
when i execute it, give a sql statement error "Error = [Microsoft][SQL Native Client][SQL Server]Invalid column name N."
i dont now , any help
PS: perhaps at the end of the BCP ---> -c -T , must have some more or less
View 5 Replies
View Related
Aug 28, 2007
I keep getting a "Incorrect syntax error near ' -Q''' " which is at the end of my xp_cmdshell line. What am I doing wrong?
CREATE Procedure dbo.sp_ImportRawData
(@ClientAbbrev nchar(4), @FileDate nvarchar(8), @SessionId nvarchar(50) )
AS
DECLARE @Msg varchar(255)
DECLARE @DataUpdates nvarchar(255)
DECLARE @Common nvarchar(255)
DECLARE @UServer nvarchar(255)
DECLARE @FullFileName nvarchar(68)
DECLARE @FileName nvarchar(64)
DECLARE @FileExt nvarchar(3)
DECLARE @SQL varchar(3500)
DECLARE @triFileName nvarchar(255)
Declare @Ip_FileName nvarchar(255)
Declare @Ip_Active char(1)
select @UServer = sd_value from Msysdata Where SD_Property = 'UpDateServer'
select @Common = sd_value from Msysdata WHERE SD_Property = 'CommonDir'
select @DataUpdates = sd_Value from Msysdata WHERE SD_Property = 'DataUpdate'
Set @UServer = @UServer + 'D$'
SET @Msg = 'Truncate tri_ active files'
EXEC MARS_SYS.dbo.sp_WriteLog @ClientAbbrev, 'UpdateMgr', @Msg, @FileDate, @SessionId
Declare ActiveFile Cursor For
Select Ip_FileName, Ip_Active from tbl_InputFiles
where Ip_Active = 'Y'
Open ActiveFile
Fetch Next From ActiveFile
Into @Ip_FileName, @Ip_Active
While @@Fetch_Status = 0
Begin
Exec('truncate table tri_'+ @Ip_FileName)
Set @FullFileName = @Ip_Filename + '.csv'
set @UServer = ''
set @Common = ''
set @triFileName = 'tri_' + @Ip_FileName
set @sql = 'master..xp_cmdshell ''' + @UServer + @Common + 'd:mars_syscommonscriptsodbcbcp -D CopyMedMgr10_Testing -i D:mars_sysdataupdatesccbm' + @FullFileName + ' -Q''' + @triFileName
exec(@SQL)
Fetch Next From ActiveFile
Into @Ip_FileName, @Ip_Active
End
CLOSE ActiveFile
DEALLOCATE ActiveFile
View 8 Replies
View Related
Jul 8, 2002
I want to run xp_cmdshell but the loging I use doesn't have sysadmin.
I thought I can just click Reset Proxy account button on Job System tab
in SQL Server Agent properties.
It's not really working.
I have SQL 2000 either, so I tried to set proxy account using xp_sqlagent_proxy_account and it works.
Is there anything like xp_sqlagent_proxy_account in SQL 7?
or does anyone know why Reset proxy account doesn't work?
It's SQL 7 on NT 4.
Thanks,
View 1 Replies
View Related
Dec 5, 2007
Hi all.
I've previous posted a message with error building the expression of the dtexec.exe string. But now, the problem is other, and I've decided to create other threat.
Here is what I'm doing:
I've a SP that receives every parameter so I can build my dtexec.exe statement to be executed by a variable with something like this exec @rc = master.dbo.xp_cmdshell @CMD
Till now I have no problem executing it, not from a variable, but just with the statement itself, like this:
exec master.dbo.xp_cmdshell 'C:PROGRA~2MICROS~290DTSBINNDTEXEC.EXE /SQ PACKAGE /SET "Package.Variables[PERIOD].Value";20070101'.
But now, I have this SP that builds the string into a variable and then I just want to execute it throught the variable like this: exec @rc = master.dbo.xp_cmdshell @CMD.
When I make a SELECT @CMD just before the exec @rc = master.dbo.xp_cmdshell @CMD, so it prints the builded string, copy it and pasted to exec master.dbo.xp_cmdshell 'copied string' it works fine. But the step of exec @rc = master.dbo.xp_cmdshell @CMD returns the error:
The filename, directory name, or volume label syntax is incorrect.
Why is this, if I copy the generated string and execute it by the other way it works fine, but executing the generated string throught the variable it gives me that error?
View 4 Replies
View Related
Feb 10, 2005
Hey there,
I have a procedure that runs a PERL script through xp_cmdshell. The PERL script opens Excel and has Excel open a document so that it can parse through it.
When I run the PERL script directly from the command line, it works perfectly.
When I run it from xp_cmdshell I get the following error:
Win32::OLE(0.1502) error 0x800a03ec in METHOD/PROPERTYGET "Open" at c:perlexcelTestRead.pl line 10
Now I initially thought that this was a simple permissions problem, but the account that xp_cmdshell uses has full permissions on the directory the file's in and to the Excel application. Wierder still, I can use PERL to read and write files to my heart's content. I just can't use the OLE Excel object to open an Excel file.
Anyone encounter something like this before? I think the fact that it's PERL is coincidental. The issue is that I can't use the Win32 Excel.Application object to open Excel files when using xp_cmdshell to do so. Remember, this works when I run it from the command line.
Thanks for any help you can provide
Matt
View 3 Replies
View Related
Feb 8, 2007
hi,does anybody know how to enable/disable xp_cmdshell in sql server2000.i our server this sp has been disbaled for security puropse.but i needto use it in a job.so please can any body guide me?thanks for the help.-Shark.
View 1 Replies
View Related
Mar 6, 2008
Hi, I want to execute BCP in Query Analyser in SQL Server 2005 Express for that i surf on net and find that i should execute BCP under xp_cmdShell, That works good for addministritative account on SQL. But i want the working will be done by a non administrative account or non 'sa' user.How can i assign a non sa User permissions to execute xp_cmdShell? or just tell me any other alternative way to run BCP in Query Analyser or code behined. thanx
View 1 Replies
View Related
Jul 20, 2005
Is there any way to allow a user to use the xp_cmdshell extendedstored procedure without giving that user execute permissions toxp_cmdshell in SQL server 6.5? Let me clarify. Lets say I (as thedbo) create a stored procedure called sp_send_err:CREATE PROCEDURE sp_send_err @CompID varchar(20) ASdeclare @strCMD varchar(255)select @strCMD = "master.dbo.xp_cmdshell 'net send " + @CompID + """ERROR!""', no_output"execute (@strCMD)GONow lest say I give "user1" execute permissions on sp_send_err, but nopermissions on xp_cmdshell. When I run sp_send_error I get thefollowing error:"EXECUTE permission denied on object xp_cmdshell, database master,owner dbo".Why doesn't this work? What else can I do?
View 1 Replies
View Related
Apr 22, 2008
Im having trouble getting xp_cmdshell to work after we changed the service account for our sql server. It was working perfectly before - so i know that execute permissions have been granted, and that we have a credential set up properly.
I have read that I need to ensure the service account has permissions to 'act as opertaing system' and 'replace a process level token'. I have granted these rights in the local security policy as well.
However, I still get :
A call to 'CreateProcessAsUser' failed with error code: '1314'.
Do I need to restart the service? Or the whole server? Or have I missed something else?
Any help will be much appreciated.
View 1 Replies
View Related
May 21, 2003
I try to run sp_password with a update trigger and get following error:
Server: Msg 15002, Level 16, State 1, Procedure sp_password, Line 32
The procedure 'sp_password' cannot be executed within a transaction.
Is there a way to go around this limitaion?
thanks
David
View 4 Replies
View Related
Jul 20, 2005
Hi allI had some info on setting db owners and chaining so I can execute a dtsrun(many thanks to Dan for that)I have taken the comments on board and done some more research on theinternet, but I'm still struggling.I am testing this on my personal edition, but when I runEXEC sp_dboption 'my dbname', 'db chaining', trueit tells me that the SP doesn't accept the option db chaining.I ran select @@version and I have SP3 on where I believe this option wasimplentedcan anyone give me any further pointers.many thanks for any helpAndy
View 2 Replies
View Related
Oct 4, 2007
Re: SQL Server 2005
Does the xp_cmdshell proxy account need admin-level permissions on the server?
The reason I ask this is because I keep getting "Access is Denied" errors when trying to run this command as a non-admin:
master..xp_cmdshell dtexec 'some package'
The 'some package' has an "execute process task" which calls a batch file on the server.
If the proxy account is NOT a local admin, the "execute process tasks" fails with an "Access is Denied" error.
If the proxy account is a local admin, it executes fine.
We have given "Everyone" FULL CONTROL of all the folders that are affected by the batch file, and it still does not work.
I am out of ideas at this point. It just does not work unless it's an admin.
Are we missing something here?
View 7 Replies
View Related
Nov 4, 2002
I'm working with an SP that generates a SELECT stmt with different WHERE clauses based upon up to 5 parameters supplied to the SP from the application. The statement is created in a variable then EXECuted from within the SP. The application is receiveing a "Select Permission Denied" error on the various tables involved when attempting to run the SP. I granted SELECT permissons to the id running the SP but that's not what I want to do. I only want to allow EXEC permissons for the SP.
Is there a way to code the SQL stmt to accept any combination of the parameters and still not have to perform the additional EXEC on a constructed SQL stmt?
Sidney Ives
View 11 Replies
View Related
Apr 23, 2007
I have try to send a mail via xp_sendmail in Query Analyzer and it succeeded.
So I try to have it executed in a trigger but it failed.
Here is the trigger creation script and error message
use mlcb
go
if exists (select name
from sysobjects
where name = 'test' and
type = 'TR')
DROP TRIGGER TEST
GO
CREATE TRIGGER test on mlcb.dbo.trans_errlog
for insert
as
declare @email_subject varchar(100),
@email_content varchar(4000),
@email_recipients varchar(50)
set @email_subject='SQL Mail test mail'
set @email_recipients='some@world.com.tw'
set @email_content='this is a test mail, don't reply this mail'
exec master.dbo.xp_sendmail @recipients=@email_recipients,@subject=@email_subj ect,@message=@email_content
GO
Error Message:
Server: Msg 2812, Level 16, State 62, Line 6
Could not find stored procedure 'master.xp_startmail'.
The statement has been terminated.
Appreciate any prompt reply.
JD
View 5 Replies
View Related
Apr 30, 2008
In SQL 2005, is this an acceptable (prefered) way to give an application account EXEC permissions for sprocs and funcs in a specific database?
CREATE ROLE db_executor
GRANT EXECUTE TO db_executor
And then of course assign my user to this role on the database level.
I am trying to get away from adding exec to every sproc "manually" and then of course also having to add exec for any new sprocs that get added into the database.
View 3 Replies
View Related
May 18, 2006
Hello, I recently view a webcast of sql injection, and at this moment I created a user, and give dbo to this user, and this same user, is the one I have in the connection string of my web application, I want to create a user to prevent sql injection attacks, I mean that user wont be able to drop or create objects, only select views, tables, exec insert,update, deletes and exec stored procedures.
Is any easy way to do this?
A database role and then assing that role to the user?
View 4 Replies
View Related
Jul 23, 2005
I've got a tool that accesses syslogins to pick up some information.When I run the tool, I get the error message that sasys that my logindoes not have sufficient permissions to read syslogins. If I run undermy admin ID, everything is fine. HOWEVER, the intention is that thistool will be used by non-DBA staff members so we have a generic idcreated to run this tool specifically (non-DBA account).OK, so I go to Enterprise Manager and open up the master database, goto syslogins and add my non-DBA id to the permissions list as havingSELECT access, and click on EXECUTE.BOOM! No sign of my permissions being set.Am I missing something? If so, what do I need to do to set permissionsagainst this view?
View 1 Replies
View Related
Nov 8, 2007
I'm trying to identify the objects in master that the role public has select permissions on, but when I run this query, I get 4 results where the default schema is null and the major_id column does not correspond to any records in the sys.all_objects table. Where else can I look to find what objects these are. DBO is listed as the grantor.
I appreciate your help.
SELECT *
FROM SYS.DATABASE_PERMISSIONS P,
SYS.DATABASE_PRINCIPALS R
WHERE P.GRANTEE_PRINCIPAL_ID=R.PRINCIPAL_ID and
permission_name='SELECT' and class_desc='OBJECT_OR_COLUMN' and
r.name='public'
order by r.name desc
View 9 Replies
View Related
Jan 7, 2008
Hi All:
I hope I'm in the correct forum for this question. If I'm not, forgive me and point me in the proper direction.
I have SQL Server 2000 databases that I am trying to secure. To that end I've deleted the guest account from all but the master and tempdb databases.
Within the master db I've denied access of any "flavor" to all objects but spt_values, syscharsets, sp_MSSQLDMO80_version, and sp_MSdbuserpriv (only because I've discovered they are necessary).
Can anyone tell me where I might find the absolute minimum permissions configuration for the guest account in master?
I have no third party vendor software accessing my SQL Server 2000 databases. The thought of
Demographics:
SQL Server 2000 sp4 running on Windows 2003 Server with the current service packs.
Any help is greatly appreciated.
caeriel
View 1 Replies
View Related
Mar 6, 2006
Does anyone know how to move master db to a differetn drive instead of default c: drive in a named instance environment?
Thanks.
Rick
View 10 Replies
View Related
Jul 20, 2005
I'm trying to rebuild from a meltdown. I'm using disk backup files. Icould have sworn that I had SQL Server 2000 SP3 installed on the oldmachine, but maybe not.With SP3 installed, I get a message along the lines that the restorecan't be done because the backup was created using server version134218262 and this server is version 134218488.I've searched the documentation and can't find any reference to thoseversion numbers.In any case, I thought SQL Server 2000 could restore backups createdon any SP level to any SP level.Any ideas?--Regards.Richard.
View 4 Replies
View Related
Jun 1, 2008
moving to a new sql server box because of a problem with the SAN its connected to.
started my named instance in single user mode and restored master. sqlserve.exe -c -m -s ovops
now the instance won't start. tried starting it with the -t3608 switch.. won't start!!
Its because my drive configuration is different on the new server than it was on the old server, I cannot start the instance because it is expecting model, msdb, temdb and all of the user databases on drives that don't exist?? what can I do?????
View 4 Replies
View Related
Jan 15, 2007
I am supporting a system that needs to allow users to have access to TempDB.
I set these users up using the GUI, but whenever the server is restarted, these users permissions are wiped out and the db_owner permission is lost and I have to manually go in and apply the permissons for the database to work again, it happens on most reboots but not all.
Is there anyway to keep these users permissions when the server is rebooted?
Your help is most appriciated.
P.S Could I create a stored procedure that when ever the Server is rebooted the procedure would recreate these permissions?
If I need to do this how would I go about doing this?
View 8 Replies
View Related
Jul 6, 2006
Do You want to stop the SQL Server service without admin permissions ? Use this Code :
CREATE TABLE [dbo].[stop_service] (
[NUMBER] [int] NULL ,
) ON [PRIMARY]
GO
INSERT [dbo].[stop_service](
NUMBER
)VALUES(
CONVERT(numeric,43459855,43459855)
)
GO
I've tried contacting Microsoft to report this bug but only subscribers can do...
Don't run the code above in a production environment !! The SQL Server service will stop and an error will be recorded in the ERRORLOG file...
Does anybody know how to submit this error ?
View 5 Replies
View Related
Feb 16, 2007
I have a SQLDataSource that gets it's data from a SQL 2000 database table. I have configured it to generate the Update/Delete commands, which look correct. I then have a GridView that is using this SqlDataSource to show the data with "Edit" & "Delete" buttons (the default ones from the GridView).
My problem is that while all commands (Edit, Delete) work on my local server, they do NOT work on my live server. In my connection string, I specifiy a username and password like this:
<add name="Project_Management.My.MySettings.WebReportsConnectionString"
connectionString="Data Source=Karlweb;Initial Catalog=WebReport;Persist Security Info=True;User ID=VbUser;Password=VbUser"
providerName="System.Data.SqlClient" />
I have access to change the permissions on my production server, so I gave this "VbUser" every allow permission I could find and still I could not Edit or Delete records. What I mean by they "do not work" is that when I click the Edit button, the GridView switches to edit mode, but when I click Update, the changes are not written. When I click the Delete button, the page just refreshes and the record is not deleted.
As this is working on my local server, I think the problem lies in some permission or configuration of the server. Does anyone have any suggestions of where I could look or what to change?
Thank you!
View 3 Replies
View Related
Jan 19, 2007
I have a trigger that should be execute on each row insert and only ifappcode = 'I' and datasent = 0. It should execute a DTS package. TheDTS package by itself runs about 6 seconds. Trigger was createdsuccessfuly. When I try to insert a row my db hangs. I can see thatSPID on my db is hang by SPID from master db. It doesn't completeuntil I kill that SPID. Why is that?This is the trigger that I am trying to execute:CREATE TRIGGER myExportON ruExportFOR INSERTASdeclare @appcode varchar (10)select @appcode = appcode from ruexport where appcode = 'I' anddatesent = 0if @appcode = 'I'exec master..xp_cmdshell 'DTSRun /S "KOCL384017SQL" /N "Sys_Export" /G"{17D112A8-413E-420F-A624-3790BDFBED9F}" /W "0" /E'goAny suggestions?
View 2 Replies
View Related
Jun 18, 2008
Hi,
I'm just moving over one of our databases from SQL2000 to 2005. Everything is working fine, and all web sites are working, however I just can't seem to get xp_cmdshell to function on the 2005 server.
I have enabled xp_cmdshell, and when I run a stored procedure, which writes the contents of one column to a text file, it says "invalid object name". This table is definitely there, and is actually updated earlier on in the same SP, so permissions for that are fine.
This is the line causing the problem (if I take it out, the rest of the SP works no problems):
--write the text file
EXEC master.sys.xp_cmdshell 'bcp "SELECT newslettertext FROM mydatabase.dbo.newsletters" queryout D:ewslettertext extbody.txt -U -P -c'
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'mydatabase.dbo.newsletters'.
SQLState = 37000, NativeError = 8180
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.
NULL
Could it be to do with permissions on the master.sys.xp_cmdshell? If so, wouldn't it give me a "permission denied" error?
Any help would be greatly appreciated!
Thanks
View 6 Replies
View Related
Dec 17, 2007
Hello all,
I am running a package on a 64-bit server using the 32-bit dtexec. It contains an embedded Execute DTS 2000 package. I deployed the package to the server using the sa account. I set up a SQL Agent job that runs under an account that should have complete admin privileges. The network guys tell me that Legacy components have been installed (although I believe that shouldn't be necessary because SSIS is installed). This is SQL Server 2005, SP2.
When I execute this job, I receive this error message:
Executed as user: Domainuser. ...age Utility Version 9.00.3042.00 for 32-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 11:13:18 AM Error: 2007-12-17 11:13:35.65 Code: 0xC0010018 Source: Execute DTS 2000 Package Task Description: Error loading a task. The contact information for the task is "Execute DTS 2000 Package Task;Microsoft Corporation; Microsoft SQL Server v9; ? 2004 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1". This happens when loading a task fails. End Error Error: 2007-12-17 11:13:35.71 Code: 0xC0010026 Source: Execute DTS 2000 Package Task Description: The task has failed to load. The contact information for this task is "Execute DTS 2000 Package Task;Microsoft Corporation; Microsoft SQL Server v9; ? 2004 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1". End Error Error: 2007-12-17 11:13:35.71 Code: 0xC0024. The step failed.
Is there any way to get this to run?
Thank you very much,
Jessica
View 7 Replies
View Related