| Author |
Topic  |
|
|
amurark
Yak Posting Veteran
India
50 Posts |
Posted - 04/05/2012 : 00:47:47
|
Hi All, Please tell me if i want to print only Deepika Katoch from below data in crystal report. How to do it. Like this data between brackets get changed,. Thanks in advance. *** 04/04/12 11:11:19(Deepika Katoch) *** Kindly do the needful. Regards Ankita
Ankita |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48076 Posts |
Posted - 04/05/2012 : 01:18:08
|
make use of substring and charindex functions
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
sql-programmers
Posting Yak Master
USA
189 Posts |
Posted - 04/05/2012 : 02:01:34
|
Use this in your Query,
SELECT SUBSTRING('04/04/12 11:11:19(Deepika Katoch)' , CHARINDEX( '(', '04/04/12 11:11:19(Deepika Katoch)') + 1, CHARINDEX(')', '04/04/12 11:11:19(Deepika Katoch)') - CHARINDEX('(', '04/04/12 11:11:19(Deepika Katoch)') -1 )
SQL Server Programmers and Consultants http://www.sql-programmers.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48076 Posts |
Posted - 04/05/2012 : 10:25:42
|
another way
SELECT REPLACE(STUFF(field,1,CHARINDEX('(',Field),''),')','') FROM table
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
amurark
Yak Posting Veteran
India
50 Posts |
Posted - 04/08/2012 : 23:30:00
|
Thanks Visakh for your kindl reply
But i am getting an error Msg 8116, Level 16, State 1, Line 1 Argument data type text is invalid for argument 1 of stuff function.
Ankita |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48076 Posts |
Posted - 04/08/2012 : 23:34:27
|
you should have told us this before. STUFF wont work with text datatype. then you've to use substring and charindex functions.
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
amurark
Yak Posting Veteran
India
50 Posts |
Posted - 04/08/2012 : 23:35:43
|
Hi sql programmers,
Thanks alot for your reply. IT woked for me
But right now i want to cahgne the foramt of the field in the below
21/06/10 11:08:39 from to 06/21/10 11:08:39
i want to print it in mm-dd-yyyy format but its not gettting printed.
SELECT SUBSTRING(Comments , CHARINDEX( '***', comments) + 3, CHARINDEX('(', comments) - CHARINDEX('***', comments) -3),CONVERT(VARCHAR(25),SUBSTRING(Comments , CHARINDEX( '***', comments) + 3, CHARINDEX('(', comments) - CHARINDEX('***', comments) -3),101) as [mm/dd/yyyy] ,comments, SUBSTRING(Comments , CHARINDEX( '(', comments) + 1, CHARINDEX(')', comments) - CHARINDEX('(', comments) -1 ) as Resolved_By , * from OCMQM1
Ankita |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48076 Posts |
Posted - 04/09/2012 : 00:30:50
|
why should you do it in sql? why cant you return it as datetime and do formatting at front end?
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|