September 29, 2011 at 7:20 pm
Hi All,
I'm just having a complete brain fart today and I have forgotten how to do a basic update. Could someone help me please.
I have a table "dbo.tblGroup_Drawing AS GD" with 2 columns, grpID and DrgNo.
Simply, using the below Select statement I need to update GD.grpID to equal tblGroup_1.grpID AS NewGroupID
SELECT d.DrgNo, GD.grpID, d.BUCode, G.grpName, G.BUCode AS Expr1, tblGroup_1.grpName AS NewGroupName, tblGroup_1.grpID AS NewGroupID, tblGroup_1.BUCode AS NewBU
FROM dbo.tblGroup_Drawing AS GD INNER JOIN
dbo.Drawing AS d ON GD.DrgNo = d.DrgNo INNER JOIN
dbo.tblGroup AS G ON GD.grpID = G.grpID INNER JOIN
dbo.tblGroup AS tblGroup_1 ON G.grpName = tblGroup_1.grpName
WHERE (d.BUCode = 7) AND (tblGroup_1.BUCode = 7)
Any help would be greatly appreciated.
Thank you
September 29, 2011 at 7:22 pm
Byzza (9/29/2011)
Hi All,I'm just having a complete brain fart today and I have forgotten how to do a basic update. Could someone help me please.
I have a table "dbo.tblGroup_Drawing AS GD" with 2 columns, grpID and DrgNo.
Simply, using the below Select statement I need to update GD.grpID to equal tblGroup_1.grpID AS NewGroupID
SELECT d.DrgNo, GD.grpID, d.BUCode, G.grpName, G.BUCode AS Expr1, tblGroup_1.grpName AS NewGroupName, tblGroup_1.grpID AS NewGroupID, tblGroup_1.BUCode AS NewBU
FROM dbo.tblGroup_Drawing AS GD INNER JOIN
dbo.Drawing AS d ON GD.DrgNo = d.DrgNo INNER JOIN
dbo.tblGroup AS G ON GD.grpID = G.grpID INNER JOIN
dbo.tblGroup AS tblGroup_1 ON G.grpName = tblGroup_1.grpName
WHERE (d.BUCode = 7) AND (tblGroup_1.BUCode = 7)
Any help would be greatly appreciated.
Thank you
You mean this?
UPDATE GD
SET GrpID = tblGroup_1.GrpID
FROM .... rest of your code here (though I'd take out Drawing/d table, you don't use it.)
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
September 29, 2011 at 8:14 pm
Yes Exactly that. Thank you. As I said brain fart. For some reason I was trying From (Select ... from ...) instead of egnoring the select line.
Thank god its Friday, and before a long weekend.
September 30, 2011 at 11:05 am
Byzza (9/29/2011)
Yes Exactly that. Thank you. As I said brain fart. For some reason I was trying From (Select ... from ...) instead of egnoring the select line.Thank god its Friday, and before a long weekend.
LOL, my pleasure, been there done that a few times myself. Of Course, in America, it was still Thursday and you had me checking my holiday calendar. 😀
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply