September 10, 2012 at 5:37 am
alter procedure Goals_history
(
@stuid nvarchar(22),
@startyear nvarchar(22),
@endyear nvarchar(22),
)
as
begin
select name,class,noofsubject,rank,test from @tab1
union
select name,class,subject,rank,test from @tab2
where rank is not null
and studentname=@stuid
and accodomicyear>=@startyear
and accodomicyear<=@endyear
end
OUTPUT:
class noofsubject rank test name
2 5 1 revision ravi
2 5 - monthly raju
2 5 3 midterm ravi
6 4 - monthly somu
2 5 - revision ravi
expectin outputrank is null means show first)
class noofsubject rank test name
6 4 - monthly somu
2 5 - monthly raju
2 5 - revision-II ravi
2 5 1 revision ravi
2 5 3 midterm ravi
:NOTE
\ null values ve print first row of output.....
not null is ve to print with space.... how to define
September 10, 2012 at 8:50 am
raghuldrag (9/10/2012)
alter procedure Goals_history(
@stuid nvarchar(22),
@startyear nvarchar(22),
@endyear nvarchar(22),
)
as
begin
select name,class,noofsubject,rank,test from @tab1
union
select name,class,subject,rank,test from @tab2
where rank is not null
and studentname=@stuid
and accodomicyear>=@startyear
and accodomicyear<=@endyear
end
OUTPUT:
class noofsubject rank test name
2 5 1 revision ravi
2 5 - monthly raju
2 5 3 midterm ravi
6 4 - monthly somu
2 5 - revision ravi
expectin outputrank is null means show first)
class noofsubject rank test name
6 4 - monthly somu
2 5 - monthly raju
2 5 - revision-II ravi
2 5 1 revision ravi
2 5 3 midterm ravi
:NOTE
\ null values ve print first row of output.....
not null is ve to print with space.... how to define
Please see the first link in my signature about best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 10, 2012 at 10:41 pm
while em using str in my query its showing error, like
select slno,entrydate,goals,kpi,weightage,goals_review_date,reviewcomments,reviewedby,reviewdate
from GOALSDTL
union
select str((slno,entrydate,goals,kpi,weightage,goals_review_date,reviewcomments,reviewedby,reviewdate),5,2)
from GOALSDTL_History
error:
doest convert date into int
September 11, 2012 at 1:37 am
Once again, I have to remind you that this is a SQL Server 2008 forum.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
September 11, 2012 at 7:07 am
hey friend
i am executing dis qury on sql server 2000 only...its not server 2008
September 11, 2012 at 7:21 am
raghuldrag (9/11/2012)
hey friendi am executing dis qury on sql server 2000 only...its not server 2008
But we still don't know what the question is. It has been suggested you read the article found at the first link in my signature. Perhaps you could read this one too. http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 11, 2012 at 7:45 am
raghuldrag (9/11/2012)
hey friendi am executing dis qury on sql server 2000 only...its not server 2008
I guessed that much from the subject of your post.
Here is a link to the SQL Server 2000 forum.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply