.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Imran Ghani
Post New Web Links

sql agent job command step multiple lines?

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :Sql Server
 

This is an oldie but a goodie, maybe there's a trick I haven't heard about?

When I create an OperatingSystem (CmdExec) job step, it seems to only execute the first line command. 

So if the first line is:

dtexec foo

It executes dtexec.  Fine.

But if I have two command lines:

set myvar=123
dtexec foo

It only executes the set command and never calls dtexec.  Bummer.

Now, we can work around this by executing a .cmd file, but then I have a whole issue of deploying .cmd files in different environments yada yada.

So the question is, is there any (new-ish) magic trick that will tell the SQL Agent job step to execute two or more command lines right from the job?

Thanks.

Josh

 




View Complete Post


More Related Resource Links

Wrap text in Multiple Lines of text column

  
I had a List created from Calendar. I then took two copies of it to use for two slightly different purposes. I created a View on the list in both cases using the "Newsletter" style. On one of the list the Description column wraps text. In the other one it does not. Any idea what I could have done differently? Is there a checkbox in the View definition or the Column definition that toggles wrap text ?

Multiple-step OLE DB operation generated errors in Pre-Execute

  
Hello, I am getting below error; what could be the reason? The input is valid adn works good if I give to a multicast for test. But I get below error when I use OLEDB Destination ("table or view fast load") as my target. Note: Columns mappings are done auto by SSIS and All looks good as my source and destination are having same names as well. [Stage - Issue [33923]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E21. An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80040E21  Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". [Stage - Issue [33923]] Error: Cannot create an OLE DB accessor. Verify that the column metadata is valid. [DTS.Pipeline] Error: component "Stage - Issue" (33923) failed the pre-execute phase and returned error code 0xC0202025. Thanks, Prabhat

Log SQL agent and message in a step

  

How can i see all error message in a DTS step. My DTS have 30 step and the error message is truncated at the step 9 :

Step_DTSExecuteSQLTask_1   DTSRun en voie d'achèvement :  DTSStep_DTSExecuteSQLTask_1   DTSRun OnStart:  DTSStep_DTSExecuteSQLTask_2   DTSRun en voie d'achèvement :  DTSStep_DTSExecuteSQLTask_2   DTSRun OnStart:  DTSStep_DTSExecuteSQLTask_5   DTSRun en voie d'achèvement :  DTSStep_DTSExecuteSQLTask_5   DTSRun OnStart:  DTSStep_DTSExecuteSQLTask_3   DTSRun en voie d'achèvement :  DTSStep_DTSExecuteSQLTask_3   DTSRun OnStart:  DTSStep_DTSExecuteSQLTask_4   DTSRun en voie d'achèvement :  DTSStep_DTSExecuteSQLTask_4   DTSRun OnStart:  DTSStep_DTSExecuteSQLTask_6   DTSRun en voie d'achèvement :  DTSStep_DTSExecuteSQLTask_6   DTSRun OnStart:  DTSStep_DTSExecuteSQLTask_7   DTSRun en voie d'achèvement :  DTSStep_DTSExecuteSQLTask_7   DTSRun OnStart:  DTSStep_DTSExecuteSQLTask_8   DTSRun en voie d'achèvement :  DTSStep_DTSExecuteSQLTask_8   DTSRun OnStart:  DTSStep_DTSExecuteSQLTask_9   DTSRun en voie d'

Multiple sql server update statments in SSIS OLE DB Command

  

Is it possible to issue multiple sql server update statements in SSIS OLE DB Command?

 

I Tried the following with no luck

 

update table1 set column1 = 1

GO

update table2 set column1 = 1


SQL Server 2008 multiple lines in a varchar(MAX) column?

  

Hi,

I'm using varchar(Max) to store a text file content. It's not taking the newline character. I tried \n and char(13) etc.. whatever solution posted in the net.

ex : update test set f='This is line 1.' + CHAR(13) + CHAR(10) + 'This is line 2.' 

after updating it doesn't have any newline or linebreak. Can anyone help me in this how to have linebreaks in the varchar(max) field.

Thanks a lot.


Agent SQL step error when call by proxy

  

I use SQL Server 2008 R2.

I configure execution step to a proxy. When I load the job an error occur :

"Impossible de démarrer l'exécution de l'étape 1 (raison : Impossible d''obtenir les données proxy pour proxy_id = 2).  L''étape a échoué."

Thanks help me.


copy/y doesn't work in SQL Agent job step

  

I added some very simple copy file steps to a job.

I wanted to give them the ability to copy over an existing file, so tried to use the copy/y switch.  When I do this the job fails with a message:

Executed as user: MYCORP\XYZ. 
The process could not be created for step 1 of job 0xA7AC060B3A9B9443A42F68DCBD74EC07 
(reason: The system cannot find the file specified). 
The step failed.

Wassup with that?

Thanks.

Josh

 


Sql Server Agent failed to executed a scheduled bat file that contains sqlcmd command

  

Hi All:

I am currently using Windows 2003 R2, Standard Edition.
I have Microsoft Sql Server 2005 Installed with the latest service pack which is sp3.
I logged into the operating system as an administrator. The windows administrator id is "test2".
I logged into the Microsoft Sql Server 2005 database using "Microsoft Sql Server Management Studio" as an "sa" which is database admin.
I placed a bat file called "test1.bat" in the directory c:\test3, the file "test1.bat" contains the following content:

sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD"

In the dos-prompt, I can run the "test1.bat" batch file with no errors.
It gives me the following output:
c:\test3\sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD"
ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD

Using "Sql Server Agent", I created a new job called "Scripts1".
For the "General" link, I have the following values:
Name:test2
Owner:SA
Category:Database Maintenance

For the step link, I have the following values:
Step Name:test2
Type:Operating system(CmdExec)
Run As:SQL Agent Service Account
Command:
sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE]

Sql Server Agent failed to executed a scheduled bat file that contains sqlcmd command

  

Hi All:

I am currently using Windows 2003 R2, Standard Edition.
I have Microsoft Sql Server 2005 Installed with the latest service pack which is sp3.
I logged into the operating system as an administrator. The windows administrator id is "test2".
I logged into the Microsoft Sql Server 2005 database using "Microsoft Sql Server Management Studio" as an "sa" which is database admin.
I placed a bat file called "test1.bat" in the directory c:\test3, the file "test1.bat" contains the following content:

sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD"

In the dos-prompt, I can run the "test1.bat" batch file with no errors.
It gives me the following output:
c:\test3\sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD"
ALTER INDEX ALL ON [JOHNDATABASE].dbo.TABLE2 REBUILD

Using "Sql Server Agent", I created a new job called "Scripts1".
For the "General" link, I have the following values:
Name:test2
Owner:SA
Category:Database Maintenance

For the step link, I have the following values:
Step Name:test2
Type:Operating system(CmdExec)
Run As:SQL Agent Service Account
Command:
sqlcmd -b -e -Q "ALTER INDEX ALL ON [JOHNDATABASE]

Drawing multiple connected lines efficiently

  

Hi 

 

As a beginner I recently wrote a spectrum analyzer in win-forms which runs nicely. Now, I'm realizing that I would be better of doing the application in WPF - which I know very little about.

 

I do have a WPF project running now where one line is changing coordinates over time. Like this:

 

            // Add a Line Element

            Line myLine = new Line();

 

            myLine.Stroke = System.Windows.Media.Brushes.LightSteelBlue;

            myLine.HorizontalAlignment = HorizontalAlignment.Left;

            myLine.VerticalAlignment = VerticalAlignment.Center;

            myLine.StrokeThickness = 2;

 

            myLine.X1 = 0;

            myLine.X2 = x++;

            myLine.Y1 = 0;

            myLine.Y2 = y++;

 

            canv.Children.Add(myLine);


But how can I draw a

SQL Agent Job - PowerShell step giving escape token error

  

Hi,

I'm confused as to why I'm getting this error:

The job step contains tokens. For SQL Server 2005 Service Pack 1 or later, you must use the appropriate ESCAPE_xxx macro to update job steps containing tokens before the job can run.).  The step failed.

The job is a single Powershell script step like this:

 

Get-ChildItem -path "\\server\share-Logs\" -recurse -include *.log | Where-Object {($_.CreationTime -le $((Get-Date).AddDays(-35)))} | Remove-Item

 

This runs fine from the PS command-line but after testing this part is causing the error: $(Get-Date.AddDays(-35)) , in the Job step

This isn't TSQL or a token - so I don't understand why it doesn't just get put as-is into the PS command-line when the job runs.

Any help appreciated.

 


Error: OLE DB provider "SQLNCLI" for linked server "MHTIS01T" returned message "Multiple-step OLE DB

  

Hi All, i am getting the error (in title) while executing the package.

can somebody tell me how do i solve it?


Really Long JSON String wraps to multiple lines in source, creates unterminated String Literal error

  

I have an app that writes a JSON object to a string and registers a script block onto the page that client-side javascript then uses to build interface components.  I found that the javascript is working fine when the data set is small, but on large datasets, when I view the source, the JSON object string takes up a few lines because it is so long.  I didn't think anything of it until I started manually trying to recreate the "Unterminated String Literal Error", only to find that the error goes away when I format the JSON string to be a little more "readable".  What I discovered is that this does away with the automatic new line wrap, making the error go away. 


Make Sense?  Is there anything I can do about this?


What is the most efficient way to filter on detail lines and have multiple detail lines displaying o

  

Hello:

Here is my dilemma - i have 10 different sizes of, let's say, Tshirts in different stores.

I need a report that displays on one detail line a count of how many shirts of size 1 thru 3 i have in store A, B and C (the stores are the columns). and i need a second detail line displaying how many shirts of size 7 thru 9 i have in the same stores. How would i filter the data to display this most efficiently. Also, i will need to total the two lines at the end of the report.

Sample:

             storeA     B         C

size 1-3      15        10     12

size 7-9     23         1        5

 


Multiple Lines of text

  

Hi

I want to be able to enter multiple lines of text into a field...... but I only want the first 100 chrs to be displayed, but with a link to show the full detail.

E.g. These would be the first few chrs on test but to display the rest you need to click.....more

Is this possible in a Share Point list?

The reason i want this is to enable Issues and Problems to be recorded in a list and the list be used to manage each issue. The notes associated with each issue will build up over time but I want the list to remain easy to read. Therefore I want the full detail of the issue to be on a separate page that is available via a ....more link within the list.

 

Is this possible?

I'm using Share Point 2010


Error_1_Error occurred in deployment step 'Upgrade solution': Command ID 'Contoso.Commands.IsSolu

  

When following this article for creating a Custom Deployment Step for SharePoint Projects i get the following error. (MSFT Article: http://msdn.microsoft.com/en-us/library/ee256698.aspx)

Error: Error 1 Error occurred in deployment step 'Upgrade solution': Command ID 'Contoso.Commands.IsSolutionDeployed' is invalid.

I have gone through the article two times and each time it does the samething. Any reason why it can't see the Command ID?


Workflow Designer 2007 that is completing on the first step of a multiple step process.

  

The work flow is tied to an infopath form 2007 and is triggers by events.  Step one is to sends the email, the workflow action is to "wait" for another event.  Howver, the workflow shows completed with no error messages. This workflow was working.  I would like to see why the workflow is completing when it is should be In Process.

The workflow states:

Condition - If mgr-approval is empty

Action Email Manager, then wait for mgr-approval to be not empty.

It would then go to step 2.  It is never getting to the next step.

 

 


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend