Tuesday, April 2, 2019
Full Text Search for Business and Place Finder
Working on a website called Near Me and creating full text search index which allow searches by distance using latitude and longitude. Similar to Google Places but based on distance rather than rating.
It is interesting how SQL Server is able to handle spatial indexes with full text search but having millions of records in the table does not make it easy so i decided to give Lucene a try, but Lucene.Net is very slow unless you keep the data in memory.
Thursday, January 21, 2010
latest project on pets dogs and puppies
The learning part about this project while working on puppies for sale website was the amount of text stored in the database. The huge amount of text data related to breed information facts and description. The existing developer who initially designed the database used varchar MAX for almost all the fields. Now the main part for me was to track all the data and see if i can fix some of this cowboy style database design.
Looks like the client is happy and all of the sudden site performance have increased, seperation of data and making table size small can really help which many front end developers does not understand specially when every query is select * from table. :)
Thursday, April 9, 2009
MySQL Hosting
I will recomment www.mysqlhosting.us for mysql hosting, only problem with them is that they offer windows based mysql hosting and no web hosting. The biggest benefit is free mysql database administration services.
Tuesday, April 7, 2009
SQL Server Hosting
In my recent research i found one sql server hosting provider company which also provides database administration services including design, monitoring and performance tunning. They do not support all features but hardly any small to medium size business is using all sql server features.
Monday, October 27, 2008
social networking and dating
All these sites are collecting more data then any other corporate collects on it's customers. The site My Life, Match.com, Arab Dating, eharmony and Indian Pakistani Dating and other social networking sites owned by large companies like google the orkut.
Is there are any end to it, these sites are from dating to friendship to social networking like each and every thing you can do after signup. :)
the fun of horoscopes
My experience did change my mind a little it, the dates were very close. Now i wonder how this thing work. But hey it was fun and i will say not a waste of money at all. :)
Monday, December 10, 2007
Youtube and SQL Server
Sunday, December 2, 2007
Real Estate Search Engine Optimization
Visit it online real estate search engine optimization its on squidoo
If you wana learn more about SEO than there are some other sites as well to learn about search engine optimization.
Saturday, December 1, 2007
VMWare Training
Saturday, November 17, 2007
Real Estate SEO - Real Estate Search Engine Optimization
The next i found website4me.com real estate seo a old company famous for web templates not on first page for many keywords but excuse was too busy to work on there own website. Any way i again thought to give them a try because of 100% money back guarantee and after 2 months my site first started poping up on 4th page then 2nd and now on first acctually at 8th search result. Very impressive the art of search engine promotion.
I liked Florida Search Engine Optimization by http://www.website4me.com/ Try them for few months, results were very good.
Wednesday, August 22, 2007
Check if file exists using sql
-- using the scripting object
declare @Path varchar(128) ,
@FileName varchar(128)
select @Path = 'C:\' ,
@FileName = 'myfile.txt'
declare @objFSys int
declare @i int
declare @File varchar(1000)
select @File = @Path + @FileName
exec sp_OACreate 'Scripting.FileSystemObject', @objFSys out
exec sp_OAMethod @objFSys, 'FileExists', @i out, @File
if @i = 1
print 'exists'
else
print 'not exists'
exec sp_OADestroy @objFSys
-- using xp_cmdshell
declare @Path varchar(128) ,
@FileName varchar(128)
select @Path = 'C:\' ,
@FileName = 'myfile.txt'
declare @cmd varchar(1000)
create table #a(s varchar(1000))
select @cmd = 'dir /B ' + @Path + @FileName
insert #a exec master..xp_cmdshell @cmd
if exists (select * from #a where s = @FileName)
print 'exists'
else
print 'not exists'
drop table #a
-- using xp_fileexists
declare @Path varchar(128) ,
@FileName varchar(128)
select @Path = 'C:\' ,
@FileName = 'myfile.txt'
declare @i int
declare @File varchar(1000)
select @File = @Path + @FileName
exec master..xp_fileexist @File, @i out
if @i = 1
print 'exists'
else
print 'not exists'
Friday, August 10, 2007
Service Oriented Architecture - SOA Definition
Easy to the point Definition:
The Service Oriented Architecture (SOA) is a design philosophy which defines how a solution should be build.
SOA design approach allow organizations with multiple technologies and platforms to build solutions which are re-useable and accessible across all systems without rewriting of code. All business technologies and functions are treated as services, these services are build to last for long time but service configurations are build for change. This approach creates a loosely-coupled systems which can be changed without spending more money. A loosely coupled system allow business processes to change more quickly as they are not dependent on underlying IT infrastructure.
A service oriented application means writing a highly dynamic, collaborative, stable, dependable application. A application which can act as service to all other business processes/systems without rewriting. The service should not be written for any specific system it should be consumable by any system. The service should use standard protocols (SOAP, XML) to exchange messages between each other. The service should be re-useable, work independently and must be manageable.
Web Services, WSDL, Remote Scripting are common examples of SOA.
Kill SQL Server connections by username
SET NOCOUNT ON
DECLARE @UName varchar(50)
DECLARE @spidstr varchar(8000)
DECLARE @ConnKilled smallint
SET @ConnKilled=0
SET @spidstr = ''
Set @UName = 'USERNAME'
SELECT @spidstr=coalesce(@spidstr,',' )+'kill '+convert(varchar, spid)+ '; '
FROM master..sysprocesses WHERE loginame=@UName
IF LEN(@spidstr) > 0
BEGIN
EXEC(@spidstr)
SELECT @ConnKilled = COUNT(1)
FROM master..sysprocesses WHERE loginame=@UName
END
Thursday, August 9, 2007
SOA - Service Oriented Architecture
One group of people gets confused that SOA or service Oriented Architecture is some kind of software which we can buy get training on it and boom its all done. The other group takes it as web service or re-useable componenet like COM objects, lot of questions were raised that we are still using it, but i guess hardly any one knew what is service oriented architecture of application is the IBM sales personals tried to define it in easy way that its the future and all enterprise business are using it.
SOA is a design concept for businesses in which all service providers (computer systems) use common standard protocol to talk to each other. The protocol which the sytems use is called SOAP very much like web services a common example i have seen is implemented by Paypal to accepting credits cards on merchant own websites.
I am still researching in more depth on SOA i guess i have used it in many applications with out knowing. I will write on it more later.
Thursday, August 2, 2007
Kill all connections to SQL Server database using a script, kill sql server connections
SET NOCOUNT ON
DECLARE @DBName varchar(50)
DECLARE @spidstr varchar(8000)
DECLARE @ConnKilled smallint
SET @ConnKilled=0
SET @spidstr = ''
Set @DBName = 'DATABASE_NAME'
IF db_id(@DBName) < 4
BEGIN
PRINT 'Connections to system databases cannot be killed'
RETURN
END
SELECT @spidstr=coalesce(@spidstr,',' )+'kill '+convert(varchar, spid)+ '; '
FROM master..sysprocesses WHERE dbid=db_id(@DBName)
IF LEN(@spidstr) > 0
BEGIN
EXEC(@spidstr)
SELECT @ConnKilled = COUNT(1)
FROM master..sysprocesses WHERE dbid=db_id(@DBName)
END
The above script can be used in SQL Query Analyzer or in SQL Server Agent Job.
Note: The job can not kill its own connection, if you are using SQL Sever Query analyzer to kill connections to the database then try to issue a use statement against any other database on top of the query, else you will receive an error.
USE master
GO
Its always a good idea to notify users before killing the connection to database using a script, by restarting the computer or any other way.
DONT KILL CONNECTIONS LIKE THIS :
Wrong way of killing the connections to database is by taking out the network wire, or by disabling network devices.
Monday, July 30, 2007
Fix Database Users Logins in SQL Server
Step 1.
Backup the production database.
Step 2.
Copy the database backup from production server to development or QA.
Step 3.
Kill all the connections in SQL Server. I use this Kill SQL Connection script.
Step 4.
Restore the database on development or QA SQL Server.
Step 5.
Fix Logins, remap them other wise users will not be able to login.
If its a development box then there are few more steps. I have to script out the new objects to make sure i am not going to overwrite any development work including sql server stored procedures and view etc.
Here is the script i use.
USE DATABASE_NAME
GO
DECLARE
@User_Name varchar(255),
@Adhoc_SQL nvarchar(2000)
DECLARE User_Cursor CURSOR FOR
select
sysusers.[name]
from
sysusers
JOIN
master..syslogins sl
ON
sysusers.[name] = sl.[name]
where
sysusers.issqluser = 1
and
(
sysusers.sid is not null
and
sysusers.sid <> 0x0
)
and
suser_sname(sysusers.sid) is null
AND
sysusers.[name] <> 'dbo'
OPEN User_Cursor
FETCH NEXT FROM
User_Cursor
INTO
@User_Name
WHILE @@FETCH_STATUS = 0
BEGIN
SET @Adhoc_SQL = 'EXEC sp_change_users_login '+
'@Action = ''Auto_Fix'', ' +
'@UserNamePattern = ''' + @User_Name + ''''
print @Adhoc_SQL
EXEC sp_ExecuteSQL @Adhoc_SQL
FETCH NEXT FROM
User_Cursor
INTO
@User_Name
END
CLOSE User_Cursor
DEALLOCATE User_Cursor
Make sure you replace the database name in the script. You can also run the above SQL Script in Query Analyzer of SQL Server.
Saturday, July 28, 2007
SQL Server 2008 Release
I dont know honestly, its my first blog. If you dont know which version of SQL Server you are using, type this command in Query Analyzer
SQL Command : SELECT @@VERSION