How To Determine Sp Caller Current Database?
Aug 23, 2007
When executing a stored procedure that is defined in another database, as:
USE db1;
EXEC db2.dbo.sproc;
Is there a way in the stored procedure "sproc" to determine that the caller made the call from db1?
View 1 Replies
ADVERTISEMENT
Mar 25, 2008
I need to determine the following about the current authenticated Windows domain user who is trying to access a SQL Server via a trusted connection.
1 Has the current user been granted login access to the trusted SQL Server?
2 Has the current user been granted access to a specific database?
3 Is the current user a member of a specific database role such as (DB_ROLE_ADMINISTRATORS)?
Thanks,
Sean
View 6 Replies
View Related
Apr 2, 2008
I am wondering if there is a way to create a procedure in a logging database that can identify the source database from which it is invoked. DB_NAME() of course returns the name of the database in which the stored procedure exists. I could pass the database name as a parameter to the proc, just wondering if there is another way.
This is SQL 2005, I did look into the sys.dm_exec views but nothing seems to have a dbid reflecting the calling context.
Thanks,
Mike
View 4 Replies
View Related
May 6, 2008
Good Morning
Is There anyway to determine the table you are referencing in a trigger's inserted / deleted tables?
i.e would this be possible
print @Table_Name + " was Updated"
Where @Table_Name is the table on which the trigger is created
(bad example I know but you get the idea)
Any input will be appreciated.
View 3 Replies
View Related
Jul 23, 2005
I am using SQL Server 2000 and SQL authentication in a webappliacation. All data access is done via single SQL Server account.In my front end I am using forms authentication. Is there a way toretrieve the forms identity (or just a username) from SQL Server?Thanks,Lac
View 2 Replies
View Related
Jan 15, 2008
Is there any way of obtaining any information about the caller of a stored procedure from within the procedure, specifically machine name or IP address?
I'm looking for a built-in SQL function, rather than passing this information in as a parameter!
Thanks
View 4 Replies
View Related
May 14, 2008
With the new features of SQL Server 2005 for error handling (TRY...CATCH blocks), how are you propagating errors back to the caller? For example, lets say we have 3 stored procedures:
dbo.usp_UpdateSomeTable1
dbo.usp_UpdateSomeTable2
dbo.usp_UpdateSomeTable3
Let say some application calls dbo.usp_UpdateSomeTable1, in turn dbo.usp_UpdateSomeTable1 calls dbo.usp_UpdateSomeTable2 and in turn dbo.usp_UpdateSomeTable2 calls dbo.usp_UpdateSomeTable3.
Now if dbo.usp_UpdateSomeTable3 generates an error, how do you handle propagating this back to the caller?
I envision encapsulating the contents of each procedure in a TRY...CATCH block like so:
BEGIN TRY
...do some stuff
END TRY
BEGIN CATCH
...handle errors - whether generated from our own RAISERROR statements or by the database engine.
END CATCH
Now my problem is I would like to capture all the error variables and toss them back to the caller and keep sending that information up the stack. So far my attempts have been pretty unreadable and end up being just a cluster of text.
View 1 Replies
View Related
Nov 8, 2007
Hi,
I have a question about sql server trigger. For example, I have a trigger for table insert. The way it works is:
A: my program run the insert query, and wait, then the record is inserted, then the trigger is launched, after the trigger job done, my program then return,
or
B: my porgram run the insert query, and wait, then the record is inserted, then my porgram returns, then the trigger is launched. Basically, my program does not have to wait the trigger job done.
Which way is right? or neither one is right.
The problem we are facing right now is, we need to run a pretty big stored procedure and it takes a long time. I am thinking about move some of them to a trigger job, so our porgram don't have to wait for everything done.
Any inputs are welcome. Thanks.
View 2 Replies
View Related
Feb 13, 2008
What is the most reliable way to determine the last LSN of a database? I've looked in sys.database_files to no avail. I've also looked in msdb.dbo.backupset which is accurate but only based on backups already performed not the current state of the database.
-joe
View 5 Replies
View Related
Feb 21, 2001
Problem: I can add 4 items to a SQL 7.0 database but I need to redirect the user if all 4 items exist in the same Record elsewhere in the Database.
Clearly I need some kind of statement like "if category1 = var1 AND category2 = var 2 AND..." but don't know where to put it.
Code:
strSQL = "SELECT * FROM tblUserQuarter"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn,adOpenStatic , adLockOptimistic
'Insert choices from report.asp into tblUserQuarter
objRS.AddNew
objRS("cboFY") = Request.Form("cboFY")
objRS("Quarter") = Request.Form("Quarter")
objRS("ID") = Request.Form("ID")
objRS("Report") = Request.Form("Report")
objRS.Update
objRS.Close
Set objRS = Nothing
objConn.Close
set objConn = Nothing
View 1 Replies
View Related
Feb 25, 2015
I ran a query to see how big my database on my SQL Server is and do not understand the metrics. I want to see how much of my 10GB database is left.
database_namedatabase_sizeunallocated space
ANTHEMQ 6521.06 MB243.55 MB
reserveddata index_sizeunused
1332304 KB1328168 KB1800 KB 2336 KB
View 3 Replies
View Related
Mar 8, 2007
Simple question...
When I use the full version of SQL Management Studio, I can run a report to view the size. How can I do this with SQL Mgmnt Express?
View 1 Replies
View Related
Jun 15, 2006
Hi There
I am trying to establish the date a database was last used.
At first i checked out sp_helpfile and sysfiles to see if there was a date last modified, i also tried using xp_cmdshell to check the date on the actual .mdf or .ldf on the o/s but if the file has not grown the date will be the create date.
I need to establish the date a database was last used, either the last time someone logged into it or the last time any sort of command was run against the database, i cannot use sysprocesses as there are no connections to the database, so i need to determine the last time there actually were any processes run against this database.
And i need to use tsql, checking audit logs etc is not viable, can anyone help ?
Thanx
View 6 Replies
View Related
Dec 18, 2007
Does anybody know of a way to determine the last date/time a table has been accessed (query/update)? I've done enough research to know that this isn't easy. However, perhaps somebody has figured out a way through some of the stats that SQL Server keeps to determine the last access of a table. I have recently been put on a team that had no DBA and has a number of databases out there. They would like to determine which databases are inactive and get rid of them. I am a developer and haven't had much SQL Server Administration experience. Any info will help greatly! Thanks!
View 2 Replies
View Related
Sep 17, 2015
I am working on Sql Server 2012. and I have multiple databases there. Out of those, i want to move one of my databases to other SQL server 2012, For that i was trying to get approximate size of my database on current server. As i don't have the admin rights, so i can't get that. Can i get the approximate size by right clicking on database and by using the size property Under Database category to get the size idea?
View 4 Replies
View Related
Dec 31, 2007
I have a SQL database that gets populated by another program. Is there a way to determine when a new record is added to that database?
Thanks
View 4 Replies
View Related
May 14, 2015
Is it possible to determine the data flow within a database? e.g. I start by adding/inserting a record in MainTable1, then through a trigger SubTable1, SubTable2 have records inserted into, SubTable3 has a record updated into, then a StoredProcedure1 is run which updates first SubTable4, then a StoredProcedure2 is run which adds a record in SubTable5. So by simply adding a record in MainTable1, I affect 5 other tables.
Imagine a more complex process than this one now (which I'm currently facing and I want to win time and precision; I will still investigate it myself (if I will find an answer first - I will post it here)) Is there a way I could "extract" this flow by using T-SQL?
View 7 Replies
View Related
Feb 1, 2007
Hi All,I have to a few backups restored from a set of backup files. Thebackup files have been removed from the drive because of some storageconstrains...For some data comparison reasons, I need to figure out the actual dateof these backup files that is used to restore these databases. Isthere any system table I can query to figure the actual backup timesof these databases...Any help will be much appreciated.. Thanks in advance.- Aravin
View 1 Replies
View Related
Jun 14, 2007
My compatibility settings are fine. Anyone know how to to this?
View 4 Replies
View Related
Jul 31, 2015
I was asked to determine the last time 2 databases were accessed.
Are the .trc files an accurate way to determine the database access history?
View 5 Replies
View Related
May 28, 2015
I use a number of certificates on my database server. I'm trying to verify the correct certificate is being used on the correct database.
View 3 Replies
View Related
Nov 15, 2007
Hi there,
Does anyone know a way (a query perhaps?) to determine which logins have write permissions to a specific database on SQL Server 2005? Ive thought about joining sys.syslogins & sys.sysusers but looking at the columns, not sure which one would render me that info.
Any help is appreciated. Many thanks!
View 1 Replies
View Related
Jun 25, 2007
Hi, all experts here,
Thank you very much for your kind attention.
Just found that my tempdb is always full whenever I run a query against a large database. Could please any experts here give me any advices on what is tempdb database used for and how to determine what files can be deleted from it?
I am looking forward to hearing from you and thanks a lot in advance.
With best regards,
Yours sincerely,
View 3 Replies
View Related
Apr 22, 2015
I was wondering if there was another method to determine when a database was last backed up without using the backup history tables in msdb? whether using DBCC DBINFO, DBCC PAGE on a specific database page...etc.
Also, when restoring a database, is there a trace flag you can use to force restore details to be written to the error log?
View 4 Replies
View Related
Apr 7, 2006
Guys,1st of all.. sorry about my english ok? Im from Brazil...Im trying to get a RS connecting through 2 databases with the querybelow:SELECTscar..osbalcao.numeroos,ccell.dbo.atrib_os.osFROMccell.dbo.atrib_osJOIN scar.dbo.osbalcao on ccell.dbo.atrib_os.os =scar.dbo.osbalcao.numeroosWHERE scar.dbo.osbalcao.localprod = '257'AND scar.dbo.osbalcao.status in ('EM')On a SQL IDE i got a good RS, but, when i try to use that same query onDelphi + ZEOS, the SQL Server tells me that "The database namecomponent of the object qualifier must be the name of the currentdatabase".I really dont understand why. I can only tell that the error isreturned from SQL Server.Have anyone got the same trouble?[]'sTiago Gigli
View 1 Replies
View Related
Oct 6, 2015
How do I determine the read/write frequency on a database table? I am trying to do this on a 2012 and 2008 R2 servers.
View 2 Replies
View Related
Apr 15, 2008
Hi,
In a stored procedure is there a way of accessing a table presend in another database.
Please provide pointers on how i can do this.
Thanks,
Raj
View 4 Replies
View Related
Apr 15, 2008
Hi,
In a stored procedure is there a way of accessing a table present in another database.
Please provide pointers on how i can do this.
Thanks,
Raj
View 4 Replies
View Related
Oct 19, 1999
Hi,
Is there any command that gives the current database name.
Regards
Kishore
View 1 Replies
View Related
Aug 4, 2006
How to get current database name using stored procedure?
View 2 Replies
View Related
Mar 26, 2004
Hi,
I want to know a sql query that would show the current database name.
I have tried looking into the online books but couldn't find the right query.I hope u can do better.This is urgent.Thanxs. -- Vijay
View 2 Replies
View Related
Apr 10, 2002
Hi:
I need to know the current database name in executing a stored procedure,
which will trancatte the log of that database.
(in a dynamic multiple customerID oriented database environment,
ex. custID_101_db, custID_102_db, .....)
View 1 Replies
View Related
Apr 27, 2007
Hello,
When I open a query analyzer , of a particular database for example 'AB'
when writting a query how can I get the databasename that I am executing
i.e in the result I should get the DB name.
I was trying select name from master..sysdatabases . But it was returning all DB names.
Also while running a query , can I prompt for the DB name , so that that particular db name can be used to run that procedure or query.
Thanks in advance
View 2 Replies
View Related