Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 2.16 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SQL Server 2000 search keyword
  2. Id name   col1 col2 col3
  3.     1  test1  c1   c2    c3
  4.     2  test2  c4   c5    c6
  5.     3  test2  c7   c8    c9
  6.        
  7. AID  ID  Add1    add2        city        state country
  8. 1    1    Add1    a2        Newburgh     NY     US
  9. 2    1    Ad1     a3        Asheville    NC     Us
  10. 3    2    test1  test2      Catskill     NY     US
  11. 4    3    ny5    ny5        Cskill       NC     US
  12.        
  13. Id name   col1 col2 col3   AID  ID  Add1    add2        city        state country
  14.   2  test2  c4   c5    c6     3    2    test1  test2      Catskill     NY     US
  15.   3  test2  c7   c8    c9     4    3    ny5    ny5        Cskill       NC     US
  16.        
  17. CREATE PROCEDURE dbo.usp_FullTextSearch_LiveAuctions_Using_LIKE_New                                  
  18. (                                                                                                    
  19.  @Keyword varchar(5000)                                                                                      
  20. )                                                                                                  
  21. AS
  22. begin
  23. set @Keyword=replace(@Keyword,'''', '')
  24.  
  25.  SELECT                                                                            
  26.     * from                                                                              
  27.        property p inner join Address
  28.       order by
  29.    case when charindex('''+@searchkey+''',name) >0 then 1000 else 0 end desc,                  
  30.    case when charindex('''+@searchkey+''',col1) >0 then 1000 else 0 end desc,                    
  31.    case when charindex('''+@searchkey+''',col2) >0 then 1000 else 0 end desc,                    
  32.    case when charindex('''+@searchkey+''',col3) >0 then 1000 else 0 end desc,                  
  33.    case when charindex('''+@searchkey+''',Add1) >0 then 1000 else 0 end desc,    
  34.       case when charindex('''+@searchkey+''',add2) >0 then 1000 else 0 end desc,                  
  35.    case when charindex('''+@searchkey+''',city) >0 then 1000 else 0 end desc,                    
  36.    case when charindex('''+@searchkey+''',state) >0 then 1000 else 0 end desc,                    
  37.    case when charindex('''+@searchkey+''',country) >0 then 1000 else 0 end desc
  38.  
  39.  end