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 |
Leonel
Starting Member
10 Posts |
Posted - 2012-10-23 : 18:48:51
|
i have this customer table(customer_id,customer_number,company_name, Address, etc)i was asked to change the customer_number field and add a zero in front of all the records, so we can then import another customer list .i dont know if this is posssible in sql , is there a way to run a querry so i can just put a zero in the begining like so(12, would be 012)the customer table look like this:customer_number name4041 Optima Bank and Trust83 Water Street Bookstore80 North Main Music4042 City of Dover4043 Manchester Community Health4044 6 Junkins court LLC |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
Leonel
Starting Member
10 Posts |
Posted - 2012-10-23 : 18:55:46
|
varchar(30) not null |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-23 : 18:57:25
|
yep do likeUPDATE tableSET customer_number = STUFF(customer_number,1,0,'0')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
Leonel
Starting Member
10 Posts |
Posted - 2012-10-23 : 21:00:27
|
Got it thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-23 : 21:30:51
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
Kannan475
Starting Member
3 Posts |
Posted - 2012-10-25 : 11:43:46
|
quote: Originally posted by visakh16 yep do likeUPDATE tableSET customer_number = STUFF(customer_number,1,0,'0')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Great, Can we just do this Update TableName set Customer_Number = '0'+Customer_Number |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-25 : 12:27:00
|
quote: Originally posted by Kannan475
quote: Originally posted by visakh16 yep do likeUPDATE tableSET customer_number = STUFF(customer_number,1,0,'0')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Great, Can we just do this Update TableName set Customer_Number = '0'+Customer_Number
Sure why notso far as Customer_Number is character datatype it will work. otherwise might require a cast------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|