Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
hii have the following 3 lines in a column (example 3 lines)
'Net Asset Value per share for Ignis Absolute Return Government Bond Fund. Class A EUR Distribution Hedged''Net Asset Value for Ignis Absolute Return Government Bond Fund. Class I2 GBP'Total Outstanding shares Class I2 GBP'
is there a way to pad this out so from where is says class to the end are always the same length.i need to read class on word so i can insert just that into another column
webfred
Master Smack Fu Yak Hacker
8781 Posts
Posted - 2014-05-16 : 07:56:21
this?
declare @test1 varchar(255) = 'Net Asset Value per share for Ignis Absolute Return Government Bond Fund. Class A EUR Distribution Hedged'selectcase when charindex('Class',@test1) > 0 then substring(@test1, charindex('Class',@test1)+6,len(@test1)-charindex('Class',@test1)) else 'not found'end
Too old to Rock'n'Roll too young to die.
rjhe22
Constraint Violating Yak Guru
283 Posts
Posted - 2014-05-16 : 08:54:04
sorry should have said these are all ready in a coulnm in a tbale so want to just pull it from there or pad it therethere will be different lines with different text dont want to have to declare them all
rjhe22
Constraint Violating Yak Guru
283 Posts
Posted - 2014-05-16 : 09:10:16
i set my column to 255used this code
selectcase when charindex('Class',[Group]) > 0 then substring([Group], charindex('Class',[Group])+0,len([Group])-charindex('Class',[Group])) else 'not found'endfrom dbo.BNYWorkingTempNavTable
still coming out different lengthsany ideas why
rjhe22
Constraint Violating Yak Guru
283 Posts
Posted - 2014-05-16 : 10:03:41
sorteed
select case when charindex('Class',[Group]) > 0 then substring([Group], charindex('Class',[Group])+0,len([Group])-charindex('Class',[Group])+1)endfrom dbo.BNYWorkingTempNavTable