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 |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2009-10-22 : 10:30:01
|
| I need to convert ClaimNum (nvarchar) such as 200910258570002 to bigint, plus 1 and convert to nvarchar again.How to code it in a store procedure? |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-10-22 : 10:36:28
|
| select cast(cast('200910258570002' as bigint)+1 as nvarchar)Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2009-10-22 : 11:04:39
|
| I used code below but do not work as expected.test data: A.CLAIMNO = 200910228450002, nvarchar data typedeclare @c bigintset @c = cast((select distinct A.CLAIMNO from a) as bigint)+1print @c // print out as 200910228450003 that is correctdeclare @d nvarcharset @d = cast(@c as nvarchar(50))print @d //print out as 2, not correct, should be 200910228450003How to code to make @d = 200910228450003 as nvarchar type? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-22 : 11:08:29
|
quote: Originally posted by Sun Foster I used code below but do not work as expected.test data: A.CLAIMNO = 200910228450002, nvarchar data typedeclare @c bigintset @c = cast((select distinct A.CLAIMNO from a) as bigint)+1print @c // print out as 200910228450003 that is correctdeclare @d nvarcharset @d = cast(@c as nvarchar(50))print @d //print out as 2, not correct, should be 200910228450003How to code to make @d = 200910228450003 as nvarchar type?
You should have size for nvarchar datatypedeclare @d nvarcharshould bedeclare @d nvarchar(50)MadhivananFailing to plan is Planning to fail |
 |
|
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2009-10-22 : 11:12:06
|
| Thank you, madhivanan. It is working now. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-23 : 01:53:07
|
quote: Originally posted by Sun Foster Thank you, madhivanan. It is working now.
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|