Jump to content

Sql Doubt


Recommended Posts

Posted

Oka easiest solution cheppandi..

 

Oka column in a table ni rename cheyyali which has 500 rows.

 

The column pattern is like:

 

abc $ 1

 

bcd $ 2.5

 

xyz $ 33

 

pqr $ 100 ...so on

 

ippudu aa string lo unna value ni +1 chesi update cheyyali..

 

 

abc $ 2

 

bcd $ 3.5

 

xyz $ 34

 

pqr $ 101 ...so on

 

RIGHT (columnname,3) hint dorkindi but ela proceede avvalo ardham avvatledhu..

 

IF condition use cheyochu ani pistundi, kaani tarvata REPLACE etla cheyyalo ardham avvatle..

 

SUggestions pls.

 

 

Posted

Create new column... copy data to new column with changing value to +1 using substr...update old column values to null n drop tht column

Posted

declare @newcolname varchar(100)

 

set @newcolname = do your stuff

exec sp_rename 'oldcolname' , @newcolname, 'COLUMN'

Posted

Select substr(columnname,1,instr(columnname,'$'))||' '||(to_number(trim(substr(columnname,instr(columnname,'$')+1)))+1) as finalvalue from testtable


ee vachina value tho new column populate cheyyi...old column teeseyi

  • Upvote 1
Posted

:4_12_13:  :4_12_13:

Select substr(columnname,1,instr(columnname,'$'))||' '||(to_number(trim(substr(columnname,instr(columnname,'$')+1)))+1) as finalvalue from testtable


ee vachina value tho new column populate cheyyi...old column teeseyi

 

Posted

Thank you 

RockStarZ

 

Select LEFT(COLUMN1,CHARINDEX('$',COLUMN1)) +  (RIGHT(COLUMN1,LEN(COLUMN1)-CHARINDEX('$',COLUMN1))+1)

FROM TABLE1 

 

worked for me

×
×
  • Create New...