Monday, April 28, 2008

on Google "time-limited" searches

Maybe you already know about this, I discovered this only today (thanks Claudio).

Try this: go to google.com, perform a search, then in the address bar add to the querystring the following:

&as_qdr=d

you will obtain the same page, but with a new dropdown list right before the "Search" button. With this, you have the chance to restrict the time span of your query!

For example, you can have Google return results only from the last past week!!!

Now this is a great idea, for some kind of searches. 

How to capture the time

Friday, April 18, 2008

A couple of Sql Server (useful) things

1) Changing sa password

A couple of days ago I discovered with horror that I forgot my "sa" password, on my sql 2005 local instance.

To solve this, googling around I found this couple of methods:

USE MASTER

ALTER LOGIN [sa] WITH PASSWORD=N'new_password'

or from a command prompt

    OSQL -S <server_name> -E
    1> EXEC sp_password NULL, 'new_password', 'sa'
    2> GO

2) Transact sql Split function

I needed a split function, and I fpound this good forum discussion exactly on this topic:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

I used this one:

CREATE FUNCTION dbo.Split
(
@RowData nvarchar(2000),
@SplitOn nvarchar(5)

RETURNS @RtnValue table
(
Id int identity(1,1),
Data nvarchar(100)
)
AS 
BEGIN
Declare @Cnt int
Set @Cnt = 1

While (Charindex(@SplitOn,@RowData)>0)
Begin
  Insert Into @RtnValue (data)
  Select
   Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))

  Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))
  Set @Cnt = @Cnt + 1
End
 
Insert Into @RtnValue (data)
Select Data = ltrim(rtrim(@RowData))

Return
END