0

Want to retrieve records from Access through linked server in SQL Server and need to convert/cast the column with VARCHAR for some constraint.

My attempt:

SELECT Cola, Colb
FROM MSAccess_LinkedServer...TableName  
WHERE CAST([Cola] AS VARCHAR) = 'A123'

Unable to get the result from above query.

But when I remove CAST then I will get the result, but I want to know how to put the cast/convert.

2
  • 1
    Please try to provide a minimal reproducible example. What do you mean with Unable to get the result? Are there any errors? Commented May 8, 2018 at 8:28
  • There is no error, just getting column name's but no records. Commented May 8, 2018 at 9:32

1 Answer 1

1

No casting should be needed for text. How about simply:

WHERE [Cola] = 'A123'
Sign up to request clarification or add additional context in comments.

2 Comments

Columns in the WHERE clause are not fixed and so values, we need to convert them.
Field names are fixed. If you wish to modify which fields are used in a Where clause, you must rewrite the SQL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.