dynamically get table column and conver into in rows

  • hi
    i need to get table column dynamically which I am getting tablename from storedprocedure .
    after that what i need is to do select (dynamiccolumnname) from @tablename,
    and same column i need to select from oracle also.

    also if SQL_Latin1_General_CP1_CI_AS comes I need to put 

    COLLATE

    DATABASE_DEFAULT, dynamically in my sp.

    example.

    select column1 collate database_default ,column2 from sql
    minus
    select column 1 ,column2 from oracle

    need to make it dynamic, where I enter parameter ,table,schema,from sp

  • I'm not sure it's worth the time to do this directly in a query when an SSIS package could make this a LOT easier.   However, the first thing is to understand what "MINUS" in Oracle means.   I presume it's the same as EXCEPT in SQL Server.   Dynamic SQL is difficult in Oracle, and although easier in SQL Server, I'd really want to rethink the idea of some stored procedure doing this.   As you'll likely have two separate servers involved, the entire Oracle table will have to traverse the network unless you use OPENQUERY or OPENROWSET and an Oracle query that has a WHERE clause.   However, as we have no information on the size of your tables or your environment in general, it's hard to know what to recommend.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply