Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a batch file on a Windows 2008 server that, when invoked from command line works fine. However, when I set a scheduled task to run this job, it does not work properly.
The task scheduler does show that that the task is getting run at regular intervals, it does not show any error. But, the batch file does not process what it is supposed to process.
Any ideas on how to fix this issue is most welcome
Windows Server 2008 will not run any batch file with quotation marks " inside the batch file.
See http://technet.microsoft.com/en-us/library/dd851678.aspx
I had a similar problem, my .bat file wouldn't correctly execute when I had the full file path in the "Program/script" field.
"D:\path\to\file\somebat.bat" didn't execute. (with quotes)
When I put D:\path\to\file\ (without quotes) in the Start in (optional): field and somebat.bat in Program/script: field somebat.bat executed correctly.
Go figure... not exactly sure why having "D:\path\to\file\somebat.bat" in the Program/script: won't work.
Maybe someone could shed some light on that?
In my case, I had 'Run whether user is logged on or not'. When I changed to 'Run only when user is logged on' it worked OK.
Make sure the task is running under an account with the necessary privileges. When you run a batch script from the command-line directly, it is running under your user account, which may have different permissions than the default account used for scheduled tasks.
Related
What would be the best way to execute a specified batch script that are located on a server from my local machine?
I tried using PHP, and I had admin issues. I need something that can specify what batch needs execute, enter it then the batch file will get executed on my server.
Could you give some examples, or any site that works?
Thanks in advance! :)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
At my job, I occasionally have to perform the following tasks:
Use Remote Desktop Connection to log on to a server.
Copy a set of files from a specific folder on my computer to a specific folder on the server.
Execute an SQL query on the server in SQL Server Management Studio, copied from a text file on my computer.
Log out of the server.
And then repeat for a whole bunch of other servers. This adds up to more than an hour, and I'm trying to figure out a way to automate it. What's the best way to go about doing this? I don't think Windows is as feature-rich as Linux when it comes to the command line, and I'm inexperienced with network protocols as it is.
You can automate this kind of behavior using batch files and scheduled tasks.
You can install the Command Line Utilities 11 for SQL Server from here:
http://www.microsoft.com/en-us/download/details.aspx?id=36433
And find reference material for the utilities it offers here:
http://technet.microsoft.com/en-us/library/ms162816.aspx
You will want to write a batch file that executes your actions in order. I recommend running a non-lethal SQL query against a test database while you develop your batch file, but it will be something like this:
::Copy the files
xcopy "\\server\c$\Source\*.*" "\\server\c$\Destination\"
::Set your MS SQL variables
set /p SName="Server Name"
set /p UName="User Name"
set /p Pwd="Password"
set /p DbName="Database Name"
::Execute your SQL query
sqlcmd -S %SName% -U %UName% -P %Pwd% -d %DbName% -i "c:\sqlCommand.sql"
Then you'll want to set it up to run as a Windows scheduled task by a user account (or service account) that has access to both of these network locations.
That should do the trick.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
How can I open a *.mdf file of a database created with Visual Studio 2010, into SQL Server Management Studio?
I tried to attach it by myself, but I cannot navigate to that file for (I guess) some security reason.
I had the same problem.
system configuration:-single system with window 7 sp1 server and client both are installed on same system
I was trying to access the window desktop. As some the answer say that your Sqlserver service don't have full access to the directory. This is totally right.
I solved this problem by doing a few simple steps
Go to All Programs->microsoft sql server 2008 -> configuration tools and then select sql server configuration manager.
Select the service and go to properties. In the build in Account dialog box select local system and then select ok button.
Steps 3 and 4 in image are demo with accessing the folder
I found this detailed post about how to open (attach) the MDF file in SQL Server Management Studio:
http://learningsqlserver.wordpress.com/2011/02/13/how-can-i-open-mdf-and-ldf-files-in-sql-server-attach-tutorial-troublshooting/
I also have the issue of not being able to navigate to the file. The reason is most likely this:
The reason it won't "open" the folder is because the service account
running the SQL Server Engine service does not have read permission on
the folder in question. Assign the windows user group for that SQL
Server instance the rights to read and list contents at the WINDOWS
level. Then you should see the files that you want to attach inside of
the folder.
(source: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c80d8e6a-4665-4be8-b9f5-37eaaa677226/cannot-navigate-to-some-folders-when-attempting-to-attach-mdf-files-to-database-in-management?forum=sqlkjmanageability)
One solution to this problem is described here: http://technet.microsoft.com/en-us/library/jj219062.aspx I haven't tried this myself yet. Once I do, I'll update the answer.
Hope this helps.
Copy the files to the default directory for your other database files. To find out what that is, you can use the sp_helpfile procedure in SSMS. On my machine it is: C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA. By copying the files to this directory, they automatically get permissions applied that will allow the attach to succeed.
Here is a very good explanation :
How to open MDF files
.
I don't know about the older versions but for SSMS 2016 you can go to the Object Explorer and right click on the Databases entry. Then select Attach... in the context menu. Here you can browse to the .mdf file and open it.
I don't know if this answer can be found on the links above, but I just run SQL Management Studio as Administrator and it worked.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm using VS2010 as a client for a TFS instance. I created a workspace, and need to map a TFS directory to a local directory - let's call the local directory "D:\aaa\bbb\ccc\ddd". When I navigate to "Manage Workspaces" and click "edit" to change the local directory to this path, I am presented with the following error: 1
This error occurs when I try to map: "D:\aaa", "D:\aaa\bbb", "D:\aaa\bbb\ccc".
Now, if I create a folder called: "D:\aaa\bbb\ccc1\ddd", the mapping works, and I do not receive this error.
Can anyone help? I've been pulling my hair out for about a day over this.
Thank you.
[EDIT01: I tried mapping all other folders under the D:\ drive, and only one other folder fails the mapping. I receive the same error as with "D:\aaa\bbb\ccc\ddd" ]
SQL Errors
First of all, you should not be receiving SQL Error 18054 (or any SQL errors) from TFS.
You should have your TFS administrator connect to the SQL server that hosts the master DB for your TFS server and run the following query:
select * from master.dbo.sysmessages where error > 50000
If this is a TFS2010 server, your TFS administrator may be able to use TFSConfig PrepSql to re-install the error messages.
If this is a TFS2008 server, your TFS administrator will need to open Add/Remove programs and run a repair on TFS.
Your actual problem
This sounds obvious at first, two
local paths cannot point to the same
place in the repository for the same
workspace. However, the one that
catches a lot of folks un-aware is
that you cannot have two repository
paths mapped to one local path on the
same computer.
In TFS, you cannot have two folders with overlapping mappings. Since D:\aaa\bbb\ccc\ddd is a sub-folder of D:\aaa, then you cannot add it.
One thing you can do though, is cloak folders so that they aren't part of the workspace mappings. In your case, you might want to map D:\aaa and add a cloak for all the other subfolders in that directory, except for D:\aaa\bbb.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Can anyone help me, I'm trying to backup a database located on localhost\SQLEXPRESS but i keep getting the following error:
Backup failed for Server 'localhost\SqlExpress'. (Microsoft.SqlServer.SmoExtended)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.2531.0+((Katmai_PCU_Main).090329-1045+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Backup+Server&LinkId=20476
ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: Cannot open backup device 'C:\backup.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105). (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.2531.0+((Katmai_PCU_Main).090329-1045+)&LinkId=20476
Can anyone explain what I'm doing wrong here ??
thanks
It looks like the SQL Server doesn't have permission to access file C:\backup.bak. I would check the permissions of the account that is assigned to the SQL Server service account.
As part of the solution, you may want to save your backup files to somewhere other that the root of the C: drive. That might be one reason why you are having permission problems.
I've faced this error when there was not enough free space to create a backup.
Assuming that the *.bak file is on the same machine as the SQL Express instance it might be a permissions issue.
If you download procmon http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx you can filter on that file path, look for ACCESS_DENIED errors and if any are there you can see the account name that's failing get to access.
I got this error too.
The problem turned out to be simply that I had to manually create the full directory structure for the file locations of the MDF & LDF files.
Shame on SQL-Server for not properly reporting the missing directory!
I've got the same error. I have been trying to fixing this by setting higher permission to account running SQL Client service, however it didnt help. The problem was that I run MS Sql Management studio just within my account. So, next time... assure that you are running it as Run as Administrator, if using Win7 with UAC enabled.
Yes, it is security issue. Check folder permissions and service account under which SQL server 2008 starts.
I had this error. Nothing worked for me until I opened the SQLServer log file in the "MSSQL10_50" Log folder. That clearly stated which file could not be overwritten. It turned out that the .mdf file was being written into the "MSSQL10" data folder. I made sure that folder had the same SQLServer user permissions as the "MSSQL10_50" equivalent folder. Then it all worked.
The issue here is that the error detail is logged but not reported, so check the logs.