Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Ciupaz
Posting Yak Master
232 Posts |
Posted - 2014-05-05 : 04:36:49
|
Hello all,I a stored procedure I have a parameter like:@CAId varchar(20)Before I use it in this procedure, I have to check if this parameter value contains the string "new", followed by a number, and then remove the "new" string. So, if I receive: @CAId = 'new365" -> @CAId = '365'@CAId = '150' -> @CAId = '150'How can I accomplish it?Thanks a lot. Luis |
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2014-05-05 : 04:40:17
|
[code]declare @CAID as varchar(50)set @CAId = 'new365' --set @CAid='150'select @CAID, replace(@CAid,'new','') as Numb[/code]sabinWeb MCP |
|
|
MuralikrishnaVeera
Posting Yak Master
129 Posts |
Posted - 2014-05-05 : 05:01:33
|
DECLARE @CAID AS VARCHAR(50)SET @CAId = 'new365' --set @CAid='150'SELECT SUBSTRING(@CAId,PATINDEX('%[0-9]%',@CAId),LEN(@CAId)) AS Number ---------------Murali KrishnaYou live only once ..If you do it right once is enough....... |
|
|
Ciupaz
Posting Yak Master
232 Posts |
Posted - 2014-05-05 : 05:29:48
|
Perfect, thank you all very much. Luis |
|
|
|
|
|