[SalesForce] Errors: Incorrect syntax near ‘LIMIT’

I am trying to query only 10 records and using LIMIT in query, but it is giving me the following error :

An error occurred while checking the query syntax. Errors: Incorrect
syntax near 'LIMIT'.

Following is my query:

SELECT SubscriberKey, EmailAddress 
    FROM MASTER_IMPORT
        WHERE EmailAddress LIKE "%gmail.com" LIMIT 10

Anything that I'm doing wrong here?

Best Answer

SFMC uses T-SQL syntax, so you need to rewrite your query using the TOP expression instead of LIMIT.

SELECT TOP(10) SubscriberKey, EmailAddress 
FROM MASTER_IMPORT
WHERE EmailAddress LIKE "%gmail.com"

Also refer to official documentation for more details on the TOP expression:

Limits the rows returned in a query result set to a specified number of rows or percentage of rows.

In a SELECT statement, always use an ORDER BY clause with the TOP clause. This is the only way to predictably indicate which rows are affected by TOP.