Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 What is the easy way?

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2007-11-07 : 13:03:30
I have a table that has a field with titles as a Varchar. I created another field that is a Title ID and another table that the ID would link to. I made that Title table by doing a distinct select on the original table. I need to be able to take the ID from the Title table and insert it into the title ID from the original table. Hope that make sense.

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2007-11-07 : 13:11:38
There are some people that don't belong in forums. You are one of those people. My best shot is this, but I do not want to run it and screw up the table.

UPDATE tbl_Name
SET FormOfAddressID =
(SELECT FormOfAddressID
FROM tbl_FormOfAddress
WHERE (FormOfAddressName = tbl_Name.FormOfAddress))
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-07 : 13:29:55
Do you have a Dev enviornment to test it in? If not, you could do a BEGIN TRAN and then run your update. Then check it out and make sure it's what you want. If not, just ROLLBACK. If it is what you want then COMMIT.
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-08 : 11:26:10
Why did the other person delete their post where they were being an asshat and trying to be rude to you?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-08 : 11:32:01
[code]UPDATE x
SET x.FormOfAddressID = y.FormOfAddressID
FROM tbl_Name AS x
INNER JOIN tbl_FormOfAddress AS y ON y.FormOfAddressName = x.FormOfAddress[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2007-11-09 : 01:09:06
i guess asking helix to post some ddl and sample data was asking too much. i didnt refer this post to be an "asshat," if you look around sqlteam youll find that others use the same link and make the same request often... i think helix was a little quick to take offense to this:

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


so, again... all apologies, but the majority of posts coming from him offer no gratitude or feedback for the sqlteamers providing help at no cost.

and sorry bout the delete, its just difficult to offer help to someone who doesnt want to put in any effort and continues to ask the same questions

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=45089
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81171

Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2007-11-09 : 01:35:50
and to answer your original question, the "easy way" is for you to press ctrl+c, ctrl-v, learn nothing, thank no one, and return here the next time you need to update using a join.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-09 : 03:11:19
Great links!
How many times can one ask for help about update and joins?
Do we have a bookie around here somewhere?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-09 : 15:05:31
quote:
Originally posted by nathans

i guess asking helix to post some ddl and sample data was asking too much. i didnt refer this post to be an "asshat," if you look around sqlteam youll find that others use the same link and make the same request often... i think helix was a little quick to take offense to this:

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


so, again... all apologies, but the majority of posts coming from him offer no gratitude or feedback for the sqlteamers providing help at no cost.

and sorry bout the delete, its just difficult to offer help to someone who doesnt want to put in any effort and continues to ask the same questions

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=45089
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81171





My only point was that you directed Helix to the proper way to post, then he kinda took offense, then you replied that you didn't mean to offend and weren't being rude and that you just wanted him to post properly. Ok, that's cool. But then you deleted your posts altogether, which tells me that yea, maybe you were trying to be rude. That's all.
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2007-11-09 : 15:34:23
yea... no worries. i did originally post the apology, but after looking at his other posts i just decided i wanted nothing to do with this guy, hence the delete. i totally appreciate that you were just sticking up for what appeared to be a grateful jr. developer, but im not convinced this guy deserves such treatment.

"asshat" did make me chuckle a bit though :)

Nathan Skerl
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-12 : 10:44:48
My bad dude. I guess I'm the asshat now...lol
Go to Top of Page
   

- Advertisement -