SQL Question

View: New views
8 Messages — Rating Filter:   Alert me  

SQL Question

by Robert Harrison-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 
This seems like something I should know, but DUH, here goes:

Lets say I have a field that may have a really long data string, say
50,000 characters, but I only need the first 300 characters. Anything
beyond that is a waste of system resources.

Is there a way in the SQL select statement I can retreive only the first
XX characters of a field string?

Thanks,

Robert B. Harrison
Director of Interactive Services, Ext. 205

155 East Main Street
Smithtown, NY 11787
P (631) 361-4400
F (631) 361-6400
http://www.linx.com
 
 
 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:25:2042
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/25
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:25
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.25
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Parent Message unknown RE: SQL Question

by Rob Mackenzie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You should be able to do it with a LEFT() statement:

SELECT Left(myColumn,300) AS myColumnTruncated...

Rob Mackenzie
Jera Technology

-----Original Message-----
From: Robert Harrison [mailto:RobertH@...]
Sent: Wednesday, November 23, 2005 10:01 AM
To: NYCFUG
Subject: SQL Question

 
This seems like something I should know, but DUH, here goes:

Lets say I have a field that may have a really long data string, say
50,000 characters, but I only need the first 300 characters. Anything
beyond that is a waste of system resources.

Is there a way in the SQL select statement I can retreive only the first
XX characters of a field string?

Thanks,

Robert B. Harrison
Director of Interactive Services, Ext. 205

155 East Main Street
Smithtown, NY 11787
P (631) 361-4400
F (631) 361-6400
http://www.linx.com
 
 
 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:25:2043
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/25
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:25
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.25
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Parent Message unknown RE: SQL Question

by Cook, Scott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Depending on the DB, this works in Sybase probably MS SQL too

select convert(varchar(300),textfield) as field300

-----Original Message-----
From: Robert Harrison [mailto:RobertH@...]
Sent: Wednesday, November 23, 2005 10:01 AM
To: NYCFUG
Subject: SQL Question


 
This seems like something I should know, but DUH, here goes:

Lets say I have a field that may have a really long data string, say
50,000 characters, but I only need the first 300 characters. Anything
beyond that is a waste of system resources.

Is there a way in the SQL select statement I can retreive only the first
XX characters of a field string?

Thanks,

Robert B. Harrison
Director of Interactive Services, Ext. 205

155 East Main Street
Smithtown, NY 11787
P (631) 361-4400
F (631) 361-6400
http://www.linx.com
 
 
 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get Instant Hacker Protection, Virus Detection, Antispam & Personal Firewall.
http://www.houseoffusion.com/banners/view.cfm?bannerid=62

Message: http://www.houseoffusion.com/lists.cfm/link=i:25:2044
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/25
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:25
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.25
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Re: SQL Question

by Dave Carabetta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/23/05, Robert Harrison <RobertH@...> wrote:

>
> This seems like something I should know, but DUH, here goes:
>
> Lets say I have a field that may have a really long data string, say
> 50,000 characters, but I only need the first 300 characters. Anything
> beyond that is a waste of system resources.
>
> Is there a way in the SQL select statement I can retreive only the first
> XX characters of a field string?
>

It would help if you told us what database you're using! ;)

In Oracle, you can do SUBSTR(myColumn, 1, 300). I'm sure SQL Server
has an equivalent, whether it be SUBSTR() or a LEFT() function or
something.

Regards,
Dave.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:25:2045
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/25
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:25
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.25
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

RE: SQL Question

by Donn Morrill II :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

SELECT LEFT(some_field,300) FROM table_foo

---------------------------------------------------
Donn Morrill                  TGP Associates, Inc.
Director of Technology        212-695-1010 x112
dmorrill@...    www.tgpassociates.com
 

-----Original Message-----
From: Robert Harrison [mailto:RobertH@...]
Sent: Wednesday, November 23, 2005 10:01 AM
To: NYCFUG
Subject: SQL Question

 
This seems like something I should know, but DUH, here goes:

Lets say I have a field that may have a really long data string, say 50,000
characters, but I only need the first 300 characters. Anything beyond that
is a waste of system resources.

Is there a way in the SQL select statement I can retreive only the first XX
characters of a field string?

Thanks,

Robert B. Harrison
Director of Interactive Services, Ext. 205

155 East Main Street
Smithtown, NY 11787
P (631) 361-4400
F (631) 361-6400
http://www.linx.com
 
 
 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:25:2046
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/25
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:25
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.25
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Parent Message unknown RE: SQL Question

by Cook, Scott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, who won that one? :-)

-----Original Message-----
From: Robert Harrison [mailto:RobertH@...]
Sent: Wednesday, November 23, 2005 10:01 AM
To: NYCFUG
Subject: SQL Question
 
This seems like something I should know, but DUH, here goes:

Lets say I have a field that may have a really long data string, say
50,000 characters, but I only need the first 300 characters. Anything
beyond that is a waste of system resources.

Is there a way in the SQL select statement I can retreive only the first
XX characters of a field string?

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.csfb.com/legal_terms/disclaimer_external_email.shtml

==============================================================================


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
 Save $10 Download ZoneAlarm Security Suite
http://www.houseoffusion.com/banners/view.cfm?bannerid=66

Message: http://www.houseoffusion.com/lists.cfm/link=i:25:2047
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/25
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:25
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.25
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Re: SQL Question

by Dave Carabetta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/23/05, Cook, Scott <scott.cook@...> wrote:
> Ok, who won that one? :-)
>

Ha! I didn't even realize there were this many people on the list!
Good to know there's still CF in New York other than my job!

Regards,
Dave.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:25:2048
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/25
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:25
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.25
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Parent Message unknown RE: SQL Question

by Robert Harrison-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks. I'm doing a complex and writing a Google Like search query and
string parse and I go brain dead on something I should now in my sleep,
but the help is appreciated.

And as I saw the emails coming I said each time, in the immortal words
of Homer Simpson... DUH!

Well, I was looking forward to Turkey day... Just didn't know I'd be the
Turkey.

Thanks Everyone.


Robert B. Harrison
Director of Interactive Services, Ext. 205

155 East Main Street
Smithtown, NY 11787
P (631) 361-4400
F (631) 361-6400
http://www.linx.com
 
 
 
-----Original Message-----
From: Dave Carabetta [mailto:dcarabetta@...]
Sent: Wednesday, November 23, 2005 10:29 AM
To: NYCFUG
Subject: Re: SQL Question

On 11/23/05, Cook, Scott <scott.cook@...> wrote:
> Ok, who won that one? :-)
>

Ha! I didn't even realize there were this many people on the list!
Good to know there's still CF in New York other than my job!

Regards,
Dave.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get help! RoboHelp
http://www.houseoffusion.com/banners/view.cfm?bannerid=58

Message: http://www.houseoffusion.com/lists.cfm/link=i:25:2049
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/25
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:25
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.25
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54