Convert from NVARCHAR2 to Unicode in SQL Plus

I need to convert from NVARCHAR2 column data to Unicode format in a query. How can I do this?

I need to convert from NVARCHAR2 column data to Unicode format in a queryMaybe with convert:
SQL> select convert(n'ABC', 'utf8') abc from dual;
AB

1 row selected.?

Similar Messages

  • COPY FROM command on ORDIMAGE closes SQL-Plus !!

    Hi, I4m using the following command:
    COPY FROM user/pass@Oracle6 INSERT mytable USING SELECT * FROM mytable;
    ...but it always starts processing and closes the SQL-Plus without copying data ! The tables contains an ORDIMAGE column, I wonder if it can be causing the problem.
    Thanks for any help.
    Alexandre.

    From the 9.0.1 doc.
    Copies data from a query to a table in a local or remote database. COPY supports the following datatypes:
    CHAR DATE LONG NUMBER VARCHAR2
    The COPY command is not being enhanced to handle datatypes or features introduced with, or after Oracle8. The COPY command is likely to be made obsolete in a future release.

  • Experiences from customer who have converted from MDMP to Unicode

    I would be interested in seeing a weblog or article from a customer who has gone through the conversion from MDMP to Unicode on an R/3 system.  I would be interested in how the process went, what kind of problems were encountered, how long it took, how many of your custom ABAP programs needed changes, etc.

    Thomas,
    I am also interested in contacting any companies that have migrated to Unicode (with or without MDMP). ChevronTexaco is planning a very large global project that will likely involve migrating to Unicode in the next few years. Anyone who is willing to chat,please feel free to contact me at [email protected], 925-842-0864.
    I suspect there are a lot of us who are going to be heading down this road in the next few years and we all want to learn from those who have blazed the trail before us.

  • How to convert from ifs date format to sql based dates

    I want to write a sql query using dates, to search an ifs
    database. Ifs stores dates as numbers created using the
    java.util.Date class. These dates are accurate to seconds.
    PLSQL uses a different format.
    What I need is a PLSQL function that converts PLSQL date format
    to and from the java.util.date format.
    This is an example of what I would like to do.
    String classname = "DOCUMENT";
    String whereclause = "CREATEDATE > theNeededFuction(to_date('01-
    Jan-2001', 'DD-Mon-YYYY'),'j')";
    Selector mySelector = new Selector(login.getSession());
    mySelector.setSearchClassname(classname);
    mySelector.setSearchSelection(whereclause);
    I do realize that I could simply convert the date in java, but
    in the long run, I want to use the oracle tools that support
    busness day calulations.
    -Mitch

    Hi Mitch - our ViewSpecification functionality automatically
    includes an Oracle Date column, which is derived from the java
    date values we store. These views are the supported way of
    performing read-only operations against an iFS instance.
    For yor reference, the Oracle date column is derived using the
    following SQL operation (e.g. for createdate):
    to_date('01-JAN-1970', 'DD-MON-YYYY') + (createdate/86400000)
    regards,
    dave

  • Select from sys.all_ind_columns works in sql*plus but not in stored proc

    I'm writing a query to find duplicate rows in a temporary table which has no unique index defined before I insert the data into the real table. I'm trying to query the sys.all_ind_columns view for the target table which belongs to a different schema:
    SELECT column_name colnm
    FROM sys.all_ind_columns i
    WHERE i.table_owner = 'SUSDB'
    AND i.index_name LIKE '%LUK'
    AND i.table_name = &tbnm
    ORDER BY i.column_position;
    This works from my GUI interface and returns five rows but when I put it into a stored procedure I get now data returned. I have granted my userid SELECT ANY DICTIONARY authority. What else do I need?

    CREATE OR REPLACE FUNCTION bog_elsa2_leslie.diag_msg_1000_cursor(i_rept_inst IN VARCHAR2,
    i_rept_time_frame IN VARCHAR2,
    i_table_name IN VARCHAR2,
    i_column_name IN VARCHAR2,
    i_domain_table IN VARCHAR2,
    i_domain_column IN VARCHAR2,
    i_domain_code IN VARCHAR2,
    i_trace_flg IN NUMBER := 0)
    RETURN VARCHAR2 IS
    cursor_stg VARCHAR2(4000);
    || File name: diag_msg_1000_cursor.fnc
    || Created by: ELSA.LESLIE
    || Created on: 20071215 4:08:20 AM
    || Purpose: Build the string that will retrieve PRIKEY and CONTENTS
    || from the target table, university, time frame, submission
    || and table passed as parameters for the 1000 dignostic.
    || Diagnostic 1000:
    || Validate that the table's logical unique key constraint
    || is not violated.
    || In: ***
    || *** ALL INPUT VARIABLES MUST BE DECLARED EVEN IF THEY ARE
    || *** NOT USED IN THIS PARTICULAR FUNCTION BECAUSE THE
    || *** EDIT_ANY_TABLE PROCEDURE CALLS THE FUNCTION IN AN
    || *** EXECUTE IMMEDIATE STATEMENT THAT REQUIRES THE 'USING'
    || *** PHRASE BE PART OF THE CALLING PROGRAM RATHER THAN BEING
    || *** INCLUDED IN THE RETURNED CURSOR_STG.
    || ***
    || i_rept_inst = reporting institution (eg. UF, FSU)
    || i_rept_time_frame = reporting time frame (eg., 200608, 20062007)
    || i_table_name = target table to be edited (eg. BUILDINGS, ENROLLMENTS)
    || i_trace_flg is optional and is used for debugging (values: TRUE/FALSE)
    || [not used] i_column_name = eg. ALTER_YR, BASE_YR
    || [not used] i_domain_table = the name of the domain table containing valid values
    || [not used] (eg. DOMAIN_MAIN_VALUES, DOMAIN_UNIV)
    || [not used] i_domain_column = the name of the column in the domain table that
    || [not used] contains the valid values (eg. CODE, OPEID_CD)
    || [not used] i_domain_code = the 5-digit domain code (eg. 10021, 01045)
    || Out: cursor_stg = executable SQL to return error row information
    || Dependencies: Logical Unique Key for tables must be have the string 'LUK'
    || postpended to it's name.
    || Exceptions: none
    || Copyright: BOG 2007
    || ***************************************************
    || Modifications:
    || Userid - Date - Modification description
    -- Constants and special assignments
    rept_inst VARCHAR2(4) := upper(i_rept_inst);
    rept_time_frame VARCHAR2(8) := i_rept_time_frame;
    table_name VARCHAR2(30) := upper(i_table_name);
    column_name VARCHAR2(30) := upper(i_column_name);
    domain_table VARCHAR2(30) := upper(i_domain_table);
    domain_column VARCHAR2(30) := upper(i_domain_column);
    domain_code VARCHAR2(5) := upper(i_domain_code);
    trace_flg NUMBER := i_trace_flg;
    file_name VARCHAR2(100) := 'diag_msg_1000_cursor: ';
    unq_cols VARCHAR2(1000) := NULL;
    unq_contents VARCHAR2(4000) := NULL;
    unq_where VARCHAR2(4000) := NULL;
    -- Accounting of process n/a all contained in the for loop
    row_num NUMBER := 0;
    -- Object types - n/a
    -- Cursors
    CURSOR ix_cols_curr(tbnm VARCHAR2 := table_name) IS
    SELECT column_name colnm
    FROM sys.all_ind_columns i
    WHERE i.table_owner = 'SUSDB'
    AND i.index_name LIKE '%LUK'
    AND i.table_name = tbnm
    ORDER BY i.column_position;
    -- Cursor variables n/a
    -- errors and exceptions
    sql_code NUMBER;
    sql_errm VARCHAR2(255);
    BEGIN
    -- output trace information if requested
    IF trace_flg = 1
    THEN
    dbms_output.put_line(file_name || 'rept_inst = ' || rept_inst);
    dbms_output.put_line(file_name || 'rept_time_frame = ' || rept_time_frame);
    dbms_output.put_line(file_name || 'table_name = ' || table_name);
    dbms_output.put_line(file_name || 'column_name = ' || column_name);
    dbms_output.put_line(file_name || 'domain_table = ' || domain_table);
    dbms_output.put_line(file_name || 'domain_column = ' || domain_column);
    dbms_output.put_line(file_name || 'domain_code = ' || domain_code);
    END IF;
    -- ix_cols_loop builds a string of the columns contain in the
    -- logical unique key which is then later incorporated into the
    -- select cursor returned to the calling program.
    FOR this_col IN ix_cols_curr(table_name)
    LOOP
    <<ix_cols_loop>>
    -- output trace information if requested
    IF trace_flg = 1
    THEN
    row_num := ix_cols_curr%ROWCOUNT;
    dbms_output.put_line(file_name || 'row=' || row_num ||
    'column_name=' || this_col.colnm);
    END IF;
    IF unq_cols IS NOT NULL
    THEN
    unq_cols := unq_cols || ', ';
    unq_contents := unq_contents || ', ';
    END IF;
    unq_cols := unq_cols || this_col.colnm;
    unq_contents := unq_contents || q'[']' || this_col.colnm ||
    q'['=]' || this_col.colnm;
    unq_where := unq_where || 'AND tbl.' || this_col.colnm ||
    ' = dups.' || this_col.colnm;
    END LOOP ix_cols_loop;
    IF trace_flg = 1
    THEN
    dbms_output.put_line(file_name || 'unq_cols =' || unq_cols);
    dbms_output.put_line(file_name || 'unq_contents =' || unq_contents);
    dbms_output.put_line(file_name || 'unq_where =' || unq_where);
    END IF;
    cursor_stg := 'SELECT prikey, ' || unq_contents || ' AS contents ' ||
    'FROM univdb.' || table_name || ' tbl, (SELECT ' ||
    unq_cols || ', COUNT(*) FROM univdb.' || table_name ||
    q'[ WHERE rept_inst = ']' || rept_inst || q'[']' ||
    q'[AND rept_time_frame = ']' || rept_time_frame || q'[']' ||
    ' GROUP BY ' || unq_cols || ' HAVING COUNT(*) > 1) dups' ||
    q'[ WHERE tbl.rept_inst = ']' || rept_inst || q'[']' ||
    q'[ AND tbl.rept_time_frame = ']' || rept_time_frame ||
    q'[']' || unq_where;
    -- output trace information if requested
    IF trace_flg = 1
    THEN
    dbms_output.put_line(file_name || 'cursor_stg = ' || cursor_stg);
    END IF;
    RETURN(cursor_stg);
    EXCEPTION
    -- block exception
    WHEN OTHERS THEN
    sql_code := SQLCODE;
    sql_errm := SQLERRM;
    IF trace_flg = 1
    THEN
    dbms_output.put_line(file_name || ' ROW NUM ' || row_num || ' sql code ' ||
    sql_code || ' sql message ' || sql_errm);
    END IF;
    END diag_msg_1000_cursor;

  • How to insert arabic&english  from oracle clients like TOAD,SQL*PLUS

    Hi
    iam trying to insert arabic&english data from TOAD&SQLPLUS.
    if i try to insert arabic by copy and paste iam getting ???? and
    if i try to insert through my keyboard (after updating my system with regional
    settings) iam able to type some junk characters.
    I have installed Oracle 8.1.6 with characterset set to UTF8 and
    in my client NLS_LANG settings i have tried with different settings like:-
    AMERICAN_AMERICA.UTF8
    AMERICAN_AMERICA.AR8MSAWIN
    ARABIC_UNITED ARAB EMIRATES.UTF8
    ARABIC_UNITED ARAB EMIRATES.AR8MSWIN1256
    i have also updated INIT.ORA nls_language ='ARABIC'.
    but still iam getting same problem.
    any help in this appriciated.
    Thanks
    Srinivas

    Are you able to use Arabic with your Java VM in general? Or are you having problems specific to your database interactions? Sun provides an internationalized version of the JDK and also an "English only" version. Perhaps you have the English only version? I would recommend trying a simple Hello World app with your JVM first... I would also check your JDBC driver documentation and make sure there are no limitations there, and that your database is also setup for internationalization.
    It is certainly possible to use TopLink in internationalized environments as we have lots of customers doing this, so hopefully we can figure out what is wrong with your setup.
    - Don

  • Checking Module to Prevent SQL Plus usage on Database

    I have a question regarding logon triggers checking against SYS_CONTEXT('USERENV', 'MODULE'). I created a logon trigger that looks for SYS_CONTEXT('USERENV', 'MODULE') = 'SQLPLUS.EXE'
    and if it matches then it only allows specified users to log in to the database. This code works but I am confused as to why when I check SYS_CONTEXT('USERENV', 'MODULE') after I login in
    shows SQL*Plus which clearly does not match my IF statement in my logon trigger.
    Second issue. If I rename sqlplus.exe to jeff.exe and run it I am abled to log in to the database as a non DBA user. But the module still shows as SQL*Plus. Why is this?
    Database Version: 11.2.0.2 64bit
    OS: Windows Server 2003 R2
    Client: 11.2.0.1
    /*********************Create Trigger******************************/
    CREATE OR REPLACE TRIGGER application_check_al
      after logon ON database 
    DECLARE
      l_username VARCHAR2(20);
      l_module   VARCHAR2(20);
    BEGIN
      l_username := SYS_CONTEXT('USERENV', 'SESSION_USER');
      l_module   := UPPER(SYS_CONTEXT('USERENV', 'MODULE'));
      IF l_module LIKE 'SQLPLUS.EXE' AND
         l_username NOT IN ('SYS', 'SYSTEM', 'DVOWNER', 'DVMGR') THEN
        raise_application_error(-20001, 'SQLPLUS ACCESS RESTRICTED FOR NON DBA USERS');
      END IF;
    END application_check_al;
    /*********************Run SQLPLUS******************************/
    SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 7 12:22:23 2012
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Enter user-name: jeffc@dev
    Enter password:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-20001: SQLPLUS ACCESS RESTRICTED FOR NON DBA USERS
    ORA-06512: at line 10
    Enter user-name: system@dev
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining, Oracle Database Vault
    and Real Application Testing options
    system@dev> select sys_context('USERENV','MODULE') from dual;
    SYS_CONTEXT('USERENV','MODULE')
    SQL*Plus
    SQL>

    jeff81 wrote:
    That doesn't make sense. Why am I able to log in when I renamed the exe? And why does the module still show as SQL*Plus?You are right - it does not make sense. The idea that Oracle might perhaps set module to SQLPLUS.EXE on executable start, and then re set from SQLPLUS.EXE to SQL*Plus after connect, or in glogin.sql, to ensure it is consistent across all operating system never crossed my mind.
    You might want to refer to Support Note "SQL*Plus Session/Module is Not Showing in V$SESSION" [ID 1312340.1] to see whether anything in there helps. I'm pretty sure http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve040.htm#i2698573 doesn't help much, though.
    I'd certainly be raising it with Support as a potential security challenge, to get that potential hole closed.
    Edited by: Hans Forbrich on Mar 7, 2012 2:23 PM
    I wonder whether Oracle put that capability in there - if an untained SQLPLUS.EXE, it tells you that it is SQLPLUS.EXE, but if renamed it tells you 'SQL*Plus'? Specuklation, but it is one thing I might do to subtly raise the flag. Best bet - ask Support.
    Edited by: Hans Forbrich on Mar 7, 2012 2:29 PM

  • Different behaviour in SQL*Plus and PL/SQL

    Does anyone know why the following SQL works from the command line in SQL*Plus but results in a syntax error when included within a cursor in a PL/SQL procedure?
    SELECT (SELECT 'dummy' FROM dual)
    FROM dual;
    null

    Is this what you require? This works...
    declare
    cursor cur_dummy is
    SELECT d.dum
    FROM (
    SELECT 'dummy' dum
    FROM dual
    ) d
    v_dummy varchar2(30);
    begin
    open cur_dummy;
    fetch cur_dummy into v_dummy;
    close cur_dummy;
    dbms_output.put_line(v_dummy);
    end;
    Cheers
    BigB
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Aqueel ([email protected]):
    In PL/SQL, every SELECT Statement must have a INTO clause. But still It's not working. Anyother know the answer?
    <HR></BLOCKQUOTE>
    null

  • Bug in SQL*Plus 9.2.0.1.0 with 8.1.6 instance.

    WARNING !!!!
    I just installed the client 9.2.0.1.0 but we are still using 8.1.6.3.8 databases on NT.
    There is a major BUG in SQL*Plus 9.2.0.1.0. If you do a select on a sys table that have a LONG column, SQL*Plus exits immediately !!!
    For example if you try the following "select * from dba_views where rownum = 1;" SQL*Plus crash immediately with no error message.
    I could not reproduce this bug with our Unix databases.

    Hi,
    Ok this is defenitly a bug and it can be reproduce with a 9.2.0 client with a 8.1.7 database if and only if the database national character set is WE8ISO8859P1.
    A workaround is to change the national character set from WE8ISO8859P1 to WE8DEC. If you use the regular expression "alter database national character set WE8DEC" you will get an error because WE8DEC is not a superset of WE8ISO8859P1. You will have to use the "INTERNAL_USE" clause as in "alter database national character set INTERNAL_USE WE8DEC".
    The magic INTERNAL_USE clause is not documented anywhere !
    Thanks

  • Which two are attributes of /SQL*Plus? (Choose two)

    A. /SQL*Plus commands cannot be abbreviated.
    B. /SQL*Plus commands are accesses from a browser.
    C. /SQL*Plus commands are used to manipulate data in tables.
    D. /SQL*Plus commands manipulate table definitions in the database.
    E. /SQL*Plus is the Oracle proprietary interface for executing SQL statements.

    What's "/SQL*Plus"? Did you mean iSQL*Plus? If so, maybe you could add,
    F. iSQL*Plus no longer exists in 11g

  • Connecting java to sql plus editor

    I want to open oracle sql plus editor by giving user name and password from a java program and send queries from java program to the sql plus editor to execute.

    I have the same sort of requirements, but I don't think that SQLPlus can be used that way. The requirements stem from having scripts written by Oracle developers that SQLPlus can parse, but are hard to parse into JDBC-executable statements with Java.
    In my case I have several Oracle database developers who produce SQL scripts to e.g. create and change PL/SQL, change tables, add and remove data, etc. Generally all kinds of DDL and DML. They write one master script to execute the rest of the scripts for a particular change, using SQLPlus' @[filepath] notation.
    I am somehow supposed to be responsible for releasing this stuff, which would normally mean executing each master script through SQLPlus.
    I am trying to figure out a way to do this automatically.
    SQLPlus would be good for this as it is written to parse the scripts that Oracle developers are used to writing.
    The problem is that running SQLPlus from the command line only lets you run one (master) script, and doesn't let you set up named variables. So you can't run scripts generically; you have to know which variables turn up in which scripts, which makes it impossible to run in more than one environment/schema.
    If I do things in JDBC, I have to either get the Oracle developers to write their scripts as Java strings - which would lead to a lot of errors - or try to parse the scripts in the same way that SQLPlus does - which would lead to a lot of errors.
    I will look at getting the developers to delimit each statement with e.g. '----------------------' which I can use to break the scripts up into separately executable statements. I doubt this will make them happy.
    I may also have to look at doing token replacement to set variables.

  • Importing from an Oracle database converted from non-unicode to unicode - SSIS 2012

    Hi,
    I've some SSIS 2012 pkgs that read from a non-unicode Oracle database to a non-unicode SQL Server database.
    Few days later, the Oracle database will be converted to unicode one and so I need to update the SQL database and the SSIS pkgs. Obiously no data conversion transformations are present in the pkgs. I'd like to avoid to add more of these data conversions.
    As a first step, I'm trying to convert a SQL table to unicode format, but it isn't possible to convert non-unicode and unicode string data types.
    I did not expect to have an error about the conversion from to non-unicode Oracle database (not yet converted) to unicode SQL Server database: a such conversion doesn't lost any information content. For me, it is right to have an error by from unicode to
    non-unicode conversion.
    Any suggests to solve this issue with a minimum development effort? Many thanks

    Nope once you change datatypes to unicode you've to refresh metadata settings within SSIS packages for it to work fine. SSIS doesnt have the ability to do metadata changes at runtime. So someone has to update package metadata information to make them unicode
    to make sure it works correctly after the changes.
    What you can do is create test dbs in oracle and sql in uncode and create some modified packages based on it. Once you make changes to production dbs you need to move these modified copies also to production after making necessary config value changes like
    servername,dbname,folder paths etc and then they will continue to work normally without causing any further downtimes to the customer.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Unable to Login to Idle Instance from SQL*Plus in windows

    Hello,
    I'm cloning the db from windows to windows enviornment. At auxilary instance after configuring the Listener and making Password file to right folder when I try to connect to Idle Instance through sql*plus by follwring connad
    c:\sqlplus sys/password as sysdba
    It gives me ORA-12518 Tns: Listener could not hand off client conenction error
    Then I put the follwing parameter in listener.ora DIRECT_HANDOFF_TTC_LISTENER=OFF and restart listener and then try to connect it gives me Ora-12560: TNS protocol adapter error.
    I try to connect through tnsnames but give me same error.
    Kindly tell me how to resolve this issue as its not allowing me to connect to an idle instance so that I can go further.
    I'm using 10gR2 on windows server 2003.
    Regards,
    Abbasi

    follow the steps to clone database:
    # 1. Backup the source database.
    To use RMAN duplicate an RMAN backup of the source database is required. If there is already one available, skip to step 2. If not, here is a quick example of how to produce an RMAN backup. This example assumes that there is no recovery catalog available:
    rman target sys@<source database> nocatalog
    RMAN>backup database plus archivelog ;
    RMAN> backup archivelog all;
    This will backup the database and archive logs.
    # 2. Produce a pfile for the new database
    This step assumes that the source database is using a spfile. If that is not the case, simply make a copy the existing pfile.
    Connect to the source database as sysdba and run the following:
    create pfile='init<new database sid>.ora' from spfile;
    This will create a new pfile in the $ORACLE_HOME/database directory.
    The new pfile will need to be edited immediately. If the cloned database is to have a different name to the source, this will need to be changed, as will any paths. Review the contents of the file and make alterations as necessary.
    Because in this example the cloned database will reside on the same machine as the source, Oracle must be told how convert the filenames during the RMAN duplicate operation. This is achieved by adding the following lines to the newly created pfile:
    db_file_name_convert=(<source_db_path>,<target_db_path>)
    log_file_name_convert=(<source_db_path>,<target_db_path>)
    # 3. Create bdump, udump & cdump directories
    Create bdump, udump & cdump directories as specified in the pfile
    # 4. Create a service
    c:/>oradim –new –sid <clonedatabasename> –intpwd <pwd>
    eg:
    c:>oradim –new –sid clonedb –intpwd oracle
    # 6. Duplicate the database
    From sqlplus, start the instance up in nomount mode:
    startup nomount
    Exit sqlplus, start RMAN and duplicate the database. As in step 1, it is assumed that no recovery catalog is available. If one is available, simply amend the RMAN command to include it.
    rman target sys@<source_database> nocatalog auxiliary /
    duplicate target database to <clone database name>;
    thats it
    For RMAN Cloning refer:
    follow the documentation replace the destinations/locations with your location/folder/destination in source and target database.
    http://www.dba-oracle.com/t_copy_clone_windows_database.htm
    http://www.shutdownabort.com/quickguides/clone_rman.php
    http://www.akadia.com/services/ora_duplicate_database_rman.html
    for manual cloning in windows refer the link below:
    http://coskan.wordpress.com/2007/04/20/adding-new-database-to-windows-without-dbca-or-rman-clone-or-rman-restore/

  • How to convert from SQL Server table to Flat file (txt file)

    I need To ask question how convert from SQL Server table to Flat file txt file

    Hi
    1. Import/Export wizened
    2. Bcp utility
    3. SSIS 
    1.Import/Export Wizard
    First and very manual technique is the import wizard.  This is great for ad-hoc and just to slam it in tasks.
    In SSMS right click the database you want to import into.  Scroll to Tasks and select Import Data…
    For the data source we want out zips.txt file.  Browse for it and select it.  You should notice the wizard tries to fill in the blanks for you.  One key thing here with this file I picked is there are “ “ qualifiers.  So we need to make
    sure we add “ into the text qualifier field.   The wizard will not do this for you.
    Go through the remaining pages to view everything.  No further changes should be needed though
    Hit next after checking the pages out and select your destination.  This in our case will be DBA.dbo.zips.
    Following the destination step, go into the edit mappings section to ensure we look good on the types and counts.
    Hit next and then finish.  Once completed you will see the count of rows transferred and the success or failure rate
    Import wizard completed and you have the data!
    bcp utility
    Method two is bcp with a format file http://msdn.microsoft.com/en-us/library/ms162802.aspx
    This is probably going to win for speed on most occasions but is limited to the formatting of the file being imported.  For this file it actually works well with a small format file to show the contents and mappings to SQL Server.
    To create a format file all we really need is the type and the count of columns for the most basic files.  In our case the qualifier makes it a bit difficult but there is a trick to ignoring them.  The trick is to basically throw a field into the
    format file that will reference it but basically ignore it in the import process.
    Given that our format file in this case would appear like this
    9.0
    9
    1 SQLCHAR 0 0 """ 0 dummy1 ""
    2 SQLCHAR 0 50 "","" 1 Field1 ""
    3 SQLCHAR 0 50 "","" 2 Field2 ""
    4 SQLCHAR 0 50 "","" 3 Field3 ""
    5 SQLCHAR 0 50 ""," 4 Field4 ""
    6 SQLCHAR 0 50 "," 5 Field5 ""
    7 SQLCHAR 0 50 "," 6 Field6 ""
    8 SQLCHAR 0 50 "," 7 Field7 ""
    9 SQLCHAR 0 50 "n" 8 Field8 ""
    The bcp call would be as follows
    C:Program FilesMicrosoft SQL Server90ToolsBinn>bcp DBA..zips in “C:zips.txt” -f “c:zip_format_file.txt” -S LKFW0133 -T
    Given a successful run you should see this in command prompt after executing the statement
    Starting copy...
    1000 rows sent to SQL Server. Total sent: 1000
    1000 rows sent to SQL Server. Total sent: 2000
    1000 rows sent to SQL Server. Total sent: 3000
    1000 rows sent to SQL Server. Total sent: 4000
    1000 rows sent to SQL Server. Total sent: 5000
    1000 rows sent to SQL Server. Total sent: 6000
    1000 rows sent to SQL Server. Total sent: 7000
    1000 rows sent to SQL Server. Total sent: 8000
    1000 rows sent to SQL Server. Total sent: 9000
    1000 rows sent to SQL Server. Total sent: 10000
    1000 rows sent to SQL Server. Total sent: 11000
    1000 rows sent to SQL Server. Total sent: 12000
    1000 rows sent to SQL Server. Total sent: 13000
    1000 rows sent to SQL Server. Total sent: 14000
    1000 rows sent to SQL Server. Total sent: 15000
    1000 rows sent to SQL Server. Total sent: 16000
    1000 rows sent to SQL Server. Total sent: 17000
    1000 rows sent to SQL Server. Total sent: 18000
    1000 rows sent to SQL Server. Total sent: 19000
    1000 rows sent to SQL Server. Total sent: 20000
    1000 rows sent to SQL Server. Total sent: 21000
    1000 rows sent to SQL Server. Total sent: 22000
    1000 rows sent to SQL Server. Total sent: 23000
    1000 rows sent to SQL Server. Total sent: 24000
    1000 rows sent to SQL Server. Total sent: 25000
    1000 rows sent to SQL Server. Total sent: 26000
    1000 rows sent to SQL Server. Total sent: 27000
    1000 rows sent to SQL Server. Total sent: 28000
    1000 rows sent to SQL Server. Total sent: 29000
    bcp import completed!
    BULK INSERT
    Next, we have BULK INSERT given the same format file from bcp
    CREATE TABLE zips (
    Col1 nvarchar(50),
    Col2 nvarchar(50),
    Col3 nvarchar(50),
    Col4 nvarchar(50),
    Col5 nvarchar(50),
    Col6 nvarchar(50),
    Col7 nvarchar(50),
    Col8 nvarchar(50)
    GO
    INSERT INTO zips
    SELECT *
    FROM OPENROWSET(BULK 'C:Documents and SettingstkruegerMy Documentsblogcenzuszipcodeszips.txt',
    FORMATFILE='C:Documents and SettingstkruegerMy Documentsblogzip_format_file.txt'
    ) as t1 ;
    GO
    That was simple enough given the work on the format file that we already did.  Bulk insert isn’t as fast as bcp but gives you some freedom from within TSQL and SSMS to add functionality to the import.
    SSIS
    Next is my favorite playground in SSIS
    We can do many methods in SSIS to get data from point A, to point B.  I’ll show you data flow task and the SSIS version of BULK INSERT
    First create a new integrated services project.
    Create a new flat file connection by right clicking the connection managers area.  This will be used in both methods
    Bulk insert
    You can use format file here as well which is beneficial to moving methods around.  This essentially is calling the same processes with format file usage.  Drag over a bulk insert task and double click it to go into the editor.
    Fill in the information starting with connection.  This will populate much as the wizard did.
    Example of format file usage
    Or specify your own details
    Execute this and again, we have some data
    Data Flow method
    Bring over a data flow task and double click it to go into the data flow tab.
    Bring over a flat file source and SQL Server destination.  Edit the flat file source to use the connection manager “The file” we already created.  Connect the two once they are there
    Double click the SQL Server Destination task to open the editor.  Enter in the connection manager information and select the table to import into.
    Go into the mappings and connect the dots per say
    Typical issue of type conversions is Unicode to non-unicode.
    We fix this with a Data conversion or explicit conversion in the editor.  Data conversion tasks are usually the route I take.  Drag over a data conversation task and place it between the connection from the flat file source to the SQL Server destination.
    New look in the mappings
    And after execution…
    SqlBulkCopy Method
    Sense we’re in the SSIS package we can use that awesome “script task” to show SlqBulkCopy.  Not only fast but also handy for those really “unique” file formats we receive so often
    Bring over a script task into the control flow
    Double click the task and go to the script page.  Click the Design script to open up the code behind
    Ref.
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

  • Script having Chinese characters throws error when run from SQL PLUS

    Dear All,
    I have a script file(.sql) which contains Chinese characters ....
    I have saved the file in unicode Format.
    When I run this file using @D:\filename from SQL PLUS it throws an error "unknown Command at line 1"...
    My database is Oracle 10g...
    Can anyone suggest anything???
    Thanks In Advance
    Dev
    Edited by: Devarsh on Oct 21, 2009 8:16 AM

    I think you may need to set your local NLS_LANG setting for your client (SQL*Plus) to recognize the characters.
    You may also consider posting your question on the Globalization forum which pertains more to these types of questions.
    Globalization Support

Maybe you are looking for

  • Sy-ucomm value for enter

    Hi, Can anyone plz help me with the sy-ucomm value for enter key. Thanks..

  • Ical - how to view from a specific time of day

    Hi y'all - Yes I did try to search and find the answer but all I got was guff about quicktime. I have upgraded from an ooooooold mac running OS X 10.3 and am now up to speed with a Macbook Pro running the latest OS X and iCal Version 2.0.5. On the ol

  • Number of Folders

    Hi this is my configuration. Sun Java(tm) System Messaging Server 6.2-4.03 (built Sep 22 2005) libimta.so 6.2-4.03 (built 04:37:42, Sep 22 2005) SunOS www 5.10 Generic sun4u sparc SUNW,Sun-Fire-V440 Is there any limit on the number of folders per use

  • Reg: FVU file conversion error

    Dear All, While i try to validate the txt file generated from SAP by FVU utility, I'm getting the error that 'T-FV-1000 Invalid File Header Record Length' The file header line of my file is below for reference 1^FH^NS1^R^11032011^123456789^D^ABCD1234

  • 20" ACD No Longer Displays Black Spots

    Hi all! We have a 20" ACD connected to a Mac G5/Dual 2.0 that for the longest time has displayed a series of black transparent spots in and around the monitors edges. We sent it in to Apple for repairs 2 or 3 times for this because it kept creeping u