0

I have 2 queries like this:

Select F_Exhibitor,F_Stand from t_order_header where F_Exhibition='10996'

AND

select F_ExhibitorCode,F_Stand from T_ExhibitorLocation where F_ExhibitionCode='10996'

I want to update T_order_header table F_stand with corresponding F_ExhibitorCode and F_stand name in the T_ExhibitorLocation

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
jase mhi
  • 83
  • 1
  • 1
  • 7
  • 1
    possible duplicate of [UPDATE from SELECT using SQL Server](http://stackoverflow.com/questions/2334712/update-from-select-using-sql-server) – Maciej Los May 14 '15 at 09:55
  • Your naming convention is all over the place and there is no code formatting. SQL commands are easier to read as UPPERCASE (I'm not shouting) For me an underscore in SQL does not work and then in your question your naming convention has changed again. Maybe a tidy up of your code might help you and others understand your problem. – Stephen Ó Connor May 14 '15 at 10:02

2 Answers2

1

Hoping to have correctly understood the request, the update query could be something like

UPDATE o
SET o.F_Stand = e.F_Stand
FROM t_order_header o INNER JOIN T_ExhibitorLocation e ON e.F_ExhibitionCode = F_Exhibition
--optional where code
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Simone
  • 1,828
  • 1
  • 13
  • 20
0
UPDATE t_order_header  
SET F_STAND = A.F_STAND
FROM 
  (SELECT F_ExhibitorCode,F_Stand 
   FROM T_ExhibitorLocation 
   WHERE F_ExhibitionCode='10996')A // What's that A ?
WHERE A.F_ExhibitorCode=F_Exhibitor

now try.....

Sliq
  • 15,937
  • 27
  • 110
  • 143
  • Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'A'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'A'. – jase mhi May 14 '15 at 10:28