Home > Archive > Microsoft SQL Server forum > January 2006 > select cast help needed









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author select cast help needed
T.M.

2006-01-26, 4:57 pm

What is the correct syntax for querying the first 20 characters of a
memo field?

I'm trying to
SELECT CAST (varchar(20) fieldname) as newfieldname
and i get a bunch of errors

Can someone please help me?

MS Access DB used with ColdFusion

Thanks
KenJ

2006-01-26, 4:57 pm

I don't have access installed but, I think you can just use the left
function...

SELECT left(fieldName, 20) as newFieldName

T.M.

2006-01-26, 4:57 pm

Thank you.
That works for one field. What if I wanted to get the first 20
characters from multiple fields? I'm trying to display the first few
lines of few articles. Each article has its own field in the db. Any ideas?


KenJ wrote:
> I don't have access installed but, I think you can just use the left
> function...
>
> SELECT left(fieldName, 20) as newFieldName
>

Hugo Kornelis

2006-01-26, 4:57 pm

On Wed, 25 Jan 2006 20:39:45 -0500, T.M. wrote:

>What is the correct syntax for querying the first 20 characters of a
>memo field?
>
>I'm trying to
>SELECT CAST (varchar(20) fieldname) as newfieldname
>and i get a bunch of errors
>
>Can someone please help me?
>
>MS Access DB used with ColdFusion
>
>Thanks


Hi T.M.,

For Access help, you might want to post to an Access group. This group
is for SQL Server. :-)

In SQL Server, you'd use

SELECT CAST(fieldname AS varchar(20)) AS newfieldname FROM tablename

I have no idea how well that would port to Access.

--
Hugo Kornelis, SQL Server MVP
Erland Sommarskog

2006-01-26, 4:57 pm

T.M. (iamcarterwells@yaho
o.com) writes:
> Thank you.
> That works for one field. What if I wanted to get the first 20
> characters from multiple fields? I'm trying to display the first few
> lines of few articles. Each article has its own field in the db. Any
> ideas?


comp.databases.ms-access


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com