ADF Lookup query create schema and select

Kiran Rredy Addelle 1 Reputation point
2021-12-13T08:30:08.707+00:00

I am trying to run a create Shema/table query in the ADF lookup activity, with a dummy select in the end.

CREATE SCHEMA [schemax] AUTHORIZATION [auth1]; SELECT 0 AS dummyValue

but I got the below error

A database operation failed with the following error: 'Parse error at line: 2, column: 1: Incorrect syntax near 'SELECT'.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Parse error at line: 2, column: 1: Incorrect syntax near 'SELECT'.,Source=.Net SqlClient Data Provider,SqlErrorNumber=103010,Class=16,ErrorCode=-2146232060,State=1

157132-screenshot-2021-12-13-at-074444.png
I was able to run a similar query without SELECT query in the end but got another error mandating lookup must return a value.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ShaikMaheer-MSFT 38,631 Reputation points Microsoft Employee Moderator
    2021-12-13T14:11:48.603+00:00

    Hi @Kiran Rredy Addelle ,

    Thank you for posting query in Microsoft Q&A Platform.

    I tried executing similar query my end its working fine. Please check below screenshot.

    Kindly try to have line break between your main query and dummy select query as I did in below screenshot.

    157089-image.png

    Hope this will help. Please let us know if any further queries. Thank you.

    ---------------------

    Please consider hitting Accept Answer button. Accepted answers helps community as well.


  2. ShaikMaheer-MSFT 38,631 Reputation points Microsoft Employee Moderator
    2021-12-20T06:26:14.573+00:00

    Hi @Kiran Rredy Addelle ,

    Yes you are right. In case of schema for direct query its not working. But below is the work around.

    Use dynamic sql query to do the same task.

    Below is the implementation which i tried and it worked.
    158849-image.png

    Hope this will help. Please let me know if any further queries.

    ------------------

    Please consider hitting Accept Answer button. Accepted answers helps community as well.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.