| Author |
Topic |
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2012-04-05 : 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. RegardsAnkitaAnkita |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-05 : 01:18:08
|
| make use of substring and charindex functions------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sql-programmers
Posting Yak Master
190 Posts |
Posted - 2012-04-05 : 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 Consultantshttp://www.sql-programmers.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-05 : 10:25:42
|
another waySELECT REPLACE(STUFF(field,1,CHARINDEX('(',Field),''),')','') FROM table------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2012-04-08 : 23:30:00
|
| Thanks Visakh for your kindl reply But i am getting an errorMsg 8116, Level 16, State 1, Line 1Argument data type text is invalid for argument 1 of stuff function.Ankita |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-08 : 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 MVPhttp://visakhm.blogspot.com/ |
 |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2012-04-08 : 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:39i 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 OCMQM1Ankita |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-09 : 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 MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|