|
hi
I have a very large database with several stored procedures. now, I need to find a stored procedure that does some calculation if that stored procedure has a string "MESSAGE"(just an example) in an IF statement somewhere down the procedure.
currently i am opening every stored procedure, doing a Ctrl+F for the above string and if i find it then that means i determine that this is the stored procedure that i will have to work with(change the calculation in it or some work)
so my question is that can i write something ... that will list me all the stored procedures which have a certain string contained in them??
I am new to sql stuff .. so please help me. this could save me a lot of time.
thanks
-messageman
|
|
|
|
|
sp_helptext is a system stored procedure which takes the name of a stored procedure and then lists it. This code will list all your stored procedure names:
SELECT name FROM sysobjects WHERE type = 'P'
So all you need to do is make a table of the names, then go through it, calling sp_helptext to get the stored procedure text, and if your text matches, return the name.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hi christian
thank you for the reply. the thing is that there are 120 stored procedures in the database and I need to know which stored procedure's BODY contains the string 'MESSAGE', etc. some stored procedures are almost 4 pages long.
I am not searching for the stored procedure named %Message%. but searching for a stored procedure whose body contains the string.
can you please give me a code sample ?
thanks
|
|
|
|
|
SELECT
ROUTINE_NAME
FROM
INFORMATION_SCHEMA.ROUTINES
WHERE
ROUTINE_DEFINITION LIKE '%MESSAGE%'
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
its_skar wrote:
the thing is that there are 120 stored procedures in the database and I need to know which stored procedure's BODY contains the string 'MESSAGE', etc. some stored procedures are almost 4 pages long.
Sure - so you need to use the code I provided to build a table that has a list of stored procedure names. Then you need to use that tempory table to step through the stored procedures, IN CODE, retrieving the text of the stored procedures, WHERE the text is LIKE %Message%.
its_skar wrote:
I am not searching for the stored procedure named %Message%. but searching for a stored procedure whose body contains the string.
That's why I gave you the name of the stored procedure that returns all the text of the procedure. You also need to get the names, otherwise, how will you know where to get the text from ?
its_skar wrote:
can you please give me a code sample ?
If I find the time tonight, I'll see what I can put together for you.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Quoting from MSDN:
"SQL Query Analyzer uses the SQL Server ODBC driver, which, by default, sets these SQL-92 options on: SET ANSI_WARNINGS, SET ANSI_PADDING, and SET ANSI_NULLS. Any errors returned are formatted as ODBC errors rather than DB-Library errors."
Is there any way to modify these options so that they are not the default?
Thanks!
|
|
|
|
|
If you mean in Query Analyzer, go to Tools/Options and change the settings on the Connection Properties tab. This affects new connections.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi,
I have a program in which I connect to MSSQL database on my system ( local host) I want to connect to a remote database on a system with particular IP. How do I do this?
Karteek
|
|
|
|
|
You don't specify what your program is written in, so I'll assume it is a language that targets the .NET Framework.
You change the connection string property of the SqlCommand object so that the part of the string that reads "Server=(local)", changes the (local), or 127.0.0.1 or whatever to the IP or machine name of the remote server.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Could someone suggest how I might best use my PalmIII w/ my laptop to emulate a network database or databases?
I need a lot of work/ SQL and .NET? (C# and C++/MFC)
Any articles, advice suggestions would be greatly appreciated. thanks
[ps- If it seems like I don't know what I'm talking about, you're right-- I don't.....]
|
|
|
|
|
You can't, simple as that. A PalmIII is only able to connect via a conduit, I believe, and certainly there is no support for SQL databases on the Palm.
Why do you need the network angle ? Just install MSDE or SQL Server on your laptop, the system will be agnostic to where the db comes from anyhow.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hello I do not have the following problem I can data to my data base add. Only if a data record is present before already in the data base, it functions. That that is appropriate for best ones owing to
void CAdoDatabaseDoc::AddNew()
{
try
{
if (m_ptrRs->Supports(adAddNew))
{
m_piAdoRecordBinding->AddNew(&m_rsRecSet);
strcpy(m_rsRecSet.m_szLastName, " " );
strcpy(m_rsRecSet.m_szFirstName, " " );
strcpy(m_rsRecSet.m_szAge, " " );
m_rsRecSet.m_dtAuswertedatum = (DATE)dtBlank;
m_rsRecSet.m_dtVersuchsdatum = (DATE)dtBlank;
}
}
....
|
|
|
|
|
hi
my problem is now that I get an empty data base entry. How does one make that correct?
thanks
|
|
|
|
|
void CAdoDatabaseDoc::AddNew()
{
try
{
// Kann ein neuer Datensatz hinzugefügt werden?
if (m_ptrRs->Supports(adAddNew))
{
m_ptrRs->AddNew();
m_ptrRs->Update();
//Leeren Datensatz hinzufügen
//m_piAdoRecordBinding->AddNew(&m_rsRecSet);
//COleDateTime dtBlank;
//strcpy(m_rsRecSet.m_szLastName, " " );
//strcpy(m_rsRecSet.m_szFirstName, " " );
//strcpy(m_rsRecSet.m_szAge, " " );
//m_rsRecSet.m_dtAuswertedatum = (DATE)dtBlank;
//m_rsRecSet.m_dtVersuchsdatum = (DATE)dtBlank;
//strcpy(m_rsRecSet.m_szLieblingsfarbe, " " );
//Aktuellen Datensatz aktualisieren
//m_piAdoRecordBinding->Update(&m_rsRecSet);
}
}
// Fehler?
catch (_com_error &e)
{
// Fehlermeldung generieren
GenerateError(e.Error(), e.Description());
}
}
|
|
|
|
|
I have something I want to clarify.
I did a .NET project some time ago and I'm not sure I remember this correctly, but I don't think I called conn.Open() whenever I want to fill a dataset.
I think I read somewhere that calling dataAdapter.Fill() will open the connection and close it right away after it fills the dataset.
If for example I have 100 datasets to fill, would it make a difference if I call conn.Open() before I tried to fill the datasets and then call conn.Close(), or should I leave it to the dataAdapter.Fill() to open and close the connection?
Which one is more efficient? Does it depend on the database server (connection pooling, etc)?
Thanks,
Edbert P.
|
|
|
|
|
EdbertP wrote:
Which one is more efficient?
While I haven't done any testing with this to determine a precise answer, from experience the first connection.Open() has a noticable delay, while subsequent Open() operations have no notiable delay. This is because the connection gets pooled and .NET is pulling the connection out of the pool rather than completely recreating it.
I would say that if timing is absolutely critical that you should Open first, then do all your Fill() operations then Close() because getting and returning a connection to the pool will still take a small amount of time.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
So I suppose that also depends on the database server you're connecting to then?
I'm assuming Access won't have such a luxury...
I'll try to implement Open before doing a whole bunch of sql operations then.
Thanks Colin!
|
|
|
|
|
EdbertP wrote:
I'm assuming Access won't have such a luxury
What luxury? If you are talking about connection pooling it is done on the .NET side - so it works for Access too.
EdbertP wrote:
I'll try to implement Open before doing a whole bunch of sql operations then.
As I said, this is if performance is absolutely critical. And if that is the case then you should also be looking at structuring everything into as few (a single, if possible) database calls. You will get a bigger performance increase over doing a single open and single close if you do that as there is less communication toing and froing between your application and the database.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Hmm...the MSDN article that I read only mentioned ".NET Framework Data Provider for SQL Server provides connection pooling automatically for your ADO.NET client application", so I assumed that it's only for SQL Server.
Thanks for the info
|
|
|
|
|
Hi Everyone,
Since my last post was so lame I thought id better explain this problem I am encountering. On SQL 6.5 doing a search data conversion from unicode to big-5 was fine no problems there. But after upgrading to SQL 2000 and doing a select in Query Analyzer the data comes up as ??? (which i am assuming is ANSII related somehow) Is there a known issue with SQL2000 doing this? Strange that on 6.5 it works fine and only after upgrading has this problem surfaced. Any help on the matter would be greatly appreciated as this is driving me nuts trying to figure out whats going on. Thanks
|
|
|
|
|
hi
I have the following code:
OleDbDataAdapter oleCmd = new OleDbDataAdapter("SELECT [Customer ID], [Customer #], [Company], [Location] FROM [Sheet1$]", oleConn);
DataSet oDS = new DataSet();
oleCmd.Fill(oDS);
The connection string is perfect. no problem with that.
It ran very good until I got this file from the client. though it has the same format and same alignment and same sheet number and etc., myprogram would fail at the FILL dataset line number.
the exception is :
System.oledb.OledbException: No value given for one or more required parameters.
seems to be a bug or something. I really cannot tell.
its erroring out in the thing that in the file they sent the first row is empty.
But, when i delete the first row and execute, program runs fine. again when i do an insert blank row at first, it still runs.
so why it didnt run at first time, and it ran ok second time.?
any format issues with excel ?
( i copied this stuff into a new excel sheet and ran prgm on that and it ran fine on that file)
I just cannot determine what is causing the error and how to resolve it.
can anyone help ?
-messageman
|
|
|
|
|
Using some code I found on MSDN I have been learning how to connect to a MSAccessDB. The code reads like this:
string DbPath = Server.MapPath("shiplist.mdb");<br />
string ConnStr;<br />
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;"+<br />
@"Data Source="+DbPath+";";
Would it not be more elegant to write it as follows:
string ConnStr="Provider=Microsoft.Jet.OLEDB.4.0" + @"Data Source="Server.MapPath("shiplist.mbd")";
Or is there some hidden pitfall that requires that I declare the directory path and DB as a string first as shown in the first example?
Best,
Jerry
I Do Whatever My Rice Krispies Tell Me To.
Toasty0.com
|
|
|
|
|
Toasty0 wrote:
Or is there some hidden pitfall that requires that I declare the directory path and DB as a string first as shown in the first example?
If you declare it in a string first then you can "watch" the value in the debugger more easily, or insert some error checking routing like checking that the file really does exist.
Also, using the + to concatenate strings is really inefficient.
If there was a small number of strings I'd use string.Concat() , or string.Format() . But for a larger number of strings I'd use a StringBuilder .
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Ahem[^]. The C# compiler turns multiple '+' operations in the same statement into a single call to string.Concat anyway.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I want empirical evidence - He just says it is "zippy"
A collegue of mine did some testing last year to determine which was the fastest between +, Concat and a StringBuilder; the + operator lost the race. So, until I see some contrary numbers I still say that the + operator is slower.
Perhaps what is happening is a+b+c+d gets converted into
string.Concat(a, string.Concat(b, string.Concat(c,d)));
As heard in the film Jerry Maguire: Show me the money!
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|