[Forum FAQ] How to use multiple field terminators in BULK INSERT or BCP command line

Introduction
Some people want to know if we can have multiple field terminators in BULK INSERT or BCP commands, and how to implement multiple field terminators in BULK INSERT or BCP commands.
Solution
For character data fields, optional terminating characters allow you to mark the end of each field in a data file with a field terminator, as well as the end of each row with a row terminator. If a terminator character occurs within the data, it is interpreted
as a terminator, not as data, and the data after that character is interpreted and belongs to the next field or record. I have done a test, if you use BULK INSERT or BCP commands and set the multiple field terminators, you can refer to the following command.
In Windows command line,
bcp <Databasename.schema.tablename> out “<path>” –c –t –r –T
For example, you can export data from the Department table with bcp command and use the comma and colon (,:) as one field terminator.
bcp AdventureWorks.HumanResources.Department out C:\myDepartment.txt -c -t ,: -r \n –T
The txt file as follows:
However, if you want to bcp by using multiple field terminators the same as the following command, which will still use the last terminator defined by default.
bcp AdventureWorks.HumanResources.Department in C:\myDepartment.txt -c -t , -r \n -t: –T
The txt file as follows:
When multiple field terminators means multiple fields, you use the below comma separated format,
column1,,column2,,,column3
In this occasion, you only separate 3 fields (column1, column2 and column3). In fact, after testing, there will be 6 fields here. That is the significance of a field terminator (comma in this case).
Meanwhile, using BULK INSERT to import the data of the data file into the SQL table, if you specify terminator for BULK import, you can only set multiple characters as one terminator in the BULK INSERT statement.
USE <testdatabase>;
GO
BULK INSERT <your table> FROM ‘<Path>’
 WITH (
DATAFILETYPE = ' char/native/ widechar /widenative',
 FIELDTERMINATOR = ' field_terminator',
For example, using BULK INSERT to import the data of C:\myDepartment.txt data file into the DepartmentTest table, the field terminator (,:) must be declared in the statement.
In SQL Server Management Studio Query Editor:
BULK INSERT AdventureWorks.HumanResources.DepartmentTest FROM ‘C:\myDepartment.txt’
 WITH (
DATAFILETYPE = ‘char',
FIELDTERMINATOR = ‘,:’,
The new table contains like as follows:  
We could not declare multiple field terminators (, and :) in the Query statement,  as the following format, a duplicate error will occur.
In SQL Server Management Studio Query Editor:
BULK INSERT AdventureWorks.HumanResources.DepartmentTest FROM ‘C:\myDepartment.txt’
 WITH (
DATAFILETYPE = ‘char',
FIELDTERMINATOR = ‘,’,
FIELDTERMINATOR = ‘:’
However, if you want to use a data file with fewer or more fields, we can implement via setting extra field length to 0 for fewer fields or omitting or skipping more fields during the bulk copy procedure.  
More Information
For more information about filed terminators, you can review the following article.
http://technet.microsoft.com/en-us/library/aa196735(v=sql.80).aspx
http://social.technet.microsoft.com/Forums/en-US/d2fa4b1e-3bd4-4379-bc30-389202a99ae2/multiple-field-terminators-in-bulk-insert-or-bcp?forum=sqlgetsta
http://technet.microsoft.com/en-us/library/ms191485.aspx
http://technet.microsoft.com/en-us/library/aa173858(v=sql.80).aspx
http://technet.microsoft.com/en-us/library/aa173842(v=sql.80).aspx
Applies to
SQL Server 2012
SQL Server 2008R2
SQL Server 2005
SQL Server 2000
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

Thanks,
Is this a supported scenario, or does it use unsupported features?
For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
in a supported way?
Thanks! Josh

Similar Messages

  • Multiple field terminators in BULK INSERT or BCP

    Can i have multiple field terminators  in BULK INSERT or BCP commands i,e, define more than 1 for a file?
    Pls provide example.

    Hi stellios,
    For character data fields, optional terminating characters allow you to mark the end of each field in a data file with a field terminator and the end of each row with a row terminator. If a terminator character occurs within the data, it is interpreted as
    a terminator, not as data, and the data after that character is interpreted as belonging to the next field or record. I do a test, if you use BULK INSERT or BCP commands and set the multiple field terminators, you can refer to the following command.
    In Windows command line:
    bcp AdventureWorks.HumanResources.Department in C:\myDepartment.txt -c -t ,: -r \n –T
    ---you can use the two characters as one terminators, it can do well
    --if you want to bcp by using multiple field terminators just like the following command, it will still use the last terminator defined by default.
    bcp AdventureWorks.HumanResources.Department in C:\myDepartment.txt -c -t , -r \n -t: –T
    If you specify terminator for  BULK import. You can only set one terminator in the BULK INSERT statement.
    USE <testdatabase>;
    GO
    BULK INSERT <your table> FROM ‘<Path>’
       WITH (
    DATAFILETYPE = 'char',
    FIELDTERMINATOR = ',',
    ROWTERMINATOR = '\n'
    GO
    For more information about filed terminators, you can review the following article.
    http://technet.microsoft.com/en-us/library/aa196735(v=sql.80).aspx
    http://technet.microsoft.com/en-us/library/ms191485.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • [Forum FAQ] How to use parameter to control the Expand/Collapse drill-down options in SSRS report?

    In SQL Server Reporting Services (SSRS), drill-down is an action we can apply to any report item to hide and show other report items. They all are ways that we can organize and display data to help our users understand our report better. In this article,
    we are talking about how to use parameter to control the Expand/Collapse drill-down options in SSRS report.
    Consider that the report has a dataset (dsSales) with following fields: SalesTerritoryGroup, SalesTerritoryCountry, CalendarYear, SalesAmount.
    1. The report has the following group settings:
    Parent Group: SalesTerritoryGroup
     Child Group: SalesTerritoryCountry
      Child Group: CalendarYear
       Details: SalesAmount
    2. Add three parameters in the report:
    GroupExpand:
    Available Values: “Specify values”
    Label: Yes           Value: Yes
    Label: No            Value: No
    Default Values: “Specify values”
    Value: Yes
    CountryExpand:
    Available Values: “Specify values”
    Label: Yes           Value: =IIF(Parameters!GroupExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No","No","Yes")
    YearExpand:
    Available Values: “Specify values”
    Label: Yes          
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No","No","Yes")
    3. Right click SalesTerritoryCountry icon in the Row Groups dialog box, select Group Properties.
    4. Click Visibility in the left pane. Select “Show or hide based on an expression” and type with following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", False, True)
    Select “Display can be toggled by this report item” option, and select “SalesTerritoryGroup” in the drop down list.
    5. Use the same method setting CalendarYear, (Details) drill-down with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", False, True)
    =IIF(Parameters!YearExpand.Value="Yes", False, True)
    6. Click SalesTerritoryGroup text box in the tablix. Select InitialToggleState property in the Properties dialog box, and type following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", True, False)
    7. Use the same method setting SalesTerritoryCountry, CalendarYear text box with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", True, False)
    =IIF(Parameters!YearExpand.Value="Yes", True, False)
    After that, when we preview the report, we can use these three parameters to expand/collapse drill-down.
    Note:
    In our test, we may meet following issue. We can check the expression of InitialToggleState property to troubleshooting the issue.
    Applies to
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012

    In SQL Server Reporting Services (SSRS), drill-down is an action we can apply to any report item to hide and show other report items. They all are ways that we can organize and display data to help our users understand our report better. In this article,
    we are talking about how to use parameter to control the Expand/Collapse drill-down options in SSRS report.
    Consider that the report has a dataset (dsSales) with following fields: SalesTerritoryGroup, SalesTerritoryCountry, CalendarYear, SalesAmount.
    1. The report has the following group settings:
    Parent Group: SalesTerritoryGroup
     Child Group: SalesTerritoryCountry
      Child Group: CalendarYear
       Details: SalesAmount
    2. Add three parameters in the report:
    GroupExpand:
    Available Values: “Specify values”
    Label: Yes           Value: Yes
    Label: No            Value: No
    Default Values: “Specify values”
    Value: Yes
    CountryExpand:
    Available Values: “Specify values”
    Label: Yes           Value: =IIF(Parameters!GroupExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No","No","Yes")
    YearExpand:
    Available Values: “Specify values”
    Label: Yes          
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No","No","Yes")
    3. Right click SalesTerritoryCountry icon in the Row Groups dialog box, select Group Properties.
    4. Click Visibility in the left pane. Select “Show or hide based on an expression” and type with following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", False, True)
    Select “Display can be toggled by this report item” option, and select “SalesTerritoryGroup” in the drop down list.
    5. Use the same method setting CalendarYear, (Details) drill-down with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", False, True)
    =IIF(Parameters!YearExpand.Value="Yes", False, True)
    6. Click SalesTerritoryGroup text box in the tablix. Select InitialToggleState property in the Properties dialog box, and type following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", True, False)
    7. Use the same method setting SalesTerritoryCountry, CalendarYear text box with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", True, False)
    =IIF(Parameters!YearExpand.Value="Yes", True, False)
    After that, when we preview the report, we can use these three parameters to expand/collapse drill-down.
    Note:
    In our test, we may meet following issue. We can check the expression of InitialToggleState property to troubleshooting the issue.
    Applies to
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012

  • [Forum FAQ]How to use Azure Cross-Platform Command-Line interface in Mac OS

    1. Download the installer on Microsoft Azure website.
    Figure 1.
    2. Open the DMG file and install the following package.
    Figure 2.
    3. Open Terminal (Mac OS build-in), type “azure login” and enter your azure account to login.
    (Note: you can login only via a Microsoft organizational account or service principal.) We used a Microsoft account to connect. (Figure 3)
    Figure 3.
    After that, we can use the commands to manager Azure instances and services. You can type “azure help” to list all the available commands.
    Figure 4.
    If you want to view the detailed information for a specific command, you can type “azure help xxx”. For example, we can run “azure
    help vm” to list all the commands for managing Azure Virtual Machines.
    Figure 5.
    In the figure below, we used the “vm create” command to create a new virtual Machine (testmachine002) in a new cloud service (testmachine003)
    and virtual network (vnet1).
    Figure 6.
    To obtain the image name, you can type “azure vm image list”:
    Figure 7.
    After the “vm create” command executed, we can find that the Virtual Machine(testmachine002) is created in Azure management portal.
    Figure 8.
    More information:
    http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Here on Apple Discussions, you will find many command line enthusiasts hanging out in the UNIX forum. Good luck.

  • How to use long capture filter with Network Monitor 3.4 command line

    I want to exclude all traffic from a list of subnets in my capture. This makes for a rather long and complex filter. Is there any option on the command line to refer to a file describing this filter or can one only use the /capture "my extremely long
    filter" command? So, I would have to make the entire thing into one line?

    I suppose if it's longer than 2048 or 4096, there will be a command line length limitation.  Maybe there's a way to work around it with a environment variable, but I think there will always be a limit.  Perhaps there's an easier way to right your
    filter?  Can you use something like the subnet example in the library to shorten the filter.
    Also, do you think your filter will affect capturing speed.  The more complex the filter, the longer it takes to evaluate each incoming message.  That means we have to buffer, and if the firehose is too much, we don't catch all the water :) 
    If the UI can keep up, then it shouldn't be a problem, but some firehoses are bigger than others.  Plus, there driver filters which can filter faster for NMCap.
    Moving forward, Message Analyzer (http://blogs.technet.com/blogs), is the replacement for Network Monitor, which can do the same most of the same kinds of capabilities, but using powershell.  I think you'd
    have more flexibility with variable lengths there.  Plus you can script fancy things.
    Paul

  • How to Use Associated App to open a file in Linux command line?

    Hi all,
    I know in windows i call always run:
    Runtime.exec("start aPicture.jpg");in order to use the default picture viewer to view the pictures
    Runtime.exec("start aEmail.eml");in order to use the default email viewer to view the .eml file
    is there a simular command in linux as well? does it depend on different distributions as well?
    thank you.

    is there a simular command in linux as well? does it
    depend on different distributions as well?In linux it's different because the handling is done by the desktop environment. KDE has it's own file associations and Gnome has it's own. There might be some way to start a file like that, but you first need to see which DE is installed (if any) and start it using that DE's method.
    But I don't know how to do it, even though most likely it's possible.
    Sincerely,
    Jussi

  • How to use multiple ipods on one account

    I have an Ipod classic and just bought my sons two nano's how do I use these on the same account without changing my account info?

    Take a look here:
    How to use multiple iPods with one computer
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Discussions page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums, in the User Tips Library and in the Apple Knowledge Base before you post a question.
    Regards.

  • How to use multiple table in single control file?

    Hi,
    How to use multiple table and data file in sigle control file? I have a four table and four csv file i mean data file for that. I am running concurrent program to load the data from csv file to custom table. based on my input data file name, it has to take automatically from one control file.
    Can anyone share with me how can i acheive this?
    Thanks

    Hi,
    Can't we acehive like below. I don't this exactly corrcect.
    OPTIONS (SKIP=1)
    LOAD DATA
    INFILE << file name 1 >>
    APPEND INTO TABLE XXCZ_VA_SAMPLE1
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
         PARENT_ITEM               "TRIM(BOTH FROM :PARENT_ITEM)"
    LOAD DATA
    INFILE << file name 2 >>
    APPEND INTO TABLE XXCZ_VA_SAMPLE2
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
         ITEM_NUMBER               "TRIM(BOTH FROM :ITEM_NUMBER)"
    )Edited by: orasuriya on Sep 14, 2009 3:03 AM

  • How to use multiple JREs (1.5.0_20 and 1.6.0_07) with Internet Explorer 8?

    Hi!
    Question about the problem mentioned in subject.
    I have configured that JNLP opens with 1.5 version, both versions are enabled in Java Control Panel Runtime Settings but when I try to start a desktop java console says:
    Java Web Start 1.5.0_22
    Using JRE version 1.6.0_07 Java HotSpot(TM) Client VM
    And the opening of the desktop creates an exception:
    Java Web Start - Invalid Argument Error
    TooManyArgumentsException[ Too many arguments supplied: {C:\WINDOWS\Temporary, Internet, Files\Content.IE5\....
    I'm trying to open my desktop with 1.5 version and other programs with 1.6 version. What is it that I still need to do? I'm kind of confused with this. Some of my collagues have succeeded with this and some doesn't, with the same configuration.
    So the question is, how to use multiple JREs with IE8 so that one application uses 1.5 version and others 1.6 version?
    Br,
    Katri
    Edited by: ka**** on 09-Mar-2011 01:16
    Edited by: ka**** on 09-Mar-2011 03:16

    ka**** wrote:
    ..Question about the problem mentioned in subject.No "Using multiple JREs (1.5.0_20 and 1.6.0_07) with Internet Explorer 8" is a statement. To transform it to a question would be something like "How to use multiple JREs (1.5.0_20 and 1.6.0_07) with Internet Explorer 8?".
    Once you can come up with an actual question, I might look at this more closely.

  • How to use multiple VCI strings for lap 1300 and 1200 (option 60) in one pool?

    Hi All,
    Hope to you a very happy new year,
    I have two differnt LAP 1300 and 1200 in my network and I need to add theme to the WLC,
    I successed to add one of theme by the option 60 in the DHCP pool at the Core SW,
    So my quetion is below:
    How to use multiple VCI strings for lap 1300 and 1200 (option 60) in one pool?
    Thanks in Advanced,
    Ahmed,

    To add to Scott's post.  Option 60 would be useful if you needed to put certain types of AP on specific controllers.  Otherwise, no real need to use it for the most part.
    Though, I do recall an issue a few years ago that some windows machines had issues getting DHCP if option 43 is being returned.
    Now, on an IOS switch, you can only configure one option 60 per DHCP scope
    HTH,
    Steve
    Please remember to rate useful posts, and mark questions as answered

  • How to use multiple selection parameters in the data model

    Hi, after have looked all the previous threads about how to use multiple selection parameters , I still have a problem;
    I'm using Oracle BI Publisher 10.1.3.3.2 and I'm tried to define more than one multiple selection parameters inside the data template;
    Inside a simple SQL queries they work perfectly....but inside the data template I have errors.
    My data template is the following (it's very simple...I am just testing how the parameters work):
    <dataTemplate name="Test" defaultPackage="bip_departments_2_parameters">
    <parameters>
    <parameter name="p_dep_2_param" include_in_output="false" datatype="character"/>
    <parameter name="p_loc_1_param" include_in_output="false" datatype="character"/>
    </parameters>
    <dataTrigger name="beforeReport" source="bip_departments_2_parameters.beforeReportTrigger"/>
    <dataQuery>
    <sqlStatement name="Q2">
    <![CDATA[
    select deptno, dname,loc
    from dept
    &p_where_clause
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_DEPT" source="Q2">
    <element name="deptno" value="deptno"/>
    <element name="dname" value="dname"/>
    <element name="loc" value="loc"/>
    </group>
    </dataStructure>
    </dataTemplate>
    The 2 parameters are based on these LOV:
    1) select distinct dname from dept (p_dep_2_param)
    2) select distinct loc from dept (p_loc_1_param)
    and both of them have checked the "Multiple selection" and "Can select all" boxes
    The package I created, in order to use the lexical refence is:
    CREATE OR REPLACE package SCOTT.bip_departments_2_parameters
    as
    p_dep_2_param varchar2(14);
    p_loc_1_param varchar2(20);
    p_where_clause varchar2(100);
    function beforereporttrigger
    return boolean;
    end bip_departments_2_parameters;
    CREATE OR REPLACE package body SCOTT.bip_departments_2_parameters
    as
    function beforereporttrigger
    return boolean
    is
    l_return boolean := true;
    begin
    if (p_dep_2_param is not null) --and (p_loc_1_param is not null)
    then
    p_where_clause := 'where (dname in (' || replace (p_dep_1_param, '''') || ') and loc in (' || replace (p_loc_1_param, '''') || '))';
    else
    p_where_clause := 'where 1=1';
    end if;
    return (l_return);
    end beforereporttrigger;
    end bip_departments_2_parameters;
    As you see, I tried to have only one p_where_clause (with more than one parameter inside)....but it doesn't work...
    Using only the first parameter (based on deptno (which is number), the p_where_clause is: p_where_clause := 'where (deptno in (' || replace (p_dep_2_param, '''') || '))';
    it works perfectly....
    Now I don't know if the problem is the datatype, but I noticed that with a single parameter (deptno is number), the lexical refence (inside the data template) works.....with a varchar parameter it doesn't work....
    So my questions are these:
    1) how can I define the p_where_clause (inside the package) with a single varchar parameter (for example, the department location name)
    2) how can I define the p_where_clause using more than one parameter (for example, the department location name and the department name) not number.
    Thanks in advance for any suggestion
    Alex

    Alex,
    the missing thing in your example is the fact, that if only one value is selected, the parameter has exact this value like BOSTON. If you choose more than one value, the parameter includes the *'*, so that it looks like *'BOSTON','NEW YORK'*. So you need to check in the package, if there's a *,* in the parameter or not. If yes there's more than one value, if not it's only one value or it's null.
    So change your package to (you need to expand your variables)
    create or replace package bip_departments_2_parameters
    as
    p_dep_2_param varchar2(1000);
    p_loc_1_param varchar2(1000);
    p_where_clause varchar2(1000);
    function beforereporttrigger
    return boolean;
    end bip_departments_2_parameters;
    create or replace package body bip_departments_2_parameters
    as
    function beforereporttrigger
    return boolean
    is
    l_return boolean := true;
    begin
    p_where_clause := ' ';
    if p_dep_2_param is not null then
    if instr(p_dep_2_param,',')>0 then
    p_where_clause := 'WHERE DNAME in ('||p_dep_2_param||')';
    else
    p_where_clause := 'WHERE DNAME = '''||p_dep_2_param||'''';
    end if;
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || ' AND LOC IN ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || ' AND LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    else
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || 'WHERE LOC in ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || 'WHERE LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    end if;
    return (l_return);
    end beforereporttrigger;
    end bip_departments_2_parameters;
    I've written a similar example at http://www.oracle.com/global/de/community/bip/tipps/Dynamische_Queries/index.html ... but it's in german.
    Regards
    Rainer

  • How to use multiple iPods

    I have multiple iPods & iPhones & I'd like to share my library with them all.  How do I do this??? How can I share content outside of purchased iTunes?

    See this for some tips:  How to use multiple iPods, iPads, or iPhones with one computer, http://support.apple.com/kb/HT1495

  • How To Use Multiple Currencies in single payroll ........

    Dear All
    Can you help me How To Use Multiple Currencies in single payroll?
    with regards
    User600722

    I am not a functional expert. but ML Note 150173.1 (which is quite old) states that this is not possible.
    Srini

  • How to use multiple statements inside the "THEN" block of CASE statement?

    Below is the code:
    SET @strTempString = case @strKeyMode
    WHEN 'AUTO/CYCLE'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'CYCLE'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'COMMERCIAL'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'ISNAP'
    THEN  set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + '  ', 2) + '  ', 2))))
    '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType
    WHEN 'ASNAP'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'MOAT'
    THEN  @strRefID + '|' + @strRetID
    else '0'
    end 
    The first 3 conditions are understandable. How to use multiple statements in 4th case?
    Here I first want to set the value as:
    set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + '  ', 2) + '  ', 2))))
    and then return the string '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType to @strTempString. 
    Please help me remove the syntax errors.
    Thanks in advance.

    Try below SQL
    DECLARE @strKeyMode varchar(20) = 'ISNAP'
    DECLARE @SQL VARCHAR(MAX)
    DECLARE @strRefID int=1
    DECLARE @strRetID INT=2
    --FIRST WAY
    IF @strKeyMode ='AUTO/CYCLE'
    SELECT CAST(@strRefID as varchar(10))
    ELSE IF @strKeyMode ='CYCLE'
    SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
    ELSE IF @strKeyMode='ISNAP'
    SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
    ELSE
    SELECT @SQL='ABC'
    print @sql
    ----SECOND WAY
    SELECT @SQL = CASE @strKeyMode
    WHEN 'AUTO/CYCLE' THEN CAST(@strRefID as varchar(10))
    WHEN 'CYCLE' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
    WHEN 'ISNAP' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
    ELSE 'No Record'
    END
    PRINT (@SQL)
    --Prashanth

  • How to use multiple classes for each form

    Hi,
    I have created two forms using screen painter and now i want to use different classes for these two forms .
    I have declared the Sbo Connection in main class i.e. Set Application ,Connection Context() but while connecting to other classes
    for executing the code for that form SAP is not connected to that class.How to use multiple classes functionality i don't able to
    do that.Please provide some sample codes for that as it will be more helpful for me to understand.
    Thanks & Regards,
    Amit

    Hi Amit,
    In fact, its more advisable to use separate classes for every form that you use.  Have one common class, say, for eg., clsMain.cs which has all the connection and connectivity to other classes, wherein, the menu event and item event of this main class, will just be calling the menu / item event of other classes.
    The individual functionality of the child classes will be called from the item / menu event of the respective classes.
    Item event in clsMain.cs will be as below.
    private void oApplication_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
                SAPbouiCOM.Form oForm;
                BubbleEvent = true;
                try
                    if ((pVal.FormTypeEx == "My_Form1Type") && (pVal.EventType != SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD))
                        oForm = oApplication.Forms.GetForm("My_FormType", pVal.FormTypeCount);
                        NameSpace.Repots.ClsForm1.ClsForm1_ItemEvent(oApplication, oCompany, oForm, ref pVal, ref BubbleEvent);
                    if ((pVal.FormTypeEx == "My_Form2Type") && (pVal.EventType != SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD))
                        oForm = oApplication.Forms.GetForm("My_FormType", pVal.FormTypeCount);
                        NameSpace.Repots.ClsForm1.ClsForm2_ItemEvent(oApplication, oCompany, oForm, ref pVal, ref BubbleEvent);
    Now, in the individual classes, you can have their respective item events, which will be called from the main class, and the respective functionalities will occur.
    Hope this helps.
    Regards,
    Satish.

Maybe you are looking for