-
Replicate
I need to find the next Id to be used in an order and pad a 0 to the front..
I know that I can select the max(strIid)+1 and get the next orderid. How do I use the Replicate function to add a leading zero to the id which is a varchar(5)?
-
You can do this
SELECT REPLICATE('0', 5 - DATALENGTH(cast(StrIid as char(5)))) + ltrim(cast(StrIid as char(5)))
FROM table
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|