Skip to main content

Posts

Showing posts from November, 2005

Screen scraping using XmlHttp and Vbscript ...

I wrote a small program for screen scraping any sites using XmlHttp object and VBScript. I know I haven't done any rocket science :) still I thought of sharing the code with you all. XmlHttp -- E x tensible M arkup L anguage H ypertext T ransfer P rotocol An advantage is that - the XmlHttp object queries the server and retrieve the latest information without reloading the page. Source code: < html > < head > < script language ="vbscript"> Dim objXmlHttp Set objXmlHttp = CreateObject("Msxml2.XMLHttp") Function ScreenScrapping() URL == "UR site URL comes here" objXmlHttp.Open "POST", url, False objXmlHttp.onreadystatechange = getref("HandleStateChange") objXmlHttp.Send End Function Function HandleStateChange() If (ObjXmlHttp.readyState = 4) Then msgbox "Screenscrapping completed .." divShowContent.innerHtml = objXmlHttp.responseText End If End Function </ script > < head > < body > &l

List of my SQL Articles / Tips ...

Last Updated on October 10, 2007 * Latest articles are added at the end of this post. Articles relating to SQL Server 7.0 / 2000 1. [MSDN] Database documentation 2. Returning comma seperated details from a table ... 3. Quick search within ALL stored procedures ... 4. Find whether a column is identiy or not 5. Encryption in SQL Server 7.0 6. About sp_readerrorlog 7. Useful TSQL code snippets for beginners 8. Copying database diagrams ... 9. Query to display Null values at the bottom ... 10. Alternate rows ... 11. Running number !! 12. Doing case sensitive searches 13. Easiest way to add comments to your SQL 2k code ... 14. Listing records from 10 to 15 (for ex) without using where clause 15. Is sorting possible in Views? 16. Creating thumbnails from binary content 17. Saving an image as binary data into SQL Server 18. Reclaim Unused Table Space 19. Encrypting ALL SP's ... 20. Database Compatibility ... 21. About TimeStamp datatype of SQL Server ... 22. Grouping Store

Returning comma seperated details from a table ...

I saw an question in one of the SQL newsgroup which I visit frequently (offlate). That person is having a problem with retriving data from a table. Let me explain it in detail. Sample table structure: Create table empTest ( [Id] int identity, Contact varchar(100), Employee_Id int ) Go Let us populate few records into the table: Insert into empTest (Contact, Employee_Id) values ( 'vmvadivel@gmail.com', 101) Insert into empTest (Contact, Employee_Id) values ( '04452014353', 101) Insert into empTest (Contact, Employee_Id) values ( 'vmvadivel@yahoo.com', 102) Insert into empTest (Contact, Employee_Id) values ( '9104452015000', 102) Go And now, as you could see each employee has more than one contact details. So if you query the table as Select * from EmpTest it would list couple of records for each employee. Instead of this won't it be nice if we could generate comma seperated contact details for each employee. i.e., There would be only one record for an

Quick search within ALL stored procedures ...

This article would explain in detail the methods involved in searching strings within ALL stored procedures. I am sure there might have been situation where you want to find out a stored procedure where you remember writing some complex logic. Won't it be nice if we can find out that stored procedure where we have already written that important piece of code .. so that we can reuse? If your answer is "yes" read on. Points to note before executing this SP: 1. I have written 2 methods for this purpose. If we want this SP to be in the MASTER database then set @method =1. If not set it to 2 2. If @method is set to 2 then it is advisable to change the SP name. As you know only SP's which exist in MASTER database needs to be prefixed with "SP_" (for performance reason). The Stored Procedure: Create Procedure sp_searchForStoredProc ( @searchString varchar(100) ) As /************************************************** Stored Procedure: sp_searchForStoredProc CreatiOn

Find whether a column is identity or not ...

In one of the newgroup somebody was asking the way to find whether a column is identity or not. I thought I would write my answer there as an article for the benefit of those who have the same doubt. I know of two ways of finding whether a given column is an identity column or not. Let me try and explain it ... Sample Table structure: Create a sample table with an identity column in it. Create table [order_details] ( OrderId int identity, OrderName varchar(10), UnitPrice int ) Method 1: [Easiest way] Select ColumnProperty(Object_id('order_details'), 'OrderId', 'IsIdentity') Method 2: For some reasons if you don't want the above method!! then try this one Declare @colName varchar(100) Declare @RetColName varchar(100) Set @colName = 'OrderId' -- Specify the column name for which you want to check --Status column = 128 means its an identity column Select @RetColName=[name] from syscolumns where (status & 128) = 128 and id=(select id from sysobjects

Sp_refreshView explained ...

Often people ask me "I have a table and there are few views based on that table. When I make a structural change to my table it invalidates all those views. So we are left out with no other option than to drop those views and recreate it. But is there any alternate way for this?". For all those people who have this doubt in mind .. read on. i) Create this sample table for demo purpose Create table tstTestingUpdateView ( Sno int identity, [Name] varchar(10), Mail varchar(50) ) ii)Insert some dummy records Insert into tstTestingUpdateView Values('Vadivel','smart3a@yahoo.com') iii) Create a view based on that table Create view tstView1 As Select * from tstTestingUpdateView iv) Execute the newly created view and have a look at the output Select * from tstView1 v) Now add a new column to the table Alter table tstTestingUpdateView add ContactNumber Varchar(20) --Now if you execute the view it won't list the newly added column in it Select * from tstView1 vi) So

Cast your vote from home!!

Estonia has sucessfully conducted an national election with online voting option. A tiny Baltic nation last week became what appears to be the first country to open its local elections to Internet voting on a nationwide level--although only about 1 percent of the votes were cast online. Check out the full article here Estonia pulls off nationwide Net voting Needless to say, internet voting would save lot of time and energy for almost everybody. But I seriously donno whether in near future it would be possible in India! I personally feel that we need to improve a lot in the following fields "Security", "Infrastructure" and "Computer awareness". I don't think this would be possible here in India or Tamil nadu for atleast next 10 years.