Declare field as a variable in SQL

I decalred one field as a variable and i am trying to execute the query. but it throwing error. what is the correct way to pass the variable.
Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near 'g'.
declare
@Query
as
varchar(3000),
@price_type
as
varchar(50)
set
@price_type =
'g.nHighPrice'
set
@Query =
'SELECT top 2 g.tPriceDescID as price_desc_id , e.tName as price_type_name
       ,g.tEffectiveDate as effective_date '
+ @price_type+'
       ,g.nMidPrice as mid_price, a.tpricename as price_comment
       ,g.nPostingPrice  as posting_price
       FROM  MdPriceDesc a
      inner join  Company b on a.yPublishCompanyID=b.yOid
      inner join Commodity c on a.yPublishCommodityID = c.yOid
      inner join Location d on a.yLocationID=d.yOid
      inner join MdPriceType e on a.yPriceTypeID = e.yOid
inner join MDR.dbo.MdPriceDetail g on g.tPriceDescID=a.tPriceDescID
execute(@Query)

There is an error with your script..
@Query =
'SELECT top 2 g.tPriceDescID as price_desc_id , e.tName as price_type_name
       ,g.tEffectiveDate as effective_date '
+ @price_type+'
you are missing a comma (,) '...as effective_date, '
Please click "Mark As Answer" if my post helped. Tony C.

Similar Messages

  • Exception in declarative section to propagating in PL/SQL Block

    Hi All, I have a requirement to send emails to some receipient whenever there is an error in a process. The is working untill the put a wrong database link in the parameter, the cursor is in declarative statement, hence when other exception does not work, create and enclosing block around the initial block so that the exception can propagate to the enclosing block, but this does not work either, please advice. Below is the a brief pseudo code. The bold is the initial block. Please advice.
    DECLARE
    Invalid_table EXCEPTION;
    PRAGMA EXCEPTION_INIT(Invalid_table, -00942);
    BEGIN
    declare
    c_test number;
    cursor c1 is select 1 from tt@sro4link1 --- wrong databaselink sent as a parameter
    where 1 =1;
    */*Because the error is in the cursor select, no email is been sent, that was the reason I put an enclosing block, but the exception is not propagate either */*
    BEGIN
    OPEN C1;
    FETCH C1 into c_test;
    CLOSE C1;
    EXCEPTION
    WHEN OTHERS THEN
    --- Send email
    END; EXCEPTION
    WHEN Invalid_table THEN
    --- send email
    END;
    /

    Ade2 wrote:
    it is not a dynamic sql. Your description is not very clear about what is code and what is pseudo code, but if you are using substitution variables in sqlplus, then that is dynamic SQL.
    sqlplus scans for substitution variables, prompts when needed, replaces the variable (substitutes) with the text input and passes the entire result to the database for validation.
    If the substitution text input results in an invalid PL/SQL block then a compilation error is returned from the database. The PL/SQL cannot be compiled, it never runs, no run time exceptions are possible.
    So you cannot use exceptions to detect errors in values input to substitution variables.
    SQL> declare
      2    l_dummy number;
      3  begin
      4    select 1 into l_dummy from dual;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> declare
      2    l_dummy number;
      3  begin
      4    &5
      5  end;
      6  /
    Enter value for 5: select 1 into l_dummy from dual;
    old   4:   &5
    new   4:   select 1 into l_dummy from dual;
    PL/SQL procedure successfully completed.
    SQL> /
    Enter value for 5: this will not compile
    old   4:   &5
    new   4:   this will not compile
      this will not compile
    ERROR at line 4:
    ORA-06550: line 4, column 8:
    PLS-00103: Encountered the symbol "WILL" when expecting one of the following:
    := . ( @ % ;

  • Using Bind variables in SQL PLUS Report

    using Bind variables in SQL PLUS Report. This report gets the arguments from the application concurrent program. Now my need is to convert the start_date and end_date to bind Variables to improve the performance. I have commented the original code in 'prompt List of Unapproved Adjustments' and used my Bind Variable but it is giving an error
    error: Bind Variable "ENDING_DATE" not declared
    Report Date and Time:
    26-OCT-2010 15:44:13
    List of Unapproved Adjustments
    Bind Variable 'ENDING_DATE" not declared
    Please see below the code for the sql plus report:
    define p_org_id           = '&1'
    define p_fy_begin_date = '&2'
    define p_start_date = '&3'
    define p_end_date = '&4'
    define p_conversion = '&5'
    declare
    variable begin_date date;
    exec :begin_date := p_start_date;
    variable ending_date date;
    exec :ending_date := p_end_date;
    /* Begin
    :begin_date := to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS');
    :ending_date := to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS');
    End; */
    set newpage none
    set termout off
    set pagesize 55
    set linesize 180
    set heading on
    set feedback off
    set wrap off
    set space 1
    set heading on
    begin
    dbms_application_info.set_client_info('&p_org_id');
    end;
    prompt
    prompt Report Date and Time:
    prompt ----------------------
    select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
    from dual ;
    prompt
    prompt List of Unapproved Adjustments
    prompt -------------------------------
    select b.trx_number,
    a.adjustment_number,
    f.user_name created_by
    from apps.ar_adjustments a,
    apps.ra_customer_trx b,
    apps.fnd_user f
    where a.customer_trx_id = b.customer_trx_id
    and a.status <> 'A'
    and a.created_by = f.user_id
    and a.creation_date between :begin_date
    and :ending_date
    -- and a.creation_Date between to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS')
    -- and to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS')
    order by
    b.trx_number ;

    Hi
    Please go to customization part of the report and verify..You have set a default value out there ..And also verify your lov and look at the values ..If it is again giving you the problem ..pl delete the report and develop it again from the scratch it will be solved...
    vishnu
    null

  • Using variables in SQL Loader

    Is it possible to pass or set a variable in SQL LOADER? In this case I want the file name (eg $data) that is getting passed from the command line to load into my table into the extract_date field.
    For example. The command line:
    sqlldr user/password control=deposit.ctl data=080322.txt
    Control file:
    Load data
    infile '$data'
    Append into table deposit
    , id position (1-10)
    , extract_date date "YYMMDD" $data
    Any thoughts?

    user567866 wrote:
    Is it possible to pass or set a variable in SQL LOADER? In this case I want the file name (eg $data) that is getting passed from the command line to load into my table into the extract_date field.
    For example. The command line:
    sqlldr user/password control=deposit.ctl data=080322.txt
    Control file:
    Load data
    infile '$data'
    Append into table deposit
    , id position (1-10)
    , extract_date date "YYMMDD" $data
    Any thoughts?Just wonder, why do you need a variable, if you are passing the filename on the command line? The sqlldr is perfectly capable to read the data from the file given as argument with parameter data. Just remove the line with infile from your controlfile and leave your commandline as is.
    Best regards
    Maxim

  • How to get a field that using variable in order to create a query

    Hi,
    I found a difficulty when creating a query. so, I would like to ask you some question.
    1. How to get a field that using variable which that field I want to put it in my query?
    For example, I would like to take quantity field in inventory audit report. And when I put my cursor in
    quantity field, there was only variable, item, etc. How to get this and put it in query?
    2. How to combined the invoice quantity with inventory audit report quantity?
    3. I have a query like this:
    SELECT distinct T0.[DocDate] as 'Tanggal', T0.[DocNum] as 'No.Faktur', T1.[ItemCode] as 'Kode Barang',
    T1.[Dscription] as 'Deskripsi', T1.[Quantity] as 'Quantity', ((T1.[LineTotal])/(T1.[Quantity])) as 'Harga
    Satuan', T1.[LineTotal] as 'Harga Total', T3.[CalcPrice] as 'HPP Satuan', ((T3.[CalcPrice]) * (T1.
    [Quantity])) as 'HPP Total', T4.[ItmsGrpNam] as 'Jenis Barang', T5.[SlpName] as 'Nama Sales', T1.
    [WhsCode] as 'Kode Gudang' FROM [dbo].[OINV] T0 INNER JOIN [dbo].[INV1] T1 ON T0.DocEntry =
    T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OINM T3 ON T2.ItemCode
    = T3.ItemCode INNER JOIN OITB T4 ON T2.ItmsGrpCod = T4.ItmsGrpCod INNER JOIN OSLP T5 ON
    T0.SlpCode = T5.SlpCode WHERE T3.[TransType] = '13' and T3.[CreatedBy] = T1.[DocEntry] and T0.
    [DocDate] >=[%0] and T0.[DocDate] <=[%1] and T4.[ItmsGrpNam] =[%2] and T1.[WhsCode] =[%3]
    Is it possible if I just take one invoice with invoice quantity and only show up at once although I have a
    lot item cost for that item? (because I'm using FIFOmethod).
    Please help me.. cause I'm stuck with this thing :l.
    Thank you very much, and I'm waiting your respon soon.
    Regards,
    Sisca

    Try this one:
    SELECT distinct T0.DocDate as 'Tanggal', T0.DocNum as 'No.Faktur', T1.ItemCode as 'Kode Barang',
    T1.Dscription as 'Deskripsi', T1.Quantity as 'Quantity', ((T1.LineTotal)/(T1.Quantity)) as 'Harga
    Satuan', T1.LineTotal as 'Harga Total', T3.CalcPrice as 'HPP Satuan', ((T3.CalcPrice) * (T1.
    Quantity)) as 'HPP Total', T4.ItmsGrpNam as 'Jenis Barang', T5.SlpName as 'Nama Sales', T1.
    WhsCode as 'Kode Gudang'
    FROM dbo.OINV T0 INNER JOIN dbo.INV1 T1 ON T0.DocEntry =T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OINM T3 ON T2.ItemCode = T3.ItemCode AND T3.TransType = '13' and T3.CreatedBy = T1.DocEntry AND T3.Warehouse = T1.WhsCode
    INNER JOIN OITB T4 ON T2.ItmsGrpCod = T4.ItmsGrpCod
    INNER JOIN OSLP T5 ON T0.SlpCode = T5.SlpCode
    WHERE T0.DocDate >=[%0\] and T0.DocDate <=[%1\] and T4.ItmsGrpNam =[%2\] and T1.WhsCode =[%3\]
    Thanks,
    Gordon

  • Error with define substitution variable in SQL

    Hi there,
    I am using PL/SQL developer and trying to define a substitution variable as follows:
    define freq = 'Weekly'
    Then later on, in my SQL statement, I used this variable in WHERE statement as follows:
    WHERE ... (&freq = 'Weekly') and ...
    But I got the "ORA-00904: "WEEKLY": invalid identifier" error.
    Where is the problem?
    Thanks in advance!

    I don't know about PL/SQL developer but in sqlplus you need single quotes around the variable.
    SQL> define freq = 'Weekly'
    SQL> select null from dual
      2  where &freq = 'Weekly';
    old   2: where &freq = 'Weekly'
    new   2: where Weekly = 'Weekly'
    where Weekly = 'Weekly'
    ERROR at line 2:
    ORA-00904: "WEEKLY": invalid identifier
    SQL> edi
    Wrote file afiedt.sql
      1  select null from dual
      2* where '&freq' = 'Weekly'
    SQL> /
    old   2: where '&freq' = 'Weekly'
    new   2: where 'Weekly' = 'Weekly'
    N
    SQL>

  • How to specify XML declaration in an XML Variable

    I had posted this question in the Flex Builder discussion,
    but I am not sure if that was the right board, so posting it again
    here:
    I need to set the XML declaration for my XML variable as
    follows:
    var employees:XML =
    <?xml version="1.0" encoding="utf-8"?>
    <employees>
    <employee ssn="123-123-1234">
    <name first="John" last="Doe"/>
    <address>
    <street>11 Main St.</street>
    <city>San Francisco</city>
    <state>CA</state>
    <zip>98765</zip>
    </address>
    </employee>
    <employee ssn="789-789-7890">
    <name first="Mary" last="Roe"/>
    <address>
    <street>99 Broad St.</street>
    <city>Newton</city>
    <state>MA</state>
    <zip>01234</zip>
    </address>
    </employee>
    </employees>;
    However, if I specify <?xml version="1.0"
    encoding="utf-8"?>, I get a design time and compile error. If I
    remove it it works fine. But the server to which I send this XML is
    expecting the declaration. How can I set the declaration?
    Any help or pointer is appreciated.

    I am not able to load the xml. Can anybody figure out the
    problem :
    I have used a LoadXML class :
    package {
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    // Demonstrates the code required to load external XML
    public class LoadXML extends Sprite {
    // The property that will eventually contain the loaded XML
    private var novel:XML;
    // The object used to load the XML
    private var urlLoader:URLLoader;
    // Constructor
    public function LoadXML () {
    // Specify the location of the external XML
    var urlRequest:URLRequest = new URLRequest("novel.xml");
    // Create an object that can load external text data
    urlLoader = new URLLoader();
    // Register to be notified when the XML finishes loading
    urlLoader.addEventListener(Event.COMPLETE,
    completeListener);
    // Load the XML
    urlLoader.load(urlRequest);
    // Method invoked automatically when the XML finishes
    loading
    private function completeListener(e:Event):void {
    // The string containing the loaded XML is stored in the
    URLLoader
    // object's data property (urlLoader.data). To create a new
    XML
    // instance from that loaded string, we pass it to the XML
    constructor
    novel = new XML(urlLoader.data);
    trace(novel.toXMLString()); // Display the loaded XML, now
    converted
    // to an XML object
    And in main.mxml :
    myXml = new LoadXml ;
    trace ( myXml.novel ) ;
    The output is errenous

  • How to specify the XML Declaration for an XML variable

    I need to set the XML declaration for my XML variable as
    follows:
    var employees:XML =
    <?xml version="1.0" encoding="utf-8"?>
    <employees>
    <employee ssn="123-123-1234">
    <name first="John" last="Doe"/>
    <address>
    <street>11 Main St.</street>
    <city>San Francisco</city>
    <state>CA</state>
    <zip>98765</zip>
    </address>
    </employee>
    <employee ssn="789-789-7890">
    <name first="Mary" last="Roe"/>
    <address>
    <street>99 Broad St.</street>
    <city>Newton</city>
    <state>MA</state>
    <zip>01234</zip>
    </address>
    </employee>
    </employees>;
    However, if I specify <?xml version="1.0"
    encoding="utf-8"?>, I get a design time and compile error. If I
    remove it it works fine. But the server to which I send this XML is
    expecting the declaration. Can somebody help me with this?
    Thanks

    I work mostly with the Java versions of the parser so you'll have to make the translation to C++. As far as I know, you can't use the SAX API to access to the encoding.
    You need to use the DOM along with Oracle's extension to the basic DOM functionality. Oracle's package, oracle.xml.parser.v2 defines a class which implements the Document interface called XMLDocument. This class has a method, getEncoding(), which returns the encoding. You would use the method in getDocument() in the Parser base class inherited by DOMParser to retrive the XMLDocument.
    Jeff

  • Passing Global Variable in Sql Object

    Hi
    How can i pass my global variable into SQL object? I tried to pass it but then I tried to update the schema it giving me the error at varble
    Please advise me

    The Update schema is used only to get the structure for the Output.
    Once you have a valid structure and the SQL Parses without any variables use the syntax for applying variables as in any Script within DI.
    $GV_MyVar enclosed within square brackets will be replaced by Value of the variable.
    $GV_MyVar enclosed within curly brackets will be replaced by Value of the variable enclosed in single quotes.
    When the job runs, the variables will be replaced with values OR values with quotes. It is at this time, the SQL send to the database is validated for syntax.
    Therefore, you will not know the validity of your SQL with Global Variables until you run the job.
    Hope this helps!
    Thanks & Regards
    Tiji
    Edited by: Tiji Mathew on May 8, 2009 3:40 PM
    The actual syntax was being posted as a link. edited to make the text descriptive.

  • What is the best way to declare field length 500 in internal table?

    Hi all,
    what is the best way to declare field length 500(constant value allways) in internal table?
    I am trying to send data from internal table to file format, and I have a field in internal table with 500 length (constant value always). So how do I can declare and append this field value to table?
    Thanks
    Murali

    Hi.  Please see the following example program, notice how I am filling the field with the constant value.
    report zrich_0001.
    *       CLASS lcl_main DEFINITION
    class lcl_main definition.
      public section.
        types: begin of ttab,
                fld1(500) type c,
               end of ttab.
        data: itab type table of ttab.
        data: xtab type ttab.
        methods: constructor,
                 write_itab.
    endclass.
    *       CLASS lcl_main IMPLEMENTATION
    class lcl_main implementation.
      method constructor.
    <b>
        xtab-fld1 =
          'This is one part of the total string which needs to be really' &
          ' long and this is a constant and we need to move it to a work' &
             ' area and then append it to the internal table which has a' &
              ' field with a length of five hundred characters'.
        append xtab to itab.</b>
      endmethod.
      method write_itab.
        loop at itab into xtab.
          write:/ xtab-fld1.
        endloop.
      endmethod.
    endclass.
    data: o_main type ref to lcl_main.
    start-of-selection.
      create object o_main.
      call method o_main->write_itab.
    Regards,
    Rich Heilman

  • Passing values in a vector list as bind variables in sql query.

    Hi,
    I have a vector list containing values 12,13,14.
    vector<string> v;
    v has values 12,13 and 14.
    Here the number of values in vector list are not fixed.
    I want to pass these values as bind variables to sql query.
    Can anyone suggest me how to do this.
    Thanks in advance!!

    Ah, the it's the classic 'Varying In-List' again
    See:
    The Tom Kyte Blog: Varying in lists...
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061 (started more than a decade ago, so scroll down for more recent examples)

  • Windows System Environment Variables in "Sql * plus"

    Can i use/reference Windows System Environment variables in "Sql * plus"?
    For example, i want to create sql-script to run in database server computer that asks variable "ORA_HOME" and uses this value to execute some sql/plsql sentences.
    Oracle 10g Personal, Windows 7.
    Edited by: CharlesRoos on 12.11.2010 17:28

    CharlesRoos wrote:
    Business problem:
    I have created 2 databases in my computer. Both databases needs tablespaces created by a script. Tablespaces' datafiles (.dbf files) names are same for both database. Both database has it's own directory where it holds datafiles at the moment. At the moment the datafiles for Database1 are in folder something like "%ORACLE_HOME%"\oradata\%databasename1%\*.dbf, and second database has its datafiles in other folder, somewhere ""%ORACLE_HOME%"\oradata\%databasename1%\*.dbf". I want now the script to create tablespace called "INDX" with same datafile name "indx1.dbf" into both database. So into both mentioned folder the file "indx1.dbf" must be created by script. I think the script should do following:
    1. get ORACLE_HOME.
    2. connect to database "databasename1"
    3. EXECUTE IMMEDIATE "Create TableSpace INDX....file=%ORACLE_HOME% || databasename1 || indx1.dbf"
    4. connect to database "databasename2"
    5. EXECUTE IMMEDIATE "Create TableSpace INDX....file=%ORACLE_HOME% || databasename2 || indx1.dbf"I don't have Oracle database near by anymore, so the code was pseudocode.
    I don't understand how to use ?-shortcut.OK, my first impression is "why does this even NEED to be scripted? Creation of new tablespaces is usually a one-off operation.
    But that aside how about this sqlplus command-line substitution variables. This example is in linux, but will work as well in Windows with the change of the way environment variables are referenced:
    *nix - echo $myvariable
    Windows - echo %myvariable%
    First, the sqlscript to create the TS. Note the use of the substitution variable "&1"
    {code}
    [oracle@vmlnx01 ~]$ cat cat makets.sql
    set echo on feedback on verify on trimsp on
    prompt &1
    CREATE SMALLFILE TABLESPACE EDSTEST
    DATAFILE '/ora01/oradata/&1/edstest.dbf'
    SIZE 5M
    REUSE
    AUTOEXTEND ON
    NEXT 1280K
    MAXSIZE 32767M
    LOGGING
    EXTENT MANAGEMENT LOCAL
    SEGMENT SPACE MANAGEMENT AUTO
    drop tablespace edstest
    including contents and datafiles
    exit
    {code}
    So, at the OS prompt: Notice that the @ is separated by a space, makeing it a command line parm instead of part of the connect string
    {code}
    [oracle@vmlnx01 ~]$ export myparm=vlnxora1
    [oracle@vmlnx01 ~]$ sqlplus system/pswd @makets $myparm
    SQL*Plus: Release 10.2.0.4.0 - Production on Fri Nov 12 13:18:05 2010
    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> prompt &1
    vlnxora1
    SQL> --
    SQL> CREATE SMALLFILE TABLESPACE EDSTEST
    2 DATAFILE '/ora01/oradata/&1/edstest.dbf'
    3 SIZE 5M
    4 REUSE
    5 AUTOEXTEND ON
    6 NEXT 1280K
    7 MAXSIZE 32767M
    8 LOGGING
    9 EXTENT MANAGEMENT LOCAL
    10 SEGMENT SPACE MANAGEMENT AUTO
    11 ;
    old 2: DATAFILE '/ora01/oradata/&1/edstest.dbf'
    new 2: DATAFILE '/ora01/oradata/vlnxora1/edstest.dbf'
    Tablespace created.
    SQL> --
    SQL> drop tablespace edstest
    2 including contents and datafiles
    3 ;
    Tablespace dropped.
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@vmlnx01 ~]$
    {code}

  • How to declare a global/public variable in Oracle Forms

    Hi All,
    I have to get the value of a variable which is declared in the event 'When_Button_Pressed', in an another trigger with in the form.
    My variable & type
    l_db_handle EXEC_SQL.ConnType;
    This variable used to get the handle of a new database connection.
    (Here I am trying to make connection to two different databases from Form. That is working fine.)
    I have tried with Global variable to transfer this variable value to other triggers. But it is not working. It shows 'Wrong type error'
    Could you please let me know, how can I declare which DB handle variable as public in form(I mean i have to use this variable all the triggers with in the form)
    Thanking You,
    Manu

    Put the code in a package within the form, have the triggers call functions/procedures within the package. All variables which need to be referenced in more than one procedure can be created as package variables.

  • Passing a Date variable to SQL

    Hi,
    I am trying to pass in a Date variable into SQL query, but I am getting this error:
    "inconsistent datatypes: expected DATE got NUMBER"
    and my code looks like this. I would appreciate any help on how I need to create the Date variable that SQL would accept it.
    THANKS A LOT!
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    String txt = "01/01/1990";
    java.util.Date startYear2 = (java.util.Date) formatter.parse(txt, new ParsePosition(0));
    java.sql.Date startYear = new java.sql.Date(startYear2.getTime());
    String txt2 = "12/31/1990";
    java.util.Date endYear2 = (java.util.Date) formatter.parse(txt2, new ParsePosition(0));
    java.sql.Date endYear = new java.sql.Date(endYear2.getTime());
    String scoredGoalsQuery = "SELECT count(name) from player_goal_rel where name = '" + pName + "' and pdate BETWEEN "+ startYear +" and "+ endYear;
    ResultSet scoredGoalsResult = stmt.executeQuery(scoredGoalsQuery);

    You should be using prepared statements.
    String scoredGoalsQuery = "SELECT count(name) from player_goal_rel where name = ? and pdate BETWEEN ? and ?":
    PreparedStatement pstmt = connection.prepareStatement(scoredGoalsQuery);
    pstmt.setString(1, pName);
    pstmt.setDate(2, startYear);
    pstmt.setDate(3, endYear);
    ResultSet scoredGoalsResult = pstmt.executeQuery();

  • Creating User Table, User Field ... with Script SQL in C#

    Hi every body,
    I wonder if we could create a user table, user field ... with script SQL in C#.
    Should I use the reference Microsoft.SqlServer.ScriptTask ??
    Thank you for your Help

    Haifa,
    I am not sure where your question is directed.  The forum that you have posted your question in is for questions related to the SAP Business One SDK.  Are you looking to create new user tables/fields in SAP Business One?  If so you can do this either through the SAP Business One SDK interface using Tools > User Defined Fields and/or Tools > User Defined tables.
    You can also create metadata objects in Business One programatically using the UserTablesMD and/or UserFields objects.
    SAP does not support direct SQL writes to the SAP Business One Db.
    HTH,
    Eddy

Maybe you are looking for