Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to return an empty result
Message
 
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00810496
Message ID:
00810500
Views:
24
This message has been marked as the solution to the initial question of the thread.
Hi Roy,

You can do it in one of two ways. You can use SQL Server specific command SET FMTONLY or WHERE condition 1=2. Neither would consume much of resources regardless of # of records in a table.
lcSql = "SET FMTONLY ON SELECT * FROM customer SET FMTONLY OFF"
lnResult = SqlExec(lnConn, lcSql)
-- or
SELECT * FROM customer WHERE 1=2
lnResult = SqlExec(lnConn, lcSql)
The second one should work for any backend but may not be as efficient as on SQL Server.

>Hi,
>
>I want to do a select statement to return an empty result without consuming resources.
>
>Let's say I just want to bring an empty result from the customers table, I could do "SELECT * FROM customer WHERE customer_id = -8994849" something like this but if the table is huge I imagine it will consume resources.
>
>Any way just to bring an empty result set without consuming resources?
>
>Thanks
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform