code_junkie

Indexing URL's in SQL Server 2005

Nov 11th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. CREATE FUNCTION GetUrlId (@Url nvarchar(400))
  2. RETURNS int
  3. AS BEGIN
  4. DECLARE @UrlId int
  5. SELECT @UrlId = Id FROM Url WHERE Url = @Url
  6. RETURN @UrlId
  7. END
  8.  
  9. INSERT INTO
  10. UrlHistory(UrlId, Visited, RemoteIp)
  11. VALUES
  12. (dbo.GetUrlId('http://www.stackoverflow.com/'), @Visited, @RemoteIp)
  13.  
  14. stackoverflow.com -> com.stackoverflow
  15. blog.stackoverflow.com -> com.stackoverflow.blog
Add Comment
Please, Sign In to add comment