Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I need help,
i have data column
[DE01]
[DE02]
[DE03]
[DE04]

i wana to change to be
[DE001]
[DE002]
[DE003]
[DE004]


how to change with query stored procedure?
Posted

check this


SQL
select Stuff('[DE01]',4,0,'0')


instead of '[DE01]' you can give the name of your data column.
 
Share this answer
 
Comments
jaket-cp 5-Dec-14 4:45am    
nice :)
just simple,

SQL
Update tbItemList
set Tag =  SUBSTRING(Tag,1,2) + '0' + SUBSTRING(Tag,3,2)
WHERE DatabaseID='250'


this works....
 
Share this answer
 
A replace could be used like so:
SQL
select replace('[DE01]','[DE','[DE0') ChangedToData;

Similar to solution 4, instead of '[DE01]' use the column/field name in the select/update (dml) statement.
 
Share this answer
 
SQL
UPDATE table1
SET data = Replace(data, '0', '00')



try this!...
 
Share this answer
 
 
Share this answer
 
SQL
create proc p1
as 
begin

alter table t1 rename column [DE01] to [DE001];
alter table t1 rename column [DE02] to [DE002];
........
end
go
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900