26 May 2012

SQL Server Where 1=0

SQL Server Where 1=0

Used in both static and dynamic query.

WHERE 1 = 0 (or any always false condition) 

It is used to create a table of identical structure, sans data: In the below query empty table is created in the same structure.
SELECT * INTO dbo.NewTable FROM dbo.SomeTable WHERE 0 = 1;

No comments:

Post a Comment

Comments Welcome

Implementing OAuth validation in a Web API

 I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...