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 |
Vack
Aged Yak Warrior
530 Posts |
Posted - 2012-12-21 : 08:58:38
|
@Startvalue is intHow do I convert the following to nvarchar?@StartValue + Row_number() over (order by (select 1)) |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-12-21 : 09:00:51
|
CAST ( yourPart AS NVARCHAR)--Chandu |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-21 : 09:01:05
|
if you want values to be appendedCAST(@StartValue AS nvarchar(10)) + CAST(ROW_NUMBER() over (order by (select 1)) AS varchar(5))------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-12-21 : 09:07:24
|
If your @startvalue is for example 10, and you want to get 11,12,13 etc. do this:CAST(@StartValue + Row_number() over (order by (select 1)) AS NVARCHAR(5)); If your @startvalue is for example 10, and you want to get 101,102,...109,1010,1011 etc., do this:CAST(@StartValue AS NVARCHAR(5)) + CAST(Row_number() over (order by (select 1)) AS NVARCHAR(5)); |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-12-24 : 03:00:29
|
quote: Originally posted by Vack @Startvalue is intHow do I convert the following to nvarchar?@StartValue + Row_number() over (order by (select 1))
Because they sound like numbers, you don't need to convert them to nvarcharMadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-24 : 15:18:28
|
quote: Originally posted by madhivanan
quote: Originally posted by Vack @Startvalue is intHow do I convert the following to nvarchar?@StartValue + Row_number() over (order by (select 1))
Because they sound like numbers, you don't need to convert them to nvarcharMadhivananFailing to plan is Planning to fail
What if requirement was appending rather than integer addition? Unless OP posts sample data and expected output we cant determine what exactly the intended result is..------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|