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.
Author |
Topic |
janjan
Starting Member
1 Post |
Posted - 2004-09-06 : 23:01:40
|
I need to write a script, or a formula for Crystal (and I am a newbie at SQL) that will select from a db field - names which contain "()" in the middle of the name, but not at the end of a name. The field contains a paranthesis at the end of each name which will be filtered out while writing the Crystal Report. But I need to check first which names contain a parenthesis within the name first, so I don't filter out the wrong ones. THANKS ! |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2004-09-06 : 23:05:31
|
This should be done in the source query rather than in the crystal code/formula.SELECT field1, field2FROM myTableWHERE field1 LIKE '%()%' This will filter out the records you need. The best thing for you to do is write and test the query in Query Analyser (assuming you're using SQL Server) to verify that you're getting the correct records. Then use this query as the basis of your report. |
|
|
sabirpatel
Starting Member
22 Posts |
Posted - 2004-09-22 : 02:54:10
|
just go through the sytax it will help to exactly construct your query.% Any string of zero or more characters. WHERE title LIKE '%computer%' finds all book titles with the word 'computer' anywhere in the book title. _ (underscore) Any single character. WHERE au_fname LIKE '_ean' finds all four-letter first names that end with ean (Dean, Sean, and so on). [ ] Any single character within the specified range ([a-f]) or set ([abcdef]). WHERE au_lname LIKE '[C-P]arsen' finds author last names ending with arsen and beginning with any single character between C and P, for example Carsen, Larsen, Karsen, and so on. Any single character not within the specified range ([^a-f]) or set ([^abcdef]). WHERE au_lname LIKE 'de[^l]%' all author last names beginning with de and where the following letter is not l. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-09-22 : 07:14:56
|
s.b. '%()_'Assuming you are looking for the two consecutive chars ().I would advise that you always base the crystal reports on stored procs. Much easier to develop and maintain. Leave crystal to do the report formatting and the SP to produce the data for the report - and do as much as possible in the SP.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|