| |

VerySource

 Forgot password?
 Register
Search
View: 4008|Reply: 12

Preceding a number by '0' How to use SQL statement

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-27 15:20:02
| Show all posts |Read mode
The field DBBH in the table DBDA in the existing SQL Server database. The value of this field is '5555555'. I want to change the DBBH to '05555555', which is to add a '0' before the DBBH field. How to write this sentence, thank you! !!
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-2-21 20:00:01
| Show all posts
update table set DBDA = '0' + DBDA
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-19 11:45:01
| Show all posts
If the field is of type char or varchar, the one upstairs is OK. If it is a number, the type must be converted
Reply

Use magic Report

0

Threads

53

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-3-22 18:30:01
| Show all posts
Ha ha, if it is a number type, ha ha, it is estimated that this work should not be done, because the database is difficult to save such a formatted number
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-24 23:15:01
| Show all posts
DBBH is an integer:
select right ('0' + cast (DBBH as varchar (10)), 10) as DBBH
Reply

Use magic Report

0

Threads

17

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-3-26 14:00:02
| Show all posts
Why are you so strenuous, you just have to add it when you call the data
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-11 17:30:02
| Show all posts
procedure setzero(var s:string;len:Integer);
var
i: Integer;
begin
  for i:=1 to len-length(s) do
  begin
    s := '0' + s;
  end;
end;

You mean that the length is not enough to fill in '0', right?
Reply

Use magic Report

0

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Unknown

Post time: 2020-8-11 18:30:01
| Show all posts
Add 0 to the front of the integer? ?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-11 22:00:01
| Show all posts
RIGHT(100000000+field name, 8)
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-14 21:00:01
| Show all posts
You can convert the value to a character, and then see how many bits there are and add 0 to the front
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list