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 |
vijay1234
Starting Member
48 Posts |
Posted - 2014-09-18 : 02:17:20
|
Hi friends,I have a requirement as followsI have a table with only one column ID (PrimaryKey).It has 1,2,3,4,5,6 recrds.So i would like to create a SP with one input parameter so that if i pass the parameter '1'..then the output should result as 123456Similarly if i pass '2', then result as 23456......if i pass '6' then result should be only 6.So i would like to know the TSQL query to create this scenarioThanks,Vijay |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-09-18 : 03:03:11
|
[code]declare @result varchar(100)select @result = isnull(@result, '') + CONVERT(VARCHAR(10), ID)from a_tablewhere ID >= @inputorder by ID[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
vijay1234
Starting Member
48 Posts |
Posted - 2014-09-18 : 03:16:23
|
Thanks Friend.How ever when i'm passing input parameter '3'. The result is nothing but the sum of 3+4+5+6 = 18.But i just want the ID's to be displayed.like 3 (input) ----> Result : 3 4 5 6 But not the Sum operation (+).Hope i'm clear Thanks,Vijay |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-09-18 : 07:01:13
|
edited the query KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|
|
|