Skip to main content

Posts

10 Ways to Save Time While Building a Website

Anders Haig talks about 10 ways by which we can save time in building a website (based on his freelancing experience). Points which he has covered are: [he has given a good description of each topic with reference links] 1. Dropdown menus 2. Image capture 3. Batch image resizing 4. Web forms 5. CSS text boxes 6. Vectorizing Images 7. Selecting color schemes 8. Creating a Patterned Background 9. Building a quick photo gallery 10. Testing your website in multiple browsers Read the full article here - http://reencoded.com/2008/08/04/10-ways-to-save-time-while-building-a-website/

Deefbox is an useful tool for websites....

Deefbox is a simple but very important tool from CQsight . This tool would help us (site owners) to understand in real time on how useful our site is to others. In other terms it would help us to understand the search pattern of the users and whether what they came looking for is available in our site or not. Setting up the tool is pretty simple. Just follow up the instructions given here http://www.cqsight.com/HowWork.aspx After you signup and setup the script in your site periodically watch out the dashboard which they would provide you in cQsight to understand your visitors usage pattern. I don't want to write a tutorial for this tool :) instead would like people to try it out themself and see how simple and powerful the tool is.

Cuil Search Engine ...

By this time you would have heard about ' Cuil ' - a search engine developed by ex-top engineers of Google. I tried our few searches in that and as of now I am not pleased with the search results. I came to know from their site that "Cuil is an old Irish word for knowledge" 1. Search Result looks like a news site. This is not a complaint :) May be I am used to the search results page template used by Google , Yahoo , Microsoft . But I like this Cuil result template as well. 2. As usual I tried searching for my name ( 'Vadivel' ) and found that Cuil wasn't able to find my blog (atleast it was not available within the first two pages) whereas Google was able to show my blogspot in the first page itself. I even tried changing the search string as Vadivel Blogspot still it wasn't able to pickup! 3. If a search string has multiple meanings they provide those options as a menu style. For ex: Find attached the screenshot which I took by searching SQL 4. Explo...

Difference between Response.Write and Response.Output.Write

From classical ASP days if we want to print some string with formatting we used to make use of Response.Write and some function to do the string formatting for us. But in .NET we have Response.Output.Write which is equal to Response.Write + String.Format features. Find below the basic sample explaining this feature! private void Page_Load (object sender, System.EventArgs e) { DateTime dtTwoDays = DateTime.Now; // Get the current date dtTwoDays = dtTwoDays.AddDays(2); // Add 2 days to it Response.Write(”Classical way of doing the same thing”); string strMessage = dispMessage(dtTwoDays); // Call a method which would return the formatted string. Response.Write(strMessage); // Print that formatted string Response.Write(”.NET way of doing the same thing:”); Response.Output.Write(”{0} from today is {1:d}”, “Two days”, dtTwoDays); } Private string dispMessage(DateTime dtMVP) { // {0} and {1:d} are the place holders which would take up the values passed as parameters // {0} will take “Two days...

2007 Internet Quiz.

I scored 100% in the 2007 internet quiz @ http://www.justsayhi.com/bb/internet I need to admit I used google for one question as I wasn't clear on the answer. So you can count me as 99% :) What's your score?

Get TIME alone from a given date

I see this to be very frequently asked question in dotnetspider.com! Solution to this is to make use of CONVERT function in SQL Server. --Query will fetch the time portion alone Select Convert(Varchar, Getdate(), 108) --Query will fetch the date portion alone. Select Convert(Varchar, Getdate(), 101) The last parameter of Convert function is StyleId. Go through books online to know the complete list of parameters and its corresponding output format.

Should we upgrade to SQL 2005 or wait for SQL Server 2008?

To my knowledge, there are companies which still works on SQL Server 7.0 and SQL Server 2000. But in the last quarter of 2005, Microsoft released SQL Server 2005. Though I have been using that product personally since that time and officially for more than one year now. I am not too sure whether everybody has migrated to SQL Server 2005! That being a case SQL Server 2008 (code named: Katmai) is around the corner now :) Hmm we need to wait and see how many of them migrate immediately.

List tables which are dependent on a given table - SQL Server 2005

Option 1: Right-click on a table and choose 'View Dependencies'. Option 2: For some reason if you want to do it programmatically check out the below code snippet Select S.[name] as 'Dependent_Tables' From sys.objects S inner join sys.sysreferences R on S.object_id = R.rkeyid Where S.[type] = 'U' AND R.fkeyid = OBJECT_ID('Person.StateProvince') here, replace Person.StateProvince with your table name.

List the modified objects in SQL Server 2005

For viewing the modified date of Stored Procs and UDF alone: Select Routine_name, Routine_Type, Created, Last_altered From Information_schema.routines Where Routine_type in ('PROCEDURE', 'FUNCTION') Order by Last_altered desc, Routine_type, Routine_name For viewing the modified date of Stored Procs, UDF and Views: We can query 'Sys.Objects' table and find out the list of Stored procs, UDFs, Views etc., which have got modified. Code snippet: Select [name] as 'Object Name', [type] as 'Object Type', create_date, modify_date From sys.objects Where [type] in ('P', 'FN', 'TF', 'V') Order by Modify_Date desc, [type], [name] The above query will list all 'SPs', 'UDFs' and 'Views' in the current database with its 'Created date' and 'Modified date'. We can further finetune this code to match our exact need! For triggers Check out create_date and modify_date columns in sys.triggers. sel...

Codd's Rule and Current RDBMS Products ...

I was discussing with few of my friends on the topic 'Codds rule'. I heard them say that 'SQL Server' and 'Oracle' supports all of the 12 codd's rule but DB2 doesn't support few of them!! I was surprised and then later got confused myself :) Actually to my knowledge there is no RDBMS product (be it, Microsoft SQL Server or Oracle or DB2) which satisfies all of the 12 rules of CODD. Hopefully in few days i will write about my knowledge on this subject and leave it open for others comments :)

SQLCMD -- Part IX (Batch files)

Using SQLCMD to execute script files easily in different environments Assume we have few script files (.sql) which needs to be run in multiple SQL Servers. Hope you would accept that's real pain to connect into different servers from SQL Management Studio and then execute the scripts one after the other. One of the easiest ways of doing it is by making use of the SQLCMD utility of SQL Server 2005. Step 1: Lets create few dummy script files for demo purpose. File1: 01TableCreation.sql Create table tblTest ( Sno int identity, FName varchar(20) ) Go File2: 02InsertRecords.sql set nocount on Insert into tblTest (Fname) values ('alpha') Insert into tblTest (Fname) values ('beta') File3: 03StoredProcedures.sql Create proc usp_GetAllTblTest as Select sno, fname from tblTest go Step 2: Create a batch file and call these .sql files in order. File4: DBInstallationScripts.bat sqlcmd -U %1 -P %2 -S %3 -d %4 -i "C:\Vadivel\SQL Related\Scripts\sqlcmd1\01TableCreation.s...

Happy Birthday Bill Gates ...

Bill Gates turns 52 today :) Happy Birthday BillG.

SQLCMD -- Part VIII (:r and about concatenating string with spaces)

Theory: :r -- parses additional T-SQL statements and sqlcmd commands from the file specified by into the statement cache. In this article we would see the usage of :r as well as handling spaces in SQLCMD. In SQL Mgmt Studio: Step 1: 01VariableInitialization.sql :setvar filepath "C:\Vadivel\SQL Related\Scripts\sqlcmd" :r $(filePath)\02TableCreation.sql Step 2: 02TableCreation.sql Create table tblTest ( Sno int identity, FName varchar(20) ) Go :r $(filePath)\03InsertScripts.sql Step 3: 03InsertScripts.sql Insert into tblTest (Fname) values ('alpha') Explanation of each file: 01VariableInitialization.sql -- In this file we create a scripting variable 'filePath' which will hold the path of the .sql files which we use for this demo. Then it executes 02TableCreation.sql. 02TableCreation.sql -- In this, we create tables of our choice. Also we make use of the scripting variable created in the previous file here to call another .sql file to insert records into th...

SQLCMD -- Part VII (Concatenating string with a Scripting Variable)

This example demonstrates the way to create a variable and make use of it for multiple purpose. Actually in this example we would see how to create a variable and append strings into it. Lets create two Database with slight difference in the name. For example, DB1 and DB2. Then create a table in each DB and populate few records into it. ---Code snippet which needs to be run in Mgmt Studio starts here--- Use master go Create Database DB1 go Use DB1 go Create table t1 (a int) go insert into t1 values (1) insert into t1 values (2) insert into t1 values (3) go Create database DB2 go Use DB2 go Create table t2 (Num int) go insert into t2 values (4) insert into t2 values (5) insert into t2 values (6) go --Code snippet to be run in Mgmt studio ends here--- Now open command prompt and connect into the DB. Step 1: SQLCMD -U sa -P hot -S VADIVEL Step 2: Press Enter Now lets create a variable by name "dbname" and assign 'DB' as the string to it. Step 3: :setvar dbname DB Now l...

Reclaiming the table space after dropping a column [without clustered index]

If we drop a column it gets dropped but the space which it was occupying stays as it is! In this article we would see the way to reclaim the space for a table which has a non-clustered Index. Create a table with non-clustered index in it: Create Table tblDemoTable_nonclustered ( [Sno] int primary key nonclustered, [Remarks] varchar(5000) not null ) Go Pump-in some data into the newly created table: Set nocount on Declare @intRecNum int Set @intRecNum = 1 While @intRecNum Begin Insert tblDemoTable_nonclustered (Sno, Remarks ) Values (@intRecNum, convert(varchar,getdate(),109)) Set @intRecNum = @intRecNum + 1 End Check the fragmentation info before dropping the column: DBCC SHOWCONTIG ('dbo.tblDemoTable_nonclustered') GO Output: DBCC SHOWCONTIG scanning 'tblDemoTable_nonclustered' table... Table: 'tblDemoTable_nonclustered' (1781581385); index ID: 0, database ID: 9 TABLE level scan performed. - Pages Scanned................................: 84 - Extents Scanned......

Reclaiming the table space after dropping a column - [With Clustered Index]

If we drop a column it gets dropped but the space which it was occupying stays as it is! In this article we would see the way to reclaim the space for a table which has a clustered Index . Create a table with clustered index in it: Create Table tblDemoTable ( [Sno] int primary key clustered, [Remarks] char(5000) not null ) Go Pump-in some data into the newly created table: Set nocount on Declare @intRecNum int Set @intRecNum = 1 While @intRecNum Begin Insert tblDemoTable (Sno, Remarks ) Values (@intRecNum, convert(varchar,getdate(),109)) Set @intRecNum = @intRecNum + 1 End If it's SQL 2000 or earlier: DBCC SHOWCONTIG ('dbo.tblDemoTable') -- Displays fragmentation information for the data and indexes of the specified table Go Output: DBCC SHOWCONTIG scanning 'tblDemoTable' table... Table: 'tblDemoTable' (1717581157); index ID: 1, database ID: 9 TABLE level scan performed. - Pages Scanned................................: 80 - Extents Scanned......................

SQLCMD -- Part VI (Scripting Variables)

To list all available SQLCMD Scripting variables, do the following: Step 1: Go to DOS prompt and open up SQLCMD Step 2: type :listvar which would list all SQLCMD scripting variables. In the screenshot you can see that the SQLCMDEditor and SQLCMDINI variable which we overwrote in the previous posts here and here are displayed. Almost all of the other variables are self-explanatory :) Creating our own local variables: :setvar DB1 testBed :setvar DB2 Adventureworks use $(DB1) go Select getdate(); go use $(DB2) go select top 5 city from person.address go Point to note: 1. If you execute :listvar again you can find these newly created variables getting listed there now. But please note that these local variables would be alive only till the life of the current session. i.e., If you exit out of SQLCMD once and come back and type :listvar these variables would be missing there. 2. Always the variables which we create will be in Uppercase only . Just try creating something like this: :s...