Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 14th, 2007, 12: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 .



Reply With Quote
  #2 (permalink)  
Old May 14th, 2007, 01:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Look for BCP utility in BOL.

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old May 14th, 2007, 03: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

Reply With Quote
  #4 (permalink)  
Old May 14th, 2007, 04:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
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
Reply With Quote
  #5 (permalink)  
Old May 14th, 2007, 04: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'.


Reply With Quote
  #6 (permalink)  
Old May 14th, 2007, 05:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
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
Reply With Quote
  #7 (permalink)  
Old May 14th, 2007, 06: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 ?


Reply With Quote
  #8 (permalink)  
Old May 14th, 2007, 07:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
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
Reply With Quote
  #9 (permalink)  
Old May 14th, 2007, 10: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.


Reply With Quote
  #10 (permalink)  
Old May 15th, 2007, 12:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

_________________________
- Vijay G
Strive for Perfection
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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 02:24 AM



All times are GMT -4. The time now is 03:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.