nyk0r

Cast direction

Dec 7th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.35 KB | None | 0 0
  1. -- The cast direction is towards number.
  2.  
  3. -- 1
  4. declare @table table (
  5.     val varchar(max)
  6. )
  7.  
  8. insert into @table (val)
  9. values ('1'), ('2'), ('a')
  10.  
  11. select *
  12. from @table
  13. where val between 1 and 2
  14.  
  15. -- 2
  16. declare @table table (
  17.     val int
  18. )
  19.  
  20. insert into @table (val)
  21. values (1), (2), (3)
  22.  
  23. select *
  24. from @table
  25. where val between '1' and '2'
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment