Click here to Skip to main content
15,906,569 members
Home / Discussions / Database
   

Database

 
AnswerRe: Parameterized Queries in the SELECT portion? Pin
Not Active7-Sep-06 18:53
mentorNot Active7-Sep-06 18:53 
GeneralRe: Parameterized Queries in the SELECT portion? Pin
Dominic Pettifer8-Sep-06 2:31
Dominic Pettifer8-Sep-06 2:31 
GeneralRe: Parameterized Queries in the SELECT portion? Pin
Colin Angus Mackay10-Sep-06 9:27
Colin Angus Mackay10-Sep-06 9:27 
Questionupdating an IMAGE column Pin
jszpila7-Sep-06 5:15
jszpila7-Sep-06 5:15 
AnswerRe: updating an IMAGE column Pin
Michael Potter7-Sep-06 5:50
Michael Potter7-Sep-06 5:50 
Questioncombining multiple rows into single column Pin
Uma Kameswari7-Sep-06 2:32
Uma Kameswari7-Sep-06 2:32 
AnswerRe: combining multiple rows into single column Pin
Michael Potter7-Sep-06 6:02
Michael Potter7-Sep-06 6:02 
AnswerRe: combining multiple rows into single column Pin
Eric Dahlvang7-Sep-06 9:26
Eric Dahlvang7-Sep-06 9:26 
If you don't know how many classes are in the table, you could make a stored procedure that dynamically creates an sql returning a column for every class:
CREATE PROCEDURE GetGrades AS

DECLARE @sql VARCHAR(2500), @cClass VARCHAR(10) 

SET @sql = ''

DECLARE curClasses CURSOR FOR SELECT DISTINCT class FROM tblGrades
OPEN curClasses
FETCH NEXT FROM curClasses INTO @cClass
WHILE @@FETCH_STATUS = 0
BEGIN
	SET @sql = @sql + ', (SELECT grade 
                              FROM tblGrades t2 
                              WHERE t2.StudentId = t1.StudentId 
                                    and t2.Class = ''' + @cClass + ''') as ' + @cClass
	FETCH NEXT FROM curClasses INTO @cClass
END

close  curClasses
DEALLOCATE curClasses

SET @sql =  'SELECT studentid ' + @sql + ' FROM tblGrades t1 GROUP BY studentid'
exec(@sql)
GO


--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters

Questionfunction vs stored procedure in sqlserver 2000 Pin
yazan_zahi7-Sep-06 1:42
yazan_zahi7-Sep-06 1:42 
AnswerRe: function vs stored procedure in sqlserver 2000 Pin
SeMartens7-Sep-06 1:52
SeMartens7-Sep-06 1:52 
AnswerRe: function vs stored procedure in sqlserver 2000 Pin
saqib827-Sep-06 4:29
saqib827-Sep-06 4:29 
AnswerRe: function vs stored procedure in sqlserver 2000 Pin
Sumitjh8213-Sep-06 20:02
Sumitjh8213-Sep-06 20:02 
QuestionHow would i query these tables? Pin
Red_Wizard_Shot_The_Food7-Sep-06 0:15
Red_Wizard_Shot_The_Food7-Sep-06 0:15 
AnswerRe: How would i query these tables? Pin
SeMartens7-Sep-06 1:48
SeMartens7-Sep-06 1:48 
AnswerRe: How would i query these tables? Pin
Mike Dimmick7-Sep-06 2:13
Mike Dimmick7-Sep-06 2:13 
GeneralRe: How would i query these tables? Pin
Red_Wizard_Shot_The_Food7-Sep-06 22:55
Red_Wizard_Shot_The_Food7-Sep-06 22:55 
QuestionC# DataSet DataAdapter Design Pin
llap4446-Sep-06 5:03
llap4446-Sep-06 5:03 
AnswerRe: C# DataSet DataAdapter Design Pin
Stephen McGuire6-Sep-06 7:02
Stephen McGuire6-Sep-06 7:02 
GeneralRe: C# DataSet DataAdapter Design Pin
llap4446-Sep-06 7:34
llap4446-Sep-06 7:34 
QuestionTranforming two text files using DTS Pin
dayakar_dn6-Sep-06 2:42
dayakar_dn6-Sep-06 2:42 
QuestionRunning Program(on VB .NET) Without SQL Pin
FriendlySoluations6-Sep-06 1:24
FriendlySoluations6-Sep-06 1:24 
AnswerRe: Running Program(on VB .NET) Without SQL Pin
Colin Angus Mackay6-Sep-06 3:14
Colin Angus Mackay6-Sep-06 3:14 
AnswerRe: Running Program(on VB .NET) Without SQL Pin
Stephen McGuire6-Sep-06 5:27
Stephen McGuire6-Sep-06 5:27 
Question.NET and metadata of database Pin
Imtiaz Murtaza5-Sep-06 22:51
Imtiaz Murtaza5-Sep-06 22:51 
Questionstoere procedure Pin
yazan_zahi5-Sep-06 22:44
yazan_zahi5-Sep-06 22:44 

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.