0

I just want to create the serial number into the table not just for view only for example:

table ConfirmationNumber:


SerialNo

--------------

00000001

00000002

00000003

and so on (the serial number will be increase each time i execute the query).

For that when I am creating a table in sql as:

CREATE TABLE confirm

(

ConfirmationID int,

name varchar(10),

SequenceNumber AS RIGHT('0000000' + convert(varchar, ConfirmationID), 8)

)

it's giving an error:

ERROR 1064 (42000): 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 'AS 
RIGHT('0000000' + convert(int, ConfirmationID), 8)
)' at line 9

Can any body help me?

Michael
  • 3,308
  • 5
  • 24
  • 36
Sai Kiran
  • 11
  • 2
  • 1
    Computed/Generated columns are not yet available in [MySQL](http://mysqlserverteam.com/generated-columns-in-mysql-5-7-5) – ughai Apr 10 '15 at 07:04
  • help me how to generate the serial number in table from 0000001 to.... so on... – Sai Kiran Apr 10 '15 at 07:12

1 Answers1

0

Remove sql-server from tags.

Put the desired code in your INSERT statements, or use a TRIGGER.

You can also use the ZEROFILL attribute to get 0s automatically displayed.

Rick James
  • 135,179
  • 13
  • 127
  • 222