Madhivanan (SQL Server MVP) is a real community hero. He is known for his two skills – 1) Help Community and 2) Help Community. I have met him many times and every time I feel if anybody in online world needs help Madhivanan does his best to reach them out and solve problem. His name is not new if you are reading this blog or have ever asked a question in any online SQL forum. He is always there to help.
When Madhivanan has time he even helps people on this blog as well. He spends his valuable time to help community only. He recently crossed over 1000 helpful comments on this blog. On that occasion, I have interviewed him to find out if he has any life outside SQL.
Q 1. Tell us something about your self.
I am Madhivanan ,an MSc computer Science graduate from Chennai, India and working as a Lead Analyst-Project at Ellaar Infotek Solutions Private Limited. I am basically a developer started with Visual Basic 6.0, SQL Server 2000 and Crystal Report 8. As years go on I started working more on writing queries in SQL Server in most of the projects developed in my company. I have some good level of knowledge in ORACLE, MySQL and PostgreSQL as well. Now I am leading a project developed in Windows Azure.
Q 2. What motivates you to help people on community and forums.
When I got some errors during the application development in my early days of my career, I got good solutions from online forums and weblogs. So I decided to help others if possible. When I visit forums I help people  if I know the answer to the questions. I am one of the leading posters at www.sqlteam.com and also a moderator at www.sql-server-performance.com. I also take part in Visual Basic and Crystal Reports forums.
I have been SQL Server MVP since 2007.
Q 3. Your personal life is not much known. Tell us something about your personal life.
I am happily married person. My wife is a B.Pharm graduate. I have a son who is now 18 months old.
Q 4. Where can we read further for your community activity.
I have a blog at where you can find most of my T-sql stuffs
Q 5. When not working with SQL what do you do?
When not working with SQL, I spend time playing with my son, reading some magazines and watching TV.
Madhivanan for your work and help to community, a true salute to you. Hats off my friend.
Reference: Pinal Dave (https://blog.sqlauthority.com)
32 Comments. Leave new
CREATE PROCEDURE TestSproc2
@size int = 20,
@current int ,
@columns varchar(1000) = ‘*’,
@tableName varchar(100),
@condition varchar(1000) = ”,
@ascColumn varchar(100) = ”,
@bitOrderType bit = 0,
@pkColumn varchar(50) = ”
AS
DECLARE @strTemp varchar(300)
DECLARE @strSql varchar(5000)
DECLARE @strOrderType varchar(1000)
BEGIN
IF @bitOrderType = 1
BEGIN
SET @strOrderType = ‘ ORDER BY ‘+@ascColumn+’ DESC’
SET @strTemp = ‘(SELECT max’
END
IF @current = 1
BEGIN
IF @condition != ”
SET @strSql = ‘SELECT TOP ‘+STR(@size)+’ ‘+@columns+’ FROM ‘+@tableName+
‘ WHERE ‘+@condition+@strOrderType
ELSE
SET @strSql = ‘SELECT TOP ‘+STR(@size)+’ ‘+@columns+’ FROM ‘+@tableName+@strOrderType
END
ELSE
BEGIN
IF @condition !=”
SET @strSql = ‘SELECT TOP ‘+STR(@size)+’ ‘+@columns+’ FROM ‘+@tableName+
‘ WHERE ‘+@condition+’ AND ‘+@pkColumn+@strTemp+'(‘+@pkColumn+’)’+’ FROM (SELECT TOP ‘+STR((@current-1)*@size)+
‘ ‘+@pkColumn+’ FROM ‘+@tableName+ ‘where’+@condition+@strOrderType+’) AS TabTemp)’+@strOrderType
ELSE
SET @strSql = ‘SELECT TOP ‘+STR(@size)+’ ‘+@columns+’ FROM ‘+@tableName+
‘ WHERE ‘+@pkColumn+@strTemp+'(‘+@pkColumn+’)’+’ FROM (SELECT TOP ‘+STR((@current-1)*@size)+’ ‘+@pkColumn+
‘ FROM ‘+@tableName+@strOrderType+’) AS TabTemp)’+@strOrderType
END
END
EXEC (@strSql)
can you please explain me what does this store proc do??
Print the value of @strSql and see what it returns
The database contains a simplified healthcare claim data model consisting of three tables:
1. MedicalClaimHeader: Contains 1 record (claim) per medical encounter
2. MedicalProcedure: Contains 0 or more records for each procedure performed during a medical encounter
3. MedicalDiagnosis: Contains 0 or more records for each diagnosis made during a medial encounter.
The MedicalClaimheader table is related to the MedicalProcedure and MedicalDiagnosis tables by the ClaimNumber field.
Write a T-SQL query that finds every claim where a procedure 8694 was performed, without a diagnosis of 4019.
can any one write this query..
Really nice to see an article on Madhi here. He’s one among the few who really motivated me when I started participating in SQLTeam and I really owe a lot to him. Hats off my friend!
Thanks Visakh for this valuable feedback
Hi,
Q1:
Emp_id Name Reporting
1 Suresh 1
2 Ramesh 2
3 kumar 3
4 rajesh 3
5 raju 3
how to disply empid name find out the reporting person
Q2:
emp_id month salary
1 jan 15000
1 feb 30000
1 mar 20000
2 jan 40000
2 feb 50000
2 mar 60000
3 jan 70000
3 Feb 80000
3 Mar 90000
disply quarter wise and grid
output:
Emp_id Jan Feb Mar
1 15000 30000 20000
2 40000 50000 60000
3 70000 80000 90000