Guest User

Untitled

a guest
Nov 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. create view RecordYearsTwo as
  2. select Record.RecordID, RecordValue.Value
  3. from Record join RecordValue on Record.RecordID = RecordValue.RecordID
  4. where len(RecordValue.Value) = 4
  5. and RecordValue.Value like '[16-20][0-9][0-9][0-9]%'
  6. and RecordValue.Value like '%[16-20][0-9][0-9][0-9]'
  7. and RecordValue.Value != '26 Mar 1850';
  8.  
  9. select * from Record
  10. join RecordYearsTwo on Record.RecordID = RecordYearsTwo.RecordID
  11. where cast(RecordYearsTwo.Value as int) >= 1800
  12.  
  13. Conversion failed when converting the nvarchar value '26 Mar 1850' to data type int.
  14.  
  15. create view RecordYearsTwo as
  16. select r.RecordID, v.Value
  17. from Record r
  18. join (
  19. select *
  20. from RecordValue
  21. where len(Value) = 4
  22. ) v on r.RecordID = v.RecordID
  23. where len(v.Value) = 4
  24. and v.Value like '[16-20][0-9][0-9][0-9]%'
  25. and v.Value like '%[16-20][0-9][0-9][0-9]'
Add Comment
Please, Sign In to add comment