Click here to Skip to main content
15,889,383 members

Comments by Sridhar Babu 2022 (Top 1 by date)

Sridhar Babu 2022 11-Sep-22 8:56am View    
create table dbo.test1(promo_text nchar(200))
--insert into test1 values('₹1234 discount')
--insert into test1 values('discount sales price ₹2345 rupees')

create or alter procedure usp_ExtractSign(@promo_text nchar(200))
as
begin
set nocount on

select
case
when
(CHARINDEX('₹', @promo_text) > 0 and ISNUMERIC(SUBSTRING(@promo_text, (CHARINDEX('₹', @promo_text)+1),3))=1) then
try_cast(try_convert(money,(substring(@promo_text,(charindex('₹', @promo_text)+1),3))) as decimal)
end
from test1


end

exec usp_ExtractSign '₹1234 discount'


My requirement:
i entered two records
when executed procedure output should be 1234 and 2345. if required any changes in procedure,
post the code,