SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query to Display only required text from column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dimepop
Starting Member

30 Posts

Posted - 08/07/2012 :  08:11:30  Show Profile  Reply with Quote
Hi,
I run a query against a SQL table in order to display some reports.

USE reports
SELECT device, message

from eventlogs


The problem is that instead of returning the full message of the column i only what something specific.
For example in the following DB
Device Message
------ --------
server1 | Failed events: The drive on 'server1' at '\\server1\E$' is 96.91% full which exceeds the limit of 95%. Successful Events: The drive on 'server1' at '\\server1\C$' is 63.80% full which is under the limit of 95%.

How can i make it so on the message column only returns the following values?
Device Message
------ -------
Server1 E$=96.91%; C$=63.80%

It would be event better that if the value in under 95% then no need to show it.

Thanks

lionofdezert
Aged Yak Warrior

Pakistan
864 Posts

Posted - 08/07/2012 :  08:14:56  Show Profile  Visit lionofdezert's Homepage  Send lionofdezert a Yahoo! Message  Reply with Quote
Use SUBSTRING() and CHARINDEX() functions


--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

dimepop
Starting Member

30 Posts

Posted - 08/07/2012 :  09:20:45  Show Profile  Reply with Quote
I will look into it,
thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47189 Posts

Posted - 08/07/2012 :  10:15:51  Show Profile  Reply with Quote
so far as the format is consistent you can devise a logic using functions above. so in case of inconsistent formats you might have to break it down into batches and apply separate logic to handle each batch

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000