Insert into table

  • I am trying to insert the resulst from the following script into a table called License_Audit. Not sure how to go about it. Any help will be greatly appreciated.

    SELECT = COUNT(USER_ID) AS LICENSE_COUNT

    FROM VMFG.dbo.LOGINS

    WHERE PROGRAM_ID = 'MENU'

  • if the table already exists:

    INSERT INTO License_Audit(LicenseType,LICENSECOUNT,AUDITDATE)

    SELECT 'MENU',COUNT(USER_ID) AS LICENSE_COUNT ,getdate()

    FROM VMFG.dbo.LOGINS

    WHERE PROGRAM_ID = 'MENU'

    to create the table on the fly:

    SELECT 'MENU' AS LicenseType,COUNT(USER_ID) AS LICENSE_COUNT ,getdate() AS AUDITDATE

    INTO License_Audit

    FROM VMFG.dbo.LOGINS

    WHERE PROGRAM_ID = 'MENU'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • The script worked great. I tried setting up a job to run this script, but it fails each time. Do I need to change something in the script in order for it to execute successfully in job mode?

    INSERT INTO License_Audit(LicenseType,LICENSE_COUNT,AUDITDATE)

    SELECT 'MENU',COUNT(USER_ID) AS LICENSE_COUNT ,getdate()

    FROM VMFG.dbo.LOGINS

    WHERE PROGRAM_ID = 'MENU'

  • I figured it out. Thanks for all the help. It is greatly appreciated.

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

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