Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQl Update Query

Posted on 2013-05-10
1
Medium Priority
?
224 Views
Last Modified: 2013-05-21
Hello,
This update query is not updating correctly
Please assist

If (select count(*) from ROusage where LoginID = @tmpLoginID) = 1
    Begin
            update ROUsage set
            LoginID=q.LoginID,
            ct=q.ct,
            sDate=q.sdate,
            userID=q.userID,
            fName=q.Fname
            from (
            select t.LoginID,t.ct,t2.sdate,u.userID as UserID, u.fName from @tmpTable t
            left join remoteoffice..Users u on u.safeword = t.LoginID
            left join @tmpTable2 t2 on t2.loginid = t.LoginID
            where t.LoginID = @tmpLoginID
            )q
      end
0
Comment
Question by:Mauro Cazabonnet
[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
1 Comment
 
LVL 25

Accepted Solution

by:
jogos earned 1500 total points
ID: 39156207
In general: Please give guidance on your "This update query is not updating correctly": to much, to few, wrong values,  error,  ....

I guess this is what you need
update R
 set
            R.LoginID=q.LoginID,
            R.ct=q.ct,
            R.sDate=q.sdate,
            R.userID=q.userID,
            R.fName=q.Fname
            from ROUsage as R 
               (
               select t.LoginID,t.ct,t2.sdate,u.userID as UserID, u.fName from @tmpTable t
               left join remoteoffice..Users u on u.safeword = t.LoginID
               left join @tmpTable2 t2 on t2.loginid = t.LoginID
               ) as q ON q.LoginID = R.LoginID
          where R.LoginID = @tmpLoginID

 

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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.

618 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