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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Request help with Query please

Author  Topic 

mrtweaver
Yak Posting Veteran

67 Posts

Posted - 2008-11-17 : 09:13:11
I have a historical database this database is 1M+ records. Off of this historical database I have a view that uses a where clause to only show the last 3 days of production. What I am looking to try to do is find an auto increment field in the historical database that I can pull over using a Query into the view. This way I could use the following type query to get the data from the live table where there has been a change in the pagemech column:

select t1.machine, t1.start, t1.mech from livedata t1 left join historical t2 on t1.{?} != t2.{?}

The t1.{?} is the column that is copied from the Historical table into the view

The t2.{?} is the auto incrementing column located in the historical table. This is the one I dont know where it is located or what to use. Someone in another type forum said about using an index, however is Microsoft SQL I can not seem to find out if this field is auto incrementing and how to access it so I can put it in a query to be placed in a view.

Can someone please help.

I am only somewhat familar with MS SQL and the only way I know of doing things is with Management Studio and that is very limited

Using MS SQL 2005.

Here is the query that creates the view:

SELECT * from historical where datediff(d,start,current_timestamp)<3

The data for the historical table is dumped in via automation thru a software product called KepServer and Factory SQL.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-17 : 09:33:07
duplicate
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=114587
Go to Top of Page
   

- Advertisement -