TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
amit varma
NA
66
12k
Getting Error from the following script
Feb 6 2016 4:36 AM
Hey guys,
i am going to create SI for each record of table ,getting error from STORED PROCEDURE.
No column name was specified for column 6 of 'cte_Alldates'.
please check the bellow script and let me know,where is the problem
Table script :
and the STORE PROCEDURE :
create proc sp_calcualtteSI
as
begin
DECLARE @today datetime
SET @today = dateadd(day,datediff(day,0,current_timestamp),0)
; with cte_dates
as
(
select distinct name,Pamount,Rateofint
,cdate
,case when isnull(@today,@today) < dateadd(month,1,dateadd(month,datediff(month,0,cdate),0))
then isnull(@today,@today)
else dateadd(month,1,dateadd(month,datediff(month,0,cdate),0))
end as MonthEnd
,isnull(@today,@today) as End_date
FROM tbl_intestcalculate
) ,
cte_Alldates
as
(
select name,Pamount,Rateofint
, cdate
,monthEnd
,@today
from cte_dates
union
select name,Pamount,Rateofint
, dateadd(month,number,monthEnd)
,case when dateadd(month,number+1,monthEnd) < @today
then dateadd(month,number+1,monthEnd)
else @today
end
,@today
from cte_dates c
cross join (select number from master..spt_values where type = 'p' and number between 0 and 11) a
where dateadd(month,number,monthEnd) < @today
)
select name
,cdate
,monthEnd
,Pamount
,Rateofint
,datediff(day,cdate,monthEnd) as No_Of_Days
,round(Pamount*Rateofint*datediff(day,cdate,monthEnd)/36500,2) as SI
from cte_Alldates
end
Reply
Answers (
9
)
Join 3 tables and fetch for latest record from 3rd table
Execution Process for a stored procedure