February 28, 2008 at 12:34 am
I have two identical databases (they need to be separate) which I'm pulling data from using a number of UNION queries. I noticed recently that some data coming back from the second database was incorrect (incorrect values for some money columns). I tracked the issue down to a view like this:
CREATE VIEW SomeTableSecondDatabase
AS
SELECT * FROM SecondDatabase.dbo.SomeTable
Which is then used in a UNION with the same table in the first database. Using sp_refreshview on the above fixed the issue, but I'd like to understand why it happened in the first place.
My guess is that the "SELECT *" is the problem as changes may have been made to the structure of the above table in both databases. The "SELECT *" was there as these databases were originally MS Access with linked tables upsized with DTS. I've changed this to pull back only the necessary columns but I'm a bit concerned it could happen again. Is my guess correct or is there something else I need to watch out for?
Thanks
February 28, 2008 at 12:58 am
Hi
do you mean to say incorrect columns or incorrect rows.
Select * will return all columns , maybe you dont require all of these.
If its returning incorrect data then probably you have to look else where .
"Keep Trying"
February 28, 2008 at 1:08 am
I mean selecting from the view like this:
SELECT SomeColumn
FROM SomeTableSecondDatabase
Returns different data to this:
SELECT SomeColumn
FROM SecondDatabase.dbo.SomeTable
I.e. querying the table direct returns different data from the same column. Obviously the correct data is returned from the second statement above.
February 28, 2008 at 11:52 pm
Hi
Was the column name changed ? was some other column renamed to the column used in the view ?
"Keep Trying"
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply