Solved

SQL Function to get attributes from a connectionstring

Posted on 2007-03-30
5
192 Views
Last Modified: 2010-08-05
Is there anyway that SQL Server 2005 can get information contained within the ConnectionString that was used to connect to the database for use in a trigger.

For example, if I have an application that uses the ConnectionString...
"server=(local); database=test; user=sa; pwd=testing; applicationname=myprogram"

how can I get out the applicationname attribute???
0
Comment
Question by:CAMSYSTEMS
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 18824131
what exactly are you trying to do here??

From what I can see so far, you can't do that
0
 
LVL 35

Expert Comment

by:YZlat
ID: 18824160
what exactly are you trying to do here??

From what I can see so far, you can't do that
0
 
LVL 10

Accepted Solution

by:
ksaul earned 500 total points
ID: 18824181
select app_name()  --application name
select host_name()
select current_user
0
 

Author Comment

by:CAMSYSTEMS
ID: 18824187
All I want to do is to be able to extract the applicationname attribute from the connectionstring that has been used to connect to the database from within SQL Server 2005???
0
 
LVL 10

Expert Comment

by:ksaul
ID: 18824242
I would create a SQL login specific to the application instead of using sa and assign it permissions required by the app.  Then you could know that the value returned by current_user is your application.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question