Home All Groups Group Topic Archive Search About
Author
20 Oct 2005 7:30 PM
Art
Hi -- I'm new to SQL and thus also new to SQL Server.

I'm working on a project that has data stored in 4 databases.  I want to
create a 5th database for my work.  I will need to retrieve data from those
other 4 databases -- usually creating tables in my 5th database.  I want to
put together stored procedures to do this.  I can extract data and create
tables within one database, but have no idea how to reach out to a different
one.

Eventually, in this project I will need to read the records, in order and
create a running calculation -- not a running sum.  I can do this within VB
pretty easily, but I don't know if this can be done is a query.  The
calculation is: (field 2, record n) =
     (field 1, record n) * (1 - field 2, record n-1) + (field2,record n)

Finally, can anyone suggest a good book that might help me with some of
these types of questions?

I'd appreciate any help on any portion of the above!

             Thanks,

              Art

Author
20 Oct 2005 7:37 PM
Jerry Spivey
Art,

To access the tables in the other databases (assuming the same server) just
qualify the object using DATABASE.OWNER.OBJECT i.e., pubs.dbo.authors.

Books (SQL):

The Guru's Guide to Transact-SQL

by Ken Henderson

http://www.amazon.com/exec/obidos/tg/detail/-/0201615762/ref=ase_sql08-20/102-4703055-5891314?v=glance&s=books

Professional SQL Server 2000 Programming

by Robert Vieira

http://www.amazon.com/exec/obidos/tg/detail/-/0764543792/ref=ase_sql08-20/102-4703055-5891314?v=glance&s=books

Joe Celko's SQL for Smarties (2005 ed)

by Joe Celko

http://www.amazon.com/exec/obidos/tg/detail/-/0123693799/qid=1129837013/sr=8-2/ref=pd_bbs_2/102-7383292-7848138?v=glance&s=books&n=507846

HTH

Jerry

Show quote
"Art" <A**@discussions.microsoft.com> wrote in message
news:D5386C63-4FEA-42A6-8958-A2CF67FCB726@microsoft.com...
> Hi -- I'm new to SQL and thus also new to SQL Server.
>
> I'm working on a project that has data stored in 4 databases.  I want to
> create a 5th database for my work.  I will need to retrieve data from
> those
> other 4 databases -- usually creating tables in my 5th database.  I want
> to
> put together stored procedures to do this.  I can extract data and create
> tables within one database, but have no idea how to reach out to a
> different
> one.
>
> Eventually, in this project I will need to read the records, in order and
> create a running calculation -- not a running sum.  I can do this within
> VB
> pretty easily, but I don't know if this can be done is a query.  The
> calculation is: (field 2, record n) =
>     (field 1, record n) * (1 - field 2, record n-1) + (field2,record n)
>
> Finally, can anyone suggest a good book that might help me with some of
> these types of questions?
>
> I'd appreciate any help on any portion of the above!
>
>             Thanks,
>
>              Art
Author
20 Oct 2005 8:19 PM
Art
Jerry,

Thanks very much!  For both answers.

          Art

Show quote
"Jerry Spivey" wrote:

> Art,
>
> To access the tables in the other databases (assuming the same server) just
> qualify the object using DATABASE.OWNER.OBJECT i.e., pubs.dbo.authors.
>
> Books (SQL):
>
> The Guru's Guide to Transact-SQL
>
> by Ken Henderson
>
> http://www.amazon.com/exec/obidos/tg/detail/-/0201615762/ref=ase_sql08-20/102-4703055-5891314?v=glance&s=books
>
> Professional SQL Server 2000 Programming
>
> by Robert Vieira
>
> http://www.amazon.com/exec/obidos/tg/detail/-/0764543792/ref=ase_sql08-20/102-4703055-5891314?v=glance&s=books
>
> Joe Celko's SQL for Smarties (2005 ed)
>
> by Joe Celko
>
> http://www.amazon.com/exec/obidos/tg/detail/-/0123693799/qid=1129837013/sr=8-2/ref=pd_bbs_2/102-7383292-7848138?v=glance&s=books&n=507846
>
> HTH
>
> Jerry
>
> "Art" <A**@discussions.microsoft.com> wrote in message
> news:D5386C63-4FEA-42A6-8958-A2CF67FCB726@microsoft.com...
> > Hi -- I'm new to SQL and thus also new to SQL Server.
> >
> > I'm working on a project that has data stored in 4 databases.  I want to
> > create a 5th database for my work.  I will need to retrieve data from
> > those
> > other 4 databases -- usually creating tables in my 5th database.  I want
> > to
> > put together stored procedures to do this.  I can extract data and create
> > tables within one database, but have no idea how to reach out to a
> > different
> > one.
> >
> > Eventually, in this project I will need to read the records, in order and
> > create a running calculation -- not a running sum.  I can do this within
> > VB
> > pretty easily, but I don't know if this can be done is a query.  The
> > calculation is: (field 2, record n) =
> >     (field 1, record n) * (1 - field 2, record n-1) + (field2,record n)
> >
> > Finally, can anyone suggest a good book that might help me with some of
> > these types of questions?
> >
> > I'd appreciate any help on any portion of the above!
> >
> >             Thanks,
> >
> >              Art
>
>
>
Author
20 Oct 2005 8:18 PM
Anith Sen
>>  I can extract data and create tables within one database, but have no
>> idea how to reach out to a different one.

Use 3-part naming like database.owner.object

>> Eventually, in this project I will need to read the records, in order and
>> create a running calculation -- not a running sum.  I can do this within
>> VB pretty easily, but I don't know if this can be done is a query.

Perhaps if you post the DDLs, sample data & expected results, others could
give it a try. ( www.aspfaq.com/5006 ). In some cases, using a client side
programming language might be the option. In other cases, you might have to
use some looping construct like a cursor.

>> Finally, can anyone suggest a good book that might help me with some of
>> these types of questions?

SQL Server Books Online should give you most of the basics on t-SQL.

--
Anith
Author
20 Oct 2005 8:31 PM
Art
Thanks Anith,

I had been using a programming language, but was wondering if I might be
better off using SQL (assuming it's possible).  Thanks again.

          Art

Show quote
"Anith Sen" wrote:

> >>  I can extract data and create tables within one database, but have no
> >> idea how to reach out to a different one.
>
> Use 3-part naming like database.owner.object
>
> >> Eventually, in this project I will need to read the records, in order and
> >> create a running calculation -- not a running sum.  I can do this within
> >> VB pretty easily, but I don't know if this can be done is a query.
>
> Perhaps if you post the DDLs, sample data & expected results, others could
> give it a try. ( www.aspfaq.com/5006 ). In some cases, using a client side
> programming language might be the option. In other cases, you might have to
> use some looping construct like a cursor.
>
> >> Finally, can anyone suggest a good book that might help me with some of
> >> these types of questions?
>
> SQL Server Books Online should give you most of the basics on t-SQL.
>
> --
> Anith
>
>
>
Author
21 Oct 2005 2:15 AM
--CELKO--
Art, you are in trouble.  Let's get back to the basics of an RDBMS.
Rows are not records; fields are not columns; tables are not files;
your post is nonsense.   But it tells us that you have no idea about
RDBMS, so your design is probably screw to hell and breakfast.

You seem to be doing attribute splitting on databases; Otherwise, it
would not make sense to mix them.
Author
21 Oct 2005 8:47 AM
NH
"But it tells us that you have no idea about RDBMS"

Hey --CELKO--, keep your posts focused on the issue at hand, not the person
posting. The forum is here to help each other, not to put down people.

This a constant problem with you. Your input is valuable and appreciated,
but these kind of comments are not (at least by me).

Are there no moderators on this site?

Show quote
"--CELKO--" wrote:

> Art, you are in trouble.  Let's get back to the basics of an RDBMS.
> Rows are not records; fields are not columns; tables are not files;
> your post is nonsense.   But it tells us that you have no idea about
> RDBMS, so your design is probably screw to hell and breakfast.
>
> You seem to be doing attribute splitting on databases; Otherwise, it
> would not make sense to mix them.
>
>

AddThis Social Bookmark Button