0

I have an Access database that need to be upgraded to using GUIDs. I added a number column with replication ID size one of the base table and now I need to add the GUIDs for each of the rows.

I'm writing in C#. Looping through all the records in the data, I'm trying to do a SQL update statement, and I can't get the syntax right.

Currently I have this;

UPDATE Locations 
SET LocationGUI = '{0027033a-7d16-485b-a76d-1c767c3ef030}', 
    Facility = '', 
    Address1 = '', Address2 = '', 
    City = '', State = '', Zip = '', 
    Telephone = '', Fax = '', Website = '' 
WHERE LocationID = 1;

But that's not right. What is the correct syntax around the GUID I'm trying to update into the table?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Bernie Hunt
  • 306
  • 4
  • 22
  • Just use [parameterized SQL](https://stackoverflow.com/q/35163361/87698) instead of trying to "guess" the correct format for GUID literals. – Heinzi Oct 17 '22 at 20:47

1 Answers1

0

Try this - without the typo and leaving the other fields untouched:

UPDATE Locations 
SET LocationGUID = '{0027033a-7d16-485b-a76d-1c767c3ef030}'
WHERE LocationID = 1;
Gustav
  • 53,498
  • 7
  • 29
  • 55