Click here to Skip to main content
15,923,218 members
Home / Discussions / Database
   

Database

 
GeneralSearching a database Pin
Binary011023-Aug-05 9:36
Binary011023-Aug-05 9:36 
GeneralRe: Searching a database Pin
Colin Angus Mackay23-Aug-05 21:21
Colin Angus Mackay23-Aug-05 21:21 
GeneralRe: Searching a database Pin
Binary011024-Aug-05 6:18
Binary011024-Aug-05 6:18 
Generalconcatenate recordset into one row Pin
JKroschel23-Aug-05 9:11
JKroschel23-Aug-05 9:11 
GeneralRe: concatenate recordset into one row Pin
airbus38024-Aug-05 22:34
airbus38024-Aug-05 22:34 
GeneralRe: concatenate recordset into one row Pin
JKroschel25-Aug-05 4:28
JKroschel25-Aug-05 4:28 
GeneralRe: concatenate recordset into one row Pin
Davene31-Aug-05 8:14
Davene31-Aug-05 8:14 
GeneralRe: concatenate recordset into one row Pin
airbus38031-Aug-05 11:45
airbus38031-Aug-05 11:45 
I want to say that
you must create a "user defined function" (T SQL function)
like this

CREATE FUNCTION SSum (@id INT)   //SSum = string sum<br />
RETURNS NVARCHAR(255) AS  <br />
BEGIN <br />
<br />
DECLARE @ssum NVARCHAR(255)<br />
DECLARE @dayofweek NVARCHAR(25)<br />
SET @ssum = ''<br />
<br />
DECLARE crs CURSOR FOR SELECT DAYOFWEEK FROM schedule WHERE ID = @id<br />
OPEN crs<br />
<br />
FETCH NEXT FROM crs INTO @dayofweek<br />
WHILE( @@FETCH_STATUS = 0 )<br />
BEGIN<br />
SET @ssum = @ssum + ',' + @dayofweek<br />
FETCH NEXT FROM crs INTO @dayofweek<br />
END<br />
<br />
CLOSE crs<br />
DEALLOCATE crs<br />
<br />
IF( LEN(@ssum) != 0 )<br />
SET @ssum = SUBSTRING(@ssum,2,255)<br />
<br />
RETURN @ssum<br />
<br />
END



After, built your report on a SELECT query using SSum function like this:

<br />
SELECT DISTINCT ID , dbo.SSum(id) AS Days<br />
FROM schedule<br />




VB6,C#

-- modified at 17:46 Wednesday 31st August, 2005
GeneralRe: concatenate recordset into one row Pin
Davene31-Aug-05 12:20
Davene31-Aug-05 12:20 
GeneralSQL Mail Pin
samoore23-Aug-05 6:09
samoore23-Aug-05 6:09 
GeneralRe: SQL Mail Pin
samoore23-Aug-05 7:32
samoore23-Aug-05 7:32 
GeneralProblem with Update ADO record through VBS Pin
IFriendly23-Aug-05 4:20
IFriendly23-Aug-05 4:20 
GeneralT-SQL Problem Pin
WDI23-Aug-05 2:45
WDI23-Aug-05 2:45 
GeneralRe: T-SQL Problem Pin
Colin Angus Mackay23-Aug-05 3:13
Colin Angus Mackay23-Aug-05 3:13 
GeneralRe: T-SQL Problem Pin
WDI23-Aug-05 4:27
WDI23-Aug-05 4:27 
GeneralRe: T-SQL Problem Pin
Colin Angus Mackay23-Aug-05 4:54
Colin Angus Mackay23-Aug-05 4:54 
GeneralRe: T-SQL Problem Pin
Frank Kerrigan23-Aug-05 4:16
Frank Kerrigan23-Aug-05 4:16 
GeneralFiltering and Paging Pin
WDI23-Aug-05 2:11
WDI23-Aug-05 2:11 
GeneralRe: Filtering and Paging Pin
miah alom25-Aug-05 10:40
miah alom25-Aug-05 10:40 
QuestionCannot lock record? Pin
Javolin22-Aug-05 14:30
Javolin22-Aug-05 14:30 
AnswerRe: Cannot lock record? Pin
Christian Graus22-Aug-05 14:33
protectorChristian Graus22-Aug-05 14:33 
Questioninsert text truncated in ADO, not in ODBC? Pin
ir_fuel22-Aug-05 11:06
ir_fuel22-Aug-05 11:06 
AnswerRe: insert text truncated in ADO, not in ODBC? Pin
toxcct22-Aug-05 20:23
toxcct22-Aug-05 20:23 
GeneralRe: insert text truncated in ADO, not in ODBC? Pin
ir_fuel22-Aug-05 22:28
ir_fuel22-Aug-05 22:28 
AnswerRe: insert text truncated in ADO, not in ODBC? Pin
Rob Graham23-Aug-05 2:32
Rob Graham23-Aug-05 2:32 

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.