| Author |
Topic  |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/13/2012 : 05:05:46
|
Hi all, the below query outputs an historical data for all columns in unsaccountB tbl. I need to add the current value (whatever is stored on outputed columns on unsaccountB tbl) of all outputed columns (dbc.ColumnName). How would I do that? Do you need any other info to help me with this thread?
|
Edited by - emmim44 on 07/20/2012 08:30:34
|
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 07/13/2012 : 10:32:22
|
is there a bit field which indicates current data? or is it based on latest date value?
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/13/2012 : 10:56:34
|
quote: Originally posted by emmim44
quote: Originally posted by visakh16
is there a bit field which indicates current data? or is it based on latest date value?
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
There is none. Basically there should be another column "CurrentValue" and should be output the current value of outputed table column...UnsAccountB table columns are the same as DialogColumn tbl columnName field. Basically the current data is stored on unsaccountB tbl. DialogWatchPropery and DialogWatchOperation contain historical data and dialogColumn contains db tables structure information.
sample: columnName CurrentValue oldValue AccountDisabled F T AccountDisabled T T
|
Edited by - emmim44 on 07/13/2012 16:01:42 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 07/13/2012 : 23:57:31
|
can you post table structures with some sample data?
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/15/2012 : 13:19:59
|
quote: Originally posted by visakh16
can you post table structures with some sample data?
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
Which tbl are u referring? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 07/15/2012 : 23:28:07
|
your tables which gives you above output
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/16/2012 : 05:46:33
|
quote: Originally posted by visakh16
your tables which gives you above output
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
Edited by - emmim44 on 07/20/2012 08:30:05 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/16/2012 : 10:20:14
|
quote: Originally posted by visakh16
can you please follow below guidelines and give data in this format?
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
what is missing? is the sample data?
By the way, I have updated query as follow and getting the err of "Invalid object name 'unsacountB'." :
SELECT p.firstname,p.lastname, u.XProxyContext, dw.[OldValue],newVal =
(select dbc.ColumnName from unsacountB where dbc.ColumnName in
(SELECT name FROM sys.columns WHERE OBJECT_NAME(object_id) = 'unsaccountb')
)
,dwo.operationDate, dwo.OperationType,dbc.ColumnName,dbc.TableName
FROM DialogWatchProperty dw
INNER JOIN DialogWatchOperation dwo ON dw.UID_DialogWatchOperation = dwo.UID_DialogWatchOperation
INNER JOIN UNSAccountB u ON dwo.ObjectKey = u.xObjectKey
INNER JOIN Person p ON p.uid_person = u.uid_person
INNER JOIN DialogColumn dbc on dbc.UID_DialogColumn = dw.UID_DialogColumn
where ---OperationType = 'U'
dwo.operationDate between convert(varchar,@sDate,1) and convert(varchar,@eDate,1)
----And dbc.ColumnName = u1.
And u.XProxyContext = @TargetSystem
And p.FirstName = (case when @FirstName <>'' then @FirstName else p.FirstName end)
And p.LastName = (case when @LastName <>'' then @LastName else p.LastName end)
And p.CentralAccount =
(case when @userName <>'' then @userName else p.CentralAccount end)
And PersonnelNumber = (case when @personelNumber <>'' then @personelNumber else PersonnelNumber end)
order by firstname,lastname,dbc.ColumnName asc, dwo.operationDate desc |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 07/16/2012 : 10:29:07
|
its a typo. table name is missing an extra c in account
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/16/2012 : 10:54:47
|
quote: Originally posted by visakh16
its a typo. table name is missing an extra c in account
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
is the logic i update on latest query wrong or right? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 07/16/2012 : 11:29:05
|
quote: Originally posted by emmim44
quote: Originally posted by visakh16
its a typo. table name is missing an extra c in account
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
is the logic i update on latest query wrong or right?
We cant suggest on that unless we know what exactly you're trying to achieve. that was purpose of asking required information as per previous link posted.
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/16/2012 : 14:59:34
|
quote: Originally posted by visakh16
quote: Originally posted by emmim44
quote: Originally posted by visakh16
its a typo. table name is missing an extra c in account
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
is the logic i update on latest query wrong or right?
We cant suggest on that unless we know what exactly you're trying to achieve. that was purpose of asking required information as per previous link posted.
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
What else is missing from what I had posted here? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 07/16/2012 : 22:20:23
|
how can we understand what are table data in those fields from what you posted and what you're trying to achieve from it. As suggested, please see how steps are explained in link and post relevant information. Unless you do that its really hard for someone to make out whats the issue with current query as well as your method. Unless you do that, we will keep on guessing which is both a waste of time and effort for both of us
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/17/2012 : 04:25:20
|
| t |
Edited by - emmim44 on 07/20/2012 08:29:46 |
 |
|
| |
Topic  |
|