Click here to Skip to main content
15,919,245 members
Home / Discussions / Database
   

Database

 
Questionho to retrieve a list of dependants Pin
Anoop Brijmohun29-Jun-09 2:59
Anoop Brijmohun29-Jun-09 2:59 
AnswerRe: ho to retrieve a list of dependants [modified] Pin
Niladri_Biswas29-Jun-09 23:59
Niladri_Biswas29-Jun-09 23:59 
GeneralRe: ho to retrieve a list of dependants Pin
Anoop Brijmohun5-Jul-09 20:16
Anoop Brijmohun5-Jul-09 20:16 
QuestionConvert String and Sort the the Intergers in a String ASC Pin
Vimalsoft(Pty) Ltd29-Jun-09 0:31
professionalVimalsoft(Pty) Ltd29-Jun-09 0:31 
AnswerRe: Convert String and Sort the the Intergers in a String ASC Pin
Aman Bhullar29-Jun-09 2:20
Aman Bhullar29-Jun-09 2:20 
GeneralRe: Convert String and Sort the the Intergers in a String ASC Pin
Vimalsoft(Pty) Ltd29-Jun-09 2:25
professionalVimalsoft(Pty) Ltd29-Jun-09 2:25 
GeneralRe: Convert String and Sort the the Intergers in a String ASC Pin
Aman Bhullar29-Jun-09 3:06
Aman Bhullar29-Jun-09 3:06 
GeneralRe: Convert String and Sort the the Intergers in a String ASC Pin
Vimalsoft(Pty) Ltd29-Jun-09 3:21
professionalVimalsoft(Pty) Ltd29-Jun-09 3:21 
I got a Solution


create FUNCTION [dbo].[fnSplit](
    @sInputList VARCHAR(8000) -- List of delimited items
  , @sDelimiter VARCHAR(8000) = ',' -- delimiter that separates items
) RETURNS @List TABLE (item int)

BEGIN
DECLARE @sItem VARCHAR(8000)
WHILE CHARINDEX(@sDelimiter,@sInputList,0) <> 0
 BEGIN
 SELECT
  @sItem=RTRIM(LTRIM(SUBSTRING(@sInputList,1,CHARINDEX(@sDelimiter,@sInputList,0)-1))),
  @sInputList=RTRIM(LTRIM(SUBSTRING(@sInputList,CHARINDEX(@sDelimiter,@sInputList,0)+LEN(@sDelimiter),LEN(@sInputList))))
 
 IF LEN(@sItem) > 0
  INSERT INTO @List SELECT @sItem
 END

IF LEN(@sInputList) > 0
 INSERT INTO @List SELECT @sInputList -- Put the last item in
RETURN
END

go

create  FUNCTION GetSortedString
(
 @inputString varchar(max)
)
RETURNS varchar(max)
AS
BEGIN
 
declare @outputString varchar(max)
set @outputString = ''
select @outputString = ltrim(rtrim(str(item))) + ','  + @outputString  from dbo.fnSplit(@inputString,',') order by item desc
if  SUBSTRING(@outputString,len(@outputString),1) = ','
 begin
  set @outputString = SUBSTRING(@outputString,1,len(@outputString)-1) 
 end
return @outputString

END
GO


and Tested it like this

select dbo.GetSortedString('2,1,4,5,3,6')


Thanks

Vuyiswa Maseko,

Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/

AnswerRe: Convert String and Sort the the Intergers in a String ASC [modified] Pin
Niladri_Biswas29-Jun-09 5:45
Niladri_Biswas29-Jun-09 5:45 
GeneralRe: Convert String and Sort the the Intergers in a String ASC Pin
Vimalsoft(Pty) Ltd29-Jun-09 5:48
professionalVimalsoft(Pty) Ltd29-Jun-09 5:48 
GeneralRe: Convert String and Sort the the Intergers in a String ASC [modified] Pin
Niladri_Biswas29-Jun-09 5:55
Niladri_Biswas29-Jun-09 5:55 
GeneralRe: Convert String and Sort the the Intergers in a String ASC Pin
Vimalsoft(Pty) Ltd29-Jun-09 5:56
professionalVimalsoft(Pty) Ltd29-Jun-09 5:56 
QuestionProblem with joining tables in MSAccess. Pin
A k ch28-Jun-09 19:32
A k ch28-Jun-09 19:32 
AnswerRe: Problem with joining tables in MSAccess. Pin
riced28-Jun-09 22:44
riced28-Jun-09 22:44 
GeneralRe: Problem with joining tables in MSAccess. Pin
A k ch28-Jun-09 23:04
A k ch28-Jun-09 23:04 
AnswerRe: Problem with joining tables in MSAccess. Pin
Niladri_Biswas28-Jun-09 23:07
Niladri_Biswas28-Jun-09 23:07 
GeneralRe: Problem with joining tables in MSAccess. Pin
A k ch28-Jun-09 23:33
A k ch28-Jun-09 23:33 
GeneralRe: Problem with joining tables in MSAccess. Pin
riced29-Jun-09 0:43
riced29-Jun-09 0:43 
GeneralRe: Problem with joining tables in MSAccess. Pin
A k ch29-Jun-09 1:00
A k ch29-Jun-09 1:00 
QuestionFLOAT vs NUMERIC for financial transaction Pin
devvvy28-Jun-09 15:23
devvvy28-Jun-09 15:23 
AnswerRe: FLOAT vs NUMERIC for financial transaction Pin
Niladri_Biswas28-Jun-09 16:37
Niladri_Biswas28-Jun-09 16:37 
GeneralRe: FLOAT vs NUMERIC for financial transaction Pin
devvvy28-Jun-09 16:41
devvvy28-Jun-09 16:41 
GeneralRe: FLOAT vs NUMERIC for financial transaction Pin
Niladri_Biswas28-Jun-09 16:44
Niladri_Biswas28-Jun-09 16:44 
GeneralRe: FLOAT vs NUMERIC for financial transaction Pin
devvvy28-Jun-09 16:57
devvvy28-Jun-09 16:57 
GeneralRe: FLOAT vs NUMERIC for financial transaction Pin
Niladri_Biswas28-Jun-09 17:33
Niladri_Biswas28-Jun-09 17:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.