?
Solved

get values through embedded sql command (string builder)

Posted on 2008-10-28
2
Medium Priority
?
681 Views
Last Modified: 2012-05-05
I am trying to get values using embeded SQL.

I have written something like the following:
strQueryText.AppendLine("RuleNumber = RuleNumberBlackJack + RuleNumberPoker,")
..
..
Some Calculations
..
..
strQueryText.AppendLine("ORDER BY RuleNumber")

This works fine and it should :). But the issue is: i want to ORDER BY RuleNumberPoker which is
 
strQueryText.AppendLine("ORDER BY")
strQueryText.AppendLine("CASE WHEN RuleNumberPoker LIKE '%^[0-9.]%' then RuleNumberPoker ELSE NULL END,")
strQueryText.AppendLine("CASE WHEN RuleNumberPoker LIKE '%[0-9.]%' then CONVERT(float, RuleNumberPoker) ELSE NULL END, RuleNumberPoker")

then concatanate both the rules. How do i do achieve this, please help
0
Comment
Question by:Kerau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
CtrlAltDl earned 2000 total points
ID: 22826477
I'm not clear on what you are asking, but I'm going to take a guess that you are trying to concatenate a SQL string together.

Make sure there is a space between (before or after) each append.
strQueryText.AppendLine(" ORDER BY")
strQueryText.AppendLine(" CASE WHEN RuleNumberPoker LIKE '%^[0-9.]%' then RuleNumberPoker ELSE NULL END,")
strQueryText.AppendLine(" CASE WHEN RuleNumberPoker LIKE '%[0-9.]%' then CONVERT(float, RuleNumberPoker) ELSE NULL END, RuleNumberPoker")

Are you having troubles using the CASE statement within the ORDER BY clause?  If so there is an example 3/4 of the way down the page here:
http://www.4guysfromrolla.com/webtech/102704-1.shtml
0
 

Author Closing Comment

by:Kerau
ID: 31510723
sorry for the delayed post as i was out of town!! Thanks for your time, it was a useful information to me....Since nobody else bothered to post anything, guess what you get all the points...:)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 21 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question