none
U-SQL Query data source - Execute statement

    Question

  • I would like to write query to remote Azure SQL database.

    I followed the tutorial via Query Data Source - Method 1

    I was successful to run the query from tutorial:

    @results1 =
      SELECT *
      FROM EXTERNAL MyAzureSQLDBDataSource EXECUTE @"SELECT @@SERVERNAME AS serverName, GETDATE() AS dayTime, DB_NAME() AS databaseName";

    But...

    I would like to update this query to following form:

    DECLARE @queryA string = @"SELECT @@SERVERNAME AS serverName, GETDATE() AS dayTime, DB_NAME() AS databaseName";
    
    @results2 =
      SELECT *
      FROM EXTERNAL MyAzureSQLDBDataSource EXECUTE @queryA;
    

    I got an error

    E_CSC_USER_SYNTAXERROR: syntax error. Expected one of: string-literal

    Any idea why I cannot use query stored in string value?

    In real query I need to dynamically create query based on parameters in where statement.

    Thank you in advance

    Friday, March 3, 2017 3:05 PM

All replies

  • Thanks for reaching out.

    This question looks like a duplicate of http://stackoverflow.com/questions/42579921/u-sql-query-data-source which has been answered in Stackoverflow?

    Thank you,

    Guy

    Monday, March 6, 2017 6:18 PM