Showing posts with label procedure. Show all posts
Showing posts with label procedure. Show all posts

Friday, March 30, 2012

Load image file

HI

how to load a image file in to a sql server.

do we need c# code for it or can we use just a t-sql procedure to upload it.

In my application we don't have ant c# or other application. we have only t-sql

thanks

sandipan

If you are planning to use SSIS, the Import Column transform could be useful for this purpose.

Thanks.

Load data from text file into some table implemented in stored procedure.

Hello, I want to load data from text file to MS SQL DB table.

In MySQL, it is the "LOAD DATA INFILE..." query statement.

What is sutable query if I want to migration from Mysql to MS SQL Server 2005 Express?

I think you need some third party tool, which will do the needed convertions. Executing query form a file you need to read the SQLCMD form BOL, this is command line utility.

|||hi remedios,

you can use the bcp(Bulk Copy Program) to basically do the same as in MySql. or if not why not use DTS in Enterprise Manager and select the text file as the Source

hth

Monday, March 26, 2012

Load assembly from Stored Procedure

Hi,
Is it possible to load an assembly either from a byte array or from the disk at runtime from a CLR stored procedure.

I have created a stored procedure that needs to load different assemblies depending on a query and then invokes a method (called execute() passing a string query as a parameter).
From debugging the CLR stored procedure in .NET I have found that it is this line that creates an error:

Assembly myAssembly= Assembly.Load()

It doesnt matter if I attempt to load the assembly from it's byte array or from a file location, it always gives the following error:

Msg 6522, Level 16, State 1, Procedure runQuery, Line 0
A .NET Framework error occurred during execution of user defined routine or aggregate 'runQuery':
System.IO.FileLoadException: LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host.
System.IO.FileLoadException:
at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection)
at System.Reflection.Assembly.Load(Byte[] rawAssembly)
at ClientInterface.RunInterface(String queryName, String parameters, String& returnValue)
It works perfectly if I run it using a mock up front end app it just seems to be sql server that doesnt like it.

Anybody have any ideas?
Assembly.Load() should work, BUT the assembly you are loading has to be catalogued in the database.

You are not allowed to load assemblies from anything but the database, that's why you are getting the error you see above: A .NET Framework error occurred... have been disabled by the host."

Niels
|||Thanks for replying Niel.

I will try loading the assemblies into the database and use Assembly.Load(assemblyName) to get it working.

N
sql

Load assembly from Stored Procedure

Hi,

Is it possible to load an assembly either from a byte array or from the disk at runtime from a CLR stored procedure.

I

have created a stored procedure that needs to load different assemblies

depending on a query and then invokes a method (called execute() passing a string query as a parameter).

From debugging the CLR stored procedure in .NET I have found that it is this line that creates an error:

Assembly myAssembly= Assembly.Load()

It

doesnt matter if I attempt to load the assembly from it's byte array or

from a file location, it always gives the following error:


Msg 6522, Level 16, State 1, Procedure runQuery, Line 0
A .NET Framework error occurred during execution of user defined routine or aggregate 'runQuery':
System.IO.FileLoadException: LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host.
System.IO.FileLoadException:

at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[]

rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark,

Boolean fIntrospection)
at System.Reflection.Assembly.Load(Byte[] rawAssembly)
at ClientInterface.RunInterface(String queryName, String parameters, String& returnValue)

It works perfectly if I run it using a mock up front end app it just seems to be sql server that doesnt like it.

Anybody have any ideas?

Assembly.Load() should work, BUT the assembly you are loading has to be catalogued in the database.

You are not allowed to load assemblies from anything but the database, that's why you are getting the error you see above: A .NET Framework error occurred... have been disabled by the host."

Niels|||Thanks for replying Niel.

I will try loading the assemblies into the database and use Assembly.Load(assemblyName) to get it working.

N

Friday, March 23, 2012

Little Lock Symbols

WE are new to SQL Server 2005. My team memebers and I have the same login-in
as a group. One member developed some stored procedure code that I am trying
to review , but there are thse little lock symbols on the file icon. how can
I see the file?
Do you mean when you open the file in Management Studio, the tab at the top
has a lock icon? This means the file is read-only, possibly because it is
checked into source control. If this is not what you are talking about,
then you can explain (a) where you see the lock, and (b) what it means that
you can't "see" the file?
A
"Candyman" <Candyman@.discussions.microsoft.com> wrote in message
news:F8A96B55-7ED2-4913-94EF-FB215804AE17@.microsoft.com...
> WE are new to SQL Server 2005. My team memebers and I have the same
> login-in
> as a group. One member developed some stored procedure code that I am
> trying
> to review , but there are thse little lock symbols on the file icon. how
> can
> I see the file?
|||WE are in Management Studio. On the left hand side is the Obkect Explorer,
We have many listings under databases. The tree structure looks like
Databases\db_ReportSource\Programmability\Stored Procedures. . . Then there
is a file dbo.SQL_myquery listed and the adjacent icon looks like a light
blue piece of paper with a darker blue stripe at the top. Then there is a
little yelow lock on the right lower corner of the icon. My team mate can
right click on the file and see a Modify option to show me the code. That
Modify option is greyed out to me. ( and four other procs he created.) How do
I see the code? Is there another way to get to it?
"Aaron Bertrand [SQL Server MVP]" wrote:

> Do you mean when you open the file in Management Studio, the tab at the top
> has a lock icon? This means the file is read-only, possibly because it is
> checked into source control. If this is not what you are talking about,
> then you can explain (a) where you see the lock, and (b) what it means that
> you can't "see" the file?
> A
> "Candyman" <Candyman@.discussions.microsoft.com> wrote in message
> news:F8A96B55-7ED2-4913-94EF-FB215804AE17@.microsoft.com...
>
>
|||If you just want to see it and not modify it, then:
(1) Right-click the database name and select new query
(2) Make sure you are in Results to Text (Ctrl+T)
(3) Type:
EXEC sp_helptext 'SQL_myquery';
(4) Hit F5 (or the Execute button on the toolbar)
"Candyman" <Candyman@.discussions.microsoft.com> wrote in message
news:119BA461-C65C-4755-83CA-E7EF1C4CAE3B@.microsoft.com...[vbcol=seagreen]
> WE are in Management Studio. On the left hand side is the Obkect
> Explorer,
> We have many listings under databases. The tree structure looks like
> Databases\db_ReportSource\Programmability\Stored Procedures. . . Then
> there
> is a file dbo.SQL_myquery listed and the adjacent icon looks like a light
> blue piece of paper with a darker blue stripe at the top. Then there is a
> little yelow lock on the right lower corner of the icon. My team mate can
> right click on the file and see a Modify option to show me the code. That
> Modify option is greyed out to me. ( and four other procs he created.) How
> do
> I see the code? Is there another way to get to it?
> "Aaron Bertrand [SQL Server MVP]" wrote:
|||if I 'check (green check)' it, the programs returns: "query excecuted
successfully".
Then when I try to run as suggested the command errors out saying "There is
no text for object 'SQL_myquery'"
Could the file actuallly be residing on the other users machine and not in
SQL Server? or network?
"Aaron Bertrand [SQL Server MVP]" wrote:

> If you just want to see it and not modify it, then:
> (1) Right-click the database name and select new query
> (2) Make sure you are in Results to Text (Ctrl+T)
> (3) Type:
> EXEC sp_helptext 'SQL_myquery';
> (4) Hit F5 (or the Execute button on the toolbar)
>
>
> "Candyman" <Candyman@.discussions.microsoft.com> wrote in message
> news:119BA461-C65C-4755-83CA-E7EF1C4CAE3B@.microsoft.com...
>
>
|||> if I 'check (green check)' it, the programs returns: "query excecuted
> successfully".
Yes, if you hold your mouse over the green check you decided to click, you
will see that means "parse" (syntax check). The success message means that
the command didn't have any syntax errors.

> Then when I try to run as suggested the command errors out saying "There
> is
> no text for object 'SQL_myquery'"
Are you sure your query is running in the correct database? When you
right-clicked "the database" was it db_ReportSource, or some other database?
Are you sure you were in an Object Explorer context of the correct server?
What happens when you execute the following in a properly created New Query
window:
USE db_ReportSource;
GO
EXEC SQL_myquery;
GO
EXEC dbo.SQL_myquery;
GO
?

> Could the file actuallly be residing on the other users machine and not in
> SQL Server? or network?
No, from your earlier description, this is a stored procedure in a database.
There are many differences between a stored procedure in the database and a
file in the file system. They are certainly not the same, and a file
somewhere on your network is certainly not going to magically appear under
the stored procedures node in object explorer.
A
|||Candyman (Candyman@.discussions.microsoft.com) writes:
> if I 'check (green check)' it, the programs returns: "query excecuted
> successfully".
> Then when I try to run as suggested the command errors out saying "There
> is no text for object 'SQL_myquery'"
> Could the file actuallly be residing on the other users machine and not in
> SQL Server? or network?
First of all, it is not a file. It's an object in a database, and there
should indeed be a file for it in the file system, or even better in
the version-control system. But if you co-worker just created the procedure
in a query window, and then closed the window without saving it, there is
no file at all. Just an object in a database.
Normally, though, stored procedures can be disassembled from the database
so you can edit them, which is popular in teams that don't believe in
files or version-control systems.
But this small lock indicates that you can't. There are two possible reasons
for this:
o The procedure was created with the clause WITH ENCRYPTION.
o It is a stored procedure created in a CLR language such as VB .Net or C#.
If you right-click the procedure and selecr Properties, you might be
able to deduce which of the cases it is. If there things like "Property
AnsiNullsStatus is not available..." it is a CLR stored procedure.
In either cases, you will have to ask your co-worker where he has the
source code.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
|||The application asked me for some date parameters, which I enterd and
recieved results back so there is something there, but I still can't see the
original code.
Erland might have hit it on found the solution as the file properties do
seem to be encrypted. This is something we will have to discuss withthe
group. Thanks so much for your input and patience.
"Aaron Bertrand [SQL Server MVP]" wrote:

> Yes, if you hold your mouse over the green check you decided to click, you
> will see that means "parse" (syntax check). The success message means that
> the command didn't have any syntax errors.
>
> Are you sure your query is running in the correct database? When you
> right-clicked "the database" was it db_ReportSource, or some other database?
> Are you sure you were in an Object Explorer context of the correct server?
> What happens when you execute the following in a properly created New Query
> window:
> USE db_ReportSource;
> GO
> EXEC SQL_myquery;
> GO
> EXEC dbo.SQL_myquery;
> GO
> ?
>
> No, from your earlier description, this is a stored procedure in a database.
> There are many differences between a stored procedure in the database and a
> file in the file system. They are certainly not the same, and a file
> somewhere on your network is certainly not going to magically appear under
> the stored procedures node in object explorer.
> A
>
>
|||BINGO!
Under properties in the Options section the file has Encrypted set to TRUE
and Replication set to FALSE also ( I guess which means I could not copy the
file which I tried to do also.)
We are baby new to this and I have to bring this up to the author of the
code and to our new “Weekly user group” . Both of which are out today, but
thank you for the info! This is helpful.
I will also suggest we start using Source Safe for version control.
Thanks!
"Erland Sommarskog" wrote:

> Candyman (Candyman@.discussions.microsoft.com) writes:
> First of all, it is not a file. It's an object in a database, and there
> should indeed be a file for it in the file system, or even better in
> the version-control system. But if you co-worker just created the procedure
> in a query window, and then closed the window without saving it, there is
> no file at all. Just an object in a database.
> Normally, though, stored procedures can be disassembled from the database
> so you can edit them, which is popular in teams that don't believe in
> files or version-control systems.
> But this small lock indicates that you can't. There are two possible reasons
> for this:
> o The procedure was created with the clause WITH ENCRYPTION.
> o It is a stored procedure created in a CLR language such as VB .Net or C#.
> If you right-click the procedure and selecr Properties, you might be
> able to deduce which of the cases it is. If there things like "Property
> AnsiNullsStatus is not available..." it is a CLR stored procedure.
> In either cases, you will have to ask your co-worker where he has the
> source code.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
>
|||> Under properties in the Options section the file has Encrypted set to TRUE
> and Replication set to FALSE also ( I guess which means I could not copy
> the
> file which I tried to do also.)
No, replication and copying a file are not the same thing.
A

little help on delete stored procedure

I created a insert stored procedure but It was not working correctly
Could you correct the code?
I am trying to insert contract information on contract table but before that I want to check the studentID in student table and contactId in contact table if they exist I want to insert into the contract table

Please help!

************************************************** ***
My contrat DDL is follows

create table contract(
contractNum int identity(1,1) primary key,
contractDate smalldatetime not null,
tuition money not null,
studentId char(4) not null foreign key references student (studentId),
contactId int not null foreign key references contact (contactId)
);

************************************************** ***
My insert stored procedure is follows

create proc sp_insert_new_contract
( @.contractDate [smalldatetime],
@.tuition [money],
@.studentId [char],
@.contactId [int])
as
if exists (select s.studentId, c.contactId
from student s, contact c
where @.contactId = contactId
and @.studentId = studentId)


begin
insert into contract
([contractDate],
[tuition],
[studentId],
[contactId])
values
(@.contractDate,
@.tuition,
@.studentId,
@.contactId)

end
else
print 'studentId and contactId are not valid, please try another studnetId and contactId'
goSyntactically, it should be:

create proc sp_insert_new_contract
( @.contractDate [smalldatetime],
@.tuition [money],
@.studentId [char] (4),
@.contactId [int])
as
if exists (select s.studentId, c.contactId
from student s, contact c
where @.contactId = contactId
and @.studentId = s.studentId)
...

But logically, you're also missing a validity of JUST a student id:

declare @.student_check char(4)
select @.student_check = max(studentid) from student where studentid = @.studentid
if @.student_check is null begin
print 'Invalid studentid specified'
return (1)
end

if exists (select 1 from contact
where @.contactId = contactId
and @.studentId = @.studentId) begin
print 'Specified studentid/contractid already exist in the table!'
return (1)
end
...
After then you can go on with the rest of your procedure.

lists through sp_helpsrvrolemember return unexpected results

When running the stored procedure sp_helpsrvrolemember to return a list of
users with 'sysadmin' permissions, my result set was inconsistent. Users tha
t
had the permissions removed weeks ago still showed up, however, when running
the query hours later, the results set changed and did not reflect the old
permissions.
Is this a known bug, a cache issue that needs restarts?
(This is a SQL 2000 sp4 instance)
DougCan you recreate that with a test database? I'm not able to do that here on
my system.
"Doug Olson" wrote:

> When running the stored procedure sp_helpsrvrolemember to return a list of
> users with 'sysadmin' permissions, my result set was inconsistent. Users t
hat
> had the permissions removed weeks ago still showed up, however, when runni
ng
> the query hours later, the results set changed and did not reflect the old
> permissions.
> Is this a known bug, a cache issue that needs restarts?
> (This is a SQL 2000 sp4 instance)
> Doug|||I haven't been able to exactly re-create it, however, I have received some
communication/feedback that this is related to a ghosting issue/problem.
Doug
"Buck Woody - Microsoft SQL Server Team" wrote:
[vbcol=seagreen]
> Can you recreate that with a test database? I'm not able to do that here o
n
> my system.
> "Doug Olson" wrote:
>|||Good stuff - so do you have this solved?
"Doug Olson" wrote:
[vbcol=seagreen]
> I haven't been able to exactly re-create it, however, I have received some
> communication/feedback that this is related to a ghosting issue/problem.
> Doug
> "Buck Woody - Microsoft SQL Server Team" wrote:
>

Listing SPs

Is there anyway of listing all the store procedure in a DB? I need to locate a SP but I don´t know in which DB is, all I have is the name
Thanks to everyone
C.Cesar,
the easiest way is to use the object search utility in query analyser - it
will allow searching in all databases.
HTH,
Paul Ibison|||Is there a query I can run to do that?|||sysobjects table in each db contains the names of the stored procudure
select * from sysobjects where type = 'p' and name = @.procname
Write a cursor to loop thru each db in your server.
HTH, Amol.
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:EDDA4F21-5A2C-4172-AEB5-B65FF859BE0A@.microsoft.com...
> Is there a query I can run to do that?|||Cesar,
(In SQL2000...)
To search a user table named 'Mytable' in all databases...
exec master.dbo.sp_MSobjsearch @.searchkey = N'Mytable', @.objecttype = 1,
@.dbname = [*], @.casesensitive = 0, @.hitlimit = 100, @.status = 1,
@.extpropname = NULL, @.extpropvalue = NULL
Do note that sp_MSobjsearch is a undocumented call and hence the usual
warnings apply.To find out details about the various parameters, do:
USE master
sp_helptext sp_MSobjsearch
Dinesh
SQL Server MVP
--
--
SQL Server FAQ at
http://www.tkdinesh.com
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:EDDA4F21-5A2C-4172-AEB5-B65FF859BE0A@.microsoft.com...
> Is there a query I can run to do that?|||Cesar,
To search for a stored procedure named 'MyStorProc' across all databases..
sp_msforeachdb "PRINT '?' select * from [?]..sysobjects where type='P' and
name='MyStorProc'"
Please note that sp_msforeachdb is a undocumented call and hence the usual
warnings apply.
--
Dinesh
SQL Server MVP
--
--
SQL Server FAQ at
http://www.tkdinesh.com
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I don´t know in which DB is, all I have is the name.
> Thanks to everyone,
> C.|||Cesar,
you could use the method that the GUI uses:
exec master.dbo.sp_MSobjsearch @.searchkey = N'storedprocedurename',
@.objecttype = 24, @.dbname = [*], @.casesensitive = 0, @.hitlimit = 100,
@.status = 1, @.extpropname = NULL, @.extpropvalue = NULL
Or you could use the code I have created below. If you want the search
explicitly, then you just need to add the parameter to athe where clause of
the exec statement, eg exec ('select o.name from ' + @.dbname +
'.dbo.sysobjects o where o.xtype = ''P'' and o.name =''storedprocedurename'' ')
HTH,
Paul Ibison
declare @.dbname varchar(100)
DECLARE databasecursor CURSOR FOR
SELECT name
FROM master.dbo.sysdatabases
OPEN databasecursor
FETCH NEXT FROM databasecursor into @.dbname
WHILE @.@.FETCH_STATUS = 0
BEGIN
select @.dbname as 'Database'
exec ('select o.name from ' + @.dbname + '.dbo.sysobjects o where o.xtype
= ''P'' ')
FETCH NEXT FROM databasecursor into @.dbname
END
CLOSE databasecursor
DEALLOCATE databasecursor
GO|||Thanks to everyone (Paul, Amol and Dinesh)!!!, I´ll try the solutions ASAP.|||>>I need to locate a SP but I don´t know in which DB is, all I have is the
name.
given the name of the SP you can press F4 in Query Analyzer and search.
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I don´t know in which DB is, all I have is the name.
> Thanks to everyone,
> C.|||Hi,
You can also use the system stored procedure sp_store_procedures
eg:
sp_store_procedures '%cust%'
This returns all the stored procedure name with cust in the procedure name.
Note:
You have to execute the procedure in each of the databases, because this
procedure will search only the current database.
Thanks
Hari
MCDBA
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I don´t know in which DB is, all I have is the name.
> Thanks to everyone,
> C.sql

Listing SPs

Is there anyway of listing all the store procedure in a DB? I need to locate a SP but I don′t know in which DB is, all I have is the name.
Thanks to everyone,
C.
Cesar,
the easiest way is to use the object search utility in query analyser - it
will allow searching in all databases.
HTH,
Paul Ibison
|||Is there a query I can run to do that?
|||sysobjects table in each db contains the names of the stored procudure
select * from sysobjects where type = 'p' and name = @.procname
Write a cursor to loop thru each db in your server.
HTH, Amol.
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:EDDA4F21-5A2C-4172-AEB5-B65FF859BE0A@.microsoft.com...
> Is there a query I can run to do that?
|||Cesar,
(In SQL2000...)
To search a user table named 'Mytable' in all databases...
exec master.dbo.sp_MSobjsearch @.searchkey = N'Mytable', @.objecttype = 1,
@.dbname = [*], @.casesensitive = 0, @.hitlimit = 100, @.status = 1,
@.extpropname = NULL, @.extpropvalue = NULL
Do note that sp_MSobjsearch is a undocumented call and hence the usual
warnings apply.To find out details about the various parameters, do:
USE master
sp_helptext sp_MSobjsearch
Dinesh
SQL Server MVP
--
SQL Server FAQ at
http://www.tkdinesh.com
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:EDDA4F21-5A2C-4172-AEB5-B65FF859BE0A@.microsoft.com...
> Is there a query I can run to do that?
|||Cesar,
To search for a stored procedure named 'MyStorProc' across all databases..
sp_msforeachdb "PRINT '?' select * from [?]..sysobjects where type='P' and
name='MyStorProc'"
Please note that sp_msforeachdb is a undocumented call and hence the usual
warnings apply.
Dinesh
SQL Server MVP
--
SQL Server FAQ at
http://www.tkdinesh.com
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I dont know in which DB is, all I have is the name.
> Thanks to everyone,
> C.
|||Cesar,
you could use the method that the GUI uses:
exec master.dbo.sp_MSobjsearch @.searchkey = N'storedprocedurename',
@.objecttype = 24, @.dbname = [*], @.casesensitive = 0, @.hitlimit = 100,
@.status = 1, @.extpropname = NULL, @.extpropvalue = NULL
Or you could use the code I have created below. If you want the search
explicitly, then you just need to add the parameter to athe where clause of
the exec statement, eg exec ('select o.name from ' + @.dbname +
'.dbo.sysobjects o where o.xtype = ''P'' and o.name =
''storedprocedurename'' ')
HTH,
Paul Ibison
declare @.dbname varchar(100)
DECLARE databasecursor CURSOR FOR
SELECT name
FROM master.dbo.sysdatabases
OPEN databasecursor
FETCH NEXT FROM databasecursor into @.dbname
WHILE @.@.FETCH_STATUS = 0
BEGIN
select @.dbname as 'Database'
exec ('select o.name from ' + @.dbname + '.dbo.sysobjects o where o.xtype
= ''P'' ')
FETCH NEXT FROM databasecursor into @.dbname
END
CLOSE databasecursor
DEALLOCATE databasecursor
GO
|||Thanks to everyone (Paul, Amol and Dinesh)!!!, I′ll try the solutions ASAP.
|||>>I need to locate a SP but I dont know in which DB is, all I have is the
name.
given the name of the SP you can press F4 in Query Analyzer and search.
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I dont know in which DB is, all I have is the name.
> Thanks to everyone,
> C.
|||Hi,
You can also use the system stored procedure sp_store_procedures
eg:
sp_store_procedures '%cust%'
This returns all the stored procedure name with cust in the procedure name.
Note:
You have to execute the procedure in each of the databases, because this
procedure will search only the current database.
Thanks
Hari
MCDBA
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I dont know in which DB is, all I have is the name.
> Thanks to everyone,
> C.

Listing SPs

Is there anyway of listing all the store procedure in a DB? I need to locate
a SP but I don′t know in which DB is, all I have is the name.
Thanks to everyone,
C.Cesar,
the easiest way is to use the object search utility in query analyser - it
will allow searching in all databases.
HTH,
Paul Ibison|||Is there a query I can run to do that?|||sysobjects table in each db contains the names of the stored procudure
select * from sysobjects where type = 'p' and name = @.procname
Write a cursor to loop thru each db in your server.
HTH, Amol.
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:EDDA4F21-5A2C-4172-AEB5-B65FF859BE0A@.microsoft.com...
> Is there a query I can run to do that?|||Cesar,
(In SQL2000...)
To search a user table named 'Mytable' in all databases...
exec master.dbo.sp_MSobjsearch @.searchkey = N'Mytable', @.objecttype = 1,
@.dbname = [*], @.casesensitive = 0, @.hitlimit = 100, @.status = 1,
@.extpropname = NULL, @.extpropvalue = NULL
Do note that sp_MSobjsearch is a undocumented call and hence the usual
warnings apply.To find out details about the various parameters, do:
USE master
sp_helptext sp_MSobjsearch
Dinesh
SQL Server MVP
--
--
SQL Server FAQ at
http://www.tkdinesh.com
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:EDDA4F21-5A2C-4172-AEB5-B65FF859BE0A@.microsoft.com...
> Is there a query I can run to do that?|||Cesar,
To search for a stored procedure named 'MyStorProc' across all databases..
sp_msforeachdb "PRINT '?' select * from [?]..sysobjects where type='P' a
nd
name='MyStorProc'"
Please note that sp_msforeachdb is a undocumented call and hence the usual
warnings apply.
Dinesh
SQL Server MVP
--
--
SQL Server FAQ at
http://www.tkdinesh.com
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I dont know in which DB is, all I have is the name.
> Thanks to everyone,
> C.|||Cesar,
you could use the method that the GUI uses:
exec master.dbo.sp_MSobjsearch @.searchkey = N'storedprocedurename',
@.objecttype = 24, @.dbname = [*], @.casesensitive = 0, @.hitlimit = 100,
@.status = 1, @.extpropname = NULL, @.extpropvalue = NULL
Or you could use the code I have created below. If you want the search
explicitly, then you just need to add the parameter to athe where clause of
the exec statement, eg exec ('select o.name from ' + @.dbname +
'.dbo.sysobjects o where o.xtype = ''P'' and o.name =
''storedprocedurename'' ')
HTH,
Paul Ibison
declare @.dbname varchar(100)
DECLARE databasecursor CURSOR FOR
SELECT name
FROM master.dbo.sysdatabases
OPEN databasecursor
FETCH NEXT FROM databasecursor into @.dbname
WHILE @.@.FETCH_STATUS = 0
BEGIN
select @.dbname as 'Database'
exec ('select o.name from ' + @.dbname + '.dbo.sysobjects o where o.xtype
= ''P'' ')
FETCH NEXT FROM databasecursor into @.dbname
END
CLOSE databasecursor
DEALLOCATE databasecursor
GO|||Thanks to everyone (Paul, Amol and Dinesh)!!!, I′ll try the solutions ASAP
.|||>>I need to locate a SP but I dont know in which DB is, all I have is the
name.
given the name of the SP you can press F4 in Query Analyzer and search.
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I dont know in which DB is, all I have is the name.
> Thanks to everyone,
> C.|||Hi,
You can also use the system stored procedure sp_store_procedures
eg:
sp_store_procedures '%cust%'
This returns all the stored procedure name with cust in the procedure name.
Note:
You have to execute the procedure in each of the databases, because this
procedure will search only the current database.
Thanks
Hari
MCDBA
"Cesar" <anonymous@.discussions.microsoft.com> wrote in message
news:1C4A03A2-5497-420B-B914-2021A860E065@.microsoft.com...
> Is there anyway of listing all the store procedure in a DB? I need to
locate a SP but I dont know in which DB is, all I have is the name.
> Thanks to everyone,
> C.

Listing permissions on Stored Procedures via query.

How do I list the permissions on a stored procedure with a query?
I'm trying to remove Public from some xp_* procedures but I'd like to see
what Public is assigned to first.
Thanks much.Look up the system procedure sp_helprotect in SQL Server Books Online.
Anith|||"Horst" <Horst@.discussions.microsoft.com> wrote in message
news:6E119626-412D-494C-8F42-FA999C485625@.microsoft.com...
> How do I list the permissions on a stored procedure with a query?
> I'm trying to remove Public from some xp_* procedures but I'd like to see
> what Public is assigned to first.
>
> Thanks much.
You could reverse engineer the sp_helprotect sproc, but this should work
for you as well.
--
USE master
GO
CREATE TABLE #Foo (
Owner sysname,
Object sysname,
Grantee sysname,
Grantor sysname,
ProtectType varchar(50),
Action varchar(50),
[Column] sysname NULL
)
INSERT #Foo
EXEC sp_helprotect
SELECT *
FROM #Foo
WHERE OBJECT LIKE 'xp%'
AND Grantee = 'public'
DROP TABLE #Foo
Rick Sawtell
MCT, MCSD, MCDBA|||Thanks for the help.
"Rick Sawtell" wrote:

> "Horst" <Horst@.discussions.microsoft.com> wrote in message
> news:6E119626-412D-494C-8F42-FA999C485625@.microsoft.com...
> You could reverse engineer the sp_helprotect sproc, but this should work
> for you as well.
> --
> USE master
> GO
>
> CREATE TABLE #Foo (
> Owner sysname,
> Object sysname,
> Grantee sysname,
> Grantor sysname,
> ProtectType varchar(50),
> Action varchar(50),
> [Column] sysname NULL
> )
> INSERT #Foo
> EXEC sp_helprotect
> SELECT *
> FROM #Foo
> WHERE OBJECT LIKE 'xp%'
> AND Grantee = 'public'
> DROP TABLE #Foo
> --
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>|||Thanks for the help.
"Anith Sen" wrote:

> Look up the system procedure sp_helprotect in SQL Server Books Online.
> --
> Anith
>
>

Wednesday, March 21, 2012

listing of sp_who

> You can use sp_helptext to get the definition of any procedure in the
> current database, but in SQL 2005, the definitions of the system
> procedures are in a database you can't get to (mssqlsystemresource).
This is not true for any of the sp_ procedures I've bothered to try,
including sp_who. The following works on 9.00.2047 and 9.00.3027:
EXEC master.sys.sp_helptext 'sp_help';
EXEC master.sys.sp_helptext 'sp_who';
EXEC master.sys.sp_helptext 'sp_who2';
EXEC master.sys.sp_helptext 'sp_helpdb';
EXEC master.sys.sp_helptext 'sp_configure';
EXEC master.sys.sp_helptext 'sp_spaceused';
EXEC master.sys.sp_helptext 'sp_helptext';
EXEC master.sys.sp_helptext 'sp_changedbowner';
EXEC master.sys.sp_helptext 'sp_columns_90_rowset';
EXEC master.sys.sp_helptext 'sp_addlogin';
Thanks. After reading your other reply, I checked, and saw that this was
true. In an early beta of SQL2005 you couldn't use sp_helptext to get the
system procs; I've even got some old notes about that from one of the guys
on the dev team. So they changed this, probably after getting lots of
complaints!
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:%23llR$UpKHHA.3488@.TK2MSFTNGP02.phx.gbl...
> This is not true for any of the sp_ procedures I've bothered to try,
> including sp_who. The following works on 9.00.2047 and 9.00.3027:
>
> EXEC master.sys.sp_helptext 'sp_help';
> EXEC master.sys.sp_helptext 'sp_who';
> EXEC master.sys.sp_helptext 'sp_who2';
> EXEC master.sys.sp_helptext 'sp_helpdb';
> EXEC master.sys.sp_helptext 'sp_configure';
> EXEC master.sys.sp_helptext 'sp_spaceused';
> EXEC master.sys.sp_helptext 'sp_helptext';
> EXEC master.sys.sp_helptext 'sp_changedbowner';
> EXEC master.sys.sp_helptext 'sp_columns_90_rowset';
> EXEC master.sys.sp_helptext 'sp_addlogin';
>
>
|||> Thanks. After reading your other reply, I checked, and saw that this was
> true. In an early beta of SQL2005 you couldn't use sp_helptext to get the
> system procs; I've even got some old notes about that from one of the guys
> on the dev team. So they changed this, probably after getting lots of
> complaints!
Yes, and I remember after they fixed that, complaining that you couldn't do:
EXEC sp_helptext 'sys.sp_who'
But you could do:
EXEC sp_helptext 'sp_who'
That has changed, because now you can do the former (and in the case of
dynamic management objects, you can't do the latter).
A

Listening for report events

I have a series of reports and want to fire off a stored procedure to update
a "Printed date" column in my database. I don't want to do this from the
dataset that populates my datset as I only want this to occur if the report
is successfully generated. Is there any way I can do this with the scheduler?
If not, are the any report events that I can listen for? And or any other
solution to this problem.Sorry. I don't think I made my intentions very clear. I meant to say that I
have a series of report, and want to fire off a stored procedure everytime a
report is successfully generated.
"Graham Hope" wrote:
> I have a series of reports and want to fire off a stored procedure to update
> a "Printed date" column in my database. I don't want to do this from the
> dataset that populates my datset as I only want this to occur if the report
> is successfully generated. Is there any way I can do this with the scheduler?
> If not, are the any report events that I can listen for? And or any other
> solution to this problem.

listbox contents to sql stored procedure command parameter?

Hello,

Stuck in a spot and hoping someone will nudge me in the right direction...

I'm trying to write to a sql db via a storedprocedure using a parameter. i'm pretty certain the below statement is causing the problem. but i'm not sure how to properly refer to it...

Dim connString As String
connString = "integrated security=false;user id=sa;server=HCENT1;database=LicenseRenewal;persist security info=False"
Dim myConnection As New SqlConnection(connString)
Dim myCommand As New SqlCommand("InsertPage1", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
' ......other (working) parameter statements.......
Dim parameterDates As New SqlParameter("@.Dates", SqlDbType.VarChar, 4000)
parameterDates.Value = Session("lstDates")
myCommand.Parameters.Add(parameterDates)

myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()

the session("lstDates") is the contents of lstDates.Items (listbox) from a previous page.
i'm guessing its not valid to refer to it as a varchar, can someone point me to the proper way to handle this?

tia
andyI would try Session("lstDates").ToString(), though I personally would try and debug it to see what exactly is in that session variable.

Are you getting an error message? If so, please give the EXACT message.|||thank you for the suggestion.

I've tried what you're saying and the table gets populated with the string:

"System.Web.UI.WebControls.ListItemCollection"

i took a stab in the dark and tried varbinary (sans .tostring) as the sqldatatype for the parameter/storedprocedure/columntype and i received:


Server Error in '/NET/LicenseRenewal' Application.
------------------------

Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement IConvertible.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidCastException: Object must implement IConvertible.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +196
LicenseRenewal.W4.WriteDBPage1() in C:\Documents and Settings\andrzej\VSWebCache\www.aea13.org\NET\LicenseRenewal\W4.aspx.vb:453
LicenseRenewal.W4.btnDONE_Click(Object sender, EventArgs e) in C:\Documents and Settings\andrzej\VSWebCache\www.aea13.org\NET\LicenseRenewal\W4.aspx.vb:158
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277

Seems it can't automatically convert a collection of listbox items into a sql column list, a string list (not one long string however) in the column would be sufficient.

i welcome/appreciate any further input.

thank you
andy|||forgot to say, the contents of the session("lstDates") are various quantities (less then 25 typically) of strings following the 'syntax' of "02/02/04 From: 08:00 AM To 09:00 AM". The string gets compiled from a text box and 2 other listboxes and added to the lstDates. I know the session("lstDates") holds valid data because i've used the session info to reload the listbox without problems

http://www.aea13.org/net/licenserenewal/w1p2.aspx is the page that has the listbox, the page following that is supposed to write to the database when someone clicks on the bottom button.

I took copies of these 2 pages out of the full application, spliced them together and have butchered the code to get rid of non (error) relevant functions. only the relevant parts work for this testing purpose, also the button is only writing the single parameter to a lone table with a lone column.

thanks again.|||ok, got tired of fighting with it so went around it...


Dim connString As String
connString = "............."
Dim myConnection As New SqlConnection(connString)
Dim myCommand As New SqlCommand("test1", myConnection)
myCommand.CommandType = CommandType.StoredProcedure

Dim strTempString As String
Dim lstTempListbox As New ListBox
Dim arrTemparray As New ArrayList
Dim x As Integer

lstTempListbox.DataSource = Session("lstDates")
lstTempListbox.DataBind()

For x = 0 To lstTempListbox.Items.Count - 1
If strTempString = "" Then
strTempString = lstTempListbox.Items(x).ToString
Else
strTempString = strTempString + lstTempListbox.Items(x).ToString
End If
Next

Dim parameterDates As New SqlParameter("@.Dates", SqlDbType.VarChar, 4000)
parameterDates.Value = strTempString
myCommand.Parameters.Add(parameterDates)

myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()

the table gets the data nicely formatted into a single cell and i can spit it back out in the RTF without formatting issues.

hope it helps someone else :)
andy

listbox and sql stored procedure

Hi,
First of all sorry for my not perfect english.
I've got listbox in my .aspx page where the users can make multiple
selection.
So, Users can select 7 items in listbox, I have to take value from
items and pass it to stored procedure to delete 7 rolls in my table. Thats
simple, but what if user select 3 or 30 items in listbox? The problem is
that I dont know the number of the parameters, and how to pass them. can I
use array or is there some different solution?
Of course I can take the collection of items and for every item, I can
call stored procedure, but this is no good in performance reason.
Please help me
Some examples here:
http://vyaskn.tripod.com/passing_arr...procedures.htm
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"John" <stomss2003@.yahoo.com> wrote in message
news:%23HUM$drXEHA.3944@.tk2msftngp13.phx.gbl...
Hi,
First of all sorry for my not perfect english.
I've got listbox in my .aspx page where the users can make multiple
selection.
So, Users can select 7 items in listbox, I have to take value from
items and pass it to stored procedure to delete 7 rolls in my table. Thats
simple, but what if user select 3 or 30 items in listbox? The problem is
that I dont know the number of the parameters, and how to pass them. can I
use array or is there some different solution?
Of course I can take the collection of items and for every item, I can
call stored procedure, but this is no good in performance reason.
Please help me
|||This link is a good starting point. You will find some excellent
information here:
http://www.sommarskog.se/
Read the "Arrays and Lists in SQL Server" link
Keith
"John" <stomss2003@.yahoo.com> wrote in message
news:%23HUM$drXEHA.3944@.tk2msftngp13.phx.gbl...
> Hi,
> First of all sorry for my not perfect english.
> I've got listbox in my .aspx page where the users can make multiple
> selection.
> So, Users can select 7 items in listbox, I have to take value from
> items and pass it to stored procedure to delete 7 rolls in my table.
Thats
> simple, but what if user select 3 or 30 items in listbox? The problem is
> that I dont know the number of the parameters, and how to pass them. can
I
> use array or is there some different solution?
> Of course I can take the collection of items and for every item, I
can
> call stored procedure, but this is no good in performance reason.
> Please help me
>

listbox and sql stored procedure

Hi,
First of all sorry for my not perfect english.
I've got listbox in my .aspx page where the users can make multiple
selection.
So, Users can select 7 items in listbox, I have to take value from
items and pass it to stored procedure to delete 7 rolls in my table. Thats
simple, but what if user select 3 or 30 items in listbox? The problem is
that I dont know the number of the parameters, and how to pass them. can I
use array or is there some different solution?
Of course I can take the collection of items and for every item, I can
call stored procedure, but this is no good in performance reason.
Please help meSome examples here:
http://vyaskn.tripod.com/passing_ar..._procedures.htm
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"John" <stomss2003@.yahoo.com> wrote in message
news:%23HUM$drXEHA.3944@.tk2msftngp13.phx.gbl...
Hi,
First of all sorry for my not perfect english.
I've got listbox in my .aspx page where the users can make multiple
selection.
So, Users can select 7 items in listbox, I have to take value from
items and pass it to stored procedure to delete 7 rolls in my table. Thats
simple, but what if user select 3 or 30 items in listbox? The problem is
that I dont know the number of the parameters, and how to pass them. can I
use array or is there some different solution?
Of course I can take the collection of items and for every item, I can
call stored procedure, but this is no good in performance reason.
Please help me|||This link is a good starting point. You will find some excellent
information here:
http://www.sommarskog.se/
Read the "Arrays and Lists in SQL Server" link
Keith
"John" <stomss2003@.yahoo.com> wrote in message
news:%23HUM$drXEHA.3944@.tk2msftngp13.phx.gbl...
> Hi,
> First of all sorry for my not perfect english.
> I've got listbox in my .aspx page where the users can make multiple
> selection.
> So, Users can select 7 items in listbox, I have to take value from
> items and pass it to stored procedure to delete 7 rolls in my table.
Thats
> simple, but what if user select 3 or 30 items in listbox? The problem is
> that I dont know the number of the parameters, and how to pass them. can
I
> use array or is there some different solution?
> Of course I can take the collection of items and for every item, I
can
> call stored procedure, but this is no good in performance reason.
> Please help me
>

listbox and sql stored procedure

Hi,
First of all sorry for my not perfect english.
I've got listbox in my .aspx page where the users can make multiple
selection.
So, Users can select 7 items in listbox, I have to take value from
items and pass it to stored procedure to delete 7 rolls in my table. Thats
simple, but what if user select 3 or 30 items in listbox? The problem is
that I dont know the number of the parameters, and how to pass them. can I
use array or is there some different solution?
Of course I can take the collection of items and for every item, I can
call stored procedure, but this is no good in performance reason.
Please help meSome examples here:
http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"John" <stomss2003@.yahoo.com> wrote in message
news:%23HUM$drXEHA.3944@.tk2msftngp13.phx.gbl...
Hi,
First of all sorry for my not perfect english.
I've got listbox in my .aspx page where the users can make multiple
selection.
So, Users can select 7 items in listbox, I have to take value from
items and pass it to stored procedure to delete 7 rolls in my table. Thats
simple, but what if user select 3 or 30 items in listbox? The problem is
that I dont know the number of the parameters, and how to pass them. can I
use array or is there some different solution?
Of course I can take the collection of items and for every item, I can
call stored procedure, but this is no good in performance reason.
Please help me|||This link is a good starting point. You will find some excellent
information here:
http://www.sommarskog.se/
Read the "Arrays and Lists in SQL Server" link
--
Keith
"John" <stomss2003@.yahoo.com> wrote in message
news:%23HUM$drXEHA.3944@.tk2msftngp13.phx.gbl...
> Hi,
> First of all sorry for my not perfect english.
> I've got listbox in my .aspx page where the users can make multiple
> selection.
> So, Users can select 7 items in listbox, I have to take value from
> items and pass it to stored procedure to delete 7 rolls in my table.
Thats
> simple, but what if user select 3 or 30 items in listbox? The problem is
> that I dont know the number of the parameters, and how to pass them. can
I
> use array or is there some different solution?
> Of course I can take the collection of items and for every item, I
can
> call stored procedure, but this is no good in performance reason.
> Please help me
>

Monday, March 19, 2012

Listbox

I'm new to MS Reporting Services and I need help ....
I have a Stored Procedure and I'm passing 3 parameters. One of the
parameters is a listbox with several options. I want to automatically
populate those options from a database query. Problem is I am not sure
how to do this.
The report data is currently coming from a Stored Procedure that
returns a single dataset. Do I need to add another dataset or a
subreport? Need helpYou can handle this by creating a new dataset, which can either use a
stored proc that brings back the options you want in your listbox, or
manually typing in the query (dataset type of "Text").
Next, go to Report --> Parameters
Choose the parameter that you want a listbox for.
Under "Available Values," choose "From Query"
In the dataset field, select the new dataset you just created
In the "value field," choose the field from your dataset that holds the
"value" you want passed to the query that drives your report
In the "label field," choose the field from your dataset that you want
to display in the listbox.
John
melishbd wrote:
> I'm new to MS Reporting Services and I need help ....
> I have a Stored Procedure and I'm passing 3 parameters. One of the
> parameters is a listbox with several options. I want to automatically
> populate those options from a database query. Problem is I am not sure
> how to do this.
>
> The report data is currently coming from a Stored Procedure that
> returns a single dataset. Do I need to add another dataset or a
> subreport? Need help|||Sorry I had misunderstood...these guys seem to have you pointed in the
right direction now, anyway.
John
melishbd wrote:
> I'm new to MS Reporting Services and I need help ....
> I have a Stored Procedure and I'm passing 3 parameters. One of the
> parameters is a listbox with several options. I want to automatically
> populate those options from a database query. Problem is I am not sure
> how to do this.
>
> The report data is currently coming from a Stored Procedure that
> returns a single dataset. Do I need to add another dataset or a
> subreport? Need help

Monday, March 12, 2012

list of stored procedure changes

I noticed that there is an inbuilt report in SSMS for the "Schema Changes
History". My questions are simple - how is it achieved? Is there a system
view I can use to achieve the same? Is there a setting which controls
whether this info is logged? Also, is it possible to get a history of
changes to a particular stored procedure this way, or is it just the name of
the stored procedure?
TIAYou could write your own in SQL server 2005 by using
OBJECT_DEFINITION() and the INFORMATION_SCHEMA.ROUTINES view
Code is here
(http://sqlservercode.blogspot.com/2...e.blogspot.com/
Joe wrote:
> I noticed that there is an inbuilt report in SSMS for the "Schema Changes
> History". My questions are simple - how is it achieved? Is there a system
> view I can use to achieve the same? Is there a setting which controls
> whether this info is logged? Also, is it possible to get a history of
> changes to a particular stored procedure this way, or is it just the name
of
> the stored procedure?
> TIA|||Looks like the Management Studio report is using the traces to look for
object changes, which you can achieve yourself by running a trace.
Alternatively, you could you DDL triggers to track object changes in SQL
Server 2005.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Joe" <Joe.Barrymore@.BT.Com> wrote in message
news:e$2LeF7iGHA.960@.TK2MSFTNGP05.phx.gbl...
I noticed that there is an inbuilt report in SSMS for the "Schema Changes
History". My questions are simple - how is it achieved? Is there a system
view I can use to achieve the same? Is there a setting which controls
whether this info is logged? Also, is it possible to get a history of
changes to a particular stored procedure this way, or is it just the name of
the stored procedure?
TIA|||SQL Server 2005 by default runs a 'lightweight trace' that captures
information about errors, security changes, configuration changes and object
creation, alter and drop. SSMS gets its data from this trace. The trace file
is stored in your \MSSQL\log directory and a new one is created every time
you restart your SQL Server.
A new feature of SQL 2005 that I like a lot is that you can open up a trace
file, or copy its contents to a table for analysis, even while the trace is
running.
I wrote about these traces in the March issue of SQL Server Magazine.
http://www.sqlmag.com/Article/Artic...or_a_Trace.html
There is a configuration option called 'default trace enabled' that turns
this tracing on or off, and it is ON by default.
Hopefully, this can give you a start into doing your own analysis.
HTH
Kalen Delaney, SQL Server MVP
"Joe" <Joe.Barrymore@.BT.Com> wrote in message
news:e$2LeF7iGHA.960@.TK2MSFTNGP05.phx.gbl...
>I noticed that there is an inbuilt report in SSMS for the "Schema Changes
>History". My questions are simple - how is it achieved? Is there a system
>view I can use to achieve the same? Is there a setting which controls
>whether this info is logged? Also, is it possible to get a history of
>changes to a particular stored procedure this way, or is it just the name
>of the stored procedure?
> TIA
>

list of stored procedure changes

I noticed that there is an inbuilt report in SSMS for the "Schema Changes
History". My questions are simple - how is it achieved? Is there a system
view I can use to achieve the same? Is there a setting which controls
whether this info is logged? Also, is it possible to get a history of
changes to a particular stored procedure this way, or is it just the name of
the stored procedure?
TIAYou could write your own in SQL server 2005 by using
OBJECT_DEFINITION() and the INFORMATION_SCHEMA.ROUTINES view
Code is here
(http://sqlservercode.blogspot.com/2006/04/use-objectdefinition-to-track.html)
Basically you would schedule a job that runs every day (or whatever you
like) and store the proc code in a table
That way you can query the tables and go back to a certain date (if
needed) and you can also check if procs have changed
Denis the SQL Menace
http://sqlservercode.blogspot.com/
Joe wrote:
> I noticed that there is an inbuilt report in SSMS for the "Schema Changes
> History". My questions are simple - how is it achieved? Is there a system
> view I can use to achieve the same? Is there a setting which controls
> whether this info is logged? Also, is it possible to get a history of
> changes to a particular stored procedure this way, or is it just the name of
> the stored procedure?
> TIA|||Looks like the Management Studio report is using the traces to look for
object changes, which you can achieve yourself by running a trace.
Alternatively, you could you DDL triggers to track object changes in SQL
Server 2005.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Joe" <Joe.Barrymore@.BT.Com> wrote in message
news:e$2LeF7iGHA.960@.TK2MSFTNGP05.phx.gbl...
I noticed that there is an inbuilt report in SSMS for the "Schema Changes
History". My questions are simple - how is it achieved? Is there a system
view I can use to achieve the same? Is there a setting which controls
whether this info is logged? Also, is it possible to get a history of
changes to a particular stored procedure this way, or is it just the name of
the stored procedure?
TIA|||SQL Server 2005 by default runs a 'lightweight trace' that captures
information about errors, security changes, configuration changes and object
creation, alter and drop. SSMS gets its data from this trace. The trace file
is stored in your \MSSQL\log directory and a new one is created every time
you restart your SQL Server.
A new feature of SQL 2005 that I like a lot is that you can open up a trace
file, or copy its contents to a table for analysis, even while the trace is
running.
I wrote about these traces in the March issue of SQL Server Magazine.
http://www.sqlmag.com/Article/ArticleID/48939/Searching_for_a_Trace.html
There is a configuration option called 'default trace enabled' that turns
this tracing on or off, and it is ON by default.
Hopefully, this can give you a start into doing your own analysis.
HTH
Kalen Delaney, SQL Server MVP
"Joe" <Joe.Barrymore@.BT.Com> wrote in message
news:e$2LeF7iGHA.960@.TK2MSFTNGP05.phx.gbl...
>I noticed that there is an inbuilt report in SSMS for the "Schema Changes
>History". My questions are simple - how is it achieved? Is there a system
>view I can use to achieve the same? Is there a setting which controls
>whether this info is logged? Also, is it possible to get a history of
>changes to a particular stored procedure this way, or is it just the name
>of the stored procedure?
> TIA
>