473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Output stored procedures as text problem

I'm using the function below to output all of my stored procedures into
a text file. Fice, except that the output file does not reflect the
names of the stored procedures correctly if the name has been changed.

For example, I create a stored procedure named: "sp123" and then rename
it to "sp123DELETE" or "sp123 DELETE" or "sp123OLD" or "sp123 OLD" and
what I end up with is four entries in the output file all having the
stored procedure name "sp123."

I stop the service and restart before outputting the file.

Any help is appreciated.

lq

Function ExportSP(myPath As String)

Dim objSQLServer As New SQLDMO.SQLServer
Dim dbs As New SQLDMO.Database
Dim sp As SQLDMO.StoredProcedure
Dim sptext As String

objSQLServer.Connect <Servername>, <Username>, <Password>
Set dbs = objSQLServer.Databases(<databasename>)

Open myPath For Output As #1

For Each sp In dbs.StoredProcedures
sptext = sp.Text

Print #1, sptext & _
vbCrLf & vbCrLf & vbCrLf & _
"*******" & _
vbCrLf & vbCrLf & vbCrLf
Next

End Function

Sep 13 '05 #1
4 4120
laurenq uantrell wrote:
I'm using the function below to output all of my stored procedures into
a text file. Fice, except that the output file does not reflect the
names of the stored procedures correctly if the name has been changed.

For example, I create a stored procedure named: "sp123" and then rename
it to "sp123DELETE" or "sp123 DELETE" or "sp123OLD" or "sp123 OLD" and
what I end up with is four entries in the output file all having the
stored procedure name "sp123."

I stop the service and restart before outputting the file.

Any help is appreciated.

lq

Function ExportSP(myPath As String)

Dim objSQLServer As New SQLDMO.SQLServer
Dim dbs As New SQLDMO.Database
Dim sp As SQLDMO.StoredProcedure
Dim sptext As String

objSQLServer.Connect <Servername>, <Username>, <Password>
Set dbs = objSQLServer.Databases(<databasename>)

Open myPath For Output As #1

For Each sp In dbs.StoredProcedures
sptext = sp.Text

Print #1, sptext & _
vbCrLf & vbCrLf & vbCrLf & _
"*******" & _
vbCrLf & vbCrLf & vbCrLf
Next

End Function


See sp_rename in Books Online - it mentions that renaming a proc does
not change the text in syscomments, so you may have problems scripting
the proc; the solution is to drop and create instead of renaming.

As a further comment, I suggest you check out the SQLDMO Script method -
it will give you a lot more control over the output and scripting
options when you generate DDL for an object.

Simon
Sep 13 '05 #2
Hi

From sp_rename documentation in BOL:
"Renaming a stored procedure, view or trigger will not change the name of
the corresponding object name in the syscomments table. This may result in
problems generating a script for the object as the old name will be inserted
from the syscomments table into the CREATE statement. For best results, do
not rename these object types. Instead, drop and re-create the object by its
new name."

John

"laurenq uantrell" <la*************@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I'm using the function below to output all of my stored procedures into
a text file. Fice, except that the output file does not reflect the
names of the stored procedures correctly if the name has been changed.

For example, I create a stored procedure named: "sp123" and then rename
it to "sp123DELETE" or "sp123 DELETE" or "sp123OLD" or "sp123 OLD" and
what I end up with is four entries in the output file all having the
stored procedure name "sp123."

I stop the service and restart before outputting the file.

Any help is appreciated.

lq

Function ExportSP(myPath As String)

Dim objSQLServer As New SQLDMO.SQLServer
Dim dbs As New SQLDMO.Database
Dim sp As SQLDMO.StoredProcedure
Dim sptext As String

objSQLServer.Connect <Servername>, <Username>, <Password>
Set dbs = objSQLServer.Databases(<databasename>)

Open myPath For Output As #1

For Each sp In dbs.StoredProcedures
sptext = sp.Text

Print #1, sptext & _
vbCrLf & vbCrLf & vbCrLf & _
"*******" & _
vbCrLf & vbCrLf & vbCrLf
Next

End Function

Sep 13 '05 #3
Ouch! This wan't a problem until I started outputting as text.

Sep 13 '05 #4
Hi

Hopefully this is a one off and you will be working with a source code
control system, therefore depending on the need for the older versions you
may want to delete or recreate them manually.

John

"laurenq uantrell" <la*************@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Ouch! This wan't a problem until I started outputting as text.

Sep 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chrisbarbers | last post by:
--part1_108.256bef7d.2c5af59f_boundary Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Hi =A0 I have purchased a package that uses ASP and SQL,...
2
by: M Wells | last post by:
Hi All, I'm wondering if anyone can tell me if it's possible to search for stored procedures by their contents? I tend to leave very descriptive notes in stored procedures and they're...
1
by: Karl | last post by:
Hi, I am trying to put SQL Server Stored Procedures into Sourcesafe as per the Microsoft Knowledge Base article 818368, but have run into a problem. The web server is SQL Server 2000 running on...
5
by: Raquel | last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it seems to run fine but returns NOTHING. I mean..as if nothing has happened..not resultset is returned. I am passing value...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
5
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored...
2
by: lauren quantrell | last post by:
I'm using the function below to output all of my stored procedures into a text file. Fice, except that the output file does not reflect the names of the stored procedures correctly if the name...
5
by: Rob Wire | last post by:
For the code below, how could I add an item in the drop down lists for both company and location to be an "All" selection that would send to the stored proc. spRptAttachments a value of "%" so...
3
by: leesquare | last post by:
Hello, I need some help getting output values from my stored procedures when using adodbapi. There's an example testVariableReturningStoredProcedure in adodbapitest.py, and that works for my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.