Create custom predicate function in T-SQL?
Is it possible to define a custom predicate in T-SQL? So that for instance I can write: SELECT a,b,c FROM MyTable WHERE dbo.myCustomPredicate(a) An easy workaround is to create a scalar-valued function dbo.myCustomPredicate which returns a BIT, and change the WHERE clause to WHERE dbo.myCustomPredicate(a)=1 Just curious if it's possible to avoid the "=1".
No this isn't possible. SQL Server doesn't support the ANSI SQL boolean datatype. You don't say what the implementation of dbo.myCustomPredicate is but quite likely WHERE dbo.myCustomPredicate(a)=1 should be avoided as well on the grounds of both Sargability and general performance of Scalar UDFs in SQL Server.
Sql query including a unicode character returns wrong result
How do I validate SQL tables data using a schema
C# SQL connection string best practice
SQL Server combine rows into single column
Sum monthly amount and output for last day of month
SSRS referring to Database Project in the solution
Error when trying to execute stored procedure
Get actual database size in SQL Server 2012 in GB?
Simple results list from SQL Server stored procedure using Codefluent
SQL Report Error - [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name
How to get distinct column in SQL Server?
Powershell returns negative exit code while script results are correct
Spark program cannot open SQL Server context?
Sql server error 916 when using a trigger that selects data in other database (outside sql server only)
Convert rows from a NoSQL schema to columns in SQL Server
Unable to pass a variable value to a stored procedure in ssis