| Author |
Topic |
|
yazasi
Starting Member
11 Posts |
Posted - 2008-10-17 : 00:23:03
|
| I have the following two servers with two tables that have two columns in common which are: (Customer_ID) and (Customer_Key_NO)that have the same data. What I need to do is to pull all customer info from Table_2 where column Management_Area_Code has one of these codes: 'A!' or '?B' or '=C' knowing that this column can have a wildcard such as: A! ?B =C ~X /FServer_1 Table_1 Customer_ID Management_Area_Code Server_2Table_2Customer_Key_NoAddressCityStateZip_CodeThe query I've used is:SELECT *FROM OPENQUERY (Server_2, 'SELECT Customer_Key_No,Address,City,State,Zip_Code From Table_2')I INNER JOIN Table_1 K ON K.Customer_ID = I.Customer_Key_No Where Management_Area_Code LIKE ''A!'' or Management_Area_Code LIKE ''?B!''-- I'm getting this error: ---- Msg 170, Level 15, State 1, Line 7 ---- Line 7: Incorrect syntax near 'A'. --Can anyone help with this one?.Thanks. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
yazasi
Starting Member
11 Posts |
Posted - 2008-10-17 : 00:30:48
|
| I'm using SQL 2005 and that's what it takes, when I use sibgle quotes it give million of errors. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
yazasi
Starting Member
11 Posts |
Posted - 2008-10-18 : 01:22:36
|
| Tara, when I put the single quotes it gives me an error stating that the table view could not be located. and when I use a "simple query" with double quotes it does return rows needed.Thanks. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-18 : 02:08:02
|
quote: Originally posted by yazasi Tara, when I put the single quotes it gives me an error stating that the table view could not be located. and when I use a "simple query" with double quotes it does return rows needed.Thanks.
single quotes will work. Are you sure you're running this code on server1? |
 |
|
|
malaytech2008
Yak Posting Veteran
95 Posts |
Posted - 2008-10-18 : 23:39:18
|
| use single quotes instead of double quotes.single works fine in SQL server 2005malay |
 |
|
|
yazasi
Starting Member
11 Posts |
Posted - 2008-10-20 : 02:01:25
|
| Will do. Thanks. |
 |
|
|
yazasi
Starting Member
11 Posts |
Posted - 2008-10-20 : 21:42:11
|
| It kept giving me an error when I used the single quote. However, it did work with the double quotes. Don't ask me how, but this is what it is :)Thank all for the help. I really appreciated. I'm new to this forum and I realized it is a big help to everyone beginers and pros. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-20 : 23:45:12
|
quote: Originally posted by yazasi It kept giving me an error when I used the single quote. However, it did work with the double quotes. Don't ask me how, but this is what it is :)Thank all for the help. I really appreciated. I'm new to this forum and I realized it is a big help to everyone beginers and pros.
can you show final query used? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-21 : 04:22:38
|
| TrySELECT *FROM OPENQUERY (Server_2, 'SELECT Customer_Key_No,Address,City,State,Zip_CodeFrom Table_2')IINNER JOIN Table_1 KON K.Customer_ID = I.Customer_Key_NoWhere Management_Area_Code LIKE 'A!' or Management_Area_Code LIKE '?B!'MadhivananFailing to plan is Planning to fail |
 |
|
|
|