How can we help you today? How can we help you today?
lgivens

Activity overview

Latest activity by lgivens

Hi Philip,   Let me see if I can answer your questions about SQL Prompt. I don't know all of your table structure, but based on what is visible in your query, I tried to duplicate what you are seeing in my test environment. As you saw Prompt recommended you add the schema to the table name. This is a best practice rule. This rule can be turned on/off via SQL Prompt > Code Analysis Rules, scroll down to Performance Rules and uncheck PE002 Schema name for table or view is not specified.   The two column names on the last line are a little more problematic, because I don't have all the information. But I think the best practice rule is to always include table name or alias with column names when using a join clause. SQL Prompt couldn't 'fix' the column names because it didn't know what table to look in (this is assuming that Table-A doesn't have ParentKeyID or PersonID columns).   So the best practice way to write the query, according to SQL Prompt, would be:   SELECT * FROM dbo.Maintable mt WHERE mt.PersonID NOT IN (SELECT CCCC.PersonID FROM dbo.TABLEA AAAA INNER JOIN dbo.TABLEB BBBB ON AAAA.AAAA-ID = BBBB.AAAA-ID AND BBBB.BBBB-ID = (SELECT MAX(BBBB-ID) FROM dbo.TABLEB WHERE AAAA-ID = AAAA.AAAA-ID AND Category IN ('Active','Draft')) INNER JOIN dbo.TABLEC CCCC ON BBBB.BBBB-ID = CCCC.BBBB-ID WHERE AAAA.AAAA-ID = mt.ParentKeyID AND CCCC.PersonID = mt.PersonID);   With that syntax, SQL Prompt wasn't highlighting anything other than to recommend using EXISTS other than IN for the main WHERE clause.   Does this help?   Thank you, Lee Givens Product Support Engineer / comments
Hi Philip, Let me see if I can answer your questions about SQL Prompt. I don't know all of your table structure, but based on what is visible in your query, I tried to duplicate what you are seeing...
0 votes