use D_LM
go
#NAME?
declare @medate as datetime
select @medate = '09/30/2020'
CREATE TABLE #TEMP
(ALS_NUM varchar(20),
LMID bigint,
MOD int,
LEV int,
RELATED bigint,
pri_ssn varchar(9),
LOANLINE varchar(4))
DECLARE @i tinyint
SELECT @i = 2
#NAME?
INSERT #TEMP
SELECT ORG_ALS_NUM, LMDB_ID, RECOMMEND, 1, NULL, pri_ssn,LOANLINE
FROM d_lm.ALLBooked
WHERE MONTH(DATE_BOOKED) = MONTH(@MEDate) AND YEAR(DATE_BOOKED) = YEAR(@MEDate)
--Now search these and see if any of these are new acct nubers for a prior 'booked' loan
--loop 5 times to find any more iterations of the same loan
WHILE @i < 10
BEGIN
INSERT #TEMP
SELECT v.ORG_ALS_NUM, v.LMDB_ID, v.RECOMMEND, @i, t.LMID , v.pri_ssn, v.LOANLINE
FROM d_lm_ALLBooked v
JOIN #TEMP t
ON (t.ALS_NUM = v.NEW_ALS_NUM
or t.als_num = v.org_als_num)
AND v.LMDB_ID NOT IN (SELECT LMID FROM #TEMP)
SELECT @i = @i + 1
END
You cannot run this code however her is my question. The code came to me in T-SQL format. I am trying to run each section and produce a dataset so I can get a visual on how to connect the datasets. Can this be dumped into a third party app like toad or SSRS. What have some of you utilized in cases like this?
... View more