Showing posts with label bug. Show all posts
Showing posts with label bug. Show all posts

Monday, March 26, 2012

PPV's, Loops & Child Packages - Bug or By Design

It would appear that if a Child package is called more than once from a Parent using the 'Execute Package' task, then after the first execute the Parent Package Variables are not applied to child package. I.E we build dimensions in a master database and these are then loaded to a number of topic specific datamarts. We simply pass Parent variables to the child that hold source & target connection strings, the first time the package is called the correct database is accessed, subsequent Executes ignore the variables and use the original values. Manipulating the (our) event queue to run the package once results in the correct behaviour

Are packages cached when they are called from a Parent? if so is there a flag that I have missed to force a reload each time a child is executed?

This has just become a big problen for us so any guidance would greatly appreciated.

Paul

I have not come across this problem before. I suggest opening a support issue for this - it will likely need some debugging.

How are you calling the child package multiple times? In a loop?

Donald

|||

Our master package is data driven, from a database.

Dimensions are build / modified in a Master database and then are moved into a number of topic specific datamarts. A dimension like CALENDAR natutally resides in most datamarts, we have a series of packages (one per Dimension) that are reponsible for moving new/changed data to the datamart (they are lightening quick). The child packages take 2 Parent variables SourceConnectionString and TargetConnectionString, these child packages are called from the parent package using the 'Execute Package' task.

This approach has worked well untill we got to serious testing of the system. When the Parent package runs properly it is quite likely that the calendar will move to several places in one execution. The first call to the Child package uses the parent variables correctly, subsequent calls to the child (event if 10 or 15 other packages have been called in the meantime) ignore the new settings of the variables and continue to adress the first datamart setting, consequently we have missing rows, the package does not fail, so the dependancy is met (we have dependacy info in our metadata) and the the Fact build crashes due to missing rows.

This serious stuff for us, we aim to go live at the end of this month

I too may have to hand over the armband....

Paul

|||

I do think you'll need to open a support call for the original issue.

However, I wonder if you could work around this. One way may be to use a different configuration type, such as SQL Server, or registry setting or environment variable.

Your master package could use a script to write out the value to that location and child packages would pick it up from there.

This would be very similar to using the parameter files that other ETL tools use for these scenarios.

Donald

If you do have to hand over the armband, try not to cry about it on TV.

|||

Sorry, my fault.

The orginal version of the package was using Event Handlers, I removed these some time ago, but missed one which was setting an action as complete. So no bug in SSIS just my carlessness.

Just a thought, it would be really nice if icons on the design surface had some indication that and Event Handler was lurking underneath.

Paul

|||

Fantastic idea. You should log it at Microsoft Connect.

It would also be great if there were a visual clue that properties had expressions on them!

-Jamie

Monday, March 12, 2012

possibly merge join bug?

i'm merge joining 2 data sources, one is oracle and the other is excel...the problem is in the oracle source, it's a sql statement like:

select hdr.div_ord_no, hdr.mtr_no, hdr.prod_cd
from qctrl_div_ord_header hdr,
(select max(sub.eff_dt_from) min_eff_dt_from, div_ord_no
from qctrl_div_ord_header sub
group by div_ord_no
) tmp
where hdr.eff_dt_from = tmp.min_eff_dt_from
and hdr.div_ord_no = tmp.div_ord_no

having that sql statement, merging will come out with 0 rows

however, having a simple query like:

select hdr.div_ord_no, hdr.mtr_no, hdr.prod_cd
from qctrl_div_ord_header hdr

merging will come out with 2 rows

you may think that the data in the first sql statement is not there for the merge, which causing the 0 rows, however, the data is there, i'm only joining by one column and definitely the data is there, the merge result should be 2 rows for both query statements

i believe this is a problem with SSIS, anyway around this?

Are the inputs to the MERGE JOIN sorted? I is a requirement that they are for MERGE JOIN to work correctly.

Note that setting IsSorted=Yes on the input does not mean that the data gets sorted for you!

-Jamie

|||yes, the input are sorted, everything should be setup correctly, hence, i got the merge to run and work as expected with the simple query

Wednesday, March 7, 2012

Possible SQL Bug with clustered indexes and DOP > 1

Hi there,
I think I have identified a possible bug in MS-SQL 2K....
The information below has been obfuscated for provacy reasons, however
the principal is the same...
I have a table which has several fields (nothing interesting). The
table has approx 1M rows. One of the fields [HR_POSITION] is of
datatype varchar(2).
I create a clustered index using several of the fields with
[HR_POSITION] at the top of the clustered index. Lets say the possible
values of [HR_POSITION] are 'L1', 'L2', 'L3', 'L4', 'L5'.
I issue a simple SELECT query as follows:-
SELECT [HR_POSITION],
[FIELD1],
[FIELD2],
[FIELD3],
[FIELD4],
[FIELD5],
[FIELD6],
[FIELD7],
[FIELD8],
[FIELD9],
[FIELD10]
from TABLE_BROKEN
WHERE [FIELD1] = 'Hello'
and [HR_POSITION] != 'L1'
ORDER BY [HR_POSITION]
Believe it or not I get L1 values in the field [HR_POSITION] in the
result set. If include the OPTION (MAXDOP 1) at the end I get a
different result set which appears to be accurate.
Has nay one seen this before, is it documented, am I the first, do I
get a free T-Shirt?
I have replicated the bug on three different machines and have
discussed it with our team here, and no one can seem to come with an
answer.
We are running MS-SQL 2K Enterprise Sp3a, on Win2K Sp4<justin.parry-okeden@.cba.com.au> wrote in message
news:1137382255.509303.42040@.g14g2000cwa.googlegroups.com...
> Hi there,
> I think I have identified a possible bug in MS-SQL 2K....
> The information below has been obfuscated for provacy reasons, however
> the principal is the same...
> I have a table which has several fields (nothing interesting). The
> table has approx 1M rows. One of the fields [HR_POSITION] is of
> datatype varchar(2).
> I create a clustered index using several of the fields with
> [HR_POSITION] at the top of the clustered index. Lets say the possible
> values of [HR_POSITION] are 'L1', 'L2', 'L3', 'L4', 'L5'.
> I issue a simple SELECT query as follows:-
> SELECT [HR_POSITION],
> [FIELD1],
> [FIELD2],
> [FIELD3],
> [FIELD4],
> [FIELD5],
> [FIELD6],
> [FIELD7],
> [FIELD8],
> [FIELD9],
> [FIELD10]
> from TABLE_BROKEN
> WHERE [FIELD1] = 'Hello'
> and [HR_POSITION] != 'L1'
> ORDER BY [HR_POSITION]
> Believe it or not I get L1 values in the field [HR_POSITION] in the
> result set. If include the OPTION (MAXDOP 1) at the end I get a
> different result set which appears to be accurate.
> Has nay one seen this before, is it documented, am I the first, do I
> get a free T-Shirt?
> I have replicated the bug on three different machines and have
> discussed it with our team here, and no one can seem to come with an
> answer.
> We are running MS-SQL 2K Enterprise Sp3a, on Win2K Sp4
>
Is it this issue?
http://support.microsoft.com/kb/814509/en-us
Can you replicate the issue on SQL 2000 SP4?
David|||Hi there David,
After extensive testing last night I came to the following
conclusions...
(*) If I change the datatype of the first member in the list of fields
for the index to a char from a varchar the bug goes away
(*) If I leave the datatype of the first member in the list of fields
for the index as varchar but set the last member of the list to not
nullable the bug goes away.
(*) If I don't change anything and apply sp4 the bug goes away.
I think there is at least two VERY NASTY bugs going on here which have
been addressed in some capacity in SP4.
JPO

Saturday, February 25, 2012

Possible DTS File Import Bug

Env: SQL Server 2000 on in WIN NT 5.x
Job: import mutiple flat files into several tables daily.
Catch: one or two of the several flat files might be empty.

First thought/test:
Use [first row as fields] option for the import process.
Problem, DTS can't complete (as a package).

As an alternative, I could probably detect if a file is empty then
decide what to do with it, with VB activeX, it might be feasible,
question, VB has a command for "FileExist", how about "FileLen" or the
like for determining the length of a file?

TIA.Hi

See http://www.sqldts.com/default.aspx?292 and
http://www.sqldts.com/default.aspx?246

John

"NickName" <dadada@.rock.com> wrote in message
news:1102971903.347486.145350@.f14g2000cwb.googlegr oups.com...
> Env: SQL Server 2000 on in WIN NT 5.x
> Job: import mutiple flat files into several tables daily.
> Catch: one or two of the several flat files might be empty.
> First thought/test:
> Use [first row as fields] option for the import process.
> Problem, DTS can't complete (as a package).
> As an alternative, I could probably detect if a file is empty then
> decide what to do with it, with VB activeX, it might be feasible,
> question, VB has a command for "FileExist", how about "FileLen" or the
> like for determining the length of a file?
> TIA.|||Very helpful. Thank you.|||Very helpful. Thank you. However, activeX problem, error obj "string
C:\myDir\file1.csv" required, the code seems to be correct.

' File Size
' check file size if empty | 0 quit

Option Explicit

Function Main()

Dim oFSO
Dim oFile
Dim sSourceFile

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set sSourceFile = "C:\myDir\file1.csv"

Set sSourceFileV = sSourceFile.Value

Set oFile = oFSO.GetFile(sSourceFileV)

If oFile.Size > 0 Then
Main = DTSTaskExecResult_Success
Else
Main = DTSTaskExecResult_Failure
End If
' Clean Up
Set oFile = Nothing
Set oFSO = Nothing
End Function|||Never mind about the activeX error, the objFile.Value attribute was
unnecessary. But the "connectors" does not seem to have an option to
connect this ActiveX script with a package and making sure run the
ActiveX script first, instead of last.

TIA.|||Hi

You can use workflow to govern the order of the steps, if you had one or
more files to process then you can use the looping example
http://www.sqldts.com/default.aspx?246, although I would expect a three way
split for in the shouldILoop procedure or a second comparison step to cater
for files with size, files with no size and no files to process.

In your code sSourceFileV is not needed, use
Set oFile = oFSO.GetFile(sSourceFile)

John

"NickName" <dadada@.rock.com> wrote in message
news:1103038306.437005.86870@.f14g2000cwb.googlegro ups.com...
> Very helpful. Thank you. However, activeX problem, error obj "string
> C:\myDir\file1.csv" required, the code seems to be correct.
> ' File Size
> ' check file size if empty | 0 quit
> Option Explicit
> Function Main()
> Dim oFSO
> Dim oFile
> Dim sSourceFile
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set sSourceFile = "C:\myDir\file1.csv"
> Set sSourceFileV = sSourceFile.Value
> Set oFile = oFSO.GetFile(sSourceFileV)
> If oFile.Size > 0 Then
> Main = DTSTaskExecResult_Success
> Else
> Main = DTSTaskExecResult_Failure
> End If
> ' Clean Up
> Set oFile = Nothing
> Set oFSO = Nothing
> End Function|||Hi

You can use workflow to determine the order of execution.

John

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Possible BUG: SP2 Printing Linked Reports in Report Manager

Hello,
I may have discovered a possible bug with the new SP2 Client Printing
capabilities.
To reproduce:
1) Create a report with margins of 0.3in top, left, bottom and right, and
page size of 8.5 x 11 (standard US letter size)
2) Deploy the report to Report Manager
3) Confirm that client printing respects margins set in report. Click on
the print button, click on Print Preview, click on Margins, you should now
see 0.3in margins all around
4) Create a linked report by going to Properties and clicking Create Link
Report button.
5) Click on the print button, click on Print Preview, click on Margins, you
should now see 0.5in margins all around, instead of 0.3in. This does not
occur while exporting linked report to PDF format.
I confirmed this behaviour numerous times, and it's not only with margin but
also with page-layout. Is there a work-around?
Many thanks,
EdgarThe work around is to call SetProperties for the linked report, setting the
PageHeight, PageWidth, TopMargin, BottomMargin, LeftMargin and RightMargin
to the values you wish. All values should be expressed in mm.
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.
"Edgar Allik" <Edgar Allik@.discussions.microsoft.com> wrote in message
news:0F3C537B-ECBF-4B69-BCE3-BFF8143B7BED@.microsoft.com...
> Hello,
> I may have discovered a possible bug with the new SP2 Client Printing
> capabilities.
> To reproduce:
> 1) Create a report with margins of 0.3in top, left, bottom and right, and
> page size of 8.5 x 11 (standard US letter size)
> 2) Deploy the report to Report Manager
> 3) Confirm that client printing respects margins set in report. Click on
> the print button, click on Print Preview, click on Margins, you should now
> see 0.3in margins all around
> 4) Create a linked report by going to Properties and clicking Create Link
> Report button.
> 5) Click on the print button, click on Print Preview, click on Margins,
> you
> should now see 0.5in margins all around, instead of 0.3in. This does not
> occur while exporting linked report to PDF format.
> I confirmed this behaviour numerous times, and it's not only with margin
> but
> also with page-layout. Is there a work-around?
> Many thanks,
> Edgar
>|||Hi, I am also experiencing the same error in SP2 where the page layout
properties don't seem to be set as they should be in a linked report.
I'm presuming "call SetProperties" is done via code - is there a work
around or way of doing this via Report Manager to fix this problem?
I'm not using any code with my reports, just URL access.
Thanks
Jeanine
Daniel Reib (MSFT) wrote:
> The work around is to call SetProperties for the linked report,
setting the
> PageHeight, PageWidth, TopMargin, BottomMargin, LeftMargin and
RightMargin
> to the values you wish. All values should be expressed in mm.
> -Daniel
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> "Edgar Allik" <Edgar Allik@.discussions.microsoft.com> wrote in
message
> news:0F3C537B-ECBF-4B69-BCE3-BFF8143B7BED@.microsoft.com...
> > Hello,
> >
> > I may have discovered a possible bug with the new SP2 Client
Printing
> > capabilities.
> >
> > To reproduce:
> > 1) Create a report with margins of 0.3in top, left, bottom and
right, and
> > page size of 8.5 x 11 (standard US letter size)
> > 2) Deploy the report to Report Manager
> > 3) Confirm that client printing respects margins set in report.
Click on
> > the print button, click on Print Preview, click on Margins, you
should now
> > see 0.3in margins all around
> > 4) Create a linked report by going to Properties and clicking
Create Link
> > Report button.
> > 5) Click on the print button, click on Print Preview, click on
Margins,
> > you
> > should now see 0.5in margins all around, instead of 0.3in. This
does not
> > occur while exporting linked report to PDF format.
> >
> > I confirmed this behaviour numerous times, and it's not only with
margin
> > but
> > also with page-layout. Is there a work-around?
> >
> > Many thanks,
> >
> > Edgar
> >

possible bug: sp_attach_single_file_db

The scenario:
The server in question has its Default Log Directory set
to "L:\". I used sp_attach_single_file_db to attach an
mdf file. Here is the command that I used:
EXEC sp_attach_single_file_db @.dbname = 'test2',
@.physname = 'f:\test2_Data.MDF'
I received the following error:
Device activation error. The physical file
name 'L:\test2_Log.LDF' may be incorrect.
New log file 'L:\\test2_log.LDF' was created.
Notice the 2 back-slashes in the path of the log file! I
didn't notice it at first, and eventually attempted to
restore the database from a backup taken from a different
server, using a 'with move'. Here is the command that I
used for that:
RESTORE DATABASE test2
FROM DISK = 'x:\test2.bak'
with MOVE 'test2_Data' TO 'f:\SQL_Data\test2_Data.mdf',
MOVE 'test2_Log' TO 'L:\test2_Log.ldf'
and the response:
Server: Msg 3156, Level 16, State 1, Line 1
File 'test2_Log' cannot be restored to 'L:\test2_Log.ldf'.
Use WITH MOVE to identify a valid location for the file.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
When I discovered the source of the problem, I inserted
the second back-slash in the move clause, and the restore
worked.
So, there may actually be 2 issues:
1. The extra back-slash that SQL expects to be in the path.
2. The erroneous error message associated with the restore
statement.
Has anyone else seen this?
Steve Phelps
SQL Server DBA
American Fidelity GroupThe extra backslash is due to a bug in EM in that if you use the browse
button to select the default directories it appends the trailing backslash
to the folder path, SQL actually expects the value to not have a trailing
backslash (easily ammended in EM by removing it although it generally
doesn't cause problems except the filename looking funny. Not come across
the restore issue, I'll try and repro that.
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Steve Phelps" <Steve.Phelps@.af-group.com> wrote in message
news:014201c356ce$1fa90c50$a601280a@.phx.gbl...
The scenario:
The server in question has its Default Log Directory set
to "L:\". I used sp_attach_single_file_db to attach an
mdf file. Here is the command that I used:
EXEC sp_attach_single_file_db @.dbname = 'test2',
@.physname = 'f:\test2_Data.MDF'
I received the following error:
Device activation error. The physical file
name 'L:\test2_Log.LDF' may be incorrect.
New log file 'L:\\test2_log.LDF' was created.
Notice the 2 back-slashes in the path of the log file! I
didn't notice it at first, and eventually attempted to
restore the database from a backup taken from a different
server, using a 'with move'. Here is the command that I
used for that:
RESTORE DATABASE test2
FROM DISK = 'x:\test2.bak'
with MOVE 'test2_Data' TO 'f:\SQL_Data\test2_Data.mdf',
MOVE 'test2_Log' TO 'L:\test2_Log.ldf'
and the response:
Server: Msg 3156, Level 16, State 1, Line 1
File 'test2_Log' cannot be restored to 'L:\test2_Log.ldf'.
Use WITH MOVE to identify a valid location for the file.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
When I discovered the source of the problem, I inserted
the second back-slash in the move clause, and the restore
worked.
So, there may actually be 2 issues:
1. The extra back-slash that SQL expects to be in the path.
2. The erroneous error message associated with the restore
statement.
Has anyone else seen this?
Steve Phelps
SQL Server DBA
American Fidelity Group|||You are aware you have to restart the SQL Service for changes to the default
directory to take effect ? A little test I did was to create a database when
the default log directory had a trailing backslash and confirm it had a \\
in it's name. Change the default log directory to remove the trailing
backslash and restart the SQL Service. I then detached the database created
earlier, deleted the log file and attached it using
sp_attach_single_file_db. This created the log file with the correct path
(no \\) . The device activation error referred to the path with the \\ in it
because it's reading the original logfile location from the database header
in the mdf file. Hope this makes things a little clearer
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Steve Phelps" <Steve.Phelps@.af-group.com> wrote in message
news:038101c356e2$dc0aaa70$a501280a@.phx.gbl...
Jasper,
Thanks for the quick response. I had considererd that
possibility and tried both with and without the slash when
I set the default directory. In neither case did I use
the browse button for that purpose. In both cases, the
default directory *appeared* to have been set properly.
Only when I used the sp_attach_single_file_db stored
procedure did the problem arise. My original thought was
that it was a bug in the stored proc. I hadn't looked at
the source code because I assumed that it was encrypted.
It isn't. I parsed out the code that builds the "Create
database" statement and executed it, printing the
resulting command:
CREATE DATABASE [test2]
ON (FILENAME ='f:\sql_data\test2_data.mdf' )
FOR ATTACH
then pasted it into Query Analyzer and executed it. Got
the same result. The new log file's path contains 2
slashes.
Steve Phelps
SQL Server DBA
American Fidelity Group
>--Original Message--
>The extra backslash is due to a bug in EM in that if you
use the browse
>button to select the default directories it appends the
trailing backslash
>to the folder path, SQL actually expects the value to not
have a trailing
>backslash (easily ammended in EM by removing it although
it generally
>doesn't cause problems except the filename looking funny.
Not come across
>the restore issue, I'll try and repro that.
>--
>HTH
>Jasper Smith (SQL Server MVP)
>I support PASS - the definitive, global
>community for SQL Server professionals -
>http://www.sqlpass.org
>"Steve Phelps" <Steve.Phelps@.af-group.com> wrote in
message
>news:014201c356ce$1fa90c50$a601280a@.phx.gbl...
>The scenario:
>The server in question has its Default Log Directory set
>to "L:\". I used sp_attach_single_file_db to attach an
>mdf file. Here is the command that I used:
>EXEC sp_attach_single_file_db @.dbname = 'test2',
> @.physname = 'f:\test2_Data.MDF'
>I received the following error:
>Device activation error. The physical file
>name 'L:\test2_Log.LDF' may be incorrect.
>New log file 'L:\\test2_log.LDF' was created.
>Notice the 2 back-slashes in the path of the log file! I
>didn't notice it at first, and eventually attempted to
>restore the database from a backup taken from a different
>server, using a 'with move'. Here is the command that I
>used for that:
>RESTORE DATABASE test2
> FROM DISK = 'x:\test2.bak'
> with MOVE 'test2_Data' TO 'f:\SQL_Data\test2_Data.mdf',
> MOVE 'test2_Log' TO 'L:\test2_Log.ldf'
>and the response:
>Server: Msg 3156, Level 16, State 1, Line 1
>File 'test2_Log' cannot be restored to 'L:\test2_Log.ldf'.
>Use WITH MOVE to identify a valid location for the file.
>Server: Msg 3013, Level 16, State 1, Line 1
>RESTORE DATABASE is terminating abnormally.
>When I discovered the source of the problem, I inserted
>the second back-slash in the move clause, and the restore
>worked.
>So, there may actually be 2 issues:
>1. The extra back-slash that SQL expects to be in the
path.
>2. The erroneous error message associated with the restore
>statement.
>Has anyone else seen this?
>Steve Phelps
>SQL Server DBA
>American Fidelity Group
>
>.
>

Possible bug: Lose members of server role when changing DataDir server property

Hello,

I think I have found a bug in AS and I would like it confirming before I report it. Please could someone try the following steps (don't do this on a production machine):

    Connect to your Analysis Server in SSMS with a user that is a member of the server role but NOT the user that installed the software

    Right-click on the server in Object Explorer. Select 'Properties...'

    On the general tab, change the value of the DataDir property to a different folder (it doesn't matter what)

    Click 'OK' on "Analysis Server properties" dialog. You will get a message telling you that the server needs to be restarted

    Restart your Analysis Server in Services panel.

    Re-Connect to the Analysis Server in Object Explorer again.

    Right-click on the server in Object Explorer. Select 'Properties...'

You won't be able to see any server properties and if you click on the 'Security' tab you will not be able to see yourself in the list of server role members. In other words...it seems you have been removed from the server role just by changing the data directory. If you try and do anything like deploy to the server you will get an error message "Either the 'username' user does not have permission to create a new object in 'LNVDMFIISDEV01', or the object does not exist."

It gets stranger...

    Log onto the server as the user that originally installed Analysis Services (for this is now the only user that will have server role privelages)

    Change the DataDir back to what it was before. Restart AS.

After that all of the server role members will be back where they were before. Everything as normal.

What gives? Can someone from MSFT confirm that this is a bug? If so I will raise it as such on Microsoft Connect.

Also, with this in mind, what should be the proper procedure for changing the data directory?

Regards

Jamie

I'm on SP1 by the way!

Thanks Jamie for catching this.

Please go ahead and file it.
The problem is indeed requires some attention. Maybe books online should explain better what is going on.

Changing Data directory is very big change. You will be loosing all of your data and metadata. More to it, you need to have physical access to the server machine to make sure new data folder has proper security permissions. It should be granted access to the SQLServer2005MSOLAPUser$MACHINENAME$MSSQLSERVER local group. So that during service account change Analysis Server still has an access to the data folder.

You also have an option to copy entire content of the old datafolder into the new location. In this case you will retain your data and metadata.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Hi Edward,

Thanks for the reply. I have raised it on Connect here: http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=146652

-Jamie

|||

I had a similar problem when trying to change the DataDir. I lost all my cubes in the old DataDir. I changed it back to the old DataDir as per Jamie's instructions to recover. But the cube I restored in the new DataDir is no longer visible. Is there any way to recover this metadata?

Edward, My serivce pack version SP1 is 2047. I saw you note dated 8/24/06 regarding next version? Is the fix planned for SP2?

A hint for others. Change/set your DataDir immediately after install of SQL Server 2005 so that you do not encounter this problem.

|||

I found a way to do this without having the problems. I posted it to my blog, so rather than retype it, here's the link

http://skinnytrail.blogspot.com/2006/08/changing-datadir-in-ssas-sql-2005.html

Possible bug: Lose members of server role when changing DataDir server property

Hello,

I think I have found a bug in AS and I would like it confirming before I report it. Please could someone try the following steps (don't do this on a production machine):

    Connect to your Analysis Server in SSMS with a user that is a member of the server role but NOT the user that installed the software

    Right-click on the server in Object Explorer. Select 'Properties...'

    On the general tab, change the value of the DataDir property to a different folder (it doesn't matter what)

    Click 'OK' on "Analysis Server properties" dialog. You will get a message telling you that the server needs to be restarted

    Restart your Analysis Server in Services panel.

    Re-Connect to the Analysis Server in Object Explorer again.

    Right-click on the server in Object Explorer. Select 'Properties...'

You won't be able to see any server properties and if you click on the 'Security' tab you will not be able to see yourself in the list of server role members. In other words...it seems you have been removed from the server role just by changing the data directory. If you try and do anything like deploy to the server you will get an error message "Either the 'username' user does not have permission to create a new object in 'LNVDMFIISDEV01', or the object does not exist."

It gets stranger...

    Log onto the server as the user that originally installed Analysis Services (for this is now the only user that will have server role privelages)

    Change the DataDir back to what it was before. Restart AS.

After that all of the server role members will be back where they were before. Everything as normal.

What gives? Can someone from MSFT confirm that this is a bug? If so I will raise it as such on Microsoft Connect.

Also, with this in mind, what should be the proper procedure for changing the data directory?

Regards

Jamie

I'm on SP1 by the way!

Thanks Jamie for catching this.

Please go ahead and file it.
The problem is indeed requires some attention. Maybe books online should explain better what is going on.

Changing Data directory is very big change. You will be loosing all of your data and metadata. More to it, you need to have physical access to the server machine to make sure new data folder has proper security permissions. It should be granted access to the SQLServer2005MSOLAPUser$MACHINENAME$MSSQLSERVER local group. So that during service account change Analysis Server still has an access to the data folder.

You also have an option to copy entire content of the old datafolder into the new location. In this case you will retain your data and metadata.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Hi Edward,

Thanks for the reply. I have raised it on Connect here: http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=146652

-Jamie

|||

I had a similar problem when trying to change the DataDir. I lost all my cubes in the old DataDir. I changed it back to the old DataDir as per Jamie's instructions to recover. But the cube I restored in the new DataDir is no longer visible. Is there any way to recover this metadata?

Edward, My serivce pack version SP1 is 2047. I saw you note dated 8/24/06 regarding next version? Is the fix planned for SP2?

A hint for others. Change/set your DataDir immediately after install of SQL Server 2005 so that you do not encounter this problem.

|||

I found a way to do this without having the problems. I posted it to my blog, so rather than retype it, here's the link

http://skinnytrail.blogspot.com/2006/08/changing-datadir-in-ssas-sql-2005.html

Possible bug with SSIS File System Task

I'm having an issue with a file system task & I'm not sure whether it is user error on my part or a bug. I'm using a SQL Task to create a transaction log backup & I'm saving the name of the file in a result set which I then am mapping to a package level user variable. After that runs I'm trying to copy this .BAK file to another folder using the file system task. I'm setting the following properties on the file system task.

Isdestinationpathvariable: False

Then I have entered the static directory for the file move.

Operation: Tried it with both copy file & move file.

Issourcepathvariable: True

Sourceconnection: User::File_name

After setting this I immediately get a validation warning telling me the source directory cannot be empty. If I try to run it, it fails. The weird thing is that if I set up a connection manager to a flat file & pass my user variable in as the connection string to this connection. Then set the Issourcepathvariable to false & the Sourceconnection to this connection manager it works.

I also have gotten it to work by substituting an ftp task in place of the file system task. The ftp task has no problem when I set the Islocalpathvariable to true & then pass my variable to Localvariable property. This is why I believe there is some sort of issue with the file system task. Has anyone seen this before? Is there some sort of problem with the way I'm setting it up?

Thank you

You might be missing the path of your source connection. Make sure you are including the path of the source file as a part of the File_name variable.

Rafael Salas

|||I tried it with both a mapped drive letter in the path & a unc path. No luck with either. Also the path I put into the variable works for the ftp task. Thank you though.

Possible Bug with SQl Server 2000

Hi,
Look at the simple set of SQL statements below: Execute the following on
Query Analyzer.
declare @.a float
declare @.b float
set @.a=24353.02821769137
set @.b=36459.95
exec('select '+@.a+'/'+@.b)
Ans=.6679392
Now, if I change the value of @.b to 36459.96,
I get a value of 0. Integer division is performed just because the value of
@.b increased by .01
This looks like bug with the internal workings of SQL. This is very
dangerous cause basic SQL assumption is that if a value is a float, the
division will also be a float division. Integer division on the other hand
gives erroneous results in this case.
Please solve this problem as soon as possible.
-Ling Yu.
Ling Yu,
This is not a bug, but it is surprising, and in my opinion, the query
should actually cause a syntax error. I'm glad you raised the question,
and I bet other people have been affected by this behavior.
Here's why it occurs:
The query processor must evaluate the query string 'select '+@.a+'/'+@.b
as its first step. When strings are concatenated inside exec(), the +
operator is not a T-SQL + operator. The + is applied by the front-end
application and only after the entire query string is assembled does
that string go to the query processor to be interpreted as T-SQL.
Query Analyzer (or the system it uses to prepare queries for the engine)
follows different rules than T-SQL to interpret the + that puts strings
together within exec(). In T-SQL, the + operation would fail, because
it tries to convert 'select ' and '/' into floats and add. But here, @.a
and @.b are converted to strings. The way in which they are converted to
strings is not obvious, but you can see it if you execute
exec('select ' + @.a) and exec('select ' + @.b)
What's important to realize is that exec() receives only a string,
without any type information about the parameters. Unfortunately,
floats are converted to strings by the front-end using at most 6 decimal
digits of precision. Since @.a is converted in both cases to the string
'24353', how the + in the query (not the concatenation + in the exec) is
understood depends on the string @.b converts to. If @.b is converted to
the string '36459.9', the addition is performed using decimal
arithmetic. If @.b is converted to '36460', the query executed is
select 24353/36460, with 0 as the result. The types of @.a and @.b are
unknown to the query processor, which sees only the string
representations of these numbers.
While at first glance, you might think the select query here recognizes
that it is receiving floats, it is not. exec() can only receive a
string and must interpret the types of numbers from their string
representations. A safer approach is to use sp_executesql, with
parameters, or to add typecasts in your query string.
I hope that helps.
PAI wrote:

>Hi,
>Look at the simple set of SQL statements below: Execute the following on
>Query Analyzer.
>declare @.a float
>declare @.b float
>set @.a=24353.02821769137
>set @.b=36459.95
>exec('select '+@.a+'/'+@.b)
>Ans=.6679392
>Now, if I change the value of @.b to 36459.96,
>I get a value of 0. Integer division is performed just because the value of
>@.b increased by .01
>This looks like bug with the internal workings of SQL. This is very
>dangerous cause basic SQL assumption is that if a value is a float, the
>division will also be a float division. Integer division on the other hand
>gives erroneous results in this case.
>Please solve this problem as soon as possible.
>-Ling Yu.
>
|||Thanks Steve. Your answer makes sense but the whole point of exec () now does
not. Why arbitrarily choose 6 precision. The disturbing this is even if you
convert it to a string and do an exec(@.sqlstring), you get the same problem.
For example:
declare @.a float
declare @.b float
set @.a=24353.02821769137
set @.b=36459.96
declare @.sql varchar(1000)
set @.sql='select '+cast(@.a as varchar(100))+'/'+cast(@.b as varchar(100))
exec('select '+@.a+'/'+@.b)
exec (@.sql)
Logically speaking when i cast 36459.96 to a varchar(100) it should retain
its decimal points and not round it. The only thing that helps is
exec('select cast('+@.a+' as float)/'+@.b)
This is so counterintuitive that its frustrating.
Thanks for your reply though
"Steve Kass" wrote:

> Ling Yu,
> This is not a bug, but it is surprising, and in my opinion, the query
> should actually cause a syntax error. I'm glad you raised the question,
> and I bet other people have been affected by this behavior.
> Here's why it occurs:
> The query processor must evaluate the query string 'select '+@.a+'/'+@.b
> as its first step. When strings are concatenated inside exec(), the +
> operator is not a T-SQL + operator. The + is applied by the front-end
> application and only after the entire query string is assembled does
> that string go to the query processor to be interpreted as T-SQL.
> Query Analyzer (or the system it uses to prepare queries for the engine)
> follows different rules than T-SQL to interpret the + that puts strings
> together within exec(). In T-SQL, the + operation would fail, because
> it tries to convert 'select ' and '/' into floats and add. But here, @.a
> and @.b are converted to strings. The way in which they are converted to
> strings is not obvious, but you can see it if you execute
> exec('select ' + @.a) and exec('select ' + @.b)
> What's important to realize is that exec() receives only a string,
> without any type information about the parameters. Unfortunately,
> floats are converted to strings by the front-end using at most 6 decimal
> digits of precision. Since @.a is converted in both cases to the string
> '24353', how the + in the query (not the concatenation + in the exec) is
> understood depends on the string @.b converts to. If @.b is converted to
> the string '36459.9', the addition is performed using decimal
> arithmetic. If @.b is converted to '36460', the query executed is
> select 24353/36460, with 0 as the result. The types of @.a and @.b are
> unknown to the query processor, which sees only the string
> representations of these numbers.
> While at first glance, you might think the select query here recognizes
> that it is receiving floats, it is not. exec() can only receive a
> string and must interpret the types of numbers from their string
> representations. A safer approach is to use sp_executesql, with
> parameters, or to add typecasts in your query string.
> I hope that helps.
>
> PAI wrote:
>
|||Ling Yu,
While the default conversion from float to string is not very useful,
you can use CONVERT with a format code. Use convert(varchar(100),@.a,2),
and the resulting string will always be in scientific notation with 16
decimal places of accuracy. Then it will always be interpreted as a
float, and never with too-low precision.
SK
PAI wrote:
[vbcol=seagreen]
>Thanks Steve. Your answer makes sense but the whole point of exec () now does
>not. Why arbitrarily choose 6 precision. The disturbing this is even if you
>convert it to a string and do an exec(@.sqlstring), you get the same problem.
>For example:
>declare @.a float
>declare @.b float
>set @.a=24353.02821769137
>set @.b=36459.96
>declare @.sql varchar(1000)
>set @.sql='select '+cast(@.a as varchar(100))+'/'+cast(@.b as varchar(100))
>exec('select '+@.a+'/'+@.b)
>exec (@.sql)
>Logically speaking when i cast 36459.96 to a varchar(100) it should retain
>its decimal points and not round it. The only thing that helps is
>exec('select cast('+@.a+' as float)/'+@.b)
>This is so counterintuitive that its frustrating.
>Thanks for your reply though
>"Steve Kass" wrote:
>

Possible Bug with SQl Server 2000

Hi,
Look at the simple set of SQL statements below: Execute the following on
Query Analyzer.
declare @.a float
declare @.b float
set @.a=24353.02821769137
set @.b=36459.95
exec('select '+@.a+'/'+@.b)
Ans=.6679392
Now, if I change the value of @.b to 36459.96,
I get a value of 0. Integer division is performed just because the value of
@.b increased by .01
This looks like bug with the internal workings of SQL. This is very
dangerous cause basic SQL assumption is that if a value is a float, the
division will also be a float division. Integer division on the other hand
gives erroneous results in this case.
Please solve this problem as soon as possible.
-Ling Yu.Ling Yu,
This is not a bug, but it is surprising, and in my opinion, the query
should actually cause a syntax error. I'm glad you raised the question,
and I bet other people have been affected by this behavior.
Here's why it occurs:
The query processor must evaluate the query string 'select '+@.a+'/'+@.b
as its first step. When strings are concatenated inside exec(), the +
operator is not a T-SQL + operator. The + is applied by the front-end
application and only after the entire query string is assembled does
that string go to the query processor to be interpreted as T-SQL.
Query Analyzer (or the system it uses to prepare queries for the engine)
follows different rules than T-SQL to interpret the + that puts strings
together within exec(). In T-SQL, the + operation would fail, because
it tries to convert 'select ' and '/' into floats and add. But here, @.a
and @.b are converted to strings. The way in which they are converted to
strings is not obvious, but you can see it if you execute
exec('select ' + @.a) and exec('select ' + @.b)
What's important to realize is that exec() receives only a string,
without any type information about the parameters. Unfortunately,
floats are converted to strings by the front-end using at most 6 decimal
digits of precision. Since @.a is converted in both cases to the string
'24353', how the + in the query (not the concatenation + in the exec) is
understood depends on the string @.b converts to. If @.b is converted to
the string '36459.9', the addition is performed using decimal
arithmetic. If @.b is converted to '36460', the query executed is
select 24353/36460, with 0 as the result. The types of @.a and @.b are
unknown to the query processor, which sees only the string
representations of these numbers.
While at first glance, you might think the select query here recognizes
that it is receiving floats, it is not. exec() can only receive a
string and must interpret the types of numbers from their string
representations. A safer approach is to use sp_executesql, with
parameters, or to add typecasts in your query string.
I hope that helps.
PAI wrote:
>Hi,
>Look at the simple set of SQL statements below: Execute the following on
>Query Analyzer.
>declare @.a float
>declare @.b float
>set @.a=24353.02821769137
>set @.b=36459.95
>exec('select '+@.a+'/'+@.b)
>Ans=.6679392
>Now, if I change the value of @.b to 36459.96,
>I get a value of 0. Integer division is performed just because the value of
>@.b increased by .01
>This looks like bug with the internal workings of SQL. This is very
>dangerous cause basic SQL assumption is that if a value is a float, the
>division will also be a float division. Integer division on the other hand
>gives erroneous results in this case.
>Please solve this problem as soon as possible.
>-Ling Yu.
>|||Thanks Steve. Your answer makes sense but the whole point of exec () now does
not. Why arbitrarily choose 6 precision. The disturbing this is even if you
convert it to a string and do an exec(@.sqlstring), you get the same problem.
For example:
declare @.a float
declare @.b float
set @.a=24353.02821769137
set @.b=36459.96
declare @.sql varchar(1000)
set @.sql='select '+cast(@.a as varchar(100))+'/'+cast(@.b as varchar(100))
exec('select '+@.a+'/'+@.b)
exec (@.sql)
Logically speaking when i cast 36459.96 to a varchar(100) it should retain
its decimal points and not round it. The only thing that helps is
exec('select cast('+@.a+' as float)/'+@.b)
This is so counterintuitive that its frustrating.
Thanks for your reply though
"Steve Kass" wrote:
> Ling Yu,
> This is not a bug, but it is surprising, and in my opinion, the query
> should actually cause a syntax error. I'm glad you raised the question,
> and I bet other people have been affected by this behavior.
> Here's why it occurs:
> The query processor must evaluate the query string 'select '+@.a+'/'+@.b
> as its first step. When strings are concatenated inside exec(), the +
> operator is not a T-SQL + operator. The + is applied by the front-end
> application and only after the entire query string is assembled does
> that string go to the query processor to be interpreted as T-SQL.
> Query Analyzer (or the system it uses to prepare queries for the engine)
> follows different rules than T-SQL to interpret the + that puts strings
> together within exec(). In T-SQL, the + operation would fail, because
> it tries to convert 'select ' and '/' into floats and add. But here, @.a
> and @.b are converted to strings. The way in which they are converted to
> strings is not obvious, but you can see it if you execute
> exec('select ' + @.a) and exec('select ' + @.b)
> What's important to realize is that exec() receives only a string,
> without any type information about the parameters. Unfortunately,
> floats are converted to strings by the front-end using at most 6 decimal
> digits of precision. Since @.a is converted in both cases to the string
> '24353', how the + in the query (not the concatenation + in the exec) is
> understood depends on the string @.b converts to. If @.b is converted to
> the string '36459.9', the addition is performed using decimal
> arithmetic. If @.b is converted to '36460', the query executed is
> select 24353/36460, with 0 as the result. The types of @.a and @.b are
> unknown to the query processor, which sees only the string
> representations of these numbers.
> While at first glance, you might think the select query here recognizes
> that it is receiving floats, it is not. exec() can only receive a
> string and must interpret the types of numbers from their string
> representations. A safer approach is to use sp_executesql, with
> parameters, or to add typecasts in your query string.
> I hope that helps.
>
> PAI wrote:
> >Hi,
> >
> >Look at the simple set of SQL statements below: Execute the following on
> >Query Analyzer.
> >
> >declare @.a float
> >declare @.b float
> >set @.a=24353.02821769137
> >set @.b=36459.95
> >exec('select '+@.a+'/'+@.b)
> >
> >Ans=.6679392
> >
> >Now, if I change the value of @.b to 36459.96,
> >I get a value of 0. Integer division is performed just because the value of
> >@.b increased by .01
> >
> >This looks like bug with the internal workings of SQL. This is very
> >dangerous cause basic SQL assumption is that if a value is a float, the
> >division will also be a float division. Integer division on the other hand
> >gives erroneous results in this case.
> >
> >Please solve this problem as soon as possible.
> >
> >-Ling Yu.
> >
> >
>|||Ling Yu,
While the default conversion from float to string is not very useful,
you can use CONVERT with a format code. Use convert(varchar(100),@.a,2),
and the resulting string will always be in scientific notation with 16
decimal places of accuracy. Then it will always be interpreted as a
float, and never with too-low precision.
SK
PAI wrote:
>Thanks Steve. Your answer makes sense but the whole point of exec () now does
>not. Why arbitrarily choose 6 precision. The disturbing this is even if you
>convert it to a string and do an exec(@.sqlstring), you get the same problem.
>For example:
>declare @.a float
>declare @.b float
>set @.a=24353.02821769137
>set @.b=36459.96
>declare @.sql varchar(1000)
>set @.sql='select '+cast(@.a as varchar(100))+'/'+cast(@.b as varchar(100))
>exec('select '+@.a+'/'+@.b)
>exec (@.sql)
>Logically speaking when i cast 36459.96 to a varchar(100) it should retain
>its decimal points and not round it. The only thing that helps is
>exec('select cast('+@.a+' as float)/'+@.b)
>This is so counterintuitive that its frustrating.
>Thanks for your reply though
>"Steve Kass" wrote:
>
>>Ling Yu,
>> This is not a bug, but it is surprising, and in my opinion, the query
>>should actually cause a syntax error. I'm glad you raised the question,
>>and I bet other people have been affected by this behavior.
>>Here's why it occurs:
>>The query processor must evaluate the query string 'select '+@.a+'/'+@.b
>>as its first step. When strings are concatenated inside exec(), the +
>>operator is not a T-SQL + operator. The + is applied by the front-end
>>application and only after the entire query string is assembled does
>>that string go to the query processor to be interpreted as T-SQL.
>>Query Analyzer (or the system it uses to prepare queries for the engine)
>>follows different rules than T-SQL to interpret the + that puts strings
>>together within exec(). In T-SQL, the + operation would fail, because
>>it tries to convert 'select ' and '/' into floats and add. But here, @.a
>>and @.b are converted to strings. The way in which they are converted to
>>strings is not obvious, but you can see it if you execute
>>exec('select ' + @.a) and exec('select ' + @.b)
>>What's important to realize is that exec() receives only a string,
>>without any type information about the parameters. Unfortunately,
>>floats are converted to strings by the front-end using at most 6 decimal
>>digits of precision. Since @.a is converted in both cases to the string
>>'24353', how the + in the query (not the concatenation + in the exec) is
>>understood depends on the string @.b converts to. If @.b is converted to
>>the string '36459.9', the addition is performed using decimal
>>arithmetic. If @.b is converted to '36460', the query executed is
>>select 24353/36460, with 0 as the result. The types of @.a and @.b are
>>unknown to the query processor, which sees only the string
>>representations of these numbers.
>>While at first glance, you might think the select query here recognizes
>>that it is receiving floats, it is not. exec() can only receive a
>>string and must interpret the types of numbers from their string
>>representations. A safer approach is to use sp_executesql, with
>>parameters, or to add typecasts in your query string.
>>I hope that helps.
>>
>>PAI wrote:
>>
>>Hi,
>>Look at the simple set of SQL statements below: Execute the following on
>>Query Analyzer.
>>declare @.a float
>>declare @.b float
>>set @.a=24353.02821769137
>>set @.b=36459.95
>>exec('select '+@.a+'/'+@.b)
>>Ans=.6679392
>>Now, if I change the value of @.b to 36459.96,
>>I get a value of 0. Integer division is performed just because the value of
>>@.b increased by .01
>>This looks like bug with the internal workings of SQL. This is very
>>dangerous cause basic SQL assumption is that if a value is a float, the
>>division will also be a float division. Integer division on the other hand
>>gives erroneous results in this case.
>>Please solve this problem as soon as possible.
>>-Ling Yu.
>>
>>

Possible Bug with HTML Comments for Data Driven Subscription

I have specified a good sized comment that gets displayed in the message
body. It is html, which by the way could be improved as it is a bit
difficult as it all has to be on one line which makes the <pre> tag useless
so I have to replace all spaces with nbsp and all line breaks with <br> (Hint
- wishlist). In either case when I go back and change something else later -
for instance the email address, it replaces the brackets on my tags in the
comment box with < and &rt, thereby messing up my comment and giving me
something that is gobbledy gook as far as the user is concerned. Why does
reporting services mess up my comment when I go back to change something else?
Thanks,
Scott EguiresThis is a known issue. The Asp.Net control encodes the data for us which
causes this problem. There is no real workaround, except to keep you html
in a separate location and cut and paste it in when ready.
--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.
"dkangel" <dkangel@.discussions.microsoft.com> wrote in message
news:9EC5C437-196A-4CD9-BA1D-BBBCD10DC100@.microsoft.com...
> I have specified a good sized comment that gets displayed in the message
> body. It is html, which by the way could be improved as it is a bit
> difficult as it all has to be on one line which makes the <pre> tag
useless
> so I have to replace all spaces with nbsp and all line breaks with <br>
(Hint
> - wishlist). In either case when I go back and change something else
later -
> for instance the email address, it replaces the brackets on my tags in the
> comment box with < and &rt, thereby messing up my comment and giving me
> something that is gobbledy gook as far as the user is concerned. Why does
> reporting services mess up my comment when I go back to change something
else?
> Thanks,
> Scott Eguires

Possible bug with excel export

We're having a problem with the excel export in one of our reports. The data region in the report is filtered by the value of a parameter chosen by the user. Everything displays and works fine until it is exported to excel. When a user does this it outputs the results for the same parameter no matter what parameter is actually selected. It's specifically related to the excel export because every other one works as expected. Can anyone reproduce this problem?Are you running the latest service pack?
Can you try copying the report to another report & then exporting?|||This is actually in 2005. Copying the report to another one doesn't help and unfortunately we don't have our new test server in yet to try it on another machine.

Possible Bug Using TOP and Paging via a Temp Table

This is not a "bug" per se, as I know that the order of rows in SQL
Server isn't guaranteed to be consistent unless ORDER BY is specified.
Still, this is somewhat odd behavior.
This involves paging logic via parameterized queries. Since I can't
post my client's DDL, I have used northwind to duplicate the issue.
Code:
--vars to simulate paging
DECLARE
@.start int,
@.end int
--create temp table
CREATE TABLE #TempTable ([__rowcnt][int] IDENTITY (1,1) NOT
NULL,[CustomerId][varchar](50) NOT NULL, [ShipVia][Int] NOT
NULL,[ShipName][VarChar](50) NOT NULL,[ShipAddress][varchar](50) NOT
NULL, [Orderdate] [DateTime] NOT NULL)
SELECT @.start = 0 /*****CHANGE ME*****/
SELECT @.end = 12 /*****CHANGE ME*****/
--insert rows
INSERT INTO #TempTable (CustomerID, ShipVia, ShipName,
ShipAddress,Orderdate)
SELECT DISTINCT
TOP 12 /*****CHANGE ME*****/
CustomerID,
ShipVia,
ShipName,
ShipAddress,
Orderdate
FROM
ORDERS
WHERE
CustomerId IN ('SAVEA', 'ERNSH', 'QUICK')
ORDER BY
CustomerId
--select the page of data
SELECT * FROM #TempTable WHERE __rowcnt > @.start AND __rowcnt <= @.end
--select to see the whole temp table
--SELECT * FROM #TempTable
DROP TABLE #TempTable
1. Run the query as is. Notice that there are 3 rows returned where
ShipVia = 2.
2. Change @.start to 12, @.end to 24, and the TOP statement to be "TOP
24". Notice that although the __rowcnt selection correctly returns
13-24, the rows are the same.
3. Change @.start to 24, @.end to 36, and the TOP statement to be "TOP
36". The page of data now changes (I believe because the customerID
changes on this page).
4. Comment out the TOP statement and re-do steps 1, 2, and 3. The pages
of data returned are now "correct"--the data returned is different for
each page.
You can uncomment the final select statement to see what is actually
going into the temp table.
It seems that the TOP statement is somehow causing the rows to be added
to the temp table in reverse order. Apparently, the "correct" rows are
returned using an unpatched version of SQL Server.
Anyone know what might cause this to happen?
Thanks for any insight,
PhilHi
Add a few 100 thousand rows to this, plus a machine with 4 processors and a
lot of RAM and the query performs different again. Even a different OS.
As the row count in your example increases, there is probably a different
query plan/spool to disk occurring.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
<psandler70@.hotmail.com> wrote in message
news:1135119108.603421.214770@.z14g2000cwz.googlegroups.com...
> This is not a "bug" per se, as I know that the order of rows in SQL
> Server isn't guaranteed to be consistent unless ORDER BY is specified.
> Still, this is somewhat odd behavior.
> This involves paging logic via parameterized queries. Since I can't
> post my client's DDL, I have used northwind to duplicate the issue.
> Code:
> --vars to simulate paging
> DECLARE
> @.start int,
> @.end int
> --create temp table
> CREATE TABLE #TempTable ([__rowcnt][int] IDENTITY (1,1) NOT
> NULL,[CustomerId][varchar](50) NOT NULL, [ShipVia][Int] NOT
> NULL,[ShipName][VarChar](50) NOT NULL,[ShipAddress][varchar](50) NOT
> NULL, [Orderdate] [DateTime] NOT NULL)
> SELECT @.start = 0 /*****CHANGE ME*****/
> SELECT @.end = 12 /*****CHANGE ME*****/
> --insert rows
> INSERT INTO #TempTable (CustomerID, ShipVia, ShipName,
> ShipAddress,Orderdate)
> SELECT DISTINCT
> TOP 12 /*****CHANGE ME*****/
> CustomerID,
> ShipVia,
> ShipName,
> ShipAddress,
> Orderdate
> FROM
> ORDERS
> WHERE
> CustomerId IN ('SAVEA', 'ERNSH', 'QUICK')
> ORDER BY
> CustomerId
> --select the page of data
> SELECT * FROM #TempTable WHERE __rowcnt > @.start AND __rowcnt <= @.end
> --select to see the whole temp table
> --SELECT * FROM #TempTable
> DROP TABLE #TempTable
>
> 1. Run the query as is. Notice that there are 3 rows returned where
> ShipVia = 2.
> 2. Change @.start to 12, @.end to 24, and the TOP statement to be "TOP
> 24". Notice that although the __rowcnt selection correctly returns
> 13-24, the rows are the same.
> 3. Change @.start to 24, @.end to 36, and the TOP statement to be "TOP
> 36". The page of data now changes (I believe because the customerID
> changes on this page).
> 4. Comment out the TOP statement and re-do steps 1, 2, and 3. The pages
> of data returned are now "correct"--the data returned is different for
> each page.
> You can uncomment the final select statement to see what is actually
> going into the temp table.
> It seems that the TOP statement is somehow causing the rows to be added
> to the temp table in reverse order. Apparently, the "correct" rows are
> returned using an unpatched version of SQL Server.
> Anyone know what might cause this to happen?
> Thanks for any insight,
> Phil
>|||There are some better approaches to paging that don't exhibit these
symptoms.
http://www.aspfaq.com/2120
<psandler70@.hotmail.com> wrote in message
news:1135119108.603421.214770@.z14g2000cwz.googlegroups.com...
> This is not a "bug" per se, as I know that the order of rows in SQL
> Server isn't guaranteed to be consistent unless ORDER BY is specified.
> Still, this is somewhat odd behavior.
> This involves paging logic via parameterized queries. Since I can't
> post my client's DDL, I have used northwind to duplicate the issue.
> Code:
> --vars to simulate paging
> DECLARE
> @.start int,
> @.end int
> --create temp table
> CREATE TABLE #TempTable ([__rowcnt][int] IDENTITY (1,1) NOT
> NULL,[CustomerId][varchar](50) NOT NULL, [ShipVia][Int] NOT
> NULL,[ShipName][VarChar](50) NOT NULL,[ShipAddress][varchar](50) NOT
> NULL, [Orderdate] [DateTime] NOT NULL)
> SELECT @.start = 0 /*****CHANGE ME*****/
> SELECT @.end = 12 /*****CHANGE ME*****/
> --insert rows
> INSERT INTO #TempTable (CustomerID, ShipVia, ShipName,
> ShipAddress,Orderdate)
> SELECT DISTINCT
> TOP 12 /*****CHANGE ME*****/
> CustomerID,
> ShipVia,
> ShipName,
> ShipAddress,
> Orderdate
> FROM
> ORDERS
> WHERE
> CustomerId IN ('SAVEA', 'ERNSH', 'QUICK')
> ORDER BY
> CustomerId
> --select the page of data
> SELECT * FROM #TempTable WHERE __rowcnt > @.start AND __rowcnt <= @.end
> --select to see the whole temp table
> --SELECT * FROM #TempTable
> DROP TABLE #TempTable
>
> 1. Run the query as is. Notice that there are 3 rows returned where
> ShipVia = 2.
> 2. Change @.start to 12, @.end to 24, and the TOP statement to be "TOP
> 24". Notice that although the __rowcnt selection correctly returns
> 13-24, the rows are the same.
> 3. Change @.start to 24, @.end to 36, and the TOP statement to be "TOP
> 36". The page of data now changes (I believe because the customerID
> changes on this page).
> 4. Comment out the TOP statement and re-do steps 1, 2, and 3. The pages
> of data returned are now "correct"--the data returned is different for
> each page.
> You can uncomment the final select statement to see what is actually
> going into the temp table.
> It seems that the TOP statement is somehow causing the rows to be added
> to the temp table in reverse order. Apparently, the "correct" rows are
> returned using an unpatched version of SQL Server.
> Anyone know what might cause this to happen?
> Thanks for any insight,
> Phil
>

possible bug regarding single line comments in SQL Server Management Studio

I don't know if this is a bug or something I've messed up in my settings. I am using SQL Server Management Studio with SQL 2005 service pack 1 installed, and I've been using it successfully ever since SP1 came out. All of a sudden, any time I have a query with a single line comment (i.e. using dash dash -- ), the rest of the query is ignored as if the single line comment is really a multi-line comment without the closing */

An example:

select top 100 *

from myTable

-- this is a comment

where myTableID = 1234

This would normally return exactly one row, but instead returns 100 rows ( as if the where clause did not exist). If I move the where clause above the comment, it works as expected. Any ideas?

In trying to fix this, I've uninstalled and reinstalled and even reinstalled SP1, but it still isn't fixed.

You've got me stumped. I took the code you have posted and it ran fine for me.

Can you post the exact code that you are using? Maybe we'll see that hanging character you missed or somthing.

|||

I used the exact query, merely changing the table name and ID column.

I ended up going through the process yet again (uninstalling the tools, reinstalling the tools, then installing SP1) and rebooted but still had the problem. However, after a second reboot, it starting behaving properly again. I hope my problem does not resurface.

|||We (me a colleague of mine), have withnessed this same behaviour and, atfer some deep analysis, we have concluded that this bug arises when the Transact-Sql line terminates with a CR (Carriage Return, Ascii(13)) only charaters when it should terminate with both CR (Carriage Return, Ascii(13)) followed by an LF (Line Feed, Ascii(10))

It seems that once SqlServer reachs a single-line comment identifier (--) it keeps fetching bytes untill a compounded line termination (CR followed by LF) is reached.

In the following sample, the {CR+LF} and {CR} are representations of their respective invisible ascii codes.

--This is just a normal single-line comment {CR+LF}
SELECT 'This command works fine' {CR+LF}

--This is a buggy single-line comment {CR}
SELECT 'This command does not work'{CR}
SELECT 'This command does not work either' {CR+LF}
SELECT 'This command work fine too' {CR+LF}

Moreover we have reasons to bellieve that this bug resides in Query Editor provided with SQL Server Management Studio Express Edition (at least, this was version my colleague was using when this bug arose). Anyway, although this bug must be corrected, LF should just be ignored when dealing with Sql scripts.

Running software:

SQL Server Management Studio Express Edition

Ms SQLServer 2000 (8.0.2039)

Win XP Portuguese SP2


Getting this sample you can:

- Load and execute it, using QueryAnalyzer to see the refered behaviour;
- View it, using Notepad, to see what actually happened.

possible bug regarding single line comments in SQL Server Management Studio

I don't know if this is a bug or something I've messed up in my settings. I am using SQL Server Management Studio with SQL 2005 service pack 1 installed, and I've been using it successfully ever since SP1 came out. All of a sudden, any time I have a query with a single line comment (i.e. using dash dash -- ), the rest of the query is ignored as if the single line comment is really a multi-line comment without the closing */

An example:

select top 100 *

from myTable

-- this is a comment

where myTableID = 1234

This would normally return exactly one row, but instead returns 100 rows ( as if the where clause did not exist). If I move the where clause above the comment, it works as expected. Any ideas?

In trying to fix this, I've uninstalled and reinstalled and even reinstalled SP1, but it still isn't fixed.

You've got me stumped. I took the code you have posted and it ran fine for me.

Can you post the exact code that you are using? Maybe we'll see that hanging character you missed or somthing.

|||

I used the exact query, merely changing the table name and ID column.

I ended up going through the process yet again (uninstalling the tools, reinstalling the tools, then installing SP1) and rebooted but still had the problem. However, after a second reboot, it starting behaving properly again. I hope my problem does not resurface.

|||We (me a colleague of mine), have withnessed this same behaviour and, atfer some deep analysis, we have concluded that this bug arises when the Transact-Sql line terminates with a CR (Carriage Return, Ascii(13)) only charaters when it should terminate with both CR (Carriage Return, Ascii(13)) followed by an LF (Line Feed, Ascii(10))

It seems that once SqlServer reachs a single-line comment identifier (--) it keeps fetching bytes untill a compounded line termination (CR followed by LF) is reached.

In the following sample, the {CR+LF} and {CR} are representations of their respective invisible ascii codes.

--This is just a normal single-line comment {CR+LF}
SELECT 'This command works fine' {CR+LF}

--This is a buggy single-line comment {CR}
SELECT 'This command does not work'{CR}
SELECT 'This command does not work either' {CR+LF}
SELECT 'This command work fine too' {CR+LF}

Moreover we have reasons to bellieve that this bug resides in Query Editor provided with SQL Server Management Studio Express Edition (at least, this was version my colleague was using when this bug arose). Anyway, although this bug must be corrected, LF should just be ignored when dealing with Sql scripts.

Running software:

SQL Server Management Studio Express Edition

Ms SQLServer 2000 (8.0.2039)

Win XP Portuguese SP2


Getting this sample you can:

- Load and execute it, using QueryAnalyzer to see the refered behaviour;
- View it, using Notepad, to see what actually happened.

Possible Bug in SQL2005 query?

Hi! This is what happened to me and my colleagues.

We are using SQL 2005. When we were building a view from a table, the
field we selected was not what came out in the output.

Let's say you have 2 specific fields in the table, the second one of
them begins with the letter "L". While your mouse focus is still on the
first field, and you type "L", the focus will jump to the second field.
But now if you left-click it (or press space bar) trying to select it,
in the output panel, you will get the first field.

I hope I get myself understood. Anyone of you happened to experience
the same thing? And what's the explanation for this? The thing is it
didn't happen with SQL 2000. And we are suspecting this to be a bug.chencongwei@.gmail.com wrote:

Quote:

Originally Posted by

Hi! This is what happened to me and my colleagues.
>
We are using SQL 2005. When we were building a view from a table, the
field we selected was not what came out in the output.
>
Let's say you have 2 specific fields in the table, the second one of
them begins with the letter "L". While your mouse focus is still on the
first field, and you type "L", the focus will jump to the second field.
But now if you left-click it (or press space bar) trying to select it,
in the output panel, you will get the first field.
>
I hope I get myself understood. Anyone of you happened to experience
the same thing? And what's the explanation for this? The thing is it
didn't happen with SQL 2000. And we are suspecting this to be a bug.


The place to report a bug is:

http://connect.microsoft.com/SQLServer
My personal recommendation would be that you should avoid the quey/view
designer altogether. Constructing your own views in the editor with the
help of the object browser is a much more powerful and reliable way to
do it.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/...US,SQL.90).aspx
--

Possible Bug in SQL Server 2000?

Hi guys,
I have hit this bug more than once and was wondering if anyone else
has ever seen it?
SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE A.nId IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or
B.nId IS NULL
LogTable.cId is a varchar(15) but it only has numeric data where
cTableName = 'TableA'.
I get the following error when I execute the statement.
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '1-L7Z5X' to a column of
data type int.
'1-L7Z5X' does exist in LogTable but not for 'TableA'.
Any thoughts?
Is LogTable.cId varchar? You might want to restrict the where clause not
only to TableA but also to those rows where the value is actually numeric.
Or, convert A.nId to a VARCHAR before comparing.
http://www.aspfaq.com/
(Reverse address to reply.)
"Dave" <david_green@.softhome.net> wrote in message
news:14ec5400.0407080852.50c22022@.posting.google.c om...
> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
> LogTable.cId is a varchar(15) but it only has numeric data where
> cTableName = 'TableA'.
> I get the following error when I execute the statement.
> Server: Msg 245, Level 16, State 1, Line 1
> Syntax error converting the varchar value '1-L7Z5X' to a column of
> data type int.
> '1-L7Z5X' does exist in LogTable but not for 'TableA'.
> Any thoughts?
|||Dave,
WHERE A.nId IN (SELECT cId
Are you comparing A.nId (int) to cId (varchar) and cId contains alpha characters?
Mark H
"Dave" wrote:

> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
> LogTable.cId is a varchar(15) but it only has numeric data where
> cTableName = 'TableA'.
> I get the following error when I execute the statement.
> Server: Msg 245, Level 16, State 1, Line 1
> Syntax error converting the varchar value '1-L7Z5X' to a column of
> data type int.
> '1-L7Z5X' does exist in LogTable but not for 'TableA'.
> Any thoughts?
>
|||[comp.databases.ms-sqlserver removed - can't send to more than 1 server]
Dave,
This isn't a bug. The optimizer is free to evaluate this query by
doing the comparison on A.nId = LogTable.cId before checking whether
cTableName is 'TableA', and presumably there are indexes in place that
make that approach better. Since you are comparing a character type to
an integer type, the character values are convered to int before the
comparison takes place. Since you can't be using an index on
LogTable.cId anyway, you can try this:
...
where A.nId IN (
select case when cTableName = 'TableA' then cast(cId as int) else NULL end
from ...
where cTableName = 'TableA'
)
If there are no non-convertible-to-int cId values in rows where
cTableName = 'TableA', the error should go away.
Steve Kass
Drew University
Dave wrote:

>Hi guys,
>I have hit this bug more than once and was wondering if anyone else
>has ever seen it?
>SELECT A.nId
>,B.nId
>FROM Server1.myDB_1.dbo.TableA A
>LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
>WHERE A.nId IN (SELECT cId
>FROM Server1.myDB_3.dbo.LogTable
>WHERE cTableName = 'TableA')
>or
>B.nId IS NULL
>
>LogTable.cId is a varchar(15) but it only has numeric data where
>cTableName = 'TableA'.
>I get the following error when I execute the statement.
>Server: Msg 245, Level 16, State 1, Line 1
>Syntax error converting the varchar value '1-L7Z5X' to a column of
>data type int.
>'1-L7Z5X' does exist in LogTable but not for 'TableA'.
>Any thoughts?
>
|||"Dave" <david_green@.softhome.net> wrote in message
news:14ec5400.0407080852.50c22022@.posting.google.c om...
> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
Sql Server is free to reorganize this query, transform the subquery into a
join, and evaluate the join criterion before the where-clause criterion. Try
casting nID to a varchar before the comparison.
SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE cast( A.nId as varchar(15)) IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or B.nId IS NULL
David
|||On 8 Jul 2004 09:52:24 -0700, Dave wrote:

> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
> LogTable.cId is a varchar(15) but it only has numeric data where
> cTableName = 'TableA'.
> I get the following error when I execute the statement.
> Server: Msg 245, Level 16, State 1, Line 1
> Syntax error converting the varchar value '1-L7Z5X' to a column of
> data type int.
> '1-L7Z5X' does exist in LogTable but not for 'TableA'.
> Any thoughts?
It's not a bug. You're asking SQL to compare A.nID to each value in the
subquery. It tries to do that by (an implied) convert(int,...) operation,
which fails for the value in LogTable.
Either convert a.nID to varchar, or restrict the values in the subquery to
those that are actually numeric.
SELECT A.nID, B.nID
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB ON B.nID = A.nID
WHERE convert(varchar(15),A.nID) IN
(SELECT cID FROM Server1.MyDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
OR b.nID IS NULL
..... or .......
SELECT A.nID, B.nID
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB ON B.nID = A.nID
WHERE A.nID IN
(SELECT cID FROM Server1.MyDB_3.dbo.LogTable
WHERE cTableName = 'TableA' and ISNUMERIC(cID))
OR b.nID IS NULL

Possible Bug in SQL Server 2000?

Hi guys,

I have hit this bug more than once and was wondering if anyone else
has ever seen it?

SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE A.nId IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or
B.nId IS NULL

LogTable.cId is a varchar(15) but it only has numeric data where
cTableName = 'TableA'.

I get the following error when I execute the statement.

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '1-L7Z5X' to a column of
data type int.

'1-L7Z5X' does exist in LogTable but not for 'TableA'.

Any thoughts?Is LogTable.cId varchar? You might want to restrict the where clause not
only to TableA but also to those rows where the value is actually numeric.

Or, convert A.nId to a VARCHAR before comparing.

--
http://www.aspfaq.com/
(Reverse address to reply.)

"Dave" <david_green@.softhome.net> wrote in message
news:14ec5400.0407080852.50c22022@.posting.google.c om...
> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
> LogTable.cId is a varchar(15) but it only has numeric data where
> cTableName = 'TableA'.
> I get the following error when I execute the statement.
> Server: Msg 245, Level 16, State 1, Line 1
> Syntax error converting the varchar value '1-L7Z5X' to a column of
> data type int.
> '1-L7Z5X' does exist in LogTable but not for 'TableA'.
> Any thoughts?|||"Dave" <david_green@.softhome.net> wrote in message
news:14ec5400.0407080852.50c22022@.posting.google.c om...
> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL

Sql Server is free to reorganize this query, transform the subquery into a
join, and evaluate the join criterion before the where-clause criterion. Try
casting nID to a varchar before the comparison.

SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE cast( A.nId as varchar(15)) IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or B.nId IS NULL

David|||On 8 Jul 2004 09:52:24 -0700, Dave wrote:

> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
> LogTable.cId is a varchar(15) but it only has numeric data where
> cTableName = 'TableA'.
> I get the following error when I execute the statement.
> Server: Msg 245, Level 16, State 1, Line 1
> Syntax error converting the varchar value '1-L7Z5X' to a column of
> data type int.
> '1-L7Z5X' does exist in LogTable but not for 'TableA'.
> Any thoughts?

It's not a bug. You're asking SQL to compare A.nID to each value in the
subquery. It tries to do that by (an implied) convert(int,...) operation,
which fails for the value in LogTable.

Either convert a.nID to varchar, or restrict the values in the subquery to
those that are actually numeric.

SELECT A.nID, B.nID
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB ON B.nID = A.nID
WHERE convert(varchar(15),A.nID) IN
(SELECT cID FROM Server1.MyDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
OR b.nID IS NULL

..... or .......

SELECT A.nID, B.nID
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB ON B.nID = A.nID
WHERE A.nID IN
(SELECT cID FROM Server1.MyDB_3.dbo.LogTable
WHERE cTableName = 'TableA' and ISNUMERIC(cID))
OR b.nID IS NULL

Possible Bug in SQL Server 2000?

Hi guys,
I have hit this bug more than once and was wondering if anyone else
has ever seen it?
SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE A.nId IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or
B.nId IS NULL
LogTable.cId is a varchar(15) but it only has numeric data where
cTableName = 'TableA'.
I get the following error when I execute the statement.
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '1-L7Z5X' to a column of
data type int.
'1-L7Z5X' does exist in LogTable but not for 'TableA'.
Any thoughts?Is LogTable.cId varchar? You might want to restrict the where clause not
only to TableA but also to those rows where the value is actually numeric.
Or, convert A.nId to a VARCHAR before comparing.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Dave" <david_green@.softhome.net> wrote in message
news:14ec5400.0407080852.50c22022@.posting.google.com...
> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
> LogTable.cId is a varchar(15) but it only has numeric data where
> cTableName = 'TableA'.
> I get the following error when I execute the statement.
> Server: Msg 245, Level 16, State 1, Line 1
> Syntax error converting the varchar value '1-L7Z5X' to a column of
> data type int.
> '1-L7Z5X' does exist in LogTable but not for 'TableA'.
> Any thoughts?|||[comp.databases.ms-sqlserver removed - can't send to more than 1 server]
Dave,
This isn't a bug. The optimizer is free to evaluate this query by
doing the comparison on A.nId = LogTable.cId before checking whether
cTableName is 'TableA', and presumably there are indexes in place that
make that approach better. Since you are comparing a character type to
an integer type, the character values are convered to int before the
comparison takes place. Since you can't be using an index on
LogTable.cId anyway, you can try this:
...
where A.nId IN (
select case when cTableName = 'TableA' then cast(cId as int) else NULL end
from ...
where cTableName = 'TableA'
)
If there are no non-convertible-to-int cId values in rows where
cTableName = 'TableA', the error should go away.
Steve Kass
Drew University
Dave wrote:
>Hi guys,
>I have hit this bug more than once and was wondering if anyone else
>has ever seen it?
>SELECT A.nId
> ,B.nId
>FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
>WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
>LogTable.cId is a varchar(15) but it only has numeric data where
>cTableName = 'TableA'.
>I get the following error when I execute the statement.
>Server: Msg 245, Level 16, State 1, Line 1
>Syntax error converting the varchar value '1-L7Z5X' to a column of
>data type int.
>'1-L7Z5X' does exist in LogTable but not for 'TableA'.
>Any thoughts?
>|||"Dave" <david_green@.softhome.net> wrote in message
news:14ec5400.0407080852.50c22022@.posting.google.com...
> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
Sql Server is free to reorganize this query, transform the subquery into a
join, and evaluate the join criterion before the where-clause criterion. Try
casting nID to a varchar before the comparison.
SELECT A.nId
,B.nId
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
WHERE cast( A.nId as varchar(15)) IN (SELECT cId
FROM Server1.myDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
or B.nId IS NULL
David|||On 8 Jul 2004 09:52:24 -0700, Dave wrote:
> Hi guys,
> I have hit this bug more than once and was wondering if anyone else
> has ever seen it?
> SELECT A.nId
> ,B.nId
> FROM Server1.myDB_1.dbo.TableA A
> LEFT OUTER JOIN Server2.myDB_2.dbo.TableB B ON B.nId = A.nId
> WHERE A.nId IN (SELECT cId
> FROM Server1.myDB_3.dbo.LogTable
> WHERE cTableName = 'TableA')
> or
> B.nId IS NULL
>
> LogTable.cId is a varchar(15) but it only has numeric data where
> cTableName = 'TableA'.
> I get the following error when I execute the statement.
> Server: Msg 245, Level 16, State 1, Line 1
> Syntax error converting the varchar value '1-L7Z5X' to a column of
> data type int.
> '1-L7Z5X' does exist in LogTable but not for 'TableA'.
> Any thoughts?
It's not a bug. You're asking SQL to compare A.nID to each value in the
subquery. It tries to do that by (an implied) convert(int,...) operation,
which fails for the value in LogTable.
Either convert a.nID to varchar, or restrict the values in the subquery to
those that are actually numeric.
SELECT A.nID, B.nID
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB ON B.nID = A.nID
WHERE convert(varchar(15),A.nID) IN
(SELECT cID FROM Server1.MyDB_3.dbo.LogTable
WHERE cTableName = 'TableA')
OR b.nID IS NULL
.... or .......
SELECT A.nID, B.nID
FROM Server1.myDB_1.dbo.TableA A
LEFT OUTER JOIN Server2.myDB_2.dbo.TableB ON B.nID = A.nID
WHERE A.nID IN
(SELECT cID FROM Server1.MyDB_3.dbo.LogTable
WHERE cTableName = 'TableA' and ISNUMERIC(cID))
OR b.nID IS NULL