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 |
|
DavisJ44
Starting Member
9 Posts |
Posted - 2009-05-22 : 12:01:03
|
| Currently I have a variable defined as follows@tbl = 0409I want to subtract 1 from this variable without loosing the format when I subtract one I always get 408 for the following setset @tbl = @tbl - 1However, I want 0408 so I then try to subtract and concatenateleft(@tbl,2)+right(@tbl,2)-1, but this then gives me40 + 8 = 12 literally when all I want is 0408This is very annoying why is the concatenate symbol not || or & like in VBA? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-22 : 12:22:37
|
convert to integer then subtract after that convert back to stringright('0000' + convert(varchar(10), @tlb_int), 4) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|