Reputation: 28
I have statement
SET @abc = 'ankit kumar'
SET @xyz = 'rohit'
SET @abc = SELECT REPLACE(@abc, 'ankit', @xyz)
but it not working and giving error: Incorrect syntax near the keyword 'SELECT'. I have also tried below instead of 3rd line but it doesn't work either:
SET @abc = REPLACE(@abc, 'ankit', @xyz)
Please assist. I am using Sybase ASE
Upvotes: 0
Views: 252
Reputation: 5636
You have both "set" and "select" in the same statement. Choose one.
SET @abc = REPLACE(@abc, 'ankit', @xyz)
or
SELECT @abc = REPLACE(@abc, 'ankit', @xyz)
Upvotes: 0
Reputation: 4391
Try this:
declare @abc varchar(100)
declare @xyz varchar(100)
SET @abc = 'ankit kumar'
SET @xyz = 'rohit'
set @abc = str_replace(@abc, 'ankit', @xyz)
Upvotes: 1