473,395 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problems with Adding text

We are trying to translate some raw flat data into a cart. What we have done is BCP the raw files into the database, and then we begin to run a series of SQL commands to copy the data and format it for the cart. This ultimatly takes 3 different flat file databases and merges them all into one. The current problem is with the following command:

Expand|Select|Wrap|Line Numbers
  1. update [translation-new].dbo.products 
  2. set 
  3.     tp.thumbnail = 'graphics/00000001/thumbs/'+td.ProdImage+'.jpg', 
  4.     tp.image = 'graphics/00000001/'+td.ProdImage+'.jpg',
  5.     tp.descrip = td.ProdDescription+'<BR><BR>'+td.MarketingDescription
  6. from
  7.     [translation-new].dbo.products as tp, datapaq.dbo.cnetprodinfo as td
  8. where tp.TDProdID = td.ProdID;
When the comand executes, i get:

Expand|Select|Wrap|Line Numbers
  1. Msg 402, Level 16, State 1, Line 37
  2. The data types text and varchar are incompatible in the add operator.
I find this very strange, as i used this type of syntax in a different query.

Expand|Select|Wrap|Line Numbers
  1. insert into 
  2.     [translation-new].dbo.comersusproducts 
  3.         (suppliername, sku, description, details, smallimageurl, imageurl, price, listprice, cost, weight,
  4.          length, height, width, recordsource)
  5. select
  6.     datapaq.dbo.datapaq.manufacturername, datapaq.dbo.datapaq.manufacturerprodid, datapaq.dbo.datapaq.proddescription,
  7.     datapaq.dbo.datapaq.proddescription, 'graphics/00000001/thumbs/'+datapaq.dbo.cnetprodinfo.prodimage+'.jpg',
  8.     'graphics/00000001/'+datapaq.dbo.cnetprodinfo.prodimage+'.jpg', datapaq.dbo.datapaq.msrp, datapaq.dbo.datapaq.msrp,
  9.     datapaq.dbo.price.prodprice, datapaq.dbo.datapaq.prodweight, datapaq.dbo.datapaq.prodlength,
  10.     datapaq.dbo.datapaq.prodheight, datapaq.dbo.datapaq.prodwidth, 'TD'
  11. from
  12.     datapaq.dbo.cnetprodinfo, datapaq.dbo.datapaq, datapaq.dbo.price
  13. where
  14.         datapaq.dbo.cnetprodinfo.prodid = datapaq.dbo.datapaq.prodid 
  15.     AND 
  16.         datapaq.dbo.cnetprodinfo.prodid = datapaq.dbo.price.prodid;
The difference between these two, is that the one is a select and the other is an update. So, trying to be crafty id did the following:

Expand|Select|Wrap|Line Numbers
  1. update tp 
  2. set 
  3.     tp.thumbnail = (select 'graphics/00000001/'+ProdImage+'.jpg' from datapaq.dbo.cnetprodinfo where prodid = td.prodid),
  4.     tp.image = (select 'graphics/00000001/thumbs'+ProdImage+'.jpg' from datapaq.dbo.cnetprodinfo where prodid = td.prodid),
  5.     tp.descrip = (select proddescription+'<br><br>'+marketingdescription from datapaq.dbo.cnetprodinfo where prodid = td.prodid)
  6. from
  7.     [translation-new].dbo.products as tp, datapaq.dbo.cnetprodinfo as td
  8. where tp.TDProdID = td.ProdID;
At first i only did the thumbnail field. removing the others, and i ran the query. It worked. Great! I added the other two fields and it failed due to the same error again. What is goin on?! So i broke it down more, and removed the last line dealing with marketing descriptions... worked again. so its this last line.

The marketingdescription and proddescription, are text types. i dont think ill be able to make them varchar as some of these descriptions are pretty big. Also, the field i am copying these to, is a text type. so it seems to be a limitation of the + operator on the datatype. So i guess the question in short is....

How do you merge "textfield1" & 'text string' & "textfield2", where textfield is a field that is of type "text". For example if the fields above pull from the database:

textfield1 = 'This is product description 1'
textfield2 = 'This is product description 2'
the value updated in the cart table, for the [full product description] is:
"This is product description 1text stringThis is product description 2"

Thanks

--Dave
Nov 28 '06 #1
2 13008
I am just posting to ask if the question i posed is clear. I know it can take some time to get a reply, and that i may not get one at all, but i dont want my posting to be overlooked, as this is pretty much a show stopper for us at the moment.

the basic of my question is:

I have three tables, they have 1 field that is type 'Text'

I am trying to take the text field from 2 of the tables and combine them to make one field to put into the 3rd table.

--Dave
Nov 30 '06 #2
ymk
24
I am just posting to ask if the question i posed is clear. I know it can take some time to get a reply, and that i may not get one at all, but i dont want my posting to be overlooked, as this is pretty much a show stopper for us at the moment.

the basic of my question is:

I have three tables, they have 1 field that is type 'Text'

I am trying to take the text field from 2 of the tables and combine them to make one field to put into the 3rd table.

--Dave

I don't think SQL allows to concatenate two fields of Datatype 'text'.

You might need to use either Cast or Convert functions to acheive it.

For Ex:
A -- DataType 'text'
B -- DataType 'text'
Inserting into another column C

Update TableA
Set C = Convert(VarChar(80),A) + Convert(VarChar(80),B)
Nov 30 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sérgio Almeida | last post by:
Greetings I'm having problems adding records to an access database. What I want to do is very simple. Here is my code. __CODE_START__ dim sqlStatement sqlStatement="insert into...
9
by: Eva | last post by:
Hi, I wanted to know how i can enter values into a specific column of a listview. I have tried the following code but this seems to enter all my values into the first column!!! Can anyone...
0
by: Duncan Spence | last post by:
Hi all, I'm sure I'm doing something silly here, but can't see it! I'm creating a series of combo boxes on a Windows Form in VB.NET. The lists of all of the comboboxes are identical and are...
32
by: Ed Jay | last post by:
A complete js newbie is asking this question: I have a form comprised of several questions, each answered with a radio button. I'd like to use onClick to bring up additional text at the end of...
1
by: thusnani | last post by:
Im trying to add txtBox1 + txtBox2 + txtBox3 + txtBox4 + txtBox5 + txtBox6 + txtBox7 + txtBox8 + txtBox9 + txtBox10 = txtBoxTotal Now im to write some code so everytime i enter a number into a...
3
by: Metalzed | last post by:
Hi I want to have a log so in my table i got a TEXT field called LOGG. I want to update this field with new data by adding more text to field. I am using MS SQL 'test' + 'test' doesn't...
7
by: joecap5 | last post by:
I have a main window from which I want to open a separate side menu window. I then want to create a list of items on that side menu by clicking on the item names in the main window. So far I am...
8
by: Nimion | last post by:
Im getting the "Syntax error in INSERT INTO statement." at my da.Update(ds, "Expenses") line in code... heres my full code to follow. ...
5
by: Alex Dransfield | last post by:
I am trying to add text to a shape but I can't figure out how to do it.. I am using the method public void DrawOnDoc(object oMissing, Microsoft.Office.Interop.Word._Document oDoc) { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.