how to add 2 more columns to my table RRS feed

  • Question

  • User2138391294 posted

    dear all,

    i have this command below:

     B.[Description] As 'Driver Name'
    ,A.DriverCard    As 'Driver ID'
    ,A.CarNumber As'Vehicle Number'
    ,A.StartDistance As 'Start Odometer'
    ,A.EndDistance As 'End Odometer'
    ,A.StartDate As 'Trip Date'
    ,A.StartHour As 'Start Time'
    ,A.EndHour As 'End Time'
    ,A.[RPMIdleTime] As 'Idle Time Engine Runing'
    ,A.DriveDistance  As'Trip Distance'
    ,A.[IdleTime] As 'Idle Time Total'
    ,A.StartDistance As 'Start Odometer'
    ,A.EndDistance As 'End Odometer'
    ,E.Location As 'Start Destincation'
    ,F.Location As 'End Destincation'

    FROM CarData.dbo.CarTravels A
    LEFT JOIN CarData.dbo.Users B ON A.DriverCard=B.CardNumber
    LEFT JOIN CarData.dbo.Cars C ON A.CarNumber=C.CarNumber
    LEFT JOIN  CarData.dbo.GPSAddress E ON A.StartGPS_ID=E.ID
    LEFT JOIN  CarData.dbo.GPSAddress F ON A.EndGPS_ID=F.ID
    LEFT JOIN CarData.dbo.Groups W ON C.GroupID=W.GroupID

    WHERE (StartDate >={?1StartDate})
    AND (StartDate <={?2EndDate})


    and i need to add to my table two more columns which are the StartDistance and EndDistance

    but i have no clue

    please any help is really appreciated

    thank you

    Monday, May 5, 2014 5:17 AM

All replies

  • User-578610739 posted

    Hi Dear,

    You can add the column same as above other column add. You did not mention that table name of these columns.

    For example , StartDistance and EndDistance is from same tablename suppose cardata , then just before the "From" cluase add it. as

    , --give here comma to continue

    Monday, May 5, 2014 5:40 AM
  • User753101303 posted


    Unclear. Do you mean that you are looking for the ALTER TABLE statement (see http://msdn.microsoft.com/en-us/library/ms190273.aspx and scroll down to "example A") so that you can those missing columns to your CatTravels table ? (would be for now my understanding). You could also do that with the UI (depends for example if you want to easily apply this same change to perhaps some other existing dbs).

    So currently this SELECT statement fails because A.StartDistance and A.EndDistance are not found ?


    Monday, May 5, 2014 5:47 AM
  • User2138391294 posted


    still not working please look at my table uploaded here


    i need to add 2 more columns at the end to show StartDistance and EndDistance

    thank you

    Monday, May 5, 2014 6:55 AM
  • User753101303 posted

    Still unclear if not even more confusing.

    The result image you shown doesn't seems to match the SQL request your first shown (for example you don't have any "Group Desc" column in the request you shown us while you have one in the result header).

    I'm still unsure if the problem is that those columns are missing from the db or if you just can't show in your result page. Could you confirm the problem ?

    Start perhaps with :

     A.StartDistance As 'Start Odometer',
     A.EndDistance As 'End Odometer'
     FROM etc...

    Do you have an error ? If yes which one ? Or does it show the columns you expect ? Then add back the missing columns and test each time until you added back them all...

    Or could it be that your output table (HTML ?) is truncated and that columns past End Destination are not shown at all for some reason ?

    Keep in mind we don't have any other context  than what you told us...


    Monday, May 5, 2014 7:48 AM