.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Imran Ghani
Post New Web Links

Case function with concantenation

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :Sql Server
 
Hi, I am trying to get a string that looks like this (05), 5 comes from ATA1 out of this sql statement and 0 is added on the front of the number so the number will look like this 05.  The following code only gives me 5 not 05.  I believe it is in the concatenation of a numeric field because 0 + 5 = 5 which is what I am getting.  I need to probably convert the field chapter to string or varchar?  Can anyone plese help with this?   Thank You! SELECT (Case CHAPTER   WHEN '0' THEN '0' + CHAPTER  WHEN '1' THEN '0' + CHAPTER WHEN '2' THEN '0' + CHAPTER WHEN '3' THEN '0' + CHAPTER WHEN '4' THEN '0' + CHAPTER WHEN '5' THEN '0' + CHAPTER          WHEN '6' THEN '0' + CHAPTER   WHEN '7' THEN '0' + CHAPTER WHEN '8' THEN '0' + CHAPTER WHEN '9' THEN '0' + CHAPTER ELSE CHAPTER END) AS ATA1,         FROM   SQLDefect_Report DEFECT AS LOGNUMBER, AC AS TAILNUMBER, REPORTED_DATE, STATION, DEFECT_DESCRIPTION AS DISCREPANCY, RESOLUTION_DESCRIPTION AS CORRECTIVEACTION, AC_POSITION AS CODE, CHAPTER, SECTION, CREATED_DATE, DEFECT_TYPE, DEFECT, DEFECT_ITEM, RESOLVED_DATE, SUBSTRING(DEFECT_TYPE, 1, 1) AS MXCODE,


View Complete Post


More Related Resource Links

Case function with concantenation

  
Hi, I am trying to get a string that looks like this (05), 5 comes from ATA1 out of this sql statement and 0 is added on the front of the number so the number will look like this 05.  The following code only gives me 5 not 05.  I believe it is in the concatenation of a numeric field because 0 + 5 = 5 which is what I am getting.  I need to probably convert the field chapter to string or varchar?  Can anyone plese help with this?   Thank You! SELECT         DEFECT AS LOGNUMBER, AC AS TAILNUMBER, REPORTED_DATE, STATION, DEFECT_DESCRIPTION AS DISCREPANCY, RESOLUTION_DESCRIPTION AS CORRECTIVEACTION, AC_POSITION AS CODE, CHAPTER, SECTION, CREATED_DATE, DEFECT_TYPE, DEFECT, DEFECT_ITEM, RESOLVED_DATE, SUBSTRING(DEFECT_TYPE, 1, 1) AS MXCODE, (Case CHAPTER     WHEN '0' THEN '0' + CHAPTER     WHEN '1' THEN '0' + CHAPTER     WHEN '2' THEN '0' + CHAPTER     WHEN '3' THEN '0' + CHAPTER     WHEN '4' THEN '0' + CHAPTER     WHEN '5' THEN '0' + CHAPTER WHEN '6' THEN '0' + CHAPTER     WHEN '7' THEN '0' + CHAPTER     WHEN '8' THEN '0' + CHAPTER     WHEN '9' THEN '0' + CHAPTER     ELSE CHAPTER   &nbs

trying to use CASE within table-valued function

  
Hi, I am trying to create a table-valued function that takes a string argument and, depending upon it's value, returns one of a number of identically-structured tables (and before someone asks why multiple identically structured tables, NOT my idea!).  I am a novice with T-SQL, but I've been attempting something like this for the function: Case @Input   When 's1' then return table1   When 's1' then return table2 End ... but I keep getting errors.  Can someone help get the ball rolling and show me the basics on how to set up a function to do this?  I'm hoping since I'm just redirecting to existing tables that this function will have minimal performance hits.

Using a User Defined Function in a case statement

  

I created a function and am trying to access it through a case statement, but I am getting the error:

Cannot find either column "core" or the user-defined function or aggregate "core.f_FiscalYear_Open_Days", or the name is ambiguous.

The case statement is below:

CASE WHEN c.program_id = 5 and CAST(minutes) As float

Visual Case Tool - UML Tutorial

  
The Class Diagram

The class diagram is core to object-oriented design. It describes the types of objects in the system and the static relationships between them.

Use Case Diagram

  
The use case diagram shows the functionality of the system from an outside-in viewpoint.

Actors (stick men) are anything outside the system that interacts with the system.

Content page control passes as argument to javascript function

  

Here is the content page:

********************************************************************

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
{
   ouput.value = input.value;
   return true;
}
 </script>
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>
</asp:Content>

********************************************************************

I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.

  

I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?


Public Shared function doubt????

  
Hi
I am using VB.net/ASP.NET and SQL Server 2000 for a web application.

For populating the dropdowns, I wrote a Public Shared function LoadDDL(), in which I pass the dataset and dropdown name to set.

I have my doubts that this function will produce unexpected results for concurrent users. And will mix the results among sessions because it is a Shared function.

I am confused here. Is it the right way to go?

Please advice. Thanks in advance.

Pankaj

Trim function in C Sharp

  
Hi,
How do i use "trim" function in C Sharp? I have a string and i want to strip off spaces from the end of the string. Any idea how do i do it??

Thanks
may~

SWITCH...CASE STATEMENT

  

Hello, i need help changing the following code into a switch...case statementUndecided

<script runat="server">
void Page_Load()
{
 
    if (Page.IsPostBack)
    {
    public String toSring()
    {
    int intcomputerChoice=1;
        
         if(computerChoice==1)
         {
         return(Rock);
       }
       if(computerChoice==2)
         {
         return(Paper);
       }
       if(computerChoice==3)
         {
         return(Scissors);
       }
       }
       if (Page.IsPostBack)
      {

Editor's Note: In Case You Hadn't Noticed .

  

Find out what's new for MSDN Magazine, including a print redesign and the introduction of virtual labs on our web site so you can experiment with our code.

Howard Dierking

MSDN Magazine June 2008


Pure C++: Invoking Generic or Function Templates

  

As I promised last time, in this month's column I'll walk through the process of defining and invoking a generic or template function under C++\CLI. A function template or a generic function begins with the template or generic keyword followed by its parameter list.

Stanley B. Lippman

MSDN Magazine October 2005


Cutting Edge: Using an Eval Function in Web Services

  

Web Services are often presented as the perfect tool for pro-grammers. They're interoperable, based on open standards such as SOAP and WSDL, and are fully integrated with the Microsoft® . NET platform.

Dino Esposito

MSDN Magazine September 2002


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend