add host name to my query.. simple I know sorry.

  • Ok so I've got a table on my database server called DBGrowthRAte which has the following columns...

    DBName, DBID, NumPages, OrigSize, CurSize, GrowthAmt, MetricDate

    And this populates the table..

    Insert into dbo.DBGrowthRate (dbname, DBID, NumPages, OrigSize, CurSize, GrowthAmt, MetricDate)

    (Select tds.dbname, tds.dbID, Sum(tds.Size) as NumPages,

    Convert(decimal(10,2),(((Sum(Convert(decimal(10,2),tds.Size)) * 8000)/1024)/1024)) as OrigSize,

    Convert(decimal(10,2),(((Sum(Convert(decimal(10,2),tds.Size)) * 8000)/1024)/1024)) as CurSize,

    '0.00 MB' as GrowthAmt, GetDate() as MetricDate

    from #TempDBSize tds

    where tds.dbID not in (Select Distinct DBID from DBGrowthRate

    where dbname = tds.dbid)

    Group by tds.dbid, tds.dbname)

    My issue is I need to add the hostname in there.. I'm not all that familiar yet with the dbo views in sql server and tsql.

    I was looking at db.sysservers but struggling to get the right feild into the table.

    My plan is to create a table on a central database for all the growth stats then do reporting off that table.

    Any help much appreciated. I know this is a amateur question..

    Cheers JP

  • If HOST_NAME() is what you need?

    _____________
    Code for TallyGenerator

  • so just set a verible and hard coded it?

  • Actually HOST_NAME() is a system function.

    As well as DB_NAME(), USER, SYSTEM_USER, etc.

    You can use it in any SELECT statement.

    Look for details in BOL.

    _____________
    Code for TallyGenerator

  • thats a bit easier than oracle.

    Thanks very much,

Viewing 5 posts - 1 through 4 (of 4 total)

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