Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Updating RN_Descritor with binary values and text

Author  Topic 

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2009-11-12 : 12:17:35
I am trying to update a tables rn_descriptor field using columns defined in the same table (see below).

I get "The data types binary and varchar are incompatible in the boolean AND operator." when I run the update statement.

Data_Cert_Template_Id, product_id, service_id are binary fields.
Check_Area is text.

Can anyone help me out with the correct syntaxt?

Thanks


begin transaction
update Data_Cert_Template
set rn_descriptor = Data_Cert_Template_Id & ' - ' & Product_Id & '/' & Service_Id & ' ' & Check_Area

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-11-12 : 12:28:03
convert them to varchar when you are trying to append them together.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2009-11-12 : 12:34:50
Got it to work.....


begin transaction
update Data_Cert_Template
set rn_descriptor = cast(cast(Data_Cert_Template_Id as int) as varchar) + ' - ' + cast(cast(Product_Id as int) as varchar) +
+ '/' + cast(cast(Service_Id as int) as varchar) + ' ' + Check_Area
--rollback
--commit
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-11-12 : 12:40:22
not sure why you would do a double cast. Why not just once as varchar?

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -