0
I basically have a database table, which has a field called DESCRIÇÃO
and the table is called Tabela123
I have 10 records in this table, and in the DESCRIPTION field I have the sentences: Hello, you are well? repeating for four times, goodbye and thank you four times and good morning twice.
I want to change these phrases using a stored Procedure.
In the first sentence I want to change to Example: Hello, you’re fine? all four records, in the second sentence I want to change to Hello and thank you in the four records.
I basically want to create a Stored Procedure
that changes a part or word of the sentence in the description field.
CREATE PROCEDURE [dbo].[UpdateTable] @XKey INT, @XDescription NVARCHAR(MAX) AS BEGIN BEGIN TRANSACTION BEGIN try
SET nocount ON
UPDATE TABLE
SET Description = @VMDescription
WHERE ID = @VMKey
COMMIT; END try BEGIN catch
ROLLBACK TRANSACTION; DECLARE @errorMessage nvarchar(4000); DECLARE @errorSeverity int; DECLARE @errorState int;
SELECT @errorMessage = ERROR_PROCEDURE() + ': ' + ERROR_MESSAGE(),
@errorSeverity = ERROR_SEVERITY(),
@errorState = ERROR_STATE(); RAISERROR(@errorMessage,@errorSeverity,@errorState); END catch END
As I have now I think it is wrong, since I have parameters and I think I will not want anything like this, I want to run the script and do what is on top.
update Tabela123 set Descricao = 'Olá, você está bem?' where Descricao = 'Olá, você está bem?'
...– Marconi
@Marconi edited the answer and I put as I had, try to add and change my code in a reply please, that goes against what I need, I’m half lost
– Programmer Master
In my view your
procedure
is correct.– Marconi