Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Im trying to join a table using a like clause between two table fields.(Code Below) Can i do this? Obviously by having the field b.invoicecompany in quotes sql is seeing it as a string however i want sql to see it as its table field value with wildcards before and after its value. Is there a way i can do this, is there some type of escape character i need to be using?Thanx in advance.create table xxx as select a.cusmerge, a.contmerg, a.firstname, a.surname, a.name, a.postal_cd, b.F3, b.InvoiceCompany, b.InvoicePostcode, b.email from rulebr.xxx a inner join rulebr.xxx_WEB bon a.firstname=b.name anda.surname=b.F3where a.name like '% b.invoicecompany%';
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-09-26 : 01:40:04
try like this
create table view xxx as select a.cusmerge, a.contmerg, a.firstname, a.surname, a.name, a.postal_cd, b.F3, b.InvoiceCompany, b.InvoicePostcode, b.email from rulebr.xxx a inner join rulebr.xxx_WEB bon a.firstname=b.name anda.surname=b.F3and a.name like '%' + b.invoicecompany + '%'