View SQL code for job in SQL Server Management Studio - sql-server-2008

I want to view the SQL code that is executed for a particular job in SQL Server Management Studio.
Specifically, I have a screen that looks like this:
If I double click it I get a screen that looks like this:
That is not really helpful. I want to see the actual code that is running and possibly modify it.
I am a long time developer but new to Windows so please give an answer that uses terminology that I can see on the screen.
[EDIT] If I click the edit button on the first screen I get the same screen as if I double click it. There is a DTSRun command and some jibberish which is not anything I would expect to edit.
[EDIT] I followed these instructions to decode the encrypted command line:
https://blogs.technet.microsoft.com/vipulshah/2007/03/12/how-to-identify-which-dts-package-is-being-called-by-scheduled-job/
Then I could see the command line looks like this:
DTSRun /S "192.168.2.1" /U "sa" /P "changeme" /N "Delete AppErrors"
I then searched the entire computer for a filename that contained AppErrors in the name. I did not find one.
So I am getting closer, but how do I find what that is executing?

There is no SQL code in this job/task, because the task type is "Operating system (CmdExec)", i.e. this is not a SQL query, but starting of Windows executable file. There will be SQL code for step type "Transact-SQL script (T-SQL)":
What you see in you job step, is execution of SSIS package, which is encrypted. For more information about DTSRun command, take a look at this article - SQL Server DTS command line utility.

I almost solved my problem like this:
A.
I followed the instructions here to decode the encrypted command line:
https://blogs.technet.microsoft.com/vipulshah/2007/03/12/how-to-identify-which-dts-package-is-being-called-by-scheduled-job/
Which amounted to:
Copy the DTSRUN line (everything including the DTSRUN)
Open a Windows Command Line window
Paste the DTSRUN line into the CMD window.
To the end of the line, add /!X /!C
/!X = do not execute /!C = copy results onto Windows Clipboard
Run the command
Open Notepad
Click Edit>Paste
that will paste the actual command into Notepad and it will show the name of the package.
B.
I observed that the command line looked like this:
DTSRun /S "192.168.2.1" /U "sa" /P "changeme" /N "Delete AppErrors"
C.
Then I follow the instructions here to find the code:
https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/cc645945(v=sql.105)
which amounted to:
In Object Explorer, expand the Management folder.
Expand the Legacy subfolder.
Expand the Data Transformation Services subfolder to show packages.
D.
I right click on it and choose Open. I get this error:
I should not have to install anything because the person who put this on the machine must have been able to edit it. (this person is completely unavailable so I can't ask him). The reason I need access to it is that we are upgrading the machine.

Related

Dynamic User in .bat file

This is my first time trying to use .bat files. I am trying to make one that keeps my front end of my Access database on the most current version for users (only ~7).
I am using:
md C:\Users\tmyers\Desktop
del C:\Users\tmyers\Desktop\Quotations.accdr
copy "\Users\counter1152\desktop\PM DESKTOP FILES\Lighting Project Management Application\Quotations.accdr" C:\Users\tmyers\Desktop
C:\Users\tmyers\Desktop\Quotations.accdr
Part of the copy string I removed due to being the path to our server (just in case). I need the user to somehow be dynamic based on the person executing the file. I could make a special .bat file for each person since I dont have many users, but that seems sloppy.
As a secondary question, how can I get the cmd prompt window to not show when this is executed? That would just be a personal preference of mine. I did find https://superuser.com/questions/140047/how-to-run-a-batch-file-without-launching-a-command-window for reference but am not 100% sure how to do wscript.
try with :
md "%userprofile%\Desktop"
del "%userprofile%\Desktop\Quotations.accdr"
copy "\Users\counter1152\desktop\PM DESKTOP FILES\Lighting Project Management Application\Quotations.accdr" "%userprofile%\Desktop"
"%userprofile%\Desktop\Quotations.accdr"
To auto-hide the cmd.exe window you can use windowmode.bat and getCMDPid.bat:
call getcmdbit.bat
call windowmode.bat -pid %errorlevel% -mode hidden

MS Access - return code to DOS batch

5893.1
Hi all,
I have searched and got answers for my questions many times from this forum. However, I now have a question that I don't think anyone has asked before.
We use Windows DOS batch to compact MS Access 2010 DB files everyday. It seems Access does not pass any return code to DOS. So my question is: Is there a way to tell whether the compacting is successful or not from within the batch?
We use Win XP/7 machines for development, and Windows Server 2008 for production. We are running MS Access 2010.
The DOS batch has a line like "D:\Microsoft Office\Office14\msaccess.exe" %DBLoc%%BkupFile% /compact %DBLoc%%DBFile%
Any help is much appreciated.
Doesn't appear that there is a return code.
However, one time-tested technique is to pipe the output from the command to a text file and then test the contents of the text file. That way, if there's an error message printed at least you'll be able to catch that.
eg. add ' > test.txt' to the end of the command line.
You'd have to check on the available command shell tools to read the text.
You may also have to specifically redirect the error output separately from the command output. see here for redirection info : http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
Edit: to head off the next question, some links on detecting the failure message in the text file
http://ss64.com/nt/findstr.html
How to set variable with the result of findstr

"Learn SQL The Hard Way" - How to Setup Properly for Beginner?

I am a beginner attempting to learn SQL with Zed Shaw's "How to Learn SQL the Hard Way"
In excercise 0: The Set up, he states:
Then, look to see that the test.db file is there. If that works then you're all set.
But when I run the command,
sqlite> create table test (id);
sqlite> .quit
the execution runs, but it doesn't create a test.db file. I looked in the same folder as where the sqlite3.exe file is and I see nothing.
I attempt to see if I can continue without this step, then - In his next exercise, "Excercise 1: Creating Tables":
I input his commands, but when attempting to run sqlite3 ex1.db < ex1.sql, it gives me an error.
I even tried putting the create table command and saving it as a '.sql' file into the same folder as sqlite3.exe.
How can I set this environment up properly? Can someone explain this on an "easy to grasp" level? Any response is appreciated**
Edit 1
I'm not exactly sure how Zed Shaw how he wants his learners to use SQLite 3, Maybe I can go into some research but I just don't understand why he leaves such a large gap of assumption that everyone knows what to do for the set up process...
I had this exact problem. I am using windows 7.
From this website: http://www.sqlite.org/download.html
I used the:
"sqlite-tools-win32-x86-3130000.zip
(1.51 MiB) A bundle of command-line tools for managing SQLite..."
under the "Precompiled Binaries for Windows" heading.
My helper directed me to open the file named "sqlite3" after I'd extracted the files from the zip file. It brought up a black window, in the command line style, showing some text, and then the familiar sqlite> prompt.
Then he had me input:" .save data_base_name.db " (I chose to have my database be named 'thedatabase'.)
which created a file in the same folder as the sqlite3 file, called "data_base_name" as a "Data Base File".
That's where I'm at so far, I'll post updates as I have them.

Open a Tcl file with Wish Application

I'm running Windows 8. I have a file named "test.tcl".
If I open a shell, type "wish", then 2 windows open. In one of them, I can type Tcl code and open the file test.tcl. If I open this file, its code is executed.
If I double click on test.tcl to open the file with "Wish Application", then 1 blank window open, and nothing happens.
Do you know why please?
On Windows, Wish is built as a GUI-only application; it has no real standard output available. Tk fakes one for you though; just put this in your script to show the fake console:
console show
The fake console shows up by default when you launch without a script file, but launching with a script file doesn't show it (so your script file can implement an application, of course).
This can catch people out when they produce a lot of output on stdout. Tk may well be keeping it all faithfully just in case the code does console show later on, though it looks and smells a lot like a memory leak if you're not prepared for it…

microsoft office/access - problem with filepath using call shell from vba

I have the following vba-code in an MS-Access97-frontend which opens a word-document stored on a server:
Call Shell("winword ""\\Fileserver\Contabilita\Crucial deadlines\Bonifico97.doc""", 1)
The document is a merge-document (getting data from a query and populates the document from the data retrieved)
Now, I have put the database-frontend on another computer (still using MS-Access 97 but with MS-Word 2003 installed on the PC - MS-Access 97 is still working nicely since it was installed in a different directory) but now when above code, using call shell, is being executed, I always get "Document not found". If I launch above shell command in Start/execute, the document is being opened correctly.
What could be the problem? The file-path? Did any anything change in VBA 97 and VBA2003 what regards file-paths? I am aware of the fact that there is a folder in the file-path with a space but it works nicely on the PC with office97 installed.
I would appreciate any help I can get. Thank you.
You will need to use the full path for Word.
Alternatives to using SHELL with the full path specified for Word would be:
Application.FollowHyperlink
ShellExecute
In either case, you'd be opening the file with the application associated with the file association of the file you're opening. The only reason to stick with Shell() is if you're using the PID returned by the Shell() function to control the application after it's run. But your original code used Call Shell... so that wasn't an issue.