开发者

Can I create a 'reserved word' for a commonly used string in an SQL statement?

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 somethi开发者_如何学Cng 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_Default which coerces collation to the current DB?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜