Compare data and return the different columns
Good Afternoon,
I am trying to compare the data in two tables and return only the columns and data where there is a difference.
I have a compare script which checks every column in the two tables against each other, but as there are 200 columns in the tables it is tricky to see which column has a difference.
So in my result set if coulum N is the differenct I would only want to return column N from both tables in the result set.
I hope that this all makes sense?.
Easiest way is to use tablediff utility for checking difference between tables
see
http://www.mssqltips.com/sqlservertip/1073/sql-server-tablediff-command-line-utility/
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Similar Messages
-
SQL statement to compare dates and return boolean (yes/no)
I am looking for a SQL statement that can compare 2 dates and return a boolean. 1 (yes) if date 1 is => date2-threshold or 0 (No) if date < date2-threshold
Ie
date1=20130603
threshold=2 days
date2=sysdate-threshold
if [ 20130603 > sysdate-$threshold ]
then
return 1
else
return 0
fi
Thanks to all that answer.Assumming I want to get "date1" from some other table instead of from
dual will this syntax be valid
I was going to invoke another SQLPLUS from my shell script and pass it in
as a variable but if I can do it on one shot it would be better.
In addition, if "no rows" are found for date1 from the below query, would
I need code to handle that
with xx as
select TO_DATE(last_date','yyyymmdd') date1, from dba_audit_table where ...;
select TO_DATE('20130603','yyyymmdd') date1, sysdate date2 from dual;
Thanks to all who answer
[/code1] -
Compare Dates and select the max date ?
Hello,
I am trying to write a script and will compare the dates in " eff_startdt" and give me the lastest date at the outcome.
I have data that some service locations have more than one contract date and I need to get the latest dated conract dates to work on the data but I tried many things I am always getting errors. When I run the script below I get " missing expression" error. I dont' see anything missing.
also somehow Max() is keep giving me errors when I do something like [ ON service_locs = vmeterid WHERE SERVICE_LOCS = SERVICE_LOCS AND EFF_STARTDT = MAX(EFF_STARTDT) ]
Can someone pls give me advice on this. Thanks
SELECT DISTINCT Broker, customer_name, service_locs, fee_kwh, qtr_monthly, eff_startdt, eff_enddt
FROM VMETER
INNER JOIN BROKER_DATA
ON service_locs = vmeterid WHERE SERVICE_LOCS = SERVICE_LOCS AND (SELECT MAX(EFF_STARTDT) FROM VMETER)
-----------------------------------------------------------Hi,
I will try to explain on my example. I have got a table:
DESC SOLD_ITEMS;
Name Value NULL? Type
COMPONENT VARCHAR2(255)
SUBCOMPONENT VARCHAR2(255)
YEAR NUMBER(4)
MONTH NUMBER(2)
DAY NUMBER(2)
DEFECTS NUMBER(10)
DESCRIPTION VARCHAR2(200)
SALE_DATE DATE
COMP_ID NUMBERI have insert example data into my table:
select component, subcomponent, sale_date,comp_id
2 from sold_items;
COMPONENT SUBCOMPONENT SALE_DAT COMP_ID
graph bar 06/04/03 1
graph bar 06/04/01 2
search user search 06/04/02 3
search user search 06/04/01 4
search product search 06/03/20 5
search product search 06/03/16 6
graph bar 06/05/01 7
graph bar 06/05/02 8
graph bar 06/05/02 9
As you can see there are a few components and subcomponents duplicated with different date and comp_id value.
I want to get component and subcomponent combination with latest date.
SELECT COMPONENT, SUBCOMPONENT, MAX(SALE_DATE)
2 FROM SOLD_ITEMS
3* GROUP BY COMPONENT, SUBCOMPONENT;
Efect:
COMPONENT SUBCOMPONENT MAX(SALE
graph bar 06/05/02
search user search 06/04/02
search product search 06/03/20
For your purpose I will do it using join and subquery. Maybe it will help you resolve your problem:
SELECT COMPONENT, SUBCOMPONENT, SALE_DATE, RANK
2 FROM (SELECT T1.COMPONENT, T1.SUBCOMPONENT, T2.SALE_DATE,
3 ROW_NUMBER() OVER (PARTITION BY T1.COMPONENT, T2.SUBCOMPONENT ORDER BY T2.SALE_DATE DESC) AS ROW
4 FROM SOLD_ITEMS T1, SOLD_ITEMS T2
5 WHERE T1.COMP_ID = T2.COMP_ID)
6* WHERE ROW = 1;
I joined the same table but it act as two different tables inside subquery. It will group values (partition by statement) and order result descending using t2.sale_date column. As you can see columns are returned from both tables. If you would like to add some conditions, you can do it after WHERE ROW=1 code.
Results:
COMPONENT SUBCOMPONENT SALE_DAT RANK
graph bar 06/05/02 1
search product search 06/03/20 1
search user search 06/04/02 1Hope this help you
Peter D. -
How to Read the one Source Column data and Display the Results
Hi All,
I have one PR_ProjectType Column in my Mastertable,Based on that Column we need to reed the column data and Display the Results
Ex:
Pr_ProjectType
AD,AM
AD
AM
AD,AM,TS,CS.OT,TS
AD,AM
like that data will come now we need 1. Ad,AM then same we need 2. AD also same we need 3. AM also we need
4.AD,AM,TS,CS.OT,TS in this string we need AD,AM only.
this logic we need we have thousand of data in the table.Please help this is urgent issue
vasuHi Vasu,
Based on your description, you want to eliminate the substrings (eliminated by comma) that are not AD or AM in each value of the column. Personally, I don’t think this can be done by just using an expression in the Derived Column. To achieve your goal, here
are two approaches for your reference:
Method 1: On the query level. Replace the target substrings with different integer characters, and create a function to eliminate non-numeric characters, then replace the integer characters with the corresponding substrings. The statements
for the custom function is as follows:
CREATE FUNCTION dbo.udf_GetNumeric
(@strAlphaNumeric VARCHAR(256))
RETURNS VARCHAR(256)
AS
BEGIN
DECLARE @intAlpha INT
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
BEGIN
WHILE @intAlpha > 0
BEGIN
SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
END
END
RETURN ISNULL(@strAlphaNumeric,0)
END
GO
The SQL commands used in the OLE DB Source is like:
SELECT
ID, REPLACE(REPLACE(REPLACE(REPLACE(dbo.udf_GetNumeric(REPLACE(REPLACE(REPLACE(REPLACE([ProjectType],'AD,',1),'AM,',2),'AD',3),'AM',4)),4,'AM'),3,'AD'),2,'AM,'),1,'AD,')
FROM MyTable
Method 2: Using a Script Component. Add a Derived Column Transform to replace the target substrings as method 1, use Regex in script to remove all non-numeric characters from the string, add another Derived Column to replace the integer
characters to the corresponding substring. The script is as follows:
using System.Text.RegularExpressions;
Row.OutProjectType= Regex.Replace(Row.ProjectType, "[^.0-9]", "");
References:
http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/
http://labs.kaliko.com/2009/09/c-remove-all-non-numeric-characters.html
Regards,
Mike Yin
TechNet Community Support -
I just updated my MAC operating system and when I went to open a recent document in numbers, the document that opened had none of my data and was formatted differently. Can I get my document with all my information back?
I suggest the easy stuff first:
1) quite Numbers and restart Numbers
2) reboot the computer
After that try opening the same document in another user space -
Function module for comparing dates and times
Hi,
I have a date and time stamp in one filed for example as below:
20070125183045
(the first 8 are date in YYYYMMDD format, the next 6 is time in HHMMSS format). Now I want to compare this value to another such value in terms of date and time. First I want to compare dates and then times. Do you know any function module that can serve this purpose?
Thanks very much!You can compare these using the function module DURATION_DETERMINE. This fuction will give you the difference, and it can be in a view different units, such as the difference in days, months, etc.
Funciton module takes in Start date and time and end date and time.
Regards,
RIch HEilman -
How to disable a single cell in a table (and not the whole column)
Hi there,
I've got a webdynpro table with a few columns, rows can be created dynamically through a button in the table toolbar.
Depending on the value of a certain cell I have to disable another cell (in the same row).
I tried to manipulate the view in the modifyview but no joy. I also tried to manipulate the attribute property through the coding below:
DATA lv_knttp TYPE knttp.
lo_nd_kostl = wd_context->path_get_node( path = `MULTIVALUES.KOSTL` ).
lo_el_kostl = lo_nd_kostl->get_element( ).
lo_el_kostl->set_attribute_property(
attribute_name = 'LTEXT'
property = lo_el_kostl->e_property-enabled
value = ''
but it disables the whole column!!!! I just need the cell to be disabled (I thought the code above, through the lead selection, would affect a certain cell only - but I was wrong).
Any ideas?
Thanks!!!Hi,
using cell variants you can do this.,
check this article: [Cell Variants in WDA|http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynproforABAPCellVariants]
Instead of binding the read only property of table as a whole , just bind the read only property of column group of table., You can do this bu drill down the table and select the required column and bind the read only column.,
then In onAction Event of button .,
loop the table, if condition satisfied set the read only property to true else false.,!!
hope this helps u.,
Thanks & regards,
Kiran -
Copy control for dates and disable the input
Hi All,
I have the following problem: I'm trying to copy dates in a follow-up order from the source order (which works fine by implementing the CRM_COPY_BADY method DATES) and disable the input of the copied dates in the follow-up order (which doesn't work).
In the change-parameter CT_INPUT_FIELDS you can specify the fields which have to be copied and furthermore you can control the modifiability of the field in the follow-up order via the parameter CHANGEABLE (e.g. 'A' means field can not be changed). This technique is the same in all methods of the copy BADI.
Unfortunately it doesn't work for the dates. As I said already, the date is copied but can be changed by the user in the follow-up order.
Anybody an idea?
Thanks and best regards, LutzDear John,
Actually, I have tried with copy requirement 2.However, it works for copying a different customer with the same sales area as original. Yes, I may need to ask developer to solve my solution. But I would like to keep it to be the last choice. I tried to search "How to copy document between inter-company businees"; but the I still not get what my custome's want. Anyways, thank you very much for sharing idea. -
How to compare date and time together
Hi,
How to compare Date and Time together?
For example in a database table there are two fields rundate and runtime. I want to compare these two with perticular date and time in the program. Like, I want to pull all the records where the records's date and time are less than a perticular date and time in the program.
Hope the question is clear...
Thanks.
KavitaHi Kavita
There is no as such Date and Time Comparision FM in Standard SAP But You can define your own like this
<b>FUNCTION ZAV4_COMPAREDATETIME.
""Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(DATE1) TYPE DATS
*" REFERENCE(TIME1) TYPE TIMS
*" REFERENCE(DATE2) TYPE DATS
*" REFERENCE(TIME2) TYPE TIMS
*" EXPORTING
*" VALUE(TWOISMORETOPICAL) TYPE C
twoismoretopical = ''.
if date2 > date1.
twoismoretopical = 'X'.
else.
if date2 = date1 and time2 > time1.
twoismoretopical = 'X'.
endif.
endif.
ENDFUNCTION.</b>
Regards
Mithlesh -
I have now transfered my files of ripped CD's to my iTunes library three times Since upgrading to iTunes 11 and Windows 8. On each occassion, the conversion seems to occur fine, the files play, but when I close my computer and return the next day, iTunes says it cannot locate any of those files. Three times. Beginning to lose my temper. Advice? Suggestions? Could the fact that my original library is located on a network drive have anything to do with it? Thanks for your help, all.
Repair security permissions
Right-click on your main iTunes folder and click Properties, then go to the Security tab and click Advanced. If necessary grant your account and system full control to this folder, subfolders and files, then tick the option to replace permissions on child objects which will repair permissions throughout the library. This is the XP dialog but Windows 7/8 shouldn't be too different.
Repeat for the media folder if it isn't a subfolder of the iTunes folder.
tt2 -
How to convert Smart Form into PDF format and return the result in BAPI?
I want to convert a Smart Form into PDF format and return the result in BAPI.
can anyone tell me how it can be done with related example
regards
pranayhi,
smart form to pdf--
All you have to do is call your SF to get OTF and then concert it to PDF. Works like charm:
DATA: p_output_options TYPE ssfcompop,
p_control_parameters TYPE ssfctrlop.
p_control_parameters-no_dialog = 'X'.
p_control_parameters-getotf = 'X'.
CALL FUNCTION v_func_name "call your smartform
EXPORTING
output_options = p_output_options
control_parameters = p_control_parameters
IMPORTING
job_output_info = s_job_output_info.
call function 'CONVERT_OTF_2_PDF'
tables
otf = s_job_output_info-otfdata
lines = t_pdf
and if u need more u can check below links also
Check the below links..
Re: Smartforms to PDF
Re: smartform (otf) as pdf and sending as email-attachment
VISIT THIS LINK
Re: Smartforms to PDF
PLZ REWARD POINTS IF IT HELPS YOU
rgds
anver -
I have a country dimension which is used in 5 cubes. Now I want to change 'key column' property of the country attribute. Whenever I do this, I get an error as "The key columns of the country measure group attribute do not match in either number or
data types to the key columns of the source attribute". I dont understand what this error is about.
Can someone please help? Thanks in advance.
-Regards,
Raj Patilsounds like you need to verify your dimensional usage tab to verify the relationships between dim and fact on the measure group.
Hi Talktorajpatil,
As Jon said, you can verify the relationships between dim and fact on the measure group on the dimensional usage tab. Use this section to define how you "join" your measure groups to your dimensions. There may be a Dimension-Measure Group relationship
that is defined using the wrong attributes and you'll need to select the correct attributes to link the Dimensions to the measure groups. Here are some similar thread for your reference.
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/74203b66-8a71-4681-8e47-8f99cce87b3d/error-on-the-measure-group-which-do-not-match-the-data-type-of-the-key-column?forum=sqlanalysisservices
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/2421058d-fd4a-44b8-8c7c-b0b349bbef2d/measure-group-attribute-key-column-does-not-match-source-attribute?forum=sqlanalysisservices
Hope this helps.
Regards,
Charlie Liao
TechNet Community Support -
Having arranged some scanned pictures in an album in I-Photo how can I keep them in the order I have chosen when I move the album. They all have the scan date and not the taken date and move to new positions if I move them from one album to another.
Is there any way to re-number them in the order I have chosen so that they can then be sorted by number? The scans are all from pre-digital images that I wish to move to a photobook and I don't want to have to organise them twice!
Thanks for any suggestions.I was a bit short, Chris, sorry. It is limited, what can be posted, when typing on an iPad.
Now I am back on my Mac. I meant the following: Batch Change the date for a large range of photos, that should have a date stepped in increments.
Select all Photos at once and use the command "Photos > Batch Change".
Then set the date for the first photo and select an increment, e.g. one minute.
Now all photos will get a new date assigned, incremented by one minute, in the sequence you have selected. So you will be able to sort them by date. This way it will be unnecessary to change the titles or filenames. -
I downloaded and installed Airport Express Utility 5.6 to get my old Airport Express to work with the latest Mac OSX 10.7.4, but when I install and run it, it still says my Airport Express is out-of-date and needs the 5.6 utility. What's up?
It is likely that you downloaded AirPort Utility 5.6.1. If you checked the requirements, this only runs on Leopard or Snow Leopard Macs.
You have Lion, so you need AirPort Utility 5.6 for Mac OS X Lion -
I recently tried to update my iPhone 3 software via my mothers Mac book comp - during the upgrade I lost all my music and calendar dates and now the iTunes on my phone has my mothers iTunes detail - how do I get all my info back on the phone?
Restore it using the computer you normally sync with.
Maybe you are looking for
-
Deletion of AppSet in SAp BPC 7 NW
Hi all, I have a problem with deletion an AppSet in SAP BPC 7.0. When I launch the operation from BPC Client I get this message error during processing: Failed to connect to ABAP Server Time limit Exceeded In NW System I modified the abap/buffersize
-
Cannot get "Edit / Duplicate" to work in Premiere Elements 13
Hi. I'm using Premiere Elements 13 on Windows 8.1. I've created a title template and placed it above a movie clip. I have several other movie clips, and I want to duplicate the title template I created to use with the remaining movie clips in my pr
-
is it possible to retrive or download a number/contact after its been deleted from your iphone? i deleted a number about 2-3 months ago and now i really need it back. is it possible to retrieve this number or maybe view or bring up my entire or past
-
I am getting confused between XT series and GT series (ATI card). What is the basic difference ? Which one is more powerful ? (my interest are : MSI RX1650XT-T2D256EZ vs MSI RX1650GT-T2D256EZ) Thanks.
-
I got sick of watching my title loop while I was working on it. I clicked the "X" to get rid of it. I can't seem to figure out a way to get it back. The "X" is "hide preview mode" but I can't find anything about "show preview mode." Thanks!