Thursday, August 1, 2013

[SQL Server] Easy (I hope) join question

[SQL Server] Easy (I hope) join question


Easy (I hope) join question

Posted: 01 Aug 2013 07:53 AM PDT

Hi,I have two tables with many fields in them. I am only interested in a few of the fields, and both of the tables have records that are duplicates on the fields I am interested in. I think if I do a left outer join A on B I will get all the records in A, but some of them will become duplicated because they exist in B more than once. How do I do a join so that I keep all the records from table A and fill in the missing blanks, but do not create additional rows? Here's a small example:table AName | AddressTai | #table BName | AddressTai | 123 Main StTai | 123 Main StTai | 123 Main StMike | 456 Broadwaydesired output:Tai 123 Main StI do not expect there will ever be more than one distinct address for each name. However, if there is more than one distinct address then I would take one randomly and don't care if there are others that I did not get. I've done something similar to this but I had to use ROW_NUMBER() OVER (PARTITION BY... which given my newbie status seems complicated and it seemed like there should be an easier way.Thanks for the help!Tai

TempDB Full...!!

Posted: 01 Aug 2013 02:13 AM PDT

Hello Masters,My TempDB full..!! Its utilising almost 400% more disk space than its assigned..! How can I free disk space ? If I will take backup of system databses, will it free the disk space ? Please advice me..

Can someone tell me what is wrong in this query: I get error Msg 102, Level 15, State 1, Line 1 Incorrect syntax near

Posted: 31 Jul 2013 10:03 PM PDT

insert [User_Id],[Customer_Id],[User_Name],[Preferred_Name],[Email],[Mobile_Phone_1],[Mobile_Phone_2],[Mobile_Phone_3],[Phone_1_Status],[Phone_2_Status],[Phone_3_Status],[Password],[REMINDER_QUESTION],[REMINDER_ANSWER],[Registration_Date],[Registered_By],[Approval_date],[Approved_by],[Last_UpdateD],[Last_Updated_By],[Last_Sign_On_Tel],[Last_Sign_On_SMS],[Last_Sign_On_IB],[Status],[approved],[block],[TryCount],[user_flg],[ex_flg]into [e_onenew].[dbo].[Users] SELECT [User_Id],[Customer_Id],[User_Name],[Preferred_Name],[Email],[Mobile_Phone_1],[Mobile_Phone_2],[Mobile_Phone_3],[Phone_1_Status],[Phone_2_Status],[Phone_3_Status],[Password],[REMINDER_QUESTION],[REMINDER_ANSWER],[Registration_Date],[Registered_By],[Approval_date],[Approved_by],[Last_UpdateD],[Last_Updated_By],[Last_Sign_On_Tel],[Last_Sign_On_SMS],[Last_Sign_On_IB],[Status],[approved],[block],[TryCount],[user_flg],[ex_flg]from [e_one].[dbo].[Users]

No comments:

Post a Comment

Search This Blog