This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Updating captions with comments

We are setting up a new SLX and would like 1000+ node names (captions) to include a comment that is friendlier than the hostname.  This request is similar to .  However, we have a custom property called Comments that we can import into the db.  Can you modify the SQL from post #40601 so that instead of checking and duplicating the SysName, it will append the Comments to the existing Caption for all nodes where the Caption does not already contain the Comments and Comments is not blank.  Thus, if a Comment exists, the Caption would be modified to something like "host.xyz.com - Comment Text".

Would be great if you could tell me how to schedule this update to run once a day also.

Thanks,

Matt

  • <FROM SEDMO's original SQL>

    SELECT Caption, SysName, IP_Address FROM Nodes

    WHERE((Caption <> SysName) AND (SysName <> ''))

    ORDER BY Caption

     This query will update the node caption field to whatever value is currently in the sysname field.

    update nodes

    set caption = sysname + ' - ' + Comments

    where caption in (SELECT Caption FROM Nodes WHERE ((Nodes.Caption <> Nodes.SysName) AND (Nodes.SysName <> '') AND (Nodes.Caption NOT LIKE Nodes.Comments) AND (Nodes.Comment <> '')))

     

    Syntax on the "NOT LIKE" may be a bit off but I think that is the general format you'll need.
    to make this run every day, simply schedule a SQL Server Agent Job that runs that code every day or create a stored procedure out of this code that runs every day.

    Good luck and hope that helps

  • I had to modify the above a bit (removing the Caption <> SysName comparisons).  What I implemented was the following and it appears to be working fine.  Thanks for the help.

    Show entries to update...

    SELECT Caption, SysName, Comments, IP_Address FROM Nodes
    WHERE((Caption NOT LIKE Comments) AND (SysName <> '') AND (Comments <> ''))
    ORDER BY Caption

    Update caption field where needed

    update nodes
    set caption = sysname + ' - ' + comments
    where caption in (SELECT Caption FROM Nodes WHERE ((Nodes.SysName <> '') AND (Nodes.Caption NOT LIKE Nodes.Comments) AND (Nodes.Comments <> '')))

  • Hello boss
    where can I type this scrypt ?