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.
| Author |
Topic |
|
Yanix
Starting Member
3 Posts |
Posted - 2003-07-30 : 11:03:44
|
Hi,I used the search, but I didn't find exactly what I am looking for...I have mboc field as an integer and I would like to do a WHERE IN clause but the field where I would be looking at is a varchar.For example:My mboc =2 (mboc is integer)My chainnum = 4, 9, 10 (chainnum is varchar)When I tried to do a select somethingfrom mytablewhere (mboc in (chainnum)) Yes..it gets me errors because of the different data types.I tried to convert the chainnum into integer but it didn't work for me so I tried to convert mboc to a varchar using the convert, but then I will need to convert the chainnum field into something like this: '4', '9', '11' to make it works...or if you have more ideas, they will be appreciated.Summary..I am trying to convert a varchar field values such as: 3, 9, 10to also varchar but with values such as:'3', '9', '10'Thank you so much.Yanira |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2003-07-30 : 11:09:38
|
| WHERE CAST(mboc as varchar) IN ('4','9','10')I can also use a udf so you can pass a string to in.Do a search on UDF and IN() and there are some post on the topic. |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
|
|
Yanix
Starting Member
3 Posts |
Posted - 2003-07-30 : 12:03:07
|
| Perfect! Thank you so much ValterBorges and Page47 The CSV link is really useful. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-07-30 : 12:54:38
|
| We should have a poll about the most asked sql question...This has GOT to be itBrett8-) |
 |
|
|
Yanix
Starting Member
3 Posts |
Posted - 2003-07-30 : 13:26:24
|
| X002548,I didn't know that the question was asked before. I tried to do the search, but without doing a search by the concept of cvs because I never heard of it or had that situation.Thanks again ValterBorges and Page47 for taking the time to reply and referred me to that link. |
 |
|
|
|
|
|
|
|