Previous icon

Next icon

Inserting an existing SQL statement

Sometimes you may have a query that has already been perfected on another system. You can either:

In this example, we will follow the process when someone from the Synergetic Management Systems team emails you a SQL statement. This Structured Query Language (SQL) statement is written in a language that database management systems can interpret. Synergetic uses the Microsoft SQL Server database management system.

In this example, we will use a simple SQL statement that will report and total all religion codes at your organisation:

Query

SELECT vStudents.StudentCampus, vStudents.StudentReligionCode, Count(*)

FROM Synergetic.dbo.vStudents vStudents

WHERE (vStudents.CurrentSemesterOnlyFlag=1)

GROUP BY vStudents.StudentCampus, vStudents.StudentReligionCode

ORDER BY vStudents.StudentCampus, vStudents.StudentReligionCode

This statement selects campus, religion code and places a count field on your spreadsheet. The fields:

To paste in a SQL statement that has been sent to you by email:

  1. Start Microsoft Excel.
  2. Select:

    Microsoft Excel - New Database Query

    The Choose Data Source window is displayed.

    Choose Data Source window

  3. Select the Synergetic database.
  4. Clear the Use the Query Wizard to create/edit queries field.

    Choose Data Source window (clear flag)

  5. Click OK button.

    The SQL Server Login window is displayed.

    Microsoft Query - SQL Server Login window

  6. Type in your username and password.

    Note: This is your usual Synergetic username and password.

  7. Click OK button.

    The Add Tables window is displayed.

    Microsoft Query - Add Tables window

  8. Click Close button.
  9. Click SQL button.

    The SQL window is displayed.

    SQL window (MS Query)

  10. Switch to the application with the SQL statement, such as an email message.
  11. Select the SQL statement text and press Ctrl + C.

    Microsoft Outlook (SQL statement)

    The SQL statement is copied to the clipboard.

  12. Switch back to the SQL window.
  13. Press Ctrl + V.

    The SQL statement is pasted into the SQL window.

    SQL window

  14. Click OK button.

    The Microsoft Query window is updated with the new criteria and the records are displayed.

  15. You can:

Last modified: 26/05/2017 5:15:04 PM

See Also

Extracting data from the Synergetic database

What's new to Extracting data

Synergetic views

Extracting data using the Microsoft Query wizard

Editing a Microsoft Query using the wizard

Common duplication problems

Extracting data using Microsoft Query directly

Advanced Microsoft Query and SQL examples

Extracting data for Crystal Reports

Using stored procedures to retrieve Synergetic data

© 2017 Synergetic Management Systems. Published 20 July 2017.

Top of page