Byron avatar image
Byron asked

Inserting into a table on a different server


This is going to be confusing. I'm going to use an analogy to simplify my problem. If you don't want to answer, don't feel bad lol

I have a basket of 23 assorted fruits, and have measured their ripeness over a certain period of time. Their conditions are classified as immature, ripe, and rotten. Each type of fruit has its own database containing a series of time points where their condition is measured and logged (eg.

time 0, immature. time 1, immature. time 2, immature. time 3, ripe.)

I have developed a cursor to go through the various databases (which are located across two servers) according to fruit type that will find the proportion of time the fruit is in each condition relative to the entire measurement period.

Now I wish to take the fruit, proportion of time immature, ripe, and rotten, and move these four values for each of the 10 fruits into a table in a different server.

I would like my table to look like this

Fruit Immature Ripe Rotten

Apple .3 .5 .2 Banana .2 .4 .4 Orange .5 .3 .2 ...

My code is setup (basically) like so:

"Code for making the cursor, While Select (fruit, proportion immature, proportion ripe, proportion rotten) INTO [myserver].[mydatabase].[dbo].[fruit_condition] From [fruit_data_server_1] Join [fruit_data_server_2] End"

I have already set up the fruit_condition table in my database I know that the data is being pulled out correctly from the cursor query, as I can get the proportions for all 10 fruits, just in 10 separate views, which is why I am trying to consolidate the data into one table

When I try to execute my code, I am told "mydatabase" does not exist (Msg 2702). Can anyone help? Should I give more detail?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers


Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.