Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View Question

Status
Not open for further replies.

jwestmore

Programmer
May 27, 2003
14
US
I have a SQL Server View that does a UNION on some other Views in the database. The records in the views I'm referencing are unkeyed and many of the records are identical. When my View does a SELECT from those Views it seems to want to combine the identical records into a single record. Is this a default behavior in SQL Server and if so, how do I prevent it from happening?

Thanks,
Jon
 

Try appending the word "ALL" after the UNION, like this

Code:
  select
    field1, 
    field2
  from view1

  UNION ALL

  select
    field2,
    field3
  from view2

I have never tested this on views, but it works in normal selects with tables.

“I have always found that plans are useless, but planning is indispensable.” --Dwight Eisenhower
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top