显示标签为“solve”的博文。显示所有博文
显示标签为“solve”的博文。显示所有博文

2012年3月22日星期四

BCP problem.Pls solve anyone immediately

Hi all,

I tried with that but i am able to inserting abtable(this has 4 cols and 12000 records) with bcp.that is working very good.but i'm getting problem with other table bibtable(this has 52 cols and 73000 records) with bcp but it is inserting all rows with dts.i want to insert both of the tables either of one bcp or dts to insert data into sqlserver 7.0

my bcp commands are:
bcp master..BIBDATA in c:\BIB20031006.TXT -fc:\MSSQL7\Binn\bib52.fmt -SJAVADEV2-PC-NJ -Usa -P
this is working properly with abtable but not with bibtable

bcp master..bibdata in c:\medsite\idocfile\new\bib20031006.txt -c -F2 -t\t -r\n -e c:\mssql7\binn\bib52.fmt -SJAVADEV2-PC-NJ -Usa -P
this is not working with anyone

in dts:

.delimited
filetype:ANSI SKIP ROWS:0
ROW DELIMITER:LF FIRST ROW HAS COLNAMES CHECKED
TEXT QUALIFIER:''

this is inserting bibtable perfectly but not abtable(inserting few records only)Try removing the space after the -e in the string -e c:\mssql7\binn\bib52.fmt so it looks like -ec:\mssql7\binn\bib52.fmt and put spaces in this string -SJAVADEV2-PC-NJ so it looks like -SJAVADEV2 -PC -NJ|||Try removing the -F2, this is telling the bcp utility to only copy the first two rows.

2012年2月18日星期六

bcp

hi friends,
whats the command used to bulk copy all the tables from the database?
pls help me to solve this.
thanks
vanithaVantha,
If you have both the source and target database on the same server you can
generate INSERT INTO tbl SELECT * FROM <SOURCE DB>.TABLE statments to copy
all the data.
try this query for generating required INSERT statements automatically.(run
this query on your destination query)
SELECT 'INSERT INTO ' + NAME + ' SELECT * FROM <YOUR_SOURCE_DATABASE>.DBO.'+
NAME
FROM SYSOBJECTS WHERE TYPE ='U'
If you source and destination servers are differnt, please create linked
servers and modify the aboove statment to include linked server name in the
SELECT statement.
Regards,
Gopinath M
"Vanitha" wrote:

> hi friends,
> whats the command used to bulk copy all the tables from the database?
> pls help me to solve this.
> thanks
> vanitha|||Gopinath M wrote:
> Vantha,
> If you have both the source and target database on the same server
> you can generate INSERT INTO tbl SELECT * FROM <SOURCE DB>.TABLE
> statments to copy all the data.
> try this query for generating required INSERT statements
> automatically.(run this query on your destination query)
> SELECT 'INSERT INTO ' + NAME + ' SELECT * FROM
> <YOUR_SOURCE_DATABASE>.DBO.'+ NAME
> FROM SYSOBJECTS WHERE TYPE ='U'
> If you source and destination servers are differnt, please create
> linked servers and modify the aboove statment to include linked
> server name in the SELECT statement.
Alternatively use DTS to copy data.
robert

2012年2月9日星期四

Basic SQL Question

I have a question on a practice assignment that I can't solve. Can someone
help me out?

Question:

The table Arc(x,y) currently has the following tuples (note there are
duplicates): (1,2), (1,2), (2,3), (3,4), (3,4), (4,1), (4,1), (4,1), (4,2).
Compute the result of the query:

SELECT a1.x, a2.y, COUNT(*)
FROM Arc a1, Arc a2
WHERE a1.y = a2.x
GROUP BY a1.x, a2.y;

Which of the following tuples is in the result?

a) (2,3,2)
b) (2,4,6)
c) (4,2,6)
d) (3,2,6)KGuy wrote:
> I have a question on a practice assignment that I can't solve. Can someone
> help me out?

Yes, create the table in question to your database, insert the given
values to there and then execute the given query and check which of
given results matches to the actual result.

This task is so simple that you don't even need brains to solve it,
since all you have to do is follow the instructions, compare few rows
and tell what you see.

If you don't have database, you can get one for free, for example mysql:
http://www.mysql.com/|||> Yes, create the table in question to your database, insert the given
> values to there and then execute the given query and check which of given
> results matches to the actual result.

Of course, I could do that, but I would like to understand why the output is
what it is. Sorry if I was unclear. Thanks for the reply.

-Imran|||KGuy wrote:

> Of course, I could do that

Don't say you could do that, just do it. When you tell the corrent
answer, someone might be able explain it. And if want to make a guess,
be sure not choose wrong one.

Please understand that if we just give the correct answers it would be
the same as just shooting you in the head. It would do you more harm
than good. Point of practise assignments is that you learn by doing them.|||>I have a question on a practice assignment that I can't solve. Can someone
> help me out?

Thanks everybody. I managed to solve it by hand using tips from someone
(Andy Hassall). It takes a while, but at least it's doable and I understand
it. If the answer is important to you, reply to this post.|||On Sun, 23 Jan 2005 13:00:20 -0500, KGuy wrote:

(crossposting removed)

>I have a question on a practice assignment that I can't solve. Can someone
>help me out?

Hi KGuy,

In a few weeks time, you'll have a test. If you don't learn to work out
your assignments now, you'll certainly fluke the test.

And if you're lucky and pass the test, you'll be in even more trouble when
you're hired and you have to debug some real SQL.

>Question:
>The table Arc(x,y) currently has the following tuples (note there are
>duplicates)
(snip)

If there are duplicates, you don't have a table at all. A collection of
data that may hold duplicates is a heap. I'm truly amazed that there are
still schools where SQL is taught with text books that don't include a
primary key on every table in every example or every assignment.

> (1,2), (1,2), (2,3), (3,4), (3,4), (4,1), (4,1), (4,1), (4,2).
>Compute the result of the query:
>SELECT a1.x, a2.y, COUNT(*)
>FROM Arc a1, Arc a2
>WHERE a1.y = a2.x
>GROUP BY a1.x, a2.y;

Almost all professionals prefer the (more verbose, but better documenting)
infixed join notation. For outer join, the infixed notation is the only
way to avoid ambiguity. For inner joins, beth versions are allowed, but
the infixed notation is more popular. Also, avoiding the optional AS
between table name and table alias is not recommended either!

SELECT a1.x, a2.y, COUNT(*)
FROM Arc AS a1
INNER JOIN Arc AS a2
ON a1.y = a2.x
GROUP BY a1.x, a2.y;

This is how the query should (IMO) appear in a decent studybook.

>Which of the following tuples is in the result?
>
> a) (2,3,2)
> b) (2,4,6)
> c) (4,2,6)
> d) (3,2,6)

Easy to work out, actually. As an example, I'll show you why the answer
isn't a. You can then work out the three remaining options.

Each row in the output that shows 2 as the first value has a1.x=2. This
must stem from the row (2, 3), as that is the only row with an x value of
2. The join condition (a1.y=a2.x) means that the a2 row must have an x
value of 3 (as the y value in the a1 row is 3). Two rows qualify: (3, 4)
and (3, 4). Both have an y value of 4, so before grouping, there are 2
rows with a1.x=2 and a2.y=4. After grouping, this is 1 group with a row
count of 2. The result set should contain (2, 4, 2) as the only row
starting with 2.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)