SELECT [Name]
,[Code]
,case when len([ParentCode]) = '' then [Code] else [ParentCode] end as [ParentCode]
,case when len([Descr])=0 then [Code] else [Descr] end as [Descr]
,[Cumulative]
,[Expense]
,[Accts]
,[Admin]
,[Assessment]
,[Balance]
,[Fiber]
,[GL]
,[LV]
,[Slush]
FROM [KR].[pl].[Accounts]
Currently I have that query, but I want to change the part where data contains underscore instead space in ParentCode, and Code columns. Ex (slush_Code) how can i modify this query to work?
Use the replace() command:
SELECT REPLACE(ParentCode,'_',' ')
For example:
SELECT [Name]
,[Code]
,case
when len([ParentCode]) = 0 then REPLACE(Code,'_',' ')
else REPLACE(ParentCode,'_',' ')
end as [ParentCode]
,case when len([Descr]) = 0 then REPLACE(Code,'_',' ')
else [Descr]
end as [Descr]
,[Cumulative]
,[Expense]
,[Accts]
,[Admin]
,[Assessment]
,[Balance]
,[Fiber]
,[GL]
,[LV]
,[Slush]
FROM [KR].[pl].[Accounts]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With