Solved

get values through embedded sql command (string builder)

Posted on 2008-10-28
2
678 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
2 Comments
 
LVL 14

Accepted Solution

by:
CtrlAltDl earned 500 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

Technology Partners: 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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 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