Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Append

Author  Topic 

chipembele
Posting Yak Master

106 Posts

Posted - 2006-11-15 : 10:40:07
Hi
I'd like to create a table on our SQL server that I can append records to when running a query.

What i intend to do is create a new table with the same fields as the query then when the query runs i want it to append the results to this new table. Is this possible? How would I go about creating the table, primary key etc?

I've tried doing this through an access front end but its not efficient and was a bit of a struggle to be honest.

Also, we need other people who may not have access to enterprise manager to be able to run this append query.
Danny

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-15 : 10:54:23
What do you mean by "append"? why data insertion order is important to you? You can retrieve data in whatever order you want.

As to creating tables and inserting data, you will have to refer SQL Server help.

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

chipembele
Posting Yak Master

106 Posts

Posted - 2006-11-15 : 11:03:00
quote:
Originally posted by harsh_athalye

What do you mean by "append"? why data insertion order is important to you? You can retrieve data in whatever order you want.



Hi
By append I mean an extra table that has data added to it when a query is run. The user runs a query and the results are added to a table that wouldnt normally be part of our database.

When someone phones in sick we run a parameter query that tells us how many hours that person would teach during their period of sickness. At the moment we run the query and export it to excel but this is inneficient for the user.

What i'm trying to do is when this query is run it appends the results to this other table (lets call it Staff sickness). Over time this table builds up and we can report on it by staffid etc to give us information about how many teaching hours the memeber has missed. All the user has to do is run the append query and input the parameters required.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-15 : 11:06:23
[code]
Create Table SomeTable
(
...
)

Insert into SomeTable
Select ....
[/code]

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

chipembele
Posting Yak Master

106 Posts

Posted - 2006-11-16 : 03:57:37
quote:
Originally posted by harsh_athalye

Create Table SomeTable
(
...
)

Insert into SomeTable
Select ....




Is this a query that would add the returned records to the specified table though?

We need to run a query against a number of tables and automatically add the results to the specified table.

Reading the above the first command tells the system to insert whatever is selected from the SELECT query in part 2. Am I reading that correctly?
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-11-16 : 07:17:21
Read the first link in my signature, and restate your question

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-11-16 : 09:02:50
This sounds a lot like M$ Access



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

chipembele
Posting Yak Master

106 Posts

Posted - 2006-11-19 : 12:20:12
I've decided to create an Access front end, link to the tables I need and create my table and append query in Access. it will give me greater flexibility for other users to run the query.

Will try to state my Q properly in future
Go to Top of Page
   

- Advertisement -