p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > SQL Server > SQL Server 2000 > SQL Server 2000
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 14th, 2007, 01:09 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamil Nadu, India.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading txt file

hi all
there is text file in which column name are stored .i need to read these column and and create a table with corresponding column in sql server 2000.its very urgent .please help me .



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old May 14th, 2007, 02:02 AM
Friend of Wrox
Points: 7,647, Level: 37
Points: 7,647, Level: 37 Points: 7,647, Level: 37 Points: 7,647, Level: 37
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,477
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Look for BCP utility in BOL.

_________________________
- Vijay G
Strive for Perfection
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old May 14th, 2007, 04:47 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamil Nadu, India.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi vijay
i am trying to execute this query:

bcp <table> in <textfile> -S servername -U username -P password

but geting syntax error .please give more details

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old May 14th, 2007, 05:29 AM
Friend of Wrox
Points: 7,647, Level: 37
Points: 7,647, Level: 37 Points: 7,647, Level: 37 Points: 7,647, Level: 37
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,477
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can't run it from your Query Analyser. Did you check BOL for BCP utility? It is a command prompt utility. You need to construct the complete BCP statement and run it using T-sql function Exec().

_________________________
- Vijay G
Strive for Perfection
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old May 14th, 2007, 05:58 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamil Nadu, India.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot vijay
 iam trying through command prompt
bcp M_obj_cat in D:\WARAQ\DECKLE\winsysorr32.txt -S INTEX -U sa -P sa

this is the statement iam trying to run in command prompt but iam geting error abt server not connecting
here "M_obj_cat" is a table name and "INTEX" is server name .Please tell me how to use T-sql function Exec()
This is Error:

SQLState = S0002, NativeError = 208
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'M_ob
j_cat'.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old May 14th, 2007, 06:28 AM
Friend of Wrox
Points: 7,647, Level: 37
Points: 7,647, Level: 37 Points: 7,647, Level: 37 Points: 7,647, Level: 37
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,477
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Always use name referencing with BCP. You are missing the one marked in RED here. Provide your database name in place of DB_NAME
Code:
bcp DB_NAME.dbo.M_obj_cat in  D:\WARAQ\DECKLE\winsysorr32.txt -S INTEX -U sa -P sa
_________________________
- Vijay G
Strive for Perfection
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old May 14th, 2007, 07:08 AM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamil Nadu, India.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

once again thanks
but till now iam geting error :

C:\>bcp DECKLE_tmp.dbo.M_obj_cat in D:\WARAQ\DECKLE\winsysorr32.txt -S NETIQUE
\NETIQUE -U sa -P sa
SQLState = S0002, NativeError = 208
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'DECK
LE_tmp.dbo.M_obj_cat'
what to do now ?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old May 14th, 2007, 08:15 AM
Friend of Wrox
Points: 7,647, Level: 37
Points: 7,647, Level: 37 Points: 7,647, Level: 37 Points: 7,647, Level: 37
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,477
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I didnt notice that... You are missing the square braces there.
Code:
bcp [DECKLE_tmp].dbo.[M_obj_cat] in  D:\WARAQ\DECKLE\winsysorr32.txt 
    -S NETIQUE\NETIQUE -U sa -P sa



_________________________
- Vijay G
Strive for Perfection
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #9 (permalink)  
Old May 14th, 2007, 11:54 PM
Authorized User
 
Join Date: May 2007
Location: Chennai, Tamil Nadu, India.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi vijay
iam very thankful to you.you have provided a very good solution till now for me.

But till now iam geting errror:

C:\>bcp [DECKLE_tmp].dbo.[M_obj_cat] in D:\WARAQ\DECKLE\winsysorr32.txt -S NET
IQUE\NETIQUE -U sa -P sa
SQLState = 37000, NativeError = 4060
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requ
ested in login '[DECKLE_tmp]'. Login fails.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #10 (permalink)  
Old May 15th, 2007, 01:43 AM
Friend of Wrox
Points: 7,647, Level: 37
Points: 7,647, Level: 37 Points: 7,647, Level: 37 Points: 7,647, Level: 37
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,477
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There seems to be some issue with your login/password. Make sure the password is right.

_________________________
- Vijay G
Strive for Perfection
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
read any ".txt" file RodrigoGuteriez C# 3 November 18th, 2008 01:07 PM
Reading multiple txt from a specified dir diegoblin Beginning VB 6 3 November 20th, 2006 06:54 PM
Reading a txt file AlphaX Beginning VB 6 2 February 20th, 2006 11:22 PM
Reading line by line from a .txt file x_ray VB.NET 2002/2003 Basics 5 February 10th, 2006 01:55 PM
export to .txt file meimy Pro VB.NET 2002/2003 0 May 31st, 2004 03:24 AM



All times are GMT -4. The time now is 10:27 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc