Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Worked in SQL Server 2005, doesn't in 2008

 
   Database Help (Home) -> Programming RSS
Next:  SQL question  
Author Message
Ed White

External


Since: Aug 28, 2007
Posts: 21



(Msg. 1) Posted: Mon Aug 18, 2008 5:54 pm
Post subject: Worked in SQL Server 2005, doesn't in 2008
Archived from groups: microsoft>public>sqlserver>programming (more info?)

I recently upgraded from SQL Server 2005 to SQL Server 2008, and I've found a
couple commands worked in 2005 but don't in 2008. Here is one annoying
example:
DELETE FROM [Groups];

INSERT INTO [Groups] ([Ticker]
,[HiLowMktCapGrp])

SELECT p.Ticker,

CASE
WHEN r.[Mkt Cap] >= (SELECT MIN([Mkt Cap]) 'Min' FROM (SELECT TOP 45 PERCENT
[Mkt Cap] FROM [RLSP0 Pivot] WHERE [Mkt Cap] IS NOT NULL ORDER BY [Mkt Cap]
DESC) x) THEN 'HiCap'
WHEN r.[Mkt Cap] <= (SELECT MIN([Mkt Cap]) 'Min' FROM (SELECT TOP 55 PERCENT
[Mkt Cap] FROM [RLSP0 Pivot] WHERE [Mkt Cap] IS NOT NULL ORDER BY [Mkt Cap]
DESC) x) THEN 'LoCap'
ELSE CASE p.[TkrType] WHEN 1 THEN NULL WHEN 2 THEN NULL ELSE 'N.A.' END END
AS HiLowMktCapGrp

FROM dbo.[RW Data] AS r RIGHT OUTER JOIN [Parent] p ON r.[Ticker] = p.[Ticker]

If I comment out the DELETE and INSERT statements, leaving just the SELECT
command, it returns the valid data that I want inserted into the table.
However, when I run the command with the DELETE and INSERT statements not
commented out, and then look at the contents of the Groups table, the
HiLowMktCapGrp has mostly NULLs (i.e. not the same data as the SELECT command
only returns). Further, this command worked correctly before I upgraded to
the 2008 version.

If I modify the code by taking out the "(SELECT ..." statements after the
WHENs, and run it, i.e.
DELETE FROM [Groups];

INSERT INTO [Groups] ([Ticker]
,[HiLowMktCapGrp])

SELECT p.Ticker,

CASE
WHEN r.[Mkt Cap] >= 1620 THEN 'HiCap'
WHEN r.[Mkt Cap] <= 1140 THEN 'LoCap'
ELSE CASE p.[TkrType] WHEN 1 THEN NULL WHEN 2 THEN NULL ELSE 'N.A.' END END
AS HiLowMktCapGrp

FROM dbo.[RW Data] AS r RIGHT OUTER JOIN [Parent] p ON r.[Ticker] = p.[Ticker]

, then it provides the correct results. So, apparently, the new 2008 SQL
Server doesn't recognize the SELECT statements after the WHEN clauses in my
SQL.

Incidentally, if I run the SELECT commands after the WHEN clauses
separately, i.e.
(SELECT MIN([Mkt Cap]) 'Min' FROM (SELECT TOP 45 PERCENT [Mkt Cap] FROM
[RLSP0 Pivot] WHERE [Mkt Cap] IS NOT NULL ORDER BY [Mkt Cap] DESC) x);
(SELECT MIN([Mkt Cap]) 'Min' FROM (SELECT TOP 55 PERCENT [Mkt Cap] FROM
[RLSP0 Pivot] WHERE [Mkt Cap] IS NOT NULL ORDER BY [Mkt Cap] DESC) x)

it correctly returns 1620 and 1140 as expected.
--
Ed

 >> Stay informed about: Worked in SQL Server 2005, doesn't in 2008 
Back to top
Login to vote
Charles Wang [MSFT]

External


Since: Apr 18, 2008
Posts: 268



(Msg. 2) Posted: Tue Aug 19, 2008 7:24 am
Post subject: RE: Worked in SQL Server 2005, doesn't in 2008 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Ed,
Thank you for reporting this issue.

I understand that your concern was that there were so many NULL values inserted into the table Group, though there should not be any NULL here.
If I have misunderstood, please let me know.

Based on your script, I performed a test by creating the same tables, adding some test records, and executing your query statement:
=============================
DELETE FROM [Groups];

INSERT INTO [Groups] ([Ticker]
,[HiLowMktCapGrp])

SELECT p.Ticker,

CASE
WHEN r.[Mkt Cap] >= (SELECT MIN([Mkt Cap]) 'Min' FROM (SELECT TOP 45 PERCENT
[Mkt Cap] FROM [RLSP0 Pivot] WHERE [Mkt Cap] IS NOT NULL ORDER BY [Mkt Cap]
DESC) x) THEN 'HiCap'
WHEN r.[Mkt Cap] <= (SELECT MIN([Mkt Cap]) 'Min' FROM (SELECT TOP 55 PERCENT
[Mkt Cap] FROM [RLSP0 Pivot] WHERE [Mkt Cap] IS NOT NULL ORDER BY [Mkt Cap]
DESC) x) THEN 'LoCap'
ELSE CASE p.[TkrType] WHEN 1 THEN NULL WHEN 2 THEN NULL ELSE 'N.A.' END END
AS HiLowMktCapGrp

FROM dbo.[RW Data] AS r RIGHT OUTER JOIN [Parent] p ON r.[Ticker] = p.[Ticker]
===============================
However it successfully completed. After that I executed "SELECT * FROM Groups" and there are no NULL values in the table.

To let me reproduce your issue, could you please mail me (changliw_at_microsoft_dot_com) a test database for reproducing your issue? Appreciate your understanding that it is hard for us to
perform further research if we could not reproduce your issue on this.

If you have any other questions or concerns, please feel free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg.TakeThisOut@microsoft.com.
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx...tificat

Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================

 >> Stay informed about: Worked in SQL Server 2005, doesn't in 2008 
Back to top
Login to vote
Ed White

External


Since: Aug 28, 2007
Posts: 21



(Msg. 3) Posted: Tue Aug 19, 2008 1:44 pm
Post subject: RE: Worked in SQL Server 2005, doesn't in 2008 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Strangely, I'm not having the problem again today. I did find one issue with
some coding that may have contributed to the problem, but I could have sworn
that yesterday when I commented out the DELETE and INSERT commands, the
remaining SELECT statement provided values that the INSERT command did not
insert when not commented out. Anyway, I'll keep looking into it, and if I
have the problem again, I will let you know.
--
Ed


""Charles Wang [MSFT]"" wrote:

> Hi Ed,
> Thank you for reporting this issue.
>
> I understand that your concern was that there were so many NULL values inserted into the table Group, though there should not be any NULL here.
> If I have misunderstood, please let me know.
>
> Based on your script, I performed a test by creating the same tables, adding some test records, and executing your query statement:
> =============================
> DELETE FROM [Groups];
>
> INSERT INTO [Groups] ([Ticker]
> ,[HiLowMktCapGrp])
>
> SELECT p.Ticker,
>
> CASE
> WHEN r.[Mkt Cap] >= (SELECT MIN([Mkt Cap]) 'Min' FROM (SELECT TOP 45 PERCENT
> [Mkt Cap] FROM [RLSP0 Pivot] WHERE [Mkt Cap] IS NOT NULL ORDER BY [Mkt Cap]
> DESC) x) THEN 'HiCap'
> WHEN r.[Mkt Cap] <= (SELECT MIN([Mkt Cap]) 'Min' FROM (SELECT TOP 55 PERCENT
> [Mkt Cap] FROM [RLSP0 Pivot] WHERE [Mkt Cap] IS NOT NULL ORDER BY [Mkt Cap]
> DESC) x) THEN 'LoCap'
> ELSE CASE p.[TkrType] WHEN 1 THEN NULL WHEN 2 THEN NULL ELSE 'N.A.' END END
> AS HiLowMktCapGrp
>
> FROM dbo.[RW Data] AS r RIGHT OUTER JOIN [Parent] p ON r.[Ticker] = p.[Ticker]
> ===============================
> However it successfully completed. After that I executed "SELECT * FROM Groups" and there are no NULL values in the table.
>
> To let me reproduce your issue, could you please mail me (changliw_at_microsoft_dot_com) a test database for reproducing your issue? Appreciate your understanding that it is hard for us to
> perform further research if we could not reproduce your issue on this.
>
> If you have any other questions or concerns, please feel free to let me know.
>
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> ===========================================================
> Delighting our customers is our #1 priority. We welcome your
> comments and suggestions about how we can improve the
> support we provide to you. Please feel free to let my manager
> know what you think of the level of service provided. You can
> send feedback directly to my manager at: msdnmg.RemoveThis@microsoft.com.
> ===========================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx...tificat
>
> Note: The MSDN Managed Newsgroup support offering is for
> non-urgent issues where an initial response from the community
> or a Microsoft Support Engineer within 1 business day is acceptable.
> Please note that each follow up response may take approximately
> 2 business days as the support professional working with you may
> need further investigation to reach the most efficient resolution.
> The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by
> contacting Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ============================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
> =========================================================
>
>
>
>
 >> Stay informed about: Worked in SQL Server 2005, doesn't in 2008 
Back to top
Login to vote
Charles Wang [MSFT]

External


Since: Apr 18, 2008
Posts: 268



(Msg. 4) Posted: Wed Aug 20, 2008 2:04 am
Post subject: RE: Worked in SQL Server 2005, doesn't in 2008 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Ed,
Thank you for letting me know this.

Welcome your posting back if you encounter this issue again. Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg.RemoveThis@microsoft.com.
=========================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================
 >> Stay informed about: Worked in SQL Server 2005, doesn't in 2008 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Iterating XML in SQL Server 2005 (or 2008) stored procedure - I need to update add rows in a table from the UI. Rather that call my AddData stored proc 3 times to save 3 rows of data, I'd rather wrap the data in XML and pass this to the stored proc. Then, I'd like to iterate the XML block and perform 3 INSERTs. How...

SQl 2005/Visual Basic 2008 - Please excuse my ignorance, as I'm not overly with the inner workings of SQL, nor do I know programming very well. I've been given the task of taking all of the data from a table on our sql 2005 server, exporting it, and importing it into a SQl 2005....

SQL Server 2008 .... CLR question - Does anyone know what version of the .NET Framework will be supported in SQL Server 2008??? Will it still be v2.0 (hopefully, it will be the current v3.5) Thanks in advance -- Stay Mobile

SQL Server 2008 models question. - Does anyone here know (an MVP perhaps), whether SQL Server 2008 will be released in "Desktop Engine" format and if so, what the limits on that might be? We had 2Gb limit with 2000, 4Gb limit with 2005 and I'm hoping for an 8Gb limit with 20...

SQL Server 2008 Geometry Library - We have developed an application that uses the geometry libraries that are part of the SQL Server 2008. We would like to know the legal aspects of this use of the libraries. We are only using the geometry libraries, no other functions of the SQL Server..
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]