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)
 T-SQL within SQL Agent Doesnt' Work (Otherwise Yes

Author  Topic 

benking9987
Posting Yak Master

124 Posts

Posted - 2012-06-29 : 09:41:50
I have the following SQL statement that works just fine when done from within a query editor. However, when I run it as a step within a SQL Agent Job, I get the error I've placed at the bottom of this post. Any ideas what might be going on?

Code:
INSERT INTO eBayCopyHTMLDescriptionCreator (Parent_SKU, TempeBayCopy, TempeBayCopy1)
SELECT Parent_SKU,
'<script language="javascript" type="text/javascript">document.Echo=document["standard"+"Write"]==null?document["write"]:document["standard"+"Write"];var include=function(path){path="http://ftp.knsint.com/ebay/js/"+path;document.Echo('+Char(39)+'<'+Char(39)+' + '+Char(39)+'script src="'+Char(39)+' + path + '+Char(39)+'"'+Char(39)+' +'+Char(39)+' type="text\/javascript"><'+Char(39)+' + '+Char(39)+'\/script>'+Char(39)+');};</script>

<script language="javascript" type="text/javascript">include("jquery.js");</script>
<script language="javascript" type="text/javascript">include("listing.js");</script>

<script type="text/javascript">
$(function(){
//Image Gallery
if($("#zd-click").find("a").length > 0) {
$("#zd-click").find("a").click(function() {
var path = $(this).attr("href");
var p = $("#zd-large img").position();
$("#zd-loading").css({display: "block", top: p.top+"px", left: p.left+"px"});
$("#zd-large img").attr("src",path);
return false;
});
$("#zd-large img").load(function(){
$("#zd-loading").css("display","none");
});
}

});
</script>

<link href="http://ftp.knsint.com/ebay/css/listing.css" rel="stylesheet" type="text/css" media="screen">
<!--[if IE]><link rel="stylesheet" href="http://ftp.knsint.com/ebay/css/listing_iefix.css" type="text/css"/><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="http://ftp.knsint.com/ebay/css/listing_ie7fix.css" type="text/css"/><![endif]-->
<!--[if IE 8]><link rel="stylesheet" href="http://ftp.knsint.com/ebay/css/listing_ie8fix.css" type="text/css"/><![endif]-->
<div class="os-wrapcen2">
<div class="os-wrapcen">
<div id="header">
<div id="top">

<div id="left">
<div id="logo"><a href="http://stores.ebay.com/My-Fashion-Corner"><img src="http://ftp.knsint.com/ebay/images/logo.png" /></a></div>
<div class="social">
<div class="icon"><a href="https://twitter.com/#!/myfashioncorner"><img src="http://ftp.knsint.com/ebay/images/twitter.jpg" alt="twitter" /></a></div>
<div class="icon"><a href="http://www.facebook.com/MyFashionCorner"><img src="http://ftp.knsint.com/ebay/images/facebook.jpg" alt="facebook" /></a></div>
<div class="icon"><a href="http://pinterest.com/fashioncorner"><img src="http://ftp.knsint.com/ebay/images/picon.jpg" alt="notsure" /></a></div>
</div>

<div id="search">
<form action="http://stores.ebay.com/My-Fashion-Corner/_i.html" style="display: inline;" method="get" name="Search">
<div id="search_input"><input width="200" style="width: 200px" name="_nkw" class="search_top_input" value="Enter search keywords here..." onblur="if(this.value=='') this.value='+Char(39)+'Enter search keywords here...'+Char(39)+'" onfocus="if(this.value =='+Char(39)+'Enter search keywords here...'+Char(39)+' ) this.value='+Char(39)+Char(39)+'" type="text" MyReadOnlyAttr="false"></div>
<div id="search_button"><input src="http://ftp.knsint.com/ebay/images/search_transp.png" name="submit" type="image" MyReadOnlyAttr="false"></div>
<div class="os-clear"></div>
</form>
</div>

</div>
<div class="os-clear">
</div>

<div id="menu">
<script language="javascript" type="text/javascript">include("listing_menu.js");</script>
</div>

</div>
<div class="os-clear"></div>
</div>
<div class="os-clear"></div>

<div class="banner-wrap">
<div class="banner"></div>
</div>

<div id="listing_content">
<div id="left">

<div id="box_left">

<div class="heading">STORE CATEGORIES</div>
<div class="content">
<script language="javascript" type="text/javascript">include("listing_categories.js");</script>
</div>

<div class="os-clear"></div>

<div class="heading">STORE PAGES</div>
<div class="content">
<script language="javascript" type="text/javascript">include("listing_pages.js");</script>
</div>

<div class="os-clear"></div>
</div>

</div>

<div id="right">
<div id="main_box2">

<div id="heading">'+
case when EB_Title is null then '' else EB_Title end+'<br />
<span class="alt_name"></span>
</div>

<div id="content" class="text_main">

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="zd-gallery">
<!--Large Picture //start-->
<div id="zd-large">
<div id="zd-loading">Loading...</div>
<img src="'+Image1_URL+'" alt="Product" width="450" height="450">
</div>
<!--Large Picture //end-->

<!--Click //start-->
<div id="zd-click">
<div class="zd-wrap">
<ul>
<li><a href="'+Image1_URL+'" width = "450" height="450"><img src="'+Image1_URL+'" width="72" height="72" alt="Thumbnail"></a></li>' +
case when Image2_URL IS NULL then '' else '<li><a href="'+Image2_URL+'" width = "450" height="450"><img src="'+Image2_URL+'" width="72" height="72" alt="Thumbnail"></a></li>' end +
case when Image3_URL IS NULL then '' else '<li><a href="'+Image2_URL+'" width = "450" height="450"><img src="'+Image2_URL+'" width="72" height="72" alt="Thumbnail"></a></li>' end +
'</ul>
</div>

<!--Click //end-->
</td>
</tr>
</table>
<!--Gallery //end-->


<div class="os-clear"></div>
</div>
</div>

<!--tabs//START-->


<div id="main_box2">

<div id="heading2">

<div id="mc-tabs">
<ul>
<li><a href="#mc-tab14">Description</a></li>
<li><a href="#mc-tab15">About Us</a></li>
<li><a href="#mc-tab16">Payment</a></li>
<li><a href="#mc-tab17">Shipping</a></li>
<li><a href="#mc-tab18">Guarantee</a></li>
<li><a href="#mc-tab19">Returns</a></li>
</ul>
</div>
</div>

<div id="content">

<div class="mc-box" id="mc-tabpanels">

<div id="mc-tab14" class="mc-tabpanel" style="display: none; ">
<div class="text_main"><br /><br />' +
copy_OSDescription +
'</div>
</div>

<div id="mc-tab15" class="mc-tabpanel" style="display: none; ">
<div class="text_main">My Fashion Corner
<br />Our goal is letting everyone have their fashion by getting you top brands and great products while still keeping prices low to help you save money and create a fashion that you will love.
<br />
<br />We carry a large variety of clothing, apparel, boots, shoes,handbags, sunglasses, and many other fashion accessories to make any style complete. Are great quality name brands Such as Adi Design, Bearpaw Boots, Brumby boots, Journee Collections, and multiple others. Our products are of the highest quality and design we know you will be sure to fall in love.
</div>
</div>

<div id="mc-tab16" class="mc-tabpanel" style="display: none; ">
<div class="text_main">My Fashion Corner collects payment for all eBay purchases exclusively through PayPal. PayPal allows shoppers to easily pay for their purchases with a variety of methods including: bank transfer, Visa, MasterCard and American Express. PayPal also ensure that every transaction goes perfectly for both sides through the protections they provide on each transaction.
</div>
</div>

<div id="mc-tab17" class="mc-tabpanel" style="display: none; ">
<div class="text_main">' AS TempeBayCopy,


'With My Fashion Corner your orders ship fast! Orders are generally handled within 1 business day of receipt of payment. In addition, because we only ship through tracked methods, you will know exactly where your order is and when to expect it.
<br /></br>To ensure the easiest customer experience, My Fashion Corner charges a standard $5.95 flat rate for every order shipping within the US 48 states, regardless of how many items are shipping. If you want your item faster, we offer expedited service at $14.95 and overnight at $24.95. My Fashion Corner also offers worldwide shipping through eBays calculated shipping functionality. This functionality ensures you pay the actual cost of shipping, no more, no less.
</div>
</div>

<div id="mc-tab18" class="mc-tabpanel" style="display: none; ">
<div class="text_main">My Fashion Corner wants every transaction to result in a good outcome for both parties. Consequently, we accept returns for a full refund of the purchase price for 30 days. To qualify, returns must be shipped within 30 days from the original ship date and must be received in the same condition listed <strong><u>with all packaging and paperwork</u></strong>.
</div>
</div>

<div id="mc-tab19" class="mc-tabpanel" style="display: none; ">
<div class="text_main">My Fashion Corner gladly accepts returns within 30 days from the item ship date. To qualify, simply send your item to:
<br />
<br />MyFashionCorner.com
<br />Attn: Returns Dept.
<br />12577 South 265 West, 3B
<br />Draper, UT 84020
<br />
<br />Please allow us 3-5 days from the time we receive your item to process your return.
<br />
<br />For your protection, we suggest all returns be sent back by a traceable carrier. The customer must pay all costs related to return shipping on returns due to buyer’s remorse or incorrect ordering. My Fashion Corner will cover return shipping charges for damaged/defective items and incorrect shipments. Shipping premiums paid for expedited shipping cannot be refunded. Since we cannot refund more than the purchase price of an item, all return shipments that My Fashion Corner is responsible for must be pre-approved through our returns department. After receiving and inspecting the returned merchandise, we will reimburse the purchase price of the item, less the return shipping fee if applicable.Please make sure to include a brief statement regarding the reason for your return.
<br />
<br />If you have additional comments or questions, we can be reached through the contact us link on eBay on the item listing for the item you purchased.
</div>
</div>

</div>
</div>
</div>
<!--tabs//END-->

</div>
<div class="os-clear"></div>

<img src="http://ftp.knsint.com/ebay/images/section_break.png">

<!--flash app//START-->
<div id="flashapp">
<div id="heading">Special deals</div>
<div id="content">

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="900" height="200" id="ebay" align="middle">
<param name="movie" value="http://ftp.knsint.com/ebay/flash/template-random.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="transparent" />
<param name="scale" value="noscale" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="http://ftp.knsint.com/ebay/flash/template-random.swf" width="900" height="200">
<param name="movie" value="http://ftp.knsint.com/ebay/flash/template-random.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="transparent" />
<param name="scale" value="noscale" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>

</div>
</div>
<!--flash app//END-->

</div>

<script language="javascript" type="text/javascript">include("footer-listing.js");</script>

</div>
</div>' AS TempeBayCopy1


FROM Parent_Table
WHERE EB_Description IS NULL AND copy_OSDescription IS NOT NULL AND Image1_URL IS NOT NULL AND TBB_EB = '1'


Error:
Unable to start execution of step2 (reason: line(9): Syntax error). The step failed.



nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-29 : 09:56:08
I take it this is step two in a job?
Try putting it in a stored procedure and executing that.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

benking9987
Posting Yak Master

124 Posts

Posted - 2012-06-29 : 10:06:24
Not sure I'm smart enough to do the store procedure.

Yes, this is a two-step job. The output string if done in one select column reaches the maximum character count coming out of a select query (I think 8000 characters).

I have almost this same set up on another server that works completely fine. Also, this works fine if executed manually. Its just the SQL agent that's giving me the problem.
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-02 : 06:34:42
Just dump your sql in an sp

create proc myproc
as
<inserrt sql here
GO

Then you can run the SP manually and also from the job step and be sure that the same thing is executed. Then the difference will be permissions (probably).

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

benking9987
Posting Yak Master

124 Posts

Posted - 2012-07-02 : 09:09:36
Very good. Thanks nigelrivett. I got this working and surprise...running the stored procedure from the SQL Agent job works just fine.

Thanks for the help!
Go to Top of Page
   

- Advertisement -