IP
|
 |
| Joined: 12 Apr 2005 |
| Total Posts: 47 |
| |
|
Sql Server Job not running Posted: 11 Dec 2006 02:50 PM |
whenever I have put 'insert into tabl_name (f1,f2)(1,1)' query under asql job with every 1 minute schedule then it works fine with job but whenever I put following code instead of insert statement then it fails.
Please give me any idea.
declare @compcode as varchar(10)
declare @segcode as varchar(10)
declare @lubenonlube as varchar(10)
declare @query as varchar(8000)
select @compcode =comp_code,@segcode=segment_code,@lubenonlube=lubenonlube from sheduled_potCalc
if @@rowcount > 0
begin
if @compcode <> 'HGR'
set @query = 'select distinct(s.ITKK_no) as ITKK_no,isnull(no_of_cyl,0) as no_of_cyl,isnull(cust_code,' + CHAR(39)+CHAR(39) + ') as cust_code from SOW_comp_header s ,SOW_comp_dtl d
where s.ITKK_no = d.ITKK_no and lube_nonlube=' +CHAR(39) + @lubenonlube + CHAR(39)+ 'and cust_code in(select SOW_cust_code from customer_mast where segment_code='+ char(39) + @segcode + char(39)+ ')'
else
set @query = 'select distinct(s.ITKK_no) as ITKK_no,isnull(no_of_cyl,0) as no_of_cyl,isnull(cust_code,' + CHAR(39)+CHAR(39) + ') as cust_code from SOW_comp_header s ,SOW_comp_dtl d
where s.ITKK_no = d.ITKK_no and lube_nonlube=' +CHAR(39) + @lubenonlube + CHAR(39)+ 'and cust_code in(select SOW_cust_code from customer_mast where comp_code=='+ char(39) + @compcode + char(39)+ ' and segment_code='+ char(39) + @segcode + char(39)+ ')'
exec Proc_PotentialCalc @query
delete from sheduled_potCalc where comp_code=@Compcode and segment_code=@segcode and lubenonlube=@lubenonlube
end |
|
|
 |
|
urid
|
 |
| Joined: 18 Jun 2007 |
| Total Posts: 34 |
| |
|
Re: Sql Server Job not running Posted: 18 Jun 2007 05:52 PM |
Hi
What is the error are you getting? |
Best Regards,
Uri Dimant
SQL Server MVP
http://dimantdatabasesolutions.blogspot.com/
|
|
 |
|