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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select so many char of a field

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2008-12-02 : 12:22:05
How do I only select the first 20 char of a field?

Dave
Helixpoint Web Development
http://www.helixpoint.com

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-02 : 12:39:23
[code]SELECT LEFT(field,20) FROM Table [/code]
Go to Top of Page

jholovacs
Posting Yak Master

163 Posts

Posted - 2008-12-02 : 14:56:54
theoretically you could also do:

SELECT SUBSTRING(field, 1, 20);

I don't know which would be faster, although it looks like the LEFT() function should be.

___________________________
Geek At Large
Go to Top of Page
   

- Advertisement -