#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    2
    Rep Power
    0

    Retrieving Column Name


    Hello

    I am using Sql Server and VC++. In VC++ I am using the below mentioned Query in my application to retrieve the sum of a particular column from a particular table.
    But I am not able to retrieve that column namer on which I have set the Sum function. The application returns a run time error saying abnormal termination of the program.

    The query is as below,

    SELECT Sum(Emp_Csh_Cash) as Emp_csh_cash
    FROM Employee_Cash
    WHERE Emp_Csh_Empdid in (Select Emp_ID from Employee where Emp_typ_Slno <> 3 and emp_typ_slno <> 4 )

    I have tried giving all possible combination of column names such as Emp_csh_cash, "Emp_csh_cash", Sum(Emp_csh_cash).
    But all have returned a run time error as mentioned above.

    Can anyone tell me as to what is wrong in my query or how else should I specify the name.

    Mythri
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    21
    Rep Power
    0
    does the query run outside of the application?


    another way of setting the column name is

    SELECT 'Emp_csh_cash' = Sum(Emp_Csh_Cash)
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    2
    Rep Power
    0
    Yes the query works outside the application. Anyway thanks, I will try out this way too.

IMN logo majestic logo threadwatch logo seochat tools logo