Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SQL Function to get attributes from a connectionstring

Posted on 2007-03-30
5
198 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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