Is there any way to remove logins from the server and all related databases
in including all roles in the databases?
Thanks,
David
======================================
David McCarter
www.vsdntips.com
VSDN Tips & Tricks .NET Coding Standards available at:
www.cafepress.com/vsdntips.20412485Hi,
Execute
sp_helplogins <loginname>
This will list out all the roles and users associated for the login. Then
you could use the appropriate system procedures to drop the users,login and
roles.
Take a look into books online for below system procs
sp_dropuser
sp_droprole
sp_droplogin
Thanks
Hari
SQL Server MVP
"dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
news:0B172044-F55A-47D2-B812-ED45DED0BB21@.microsoft.com...
> Is there any way to remove logins from the server and all related
> databases
> in including all roles in the databases?
> Thanks,
> David
> ======================================
> David McCarter
> www.vsdntips.com
> VSDN Tips & Tricks .NET Coding Standards available at:
> www.cafepress.com/vsdntips.20412485|||Thanks. I was hoping for one command to do it all ;-)
"Hari Prasad" wrote:
> Hi,
> Execute
> sp_helplogins <loginname>
> This will list out all the roles and users associated for the login. Then
> you could use the appropriate system procedures to drop the users,login an
d
> roles.
> Take a look into books online for below system procs
> sp_dropuser
> sp_droprole
> sp_droplogin
> Thanks
> Hari
> SQL Server MVP
> "dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
> news:0B172044-F55A-47D2-B812-ED45DED0BB21@.microsoft.com...
>
>|||Hi,
You could do every thing using SQL Enterprise manager / SQL Server
Management studio. But internally it does all the below commands.
Thanks
Hari
SQL Server MVP
"dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
news:6308E118-80EA-4D9D-8621-578F9E514209@.microsoft.com...[vbcol=seagreen]
> Thanks. I was hoping for one command to do it all ;-)
> "Hari Prasad" wrote:
>
Showing posts with label including. Show all posts
Showing posts with label including. Show all posts
Friday, March 9, 2012
Removing Logins from Server and Databases
Is there any way to remove logins from the server and all related databases
in including all roles in the databases?
Thanks,
David
====================================== David McCarter
www.vsdntips.com
VSDN Tips & Tricks .NET Coding Standards available at:
www.cafepress.com/vsdntips.20412485Hi,
Execute
sp_helplogins <loginname>
This will list out all the roles and users associated for the login. Then
you could use the appropriate system procedures to drop the users,login and
roles.
Take a look into books online for below system procs
sp_dropuser
sp_droprole
sp_droplogin
Thanks
Hari
SQL Server MVP
"dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
news:0B172044-F55A-47D2-B812-ED45DED0BB21@.microsoft.com...
> Is there any way to remove logins from the server and all related
> databases
> in including all roles in the databases?
> Thanks,
> David
> ======================================> David McCarter
> www.vsdntips.com
> VSDN Tips & Tricks .NET Coding Standards available at:
> www.cafepress.com/vsdntips.20412485|||Thanks. I was hoping for one command to do it all ;-)
"Hari Prasad" wrote:
> Hi,
> Execute
> sp_helplogins <loginname>
> This will list out all the roles and users associated for the login. Then
> you could use the appropriate system procedures to drop the users,login and
> roles.
> Take a look into books online for below system procs
> sp_dropuser
> sp_droprole
> sp_droplogin
> Thanks
> Hari
> SQL Server MVP
> "dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
> news:0B172044-F55A-47D2-B812-ED45DED0BB21@.microsoft.com...
> > Is there any way to remove logins from the server and all related
> > databases
> > in including all roles in the databases?
> >
> > Thanks,
> > David
> >
> > ======================================> > David McCarter
> > www.vsdntips.com
> > VSDN Tips & Tricks .NET Coding Standards available at:
> > www.cafepress.com/vsdntips.20412485
>
>|||Hi,
You could do every thing using SQL Enterprise manager / SQL Server
Management studio. But internally it does all the below commands.
Thanks
Hari
SQL Server MVP
"dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
news:6308E118-80EA-4D9D-8621-578F9E514209@.microsoft.com...
> Thanks. I was hoping for one command to do it all ;-)
> "Hari Prasad" wrote:
>> Hi,
>> Execute
>> sp_helplogins <loginname>
>> This will list out all the roles and users associated for the login. Then
>> you could use the appropriate system procedures to drop the users,login
>> and
>> roles.
>> Take a look into books online for below system procs
>> sp_dropuser
>> sp_droprole
>> sp_droplogin
>> Thanks
>> Hari
>> SQL Server MVP
>> "dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
>> news:0B172044-F55A-47D2-B812-ED45DED0BB21@.microsoft.com...
>> > Is there any way to remove logins from the server and all related
>> > databases
>> > in including all roles in the databases?
>> >
>> > Thanks,
>> > David
>> >
>> > ======================================>> > David McCarter
>> > www.vsdntips.com
>> > VSDN Tips & Tricks .NET Coding Standards available at:
>> > www.cafepress.com/vsdntips.20412485
>>
in including all roles in the databases?
Thanks,
David
====================================== David McCarter
www.vsdntips.com
VSDN Tips & Tricks .NET Coding Standards available at:
www.cafepress.com/vsdntips.20412485Hi,
Execute
sp_helplogins <loginname>
This will list out all the roles and users associated for the login. Then
you could use the appropriate system procedures to drop the users,login and
roles.
Take a look into books online for below system procs
sp_dropuser
sp_droprole
sp_droplogin
Thanks
Hari
SQL Server MVP
"dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
news:0B172044-F55A-47D2-B812-ED45DED0BB21@.microsoft.com...
> Is there any way to remove logins from the server and all related
> databases
> in including all roles in the databases?
> Thanks,
> David
> ======================================> David McCarter
> www.vsdntips.com
> VSDN Tips & Tricks .NET Coding Standards available at:
> www.cafepress.com/vsdntips.20412485|||Thanks. I was hoping for one command to do it all ;-)
"Hari Prasad" wrote:
> Hi,
> Execute
> sp_helplogins <loginname>
> This will list out all the roles and users associated for the login. Then
> you could use the appropriate system procedures to drop the users,login and
> roles.
> Take a look into books online for below system procs
> sp_dropuser
> sp_droprole
> sp_droplogin
> Thanks
> Hari
> SQL Server MVP
> "dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
> news:0B172044-F55A-47D2-B812-ED45DED0BB21@.microsoft.com...
> > Is there any way to remove logins from the server and all related
> > databases
> > in including all roles in the databases?
> >
> > Thanks,
> > David
> >
> > ======================================> > David McCarter
> > www.vsdntips.com
> > VSDN Tips & Tricks .NET Coding Standards available at:
> > www.cafepress.com/vsdntips.20412485
>
>|||Hi,
You could do every thing using SQL Enterprise manager / SQL Server
Management studio. But internally it does all the below commands.
Thanks
Hari
SQL Server MVP
"dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
news:6308E118-80EA-4D9D-8621-578F9E514209@.microsoft.com...
> Thanks. I was hoping for one command to do it all ;-)
> "Hari Prasad" wrote:
>> Hi,
>> Execute
>> sp_helplogins <loginname>
>> This will list out all the roles and users associated for the login. Then
>> you could use the appropriate system procedures to drop the users,login
>> and
>> roles.
>> Take a look into books online for below system procs
>> sp_dropuser
>> sp_droprole
>> sp_droplogin
>> Thanks
>> Hari
>> SQL Server MVP
>> "dotNetDave" <dotNetDave@.discussions.microsoft.com> wrote in message
>> news:0B172044-F55A-47D2-B812-ED45DED0BB21@.microsoft.com...
>> > Is there any way to remove logins from the server and all related
>> > databases
>> > in including all roles in the databases?
>> >
>> > Thanks,
>> > David
>> >
>> > ======================================>> > David McCarter
>> > www.vsdntips.com
>> > VSDN Tips & Tricks .NET Coding Standards available at:
>> > www.cafepress.com/vsdntips.20412485
>>
Monday, February 20, 2012
Removing all between [and ]
Hi All,
Does anyone know of a way of removing everything between, and including two
given characters in string using TSQL.
e.g. If my result set returns 'Sample Text [12345]' where 12345 is unknown
text, how can I make this 'Sample Text'
I know this is something perhaps best done at application level, but in this
case I need to do this in the data, before it reaches the app.
Thanks!
Simon.lookup charindex() and substring() in bol
Simon Harris wrote:
> Hi All,
> Does anyone know of a way of removing everything between, and including tw
o
> given characters in string using TSQL.
> e.g. If my result set returns 'Sample Text [12345]' where 12345 is unknown
> text, how can I make this 'Sample Text'
> I know this is something perhaps best done at application level, but in th
is
> case I need to do this in the data, before it reaches the app.
> Thanks!
> Simon.
>|||If you are using SQL Server 2005, you could do this with
a .NET UDF and Regular Expressions:
http://www.eggheadcafe.com/articles...5_clr_regex.asp
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp
"Simon Harris" <too-much-spam@.makes-you-fat.com> wrote in message
news:%23HkAACQAGHA.312@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> Does anyone know of a way of removing everything between, and including
> two given characters in string using TSQL.
> e.g. If my result set returns 'Sample Text [12345]' where 12345 is unknown
> text, how can I make this 'Sample Text'
> I know this is something perhaps best done at application level, but in
> this case I need to do this in the data, before it reaches the app.
> Thanks!
> Simon.
>|||hi Simon,
Try this out
select substring('Sample Text[12345]',1,charindex('[','Sample
Text[12345]',1)-1) as Result
"Simon Harris" wrote:
> Hi All,
> Does anyone know of a way of removing everything between, and including tw
o
> given characters in string using TSQL.
> e.g. If my result set returns 'Sample Text [12345]' where 12345 is unknown
> text, how can I make this 'Sample Text'
> I know this is something perhaps best done at application level, but in th
is
> case I need to do this in the data, before it reaches the app.
> Thanks!
> Simon.
>
>|||Hi Simon ,
What Manish asked will work but fails for data without any '['
Try This
Select Substring('sample text [12345]', 1, Case When
CharIndex('[','sample text [12345]') > 0 Then CharIndex('[','sample
text [12345]') - 1 Else Len('sample text [12345]') End )
With Warm regards
Jatinder Singh|||Jatinder, your timing could not have been better...I've been trying to work
out what was wrong!! :)
Thanks!!...and to the other guys that replied.
Simon.
"jsfromynr" <jatinder.singh@.clovertechnologies.com> wrote in message
news:1134646198.240311.227770@.g44g2000cwa.googlegroups.com...
> Hi Simon ,
> What Manish asked will work but fails for data without any '['
> Try This
> Select Substring('sample text [12345]', 1, Case When
> CharIndex('[','sample text [12345]') > 0 Then CharIndex('[','sample
> text [12345]') - 1 Else Len('sample text [12345]') End )
> With Warm regards
> Jatinder Singh
>
Does anyone know of a way of removing everything between, and including two
given characters in string using TSQL.
e.g. If my result set returns 'Sample Text [12345]' where 12345 is unknown
text, how can I make this 'Sample Text'
I know this is something perhaps best done at application level, but in this
case I need to do this in the data, before it reaches the app.
Thanks!
Simon.lookup charindex() and substring() in bol
Simon Harris wrote:
> Hi All,
> Does anyone know of a way of removing everything between, and including tw
o
> given characters in string using TSQL.
> e.g. If my result set returns 'Sample Text [12345]' where 12345 is unknown
> text, how can I make this 'Sample Text'
> I know this is something perhaps best done at application level, but in th
is
> case I need to do this in the data, before it reaches the app.
> Thanks!
> Simon.
>|||If you are using SQL Server 2005, you could do this with
a .NET UDF and Regular Expressions:
http://www.eggheadcafe.com/articles...5_clr_regex.asp
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp
"Simon Harris" <too-much-spam@.makes-you-fat.com> wrote in message
news:%23HkAACQAGHA.312@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> Does anyone know of a way of removing everything between, and including
> two given characters in string using TSQL.
> e.g. If my result set returns 'Sample Text [12345]' where 12345 is unknown
> text, how can I make this 'Sample Text'
> I know this is something perhaps best done at application level, but in
> this case I need to do this in the data, before it reaches the app.
> Thanks!
> Simon.
>|||hi Simon,
Try this out
select substring('Sample Text[12345]',1,charindex('[','Sample
Text[12345]',1)-1) as Result
"Simon Harris" wrote:
> Hi All,
> Does anyone know of a way of removing everything between, and including tw
o
> given characters in string using TSQL.
> e.g. If my result set returns 'Sample Text [12345]' where 12345 is unknown
> text, how can I make this 'Sample Text'
> I know this is something perhaps best done at application level, but in th
is
> case I need to do this in the data, before it reaches the app.
> Thanks!
> Simon.
>
>|||Hi Simon ,
What Manish asked will work but fails for data without any '['
Try This
Select Substring('sample text [12345]', 1, Case When
CharIndex('[','sample text [12345]') > 0 Then CharIndex('[','sample
text [12345]') - 1 Else Len('sample text [12345]') End )
With Warm regards
Jatinder Singh|||Jatinder, your timing could not have been better...I've been trying to work
out what was wrong!! :)
Thanks!!...and to the other guys that replied.
Simon.
"jsfromynr" <jatinder.singh@.clovertechnologies.com> wrote in message
news:1134646198.240311.227770@.g44g2000cwa.googlegroups.com...
> Hi Simon ,
> What Manish asked will work but fails for data without any '['
> Try This
> Select Substring('sample text [12345]', 1, Case When
> CharIndex('[','sample text [12345]') > 0 Then CharIndex('[','sample
> text [12345]') - 1 Else Len('sample text [12345]') End )
> With Warm regards
> Jatinder Singh
>
Subscribe to:
Posts (Atom)