Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Update statement get executed but table remains the same

Started 1 month, 1 week ago by asyed01
Hello Experts, I’m trying to fill in one of my table with the information which I’m pulling from two different places (sys.Object & Information.schema.columns). So far I’ve fetch and stored all the data what I need. My first table structure is as follows Create Table #TempTotalTable( DBname varchar(100), TBId int, TBName varchar(500), CapturedDate datetime, TBCreationData ...
Site: dBforums - Database Support Community  dBforums - Database Support Community - site profile
Forum: Microsoft SQL Server  Microsoft SQL Server - forum profile
Total authors: 5 authors
Total thread posts: 7 posts
Thread activity: no new posts during last week
Domain info for: dbforums.com

Other posts in this thread:

Pat Phelan replied 1 month, 1 week ago
Code: UPDATE #TempTotalTable SET NoOfCol = #ColumnPerTable. NoOfCol FROM #ColumnPerTable WHERE #TempTotalTable.TBName = #ColumnPerTable.TBName -PatP

r937 replied 1 month, 1 week ago
Code: UPDATE #TempTotalTable SET NoOfCol = #ColumnPerTable.NoOfCol FROM #TempTotalTable t1 INNER JOIN #ColumnPerTable t2 ON t1.TBName = t2.TBName

dportas replied 1 month, 1 week ago
Your tables don't have any keys! That's your first problem. You are using Microsoft's version of the UPDATE statement with its FROM and JOIN clauses. That syntax suffers a pretty nasty design flaw that can cause unpredictable results when the joining criteria is not unique. If you are using SQL Server 2008 then I suggest you replace the UPDATE with MERGE, which is standard SQL, doesn't ...

asyed01 replied 1 month, 1 week ago
Thank you so much guy for your replies to solve my problem and I learned from my mistake. Many Thanks again for showing me correct way. YOU ALL ARE BEST.

Brett Kaiser replied 1 month, 1 week ago
thank you remember we are equal some just more so

Pat Phelan replied 1 month, 1 week ago
Dportas is right, MERGE would be preferable if it works in asyed01's environment. I was just lazy and provided the piece needed to get the posted statement to work instead of explaining why it was dangerous and better options for accomplishing the same purpose. In this case I should have done more than just get the code working. -PatP

 

Top contributing authors

Name
Posts
Pat Phelan
2
user's latest post:
Update statement get executed...
Published (2009-11-14 19:25:00)
Dportas is right, MERGE would be preferable if it works in asyed01's environment. I was just lazy and provided the piece needed to get the posted statement to work instead of explaining why it was dangerous and better options for accomplishing the same purpose. In this case I should have done more than just get the code working. -PatP
asyed01
2
user's latest post:
Update statement get executed...
Published (2009-11-14 12:42:00)
Thank you so much guy for your replies to solve my problem and I learned from my mistake. Many Thanks again for showing me correct way. YOU ALL ARE BEST.
Brett Kaiser
1
user's latest post:
Update statement get executed...
Published (2009-11-14 17:49:00)
thank you remember we are equal some just more so
r937
1
user's latest post:
Update statement get executed...
Published (2009-11-14 11:23:00)
Code: UPDATE #TempTotalTable SET NoOfCol = #ColumnPerTable.NoOfCol FROM #TempTotalTable t1 INNER JOIN #ColumnPerTable t2 ON t1.TBName = t2.TBName
dportas
1
user's latest post:
Update statement get executed...
Published (2009-11-14 11:55:00)
Your tables don't have any keys! That's your first problem. You are using Microsoft's version of the UPDATE statement with its FROM and JOIN clauses. That syntax suffers a pretty nasty design flaw that can cause unpredictable results when the joining criteria is not unique. If you are using SQL Server 2008 then I suggest you replace the UPDATE with MERGE, which is standard SQL, doesn't suffer the same problems as UPDATE and...

Related threads on "dBforums - Database Support Community":

Related threads on other sites:

Thread profile page for "Update statement get executed but table remains the same" on http://www.dbforums.com. This report page is a snippet summary view from a single thread "Update statement get executed but table remains the same", located on the Message Board at http://www.dbforums.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity