Showing posts with label greetings. Show all posts
Showing posts with label greetings. Show all posts

Tuesday, March 27, 2012

A difficult Combining Rows problem

Greetings,
I'm working to combine rows based on a time window and I am hoping to
be able to write a stored procedure to do this for me, rather than have
parse through all this data in my program. I'm not very well versed
with T-SQL syntax.. just enough to get by selecting using inner joins,
updating and inserting... thats about it. (Hence why I am here.)
The raw data I have below looks like this:
groupID, StartTime, EndTime, Min, Max, Points
----
1, 2005-10-05 06:00, 2005-10-05 06:14:59, 7, 32, 13
1, 2005-10-05 06:15, 2005-10-05 06:29:59, 5, 29, 6
1, 2005-10-05 06:30, 2005-10-05 06:44:59, 5, 28, 4
1, 2005-10-05 06:45, 2005-10-05 06:59:59, 5, 29, 16
1, 2005-10-05 07:00, 2005-10-05 07:14:59, 5, 23, 13
1, 2005-10-05 07:15, 2005-10-05 07:29:59, 5, 25, 18
1, 2005-10-05 07:30, 2005-10-05 07:44:59, 5, 34, 49
1, 2005-10-05 07:45, 2005-10-05 07:59:59, 5, 31, 49
Pretty straight forward; you can see each entry is a 15 minute time
interval. What I want to be able to do is to use a view or a stored
procedure to view this in one hour chunks, like below:
groupID, StartTime, EndTime, Min, Max, Points
----
1, 2005-10-05 06:00, 2005-10-05 06:59:59, 5, 32, 39
1, 2005-10-05 07:00, 2005-10-05 07:59:59, 5, 34, 129
This involves several things:
- Recognizing that there are variable # of rows (maybe we only have 3
15 minute entries instead of 4)
- Getting a min of those row's min column
- Getting a max of those row's max column
- Getting a total for those row's points column
- Input to any view or whatver would be based on the startTime and
endTime and would always be in whole hours.
I have a feeling that I am going to be doing this all in the C# .NET
end of things, but it's at least worth a shot asking all of you SQL
experts. What I am basically interested in knowing is, do you all
think that this is possible using views or stored procedures or
something else I don't know about. I didn't even know about views
until i started researching how to do this.
Any ideas? Is this possible? Should I just give up and do it on the
C# end of things? Seems to me that it might be possible to do in a
stored procedure, but possible not worth my time. I aprpeciate any
help or suggestions.
JasonTry this:
SELECT groupid,
MIN(DATEADD(HH,DATEDIFF(HH,'20050101',st
arttime),'20050101')),
MIN(DATEADD(HH,DATEDIFF(HH,'20050101',st
arttime),'2005-01-01T00:59:59')),
MIN(min), MAX(max), SUM(points)
FROM tbl
GROUP BY groupid, DATEDIFF(HH,'20050101',starttime) ;
David Portas
SQL Server MVP
--|||Hi
Check out the dateadd/datepart functions in Books Online for rounding times.
Try:
SELECT GROUPID, DATEADD(mi,-DATEPART(mi,Starttime),Starttime) AS StartTime,
DATEADD(ms,-3,DATEADD(hh,1,DATEADD(mi,-DATEPART(mi,Starttime),Starttime)))
AS EndTime,
Min([Min]), Max([Max]), SUM([Points])
FROM Readings
GROUP BY GroupId,
DATEADD(mi,-DATEPART(mi,Starttime),Starttime),
DATEADD(ms,-3,DATEADD(hh,1,DATEADD(mi,-DATEPART(mi,Starttime),Starttime)))
John
"Factor" wrote:

> Greetings,
> I'm working to combine rows based on a time window and I am hoping to
> be able to write a stored procedure to do this for me, rather than have
> parse through all this data in my program. I'm not very well versed
> with T-SQL syntax.. just enough to get by selecting using inner joins,
> updating and inserting... thats about it. (Hence why I am here.)
> The raw data I have below looks like this:
> groupID, StartTime, EndTime, Min, Max, Points
> ----
> 1, 2005-10-05 06:00, 2005-10-05 06:14:59, 7, 32, 13
> 1, 2005-10-05 06:15, 2005-10-05 06:29:59, 5, 29, 6
> 1, 2005-10-05 06:30, 2005-10-05 06:44:59, 5, 28, 4
> 1, 2005-10-05 06:45, 2005-10-05 06:59:59, 5, 29, 16
> 1, 2005-10-05 07:00, 2005-10-05 07:14:59, 5, 23, 13
> 1, 2005-10-05 07:15, 2005-10-05 07:29:59, 5, 25, 18
> 1, 2005-10-05 07:30, 2005-10-05 07:44:59, 5, 34, 49
> 1, 2005-10-05 07:45, 2005-10-05 07:59:59, 5, 31, 49
> Pretty straight forward; you can see each entry is a 15 minute time
> interval. What I want to be able to do is to use a view or a stored
> procedure to view this in one hour chunks, like below:
> groupID, StartTime, EndTime, Min, Max, Points
> ----
> 1, 2005-10-05 06:00, 2005-10-05 06:59:59, 5, 32, 39
> 1, 2005-10-05 07:00, 2005-10-05 07:59:59, 5, 34, 129
> This involves several things:
> - Recognizing that there are variable # of rows (maybe we only have 3
> 15 minute entries instead of 4)
> - Getting a min of those row's min column
> - Getting a max of those row's max column
> - Getting a total for those row's points column
> - Input to any view or whatver would be based on the startTime and
> endTime and would always be in whole hours.
> I have a feeling that I am going to be doing this all in the C# .NET
> end of things, but it's at least worth a shot asking all of you SQL
> experts. What I am basically interested in knowing is, do you all
> think that this is possible using views or stored procedures or
> something else I don't know about. I didn't even know about views
> until i started researching how to do this.
> Any ideas? Is this possible? Should I just give up and do it on the
> C# end of things? Seems to me that it might be possible to do in a
> stored procedure, but possible not worth my time. I aprpeciate any
> help or suggestions.
> Jason
>|||John Bell and David Portas,
I will have to read up on these Dateadd/DatePart parameters an actually
interpret what is going on within these statements, but just from what
you gave me here it looks like this will work out very well, and I
really appreciate the insight. This will allow me to vary that time
window fairly easily I do believe, all on a SQL call (that's much
better than bringing back all the data and parsing through it all it.
Thanks again,
Jason|||John
I have read over those functions and I now understand what they do and
how to use them, but I am still as to why the min / max /
total fields actually work. I assume it has something to do with the
GROUP BY statements, but again, I don't know why.
Assuming black magic happens and thats just how it works, I should just
be able to change those hh,1 to hh,4 and get 4 hour increments instead.
When I do that, the Starttime and Endtime values do return correctly
(although I do get an entry for 8-12, 9-1, 10-2, etc... thats fine) but
the MIN/MAX/SUM stuff is still reflective of the 1 hour timing.. so
that black magic that is limiting the MIN/MAX/SUM to one hour is still
limiting them to one hour even with the altered start and end times.
I'm unsure how to fix or get around this because I don't yet understand
what is limiting that max to an hour in the first place. How does this
work? I've been tripped up GROUP BY things before, it's my kryptonite
for some reason.
Hope that is not too confusing, I'm all jumbled in my head.
I really apprecaite the help with this so far, you've all been
wonderful.
Jason|||John
I have read over those functions and I now understand what they do and
how to use them, but I am still as to why the min / max /
total fields actually work. I assume it has something to do with the
GROUP BY statements, but again, I don't know why.
Assuming black magic happens and thats just how it works, I should just
be able to change those hh,1 to hh,4 and get 4 hour increments instead.
When I do that, the Starttime and Endtime values do return correctly
(although I do get an entry for 8-12, 9-1, 10-2, etc... thats fine) but
the MIN/MAX/SUM stuff is still reflective of the 1 hour timing.. so
that black magic that is limiting the MIN/MAX/SUM to one hour is still
limiting them to one hour even with the altered start and end times.
I'm unsure how to fix or get around this because I don't yet understand
what is limiting that max to an hour in the first place. How does this
work? I've been tripped up GROUP BY things before, it's my kryptonite
for some reason.
Hope that is not too confusing, I'm all jumbled in my head.
I really apprecaite the help with this so far, you've all been
wonderful.
Jason|||On 10 Nov 2005 11:41:54 -0800, Factor wrote:

>John
>I have read over those functions and I now understand what they do and
>how to use them, but I am still as to why the min / max /
>total fields actually work. I assume it has something to do with the
>GROUP BY statements, but again, I don't know why.
Hi Jason,
Correct. The GROUP BY tells SQL Server to combine the data from several
rows into one row. This is normally used to report totals, minimum,
maximum per project, per section, etc. But with the appropriate
expression, it cal also be used to combine rows that fit in the same
"period" into one group.
Though John's and David's versions both work, I suggest you go with
Davids version, as this is more flexible. (And, once you get your head
around it, easier to understand as well).
Basically, John's version works by taking each of the date parts you
want to disregard (milliseconds, seconds, minutes), then subtracting
that amount of time from the Starttime. The end result will of course be
the last full hour equal to or before Starttime.
David's version works the other way around - it calculates the number of
full hours that have elapsed since a chosen anchor date, then adds that
number to the chosen anchor date. The result will be the same as John's
expression.
(Note: David chose to just use the number of hours for the group by, and
add it back to the anchor date in the SELECT clause only)

>Assuming black magic happens and thats just how it works, I should just
>be able to change those hh,1 to hh,4 and get 4 hour increments instead.
No. I'll give you two examples how to modify David's query to report on
4-hour intervals and to report on 1/2-hour intervals.
For 4-hour intervals, again calculate the number of hours since an
anchor date. Divide by 4 and truncate, then multiply by 4 again. Add
this number of hours to the anchor date. There you have the start of the
last 4-hour interval
SELECT groupid,
MIN(DATEADD(hour,
4 * (DATEDIFF(hour, '20050101', Starttime) / 4),
'20050101')),
MIN(DATEADD(hour,
4 * (DATEDIFF(hour, '20050101', Starttime) / 4),
'2005-01-01T03:59:59')),
MIN(min), MAX(max), SUM(points)
FROM tbl
GROUP BY groupid, DATEDIFF(hour, '20050101', Starttime) / 4;
For 1/2-hour intervals, we can't divide the number of hours sice the
anchor date by 0.5, as that won't give us back the precision we already
lost. Instead, we'll have to calculate minutes and divide by 30:
SELECT groupid,
MIN(DATEADD(minute,
30 * (DATEDIFF(minute, '20050101', Starttime) /30),
'20050101')),
MIN(DATEADD(minute,
30 * (DATEDIFF(minute, '20050101', Starttime) /30),
'2005-01-01T00:29:59')),
MIN(min), MAX(max), SUM(points)
FROM tbl
GROUP BY groupid, DATEDIFF(minute, '20050101', Starttime) /30;
In both cases, don't forget to change the shifted anchor value in the
expression for the end point of the interval. Instead of using the same
anchor date, then adding 30 minunte or 4 hours minus one second, the
anchor date is shifted by 30 minutes or 4 hours minus one second.
Now, the above code can still be simplified further. If your table
always has the complete data (as your sample roiws indicate), then you
could change the above queries to:
SELECT groupid,
MIN(StartTime), MAX(EndTime),
MIN(min), MAX(max), SUM(points)
FROM tbl
GROUP BY groupid, DATEDIFF(minute, '20050101', Starttime) /30;
-- or: GROUP BY groupid, DATEDIFF(hour, '20050101', Starttime) / 4;
Note that this might show "holes" in the periods if your real data is
not as complete as the sample you posted indicates. But the advantage is
that you get rid of the "shifted" anchor date for calculating end time.
Final step would be to put it in a stored procedure and use a parameter
for the interval length (in minutes):
SELECT groupid,
MIN(StartTime), MAX(EndTime),
MIN(min), MAX(max), SUM(points)
FROM tbl
GROUP BY groupid, DATEDIFF(minute, '20050101', Starttime) / @.Interval;
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Hi Jason,
What David Provided is an Excellent query .
Let us see if this query can help you.
Select GID , Min(STime) , Max(ETime) ,
Min(Minimum),Max(Maximum),Sum(Points)[co
lor=darkred]
>From yourTableName Group By[/color]
GID,Convert(varchar,STime,112),DatePart(
hh,STime)
Having same name as Functions/ Keyword sound confusing to me so I
changed them.
With Warm Regards
Jatinder Singh|||Hi
This is easier with David's method (see Hugo's reply for an explanation).
Dividing the number of hours by 4 and dropping the remainder will give you 4
hour chunks when they are multiplied back up. You also need to change the en
d
time to give a 4 hour gap.
SELECT groupid,
MIN(DATEADD(HH,
4*(DATEDIFF(HH,'20050101',starttime)/4),'20050101')
) AS Starttime,
MAX(DATEADD(HH,
4*(DATEDIFF(HH,'20050101',starttime)/4),'2005-01-01T03:59:59')
) AS Endtime,
MIN(min) AS [Min],
MAX(max) AS [Max],
SUM(points) AS [Total Points]
FROM Readings
GROUP BY groupid,
4*(DATEDIFF(HH,'20050101',starttime)/4)
John
"Factor" wrote:

> John
> I have read over those functions and I now understand what they do and
> how to use them, but I am still as to why the min / max /
> total fields actually work. I assume it has something to do with the
> GROUP BY statements, but again, I don't know why.
> Assuming black magic happens and thats just how it works, I should just
> be able to change those hh,1 to hh,4 and get 4 hour increments instead.
> When I do that, the Starttime and Endtime values do return correctly
> (although I do get an entry for 8-12, 9-1, 10-2, etc... thats fine) but
> the MIN/MAX/SUM stuff is still reflective of the 1 hour timing.. so
> that black magic that is limiting the MIN/MAX/SUM to one hour is still
> limiting them to one hour even with the altered start and end times.
> I'm unsure how to fix or get around this because I don't yet understand
> what is limiting that max to an hour in the first place. How does this
> work? I've been tripped up GROUP BY things before, it's my kryptonite
> for some reason.
> Hope that is not too confusing, I'm all jumbled in my head.
> I really apprecaite the help with this so far, you've all been
> wonderful.
> Jason
>|||Wondeful! Lots ot take in, I thank everyone for their help. I've made
a lot of progress and I've learned a TON about SQL int he past two
days.
I hope I can help you all in the future with something!
Thanks again,
Jason

Sunday, March 25, 2012

A couple of, I hope Basic Questions RE SqlDataSources and scripting

Greetings!

I am writing a proof of concept ASP.net application for my employer and I have run into a couple perplexing issues. First off, In my Page_Load event I have the following code.

txOTHrs.Attributes[

"onBlur"] ="return calculateTotal(this)";

The onblur event handler is coded as follows

function calculateTotal(tb)

{

var regHrs = document.getElementById ("txRegHrs").value; var otHrs = document.getElementById("txOtHrs").value; var rate = document.getElementById("txRate").value; var regAmt = rate * regHrs; var otAmt= rate * ( otHrs * 1.5 ); var total = otAmt + regAmt;

document.getElementById(

"txTotal").value = total;

}

Everything seems to work fine. The onBlur event is handled and, as I expect the value in the txTotal text box is updated correctly. The problem occurs when I try to access that value in the codebehind page. When ever I look at txTotal.Text in the debugger it is always blank. This has left me scratching my head as I can clearly see a value on the web page. Have I missed some step where I have to notify the server that a value in the control has changed ?

My second question is, I hope a very easy one to answer. In WinForms when I have a dataset I can access the individual rows ( in an untyped dataset ) by speficying dataset.tables["tableName"].Rows[index]. Is there any similar mechanism for accessing the individual rows, and fields in the SqlDataSource object in ASP.net ?

Any help anyone can provide is greatly appreciated!!

If you are comming from a "Windows Forms" world, then there are a few key concepts that you are going to need to understand... most especially is the "Page Lifecycle" which I will mention further down... but to answer your questions quickly:

sabrecat:

Have I missed some step where I have to notify the server that a value in the control has changed ?

- Yes... you need to "PostBack" to the server at any time that you want to reflect changes.

sabrecat:

In WinForms when I have a dataset I can access the individual rows ( in an untyped dataset ) by speficying dataset.tables["tableName"].Rows[index]. Is there any similar mechanism for accessing the individual rows, and fields in the SqlDataSource object in ASP.net ?

- Again, Yes... here is a small example:

DataView myDataView = (DataView)this.MarketDataSource.Select(DataSourceSelectArguments.Empty);

foreach (DataRow rowin myDataView.Table.Rows)
{
// do something here :)
}

// Or you can do...

string firstPersonsLastName = (string)myDataView.Table.Rows[0]["LastName"];

Here is the "Page Lifecycle" that I mentioned earlier:
http://msdn2.microsoft.com/en-us/library/ms178472.aspx
http://www.eggheadcafe.com/articles/o_aspNet_Page_LifeCycle.jpg

Read the MSDN article, save that picture to your desktop and look at it often :)

I hope this helps.

Peace,

|||

Thank you very much for the reply! You have been tremendously helpful!

I thought that the data that I was putting into the control wasnt getting back to the serve. I wasnt sure what mechanism to use however to get it into the server. To actually perform thepostback I would use the __doPostBack function that ASP.Net puts into the page right ? I mean in my script I'd do somthing like

function calculateTotal(e, tb)
{
var regHrs = document.getElementById ("txRegHrs").value;
var otHrs = document.getElementById("txOtHrs").value;
var rate = document.getElementById("txRate").value;
var regAmt = rate * regHrs;
var otAmt= rate * ( otHrs * 1.5 );
var total = otAmt + regAmt;
document.getElementById("txTotal").value = total;
__doPostBack(tb,e);
}

Since my calulateTotal function right now only has the one argument (tb) I assume then that I would have to change my codebehind page to look somthing like

txOTHrs.Attributes[

"onBlur"] ="return calculateTotal(event, this)";

instead of

txOTHrs.Attributes["onBlur"] ="return calculateTotal(this)";

Regarding the SqlDataSource. Does the argument DataSourceSelectArguments.Empty make the invocation of the Select method NOT go out to the database again ? If this is not the case and the database is hit again then I would want to get the data into a DataView at the time that I do my initial select on the database and then put that object into the session to make it persistant between page reloads ?

Again thank you very much for all the insights and the links to some really good data.

Thursday, March 22, 2012

A challenging query about grouping and order

Greetings !!

I am facing a challenge and hope some one can help me with the query.

I have a school. School have classrooms. Classrooms have students. Classrooms are divided into various sections (Section A, Section B and so on) .Every student is allocated a rollnumber in that section. When a student is transfered from one section to the other, there are gaps in the roll number of other students of the same section. For eg:

Section A

Student 1 Roll no. 1
Student 2 Roll No. 2
Student 3 Roll No 3

Student 4 Roll no 4 and so on.

Now lets say student 2 was transferred to section B, so now there is a gap as roll no 2 is missing in section A

So what should happen is that roll no need to be grouped together based on the section and the rest be readjusted accordingly. So when a student is removed, the roll nos of other students need to be adjusted accordingly. In our case, student 3 will get a roll no of 2, student 4 will have roll no of 3 and so on.

How do I write a query for this. I need to run this as a batch process every fortnight.

Thanks

Suppose if the Roll No is not a foriegn key for other tables then I will agree with your design.

Solution for SQL Server 2005,

Code Snippet

Create Table #data (

[RId] int ,

[Class] int ,

[Section] Char ,

[RollNo] int

);

Insert Into #data Values('1','1','A','1');

Insert Into #data Values('2','1','A','2');

Insert Into #data Values('3','1','A','3');

Insert Into #data Values('4','1','A','4');

Insert Into #data Values('5','1','A','5');

Insert Into #data Values('6','1','A','6');

Insert Into #data Values('7','1','B','1');

Insert Into #data Values('8','1','B','2');

Insert Into #data Values('9','1','B','3');

Insert Into #data Values('10','1','B','4');

Insert Into #data Values('11','1','B','5');

Insert Into #data Values('12','1','B','6');

Insert Into #data Values('13','1','B','7');

Insert Into #data Values('14','1','B','8');

Insert Into #data Values('15','1','B','9');

--Transfer the Student 4 from A section to B section

Update #data Set RollNo=10, Section='B' Where Section='A' And RollNo=4

--To fill the current gap

;WITH CTE

as

(

Select * , Row_Number() OVER (Partition By Class,Section Order By RollNo) NewRollNo

from #data

)

Update

CTE

Set

RollNo = NewRollNo

Where

RollNo <> NewRollNo

|||

For SQL Server 2000,

Code Snippet

Create Table #data (

[RId] int ,

[Class] int ,

[Section] Char ,

[RollNo] int

);

Insert Into #data Values('1','1','A','1');

Insert Into #data Values('2','1','A','2');

Insert Into #data Values('3','1','A','3');

Insert Into #data Values('4','1','A','4');

Insert Into #data Values('5','1','A','5');

Insert Into #data Values('6','1','A','6');

Insert Into #data Values('7','1','B','1');

Insert Into #data Values('8','1','B','2');

Insert Into #data Values('9','1','B','3');

Insert Into #data Values('10','1','B','4');

Insert Into #data Values('11','1','B','5');

Insert Into #data Values('12','1','B','6');

Insert Into #data Values('13','1','B','7');

Insert Into #data Values('14','1','B','8');

Insert Into #data Values('15','1','B','9');

--Transfer the Student 4 from A section to B section

Update #data Set RollNo=10, Section='B' Where Section='A' And RollNo=4

--To fill the current gap

Update #data

Set

RollNo = (Select Count(*) From #data Sub

Where Sub.Class=#data.Class And Sub.Section=#data.Section And Sub.RollNo<= #data.RollNo)

|||

Thanks Manivannan for the solution. I will try the solution and revert back.

Regards,

Lalit

|||

Hi,

Currently the query is for a single classroom. Could you also suggest me how to extend this query to run for multiple classrooms one after the other.

I hope you help me out. Thanks a ton Manivannan.

|||The above query is capable to handle multiple calssrooms also.. Smile

A challenging query about grouping and order

Greetings !!

I am facing a challenge and hope some one can help me with the query.

I have a school. School have classrooms. Classrooms have students. Classrooms are divided into various sections (Section A, Section B and so on) .Every student is allocated a rollnumber in that section. When a student is transfered from one section to the other, there are gaps in the roll number of other students of the same section. For eg:

Section A

Student 1 Roll no. 1
Student 2 Roll No. 2
Student 3 Roll No 3

Student 4 Roll no 4 and so on.

Now lets say student 2 was transferred to section B, so now there is a gap as roll no 2 is missing in section A

So what should happen is that roll no need to be grouped together based on the section and the rest be readjusted accordingly. So when a student is removed, the roll nos of other students need to be adjusted accordingly. In our case, student 3 will get a roll no of 2, student 4 will have roll no of 3 and so on.

How do I write a query for this. I need to run this as a batch process every fortnight.

Thanks

Suppose if the Roll No is not a foriegn key for other tables then I will agree with your design.

Solution for SQL Server 2005,

Code Snippet

Create Table #data (

[RId] int ,

[Class] int ,

[Section] Char ,

[RollNo] int

);

Insert Into #data Values('1','1','A','1');

Insert Into #data Values('2','1','A','2');

Insert Into #data Values('3','1','A','3');

Insert Into #data Values('4','1','A','4');

Insert Into #data Values('5','1','A','5');

Insert Into #data Values('6','1','A','6');

Insert Into #data Values('7','1','B','1');

Insert Into #data Values('8','1','B','2');

Insert Into #data Values('9','1','B','3');

Insert Into #data Values('10','1','B','4');

Insert Into #data Values('11','1','B','5');

Insert Into #data Values('12','1','B','6');

Insert Into #data Values('13','1','B','7');

Insert Into #data Values('14','1','B','8');

Insert Into #data Values('15','1','B','9');

--Transfer the Student 4 from A section to B section

Update #data Set RollNo=10, Section='B' Where Section='A' And RollNo=4

--To fill the current gap

;WITH CTE

as

(

Select * , Row_Number() OVER (Partition By Class,Section Order By RollNo) NewRollNo

from #data

)

Update

CTE

Set

RollNo = NewRollNo

Where

RollNo <> NewRollNo

|||

For SQL Server 2000,

Code Snippet

Create Table #data (

[RId] int ,

[Class] int ,

[Section] Char ,

[RollNo] int

);

Insert Into #data Values('1','1','A','1');

Insert Into #data Values('2','1','A','2');

Insert Into #data Values('3','1','A','3');

Insert Into #data Values('4','1','A','4');

Insert Into #data Values('5','1','A','5');

Insert Into #data Values('6','1','A','6');

Insert Into #data Values('7','1','B','1');

Insert Into #data Values('8','1','B','2');

Insert Into #data Values('9','1','B','3');

Insert Into #data Values('10','1','B','4');

Insert Into #data Values('11','1','B','5');

Insert Into #data Values('12','1','B','6');

Insert Into #data Values('13','1','B','7');

Insert Into #data Values('14','1','B','8');

Insert Into #data Values('15','1','B','9');

--Transfer the Student 4 from A section to B section

Update #data Set RollNo=10, Section='B' Where Section='A' And RollNo=4

--To fill the current gap

Update #data

Set

RollNo = (Select Count(*) From #data Sub

Where Sub.Class=#data.Class And Sub.Section=#data.Section And Sub.RollNo<= #data.RollNo)

|||

Thanks Manivannan for the solution. I will try the solution and revert back.

Regards,

Lalit

|||

Hi,

Currently the query is for a single classroom. Could you also suggest me how to extend this query to run for multiple classrooms one after the other.

I hope you help me out. Thanks a ton Manivannan.

|||The above query is capable to handle multiple calssrooms also.. Smile

Tuesday, March 6, 2012

64-bit SQL Server, DTS and Mail

Greetings al
Any feedback on 64-bit SQL Server? Is anyone using it? Any positive results or problems experienced
I read in the BOL that DTS componenets are not included in the current release. I see this as a major hurdle to overcome - yes packages can be run from a 32-bit server, but this would have an assoicated downside.
Also, SQL Mail is not supported. Can anyone at MS explain why SQL Agent Mail is supported but not SQL Mail? And why is Outlook Express the mail client and not Outlook
Finally, will DTS and SQL Mail be fully supported in future releases on the 64-bit platformThe primary reason for no SQLMail support is that SQLMail requires Extended
MAPI which was not ported to 64bit.
Agent Mail is supported because we did some work on it to support Simple
MAPI which is included with Outlook Express. It is not possible to run
Simple MAPI inside SQL Server as an XP hence this solution does not work
for SQLMail.
The reasons for Outlook Express and not Outlook are:
1/ There is no 64bit version of Outlook, hence no 64bit Simple/Extended MAPI
included with it.
2/ Even under 32bit once Extended MAPI is installed Simple MAPI no longer
works in a manner which allows it to be used by Agent Mail.
We aim to resolve these in a future release.
-Euan
Please reply only to the newsgroup so that others can benefit. When posting,
please state the version of SQL Server being used and the error number/exact
error message text received, if any.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Elliot Wien" <anonymous@.discussions.microsoft.com> wrote in message
news:B0C44188-50B4-4461-9E54-D53AE943B019@.microsoft.com...
> Greetings all
> Any feedback on 64-bit SQL Server? Is anyone using it? Any positive
results or problems experienced?
> I read in the BOL that DTS componenets are not included in the current
release. I see this as a major hurdle to overcome - yes packages can be run
from a 32-bit server, but this would have an assoicated downside.
> Also, SQL Mail is not supported. Can anyone at MS explain why SQL Agent
Mail is supported but not SQL Mail? And why is Outlook Express the mail
client and not Outlook?
> Finally, will DTS and SQL Mail be fully supported in future releases on
the 64-bit platform?
>

Thursday, February 9, 2012

3rd party components/API support in SISS

Greetings,

I was just getting through the features of SSIS, i wanted to confirm a few things

    can i make my own dll in .net (version 2.0 or earlier) and use them im SISS via Execute Script? thers is one thing i saw on msn that i can make my ssis packages reusable by adding them on mt tool box and drag drop use them on other ssis packages. correct? can i use any other 3rd party components like APIs, or some other ETL tool's package in SISS ?

regards,

adnan shamim

1. Yes, you can use the Script task or component to reference external .NET assemblies.

2. You can't add a package to your toolbar. You can call packages from other packages. And you can create custom tasks and components to reuse across multiple packages.

3. You can call outside APIs from the script task or component. You can also use Execute Process to run external executables.

|||Thank you very much for the timely response welch! . i really appreciate it.