Showing posts with label guys. Show all posts
Showing posts with label guys. Show all posts

Wednesday, March 28, 2012

MDAC and Oracle9

Hei guys, today we have encountered a problem with connectivity from MS SQL
server to ORACLE. We have been using MDAC for linked Oracle DB and all
worked fine on ORACLE8 and early ORACLE9 DBs (for example 9.0.1.0.0). Some
days ago, the ORACLE DB has been upgraded to 9.2.0.4.0 and the link doesn't
work any longer. It is created (even dropped and recreated), but when we try
SELECT from whatever table, it returns known Error 7356: "OLE DB provider
'MSDASQL' supplied inconsistent metadata for a column.Metadata information
was changed at execution time......"
We used time to go through newsgroups and found references to this error
message. For example
http://support.microsoft.com/defaul...kb;en-us;264012 or
http://groups.google.com/groups?hl=...hreadm=UORMZEmf
DHA.2332%40cpmsftngxa06.phx.gbl&rnum=9&prev=/groups%3Fhl%3Dcs%26lr%3D%26ie%3
DUTF-8%26oe%3DUTF-8%26selm%3DUORMZEmfDHA.2332%2540cpmsftngxa06.phx.gbl%26rnu
m%3D9
or
http://groups.google.com/groups?q=E...-8&oe=UTF-8&sel
m=OW5q0QuLDHA.1552%40TK2MSFTNGP10.phx.gbl&rnum=3 - just our problem but with
newer ORACLE vrsion.
All suggestions concern registry. We checked the registry but there are no
registry entries for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MS
DTC\MTxOCI on
the server. In addition, ORACLE 9 is not mentioned in articles we've found.
We run SQL Server 2000 and ORACLE 9.2.0.4.0
Any ideas how to fix this problem? Thanks in advance.
JiriHello. I am seeing a similar problem. I have SQL 2000 server running
Oracle 9i client 9.2.0.1 and linking to an Oracle 9.2.0.3 server. I
can create the link to the Oracle server, but when I do a SELECT
against the Oracle tables I get the error 7356 with the MSDAORA
provider, same Metadata references.
I followed this article but it still didn't work:
http://www.databasejournal.com/feat...cle.php/3290801
I have not found a solution yet either. I tried installing MDAC 2.8
but that didn't make a difference.
"feli" <jife@.email.cz> wrote in message news:<erFkIG3BEHA.684@.tk2msftngp13.phx.gbl>...[colo
r=darkred]
> Hei guys, today we have encountered a problem with connectivity from MS SQ
L
> server to ORACLE. We have been using MDAC for linked Oracle DB and all
> worked fine on ORACLE8 and early ORACLE9 DBs (for example 9.0.1.0.0). Some
> days ago, the ORACLE DB has been upgraded to 9.2.0.4.0 and the link doesn'
t
> work any longer. It is created (even dropped and recreated), but when we t
ry
> SELECT from whatever table, it returns known Error 7356: "OLE DB provider
> 'MSDASQL' supplied inconsistent metadata for a column.Metadata information
> was changed at execution time......"
> We used time to go through newsgroups and found references to this error
> message. For example
> http://support.microsoft.com/defaul...kb;en-us;264012 or
> [url]http://groups.google.com/groups?hl=cs&lr=&ie=UTF-8&oe=UTF-8&threadm=UORMZEmf[/ur
l]
> DHA.2332%40cpmsftngxa06.phx.gbl&rnum=9&prev=/groups%3Fhl%3Dcs%26lr%3D%26ie
%3
> DUTF-8%26oe%3DUTF-8%26selm%3DUORMZEmfDHA.2332%2540cpmsftngxa06.phx.gbl%26r
nu
> m%3D9
> or
> [url]http://groups.google.com/groups?q=Error+7356&hl=cs&lr=&ie=UTF-8&oe=UTF-8&sel[/ur
l]
> m=OW5q0QuLDHA.1552%40TK2MSFTNGP10.phx.gbl&rnum=3 - just our problem but wi
th
> newer ORACLE vrsion.
> All suggestions concern registry. We checked the registry but there are no
> registry entries for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MS
DTC\MTxOCI on
> the server. In addition, ORACLE 9 is not mentioned in articles we've found
.
> We run SQL Server 2000 and ORACLE 9.2.0.4.0
> Any ideas how to fix this problem? Thanks in advance.
> Jiri[/color]|||We are having, apparently, the same problem here. Also with Oracle
9.2.0.4.0.
We have tried Oracle's native driver, the MS OLE DB driver for Oracle
and the MS OLE DB Driver for ODBC Drivers using either the Microsoft
or Oracle ODBC drivers. We have had some success retriving data with
a linked server connection using Microsoft OLE DB Provider for ODBC
Drivers using Microsoft ODBC for Oracle {version 2.573.9030.00}. [
Not
sure what MDAC provided this]
All other methods fail with error messages like:
Server: Msg 7356, Level 16, State 1, Line 2
OLE DB provider 'OraOLEDB.Oracle' supplied inconsistent metadata for a
column. Metadata information was changed at execution time.
OLE DB error trace [Non-interface error: Column 'MIN_EXTENTS'
(compile-time ordinal 12) of object '"SYS"."ALL_TABLES"' was reported
to have a DBTYPE of 130 at compile time and 5 at run time].
or
Server: Msg 7318, Level 16, State 1, Line 2
OLE DB provider 'MSDASQL' returned an invalid column definition.
OLE DB error trace [Non-interface error: OLE/DB provider returned an
invalid column definition.].
We are getting error messages like this from W2K Server SQL Server
2000 machines whether the Oracle 8i or 9i drivers are installed if the
linked target is Oracle 9.2.0.4.0.
We suspect that SQL Server 2000 is using old methods to communicate
with Oracle that are not appropriate for Oracle 9.2.0.4.0 and perhaps
other releases around that version. Since Oracle is working fine and
connections to it to retrieve data using a Windows script file are
successful [using ODBC and UDL files], my current suspicion is that a
patch will be required for MS SQL Server 2000 to work with more recent
versions of Oracle.
Anyone else having this experience or perhaps information on a fix for
this problem?|||Has anyone resolved this error?
quote:
[i] ... Error 7356: "OLE DB provider
'MSDASQL' supplied inconsistent metadata for a column.Metadata information w
as changed at execution time......"
[/B]
|||"feli" <jife@.email.cz> wrote in message
news:erFkIG3BEHA.684@.tk2msftngp13.phx.gbl...
> Hei guys, today we have encountered a problem with connectivity from MS
SQL
> server to ORACLE. We have been using MDAC for linked Oracle DB and all
> worked fine on ORACLE8 and early ORACLE9 DBs (for example 9.0.1.0.0). Some
> days ago, the ORACLE DB has been upgraded to 9.2.0.4.0 and the link
doesn't
> work any longer. It is created (even dropped and recreated), but when we
try
> SELECT from whatever table, it returns known Error 7356: "OLE DB provider
> 'MSDASQL' supplied inconsistent metadata for a column.Metadata information
> was changed at execution time......"
Do you have to use the MS supplied oledb driver - the Oracle supplied
provider works just fine for me.
Niall Litchfield
Oracle DBA
Audit Commission UK
http://www.niall.litchfield.dial.pipex.com/

Friday, March 23, 2012

MCDBA Roadmap

Hey Guys,
Does any 1 have the roadmap to MCDBA? If you have the document, please send
me a link where I can download or please email the document to
seelanr@.hotmail.com
Thanks"Seelan Raja" <seelan_rd@.NOSPAMyahoo.com> wrote in message
news:%234iLarkNGHA.1716@.TK2MSFTNGP10.phx.gbl...
> Hey Guys,
> Does any 1 have the roadmap to MCDBA? If you have the document, please
> send
> me a link where I can download or please email the document to
> seelanr@.hotmail.com
> Thanks
>
http://www.microsoft.com/learning/mcp/mcdba/mcdba.asp
Rick Sawtell
MCT, MCSD, MCDBA|||Thanks Rick
But that web page only has the requirements and NOT the ROADMAP.
"Rick Sawtell" <Quickening@.msn.com> wrote in message
news:uACCW9kNGHA.2624@.TK2MSFTNGP12.phx.gbl...
> "Seelan Raja" <seelan_rd@.NOSPAMyahoo.com> wrote in message
> news:%234iLarkNGHA.1716@.TK2MSFTNGP10.phx.gbl...
> http://www.microsoft.com/learning/mcp/mcdba/mcdba.asp
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>|||What are you talking about if not the MCDBA requirements? The roadmap
is simply do the 3 core exams (SQL design, SQL admin & one of the Win
Server exams) and 1 of the electives (mostly dev/design exams). Or do
you mean MCDBA (SQL 7) -> MCDBA (SQL 2000) -> MCDBA (SQL 2005) -> ?
etc.? If so then this may (or may not) be helpful:
http://www.microsoft.com/learning/mcp/mcitp/dbadmin/
*mike hodgson*
http://sqlnerd.blogspot.com
Seelan Raja wrote:

>Thanks Rick
>But that web page only has the requirements and NOT the ROADMAP.
>"Rick Sawtell" <Quickening@.msn.com> wrote in message
>news:uACCW9kNGHA.2624@.TK2MSFTNGP12.phx.gbl...
>
>
>|||Hey Guys,
Thanks for the replies but What I am looking for is the steps/the order in w
hich I take the courses/ exam.
-Seelan
"Mike Hodgson" <e1minst3r@.gmail.com> wrote in message news:OJgWJBoNGHA.3936@.
TK2MSFTNGP10.phx.gbl...
What are you talking about if not the MCDBA requirements? The roadmap is simply do the
3 core exams (SQL design, SQL admin & one of the Win Server exams) and 1 of the electi
ves (mostly dev/design exams). Or do you mean MCDBA (SQL 7) -> MCDBA (SQL 2000) -> MCD
BA (SQL 2005) -> ? etc.? If so then this may (or may not) be helpful: http://ww
w.microsoft.com/le.../mcitp/dbadmin/
mike hodgson
http://sqlnerd.blogspot.com
Seelan Raja wrote:
Thanks Rick
But that web page only has the requirements and NOT the ROADMAP.
"Rick Sawtell" <Quickening@.msn.com> wrote in message
news:uACCW9kNGHA.2624@.TK2MSFTNGP12.phx.gbl...
"Seelan Raja" <seelan_rd@.NOSPAMyahoo.com> wrote in message
news:%234iLarkNGHA.1716@.TK2MSFTNGP10.phx.gbl...
Hey Guys,
Does any 1 have the roadmap to MCDBA? If you have the document, please
send
me a link where I can download or please email the document to
seelanr@.hotmail.com
Thanks
http://www.microsoft.com/learning/mcp/mcdba/mcdba.asp
Rick Sawtell
MCT, MCSD, MCDBA|||There are no steps. Order is unimportant. You can take them in any
order you feel like. Each exam is independent in it's own right. Many
people like to do the ones they are most comfortably with first (ie. the
ones they think they are most likely to pass) to give them a confidence
boost for the harder ones but it's all just personal preference.
*mike hodgson*
http://sqlnerd.blogspot.com
Seelan Raja wrote:
[vbcol=seagreen]
> Hey Guys,
> Thanks for the replies but What I am looking for is the steps/the
> order in which I take the courses/ exam.
> -Seelan
> "Mike Hodgson" <e1minst3r@.gmail.com <mailto:e1minst3r@.gmail.com>>
> wrote in message news:OJgWJBoNGHA.3936@.TK2MSFTNGP10.phx.gbl...
> What are you talking about if not the MCDBA requirements? The
> roadmap is simply do the 3 core exams (SQL design, SQL admin & one
> of the Win Server exams) and 1 of the electives (mostly dev/design
> exams). Or do you mean MCDBA (SQL 7) -> MCDBA (SQL 2000) -> MCDBA
> (SQL 2005) -> ? etc.? If so then this may (or may not) be
> helpful: http://www.microsoft.com/learning/mcp/mcitp/dbadmin/
> --
> *mike hodgson*
> http://sqlnerd.blogspot.com
>
> Seelan Raja wrote:
>

MCDBA Roadmap

Hey Guys,
Does any 1 have the roadmap to MCDBA? If you have the document, please send
me a link where I can download or please email the document to
seelanr@.hotmail.com
Thanks
"Seelan Raja" <seelan_rd@.NOSPAMyahoo.com> wrote in message
news:%234iLarkNGHA.1716@.TK2MSFTNGP10.phx.gbl...
> Hey Guys,
> Does any 1 have the roadmap to MCDBA? If you have the document, please
> send
> me a link where I can download or please email the document to
> seelanr@.hotmail.com
> Thanks
>
http://www.microsoft.com/learning/mcp/mcdba/mcdba.asp
Rick Sawtell
MCT, MCSD, MCDBA
|||Thanks Rick
But that web page only has the requirements and NOT the ROADMAP.
"Rick Sawtell" <Quickening@.msn.com> wrote in message
news:uACCW9kNGHA.2624@.TK2MSFTNGP12.phx.gbl...
> "Seelan Raja" <seelan_rd@.NOSPAMyahoo.com> wrote in message
> news:%234iLarkNGHA.1716@.TK2MSFTNGP10.phx.gbl...
> http://www.microsoft.com/learning/mcp/mcdba/mcdba.asp
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>
|||What are you talking about if not the MCDBA requirements? The roadmap
is simply do the 3 core exams (SQL design, SQL admin & one of the Win
Server exams) and 1 of the electives (mostly dev/design exams). Or do
you mean MCDBA (SQL 7) -> MCDBA (SQL 2000) -> MCDBA (SQL 2005) -> ?
etc.? If so then this may (or may not) be helpful:
http://www.microsoft.com/learning/mcp/mcitp/dbadmin/
*mike hodgson*
http://sqlnerd.blogspot.com
Seelan Raja wrote:

>Thanks Rick
>But that web page only has the requirements and NOT the ROADMAP.
>"Rick Sawtell" <Quickening@.msn.com> wrote in message
>news:uACCW9kNGHA.2624@.TK2MSFTNGP12.phx.gbl...
>
>
>
|||Hey Guys,
Thanks for the replies but What I am looking for is the steps/the order in which I take the courses/ exam.
-Seelan
"Mike Hodgson" <e1minst3r@.gmail.com> wrote in message news:OJgWJBoNGHA.3936@.TK2MSFTNGP10.phx.gbl...
What are you talking about if not the MCDBA requirements? The roadmap is simply do the 3 core exams (SQL design, SQL admin & one of the Win Server exams) and 1 of the electives (mostly dev/design exams). Or do you mean MCDBA (SQL 7) -> MCDBA (SQL 2000) -> MCDBA (SQL 2005) -> ? etc.? If so then this may (or may not) be helpful: http://www.microsoft.com/learning/mcp/mcitp/dbadmin/
mike hodgson
http://sqlnerd.blogspot.com
Seelan Raja wrote:
Thanks Rick
But that web page only has the requirements and NOT the ROADMAP.
"Rick Sawtell" <Quickening@.msn.com> wrote in message
news:uACCW9kNGHA.2624@.TK2MSFTNGP12.phx.gbl...
"Seelan Raja" <seelan_rd@.NOSPAMyahoo.com> wrote in message
news:%234iLarkNGHA.1716@.TK2MSFTNGP10.phx.gbl...
Hey Guys,
Does any 1 have the roadmap to MCDBA? If you have the document, please
send
me a link where I can download or please email the document to
seelanr@.hotmail.com
Thanks
http://www.microsoft.com/learning/mcp/mcdba/mcdba.asp
Rick Sawtell
MCT, MCSD, MCDBA
|||There are no steps. Order is unimportant. You can take them in any
order you feel like. Each exam is independent in it's own right. Many
people like to do the ones they are most comfortably with first (ie. the
ones they think they are most likely to pass) to give them a confidence
boost for the harder ones but it's all just personal preference.
*mike hodgson*
http://sqlnerd.blogspot.com
Seelan Raja wrote:
[vbcol=seagreen]
> Hey Guys,
> Thanks for the replies but What I am looking for is the steps/the
> order in which I take the courses/ exam.
> -Seelan
> "Mike Hodgson" <e1minst3r@.gmail.com <mailto:e1minst3r@.gmail.com>>
> wrote in message news:OJgWJBoNGHA.3936@.TK2MSFTNGP10.phx.gbl...
> What are you talking about if not the MCDBA requirements? The
> roadmap is simply do the 3 core exams (SQL design, SQL admin & one
> of the Win Server exams) and 1 of the electives (mostly dev/design
> exams). Or do you mean MCDBA (SQL 7) -> MCDBA (SQL 2000) -> MCDBA
> (SQL 2005) -> ? etc.? If so then this may (or may not) be
> helpful: http://www.microsoft.com/learning/mcp/mcitp/dbadmin/
> --
> *mike hodgson*
> http://sqlnerd.blogspot.com
>
> Seelan Raja wrote:
sql

Monday, March 19, 2012

Maximum Value

Hey guys, I have this query which tries to get the maximum values from a table.

Code Snippet

SELECT scbcrse_subj_code,

MAX(scbcrse_eff_term), scbcrse_crse_numb, scbcrse_coll_code, scbcrse_title, scbcrse_csta_code

FROM Courses

WHERE scbcrse_csta_code = ''A''

GROUP BY scbcrse_subj_code, SCBCRSE_CRSE_NUMB, scbcrse_coll_code, scbcrse_csta_code, scbcrse_title

ORDER BY scbcrse_subj_code

Sample Table

scbcrse_subj_code scbcrse_eff_term scbcrse_crse_numb scbcrse_coll_code scbcrse_title ACCT 200620 4010 SB Advanced Accounting ACCT 200530 4010 SB Financial Accounting IV

Now, there is a column which is called scbcrse_title which shows the title of the course, which in this case on the table the titles are different. One is called Advanced Accounting and the other is called Financial Accounting IV. My question is, how can I only show the highest number on the scbcrse_eff_term? The problem occurs when there are different titles.

Does scbcrrse_title need to be part of the group by? Can you just group on crse_numb, coll_code, and subj_code only ? Then subselect the title using the three group by values where eff_term is max? Something like the below (i did not check the code for errors sorry)

Code Snippet

SELECT C.scbcrse_subj_code,

C.scbcrse_crse_numb,

C.scbcrse_coll_code,

C.scbcrse_csta_code,

MAX(C.scbcrse_eff_term),

(SELECT scbcrse_title

FROM Courses

WHERE scbcrse_subj_code = C.scbcrse_subj_code

AND scbcrse_crse_numb = C.scbcrse_crse_numb

AND scbcrse_coll_code = C.scbcrse_coll_code

AND scbcrse_csta_code = C.scbcrse_csta_code

AND scbcrse_eff_term) = (SELECT MAX(C.scbcrse_eff_term) FROM Courses WHERE C.Cscbcrse_csta_code = 'A' GROUP BY C.scbcrse_subj_code, C.SCBCRSE_CRSE_NUMB, C.scbcrse_coll_code, C.scbcrse_csta_code ) AS [Title]

FROM Courses C

WHERE C.Cscbcrse_csta_code = 'A'

GROUP BY C.scbcrse_subj_code, C.SCBCRSE_CRSE_NUMB, C.scbcrse_coll_code, C.scbcrse_csta_code

ORDER BY scbcrse_subj_code

|||Thanks Dave, I'll check the code to see if it works. And yes, the GROUP BY command does force me to include scbcrse_title.|||

Maybe this:

Code Snippet

SELECT scbcrse_subj_code,

scbcrse_eff_term,

scbcrse_crse_numb,

scbcrse_coll_code,

scbcrse_title,

scbcrse_csta_code

FROM Courses c

inner join

(

SELECT scbcrse_subj_code,

scbcrse_crse_numb,

scbcrse_coll_code,

MAX(scbcrse_eff_term) as eff_term

FROM Courses

) selhigh

on c.scbcrse_subj_code = selhigh.scbcrse_subj_code

and c.scbcrse_crse_numb = selhigh.scbcrse_crse_numb

and c.scbcrse_coll_code = selhigh.scbcrse_coll_code

and c.scbcrse_eff_term = selhigh.scbcrse_eff_term

WHERE c.scbcrse_csta_code = 'A'

|||Diango,

You can do this without a GROUP BY as follows:

SQL Server 2000

SELECT scbcrse_subj_code, scbcrse_eff_term, scbcrse_crse_numb, scbcrse_coll_code, scbcrse_title, scbcrse_csta_code
FROM Courses
WHERE scbcrse_csta_code = ''A''
AND NOT EXISTS (
SELECT * FROM Courses AS C
WHERE C.scbcrse_subj_code = Courses.scbcrse_subj_code
AND C.scbcrse_crse_numb = Courses.scbcrse_crse_numb
AND C.scbcrse_coll_code = Courses.scbcrse_coll_code
AND C.scbcrse_scbcrse_eff_term > Courses.scbcrse_eff_term
)
ORDER BY scbcrse_subj_code

In other words, choose all rows for Courses where the table does not contain a later (measured by eff_term) row with the same (subj_code, crse_numb, coll_code) combination. This assumes you want one result row for each (subj_code, crse_numb, coll_code) combination, and you can adjust the inner WHERE clause if this is not the set of columns that you want one row for each combination of.

In SQL Server 2005, you have another option:

SQL Server 2005

WITH Courses_ranked AS (
SELECT
scbcrse_subj_code, scbcrse_eff_term, scbcrse_crse_numb,
scbcrse_coll_code, scbcrse_title, scbcrse_csta_code,
RANK() OVER (
PARTITION BY scbcrse_subj_code, scbcrse_crse_numb, scbcrse_coll_code
ORDER BY scbcrse_eff_term DESC
) AS rk
)
SELECT
scbcrse_subj_code, scbcrse_eff_term, scbcrse_crse_numb,
scbcrse_coll_code, scbcrse_title, scbcrse_csta_code
FROM Courses_ranked
WHERE rk = 1

Both solutions will return the "latest" row (or rows in the case of ties for latest) for each combination (scbcrse_subj_code, scbcrse_crse_numb, scbcrse_coll_code) in the table.

Steve Kass
Drew University
http://www.stevekass.com
|||The first solution almost worked but it had the problem that when there was a code that only had one value, it got omitted. The second solution I have never done before so I'm having some problems implementing it.|||I notice I left the = 'A' out of the inner query in the first solution. That could be it, but it could also be something about your data that you didn't mention. If you post some sample data and your adapted query that fails, I can take a look.

SK
|||That worked, you rock! As soon as I added the ''A'' in the inner join, it came back with the correct result.|||Steve, I don't mean to be a pain in the ass, but I have a new issue. I'm still a bit of a noob so bare with me. Your code worked great by the way, it did the job as intended. New update is required which I wasn't aware. I want to take into account those courses that do have '' I '' as well as the maximum value on the scbcrse_eff_term. I can do this easily by simply removing the WHERE clause where scbcrse_csta_code = ''A'' on both occasions. The thing is, for those courses that have the maximum value which have an '' I '' I need those courses removed completly. ( I don't mean delete those records that '' I '' , I just mean Omitting them some how.|||I hope I'm understanding, because you didn't give any specific example.

You want to see the latest row for each (subject code, course number, college code) from among those rows with csta code either 'A' or 'I', only if that latest row happens to be one of the 'A' rows. Note that if 'A' and 'I' are the only possible values of csta_code, you don't have to say WHERE scbcrse_csta_code IN ('A','I'). I think this will do it.

SK

SELECT scbcrse_subj_code, scbcrse_eff_term, scbcrse_crse_numb, scbcrse_coll_code, scbcrse_title, scbcrse_csta_code
FROM Courses
WHERE scbcrse_csta_code IN ('A','I')
AND NOT EXISTS (
SELECT * FROM Courses AS C
WHERE C.scbcrse_subj_code = Courses.scbcrse_subj_code
AND C.scbcrse_crse_numb = Courses.scbcrse_crse_numb
AND C.scbcrse_coll_code = Courses.scbcrse_coll_code
AND C.scbcrse_scbcrse_eff_term > Courses.scbcrse_eff_term
AND C.scbcrse_csta_code IN ('A','I')
)
AND Courses.scbcrse_csta_code = 'A'
ORDER BY scbcrse_subj_code
|||

Sorry, I should have explained myself a little better. Ok, this is your code:

SELECT scbcrse_subj_code, scbcrse_eff_term, scbcrse_crse_numb, scbcrse_coll_code, scbcrse_title, scbcrse_csta_code
FROM Courses
WHERE scbcrse_csta_code = ''A''
AND NOT EXISTS (
SELECT * FROM Courses AS C
WHERE C.scbcrse_subj_code = Courses.scbcrse_subj_code
AND C.scbcrse_crse_numb = Courses.scbcrse_crse_numb
AND C.scbcrse_Coll_code = Courses.scbcrse_Coll_Code

AND C.scbcrse_csta_code = ''A''
AND C.scbcrse_scbcrse_eff_term > Courses.scbcrse_eff_term
)
ORDER BY scbcrse_subj_code

From the original code, we had a clause WHERE = ''A''. By having those two clauses, it returned the top value from scbcrse_eff_term Where scbcrse_csta_code = A, agreed? I found out later that the original requirement was wrong. The correct requirement was, get the highest scbcrse_eff_term as long as the class is active, or otherwise known as having a csta_code of ''A''. I know it sounds the same but let me explain further.

For example:

scbcrse_subj_code scbcrse_crse_numb scbcrse_eff_term scbcrse_csta_code

ACCT 4041 195600 A

ACCT 4041 200023 A

ACCT 4041 221457 I

From the original code, it should return the second row with a value of 200023 because it's the highest row that has a csta_code of ''A''. Here is where it changes, on the example, since the highest value for the class is 221457 and has a csta_code of '' I '' the class has become inactive and therefore ACCT 4041 must no longer show up in our query. So in essence, every class that has the highest scbcrse_eff_term with a value of csta_code '' I '' should not show up at all in our query return. So ACCT 4041 would not show up on our list.

|||

Code Snippet

SELECT scbcrse_subj_code,

scbcrse_eff_term,

scbcrse_crse_numb,

scbcrse_coll_code,

scbcrse_title,

scbcrse_csta_code

FROM Courses c

inner join

(

SELECT scbcrse_subj_code,

scbcrse_crse_numb,

scbcrse_coll_code,

MAX(scbcrse_eff_term) as scbcrse_eff_term

FROM Courses

) selhigh

on c.scbcrse_subj_code = selhigh.scbcrse_subj_code

and c.scbcrse_crse_numb = selhigh.scbcrse_crse_numb

and c.scbcrse_coll_code = selhigh.scbcrse_coll_code

and c.scbcrse_eff_term = selhigh.scbcrse_eff_term

WHERE c.scbcrse_csta_code = 'A'

|||Dale, that's not working for me. I'm getting some errors when I try to implement it. I get the error of it's not a group by function. I also think that the code would return the maximum value of the courses that have a csta_code value of ''A'', not taking into account '' I ''. Which I do want to take into account '' I '' , but if the maximum scbcrse_eff_term of a course has a csta_code of '' I '' the class should be omitted completely from the result. It's not just eliminating all the '' I '', but it's eliminating all the courses from the list that has a maximum scbcrse_eff_term with scbcrse_csta_code of '' I ''. I don't know if that makes sense to you.|||

See if this is better.

I forgot the group by in the subquery.

This will gather up all the courses with the most current date, then only keep the ones that are A.

My understanding from what you've been saying is that you want to disregard all entries for the class if its current row is an I.

This should do just that.

Code Snippet

SELECT scbcrse_subj_code,

scbcrse_eff_term,

scbcrse_crse_numb,

scbcrse_coll_code,

scbcrse_title,

scbcrse_csta_code

FROM Courses c

inner join

(

SELECT scbcrse_subj_code,

scbcrse_crse_numb,

scbcrse_coll_code,

MAX(scbcrse_eff_term) as scbcrse_eff_term

FROM Courses

GROUP BY scbcrse_subj_code,

scbcrse_crse_numb,

scbcrse_coll_code

) selhigh

on c.scbcrse_subj_code = selhigh.scbcrse_subj_code

and c.scbcrse_crse_numb = selhigh.scbcrse_crse_numb

and c.scbcrse_coll_code = selhigh.scbcrse_coll_code

and c.scbcrse_eff_term = selhigh.scbcrse_eff_term

WHERE c.scbcrse_csta_code = 'A'

|||

It doesn't bring back the desired result. Let me show you what I mean.

scbcrse_subj_code scbcrse_crse_numb scbcrse_eff_term scbcrse_csta_code

ACCT 4041 195600 A

ACCT 4041 200023 A

ACCT 4041 221457 I

This is an example of a class that has gone inactive. This table has been poorly designed, which is why it's so challenging to create the proper effect. As you can see from this class, it has become inactive. When we run your query, it returns for example ACCT 4041 200023 and a code of A. The desired result is that this course doesn't come back at all because the maximum value for it is 221457 and because it has a scbcrse_csta_code of '' I ''.

Steve's code is great because it really can eliminate duplicates and it also brings the highest value of a course no matter what csta_code it has, because I removed the two WHERE clauses. Now, from the result set, I need to remove the courses that have a maximum value with a csta_code of '' I '' combination.

Monday, March 12, 2012

Maximum Performace with Concurrency and without Deadlocks or Dirty

Hi guys + gals,
I've come to a point in redesigning a database that is basically the reason
we chose to redesign it is for International support and to rid the db and
application code of permitting dirty reads against the database. However,
I'm at the point where I just cannot find a suitable solution other than to
still permit dirty reads due to the nature of the service the db provides.
Here's what 1 table in a database needs to do, but also needs to be able to
support a whole load of concurrent users / connections
A packet of data identifying the userId, the serviceId and a integer value
that the user has selected. The Stored Proc needs to insert the data, then
check that value against the other rows in the table for the same serviceId
which indicates that its either unique, lowest unique or how many other user
s
have that same integer value logged?
As you see from the code below, from the time I check the current status of
the lowest unique number, to adding a value from the user and to recheck the
data, there will have been other users possibly in the hundreds each adding
their own values. Because of this, I either lock the table until the
transaction is completed or break the code up into smaller modular procedure
s
that allow Dirty reads. The main aim is to always feedback the most accurate
data whilst still processing other concurrent users. Is there a better way
of achieving maximum performance and concurrency than what I'm doing without
resorting to dirty reads to prevent deadlocking. I have thought about
denormalising the data to keep current references to the user and value of
the current lowest unique data in another table but I find that I could end
up out of sync with the real data or again I would have to allow dirty reads
or impliment some kind of row versioning all which have cost to performance.
I would appreciate if anyone could offer a good solution or point me in the
right direction to further investivate my problem.
Thanks everyone...
Andy
Here's the DDL
CREATE TABLE [dbo].[UserChoice]
(
[userChoiceId] [int] IDENTITY(1,1) NOT NULL,
[fkUserId] [int] NULL,
[fkServiceId] [int] NULL,
[userValue] [int] NULL,
CONSTRAINT [PK_UserChoice] PRIMARY KEY CLUSTERED
(
[userChoiceId] ASC
)
)
CREATE PROCEDURE UserChoiceInsert
@.UserId INT,
@.ServiceId INT,
@.UserValue INT
AS
IF EXISTS
(
SELECT userValue
FROM UserChoice
WHERE (fkServiceId = @.ServiceId)
AND (fkUserId = @.UserId)
AND (userValue = @.userValue)
)
BEGIN
RAISERROR (N'User already has the value recorded', 10, 1);
RETURN 0
END
DECLARE @.previousLowestUnique INT
SET @.previousLowestUnique = (
SELECT TOP 1 userValue
FROM UserChoice
WHERE (fkServiceId = @.ServiceId)
GROUP BY userValue
Having Count(userValue) = 1)
INSERT INTO UserChoice
(
fkUserId,
fkServiceId,
userValue
)
VALUES
(
@.UserId,
@.ServiceId,
@.userValue
)
DECLARE @.LowestUnique INT
DECLARE @.NumberAtValue INT
DECLARE @.previousUserAtValue INT
SET @.LowestUnique = (
SELECT TOP 1 userValue
FROM UserChoice
WHERE (fkServiceId = @.ServiceId)
GROUP BY userValue
Having Count(userValue) = 1)
SET @.NumberAtValue = (
SELECT COUNT(userValue)
FROM UserChoice
WHERE (fkServiceId = @.ServiceId)
AND (userValue = @.userValue))
PRINT CAST(@.NumberAtValue AS VARCHAR(3)) + ' Number at Value'
PRINT CAST(@.previousLowestUnique AS VARCHAR(3)) + ' Previous Lowest Unique
Value'
PRINT CAST(@.LowestUnique AS VARCHAR(3)) + ' Lowest Unique Value'
PRINT CAST(@.userValue AS VARCHAR(3)) + ' User Value'
DECLARE @.IsLowestUnique BIT
DECLARE @.IsUnique BIT
--Is Lowest Unique
IF ((@.LowestUnique = @.userValue) AND @.NumberAtValue = 1)
BEGIN
PRINT 'Is Lowest Unique'
SET @.IsLowestUnique = 1
END
--no longer lowest unique
ELSE IF ((@.previousLowestUnique = @.userValue) AND @.NumberAtValue = 2)
BEGIN
PRINT 'No longer lowest unique'
SET @.IsLowestUnique = 0
SELECT @.previousUserAtValue = fkUserId
FROM UserChoice
WHERE (fkServiceId = @.ServiceId )
AND (userValue = @.userValue) AND (fkUserId < @.UserId OR fkUserId > @.UserId)
END
--no longer unique
ELSE IF ( @.NumberAtValue > 1)
BEGIN
PRINT 'No longer unique'
SET @.IsLowestUnique = 0
SELECT @.previousUserAtValue = fkUserId
FROM UserChoice
WHERE (fkServiceId = @.ServiceId )
AND (userValue = @.userValue) AND (fkUserId < @.UserId or fkUserId > @.UserId)
END
--Is unique not lowest
ELSE IF ((@.LowestUnique < @.userValue) AND @.NumberAtValue = 1)
BEGIN
PRINT 'Is unique not lowest'
SET @.IsUnique = 1
END
ELSE
BEGIN
PRINT 'Is not unique'
SET @.IsUnique = 0
END
SELECT
@.IsUnique AS IsUnique,
@.IsLowestUnique AS IsLowestUnique,
@.previousUserAtValue as PreviousUserAtValueAndy Furnival (AndyFurnival@.discussions.microsoft.com) writes:
> I've come to a point in redesigning a database that is basically the
> reason we chose to redesign it is for International support and to rid
> the db and application code of permitting dirty reads against the
> database. However, I'm at the point where I just cannot find a suitable
> solution other than to still permit dirty reads due to the nature of the
> service the db provides.
>...

> CREATE TABLE [dbo].[UserChoice]
> (
> [userChoiceId] [int] IDENTITY(1,1) NOT NULL,
> [fkUserId] [int] NULL,
> [fkServiceId] [int] NULL,
> [userValue] [int] NULL,
> CONSTRAINT [PK_UserChoice] PRIMARY KEY CLUSTERED
> (
> [userChoiceId] ASC
> )
> )
I realize that there may be more to the system than you show here, but
judging from the procedure UserChoiceInsert, this table should really
look like:
CREATE TABLE [dbo].[UserChoice]
(
[fkServiceId] [int] NOT NULL,
[userValue] [int] NOT NULL,
[fkUserId] [int] NOT NULL,
CONSTRAINT [PK_UserChoice] PRIMARY KEY CLUSTERED
(
[fkServiceId, userValue, fkUserId] ASC
)
)
That is, these three colunms are are unique, and it appears that it
makes no sense for them to permit NULL.
But what is more important is that with an index on (fkServiceId,
userValue), you can reduce the possibilities for deadlocks considerably.
Your queries now scan the tables several times, which is not good at
all. If two users insert the value for the same service ID simultaneous,
there is still a risk have a risk for deadlocks. One way to avoid this
is to move and modify where you compute @.NumberAtValue:
SELECT @.NumberAtValue = COUNT(*) + 1
FROM UserChoice WITH (UPDLOCK)
WHERE fkServiceID = @.serviceid
AND userValue = @.userValue
The UPDLOCK is shared lock, that only one process at a time can have.
Thus if two users tries into insert the same @.serviceId, userValue at
the same time, one will be held up, until the other commits.

> SET @.previousLowestUnique = (
> SELECT TOP 1 userValue
> FROM UserChoice
> WHERE (fkServiceId = @.ServiceId)
> GROUP BY userValue
> Having Count(userValue) = 1)
You need an ORDER BY here, or else you will just get any unique value.

> INSERT INTO UserChoice
> (
> fkUserId,
> fkServiceId,
> userValue
> )
> VALUES
> (
> @.UserId,
> @.ServiceId,
> @.userValue
> )
Save the insert to the end of the procedure and the transaction. This
means that you reduce the amount of time you hold locks. You would of
course have to modify the logic for this.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Wednesday, March 7, 2012

maximum databases no.

hi,
I would like to hear from you guys how many databases (maximum number)
did you reach on a single server.
We are trying to work with a few hundreds of databases at the same
time, and we get weird errors or problems, even with low load on these
databases.
I would like to hear from your experience and maybe get leads to
material on the subject.
I'm aware of the official limits (http://technet.microsoft.com/en-us/
library/ms143432(SQL.90).aspx) but in reality the numbers are much
lower.
I don't have any problems with over 500 databases on two different
production systems.
Of course, I took painstaking efforts to make sure the systems were designed
to really treat the databases as independently as possible.
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
<yaniv.harpaz@.gmail.com> wrote in message
news:1181232580.249349.26550@.q69g2000hsb.googlegro ups.com...
> hi,
> I would like to hear from you guys how many databases (maximum number)
> did you reach on a single server.
> We are trying to work with a few hundreds of databases at the same
> time, and we get weird errors or problems, even with low load on these
> databases.
> I would like to hear from your experience and maybe get leads to
> material on the subject.
> I'm aware of the official limits (http://technet.microsoft.com/en-us/
> library/ms143432(SQL.90).aspx) but in reality the numbers are much
> lower.
>
|||I have a client with 6400+ databases on a single relatively low-end cluster
(2 dual core AMD 64 bit CPUs, 8GB ram, VERY low-end drive system). These
same databases are log-shipped (custom-code, not built in) to an even
wimpier stand alone server for reporting purposes. Issues include:
1) Most automated tools break down. These include automated
monitoring/backup apps as well as tools like DBArtisan, which simply barf at
the extreme amount of system information they try to chew through.
2) Log-shipping/mirroring/replication become essentially non-useable too in
my experience.
3) Automation of things like rollouts, maintanence, etc are a must to keep
your sanity. I had a developer build what I call a "database shotgun" that
uses between 10 and 20 threads to concurrently run scripts against multiple
databases at a time. Stuff that takes ms_foreachdb tens of minutes to
complete now complete in a few minutes.
4) msdb will get huge. plan for this by expanding the data and log file
sizes ahead of time to avoid fragmentation. Set up jobs to flush old
history records for job runs/backups as appropriate.
Not sure about the 'wierd errors or problems' you are receiving. Any
examples?
TheSQLGuru
President
Indicium Resources, Inc.
<yaniv.harpaz@.gmail.com> wrote in message
news:1181232580.249349.26550@.q69g2000hsb.googlegro ups.com...
> hi,
> I would like to hear from you guys how many databases (maximum number)
> did you reach on a single server.
> We are trying to work with a few hundreds of databases at the same
> time, and we get weird errors or problems, even with low load on these
> databases.
> I would like to hear from your experience and maybe get leads to
> material on the subject.
> I'm aware of the official limits (http://technet.microsoft.com/en-us/
> library/ms143432(SQL.90).aspx) but in reality the numbers are much
> lower.
>
|||with 64-bit 8GB memory I got connection timeouts after going over 200
connections
I got very efficient queries starting to take 10 minutes instead of 2
seconds (without having high load on the DB server)
|||yaniv.harpaz@.gmail.com wrote:
> with 64-bit 8GB memory I got connection timeouts after going over 200
> connections
> I got very efficient queries starting to take 10 minutes instead of 2
> seconds (without having high load on the DB server)
I have to second yaniv's experience with sql2005 - with time it becomes
much more brittle than Sql2000.

maximum databases no.

hi,
I would like to hear from you guys how many databases (maximum number)
did you reach on a single server.
We are trying to work with a few hundreds of databases at the same
time, and we get weird errors or problems, even with low load on these
databases.
I would like to hear from your experience and maybe get leads to
material on the subject.
I'm aware of the official limits (http://technet.microsoft.com/en-us/
library/ms143432(SQL.90).aspx) but in reality the numbers are much
lower.I don't have any problems with over 500 databases on two different
production systems.
Of course, I took painstaking efforts to make sure the systems were designed
to really treat the databases as independently as possible.
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
<yaniv.harpaz@.gmail.com> wrote in message
news:1181232580.249349.26550@.q69g2000hsb.googlegroups.com...
> hi,
> I would like to hear from you guys how many databases (maximum number)
> did you reach on a single server.
> We are trying to work with a few hundreds of databases at the same
> time, and we get weird errors or problems, even with low load on these
> databases.
> I would like to hear from your experience and maybe get leads to
> material on the subject.
> I'm aware of the official limits (http://technet.microsoft.com/en-us/
> library/ms143432(SQL.90).aspx) but in reality the numbers are much
> lower.
>|||I have a client with 6400+ databases on a single relatively low-end cluster
(2 dual core AMD 64 bit CPUs, 8GB ram, VERY low-end drive system). These
same databases are log-shipped (custom-code, not built in) to an even
wimpier stand alone server for reporting purposes. Issues include:
1) Most automated tools break down. These include automated
monitoring/backup apps as well as tools like DBArtisan, which simply barf at
the extreme amount of system information they try to chew through.
2) Log-shipping/mirroring/replication become essentially non-useable too in
my experience.
3) Automation of things like rollouts, maintanence, etc are a must to keep
your sanity. I had a developer build what I call a "database shotgun" that
uses between 10 and 20 threads to concurrently run scripts against multiple
databases at a time. Stuff that takes ms_foreachdb tens of minutes to
complete now complete in a few minutes.
4) msdb will get huge. plan for this by expanding the data and log file
sizes ahead of time to avoid fragmentation. Set up jobs to flush old
history records for job runs/backups as appropriate.
Not sure about the 'wierd errors or problems' you are receiving. Any
examples?
TheSQLGuru
President
Indicium Resources, Inc.
<yaniv.harpaz@.gmail.com> wrote in message
news:1181232580.249349.26550@.q69g2000hsb.googlegroups.com...
> hi,
> I would like to hear from you guys how many databases (maximum number)
> did you reach on a single server.
> We are trying to work with a few hundreds of databases at the same
> time, and we get weird errors or problems, even with low load on these
> databases.
> I would like to hear from your experience and maybe get leads to
> material on the subject.
> I'm aware of the official limits (http://technet.microsoft.com/en-us/
> library/ms143432(SQL.90).aspx) but in reality the numbers are much
> lower.
>|||with 64-bit 8GB memory I got connection timeouts after going over 200
connections
I got very efficient queries starting to take 10 minutes instead of 2
seconds (without having high load on the DB server)|||yaniv.harpaz@.gmail.com wrote:
> with 64-bit 8GB memory I got connection timeouts after going over 200
> connections
> I got very efficient queries starting to take 10 minutes instead of 2
> seconds (without having high load on the DB server)
I have to second yaniv's experience with sql2005 - with time it becomes
much more brittle than Sql2000.

maximum databases no.

hi,
I would like to hear from you guys how many databases (maximum number)
did you reach on a single server.
We are trying to work with a few hundreds of databases at the same
time, and we get weird errors or problems, even with low load on these
databases.
I would like to hear from your experience and maybe get leads to
material on the subject.
I'm aware of the official limits (http://technet.microsoft.com/en-us/
library/ms143432(SQL.90).aspx) but in reality the numbers are much
lower.I don't have any problems with over 500 databases on two different
production systems.
Of course, I took painstaking efforts to make sure the systems were designed
to really treat the databases as independently as possible.
--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
<yaniv.harpaz@.gmail.com> wrote in message
news:1181232580.249349.26550@.q69g2000hsb.googlegroups.com...
> hi,
> I would like to hear from you guys how many databases (maximum number)
> did you reach on a single server.
> We are trying to work with a few hundreds of databases at the same
> time, and we get weird errors or problems, even with low load on these
> databases.
> I would like to hear from your experience and maybe get leads to
> material on the subject.
> I'm aware of the official limits (http://technet.microsoft.com/en-us/
> library/ms143432(SQL.90).aspx) but in reality the numbers are much
> lower.
>|||I have a client with 6400+ databases on a single relatively low-end cluster
(2 dual core AMD 64 bit CPUs, 8GB ram, VERY low-end drive system). These
same databases are log-shipped (custom-code, not built in) to an even
wimpier stand alone server for reporting purposes. Issues include:
1) Most automated tools break down. These include automated
monitoring/backup apps as well as tools like DBArtisan, which simply barf at
the extreme amount of system information they try to chew through.
2) Log-shipping/mirroring/replication become essentially non-useable too in
my experience.
3) Automation of things like rollouts, maintanence, etc are a must to keep
your sanity. I had a developer build what I call a "database shotgun" that
uses between 10 and 20 threads to concurrently run scripts against multiple
databases at a time. Stuff that takes ms_foreachdb tens of minutes to
complete now complete in a few minutes.
4) msdb will get huge. plan for this by expanding the data and log file
sizes ahead of time to avoid fragmentation. Set up jobs to flush old
history records for job runs/backups as appropriate.
Not sure about the 'wierd errors or problems' you are receiving. Any
examples?
--
TheSQLGuru
President
Indicium Resources, Inc.
<yaniv.harpaz@.gmail.com> wrote in message
news:1181232580.249349.26550@.q69g2000hsb.googlegroups.com...
> hi,
> I would like to hear from you guys how many databases (maximum number)
> did you reach on a single server.
> We are trying to work with a few hundreds of databases at the same
> time, and we get weird errors or problems, even with low load on these
> databases.
> I would like to hear from your experience and maybe get leads to
> material on the subject.
> I'm aware of the official limits (http://technet.microsoft.com/en-us/
> library/ms143432(SQL.90).aspx) but in reality the numbers are much
> lower.
>|||with 64-bit 8GB memory I got connection timeouts after going over 200
connections
I got very efficient queries starting to take 10 minutes instead of 2
seconds (without having high load on the DB server)|||yaniv.harpaz@.gmail.com wrote:
> with 64-bit 8GB memory I got connection timeouts after going over 200
> connections
> I got very efficient queries starting to take 10 minutes instead of 2
> seconds (without having high load on the DB server)
I have to second yaniv's experience with sql2005 - with time it becomes
much more brittle than Sql2000.

maximum Data flow tasks execution

Hi guys,

i got a foreach loop that has about 20 data flow tasks(same database connections but different extractions) but i notice that when i execute the project it only runs 4 data flow tasks at a time.

i know that there is an option for each data flow to set the "Engine Threads", but is there a way to set the thereads in a foreach loop or for the whole project so it will execute all data flow tasks in one go for each loop.

please help?

Here is a interesting document that talks about: Integration Services: Performance Tuning Techniques that may be helpful to understand how to get better performance.

http://www.microsoft.com/technet/prodtechnol/sql/2005/ssisperf.mspx

BTW what kind of hardaware do you have? wanting to run 20 data flow tasks in parallel sounds somehow unrealistic to me.

Rafael Salas

|||

Thanks for the post Rafael,

hmm, it wasn't exactly what i was looking for but it certainly gave me a good knowledge SSIS performance tuning.

the examplease that they had they were all in side data flows tasks, my problem sort of lies outside, inside a foreach loop. why it's only running 4 tasks at a time, there must be a counter somewhere.

but your link sort of gave me an idea of doing the extraction in another way. but it's going to be a lot of work, since i've already made my project.

you see what i'm doing is, i'm doing an overnight extract from the main datasbase to my data warehouse, has 20 scripts (all different sources and different destination). the reason it's inside a forloop is i've got many database sources that uses the same scripts to extract data.

the destination sql server is pretty good (SSIS runs on). it's a XEON 2 CPUs with 4gb RAM. resources is not an issue, well at least i think it's not. even if it's not enough i can get more CPUs and RAM to it, to get the job done faster.

cheers

AJ