Click here to Skip to main content
15,900,378 members
Home / Discussions / Database
   

Database

 
AnswerRe: Check Which rows are changed Pin
Niladri_Biswas4-Jul-09 2:17
Niladri_Biswas4-Jul-09 2:17 
QuestionHow to modify the SP in case of multiple row data into single row Pin
Krishna Aditya2-Jul-09 23:44
Krishna Aditya2-Jul-09 23:44 
AnswerRe: How to modify the SP in case of multiple row data into single row Pin
Niladri_Biswas3-Jul-09 6:24
Niladri_Biswas3-Jul-09 6:24 
GeneralRe: How to modify the SP in case of multiple row data into single row Pin
Krishna Aditya9-Jul-09 3:50
Krishna Aditya9-Jul-09 3:50 
GeneralLike Command in SQL Server 2005 Pin
Isaac Gordon2-Jul-09 23:24
Isaac Gordon2-Jul-09 23:24 
GeneralRe: Like Command in SQL Server 2005 Pin
Eddy Vluggen3-Jul-09 1:17
professionalEddy Vluggen3-Jul-09 1:17 
GeneralRe: Like Command in SQL Server 2005 Pin
David Skelly3-Jul-09 2:17
David Skelly3-Jul-09 2:17 
GeneralRe: Like Command in SQL Server 2005 Pin
Niladri_Biswas3-Jul-09 7:15
Niladri_Biswas3-Jul-09 7:15 
GeneralRe: Like Command in SQL Server 2005 Pin
Isaac Gordon3-Jul-09 19:08
Isaac Gordon3-Jul-09 19:08 
GeneralRe: Like Command in SQL Server 2005 Pin
Niladri_Biswas4-Jul-09 4:49
Niladri_Biswas4-Jul-09 4:49 
Questiontrigger on system tables Pin
sunit_822-Jul-09 22:54
sunit_822-Jul-09 22:54 
AnswerRe: trigger on system tables [modified] Pin
Niladri_Biswas3-Jul-09 17:29
Niladri_Biswas3-Jul-09 17:29 
GeneralRe: trigger on system tables Pin
sunit_825-Jul-09 22:39
sunit_825-Jul-09 22:39 
QuestionHow SQL View can be used in this scenario Pin
Krishna Aditya2-Jul-09 22:29
Krishna Aditya2-Jul-09 22:29 
AnswerRe: How SQL View can be used in this scenario Pin
Krishna Aditya2-Jul-09 22:41
Krishna Aditya2-Jul-09 22:41 
AnswerRe: How SQL View can be used in this scenario Pin
David Skelly3-Jul-09 2:26
David Skelly3-Jul-09 2:26 
GeneralRe: How SQL View can be used in this scenario Pin
Krishna Aditya3-Jul-09 2:58
Krishna Aditya3-Jul-09 2:58 
GeneralRe: How SQL View can be used in this scenario Pin
David Skelly3-Jul-09 5:57
David Skelly3-Jul-09 5:57 
QuestionFull Text Search in SQL Server 2005 Pin
Isaac Gordon2-Jul-09 18:21
Isaac Gordon2-Jul-09 18:21 
AnswerRe: Full Text Search in SQL Server 2005 Pin
Niladri_Biswas2-Jul-09 18:53
Niladri_Biswas2-Jul-09 18:53 
QuestionComplicated Summation Query Help Pin
JohnQuar12-Jul-09 7:44
JohnQuar12-Jul-09 7:44 
AnswerRe: Complicated Summation Query Help Pin
David Mujica2-Jul-09 8:37
David Mujica2-Jul-09 8:37 
After thinking about this for a bit, I think I would do this by creating a TEMP table and cursor to loop through the main table.

The TEMP table would be something like this:

Category      Zero  Total    Sum
Devices          0  38111   38111
Plan         38111   6063   44147
Improvements 44174   2266    4640



Use the following code snipet to get you going with the logic ...


DECLARE  myCURSOR CURSOR FOR 
	  SELECT CATEGORY, TOTAL
	  FROM myTABLE

OPEN myCURSOR
FETCH NEXT FROM myCURSOR INTO @XCATEGORY, @XTOTAL

SET @PBAL = 0.0
	
WHILE(@@FETCH_STATUS=0)	BEGIN

  SET @GTOTAL = @PBAL + @XTOTAL

  SET @MYSQL = 'INSERT INTO #MYTEMP'
  SET @MYSQL = @MYSQL + ' VALUES(' + CHAR(39) + @XCATEGORY+ CHAR(39) + ',' + @PBAL, + ',' + @XTOTAL + ','
  SET @MYSQL = @MYSQL + @GTOTAL + ')'

  PRINT @MYSQL

  EXEC(@MYSQL)

  FETCH NEXT FROM myCURSOR INTO @XCATEGORY, @XTOTAL

END

CLOSE myCURSOR
DEALLOCATE myCURSOR

GO


Hope this helps you !Thumbs Up | :thumbsup:
GeneralRe: Complicated Summation Query Help Pin
JohnQuar12-Jul-09 8:44
JohnQuar12-Jul-09 8:44 
QuestionSequential updates Pin
Gymnast1-Jul-09 18:42
Gymnast1-Jul-09 18:42 
AnswerRe: Sequential updates [modified] Pin
Niladri_Biswas1-Jul-09 18:58
Niladri_Biswas1-Jul-09 18:58 

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.