This is not a calculation or a function, it is simply a command I have to add often which is difficult to remember.
I am often running queries on data across two databases (one old, one new) so I have to add “collate SQL_Latin1_General_CP1_CI_AS” wherever values of one are being compared with values of the other.
For example…
...where db1.transactions.accountnumber = db2.clients.accountnumber collate SQL_Latin1_General_CP1_CI_AS
Is there a way to create something like a ‘reserved word’ for this, so that I could type something like the following…
where db1.transactions.accountnumber = db2.clients.accountnumber coll
where ‘coll’ is the replacement for ‘collate SQL_Latin1_General_CP1_CI_AS’
SSMS tools pack (free) has snippets which may do what you want.
We use SQL prompt too which has the same.
FYI: Have you considered
COLLATE Database_Defaultwhich coerces collation to the current DB?