| |

VerySource

 Forgot password?
 Register
Search
View: 910|Reply: 7

Find a super simple SQL statement, online etc. Thank you!

[Copy link]

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-13 11:30:01
| Show all posts |Read mode
Need to get: 00008
Now getting: 8
A total of 5 digits need to be filled with 0 before the default bit; what should I do!
Reply

Use magic Report

0

Threads

49

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-6-8 10:00:01
| Show all posts
select right('00000'+ '8',5)
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-6-8 11:45:01
| Show all posts
select right('10000'+'8',5)
result:
------
00008

(The number of rows affected is 1 row)
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-6-8 12:15:01
| Show all posts
Brother upstairs, the default position in front is not fixed!! What should I do, thank you!!
Reply

Use magic Report

0

Threads

28

Posts

25.00

Credits

Newbie

Rank: 1

Credits
25.00

 Canada

Post time: 2020-6-8 13:30:01
| Show all posts
Upstairs correct solution, too fast
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-8 14:15:02
| Show all posts
Declare @Num Int
Set @Num=8
Select Right(('00000'+Cast(@Num As Varchar)),5)
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-6-8 16:15:01
| Show all posts
Oh. Got it!! Thanks
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-6-8 18:30:01
| Show all posts
select rtrim(right('00000', 5-len('8'))+'8')
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