Convert Column from Varchar to NVarchar

Hi Guys,
i know we cannot alter a columns datatype when there is a data. but the problem is that i would like to alter a datatype with the data in database. as there is no downtime to our server. im not sure this can be achieved, but i feel someone might have faced this kind of problem. even we cannot create new columns and then dump the data there and then delete the old columns as the data is huge.
please advice.
thanks
Fairozkhan

Cant you just alter it
SQL> select * from v$version where rownum < 2
  2  /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
SQL> create table t(c varchar2(10))
  2  /
Table created.
SQL> desc t
Name                                      Null?    Type
C                                                  VARCHAR2(10)
SQL> insert into t values('karthick')
  2  /
1 row created.
SQL> commit
  2  /
Commit complete.
SQL> alter table t modify c nvarchar2(10)
  2  /
Table altered.
SQL> desc t
Name                                      Null?    Type
C                                                  NVARCHAR2(10)
SQL> select * from t
  2  /
C
karthick
SQL>

Similar Messages

  • Derived column transformation from varchar(8) YYYYMMDD to DATETIME column

    It seems I have tried everything, but all I need to do is change a column from varchar(8) to DATETIME. Some lines are blank, zero length strings, and some have dates such as 20140829. All the rows go to an exception table or it just bombs altogether. The
    only thing I can get to run is NULL(DT_DATE), but obviously, that won't work in the end.
    I tried LTRIM(RTRIM(MyDateColumn) == "" ? (DT_DATE)"1900-01-01" : (DT_DATE)(SUBSTRING(MyDateColumn,1,4) + "-" + SUBSTRING(MyDateColumn,5,2) + "-" + SUBSTRING(MyDateColumn,7,2))
    I got truncation errors on that.
    Sometimes I got an error: An error occurred while attempting to perform a type cast.
    I tried DT_DATE, DT_DBDATE and DB_DBTIMESTAMP
    I even tried putting GETDATE() in there or a literal date such as "2014-08-29" like (DT_DBDATE)"2014-08-29"
    This wouldn't even compile: MyDatCeolumn == "" ? NULL(DT_DBDATE) : (DT_STR,10,1252)((DT_DBDATE)MyDateColumn)
    I tried many variations on these. I either got truncation errors or the transformation would turn red and stop, or the expression wouldn't work (turns red when you leave the row).
    Review:
    Source MyDateColumn VARCHAR(8) NULL; Target MyDateColumn DATETIME; Source values in format of "" (blank) or "20140829". The blanks should end up null, or maybe a literal date like Jan 1, 1900, and the actual dates should be transformed
    to DATETIME.
    Should not be that hard. Thanks in advance for help.

    Hi duanewilson,
    Please create a Derived Column transformation and a new column, then use the following expression for the expression field:
    (DT_DATE)(SUBSTRING([MyDateColumn],1,4) + "-" + SUBSTRING([MyDateColumn],5,2) + "-" + SUBSTRING([MyDateColumn],7,2))
    If you have any feedback on our support, please click
    here.
    Elvis Long
    TechNet Community Support

  • Converting Column to Rows

    Hello,
    I am trying to build and SQL to convert columns from multiple rows to the all rows - see below test data and result expected:
    CREATE TABLE XX_TEST(NAME VARCHAR2(10),A1 VARCHAR2(10),A2 VARCHAR2(10), A3 VARCHAR2(10),A4 VARCHAR2(10),A5 VARCHAR2(10));
    INSERT INTO XX_TEST VALUES('LIST','A','B','C','D','E');
    INSERT INTO XX_TEST VALUES('L1','1',NULL,'3',NULL,NULL);
    INSERT INTO XX_TEST VALUES('L2','1','5','4',NULL,NULL);
    COMMIT
    SELECT * FROM XX_TEST;
    Result expected:
    NAME is Column from table XX_TEST but COLUMN and VALUE are the columns converted to rows-
    NAME COLUMN VALUE
    L1 A1 1
    L1 A2 NULL
    L1 A3 3
    L1 A4 NULL
    L1 A5 NULL
    L2 A1 1
    L2 A2 5
    L2 A3 4
    L2 A4 NULL
    L2 A5 NULL
    Thanks
    BS

    Hi,
    Thanks for posting the sample data in such a useful form!
    Whenever you post a question, you should always say what version of Oracle you're using, too.
    Displaying multiple columns from one row as one column on multiple rows is called Unpivoting .
    In Oracle 11, you can use the SELECT ... UNPIVOT feature to do that.
    In any version of Oracle, you can cross-join your table to a Counter that has as many rows as your original table has columns to be unpivoted.
    In this problem, we need a self-join of the unpivoted data, to join the rows with name='LIST' to every other row.
    WITH     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL     <= 5
    ,     unpivoted_xx_test     AS
         SELECT     x.name
         ,     'A' || c.n     AS col
         ,     CASE  c.n
                   WHEN 1     THEN x.a1
                   WHEN 2     THEN x.a2
                   WHEN 3     THEN x.a3
                   WHEN 4     THEN x.a4
                   WHEN 5     THEN x.a5
              END          AS val
         FROM          cntr     c
         CROSS JOIN     xx_test     x
    SELECT       u.name
    ,       u.col
    ,       l.val          AS val1
    ,       u.val          AS val2
    FROM       unpivoted_xx_test     l
    JOIN       unpivoted_xx_test     u  ON     l.col     = u.col
    WHERE       l.name     =  'LIST'
    AND       u.name     != 'LIST'
    ORDER BY  name
    ,       col
    ;Output:
    NAME       COL VAL1       VAL2
    L1         A1  A          1
    L1         A2  B
    L1         A3  C          3
    L1         A4  D
    L1         A5  E
    L2         A1  A          1
    L2         A2  B          5
    L2         A3  C          4
    L2         A4  D
    L2         A5  EThe query above uses some features that were new in Oracle 9, but the basic strategy will work in earlier versions.
    If your columns don't have such regular names (A1, A2, A3, ...) then you can use another CASE expression to derive unpivoted_xx_test.col.

  • Saving result from sp_executesql into a variable and using dynamic column name - getting error "Error converting data type varchar to numeric"

    Im getting an error when running a procedure that includes this code.
    I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
    DECLARE @retval AS DECIMAL(12,2)
    DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
    DECLARE @sqlcmd AS NVARCHAR(150)
    DECLARE @paramdef NVARCHAR(150)
    SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
    SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
    SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
    SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
    --default
    SET @retval = 0.0;
    EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
    SELECT @retval
    DECLARE @return_value DECIMAL(12,2)
    EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
    @SpreadKey = 1,
    @MonthNumber = 4
    SELECT 'Return Value' = @return_value
    Msg 8114, Level 16, State 5, Line 1
    Error converting data type varchar to numeric.

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
    This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
    the shoe size, the phone number or something else at run time of this entity. 
    In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point. 
    Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity. 
    Do you know that SQL is a declarative language? This family of languages does not use local variables! 
    Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.  
    Think about how silly this is: 
     SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
    We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental. 
    We need to see the DDL so we can re-write this mess. Want to fix it or not?
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • To convert the values in the column from upper case to Camel Case.

    Hi All,
    I have requirement to convert the column values(Data in the Columns) from upper case to camel case in pivot table view.
    For Eg:
    I have
    Table Name:Billing_Transaction
    under Billing_Transaction table i Have column Comment_Text
    Data in Comment_Text Column is
    INSERT,
    EXPORT,
    AMEND
    How i will change these values in to Insert,Export,Amend.(Camel Case condition)
    I want only the first letter of a word to be in caps and others to be in smaller case.
    Thanks,
    Chitra Subramani.

    Hi Aravind,
    Thanks for immediate response.your query is helpful.But i need to satisfy another condition in my requirement by using same formula.
    "REPLACE(UPPER(SUBSTRING(BILLING_TRANSACTION.BILLING_TRANSACTION_DESC FROM 1 FOR 1)) || lower(substring(BILLING_TRANSACTION.BILLING_TRANSACTION_DESC FROM 2)), '_', ' ')"
    above query satisfying Camil case and replacing '_' with ' '(space)......but inthis query i want add another condition to satisfy camil case for word which comes after '_'
    for example:
    DECLINE_IMPORT
    above query satisfying 2 conditions to convert above data into
    "Decline import"
    But in my requirement for word 'import' also it should come in camil case condition like
    "Decline Import"
    Thanks & Regards,
    Chitra
    Edited by: user6371773 on Apr 25, 2011 6:29 AM

  • How to import decimal values from Excel to nvarchar column correctly?

    I have SQL Server 2012 Integration Services. I have Excel Source and OLE DB Destination.
    I have 2 Excels, both having exactly same columns and their destination table is same.
    I have MarketShare column in Excel. I have also MarketShare column nvarchar(100) in Database. I should not make any change in Excel file or DB table.
    MarketShare value can be numerical like "0.50" or "25.4" or text like "Not Available" or text like "Not Available Yet" 
    My problem is that numerical values are stored to DB like 0.500000000000003, 25.399999999999999. Text as stored correctly.
    What should I do so that digits of numerical values are stored corretly to nvarchar(100) column?
    Kenny_I

    Hi Kenny_I,
    I am unable to reproduce the issue in my test environment no matter it is a XLS file or a XLSX file. After adding extended property “IMEX=1” to the ConnectionString of the Excel Connection Manager, the connection string should be as follows:
    For XLS file:
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\Test.xls;Extended Properties="EXCEL 8.0;HDR=YES;IMEX=1";
    For XLSX file:
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Temp\Test.xlsx;Extended Properties="EXCEL 12.0 XML;HDR=YES;IMEX=1";
    If we open the Advanced Editor for the Excel Source, and expand the Output Columns node,  the data type of the MarketShare column should be to DT_WSTR with 255 length. Because the length of the destination column in SQL Server table is 100,
    we need to change the length of the output column from 255 to 100. There may be a warning about data truncation thrown by the Excel Source but we can ignore this warning.
    If the above steps doesn’t work, please post more information about this package for further investigation. Please post the data type of the Output Column MarketShare of the Excel Source as well as the Input Column MarketShare of the OLE DB Destination.
    Besides, click the path between the Excel Source and OLE DB Destination and click “Enable Data Viewer”. Then, run the package to check whether the data displayed in the Data Viewer are the same as the source data (like 0.50) or the same as the data inserted
    to the SQL Server table (like 0.500000000000003).
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • How to convert  from  varchar to blob ?

    How to convert from varchar to blob ?
    thanks

    Here is a small PL/SQL block that we have used to convert varchar2 to blob.
    declare
    cursor get_blob is
    select blob_statement
    from report
    where report_id = 205
    FOR UPDATE OF blob_statement;
    v_loc blob;
    v_raw_buffer raw(32767);
    v_amount binary_integer := 32767;
    v_offset binary_integer := 1;
    v_buffer VARCHAR2(32767);
    begin
    open get_blob;
    fetch get_blob into v_loc;
    close get_blob;
    v_buffer := 'Sample text';
    v_raw_buffer := utl_raw.cast_to_raw(v_buffer);
    v_amount := utl_raw.length(v_raw_buffer);
    dbms_lob.write(v_loc, v_amount, v_offset, v_raw_buffer);
    commit;
    end;

  • Converting text to varchar in a variable

    hi all,
    i am getting  CUSTMER_ID  like ('1234','23456','23445','9845'.....)  almost 3k  Customers in single row, i am selecting this from a table a running through execute SQL task and  capturing the result in a variable , but when i try
    execute the task i am getting the error saying variable value is differs from the current variable. i converted the column to varchar(max) but no use.
    please help me to solve this issue , any help will be appreciated. 

    SSIS doesn't recognize VARCHAR(MAX). So,
    Try using SELECT CAST(CUSTOMER_ID AS VARCHAR(8000)) Cust_ID FROM YourTable and map this "Cust_ID" column in Result Set.
    If your result is exceeding the limit, store it in Object variable.
    Later you can access Cust_ID by using ForEach Loop or using Script Task.
    -Vaibhav Chaudhari

  • How to get the columns from SYS.ALL_COLUMNS and use it in COALESCE() Function.

    Hi,
    I have table called Employe. And the Columns are Emp_ID,EMP_NAME,SRC_SYS_CD,DOB
    I have Query like
    Select
    COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN Emp_id END), MAX(CASE WHEN src_sys_cd='2' THEN Emp_Id END))Emp_Id,
    COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN Emp_name END), MAX(CASE WHEN src_sys_cd='2' THEN Emp_Name END))Emp_name,
    COALESCE(MAX(CASE WHEN src_sys_cd='1' THEN dob END), MAX(CASE WHEN src_sys_cd='2' THEN dob END))dob ,
    from Employe
    group by dob.
    I want to generalize the query like get the columns from SYS.ALL_COLUMNS table for that table name and want to pass it to COALEACE() function. I tried with Cursor. But i didnt get the appropriate results.
    Is there any way to achieve this? Please help me out in this regard.
    Thanks,

    Is this the kinda thing you're after?
    Add a filter to the queries to get just a single table/
    WITH allCols AS (
    SELECT s.name as sName, o.name AS oName, c.name AS cName, column_id,
    CASE WHEN st.name in ('float','bigint','tinyint','int','smallint','bit','datetime','money','date','datetime2','uniqueidentifier','sysname','geography','geometry') THEN st.name
    WHEN st.name in ('numeric','real') THEN st.name + '('+CAST(c.scale AS VARCHAR)+','+CAST(c.precision AS VARCHAR)+')'
    WHEN st.name in ('varbinary','varchar','binary','char','nchar','nvarchar') THEN st.name + '(' + CAST(ABS(c.max_length) AS VARCHAR) + ')'
    ELSE st.name + ' unknown '
    END + ' '+
    CASE WHEN c.is_identity = 1 THEN 'IDENTITY ' ELSE '' END +
    CASE WHEN c.is_nullable = 0 THEN 'NOT ' ELSE '' END + 'NULL' AS bText,
    f.name AS fileGroupName
    FROM sys.columns c
    INNER JOIN sys.objects o
    ON c.object_id = o.object_id
    AND o.type = 'U'
    INNER JOIN sys.systypes st
    ON c.user_type_id = st.xusertype
    INNER JOIN sys.schemas s
    ON o.schema_id = s.schema_id
    INNER JOIN sys.indexes i
    ON o.object_id = i.object_id
    AND i.index_id = (SELECT MIN(index_id) FROM sys.indexes WHERE object_ID = o.object_id)
    INNER JOIN sys.filegroups f
    ON i.data_space_id = f.data_space_id
    ), rCTE AS (
    SELECT sName, oName, cName, column_id, CAST(cName + ' ' + bText AS VARCHAR(MAX)) as bText, CAST(cName AS VARCHAR(MAX)) AS colList, fileGroupName
    FROM allCols
    WHERE column_id = 1
    UNION ALL
    SELECT r.sName, r.oName, r.cName, c.column_id, CAST(r.bText +', ' + c.cName + ' ' +c.bText AS VARCHAR(MAX)), CAST(r.colList+ ', ' +c.cName AS VARCHAR(MAX)), c.fileGroupName
    FROM allCols c
    INNER JOIN rCTE r
    ON c.oName = r.oName
    AND c.column_id - 1 = r.column_id
    ), allIndx AS (
    SELECT 'CREATE '+CASE WHEN is_unique = 1 THEN ' UNIQUE ' ELSE '' END+i.type_desc+' INDEX ['+i.name+'] ON ['+CAST(s.name COLLATE DATABASE_DEFAULT AS NVARCHAR )+'].['+o.name+'] (' as prefix,
    CASE WHEN is_included_column = 0 THEN '['+c.name+'] '+CASE WHEN ic.is_descending_key = 1 THEN 'DESC' ELSE 'ASC' END END As cols,
    CASE WHEN is_included_column = 1 THEN '['+c.name+']'END As incCols,
    ') WITH ('+
    CASE WHEN is_padded = 0 THEN 'PAD_INDEX = OFF,' ELSE 'PAD_INDEX = ON,' END+
    CASE WHEN ignore_dup_key = 0 THEN 'IGNORE_DUP_KEY = OFF,' ELSE 'IGNORE_DUP_KEY = ON,' END+
    CASE WHEN allow_row_locks = 0 THEN 'ALLOW_ROW_LOCKS = OFF,' ELSE 'ALLOW_ROW_LOCKS = ON,' END+
    CASE WHEN allow_page_locks = 0 THEN 'ALLOW_PAGE_LOCKS = OFF' ELSE 'ALLOW_PAGE_LOCKS = ON' END+
    ')' as suffix, index_column_id, key_ordinal, f.name as fileGroupName
    FROM sys.indexes i
    LEFT OUTER JOIN sys.index_columns ic
    ON i.object_id = ic.object_id
    AND i.index_id = ic.index_id
    LEFT OUTER JOIN sys.columns c
    ON ic.object_id = c.object_id
    AND ic.column_id = c.column_id
    INNER JOIN sys.objects o
    ON i.object_id = o.object_id
    AND o.type = 'U'
    AND i.type <> 0
    INNER JOIN sys.schemas s
    ON o.schema_id = s.schema_id
    INNER JOIN sys.filegroups f
    ON i.data_space_id = f.data_space_id
    ), idxrCTE AS (
    SELECT r.prefix, CAST(r.cols AS NVARCHAR(MAX)) AS cols, CAST(r.incCols AS NVARCHAR(MAX)) AS incCols, r.suffix, r.index_column_id, r.key_ordinal, fileGroupName
    FROM allIndx r
    WHERE index_column_id = 1
    UNION ALL
    SELECT o.prefix, COALESCE(r.cols,'') + COALESCE(', '+o.cols,''), COALESCE(r.incCols+', ','') + o.incCols, o.suffix, o.index_column_id, o.key_ordinal, o.fileGroupName
    FROM allIndx o
    INNER JOIN idxrCTE r
    ON o.prefix = r.prefix
    AND o.index_column_id - 1 = r.index_column_id
    SELECT 'CREATE TABLE ['+sName+'].[' + oName + '] ('+bText+') ON [' + fileGroupName +']'
    FROM rCTE r
    WHERE column_id = (SELECT MAX(column_id) FROM rCTE WHERE r.oName = oName)
    UNION ALL
    SELECT prefix + cols + CASE WHEN incCols IS NOT NULL THEN ') INCLUDE ('+incCols ELSE '' END + suffix+' ON [' + fileGroupName +']'
    FROM idxrCTE x
    WHERE index_column_id = (SELECT MAX(index_column_id) FROM idxrCTE WHERE x.prefix = prefix)

  • XML Column from table extract to Pipe Delimited Text File

    Hi,
    I have an XML column with large data in a Table ( Source SQL server Database).
    I was asked to   extract    XML column to .txt file using SSIS.
    Is it possible to extract xml column with huge data to text file ?
    when I tried,  select XML column from Table in source , I noticed  that Property of column is taken as [DT_NTEXT] . I Converted it to DT_TEXT as Ansi donot support DT_NTEXT.
    Execution method was success but it failed due to trucation. so wondering is there a way to get XML column extracted to Pipe delimited text file?
    Is it advisable to do this ? or IS It Valid to export XML in Pipe Delimited File ?
    Please Kindly advice
    thanks
    kodi

    Are you looking at shredding data within XML nodes and then importing it to text file or are you looking at exporting XML value as is? Also is SSIS a necessity?
    If not, You can simply use T-SQL for this along with bcp for this. just use a query like
    EXEC xp_cmdshell 'bcp "SELECT CAST(XMLColumn AS varchar(max)) AS Column FROM table" queryout <full file path> -c -S <ServerName> -T -t |'
    provided you use trusted connection (windows authentication)
    see
    http://visakhm.blogspot.in/2013/10/bcp-out-custom-format-data-to-flat-file.html
    If you want to shred the data use Xpath functions in the query as below
    http://visakhm.blogspot.in/2012/10/shred-data-as-well-as-metadata-from-xml.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Error converting data type varchar to numeric - maybe non printable character?

    Hello all. I'm having some trouble converting a column in my table from varchar(50) to decimal(20,4). I've also tried to convert it to int and had no luck. In trying to find the records with non numeric data, I ran this query...
    SELECT *
    FROM [table]
    WHERE [column] not like '%[^0-9]%'
    My result set was 32 rows where the field in question had zeros. This doesn't make sense to me. If it was a real zero, it would have been excluded from the query.
    So, I flipped it around and ran the following query, and got the same results.
    SELECT *
    FROM [table]
    WHERE [column] = '0'
    If it's really a string 0, what would keep it from converting to a numeric type? I'm wondering if there are non printable characters in there because this table was populated via SSIS package using a flat file.
    Thanks for any help you can provide!
    WeeLass

    I have discovered one of the values that will not convert. It is '-1.2317    ' and I tried RTRIM and those trailing spaces stay there.
    It has a length of 8, and ASCII value of 45, and converting to varbinary gives 0x2D312E3233313709.
    The 45 and 2D both point to a negative sign. This one does indeed have a negative sign, but it's in the front, not trailing. Also, another value that was failing was not negative, but did have the trailing spaces.
    Any ideas on how to figure out what those spaces actually are? Hopefully, if I know that, then I can know how to get rid of them.
    WeeLass
    It may be a hard space
    RTRIM trims only soft spaces
    try this and see if works
    REPLACE(ColumnName,CHAR(160),'')
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to I convert data from oracle database into excel sheet

    how to I convert data from oracle database into excel sheet.
    I need to import columns and there datas from oracle database to microsoft excel sheet.
    Please let me know the different ways for doing this.
    Thanks.

    asktom.oracle.com has an excellent article on writing a PL/SQL procedure that dumps data to an Excel spreadsheet-- search for 'Excel' and it'll come up.
    You can also use your favorite connection protocol (ODBC, OLE DB, etc) to connect from Excel to Oracle and pull the data out that way.
    Justin

  • Excel & ActiveX: Insert arbitrary columns from 2D array and create graph problems

    Hi there,
    I want to insert data from either a 1D or 2D array from LabView into Excel and create graphs.
    I used the information from the following example:
    http://www.ni.com/example/28934/en/
    and was able to create a new Excel file (I'm using Excel 2010), writing data from an 1D array to a column in excel by creating a while loop and using the first element of the array to write it to a specific cell. I use the counter of the loop to write to the next cell when the loop starts over and always delete the first value, which I write to the cell, from the array until it is empty.
    Now I also would like to write a 2D array - so the first column in Excel should be the first column from the array and so. Here I cannot use the loop counter directly as Excel only counts 1,2,... for the rows, but uses A,B,... to count columns. Also I do not know in advance how many columns my 2D array will contain, so creating a lookup table like (A means 1, B means 2,...) is not really an option (except there really is no other way). Is there a possibilty to convert numbers into letters or some way to 'explain' to the program that column 2 in the array means column B in Excel for example, or is there a way to insert new columns?
    I figured out how to add new Worksheets and as I also need to create a certain number of Worksheets and I know that on standard 3 sheets are present when creating the file, I use the 'add' methode to create every new worksheets before worksheet 3 - I could use the same methode to create new columns in Excel, but so far I didn't find a methode to do so. Or is there a way to enter the whole 2D array at once?
    Then I'd like to create a graph (in case of the 1D arrays a bar plot, when using 2D arrays a 3D plot) to view the data. I found this example:
    http://www.ni.com/newsletter/51339/en/
    -> as I do not have the toolkit I'd like to do it using ActiveX directly, so I tried to do things like shown under the headline 'DIY ActiveX/.NET'
    I tried to load the snippet to a new Excel file but got the error message 'microsoft.office.interop.excel.dll not found' and hence the code is not working. That confuses me a little as I would guess when this dll is not present I cannot access Excel from LabView at all, though my understanding of what I'm really doing so far is quiet limited. ;-)
    Also - as far as I understand from the snippet - when creating a new chart object I should be able the create methodes for it, however when I do a right click on the chart object of an ActiveX Worksheet symbol there are none listed.
    To explain my problems better I added a snippet showing my two problems: The inner of the two while loops shows how I import a 1D array. In the outer loop I seperate the columns. I know that currently this is not working as all data end up in column A of the Excel sheet - so I would need to convert the number of the outer counter to A, B,... or find a different solution.
    Moreover on the snippet I placed an ActiveX Worksheet Property with the Chart Object - as I can see the difference to the Chart Object in the example code from the last link above is the color. However I'm not sure what that means and how to change/ solve this.
    And just to make sure - I know this way the VI does not run as the Chart Object is placed completely wrong - I just did it, so it is included in the snippet.
    I'd be thankful for any suggestions,
    Thanks!
    Solved!
    Go to Solution.
    Attachments:
    ExcelAreaScan.png ‏60 KB

    Hello everyone and thanks for the answers.
    I only have the LabView Student Edition available here - is the toolkit included in it too. How can I check if it is installed/ available and in case it is installed - where can I find it?
    Today I had time to take a look at the example
    Create via ActiveX Labview a XY Scatter plot graph on an excel sheet
    It almost does what I want in terms of creating a graph. The only problem I could not fix, is that in this example a sheet is created where only the graph is present. i'd like to add the graph to a previously created worksheet. Today I tried get this working but it seems I stilll don't really understand what I'm doing, I'll post a snippet of my code as soon as I can access the PC with LabView on it again.
    I also took a look at the other example for inserting 2D attays - it seems to be what I need, I just had no time so far to test it, I'll post an update when I could test it.
    Thanks for the help so far!

  • Desc doesn't show datetime columns from SQl Server

    Hi Everyone,
    I have working db link to sql server using hsodbc:
    Oracle 10.2 on AIX using freetds odbc driver version 0.82.
    I can access tables on sql server but oracle sees only varchars and numerics columns in a table.
    Is there a way to select datetime columns from sql server using hsodbc?

    when hsodbc does not show a certain data type it is commonly related to the fact that HSODBC doesn't support the related ODBC data type.
    In general you have a data type in your SQL Server which is mapped to an ODBC data type by the ODBC driver. HSODBC then maps the ODBC data type to an Oracle equivalent and when the ODBC data type isn't supported by HSODBC it just drops it from the select list.
    So for a root cause analysis an ODBC trace is required to determine the mapping of the FreeTDS ODBC driver.
    With this info we can then compare the mapping documented in the HSODBC manual and if the ODBC data type isn't listed as a supported data type you then need to cast the data type on the source side to a different data type (for example varchar/char).
    So please post the ODBC trace and I'll have a look.
    - Klaus
    Edited by: kgronau on Apr 2, 2013 12:50 PM
    BTW, here the link to the HSODBC docu:
    http://docs.oracle.com/cd/B19306_01/server.102/b14232.pdf
    Oracle® Database
    Heterogeneous Connectivity Administrator's Guide
    10g Release 2 (10.2)
    B14232-01
    B.1 Mapping ANSI Data Types to Oracle Data Types Through an ODBC
    Interface

  • A way to convert selection from query builder in DML language

    I search a way to convert selection from query builder in DML language.
    regards

    We will make a sample from this request and post it on OTN. I have pasted all the JSP code so you should be able to use it directly. Just change the BISession details and the presentation references.
    <%@ taglib uri="http://xmlns.oracle.com/bibeans" prefix="orabi" %>
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.util.Vector" %>
    <%@ page import="oracle.dss.thin.beans.crosstab.ThinCrosstab" %>
    <%@ page import="oracle.dss.util.DataAccess" %>
    <%@ page import="oracle.dss.selection.Selection" %>
    <%@ page import="oracle.dss.thin.beans.graph.ThinGraph" %>
    <%@ page import="oracle.dss.dataSource.client.QueryClient"%>
    <%-- Start synchronization of the BI tags --%>
    <% synchronized(session){ %>
    <orabi:BIThinSession id="BIThinSession1" configuration="/Project1BIConfig1.xml" >
    <orabi:Presentation id="untitled2_Presentation1" location="Presentation1" />
    <orabi:Presentation id="untitled2_Presentation2" location="Presentation2" />
    </orabi:BIThinSession>
    <%
    String CROSSTAB_ID = "untitled2_Presentation2";
    String GRAPH_ID = "untitled2_Presentation1";
    String MYProducts = "Nothing";
    String prodID = "MDM!D_CS_OLAP.SHAWPRODUCTS";
    //Find the crosstab object on the page
    Object crosstabObject = pageContext.findAttribute(CROSSTAB_ID);
    ThinCrosstab thinCrosstab = (ThinCrosstab)crosstabObject;
    //Get the various query components from the Crosstab
    QueryClient myQCXtab = (QueryClient)thinCrosstab.getDataSource();
    Selection mySelXtab = myQCXtab.findSelection(prodID);
    DataAccess daXtab = myQCXtab.createQueryAccess().getDataAccess(mySelXtab);
    // This is a one-d data access, only has the column edge
    int colExtentXtab = daXtab.getEdgeExtent(oracle.dss.util.DataDirector.COLUMN_EDGE);
    for (int i=0; i<colExtentXtab; i++)
    String memberLabel = (String)daXtab.getMemberMetadata(oracle.dss.util.DataDirector.COLUMN_EDGE, 0, i, oracle.dss.util.MetadataMap.METADATA_LONGLABEL);
    String memberValue = (String)daXtab.getMemberMetadata(oracle.dss.util.DataDirector.COLUMN_EDGE, 0, i, oracle.dss.util.MetadataMap.METADATA_VALUE);
    System.out.println(memberLabel + " " + memberValue);
    // As above except for graphs.
    Object graphObject = pageContext.findAttribute(GRAPH_ID);
    ThinGraph thinGraph = (ThinGraph)graphObject;
    QueryClient myQCGraph = (QueryClient)thinGraph.getDataSource();
    Selection mySelGraph = myQCGraph.findSelection(prodID);
    DataAccess daGraph = myQCGraph.createQueryAccess().getDataAccess(mySelGraph);
    // This is a one-d data access, only has the column edge
    int colExtentGraph = daGraph.getEdgeExtent(oracle.dss.util.DataDirector.COLUMN_EDGE);
    for (int i=0; i<colExtentGraph; i++)
    String memberLabel = (String)daGraph.getMemberMetadata(oracle.dss.util.DataDirector.COLUMN_EDGE, 0, i, oracle.dss.util.MetadataMap.METADATA_LONGLABEL);
    String memberValue = (String)daGraph.getMemberMetadata(oracle.dss.util.DataDirector.COLUMN_EDGE, 0, i, oracle.dss.util.MetadataMap.METADATA_VALUE);
    System.out.println(memberLabel + " " + memberValue);
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>
    Hello World
    </title>
    </head>
    <body>
    <FORM name="BIForm">
    <!-- Insert your Business Intelligence tags here -->
    <orabi:Render targetId="untitled2_Presentation1" parentForm="BIForm" />
    <orabi:Render targetId="untitled2_Presentation2" parentForm="BIForm" />
    <%-- The InsertHiddenFields tag adds state fields to the parent form tag --%>
    <orabi:InsertHiddenFields parentForm="BIForm" biThinSessionId="BIThinSession1" />
    </FORM>
    <h2>
    The current time is:
    </h2>
    <p>
    <%= new java.util.Date() %></p>
    <input type="text" name="MyTextField" value=MYProducts readonly>
    </body>
    </html>
    <% } %>
    <%-- End synchronization of the BI tags --%>
    Hope this helps
    Business Intelligence Beans Product Management Team
    Oracle Corporation

Maybe you are looking for

  • How do i install photo shop elements 11 on mac book pro with no disk drive

    i bought adobe photoshop elements 11 about a year ago. and want to install it on our mac book pro but not sure how to, as the mac doesn't have a disc drive , any information is greatly appreciated

  • Purchase Order Script

    Hi, I have an output type which is configured for both create and change of Purchase order. When ever we do changes to Purchase order items after creation, if previous output has been released, then a new output will be determined to capture the chan

  • Consistently freezes on startup

    I have had this problem for a while, even before I upgraded from Leopard to Snow Leopard. Every time I start up my computer, the computer freezes. If I don't touch the mouse during the startup, it freezes at the gray screen with the wheel. If I wiggl

  • Error COM_PRODUCT812 when syncing products with Attribute Set Type

    Good Morning, I was wondering if anyone could help me with an error I am receiving when synchronizing products over with a set type for the MARC table. I get the following error for some products when I load them initially.  I only get this error on

  • Flash Builder 4 - Create reports ?

    Hello, I currently am developing in Flash Builder 4 and connecting to SQL 2005 thru web services. Is there an Adobe application i can use to create reports that i can call from my application? thanks.