I was wondering if it’s possible to run a script for multiple Clients where I can add extra where clauses when I’m running for the specified Client, without having to rewrite the basic script multiple times?
Eg. basic script is
SELECT Status, count(distinct T1.AccountNo)
FROM Orders (nolock), Accounts (NOLOCK)
WHERE Orders.AccountNo = Accounts .AccountNo
AND date between '1 Oct 2011' and '31 Oct 2011'
GROUP BY Status
But when I run for Client A I would like to include the extra criteria
AND Accounts.Role IN ('User','Admin')
AND Accounts.Active= 'Y'
On SQL Server, you can use HOST_NAME() as follows: