June 6, 2019 at 11:08 pm
Hi all,
I have a query which is working fine. However, when I attempt to put it into a view SQL always crashes.
There is no error message when I run the view other than the crash window: SSMS - SQL Server Management has stopped working.
However, if I try save the view, the error message I get is: Attempted to read or write protected memory. This is often and indication that other memory is corrupt.
SELECT MaxDate.LatestUDate, AAA_Tbl_P_M.EndDate, isnull((select 'T' where [LatestUDate]>=[EndDate]),'F')
AS bIsAtOrPastEndDate, AAA_Tbl_P_MU.*
FROM AAA_Tbl_P_M
INNER JOIN ((SELECT P_ID, Max(UDate)
AS LatestUDate
FROM AAA_Tbl_P_MU
GROUP BY P_ID)
AS MaxDate
LEFT JOIN AAA_Tbl_P_MU
ON (MaxDate.LatestUDate = AAA_Tbl_P_MU.UDate)
AND (MaxDate.P_ID = AAA_Tbl_P_MU.P_ID))
ON AAA_Tbl_P_M.ID = MaxDate.P_ID
WHERE AAA_Tbl_P_M.EndDate>Getdate() AND isnull((select 'T' where [LatestUDate]>=[EndDate]),'F')='F'
Why is my SQL studio always crashing when I try to make a view out of this?
And how can I resolve?
Cheers
Addendum: I have found a workable solution in creating the view via a query editor, rather than the designer. Still, I'd rather like to know how to work with the tools without crashing.
June 7, 2019 at 6:16 am
Using the query editor is the correct way to do it. The view/query designer in SSMS is fairly useless. There are a lot of SQL constructs it does not support and it is apparently not able to cope with a query of the complexity you are feeding it. Overall I recommend against using the view/query designer.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply