Monday, March 19, 2012
Active directory Update
I want to write a trigger that add a new computer account in my active directory when I do an Insert in my MSSQL table.
I know how to use SELECTstatements using LDAP but I want to do a INSERT statement. Is that even possible?
Can you write vb code directly in SP i mssql 2000?
What I think I have to do is to have a vbscript that does the adding then call the script using exetended SP cmd execute passing the name to the script.
If someone has a another solutions please let me know!
Regards..I've written simple ActiveX out-of-process OLE servers using VB. This is not hard to do. But I think you're going from the wrong direction. I'd rather add a computer account using LDAP from my VB code and then fire a stored procedure to update whatever you want to update. The other way around is possible too, but it doesn't make it easier, not does it make it right either.
Sunday, March 11, 2012
Activating Nested Trigger with DTC
I built a trigger that activates another trigger (Nested Trigger).
The First trigger which is located on table A inserts data into table B and in return the second trigger which is located on table B updates data in table A.
The whole process works fine when both tables are on the same server but when the tables are on different servers i get the following error:
"[Microsoft][ODBC SQL Server Driver][SQL Server]The operation could not be performed because the OLE DB Provider 'SQLOLEDB' was unable to begin a distributed transaction.
[Microsoft][ODBC SQL Server Driver][SQL Server][OLE/DB provider returned message: New transaction cannot enlist in the specified transaction coordinator.]"
Any ideas?Under the server properties goto connection tab and check option for 'Enforce Distributed Transactions (DTS)", make sure to uncheck the option.|||I tried it and it didn't work - I even got the same error message.
Any more ideas?|||Make sure to check whether MSDTC is running on all involved servers.|||I checked the servers and MS-DTC runs on both of them.
Could it be connected to the settings of MS-DTC? something in the settings of MS-DTC that doesn't allow a trigger to activate another trigger?|||It always helps try to refresh the services and MSDTC to get it worked.|||no, sorry, still doesn't help
I stopped and played MS-DTC on both servers + refreshed services but still no good|||I'm out of ideas now in this regard, BTW what is the SP Level?
You may refer the case of MS Support for a fix or search under KB for any fix.|||Both servers are running MS-SQL 2K, SP3
Thanks for your time,
I'll update on any solution, if will be founded..|||For information refer thru:
run SP_SERVEROPTION from QA and deliver the result.
Try to implement :
SET ANSI_DEFAULTS ON
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
SET XACT_ABORT ON
.... before the transaction begins...|||all parameters were already set as mentioned.
sp_serveroption enables changing several server parameters, which one did u mean?
Tuesday, March 6, 2012
Acquire NTLM User ID within Trigger or Sproc?
workstation. I need to do it from within a Trigger.
How?If you are using Windows Authentication then see function suser_sname in BOL
.
AMB
"Carl Perkins" wrote:
> I need to acquire the userid that the person signed on at their Windows
> workstation. I need to do it from within a Trigger.
> How?|||That does not return the login user that logged into NT - it returns the use
r
that is setup to connect to sql server from the connection string.
When I execute it in Query Analyzer it certainly does work but I need it
from within a trigger and that is a bit different.
Thanks,
Carl
"Alejandro Mesa" wrote:
> If you are using Windows Authentication then see function suser_sname in B
OL.
>
> AMB
> "Carl Perkins" wrote:
>|||If the setup runs under the loggedon account thatll work for you like
Alejandro described. if you are using SQL Server Auth. you have to go for
tha:
There is a bad hack for that if you have control over the connection string:
912257c40e693afe" target="_blank">http://groups.google.de/group/micro...12257c40e693afe
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Carl Perkins" <CarlPerkins@.discussions.microsoft.com> schrieb im
Newsbeitrag news:A899FA96-996A-44D0-ADB5-1AD165506093@.microsoft.com...
> That does not return the login user that logged into NT - it returns the
> user
> that is setup to connect to sql server from the connection string.
> When I execute it in Query Analyzer it certainly does work but I need it
> from within a trigger and that is a bit different.
> Thanks,
> Carl
> "Alejandro Mesa" wrote:
>|||suser_sname(), but that only works of course if the user logs in to SQL
Server using Windows Authentication, not if you use SQL Server
Authentication.
Jacco Schalkwijk
SQL Server MVP
"Carl Perkins" <CarlPerkins@.discussions.microsoft.com> wrote in message
news:ED6D28FE-6F36-401A-8DF6-12480EB62F51@.microsoft.com...
>I need to acquire the userid that the person signed on at their Windows
> workstation. I need to do it from within a Trigger.
> How?
Friday, February 24, 2012
Accessing which data caused a trigger to fire
I need to make a trigger which fires when after an UPDATE is done on
table A in database X. The trigger must perform a statement which
copies some of the data from the update to table B in database Y on
the same server.
My question is: Can I access the data which caused the trigger to fire
or just get an indication of which entry in table A had been updated?
Best Regards
Jens Christian Andersen.There are 2 pseudo-tables available in trigger code: "deleted" and
"inserted". When a trigger is fired by an UPDATE statement, the "deleted"
table contains images of the rows before the update and the "inserted" table
contain the row images after the update. In your update trigger code, you
can do something like:
INSERT INTO Y.dbo.B (Column1, Column2)
SELECT Column1, Column2
FROM inserted
In a trigger fired by a DELETE statement, the "deleted" table contains the
rows just deleted and the "inserted" table is empty. Similarly, when a
trigger is fired by an INSERT statement, the "inserted" table contains the
rows just inserted and the "deleted" table in empty. See the Books Online
for details.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"jcandersen" <jca@.dse.dkwrote in message
news:1172660503.230464.291380@.8g2000cwh.googlegrou ps.com...
Quote:
Originally Posted by
Hi.
>
I need to make a trigger which fires when after an UPDATE is done on
table A in database X. The trigger must perform a statement which
copies some of the data from the update to table B in database Y on
the same server.
My question is: Can I access the data which caused the trigger to fire
or just get an indication of which entry in table A had been updated?
>
Best Regards
Jens Christian Andersen.
>
wrote:
Quote:
Originally Posted by
There are 2 pseudo-tables available in trigger code: "deleted" and
"inserted". When a trigger is fired by an UPDATE statement, the "deleted"
table contains images of the rows before the update and the "inserted" table
contain the row images after the update. In your update trigger code, you
can do something like:
>
INSERT INTO Y.dbo.B (Column1, Column2)
SELECT Column1, Column2
FROM inserted
>
In a trigger fired by a DELETE statement, the "deleted" table contains the
rows just deleted and the "inserted" table is empty. Similarly, when a
trigger is fired by an INSERT statement, the "inserted" table contains the
rows just inserted and the "deleted" table in empty. See the Books Online
for details.
>
--
Hope this helps.
>
Dan Guzman
SQL Server MVP
>
"jcandersen" <j...@.dse.dkwrote in message
>
news:1172660503.230464.291380@.8g2000cwh.googlegrou ps.com...
>
Quote:
Originally Posted by
Hi.
>
Quote:
Originally Posted by
I need to make a trigger which fires when after an UPDATE is done on
table A in database X. The trigger must perform a statement which
copies some of the data from the update to table B in database Y on
the same server.
My question is: Can I access the data which caused the trigger to fire
or just get an indication of which entry in table A had been updated?
>
Quote:
Originally Posted by
Best Regards
Jens Christian Andersen.
Thanks, this is just what I needed.