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
 General SQL Server Forums
 New to SQL Server Programming
 dealing with numbers in text field

Author  Topic 

Mike.C
Starting Member

2 Posts

Posted - 2015-03-29 : 19:49:31
I have run into a problem when searching for a Movie title that is a number (like the movie name 21)

This is an access database and the Movie_Name is a text field

The SQL I am using is
Select * from Movie_Data where Movie_Title = ‘” & Movie_Name & “’”

This works perfectly for everything except when the Movie_Name = a number

Is there a way to make this search work with both characters and numbers?

cheers
Mike

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2015-03-30 : 08:42:22
You might try
Movie_Title = CStr( Movie_Name )
Go to Top of Page

Ash1807
Starting Member

10 Posts

Posted - 2015-03-30 : 09:23:18
James,

That worked a treat, using just varchar for all the fields for a "staging" table. Now the task of moving these raw fields into formatted fields

Thank you James, but may come back for further advice on the 2nd hoop.
Wish me luck



Ash Gajjar
Go to Top of Page

Mike.C
Starting Member

2 Posts

Posted - 2015-03-30 : 11:34:01
Thanks James

Tried your suggestion and it didn't work. So, I build a test DB and everything worked perfectly. Tried the real DB again and same error. Found out that anytime there was only a number in the title field there was an extra (invisible) character added during the import process, so the query failed. Everything now works.............

cheers
Mike
Go to Top of Page
   

- Advertisement -