Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2007, 12:09 AM
Authorized User
 
Join Date: May 2007
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 .



 
Old May 14th, 2007, 01:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Look for BCP utility in BOL.

_________________________
- Vijay G
Strive for Perfection
 
Old May 14th, 2007, 03:47 AM
Authorized User
 
Join Date: May 2007
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

 
Old May 14th, 2007, 04:29 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old May 14th, 2007, 04:58 AM
Authorized User
 
Join Date: May 2007
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'.


 
Old May 14th, 2007, 05:28 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old May 14th, 2007, 06:08 AM
Authorized User
 
Join Date: May 2007
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 ?


 
Old May 14th, 2007, 07:15 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old May 14th, 2007, 10:54 PM
Authorized User
 
Join Date: May 2007
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.


 
Old May 15th, 2007, 12:43 AM
Friend of Wrox
 
Join Date: Jun 2003
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.