Results 1 to 5 of 5

Thread: Record count

  1. #1
    Join Date
    Aug 2003
    Posts
    43

    Unanswered: Record count

    Hi,

    I have a set of records in the temporary table. I need to put them in a file. The requirement is to add sequence number of the records (1 for first record, 2 for second record, etc ..) while writing to the file. The C program just need to copy the data into file. Unfortunately I cannot use C code to write the sequence numbers.
    Is there any way to add sequence numbers to the records? Please let me know.

    Thanks
    -Durga

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    create the temp table with an identity column
    use bcp to create the file (perminant table in tempdb)
    Last edited by pdreyer; 01-23-07 at 08:55.

  3. #3
    Join Date
    Aug 2003
    Posts
    43
    Thank you pdreyer. It worked partially. My net row count is 55. But the index is showing a value of 9099325475709464631. And because of huge value C program is not able to handle. Ideally it is supposed to have 55.

    Also when I run interactively identity field id showing 55. But when it is automated it is throwing huge value.


    Quote Originally Posted by pdreyer
    create the temp table with an identity column
    use bcp to create the file (perminant table in tempdb)

  4. #4
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Need more detail about your temp table and how you use it
    Maybe a small example might assist
    Code:
    isql
    1> select seqno=identity(9),name into tempdb..pdreyer_work
    2> from sysobjects where name like 'sysl%'
    3> go
    (7 rows affected)
    1> exit
    
    bcp tempdb..pdreyer_work out /tmp/pdreyer.txt -Ume -Smysrv -c
    Password: 
    Starting copy...
    7 rows copied.
    Clock Time (ms.): total = 1  Avg = 0 (7000.00 rows per sec.)
    
    more /tmp/pdreyer.txt
    1       syslanguages
    2       syslisteners
    3       syslocks
    4       sysloginroles
    5       syslogins
    6       syslogs
    7       syslogshold
    
    isql
    1> drop table tempdb..pdreyer_work
    2> go
    1> exit

  5. #5
    Join Date
    Aug 2003
    Posts
    43
    Hi Pdreyer,

    Thank you for your response. It was sorted out it was because of incorrect data type.

    -Durga

    Quote Originally Posted by pdreyer
    Need more detail about your temp table and how you use it
    Maybe a small example might assist
    Code:
    isql
    1> select seqno=identity(9),name into tempdb..pdreyer_work
    2> from sysobjects where name like 'sysl%'
    3> go
    (7 rows affected)
    1> exit
    
    bcp tempdb..pdreyer_work out /tmp/pdreyer.txt -Ume -Smysrv -c
    Password: 
    Starting copy...
    7 rows copied.
    Clock Time (ms.): total = 1  Avg = 0 (7000.00 rows per sec.)
    
    more /tmp/pdreyer.txt
    1       syslanguages
    2       syslisteners
    3       syslocks
    4       sysloginroles
    5       syslogins
    6       syslogs
    7       syslogshold
    
    isql
    1> drop table tempdb..pdreyer_work
    2> go
    1> exit

Posting Permissions

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