Excel Spreadsheet Automation with the QUERY Formula



Pull data, automate spreadsheets, and more with the QUERY formula.

The CData Excel Add-In for Sybase provides formulas that can edit, save, and delete Sybase data. The following three steps show how you can automate the following task: Search Sybase data for a user-specified value and then organize the results into an Excel spreadsheet.

The syntax of the CDATAQUERY formula is the following: =CDATAQUERY(Query, [Connection], [Parameters], [ResultLocation]);

This formula requires three inputs:

  • Query: The declaration of the Sybase data records you want to retrieve or the modifications to be made, written in standard SQL.
  • Connection: Either the connection name, such as SybaseConnection1, or a connection string. The connection string consists of the required properties for connecting to Sybase data, separated by semicolons.

    To connect to Sybase, specify the following connection properties:

    • Server: Set this to the name or network address of the Sybase database instance.
    • Database: Set this to the name of the Sybase database running on the specified Server.

    Optionally, you can also secure your connections with TLS/SSL by setting UseSSL to true.

    Sybase supports several methods for authentication including Password and Kerberos.

    Connect Using Password Authentication

    Set the AuthScheme to Password and set the following connection properties to use Sybase authentication.

    • User: Set this to the username of the authenticating Sybase user.
    • Password: Set this to the username of the authenticating Sybase user.

    Connect using LDAP Authentication

    To connect with LDAP authentication, you will need to configure Sybase server-side to use the LDAP authentication mechanism.

    After configuring Sybase for LDAP, you can connect using the same credentials as Password authentication.

    Connect Using Kerberos Authentication

    To leverage Kerberos authentication, begin by enabling it setting AuthScheme to Kerberos.

See the Using Kerberos section in the Help documentation for more information on using Kerberos authentication.

You can find an example connection string below: Server=MyServer;Port=MyPort;User=SampleUser;Password=SamplePassword;Database=MyDB;Kerberos=true;KerberosKDC=MyKDC;KerberosRealm=MYREALM.COM;KerberosSPN=server-name

  • ResultLocation: The cell that the output of results should start from.

    Pass Spreadsheet Cells as Inputs to the Query

    The procedure below results in a spreadsheet that organizes all the formula inputs in the first column.

    1. Define cells for the formula inputs. In addition to the connection inputs, add another input to define a criterion for a filter to be used to search Sybase data, such as ProductName.
    2. In another cell, write the formula, referencing the cell values from the user input cells defined above. Single quotes are used to enclose values such as addresses that may contain spaces.
    3. =CDATAQUERY("SELECT * FROM Products WHERE ProductName = '"&B6&"'","User="&B1&";Password="&B2&";Server="&B3&";Database="&B4&";Charset="&B5&";Provider=Sybase",B7)
    4. Change the filter to change the data.
  • Ready to get started?

    Download a free trial of the Excel Add-In for Sybase to get started:

     Download Now

    Learn more:

    SAP Sybase Icon Excel Add-In for Sybase

    The Sybase Excel Add-In is a powerful tool that allows you to connect with live data from Sybase databases, directly from Microsoft Excel.

    Use Excel to read, write, and update Sybase. Perfect for mass imports / exports / updates, data cleansing & de-duplication, Excel based data analysis, and more!