|
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
|
|
|
May 14th, 2007, 12:09 AM
|
Authorized User
|
|
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 .
|
May 14th, 2007, 01:02 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Look for BCP utility in BOL.
_________________________
- Vijay G
Strive for Perfection
|
May 14th, 2007, 03:47 AM
|
Authorized User
|
|
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
May 14th, 2007, 04:29 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
May 14th, 2007, 04:58 AM
|
Authorized User
|
|
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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'.
|
May 14th, 2007, 05:28 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
May 14th, 2007, 06:08 AM
|
Authorized User
|
|
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ?
|
May 14th, 2007, 07:15 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
May 14th, 2007, 10:54 PM
|
Authorized User
|
|
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
May 15th, 2007, 12:43 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
There seems to be some issue with your login/password. Make sure the password is right.
_________________________
- Vijay G
Strive for Perfection
|
|
|