Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2008
    Posts
    2

    Unanswered: how to do bulk cp within isql?

    Hi,
    I need to write a query in isql and reference some data on the disk. I don't want to(or may not be able to) create a table to store those data since the data changes from time to time.
    Since I don't have the table created for the data, I can't use bcp.

    Is there anyway I can create a temporary table within isql and upload the data from disk file in to that temporary table and use it in the query? Certainly, I don't want to use insert statement for every record in the data file(there are hundreds).

    Thanks in advance!

  2. #2
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    Quote Originally Posted by may5
    Hi,
    I need to write a query in isql and reference some data on the disk. I don't want to(or may not be able to) create a table to store those data since the data changes from time to time.
    Since I don't have the table created for the data, I can't use bcp.

    Is there anyway I can create a temporary table within isql and upload the data from disk file in to that temporary table and use it in the query? Certainly, I don't want to use insert statement for every record in the data file(there are hundreds).

    Thanks in advance!
    Yes, you just need to write a script say in perl, shell or batch file something as below

    isql -U....... << END
    use tempdb
    go
    if exists (select * from sysobjects where name='mytempname')
    drop table mytempname
    go
    create table mytempname
    ( mycol1 int,
    mycol2 data)
    go
    END
    bcp tempdb..mytempname in '/myfile.dat' -Uuser -Sserver -Ppassword -c

    isql -U.... << END
    Your select statement which will do the query using the tempdb..tempname.
    go
    END


    The above is one option.

    OR

    You can just create all the sql statements you need based on the data in a script and just run that script against sybase.

    The decision of the above methods depends on how complicated the final query will be.

    Hope it helps.

  3. #3
    Join Date
    Jan 2008
    Posts
    2
    Thanks! That will work.
    I was thinking temporary table with "#" in the table name. You are right, I can use tempdb.

  4. #4
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    Quote Originally Posted by may5
    Thanks! That will work.
    I was thinking temporary table with "#" in the table name. You are right, I can use tempdb.
    Since you have to use two sql sessions # table will not work as its only session based. So, thats why I put in a permenant table in tempdb which will be permenant till the server gets bounces.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •