I am having a problem writing the query in SQL, this is what I have got:
UPDATE [DS_SKU] --The table I want to update
SET [SKU_Code] = [PROD].[SKU Code], --The field from table DS_SKU
I want updated from table PROD, Field SKU Code
FROM [DS_SKU] -- Have tried both tables
INNER JOIN [PROD] --This is the join of the table,
ON [PROD].[SKU Code]=[DS_SKU].[SKU_Code]; -- This is the PK & FK for
the tables
-- I have omitted the WHERE keyword as I want to update the whole table
But keep getting this error:
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'FROM'.
Banana said:
I see.
Are both tables linked? What happen if you run a equivalent query in
T-SQL via SQL Sever Management Studio?
Considering that the error came from "ODBC Manager", not "SQL Driver" or
"SQL Native Client", I'm inclined to think there is something flaky with
the process of passing this particular query, but let's verify if you
can get it to work on the SQL Server without any errors.
Lez wrote:
Hey Banana,
This is a regular query, I can open the tables directly. If I change
the query to a right join the query runs, but the update naturally does
not work.
The query tries to run, i.e. you can see the progress bar moving, then
the error occurs
Thanks
Lez
Is this a passthrough query or regular query? If it's a passthrough
query, then I think the SQL isn't correct for the SQL Server (guessing
based on the fact that your tables has prefix 'dbo_').
If it's a regular query, do you have another passthrough query that
works using exact same connection string? What about linked tables;
can you open it just fine?
Lez wrote:
Hi Guys,
I am trying to complete an update query, this is my SQL:
UPDATE dbo_PROD LEFT JOIN dbo_DS_SKU ON dbo_PROD.[SKU Code] =
dbo_DS_SKU.SKU_code
SET dbo_DS_SKU.SKU_productname = [dbo_PROD].[Product Name],
dbo_DS_SKU.SKU_code = [dbo_PROD].[SKU Code];
Each time I try to run this update I keep getting an ODBC error
message:
ODBC --- call failed
[Microsoft][ODBC Driver Manager] Invalid argument value (#0)
Can anyone advise why this error would occur and how can I resolve it
Thank you.