0

I have a table in Sql Server, in which I want to generate alphanumeric sheets. So I'm going to make an alter column but when I execute it, it gives me an error, I don't understand why it happens. Here is the SQL code:

  ALTER TABLE [DB_AtencionCliente].[WAPP].[TBL_TRANSFERENCIA_BANCARIA]
  ALTER COLUMN FOLIO AS ([TIPO_TRX] + RIGHT('00000000' + CAST([TRX] AS VARCHAR(9)), 9)) PERSISTED;
  • What's the error that it gives you? – squillman Oct 29 '21 at 17:59
  • @squillman The mistake is: " Incorrect syntax near '('. " – Nicolas Flores Muñoz Oct 29 '21 at 18:02
  • You can't alter a computed column. You can only drop it and readd it with the new formula. – squillman Oct 29 '21 at 18:07
  • 2
    Does this answer your question? Even though the linked question is for SQL Server 2008 it still applies. [How can I alter this computed column in SQL Server 2008?](https://stackoverflow.com/questions/2372655/how-can-i-alter-this-computed-column-in-sql-server-2008) – squillman Oct 29 '21 at 18:08
  • Just an aside. If by chance you have NULLs, rather than generating a NULL, concat() will treat them as an empty string... concat([TIPO_TRX],RIGHT(concat('000000000',[TRX]), 9)) – John Cappelletti Oct 29 '21 at 18:08

0 Answers0