Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Friday, March 23, 2012

Listing procdure/trigger SQL code

I would like to create a script that lists out all of the SQL code for the procedures and triggers I have created in a database.

What I want to do is save the code for each procedure/trigger as a *.SQL file without having to open up each one in Enterprise Manager and save them individually.

Listing the names is easy by looking in sysobjects, but is the SQL code stored in a system table anywhere?

Does anybody have any alternative approach to this problem?

Thanks in advance,

MarkI don't understand you problem. EM allows you to script out all the objects of any particular type(s) to separate files. There is nothing that limits you to one object at a time.

Monday, March 19, 2012

List Windows Userids Object Permission

I am looking for a script that will list windows userids and sql userids
with database object permissions.
Please help me with this task.
Thanks,Hi
Look at the sysusers, syspermissions and sysprotects tables
John
"Joe K." wrote:

> I am looking for a script that will list windows userids and sql userids
> with database object permissions.
> Please help me with this task.
> Thanks,

Monday, March 12, 2012

List Server Roles

I am currently working on a SSIS configuration database. However, I am having trouble writing a script to get the the users that have each server role permissions. I'm pretty sure that I need to use sp_helpsrvrole, but am not sure where to go from here. If anybody has any ideas or has seen a script on the internet to get this then that would be a tremendous help.

Thanks in advance,

Kyle

Please try:

exec sp_helpsrvrolemember

this should get the server role membership information you are looking for. Let us know if you have any further questions.

-Raul Garcia

SDE/T

SQL Server Engine

List remote server and directory

Hi
Trying to work on a script which is able to list files on a remote server
and its drive but unsure of the syntax. Can anyone advise as below doesnt
work.
xp_cmdshell 'dir "\\server::d:\"
Thanks
Hi,
The remote server needs to have a share exposed that you can use to get a
directory listing. The syntax would be:
exec master.dbo.xp_cmdshell 'dir \\myserver\d$'
If the path contains blanks then you need to quote the parameter with
double-quotes:
exec master.dbo.xp_cmdshell 'dir "\\myserver\c$\Program Files"'
RLF
"guest5" <guest5@.discussions.microsoft.com> wrote in message
news:C2CC72B2-F903-423A-A499-36E639532789@.microsoft.com...
> Hi
> Trying to work on a script which is able to list files on a remote server
> and its drive but unsure of the syntax. Can anyone advise as below doesnt
> work.
> xp_cmdshell 'dir "\\server::d:\"
>
> Thanks

List remote server and directory

Hi
Trying to work on a script which is able to list files on a remote server
and its drive but unsure of the syntax. Can anyone advise as below doesnt
work.
xp_cmdshell 'dir "\\server::d:\"
ThanksHi,
The remote server needs to have a share exposed that you can use to get a
directory listing. The syntax would be:
exec master.dbo.xp_cmdshell 'dir \\myserver\d$'
If the path contains blanks then you need to quote the parameter with
double-quotes:
exec master.dbo.xp_cmdshell 'dir "\\myserver\c$\Program Files"'
RLF
"guest5" <guest5@.discussions.microsoft.com> wrote in message
news:C2CC72B2-F903-423A-A499-36E639532789@.microsoft.com...
> Hi
> Trying to work on a script which is able to list files on a remote server
> and its drive but unsure of the syntax. Can anyone advise as below doesnt
> work.
> xp_cmdshell 'dir "\\server::d:\"
>
> Thanks

List remote server and directory

Hi
Trying to work on a script which is able to list files on a remote server
and its drive but unsure of the syntax. Can anyone advise as below doesnt
work.
xp_cmdshell 'dir "\\server::d:\"
ThanksHi,
The remote server needs to have a share exposed that you can use to get a
directory listing. The syntax would be:
exec master.dbo.xp_cmdshell 'dir \\myserver\d$'
If the path contains blanks then you need to quote the parameter with
double-quotes:
exec master.dbo.xp_cmdshell 'dir "\\myserver\c$\Program Files"'
RLF
"guest5" <guest5@.discussions.microsoft.com> wrote in message
news:C2CC72B2-F903-423A-A499-36E639532789@.microsoft.com...
> Hi
> Trying to work on a script which is able to list files on a remote server
> and its drive but unsure of the syntax. Can anyone advise as below doesnt
> work.
> xp_cmdshell 'dir "\\server::d:\"
>
> Thanks

Friday, February 24, 2012

List available SQL instances in a Server

Hi, iam using this script to connect to the default instance of a SQL Server
(7 or 2000)
strcomputer = wscript.arguments(0)
Set oServer=CreateObject("SQLDMO.Sqlserver")
oserver.loginsecure = true
oServer.Connect strComputer
The problem is:
When i try to connect to a server that has many instances
(MSSQLSERVER$XXXXXX) i cant connect. This scripts only works with the defaul
t
mssqlserver. The question is how can connect to a server and list the
available instances instead of hardcoding in code (Like strcomputer &
"\Instance") using vbscript or other shell tool. (The discover tool like osq
l
-L doesn't work, because it cant detect server over lot of networks)
Thanks all.Use the ListAvailableServers Method of the application object.
INF: How to Enumerate Available SQL Servers Using SQLDMO
http://support.microsoft.com/defaul...b;en-us;Q287737
AMB
"Tinchos" wrote:

> Hi, iam using this script to connect to the default instance of a SQL Serv
er
> (7 or 2000)
> strcomputer = wscript.arguments(0)
> Set oServer=CreateObject("SQLDMO.Sqlserver")
> oserver.loginsecure = true
> oServer.Connect strComputer
> The problem is:
> When i try to connect to a server that has many instances
> (MSSQLSERVER$XXXXXX) i cant connect. This scripts only works with the defa
ult
> mssqlserver. The question is how can connect to a server and list the
> available instances instead of hardcoding in code (Like strcomputer &
> "\Instance") using vbscript or other shell tool. (The discover tool like o
sql
> -L doesn't work, because it cant detect server over lot of networks)
> Thanks all.|||Thanks Alejandro. But it doesn't work neither. It's the same that use the
osql -L (only works on local network)
I need to find a method to connect to a server and list the available
instances with dmo.
Thanks !!
"Alejandro Mesa" wrote:
> Use the ListAvailableServers Method of the application object.
> INF: How to Enumerate Available SQL Servers Using SQLDMO
> http://support.microsoft.com/defaul...b;en-us;Q287737
>
> AMB
> "Tinchos" wrote:
>|||See if querying master.dbo.sysservers or executing sp_helpserver helps.
AMB
"Tinchos" wrote:
> Thanks Alejandro. But it doesn't work neither. It's the same that use the
> osql -L (only works on local network)
> I need to find a method to connect to a server and list the available
> instances with dmo.
> Thanks !!
> "Alejandro Mesa" wrote:
>|||Nop, i have a about 50 sql server over the network.
New sql servers are installed with instances, like this:
SERVER\UNLAMXEX
SERVER\UNLAMXFO
SERVER\UNLAMXPR
I need to specify the instance to connect with isql o other. I need some
scripting tool to detects automatically the instances.
Thanks.
Martin
"Alejandro Mesa" wrote:
> See if querying master.dbo.sysservers or executing sp_helpserver helps.
>
> AMB
> "Tinchos" wrote:
>