How to use Top 1 in this query

Hi!

Have this query, that gives me this error message:
 [Error Code: 4104, SQL State: S1000]  The multi-part identifier "a.Varenrhgn" could not be bound.

Query:

UPDATE dbo.VEC_Artikkel
SET a.Varenrhgn = b.ITEMID
FROM dbo.VEC_Artikkel a
INNER JOIN [hgnn-sql01].[axdb5-drift].[DBO].[CUSTVENDEXTERNALITEM] b 
ON a.Varenr = b.EXTERNALITEMID

Open in new window


Must use Top 1 here , but where do i put Top 1 in the query ?
LVL 2
team2005Asked:
Who is Participating?
 
lwadwellConnect With a Mentor Commented:
You could try:
UPDATE a
SET a.Varenrhgn = b.ITEMID
FROM dbo.VEC_Artikkel a
INNER JOIN [hgnn-sql01].[axdb5-drift].[DBO].[CUSTVENDEXTERNALITEM] b 
ON a.Varenr = b.EXTERNALITEMID

Open in new window


With regard to a TOP 1 ... you can set a TOP on the update and that limits how many rows get updated.  Is that what you want?
0
 
team2005Author Commented:
Thanks alot, works like a charm :)
0
All Courses

From novice to tech pro — start learning today.