Updating a table in sql Free adult shock chat
Account Number FROM Retrieve Account Number WHERE [Sales_Lead].[dbo].[Sales_Import]. Lead ID) I think there is no need for the inner join.
Account Number FROM Retrieve Account Number WHERE [Sales_Lead].[dbo].[Sales_Import]. Lead ID I have used all above queries, but they're not working; and when I used this one, it's done. DROP TABLE #TMP1 DROP TABLE #TMP2 CREATE TABLE #TMP1(Lead ID Int, Account Number NVarchar(50)) CREATE TABLE #TMP2(Lead ID Int, Account Number NVarchar(50)) INSERT INTO #TMP1 VALUES (147,'5807811235') ,(150,'5807811326') ,(185,'7006100100007267039'); INSERT INTO #TMP2 VALUES (147,'7006100100007266957') ,(150,'7006100100007267039') ,(185,'7006100100007267039'); UPDATE A SET A. Account Number FROM #TMP1 A INNER JOIN #TMP2 B ON A. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
-- the join clause is whatever suits you DECLARE @tbl1 TABLE (id INT, col1 VARCHAR(10), col2 VARCHAR(10)) DECLARE @tbl2 TABLE (id INT, col1 VARCHAR(10), col2 VARCHAR(10)) INSERT @tbl1 SELECT 1, 'a', 'b' UNION SELECT 2, 'b', 'c' INSERT @tbl2 SELECT 1, '1', '2' UNION SELECT 2, '3', '4' UPDATE t SET t.col1 = a.col1 ,t.col2 = a.col2 FROM ( SELECT id, col1, col2 FROM @tbl2) a INNER JOIN @tbl1 t ON = SELECT * FROM @tbl1 SELECT * FROM @tbl2 drop table uno drop table dos create table uno ( uid int, col1 char(1), col2 char(2) ) create table dos ( did int, col1 char(1), col2 char(2), [sql] char(4) ) insert into uno(uid) values (1) insert into uno(uid) values (2) insert into dos values (1,'a','b',null) insert into dos values (2,'c','d','cool') select * from uno select * from dos The other way to update from select statement What is the difference to other answers? Keep in mind: A good answer will always have an explanation of what was done and why it was done in such a manner, not only for the OP but for future visitors to SO.
This answer turned up in the low quality review queue, presumably because you don't provide any explanation of the code. I am using a phone to reply this, no computer to try.
I created a view linking the table to the account/card database to return the Table ID and the related account number, and now I need to update those records where the ID matches with the Account Number.
This is the UPDATE [Sales_Lead].[dbo].[Sales_Import] SET [Account Number] = (SELECT Retrieve Account Number.