Thursday, November 20, 2008

Insert Script for MS SQL Server

Browsing the net i found this great script it creates a procedure with takes table name as input and returns a insert script for table works for both SQL Server 2000 and 2005. Great to use and no additional server requirement or installs required.

/***** Object: StoredProcedure [dbo].[sp_CreateDataLoadScript] Script
******/

SET ANSI_NULLS ONGOSETQUOTED_IDENTIFIER ON

GO

Create Procedure[dbo].[sp_CreateDataLoadScript]@TblName
varchar(128)

as

/*execsp_CreateDataLoadScript 'MyTable'*/

create table #a (id intidentity (1,1), ColType int, ColName varchar(128))

insert #a
(ColType,ColName) select case when DATA_TYPE like '%char%' then 1 else 0 end
,COLUMN_NAME from information_schema.columns where TABLE_NAME =@TblNameorder by ORDINAL_POSITION

if not exists (select * from #a)
begin
raiserror('No columns found for table %s', 16,-1, @TblName)
return
end

declare @id int ,@maxid int,@cmd1 varchar(7000) ,@cmd2 varchar(7000)

select @id = 0 ,@maxid =max(id)from
#a

select @cmd1 = 'select '' insert ' + @TblName + ' ('select @cmd2 = ' + ''
select '' + 'while @id < @maxid begin select@id = min(id) from #a where id > @idselect

@cmd1 = @cmd1 + ColName +',' from #a where id = @idselect

@cmd2 = @cmd2+ ' casewhen ' + ColName + ' is null '+ ' then ''null'' '+ ' else '+
case when ColType = 1 then ''''''''' + ' + ColName + ' + '''''''''
else 'convert(varchar(20),' + ColName + ')' end+ ' end + '','' + 'from #a
where id = @idendselect

@cmd1 = left(@cmd1,len(@cmd1)-1) +' ) '' '

select @cmd2 = left(@cmd2,len(@cmd2)-8) + ' from ' + @tblNameselect '

/*' + @cmd1 + @cmd2 +'*/'

exec (@cmd1 + @cmd2)

droptable #a



Note: you will have to turn of identity column if you want to insert the primary key as well.

Tuesday, November 18, 2008

Back button with Ajax in ASP.Net

I am sure anyone who is worked on AJAX grids has come accross a QA or client who wants the grid pager to go to previous page when they hit browser back button. well asp.net 3.5 Sp1 has the perfect answer, it has a history control which allows you to add history on your ajax enabled pages. it is defined in five simple steps on the blog link mentioned below.

http://geekswithblogs.net/ranganh/archive/2008/11/17/enabling-the-browserrsquos-back-button-for-grid-view-asp.net-ajax.aspx

basic logic here is that you are able to create history points to you browser on AJAX postback.

Friday, November 14, 2008

SQL Server - Tips and more

I have been a great fan of MS SQL Server, I just wanted to share some of the tips and tricks i picked up that can be quite helpful.

1. Changing owner of tables/ procedure or Function.

For Tables


DECLARE @old sysname, @new sysname, @sql varchar(1000)

SELECT
@old =
'oldOwner_CHANGE_THIS'
, @new = 'dbo'
, @sql = '
IF EXISTS (SELECT
NULL FROM INFORMATION_SCHEMA.TABLES
WHERE
QUOTENAME(TABLE_SCHEMA)+''.''+QUOTENAME(TABLE_NAME) = ''?''
AND
TABLE_SCHEMA = ''' + @old + '''
)
EXECUTE sp_changeobjectowner ''?'',
''' + @new + ''''

EXECUTE sp_MSforeachtable @sql


For Procedures


DECLARE @oldOwner sysname, @newOwner sysname

SELECT
@oldOwner =
'oldOwner_CHANGE_THIS'
, @newOwner = 'dbo'

select 'EXECUTE
sp_changeobjectowner
'''+QUOTENAME(a.SPECIFIC_SCHEMA)+'.'+QUOTENAME(a.ROUTINE_NAME)+''','''+@newOwner+''''
from
INFORMATION_SCHEMA.ROUTINES a
where
a.ROUTINE_TYPE =
'PROCEDURE'
AND a.SPECIFIC_SCHEMA = @oldOwner
AND
OBJECTPROPERTY(OBJECT_ID(QUOTENAME(a.SPECIFIC_SCHEMA)+'.'+QUOTENAME(a.ROUTINE_NAME)),
'IsMSShipped') = 0


For Functions

DECLARE @oldOwner sysname, @newOwner sysname

SELECT
@oldOwner =
'oldOwner_CHANGE_THIS'
, @newOwner = 'dbo'

select 'EXECUTE
sp_changeobjectowner
'''+QUOTENAME(a.SPECIFIC_SCHEMA)+'.'+QUOTENAME(a.ROUTINE_NAME)+''','''+@newOwner+''''
from
INFORMATION_SCHEMA.ROUTINES a
where
a.ROUTINE_TYPE =
'Function'
AND a.SPECIFIC_SCHEMA = @oldOwner
AND
OBJECTPROPERTY(OBJECT_ID(QUOTENAME(a.SPECIFIC_SCHEMA)+'.'+QUOTENAME(a.ROUTINE_NAME)),
'IsMSShipped') = 0

2. Insert Script for SQL Server

Browsing the net i found this great script it creates a procedure with takes table name as input and returns a insert script for table.

****** Object: StoredProcedure [dbo].[sp_CreateDataLoadScript] Script Date:
09/19/2008 20:53:38 ******/
SET ANSI_NULLS ON
GO
SET
QUOTED_IDENTIFIER ON
GO

Create Procedure
[dbo].[sp_CreateDataLoadScript]
@TblName varchar(128)
as
/*
exec
sp_CreateDataLoadScript 'MyTable'
*/


create table #a (id int
identity (1,1), ColType int, ColName varchar(128))

insert #a (ColType,
ColName)
select case when DATA_TYPE like '%char%' then 1 else 0 end ,
COLUMN_NAME
from information_schema.columns
where TABLE_NAME =
@TblName
order by ORDINAL_POSITION

if not exists (select * from #a)
begin
raiserror('No columns found for table %s', 16,-1, @TblName)
return
end

declare @id int ,
@maxid int ,
@cmd1
varchar(7000) ,
@cmd2 varchar(7000)

select @id = 0 ,
@maxid =
max(id)
from #a

select @cmd1 = 'select '' insert ' + @TblName + ' (
'
select @cmd2 = ' + '' select '' + '
while @id < @maxid begin select
@id = min(id) from #a where id > @id

select @cmd1 = @cmd1 + ColName +
','
from #a
where id = @id

select @cmd2 = @cmd2
+ ' case
when ' + ColName + ' is null '
+ ' then ''null'' '
+ ' else '
+ case
when ColType = 1 then ''''''''' + ' + ColName + ' + ''''''''' else
'convert(varchar(20),' + ColName + ')' end
+ ' end + '','' + '
from #a
where id = @id
end


select @cmd1 = left(@cmd1,len(@cmd1)-1) +
' ) '' '
select @cmd2 = left(@cmd2,len(@cmd2)-8) + ' from ' + @tblName

select '/*' + @cmd1 + @cmd2 + '*/'

exec (@cmd1 + @cmd2)
drop
table #a

Note: you will have to turn of identity column if you want to insert the primary key as well.

Friday, May 30, 2008

Client Handling - Keeping it simple

I am sure one time or the other as developer or team lead or project manager you come across finite number of issue that seem to complex to be implemented. its easy to get carried away with issues like client does not get what i am trying to say, or i don't get what the client is trying to say and client is not willing to meet you half way. well get over it



I have had a great carrier graph but a tough one with a steep learning curve, i stared of as an ASP.Net developer in a small company worked there for little more than a year and then got an offer to work as Team Lead in Graycell Technologies Exports, and have been with the company till date. moving through the ranks i have moved up to delivery head.


Handling client is like handling children, sometimes they will be unreasonable and you cannot just get your point across and sometimes you are able to sway there opinion with a bit of logic and conviction. And then there are the really smart one (well they think so at least ). I have in no way mastered client handling, but do have an opinion on it. We mess it up with the client when we try to out smart the client or force the issue on to the client (and then there are those who try to out smart us). It normally works the best if both sides are honest and straight forwards towards the objectives of the project. The prime objective should be long term relationship and not a one off thing.

Over a period what i have noted with the client i dealt with is that the clients noramlly are not that target oriented as we would like them to be, they would provide you the specs (if any) and at hope that all the will work out as per their expectations. That is where i think a agile approach to the project helps here the client is proactively involved in the project and the project is broken into small sets of deliver ables and client is demoed the project and he is able to analyze the development and provide feedback on the exactly what is right and what is wrong. But PMs needs to careful and not give away too much leaway and end up in a mess. each set of deliverable should clarly defined and scope should be clear if thats not the case the client can take you for a ride.

These are my intial thoughts about client handling, i would like to see your comments as they would help me improve.



हेमंत

Monday, May 19, 2008

Agile a new methodology

Software has been written for last 30+ years but the story has remained the same for trough out "you write code you create bugs". You deliver but client says its not what is asked for. I am no super coder or a masterful project manager. I have been at the short end of the stick many-a-times. The fact of the matter is that requirements change with time and longer we take to deliver more likely it is client has a change of mind/ or competition came up with better solution before we delivered and now client does not want to be undone by the competition (Fair). The problem lies in the speed at which world is changing, 2 years ago if someone was to take on 2 yr project in ASP.Net 1.1 by the time of the planned release the client would be looking for a solution in ASP.Net 3.5. Now porting it to 3.5 would be a mammoth task (not sure a good example).

For the customers it not only hard to be precise about what's needed, it's also hard to see why it should be difficult to change later. Customers expect software to be soft.Traditional methodologies establish procedures that discourage requirements changes, they resist change. This helps them maintain a predictable schedule, but it does nothing to ensure that the final results meets the customers real, changing needs. While predictability may be very desirable, it can only be achieved by seriously compromising other qualities – particularly the fit of the final result to the real (emerging) requirements.
A typical project plan will indicate that the project requires “three programmers”. Once again, the assumption is that the project can be managed using a defined process, and that the outcome won't depend on the individuals that are assigned. But in our hearts we know that this isn't true – that the outcome depends heavily on the individuals involved. Alistair Cockburn (Author - “Characterizing People as Non-linear, First-Order Components in Software Development”) in particular has presented forceful arguments as to why people need to be considered the most influential factor in project success or failure.

The points above clearly illustrate the failure of earlier methodologies like water fall, spiral etc. one may think why did these why did these work in the past, well the basic reason is that things happen much faster not then it did in the past. MS took years to come up with a new version of office 97 and then 2000 and now they plan to do that practically every year, same is true for many of there products. Customers are now more informative and want to move with the fast paced world.

Agile - Introduction

During the 90s a number of different people realised that things had somehow changed. These people became interested in developing software methodologies that were a better fit with the new business environment – more nimble, easier to manoeuvre through a turbulent business environment. Although the details of these methodologies differ, they all share certain underlying principles, to the extent that these methodologies are often now grouped under the title “agile methodologies”.Given the opportunity to reject the “software engineering” metaphor and start all over again, what would we consider as we were developing a new methodology?·

  • Software development is predominantly a design activity·
  • Characteristics of individuals are the first-order influence on project activities·
  • Modern software development can't rely on individuals – it requires effective teams·
  • Customers are unlikely to know what they want in detail before they start·
  • Customers need to be able to change requirements without unreasonable penalties·
  • The process needs to be flexible·
  • Responsibility should be aligned with authority

I am still a student of agile and will be writing more about it in the future.




kick it on DotNetKicks.com

Wednesday, May 14, 2008

Sharepoint Templates - Makes life easy

I have recently started looking at share point as an alternate to custom coding . it is a great tool and provides great flexibility, though at times you feel lost but the end result is quite encouraging. Microsoft offers a host of free templates which can meet a vast range of requirements and with a bit of customization you are ready to roll. I see it as a great to ol for intranet based apps which are required from time to time. also with MS providing a host of templates it helps you provide a quick solution to the client which when custom coded could have taken months. Sharepoint Templates - Makes life easy

List of templates available

Application Templates for Windows SharePoint Services 3.0
Application Templates are out-of-the-box, custom solutions tailored to address the needs and requirements of specific business processes or sets of tasks within organizations of any size। The templates can be applied to common scenarios, such as managing a help desk or tracking a marketing campaign, to easily create a dedicated Web-based application for a more efficient and effective way of working.

A set of 40 new Application Templates for Windows SharePoint Services 3.0 is now available for download.

Server Admin Templates: Server admin templates are created as site definitions, providing tighter integration and enhanced functionality within the Windows SharePoint Services platform. They will require a server administrator to install. If you do not have Central Server Admin rights, you can still install the site admin templates (see second list below) in the sites/workspaces that you own or administrate.

  • Absence Request and Vacation Schedule Management
  • Help Desk
  • Budgeting and Tracking Multiple Projects
  • Inventory Tracking
  • Bug Database
  • IT Team Workspace
  • Call Center
  • Job Requisition and Interview Management
  • Change Request Management
  • Knowledge Base
  • Compliance Process Support Site
  • Lending Library
  • Contacts Management
  • Physical Asset Tracking and Management
  • Document Library and Review
  • Project Tracking Workspace
  • Event Planning
  • Room and Equipment Reservations
  • Expense Reimbursement and Approval Site
  • Sales Lead Pipeline Site

Admin Templates: Site admin templates are easy for site administrators to install in a template gallery without requiring server administration access.

  • Board of Directors
  • Employee Training Scheduling and Materials
  • Business Performance Rating
  • Equity Research
  • Case Management for Government Agencies
  • Integrated Marketing Campaign Tracking
  • Classroom Management
  • Manufacturing Process Management
  • Clinical Trial Initiation and Management
  • New Store Opening
  • Competitive Analysis Site
  • Product and Marketing Requirements Planning
  • Discussion Database
  • Request for Proposal
  • Disputed Invoice Management
  • Sports League
  • Employee Activities Site
  • Team Work Site
  • Employee Self-Service Benefits
  • Timecard Management
you can look at these templates at http://www.sharepointshowcase.com/default.aspx after registering.

Role-Based Templates for SharePoint My Sites
Role-Based Templates for SharePoint My Sites are custom templates, designed for Microsoft Office SharePoint Server 2007 and the My Site functionality, and tailored to address the unique needs and requirements of specific roles within an organization। The templates extend the standard My Site functionality, providing a personal portal and dashboard with data relevant to your job role and displaying information in a way that is familiar, easy, and built around the way people in the company work.

Two role-based My Site templates are available for download now, with five additional templates scheduled for release in spring 2007.

Sample Master Pages
Master Pages provide a single source for all the page design and layout elements you want to repeat on multiple pages within a SharePoint site or application. They enable you to create and update elements in one place, giving your site a more consistent appearance. Microsoft has made available a package of four sample master page sets that were built using new CSS and Master Page editing tools within Microsoft Office SharePoint Designer 2007 and are compatible with the Application Templates for Windows SharePoint Services 3.0.

GroupBoard Workspace 2007
GroupBoard Workspace 2007 is an application template for Windows SharePoint Services 3.0 designed to provide a collaborative platform for team-based information sharing and joint documentation creation. The lists in GroupBoard Workspace 2007 provide visibility for key information, including group schedules, the movements of group members, equipment reservations and memos circulated to the group.

Community Kit for SharePoint
The Community Kit for SharePoint is a set of best practices, templates, Web Parts, tools, and source code that enables practically anyone to create a community Web site based on SharePoint technology for practically any group of people with a common interest.

For more details go to MS Website







kick it on DotNetKicks.com

Wednesday, April 23, 2008

Measure the performance of QA

I have been pondering on how to measure QA performance, while there are many parameters to measure performance of development team, I could not come across one for QA. I have been strongly opposed to quantitative analysis of performance as it brings in a mechanical and defensive approach to project development, though it makes our job a lot easier. We as an organization want to promote camaraderie leading to a good team spirit leading to greater things.

Defect metrics are not 'objective' and should not be used for appraisals. In-fact, as a practice metrics should not be used for performance appraisals because they may cause defensiveness and next time around one may find stuffed results (therefore devaluing the process & also cause inter/intra team conflicts -eg.if lots of bugs were found, would one conclude that the development was poor? It may have been a complex module or a buggy dependency, or even an unclear spec, a change in requirements!).
First of all, it should be understood that any evaluation IS subjective.One uses data in order to make evaluations 'fair' and normalize it over various teams (to bring about some consistency in evaluations across managers)

So how would one go about it? I would think, similar to evaluating developers.
To get a feel, involve in a sample of their work product reviews like test plans, test cases, test programs. This gives an insight into their domain knowledge and expertise.
Ask them to present how they would test a given requirement/design? Have they been innovative (eg.automated any testing)?
How have they contributed to design reviews, code reviews during the development cycles (testing does not begin after the code has been written)?
Have there been instability in the product after its release?
Has the team/ individual worked collaboratively with others (a team player)?
One needs to quote situations/events, how the individual responded, give constructive suggestions/feedback, acknowledge difficult situations.
This would, in my opinion be 'objective' and also supported by data. We can have a similar process for developers as well.


kick it on DotNetKicks.com

हेमंत