[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need help understanding a query

Posted on 2015-02-16
3
Medium Priority
?
97 Views
Last Modified: 2015-02-16
I need help understanding this query. Is the query inserting records into the table CORE_ADMN_PSUS_PR_STE_USERS ???

Also, isn't there are bug at line 2.????, because this would basically delete the data that was selected into the temp table at line 2?



1.  SELECT * INTO #TEMP_PR FROM STAGING_BLLD_USER_DETAILS

2.  DELETE T FROM #TEMP_PR T
3.  INNER JOIN CORE_ADMN_PSUS_PR_STE_USERS S
4.  ON T.SECA_ASSOC_NUM = S.SECA_ASSOC_NUM
5.  AND T.PSUS_USER_ID = S.PSUS_USER_ID

6.  INSERT INTO (
7.  SECA_ASSOC_NUM,
8.  PSUS_USER_ID,CORE_ADMN_PSUS_PR_STE_USERS
9.  PSUS_EFF_DATE,
10. PSUS_END_DATE,
11. PSUS_ACTIVE
12.              )

13. SELECT
14. SECA_ASSOC_NUM,
15. PSUS_USER_ID,
16. PSUS_EFF_DATE,
17. PSUS_END_DATE,
18. PSUS_ACTIVE

19. FROM
20. #TEMP_PR

21. WHERE PSUS_USER_ID NOT IN (
22. SELECT FUUP_USUS_ID_OLD
23. FROM CORE_FCTS_FUUP_UPD_USUS_ID
                                  )
0
Comment
Question by:brgdotnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1920 total points
ID: 40613162
you are missing the destination table name on line 6

INSERT INTOCORE_ADMN_PSUS_PR_STE_USERS   (
  SECA_ASSOC_NUM,
0
 
LVL 49

Assisted Solution

by:PortletPaul
PortletPaul earned 80 total points
ID: 40613164
This has been subject to a previous question where I stated it needed more input from you. The SQL snippet above has syntax errors and isn't a working query, so trying to describe what it currently does isn't very fruitful.

It seems there is a missing table reference, and when that is fixed (see line 12) it looks like this:
SELECT
      *
INTO #TEMP_PR
FROM STAGING_BLLD_USER_DETAILS

DELETE T
      FROM #TEMP_PR T
      INNER JOIN CORE_ADMN_PSUS_PR_STE_USERS S
            ON T.SECA_ASSOC_NUM = S.SECA_ASSOC_NUM
            AND T.PSUS_USER_ID = S.PSUS_USER_ID

INSERT INTO some_table_missing_here
      SELECT
            SECA_ASSOC_NUM
          , PSUS_USER_ID
          , PSUS_EFF_DATE
          , PSUS_END_DATE
          , PSUS_ACTIVE

      FROM #TEMP_PR

      WHERE PSUS_USER_ID NOT IN (
                  SELECT
                        FUUP_USUS_ID_OLD
                  FROM CORE_FCTS_FUUP_UPD_USUS_ID
            )

Open in new window


What is the correct table on line 12? What were you expecting of this query?
0
 
LVL 2

Author Closing Comment

by:brgdotnet
ID: 40613345
Hi, thanks Experts. No Paul, the question is very different. I am looking at an entirely different block of code, here and the subject of the bug is the insert which is missing the table name. You have helped me before, and I am so very grateful sir. Seriously though, this was something slightly different.

Thanks Aneesh.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question