June 1, 2009 at 7:07 pm
I have a query with 2 inner joins and an IN.
But unfortunately i can't use the query because the application needs a normal table i.e select a,b,c from d
So i was thinking of using a select into newtable from OldTable against the query which worked.
But how can i setup this process to insert to the table new data
Thanks in advance
June 1, 2009 at 7:45 pm
Patrick Ige (6/1/2009)
I have a query with 2 inner joins and an IN.But unfortunately i can't use the query because the application needs a normal table i.e select a,b,c from d
So i was thinking of using a select into newtable from OldTable against the query which worked.
But how can i setup this process to insert to the table new data
Thanks in advance
Well, not much to work on, so here goes the requests:
Please provide the DDL (create table statements) for alll tables involved, sample data (in a readily consummable format - just cut, paste, and execute in SSMS to load the tables), expected results based on the sample data, and the code you currently have written to solve the problem.
Need help with the above? Read the first article I reference below in my signature block. The more work you do up front, the better answers you will get in return.
June 1, 2009 at 8:14 pm
Lynn..
I don't know what else to write.
I have a query that has 3 tables joined that result in a resultset.
I can't use this query because it won't work with this particular application.
So i need a flat table as i explained earlier.
i can use a select into to wrap the query and insert into this new table.
But what can i do to update/add to this new table?
As this is the table i will be using.
June 1, 2009 at 8:23 pm
To avoid adding duplicate records, you might want to look at using "where not exists ()" or "where not IN ()"
You might also be able to use the EXCEPT operator.
To get further help, you will really need to provide table structures (including constraints) (DDL), and test data for these tables (DML). As a benefit, you then get TESTED code.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
June 1, 2009 at 9:15 pm
Patrick Ige (6/1/2009)
Lynn..I don't know what else to write.
I have a query that has 3 tables joined that result in a resultset.
I can't use this query because it won't work with this particular application.
So i need a flat table as i explained earlier.
i can use a select into to wrap the query and insert into this new table.
But what can i do to update/add to this new table?
As this is the table i will be using.
Provide us with the DDL (create table statements for the tables involved in your query), sample data (in a consummable format to load the tables you provide, should be able to cut, paste, and execute in SSMS), the expected results you are looking for (not what you are currently getting), and the code you have written so far that isn't working.
Also, make sure the sample data is sufficient to show the problem(s) you are experiencing as well.
Just explaining things isn't always enough. Sometimes you have to show us what you are trying to accomplish. For me seeing something visually helps me understand the problem better.
If you have any problems with this, please read the first article I reference in my signature block below. It provides you with step by step instruction on what you need to do to get better answers to your questions.
June 4, 2009 at 7:41 am
Is there any reason you can't drop the flat table, and then recreate it using the select into everytime you want to update it?
June 4, 2009 at 7:44 am
Maybe you can create a view based on your query and then select data from it?
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply