Find out the calling database in a sproc called from a different database

Hello, I'm trying to figure out how to identify the calling database within a sproc on a different database without using a parameter. Any ideas?
Thanks

Hi First Kit Carson,
Regarding your description, are you looking for something as below?
CREATE DATABASE TestDB1
CREATE DATABASE TestDB2
GO
USE TestDB1
CREATE TABLE TestDB2.dbo.T1(ID INT);
CREATE TABLE TestDB2.dbo.T2(ID INT);
GO
CREATE PROC dbo.PROC1
AS
SELECT * FROM TestDB2.dbo.T1
GO
CREATE PROC dbo.PROC2
AS
SELECT * FROM TestDB2.dbo.T2
GO
SELECT *
FROM sys.dm_sql_referenced_entities ('dbo.PROC2', 'OBJECT');
SELECT R.SPECIFIC_CATALOG,r.SPECIFIC_NAME,cat.* FROM
INFORMATION_SCHEMA.ROUTINES R
CROSS APPLY
SELECT referenced_server_name,referenced_database_name,referenced_schema_name,referenced_entity_name,referenced_minor_name,referenced_class_desc
FROM sys.dm_sql_referenced_entities(R.SPECIFIC_SCHEMA+'.'+R.SPECIFIC_NAME,'OBJECT')
) AS cat
WHERE R.ROUTINE_TYPE='PROCEDURE'
GO
USE master
DROP DATABASE TESTDB1,TESTDB2
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support

Similar Messages

  • How to find out the calling point of a Badi

    Hi Experts,
    Say one Badi is getting called in a particular screen of a transaction.
    Can anyone please guide me how to find out the calling point for that Badi.
    I checked for transaction CC31 screen 2000, method IF_EX_ECM_EXIT~OMR_CHECK_01
    is getting called.
    But I could not find the calling point.
    Please help.
    Thanks,
    Sonali.

    Go in to the perticular method, and click on where used list.That may help.
    Or get into the method in debugging, and press F7. That will take you to the calling point.

  • Is there a way to find out the caller function in ESTK?

    Dear forum,
    How do you find out the caller function?
    I remember this question was asked on the forum before and, if memory serves me right, it was Peter Kahrel who answered it. Anyway, it was long ago and I can't find the post.
    main();
    function main() {
        hello();
    function hello() {
        // Is it possible to find out that the caller function is 'main'?
    Before making the post, I googled for it and found many suggestions, for example:
    alert("caller is " + arguments.callee.caller.toString());
    But nothing works for me.
    Regards,
    Kasyan

    Here's a new version of the function:
    function callerName() {
        var arr = $.stack.split(/[\n]/),
        callerName = arr[arr.length - 3].replace(/\(.*\)/, "")
        return callerName;
    I corrected the regex to remove the parentheses and everything in between.
    The previous version returned the function's name with arguments, like so:
    Result: ProcessTables([Paragraph:[object Paragraph]])

  • HT204088 how to I find out the most recent deductions to my account from the app store (say, for a recent download for additional functionality on a iPad game)

    How to I find out the most recent deductions to my account from the app store (say, for a recent download for additional functionality on a iPad game). Much as I try, I can't seem to get to see my account in enough detail to see what I have spent downloading apps to the ipad.

    You need to punch in the passcode for any purchase right, not just for new apps??
    If one of the other students, or anyone else, got access to your iTunes Store account, necessary to make any purchases, then they'd have all the information they'd need to also make in-app purchases. But an in-app purchase can only be made through the account through which the original app was purchased. Either your son bought the game (free or paid) and then shared it with someone else along with the account information (necessary to authorize the app on someone else's device), or someone else downloaded the game as well, not just made in-app purchases.
    In any case, changing your iTunes Store password should now have cut off any such unauthorized activity, though of course if your son gives the new password out, you'll be back to square one.
    Regards.

  • How to find out  fn calls  from portal.

    can anyone help me to find out  fn calls in xrpm portal?
    steps!

    You can use the following steps for doing it in portal
    Open two sessions of SAP EP with the same user
    Navigate to: Portfoliomanagement – Administration – Cache Administration – RFC Debugging (first session)
    Activate the Debugging
    Execute xRPM application in the second session
    Switch back to the RFC Debugging press Load
    Select the executed function
    All parameters will be displayed in the Context Input window
    if you need to do debugging in backend !
    make sure to swithch to new editor.
    regards@gopeekrishnan

  • How to find out the failed sql command and its data from DEFERROR

    Hi,
    has anybody a procedure or some other possibilities to read the content of column USER_DATA of the advanced replication view DEFERROR in order to find out the failed sql command and its column values?
    Thanks in advance.

    Hi Vishwa,
                 The control would be something like this for navigation in Get_p_xxx method u mention as link and u mention a event name which gets triggered on the click of this hyperlink. So your GET_P_XXX method would have the following code:
    CASE iv_property.
        WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
          rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
        WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
          rv_value = 'EXAMPLE'.
    Now you have to create a method as EH_ONEXAMPLE at your IMPL class and within which you would give an outbound plug method. Within the outbound plug the target data would be filled in the collection and window outbound plug would be triggered.
    This is a huge topic and  i have just mentioned you basic things.
    Regards,
    Bharathy.

  • How to find out the caller of a method?

    Hi there,
    I wonder if there is a recommended way to find out, from which code a method gets called. My only idea is to create a stacktrace with new Exception().getStackTrace() and inspect the 2nd stacktrace element. Does anyone know if there is a better (or recommended) way to do this?
    Thanks, Hans

    Sounds like you really want two methods, one for internal use and one for external use. What you're asking for goes against good OOP principles.OK - in the mentioned case, i can get along with using two different methods. But for me it was not the first time that this question arised and i guess there might be cases where it would make sense to differentiate between callers. (In the core classes, for example, there is code which checks if certain methods are overridden in a sub-class and branches execution dependent on this information, which is a similar approach).
    Thanks to all replying to my question - Hans

  • How to find out the provider information of a cell phone (from deceased relative)

    Hello all!
    I have an odd sort of question that I am hoping for some help on.  My wife's uncle recently passed away and we are now in possession of his old cell phone.  He was slightly estranged from the family and didn't share a lot of information so we currently have no idea whether this phone is prepaid or if it uses a service provider.  We would like to find out who the provider is, if there is one, so that we can cancel service, but are not sure how to go about doing this.  We have been unable to find any information on his phone as of yet.  Is there any way that this information can be found?
    Thank you so much for the help!

    http://http://www.peoplesmart.com/phone
    Enter the number, the next screen will show the provider.
    Other option, just call *611 from the phone

  • How to find out the memory status of RT PXI controller from host?

    I want to find/read the memory status of the RT controller from host programmatically. Can any one have any idea about it? If yes can please share your valuable suggestion.
    Regards
    Vijay

    Hello Vijay,
    Check out the attached example, it monitors the CPU usage as well as the memory usage. You will need to install our STM component that you can download here:
    http://zone.ni.com/devzone/cda/epd/p/id/2739
    Message Edited by Jimmie A. on 06-12-2008 03:08 AM
    Regards,
    Jimmie Adolph
    Systems Engineer Manager, National Instruments Northern Region
    Bring Me The Horizon - Sempiternal
    Attachments:
    CPU and Memory Tracker1.zip ‏150 KB

  • Is there a way to find out the ipod that bought and download music from my acct?  My credit card was charged over $150.00 and my kids didn't do it

    Is there a way to identifiy who bought and downloaded music from iTunes from my account.  I looked at my kids touches and they don't have the music downloaded.  Over $150.00 have been charged to my credit card.

    First things first is you absolutely NEED to change your iTunes password, and possibly even your email password as well for that account.
    Secondly, you can get help with fraudulent purchases through the iTunes support site. http://www.apple.com/support/itunes/
    Click iTunes Store Account and Billing and there's a section about Billing Inquiries.
    After purchases, they should be emailing you invoices within a few days of the purchase. You can use that as reference to what was purchased, so that will help you determine if it was legitimate or not.  Simply look at the kid's iPod/iPad/iPhone and see if it is on their device.  Since you're all sharing the same account, you won't be able to tell which device purchased it.
    You're welcome to disregard the above statements if you'd like, since I reread your question and notice that you did already look at your kid's devices.
    Please change your email and itunes password immediately!

  • How to find out the labview-ve​rsion of a vi

    Hello,
    is there a way to find out the labview-version of a vi?
    I have different projects here and o am not sure which project is created with which labview-version.
    Now i can do it manually to open each vi with different lv-version and check when i can opn it.
    Or is there a tool that can do this for me?
    thanks for tips

    TedAnderson wrote:
    Ultimately I wrote the utility that I'm attaching to this post.  It's in LV2012, so it will only report LV versions up through 2012.
    This isn't true at all.  The "Get VI Version"  invoke node will return the version of the VI, regardless of the development environment.  If you used that property in LabVIEW 7.1 and the VI file was a 2013 it will return the version 2013 which is the version of the VI, not the version of the developement environment.
    My utility will examine all vi, vit, and ctl files.  lvproj files throw error 1059 when input to Get VI Reference.  
    This is because the project is not a VI and getting the VI reference to a non VI file throws an error.  To do this you would need to use the Project >> Open Invoke node to get a reference to the project, and then use that reference to get the version.
    I also couldn't help but notice you aren't closing any of your references that you are opening.  This will mean each time you run this VI your memory will increase.  It will also increase much faster with a larger number of VIs.  Put a Close Reference function closing all the VI references you open.
    If you are interested in reading the version from disk instead of opening references you will need to look at the "vers" block data in the VI.  Assembling it is a little bit of a pain but you can figure it out if you know the version you are looking for when developing the code.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Find out the process id from a background running script

    Hello all:
    I created a java service and use a shell script to drive it from background. In the script, I have code like this:
    javac myApp & I want to find out the pid for this process. After googling for a while I came up with this:
    echo $$ > test.pid However, I notice two things:
    1. This only works when my script runs frontground, meaning only when I remove "&";
    2. The pid file, test.pid, won't be created until the running script exits, after I clicked ctrl+c, for instance.
    Now the question is, how can I find out the pid of a background running script from within the script itself?
    I don't want to use code such as ps -ef | grep .... because of the possible name conflict.
    Thanks,
    Johnny

    Yes, but as far as I understand this can happen to any background process, for instance, when the user logs out while a background process is still running.
    But using the "$!" variable as you've shown is the "correct" solution.
    This is probably what the OP is looking for:
    javac myApp & echo $! > test.pidFrom the bash man page:
    $ Expands to the process ID of the shell. In a () subshell, it expands to the process ID of the current shell, not the subshell.
    ! Expands to the process ID of the most recently executed background (asynchronous) command.

  • How does one find out the database name , service name in a database

    hi,
    how do u find out the database name , service name , SID in a database.
    Please reply.
    Thanks ,
    Regards,
    RC

    This particular information is available in the view V_$PARAMETER owned by SYS. But you can also login with Server Manager as user INTERNAL and run:
    SHOW PARAMETERS
    The entries pertaining to the naming of the database are:
    1. db_name
    2. db_domain
    3. db_name
    4. instance_name
    5. service_names
    GLOBAL_NAME is a static (not changing) Data Dictionary view which has just 1 attribute (column) called GLOBAL_NAME.
    When you run:
    select GLOBAL_NAME from GLOBAL_NAME;
    You are returned the full global name of the database, i.e. the db_name and the db_domain joined together by dot (.) For e.g. if your db_name = mgmt and db_domain = tech.co.in, then your global_name will be MGMT.TECH.CO.IN.
    Ciao.
    null

  • How to find out the database-size

    Hello,
    how can I find out the size of the database.
    I created the user as below. I defined the size of the database to 2MB. Now I want to know how much is the size of the database.
    CREATE USER oemer
    IDENTIFIED BY ...
    DEFAULT TABLESPACE system
    QUOTA 2M ON system;

    Actually, since Omer is a veteran poster to the Forms and Reports forums, I doubt that. I think he is making a much more interesting journey: from front-end to back-end.
    I'll be a bit more helpful this morning.
    Databases are ways of organising disk space to store data. Fundamentally they consist of OS files, data files. The RDBMS handles by grouping them into tablespaces. When we build tables we assign them to a tablespace.
    So, the size of the database is the sum of its datafiles. Of course, some tablespaces are used for sorting and holding undo information, so the size of the database for the purposes of persisting data is:
    SELECT count(x.tablespace_name) AS total_TS, sum(x.MB) AS total_mb, sum(x.free_mb) AS total_free_mb
    FROM   ( SELECT t.tablespace_name, sum(d.bytes)/1048576 AS mb, sum(f.bytes)/1048576 AS free_mb
             FROM   dba_free_space f, dba_data_files d, dba_tablespaces t
             WHERE  t.contents = 'PERMANENT'
             AND    d.tablespace_name = t.tablespace_name
             AND    d.file_id = f.file_id
             GROUP  BY t.tablespace_name ) x
    /The SYSTEM tablespace is special. It is used by Oracle to hold the data dictionary, the definitions of all the objects in the database. It should not be used for storing application objects (it affects the performance, apatrt from anything else). That is why we must not use it as a default tablespace.
    CREATE USER oemer
    IDENTIFIED BY ...
    DEFAULT TABLESPACE ts_users
    QUOTA 2M ON ts_users; Cheers, APC

  • How to search this value in oracle database to find out the table

    Hi expert,
    I know there is a value in oracle database, please show me how to search this value in oracle database to find out the table holding this value.
    Many Thanks,

    918440 wrote:
    Hi friends,
    this question is really practical, I already know there is value from application saved in database, I want to search the whole database to figure out which table the value is contained.write SQL that writes SQL to query every table.
    Handle:     918440
    Status Level:     Newbie
    Registered:     Mar 2, 2012
    Total Posts:     20
    Total Questions:     10 (10 unresolved)
    why do you waste time here when you NEVER get any answer to any question you post?

Maybe you are looking for