Hi,
I'm trying to get the information about the user who modified the record in the table. I'm able to capture the datetime of modification through trigger.
CREATE TRIGGER [upd_dtm] ON dbo.Sample
FOR INSERT, UPDATE
AS
BEGIN
UPDATE Sample SET update_dtm = (SELECT GETDATE())
WHERE Sample.ID IN (SELECT ID FROM inserted)
END
I'm stuck, how to get the User who modified it?
Any help is greately appreciated!
I need to write an auditing trigger that will capture time of an insert and user that is making the insert. The time part i think i can use getdate(), but how can I find out which user is making the insert? Any help appreciated.
Im trying to add a new rcord to my db on a button click usign the following code
'data adapter Dim dAdapt1 As New SqlClient.SqlDataAdapter 'create a command object Dim objCommand As New SqlClient.SqlCommand 'command builder Dim builderT As SqlClient.SqlCommandBuilder 'connection string Dim cnStr As String = "Data Source=ELEARN-FRM-BETA;Initial Catalog=StudentPlayGround;Integrated Security=True" 'dataset Dim dsT As DataSet Private Sub connect() 'connection objCommand.Connection = New SqlClient.SqlConnection(cnStr) 'associating the builder with the data adapter builderT = New SqlClient.SqlCommandBuilder(dAdapt1) 'opening the connection objCommand.Connection.Open() 'query string Dim query As String = "SELECT * from StudentPlayground..Employees" 'setting the select command dAdapt1.SelectCommand = New SqlClient.SqlCommand(query, objCommand.Connection) 'dataset dsT = New DataSet("Trainee Listings") dAdapt1.Fill(dsT, "Employees") End Sub Private Sub BindData() connect() DataBind() End Sub Protected Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click Dim empID As Integer = CType(FindControl("TextBox8"), TextBox).Text BindData() Dim firstName As String = CType(FindControl("TextBox1"), TextBox).Text BindData() Dim lastName As String = CType(FindControl("TextBox2"), TextBox).Text BindData() Dim location As String = CType(FindControl("TextBox3"), TextBox).Text BindData() Dim termDate As Date = CType(FindControl("TextBox4"), TextBox).Text BindData() Dim hireDate As Date = CType(FindControl("TextBox7"), TextBox).Text BindData() Dim dept As String = CType(FindControl("TextBox5"), TextBox).Text BindData() Dim super As String = CType(FindControl("TextBox6"), TextBox).Text BindData() Dim newRow As DataRow = dsT.Tables("Employees").NewRow newRow.BeginEdit() newRow.Item(0) = empID newRow.Item(1) = firstName newRow.Item(2) = lastName newRow.Item(3) = location newRow.Item(4) = hireDate newRow.Item(5) = termDate newRow.Item(6) = dept newRow.Item(7) = super newRow.EndEdit()
'do the update Dim insertStr As String = "INSERT INTO Employees" + _ "(EmployeeID,FirstName,LatName,Location,HireDate,TerminationDate,Supervisor)" + _ "VALUES (empID,firstName,lastName,location,hireDate,termDate,dept,super)" Dim insertCmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(insertStr, objCommand.Connection) dAdapt1.InsertCommand() = insertCmd
dAdapt1.Update(dsT, "Employees") 'Dim insertCmd As new SqlClient.SqlCommand = (builderT.GetInsertCommand()).ToString()) 'dAdapt1.InsertCommand = New SqlClient.SqlCommand(insertCmd.ToString(), objCommand.Connection) BindData() objCommand.Connection.Close() objCommand.Connection.Dispose() End Sub
im not sure wats going wrong because the record is not being added. Please help!!
Dear group,I am a DB-Administrator for a Company that creates and maintains asoftware solution based on SQL-Server and Crystal-Reports.The Crystal-Reports part uses the following method to present data.First a specific user (database authentification) is created with afixed password. Then Crystal Reports uses thisuser/password-information to login to the database and present or printthe data.I recently received a database from a customer of ours and i restoredit on my machine. It worked perfectly except that the Crystal Reportspart did not function at all (showing only blank reports).After dropping the specific user and creating the fixed password thething worked.So my question: does restoring a SQL-Server database on a differentmachine alter or eliminate login and user information ?Any reply will be highly appreciated.Greetings from ViennaUli
== I asked this question directly to Remus and wanted to share the response to all of those people using this forum == We recently moved our database server from SQL Server 2000 to SQL Server 2005. All applications on our intranet development server stay the same [VS.NET 2003], but recently resources in our Dev DB server ran out of space. While doing a thorough investigation, I noticed ERRORLOG file was occupying about 35 Gig of HDD space. I immediately checked SQL Server error log and noticed an entry which says €“ =========================================================================================== Date 7/7/2006 4:45:37 PM Log SQL Server (Current - 7/7/2006 4:45:00 PM)
Source spid77s
Message The activated proc [dbo].[SqlQueryNotificationStoredProcedure-5eaf8465-d0cb-4be7-93b6-44bb979dd41c] running on queue BW_Content.dbo.SqlQueryNotificationService-5eaf8465-d0cb-4be7-93b6-44bb979dd41c output the following: 'Could not obtain information about Windows NT group/user 'BWCINCHoffK', error code 0x534.' ===========================================================================================
What is this SqlQueryNotificationService in my database? Is it a SQL Server 2005 thing? Why the same kind of stored procedure does not exist in other databases, but BW_Content? This error is getting repeated most probably every second and is filling up our server. I believe our corporate IT people removed our domain accounts from BWCINC domain to BWCORP domain and probably some application which is using BWCINCHoffK credential is getting errored out. I tried to locate this application and was not successful. Is there anyway that I can stop this ERRORLOG from growing? How can I delete these log entries so that I can make space on our Hard Drive? Is there an easy way in SQL Server 2005 to locate which application is creating this error? Response from Remus: The 'SqlQueryNotificationService-...' is the service created by SqlDependency when you call SqlDependency.Start (). The problem you describe appears because the 'dbo' user of the database is mapped to the login that originally created this database. The SqlDependency created queue has an EXECUTE AS OWNER clause, owner is 'dbo' and therefore this is equivalent to an EXECUTE AS USER = 'dbo'. The error you see is reported by the domain controller when asked to give information about the original account 'dbo' mapps to (that is, BWCINCHoffK'): Error code: (Win32) 0x534 (1332) - No mapping between account names and security IDs was done.
To solve the issue, change 'dbo' to match a correct login, using either sp_changedbowner or ALTER AUTHORIZATION ON DATABASE::[dbname] TO [somavalidlogin] To find the databases that have this problem, run this query:
select name, suser_sname(owner_sid) from sys.databases The databses that have the problem will show NULL on the second column. A similar problem is described here: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=65711&SiteID=1
To remove the entries, use sp_cycle_errorlog to force a new errorlog file, then delete the huge log file. ---------------------------------------
I executed ALTER AUTHORIZATION ON DATABASE::[BW_Content] TO [sa];
I got this error in SQL Error Log once and the growth of ERRORLOG was stopped. =============================================================== Date 7/10/2006 1:16:55 PM Log SQL Server (Current - 7/10/2006 1:17:00 PM) Source spid20s
Message
The query notification dialog on conversation handle '{6BDE95F7-0EFB-DA11-9064-000C2921B41B}.' closed due to the following error: '<?xml version="1.0"?><Error xmlns="http://schemas.microsoft.com/SQL/ServiceBroker/Error"><Code>-8490</Code><Description>Cannot find the remote service 'SqlQueryNotificationService-c15bb868-ed56-47d2-bf91-ce18b320989a' because it does not exist.</Description></Error>'. ===============================================================
hye everyone, when i browse my web application the eror as below display.. what should i do.. any suggestion or tips...
"Cannot start your application. The workgroup information file is missing or opened exclusively by another user. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Cannot start your application. The workgroup information file is missing or opened exclusively by another user. "
Hi all, I'm kinda new at programming, and am currently attempting to create a web application. I have an error when I try to insert information into a sql server database, and can't find how to fix it no matter how hard I try. The error I get is: Cannot start your application. The workgroup information file is missing or opened exclusively by another user. I have it so a user is logged in and is shown a form to fill out, then submits it (which creates an insert statement and sends it to the database). My connection string is as follows: CnnString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "data source=serverdestination;" + "User id=user;" + "Password=pass;"; If you need any more information, just let me know. Any help would be greatly appreciated!
I have some troubles with IBM WebSphere Application Server using MS SQL Server 2005 JDBC Driver. I always get the error e.g. java.lang.SecurityException: class "com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData"'s signer information does not match signer information of other classes in the same package
I found this Feedback but it seems to be closed.
A temporary solution for me was to delete the meta-inf directory of the JAR-File, but that can't be the solution.
This is my first time to deploy an asp.net2 web site. Everything is working fine on my local computer but when i published the web site on a remote computer i get the error "Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed" (only in pages that try to access the database) Help pleaseee
When I am in Visual Studio 2005, and I try to add an SQL database, I get the following error "generating user instances in sql server is disabled. use sp_configure user instances enabled to generate user instances." I am currently using SQL server 2005 Express. What do I need to do, to create an SQL database? Thanks in advance.
i'm using the Enterpirse library logger to write logs into a database. When choosing connection string i choose the database i want in the "connection properties" dialog box and push 'Test connection' button. everything goes well.
then i open the SQL Server Management studio express and connect to the databse to check some things, from that point on , when i push the 'Test Connection' button in the Enterprise library i get the error:
"cannot open user default database. Login failed. login failed for user My'server/MyuserName'"
even when i close the sql server manager , it is still stuck - the connection test doesn't work anymore.... it only work when i restart the computer.
I have a job that runs each night that deletes all records from a table that are older than two weeks old. Is there some way I can view how many records were deleted from the table each night. Is it written to a log somewhere? Thanks in advance!
Hi all, This is my first thread here. I got an information about SET NO_BROWSETABLE ON/OFF in your forum.. The replier told that this is an undocumented option. My question is how you guys find information on such undocumented things....
I am trying to get job information and have a query set up. However, I would also like to get the owner information. However, the job only stores the sid of the owner. Does anybody know how I could change this query to get the owner name instead of sid? Don't want to use the sp_help_job command.
SELECT @@SERVERNAME AS Server, msdb.dbo.sysjobs.job_id, msdb.dbo.sysjobs.name, msdb.dbo.sysjobs.enabled AS Job_Enabled, msdb.dbo.sysjobs.description, msdb.dbo.sysjobs.notify_level_eventlog, msdb.dbo.sysjobs.notify_level_email, msdb.dbo.sysjobs.notify_level_netsend, msdb.dbo.sysjobs.notify_level_page, msdb.dbo.sysjobs.notify_email_operator_id, msdb.dbo.sysjobs.date_created, msdb.dbo.syscategories.name AS Category_Name, msdb.dbo.sysjobschedules.next_run_date, msdb.dbo.sysjobschedules.next_run_time, msdb.dbo.sysjobservers.last_run_outcome, msdb.dbo.sysjobservers.last_outcome_message, msdb.dbo.sysjobservers.last_run_date, msdb.dbo.sysjobservers.last_run_time, msdb.dbo.sysjobservers.last_run_duration, msdb.dbo.sysoperators.name AS Notify_Operator, msdb.dbo.sysoperators.email_address, msdb.dbo.sysjobs.date_modified, GETDATE() AS Package_run_date FROM msdb.dbo.sysjobs INNER JOIN msdb.dbo.syscategories ON msdb.dbo.sysjobs.category_id = msdb.dbo.syscategories.category_id LEFT OUTER JOIN msdb.dbo.sysoperators ON msdb.dbo.sysjobs.notify_email_operator_id = msdb.dbo.sysoperators.id LEFT OUTER JOIN msdb.dbo.sysjobservers ON msdb.dbo.sysjobs.job_id = msdb.dbo.sysjobservers.job_id LEFT OUTER JOIN msdb.dbo.sysjobschedules ON msdb.dbo.sysjobschedules.job_id = msdb.dbo.sysjobs.job_id
I'm looking for books or information on command line configuration of settings for things like activating Remote Connections under the Service Area Configuration and setting a port for that connection.
What books would be good to get or where can I download papers on this?
Hi!This is a very simple question and I'm sure you guys will help me a lot.I'm using Visual Basic 2005 for programming. I have one table on my MS SQL 2005 database that has an int column with a counter that needs to be incremented when a user registers.So when reading the value I use a simple SQL query like this: SELECT counter FROM companies WHERE company=0 then I store the value in a local int variable and then I increment it. Then I update the incremented value. UPDATE companies ... I need every single customer to have an individual value. My question is how can I prevent an error, data corruption or whatever if two or more users want to register at the same time? I've been reading about lock update but I'm not sure how to implement it on Visual Basic 2005 and I don't want to store scripts on SQL Server. I'll appreciate your comments and help on this situation.
Hi, I have a problem here in my SQL Server Database. I want to find which trigger is working backend affecting my table input. Since the original author of this trigger was somebody else, I am not able to find the trigger information A simple line of syntax would be great. Thanks in advance sandeep
I am doing an audit of user information in our database and was wondering if there is a way for me to see the last time a user logged into the database. I am using a SQL Server 7.0 box. Any Information would be greatly appreciated. Thanks!
Hi, In my database one user is aliased like a guest. When i run sp_helpuser on the particular database it is giving following result.
username login name database -------- ----------- -------- aaaa NULL XYZ
NOrmally we fill see like this for GUEST User. Now i want to drop this user 'aaaa' only. IF i use sp_dropuser 'null' i think guest user will also drop from XYZ database. So can anyone pls suggest me how to drop this user. I have to add a same user with full permissions. i know in 65 we have sysalternates table gives all alias information. Is there any table gives the same information in sql7. Pls suggest me regarding this.
I administering SQL server and one of or Db (size ~7 Gb) have a table with size 396 MB and 25 indexes created on this one. We working with this DB using Siebel Call center. I have met a very strange situation: when I tried to get some data (using Siebel) my request take ~5 min. I run Profiler and catched this T-SQL statement which Siebel send to SQL server. After that, I run this T-SQL query using Query Analyser and found that Query Optimiser used wrong index. (clustered index) and try to compare every 470436 rows from the tables. This is the statement. @P1, @P2, and @P3 just variable which siebel transfer to SQL server.
SELECT ........ FROM dbo.S_EVT_ACT T1 LEFT OUTER JOIN dbo.S_CONTACT T2 ON T1.TARGET_PER_ID = T2.ROW_ID WHERE ((T1.APPT_REPT_FLG != @P1 OR T1.APPT_REPT_FLG IS NULL) AND (T1.TEMPLATE_FLG != @P2 OR T1.TEMPLATE_FLG IS NULL)) AND (T1.SRA_DEFECT_ID = @P3)
But I found the very strange situation - when I manualy put the value '1-FRK' instead of @P3 - Query Optimizer used RIGHT index and I had a very good performance.
And addition when I tried to run the first Query on the same table but with the only 1000 rows the Query Optimiser choose right index.
Wat's on, wat happend with My Query Optimizer? Wy his decision so different from time to time?
Thank's a lot for any information about how to make Optimiser obedient.
Is there any way to use Transact SQL to get the detailed information on a process like you get when you use the GUI interface under the Enterprise manager for server activity.
Is there a way to view the triggers on a table using query analyzer?
I have a developer that wants to see this information without having to right click every table in the database and viewing the triggers through enterprise manager.
I just started at a new company. The security stinks, everyone logs into the servers as sa (including many applications). I am taking steps to tighten security and restrict access to the sa login. I would like to capture some additional information at logon as an interim measure.
Can anyone assist me in automatically recording the following: Host Name / IP Address Login time
I realize I could periodically run an sp_who2 and capture the results - I also realize that if I turn on auditing, the logon will be written to the SQL Srvr LOG - I'm looking for an elegant / low impact way to capture the logon and host information.
I'm trying to access data from one table by matching ids pulled from another table. I can't quite get the syntax though if anybody could help I would appericate it.
Here is where I'm at
select * from table1 where variable 1 = (select distinct(variable 2) from table 2 where variable 3 = variable 4)
Hi, Does anyone has a script to find out what are the scheduled timining for all sql server agent jobs. I'm trying to get the result with the following query, it doen't seem working..
select sj.name, case sjs.freq_type when '1 ' then 'Once' when '4' then 'Daily' when '8' then 'Weekly' when '16' then 'Monthly' when '32' then 'Monthly relative' when '64' then 'When SQL Server Agent starts' end as Frequency, case sjs.freq_interval when '1' then 'Sunday' when '2' then 'Monday' when '4' then 'Tuesday' when '8' then 'Wednesday' when '16' then 'Thursday' when '32' then 'Friday' when '64' then 'Saturday' end as DAY from sysjobs sj, sysjobschedules sjs where sj.job_id = sjs.job_id