SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


UNION error


UNION error

Author
Message
Mauve
Mauve
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3206 Visits: 2065
I agree with "J"!

Although I had selected "change the data type to varchar(max)" I removed it as the scenario had stated that no duplicates could be assumed. Therefore, the only proper solution (workaround) to the problem stated was to use UNION ALL -- which, by the way should have used in the first place if the data is not duplicated between the two tables.

A data type change to a table is NOT a "workaround".


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
J-440512
J-440512
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1639 Visits: 949
Now,

69% of reponses were right (UNION ALL).

So, peasants, let's organize. Pick up your torches and pitchforks and let's all walk up to Frankenstein's castle!
Carla Wilson-484785
Carla Wilson-484785
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2272 Visits: 1951
JohnG (11/6/2008)
A data type change to a table is NOT a "workaround".


While I agree that a datatype change to an existing production table may not be a work-around, I do think this is an important idea for future design - to move away from the use of text datatypes and use varchar(max) instead.
Mauve
Mauve
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3206 Visits: 2065
Carla Wilson (11/6/2008)
JohnG (11/6/2008)
A data type change to a table is NOT a "workaround".


While I agree that a datatype change to an existing production table may not be a work-around, I do think this is an important idea for future design - to move away from the use of text datatypes and use varchar(max) instead.


Totally agree that the new "max" data types should be used vs. TEXT and NTEXT for all new development work. And, where possible, they should be changed in existing applications. However, such a change is not simple as code (T-SQL or other) may be using special functions and/or methods that are only applicable to TEXT and NTEXT.

The scenario presented would indicate that it was an existing application as a "workaround" (sic) was needed. If on the other hand, the scenario had started off with "you are designing tables for a new application..." the "change the data type" answer would apply.


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
JestersGrind
JestersGrind
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3899 Visits: 1585
It was my understanding that varchar(max) was meant to be a replacement to the text data type because of the issue that this question raises as well as other like:

Being able to use varchar(max) as a local variable (can't with text)
Being able to use most string functions with it

It can still hold 2Gb of data like text can, so what would this break?

Please correct me if I'm wrong. These discussions are great!

Greg



Mauve
Mauve
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3206 Visits: 2065
G² (11/6/2008)
It was my understanding that varchar(max) was meant to be a replacement to the text data type because of the issue that this question raises as well as other like:

Being able to use varchar(max) as a local variable (can't with text)
Being able to use most string functions with it

It can still hold 2Gb of data like text can, so what would this break?

Please correct me if I'm wrong. These discussions are great!

Greg


Yes, all of the above is true. That is why I have changed my usage when we dropped SQL Server 2000 support. As to breakage, the application could be using READTEXT, WRITETEXT, UPDATETEXT, TEXTPTR, etc. See the BOL for details.


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
JestersGrind
JestersGrind
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3899 Visits: 1585
JohnG (11/6/2008)
G² (11/6/2008)
It was my understanding that varchar(max) was meant to be a replacement to the text data type because of the issue that this question raises as well as other like:

Being able to use varchar(max) as a local variable (can't with text)
Being able to use most string functions with it

It can still hold 2Gb of data like text can, so what would this break?

Please correct me if I'm wrong. These discussions are great!

Greg


Yes, all of the above is true. That is why I have changed my usage when we dropped SQL Server 2000 support. As to breakage, the application could be using READTEXT, WRITETEXT, UPDATETEXT, TEXTPTR, etc. See the BOL for details.



That's a good point. I hadn't thought of the text specific functions.

Thanks,

Greg



Mauve
Mauve
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3206 Visits: 2065
G² (11/6/2008)
[quote]
That's a good point. I hadn't thought of the text specific functions.

Thanks,

Greg


Now you know why just performing an "ALTER TABLE" to change the data type could not be considered a "workaround" to the specific query problem. The entire application could fail.


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
J-440512
J-440512
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1639 Visits: 949
DOCTOR FRANKENSTEIN

OPEN UP !
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91142 Visits: 38945
Not mentioned as an answer, but here is a workaround using varchar(max) (or nvarchar(max)); build views over the two tables and cast the text/ntext column as a varchar(max)/nvarchar(max) datatype in the select statement.

There is your workaround, and it doesn't affect the underlying table or procedures that work with the text/ntext column.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search