Skip to main content

Posts

Showing posts from January, 2007

Are you looking for loans in Chennai?

My sister (Sumathi Maraimallai) was working with Citi Shelters for approx 3 years as a Manager for Personal Loans section. After that she moved to another company for better career growth and now she has become a DSA (Direct selling agent) of few MNC banks along with her friend Mr. Roshan (who was also working previously with Citi Shelters for approx 6 years). On the other day she was asking for some referals. I said, I don't want to put people in trouble by giving away their mobile numbers :) Rather I thought I would put a word across here for the benefit of others. If at all you are looking for Personal loans then you might want to make a note of their contact numbers [ Feel free to refer my name so that they would realize that I am also capable of giving them business lol ]: Mobile - 9841283226 Land Line - 664561901 / 02 /03 E–Mail : corporateloans (at) airtelbroadband.in Couple of questions which I thought people would ask by default: 1. What is the duration for getting a loa

Removing unwanted spaces within a string ...

Removing leading and trailling spaces is pretty easy. All you need to do is make use of Ltrim and Rtrim function respectively. But there are times when you want to remove unwanted spaces within a string. Check out the below code snippet to know how to do it. --Declaration and Initialization Declare @strValue varchar(50) Set @strValue = ' I Love you ! ' -- Here between each word leave as many spaces as you want. --Remove the leading and trailing spaces Set @strValue = Rtrim(Ltrim(@strValue)) --Loop through and remove more than one spaces to single space. While CharIndex(' ',@strValue)>0 Select @strValue = Replace(@strValue, ' ', ' ') --Final output :) Select @strValue

An error has occurred while establishing a connection to the server.

Error Description :: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Solution 1: Go to, Start >> Programs >> Microsoft SQL Server 2005 >> Configuration Tools >> SQL Server 2005 Surface Area Configuration >> Surface Area Configuration for Services and connections. Within this check whether "Local and remote connections" is choosen. If not choose it :) Solution 2: Check this URL http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=192622&SiteID=1 :) Technorati tags: SQL Server 2005

Why isn’t there any official message from Microsoft?

Microsoft announced a “ BlogStar ” contest last year and the winners were announced in the first week of November 2006. How do I know that I am one among the winners? On November 5 or 6th I got a call from one Ms. Bharathi claiming to be working in Microsoft. The number from which she called is 91-80-65605725. She said that I have won a prize and needed my size and full contact address to ship a jerkin. As the line wasn't clear I couldn't hear properly for what exactly is this gift for? But at that time Blogstar was the only Microsoft competition I was participating so I presumed it to be that. So, you got a call from Microsoft employee and hope you have received your prize as well! What else are you asking for? Excuse me :) As the female's communication was not that professional I thought its some spam caller and asked her to mail me the reason for requesting my contact address so that I can communicate my address back to her official ID. That said, it’s almost two months

List tables that doesn't participate in any relationships

This query returns those tables which satisfy the below two conditions: 1. Tables that do not contain any Foreign Key referencing other tables. 2. Tables that are not referenced by other tables using foreign key constraints. Solution: Till SQL Server 2000 days we used to write the below scripts [This still works with SQL Server 2005 also]. Select [name] as "Orphan Tables" from SysObjects where xtype='U' and id not in ( Select fkeyID from SysForeignKeys union Select rkeyID from SysForeignKeys ) Solution which works only with SQL Server 2005: Method 1: Select [name] as "Orphan Tables" from Sys.Tables where object_id not in ( Select parent_object_id from Sys.Foreign_Keys union Select referenced_object_id from Sys.Foreign_Keys ) Method 2: Select ST.[Name] as "Orphan Tables" from Sys.Foreign_Keys as SFK Right Join Sys.Tables as ST On ST.object_id = SFK.parent_object_id Or ST.object_id = SFK.referenced_object_id Where SFK.type is null Technorati tags: SQ

How to find the number of days in a month

This seems to be one another frequently asked question in the discussion forums. So thought would write a small post on this today. With the help of built in SQL Server functions we can easily achieve this in one single T-SQL statement as shown below. Select Day(DateAdd(Month, 1, '01/01/2007') - Day(DateAdd(Month, 1, '02/01/2007'))) Generalized Solution: We can generalize it by creating a "User defined Stored Procedure" as shown below: Create Function NumDaysInMonth (@dtDate datetime) returns int as Begin Return(Select Day(DateAdd(Month, 1, @dtDate) - Day(DateAdd(Month, 1, @dtDate)))) End Go Test: Select dbo.NumDaysInMonth('20070201') Go Technorati tags: SQL Server , SQL Server 2005

Find tables which doesn't have Primary Key

The below queries would list down the tables which doesn't have Primary Key in it. In SQL Server 2000 : Solution 1: Select Table_name as "Table name" From Information_schema.Tables Where Table_type = 'BASE TABLE' and Objectproperty (Object_id(Table_name), 'IsMsShipped') = 0 and Objectproperty (Object_id(Table_name), 'TableHasPrimaryKey') = 0 Solution 2: SysObjects :: Contains one row for each object that is created within a database, such as a constraint, default, log, rule, and stored procedure. No prizes for guessing 'U' refers to user tables, and 'PK' refers to Primary Keys :) Select [name] as "Table Name without PK" from SysObjects where xtype='U' and id not in ( Select parent_obj from SysObjects where xtype='PK' ) SQL Server 2005: Catalog views return information that is used by the Microsoft SQL Server 2005 Database Engine. We recommend that you use catalog views because they are the most general int