I did not bother to name this...

From Gruff Parakeet, 1 Week ago, written in Plain Text, viewed 16 times.
URL http://codebin.org/view/f07c8fa9 Embed
Download Paste or View Raw
  1. Declare @sSearchText Varchar(50) = 'Seizures'
  2.  
  3. Select c.fCAccountID, c.fCAccountNo, c.fCAccountNoSub,
  4. Case When c.fCAccountNoSub > 0 Then '   ' + c.fCAccountName Else c.fCAccountName End AccountName,
  5. t.fName AccountType, Case When c.fCAccountNoSub > 0 Then m.fCAccountName + ' - ' + c.fCAccountName Else c.fCAccountName End AccountUse
  6. From dbo.actblCAccounts c With (Nolock)
  7. Inner Join dbo.actblCAccounts m With (Nolock) On c.fCAccountNo = m.fCAccountNo And m.fCAccountNoSub = 0
  8. Left Join dbo.systblConst2 t With (Nolock) On c.fCAccountFS = t.fKey2 And t.fKey1 = 2371
  9. Left Join dbo.actblCAccounts s With (Nolock) On c.fCAccountID = s.fCAccountID And s.fDisabled = 0 And s.fDelete = 0
  10. Where c.fDisabled = 0 and c.fDelete = 0
  11. --And m.fCAccountNo < 2000
  12. --And m.fCAccountNo >= 2000 and m.fCAccountNo < 3000
  13. --And m.fCAccountNo >= 3000
  14. --And m.fCAccountID = 2211
  15. And (c.fCAccountName Like '%' + @sSearchText + '%' Or (c.fCAccountNoSub = 0 and c.fCAccountNo In
  16.         (Select Distinct fCAccountNo From dbo.actblCAccounts With (Nolock)
  17.         Where fCAccountName like '%' + @sSearchText + '%' And fDisabled = 0 And fDelete = 0)))

Reply to "I did not bother to name this..."

Here you can reply to the paste above