Sending Column Name From SP to C# App
-
hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value WITH a column name like Percantage. Here is the query for stored proc but I dont know what to add
CREATE PROCEDURE [dbo].[GetStudents] AS
SELECT
s.StudentId, s.FirstName,s.SurName,
( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column nameFROM Students s
GROUP BY
s.StudentId, s.FirstName,s.SurName -
hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value WITH a column name like Percantage. Here is the query for stored proc but I dont know what to add
CREATE PROCEDURE [dbo].[GetStudents] AS
SELECT
s.StudentId, s.FirstName,s.SurName,
( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column nameFROM Students s
GROUP BY
s.StudentId, s.FirstName,s.SurNameHi, try giving your calculate column value an alias. Then you can reference it by name in your c# datatable. I've modified (but no tested or ran) your procedure. Hope it helps,
CREATE PROCEDURE [dbo].[GetStudents] AS
SELECT
s.StudentId, s.FirstName,s.SurName,
( ((s.ObtMarks) / (s.TotalMarks)) * 100) AS PercentageValueFROM Students s
GROUP BY
s.StudentId, s.FirstName,s.SurName -
Hi, try giving your calculate column value an alias. Then you can reference it by name in your c# datatable. I've modified (but no tested or ran) your procedure. Hope it helps,
CREATE PROCEDURE [dbo].[GetStudents] AS
SELECT
s.StudentId, s.FirstName,s.SurName,
( ((s.ObtMarks) / (s.TotalMarks)) * 100) AS PercentageValueFROM Students s
GROUP BY
s.StudentId, s.FirstName,s.SurNamejust put colName = Calculated Value and you are good to go :)
-
hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value WITH a column name like Percantage. Here is the query for stored proc but I dont know what to add
CREATE PROCEDURE [dbo].[GetStudents] AS
SELECT
s.StudentId, s.FirstName,s.SurName,
( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column nameFROM Students s
GROUP BY
s.StudentId, s.FirstName,s.SurNamejust change the query like this..
SELECT
s.StudentId, s.FirstName,s.SurName,
( 'Percentage - ' + ((s.ObtMarks) / (s.TotalMarks)) * 100) as 'Percentage'hope it works..
with regards Karthik Harve
-
hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value WITH a column name like Percantage. Here is the query for stored proc but I dont know what to add
CREATE PROCEDURE [dbo].[GetStudents] AS
SELECT
s.StudentId, s.FirstName,s.SurName,
( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column nameFROM Students s
GROUP BY
s.StudentId, s.FirstName,s.SurNamecan be a useful keyword. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
can be a useful keyword. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum