sql-server


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.

Related Links

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

Categories

HOME
sharepoint
swift
converter
ssas-2012
redis
openssl
webrtc
firebase-app-indexing
smartphone
ubuntu-12.04
matplotlib
search-engine
ext.net
tumblr
simpy
goutte
lotus-notes
wordpress-theming
wysiwyg
gatsby
image-recognition
dlib
local
uisplitviewcontroller
scaling
rhapsody
yeoman-generator
atlassian-plugin-sdk
zend-framework-mvc
ios10.3
excel-2010
onsen-ui
tcpclient
qsub
net-snmp
ggmap
nesc
aurelia-binding
pygooglechart
cell-array
fractals
hawtio
modulo
remote-server
hashcat
vsts-package-management
discord.net
axis-labels
nsexception
code-composer
dojox.mobile
rkt
uiviewpropertyanimator
execl
python-hypothesis
unity3d-editor
libtiff.net
gradle-script-kotlin
cleditor
backstop.js
galleriffic
audioqueue
mailcatcher
try-finally
django-filer
inotifypropertychanged
concur
aerogear
altbeacon
futuretask
manjaro
type-mismatch
bridge
web-component-tester
xaml-designer
searchkick
consensus
low-level
omnifocus
and-operator
sthttprequest
dache
svcutil.exe
roxygen
java.util.date
dllexport
threadx
mailcore
fraud-prevention
zend-lucene
pascals-triangle
qt4.6
arbor.js
bulbs
socketstream
returnurl
file-exists
hobo
testunit
getresource
code-design
asp.net-mvc-controller
swfloader
microsoft.ink
economics

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App