SQL QUERY RESULTS IN FORMATTED TABLE

  • Hi Guys,

    You've always come up trumps before so i'm hoping you're going to be able to help me this time.

    Not sure if i'm out of my depth here or not so here goes.....

    CREATE TABLE [dbo].[SCCall] (

    [Call_Num] [int] NOT NULL,

    [Call_RDate] [datetime] NOT NULL

    What i would like to do is query the above table and have the results displayed in a table somehow.

    I would also like to colour code the rows of the table based on the value of Call_RDate compared to GetDate() eg

    if Call_RDate is one hour after GetDate() then have the row red, two hours them orange, three then green

    I would also like the results to auto update / refresh at a time interval of my choosing if poss...

    If anyone has any ideas i'd be really gratefull for your help, also please let me know if you want any more info as even I don't understand myself sometimes!

    Thanks in advance

    Sam Marsden

  • CREATE TABLE [dbo].[SCCall] (

    [Call_Num] [int] NOT NULL,

    [Call_RDate] [datetime] NOT NULL

    ....

    ======================================

    SELECT CASE WHEN

    DATEDIFF(HOUR, GetDate(), [Call_RDate] )=1 THEN

    '

    '

    ELSE

    CASE WHEN

    DATEDIFF(HOUR, GetDate(), [Call_RDate] )=2 THEN

    ' '

    END

    END,

    [dbo].[SCCall].*

    FROM [dbo].[SCCall];

    Or I did not understand the task correctly? 🙂

    -------------------

    StarWind Software developer ( http://www.starwindsoftware.com )

  • The client has to handle the color coding. It's not a SQL function.

  • ah thats makes sense, by chance does anyone have a sample of how to run a sql query in HTML and format the results into a table?

    I haven't really got any idea of where to start....

    Sam Marsden

  • Try here

  • lol tried that but could not really find what i am after - everything seems to be centered around MySQL and PHP, both of which i have no experience using....

    Sam Marsden

  • So, what do you have experience in? C#, VB, ASP, ASP.NET, Reporting Services?

    You'll need to write some server side code whatever.

    There are many possible ways to do this but it depends on the environment in which you are working.

  • To be perfectly honest not a lot - i am a self taught accidental IT bloke / DBA, i am good with crystal reports (of course no use here)

    To be honest i am after something that is similar to the attachment below but configurable as per my specification whereas at the moment its the old "like what you're given or else" scenario.

    It may be that this is completely beyond me but thought i'd at least investigate...

    Sam Marsden

  • Sam,

    Since you're already using SQL Server and you have Crystal experience I'd suggest you give Reporting Services a go since it comes for free with SQL.

    Try starting here, and here if you're using SQL Express.

  • Thanks Nigel,

    As it happens (for some reason) the version of Express that i have has not got the reporting services so i didn't even think of it - i'm going to download "Microsoft® SQL Server® 2008 Express with Advanced Services" now and give it a whirl!

    Thanks

    Sam Marsden

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply