-2
DECLARE @id uniqueidentifier
SET @id = NEWID()

When I try to use the above declare to set up unique identifier, I am getting the below error:

DECLARE @id uniqueidentifier SET @id = NEWID() Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @id uniqueidentifier SET @id = NEWID()'

Not sure what the issue is. Any help is much appreciated

Thanks

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
jack
  • 1
  • The issue seems to be before the DECLARE already (MySQL error logging usually starts with the first character right after where things go wrong). So what is the rest of the code? – Norbert Apr 19 '15 at 00:03
  • @Norbert Actually i am trying to create a unique alphnumeric column in mysql. So i'm using the below query to do that. But when i execute the below query i get similar kind of error. So i that first we need to use the declare function to achieve that but no luck CREATE TABLE Product ( CustomerID uniqueidentifier NOT NULL DEFAULT newid(), Company varchar(30) NOT NULL, ContactName varchar(60) NOT NULL, ); – jack Apr 19 '15 at 00:16
  • 1
    , ); – : There is a lost , after the NULL (if this gets nowhere: Edit your post to be more clear :) ) – Norbert Apr 19 '15 at 00:22

1 Answers1

0

Check the documentation and adjust as needed:

SET @`id` := UUID();
SELECT @`id`;

SQL Fiddle demo

wchiquito
  • 16,177
  • 2
  • 34
  • 45