Hi,
I have a SQL query:
select products.name, products.notes, products.purchase_date,
products.serial_no, products.total_value, products.product_code,
products.quantity, products.product_group, products.lhs1_name,
lhs1.department, lhs1.address1, lhs1.city, lhs1.country
from products, lhs1
where products.lhs1_id = lhs1.id
I want to insert the results of this query into a table called 'temp' in the
database. I used to copy and paste this into excel then import it but it
doesn't always work.
Is there a way to do it all in a SQL script. Please be aware that my
knowledge of SQL is fairly basic so please explain things clearly.
Thanks,
Darren 4 13737
INSERT INTO Temp
select products.name, products.notes, products.purchase_date,
products.serial_no, products.total_value, products.product_code,
products.quantity, products.product_group, products.lhs1_name,
lhs1.department, lhs1.address1, lhs1.city, lhs1.country
from products, lhs1
where products.lhs1_id = lhs1.id
if it does not exists at runtime:
SELECT
products.name, products.notes, products.purchase_date,
products.serial_no, products.total_value, products.product_code,
products.quantity, products.product_group, products.lhs1_name,
lhs1.department, lhs1.address1, lhs1.city, lhs1.country
from products, lhs1
where products.lhs1_id = lhs1.id
INTO Temp
HTH, Jens Suessmeyer.
Hi Jens,
Thanks for the quick reply. Your help is much appreciated. What would I need
to do in order to insert the results into a table called 'temp' that resides
in a different database e.g. Logi?
Thanks
"Jens" <Je**@sqlserver2005.de> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... INSERT INTO Temp select products.name, products.notes, products.purchase_date, products.serial_no, products.total_value, products.product_code, products.quantity, products.product_group, products.lhs1_name, lhs1.department, lhs1.address1, lhs1.city, lhs1.country from products, lhs1 where products.lhs1_id = lhs1.id
if it does not exists at runtime:
SELECT products.name, products.notes, products.purchase_date, products.serial_no, products.total_value, products.product_code, products.quantity, products.product_group, products.lhs1_name, lhs1.department, lhs1.address1, lhs1.city, lhs1.country from products, lhs1 where products.lhs1_id = lhs1.id INTO Temp
HTH, Jens Suessmeyer.
Refering to the four part notation this is gernerally:
[servername].[databasename].[owner].[objectname]
SELECT
products.name, products.notes, products.purchase_date,
products.serial_no, products.total_value, products.product_code,
products.quantity, products.product_group, products.lhs1_name,
lhs1.department, lhs1.address1, lhs1.city, lhs1.country
from products, lhs1
where products.lhs1_id = lhs1.id
INTO logi..Temp
HTH, Jens Suessmeyer.
>> Products.lhs1_id = lhs1.id <<
Why did a data element change names from table to table? Why do so
many of your data elements violate the rules of data modeling and
ISO-11179?
I would bet that this magical table, Temp, is not needed but is used to
mimic a scratch tape in a procedural solution. It is a common Newbie
error. You probably ought to get some help on the entire schema.
Otherwise, go to BOL and look up INSERT INTO .. SELECT.. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sans Spam |
last post by:
Greetings! I have a table that contains all of the function
permissions within a given application. These functions are different
sections of a site and each has its own permissions (READ, WRITE,...
|
by: traceable1 |
last post by:
I am inserting data rows into a table via a stored procedure. After
the inserts, I query the rows in the table and I want them to spit
back out in the same order I put them in.
However,...
|
by: jtocci |
last post by:
I'm having a big problem with CREATE RULE...ON INSERT...INSERT
INTO...SELECT...FROM...WHERE when I want to INSERT several (20~50)
records based on a single INSERT to a view. Either I get a 'too...
|
by: Philip Boonzaaier |
last post by:
I want to be able to generate SQL statements that will go through a list of
data, effectively row by row, enquire on the database if this exists in the
selected table- If it exists, then the colums...
|
by: maltchev |
last post by:
i need to insert data from an xml file into sql server table.
the xml file contains only one record.
how to insert the data? how to map the names of the fields in the xml file
and the table?...
| |
by: efgh |
last post by:
I'm fairly confident in my knowledge of SQL but I'm stumped with regards
with an Insert Into statement in Access 2003. I've got a 4 column table
that I've simplified about as much as I can, no...
|
by: Serdge Kooleman |
last post by:
i have a query: select id, name from Dictionary
field "id" is guid (so not null, and not identity)
i show only "name" in the dataGrid
how to set new id when i insert a new record?
...
|
by: nano2k |
last post by:
Hi
Shortly, I keep invoices in a table.
Occasionally, someone will fire the execution of a stored procedure
(SP) that performs several UPDATEs against (potentially) all invoices
OLDER than a...
|
by: weird0 |
last post by:
I have two tables accounts and ATM and i am trying to insert a tuple
in ATM with accountId as foreign key. But even this simple work,I
encounter the following error:
The INSERT statement...
|
by: lenygold via DBMonster.com |
last post by:
Hi Everebody:
I have a table:
CREATE TABLE CROSS_REFERENCE
(ROW# INTEGER NOT NULL
,KEY_WORD CHAR(16) NOT NULL
,QUERY_DESCR VARCHAR(330) NOT NULL
,PRIMARY KEY (ROW#,KEY_WORD));
It is a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |