02-09-2009 7:27 AM
Hi Experts,
I would like to know what are the best practices to be followed for writing a native SQL query. Is it recommended by SAP. What are the potential issues apart from the fact that they are database dependent. I would also like to know if we go for a SAP upgrade, how will my queries get affected.
Regards,
Abdullah Ismail.
02-09-2009 7:33 AM
Hi Abdullah,
I I am sending you a document for the query you were facing.Hoping you will get the information.
Link:[Native|http://download.microsoft.com/download/a/4/7/a47b7b0e-976d-4f49-b15d-f02ade638ebe/SQLServer2005forSAP.doc.].
Please do check for query in this document.
Have a best day ahead.
02-09-2009 7:54 AM
Hi,
Thanks for your prompt feedback. This document is from MS SQL perspective. I would like to know what are the best practices from SAP point of view. Do they recommend writing native SQL queries?
Warm Regards,
Abdullah
02-09-2009 11:50 AM
>
> Hi,
>
> Thanks for your prompt feedback. This document is from MS SQL perspective. I would like to know what are the best practices from SAP point of view. Do they recommend writing native SQL queries?
>
> Warm Regards,
> Abdullah
As far as I know, SAP do not encourage native SQL for the simple reason that it is database specific and any SAP system is supposed to be portable to any database platform. If you do use real SQL (and I have done) you have to be aware that if you change database platforms your SQL will almost certainly have to be rewritten.
The other disadvantage of using real SQL is that you have to know what you are doing since the syntax checker will not help.
Just for interest, something I noticed the other day. There have been posts in this forum before asking if there is a SQL scratchpad available where you can write SQL queries directly in your test or productions systems. As of release ECC 6.0 there is; in tcode DBACOCKPIT there is a SQL command editor option under Performance -> Additional Functions which seems to allow you to do just this - but using real SQL only.
02-09-2009 8:21 AM
Hi,
You can write native sql query in ABAP, It is not restricted by SAP.
Only the thing is Native SQL query will establish a connection to the data base and from select ... and end-select.
the connection exists, So it is recommended not to use any other native SQL query or any other statement between select........... and end-select.
02-09-2009 10:44 AM
Hi Abdullah,
Acess of database through Native SQL is not SAP Concept.If we use native SQL in all the things then we can not use the SAP Tools and Many other functions in SAP.So when we use SAP native SQL is avoided.Though in some case we right SQL Coding in Native.The format is
EXEC SQL PERFORMING <form>.
<Native SQL statement>
ENDEXEC.
Native SQl is database independent.So you need to know database structure while you write the query.And SAP being the operating system indepedent Application.In SAP The open SQL statement written by the user is changed into native sql through interpretor inside the R/3 platform.As R/3 platform then converts it according to the data base used.If we do it directly we can not use all the functionality of SAP.Hope your query reolves.I am attching a document for it.Please have a look.
Link:[NativeSQl|http://help.sap.com/saphelp_nw04/helpdata/en/51/ef9f94e4ba894d8e93b2eed7c9f82d/frameset.htm]
Have a best day ahead.