April 12, 2006 at 5:01 am
SELECT Institution, Period
FROM Transactions
WHERE (0 = 1)
Could someone please assist? What does the above where clause mean?
April 12, 2006 at 7:01 am
It pretty much should negate any return set. This is because 0 will never equal 1. Similar to if you were to put WHERE 1=1 then it will always return all records since your are guaranteed that 1 equals 1.
April 12, 2006 at 7:37 am
Some development and front-end tools will generate a:
select * from <object> where 0 = 1
for every table and view in a database as a way of cataloging the columns in all the tables and views in a database.
I sometimes do it myself as part of the process of editing a query.
The 0 = 1 guarantees no rows will be returned.
April 12, 2006 at 7:49 am
Thanks for the help!!
April 12, 2006 at 8:19 am
This will achieve the same without the WHERE clause
SET FMTONLY ON
SELECT Institution, Period FROM Transactions
Far away is close at hand in the images of elsewhere.
Anon.
April 13, 2006 at 9:55 am
I've used it many times if I want a quick and easy way to copy the schema of one table to one on another server. Try
select * from RemoteServer.DB.owner.table1 into LocalTable where 1=0
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply