Showing posts with label applications. Show all posts
Showing posts with label applications. Show all posts

Friday, March 30, 2012

Running ALTER on stored procedure removes delay

Every so often we have problems running several stored procedures on our database. Specifically, our applications begin timing out. We have been able to fix the problem everytime by running an ALTER on our stored procedures. Note that the we don't change anything in the tsql, we just run ALTER. Example:
If we created the SP using:
CREATE PROCEDURE [dbo].[Test]
AS
SELECT *
FROM TABLES

running

ALTER PROCEDURE [dbo].[Test]
AS
SELECT *
FROM TABLES

will fix our timeout problem. What could running the ALTER do which which could get rid of timeout issues?

It's recompiling, or marking the procedure for re-compile.

Are there a lot of data changes on the underlying tables?

Are you keeping the stats of the tables current?

|||

hello,

when you execute a stored procedure you must write a particular thing i.e.

you must give a command in your query window for using your database.

for example,

if the database name is XYZ the

use xyz

exec test

|||

I figured it was recompiling it, but how would that effect the speed of the procedure?

The underlying tables are altered quite a bit. How do I know if the stats are being updated?

|||

If you have large amounts of data modifications then the execution plan for the SP can become out-dated.

When you recompile it a new plan is constructed based on the current information.

You can view the last update date using this:

Code Snippet

SELECT'Index Name'= i.name,'Statistics Date'=STATS_DATE(i.object_id, i.index_id)

FROMsys.objects o

JOINsys.indexes i ON o.name ='Address'AND o.object_id= i.object_id;

And you can refresh, and keep the statistics current, using the UPDATE STATISTICS statement.

BOL can give you the parameters and options.

|||How do you do that in SQL 2000? We're in the midsts of updating, but we're not quite there yet.|||

Code Snippet

SELECT'Index Name'= i.name,'Statistics Date'=STATS_DATE(i.id, i.indid)

FROMsysobjects o

JOINsysindexes i ON o.name ='Address'AND o.id = i.id;

|||If you are making major changes to the underlying structure on a continuing basis, you need to set the "RECOMPILE" option so the execution plan can be updated. Use this:

CREATE PROC name WITH RECOMPILE
AS
....

|||What do you mean by "changes to the underlying structure"? We're not changing the number of columns or adding and removing tables or indexes. Just continually adding data.|||Changing data changes the statistics on the indexes and could cause the stored execution plan to pick a "non-optimal" index. Either doing what you have been doing with "ALTER PROC" or using the "WITH RECOMPILE" will cause it to recreate the execution plan every time the proc is run, and should pick and optimal path.
sql

Wednesday, March 28, 2012

Running a system stored procedure

I write applications in VS.net that run against SQL Server 2000. I am
trying to write a stored procedure that accesses a database in different SQL
server than the one hosting the data. I entered into the FROM statement
"<OtherServerName>.<DatabaseName>.MyTable" and I get back a message that it
can't find the server "OtherServerName" and tells me to run the store
procedure "sp_addlinkedserver" to correct this. My question is:
Where do I find this sp? Do I run it from the VS.net environment, at the
console of one of the servers? What is the procedure to run it?
Any help is greatly apperceived.
Hi,
You have to create a linked server from local server when you want to access
a database resides in another SQL server. So you have to login into SQL
server
using Query Analyzer or Enterprise Manager and create a linked server.
See sp_addlinkedserver and sp_addlinkedsrvlogin in books online or use the
enterprise manager -- conenct to source sql server --
Expand the security -- select linked server and create a new connection to
new server.
Thanks
Hari
MCDBA
"Greg Smith" <gjs@.umn.edu> wrote in message
news:eJ0ZWcYdEHA.384@.TK2MSFTNGP10.phx.gbl...
> I write applications in VS.net that run against SQL Server 2000. I am
> trying to write a stored procedure that accesses a database in different
SQL
> server than the one hosting the data. I entered into the FROM statement
> "<OtherServerName>.<DatabaseName>.MyTable" and I get back a message that
it
> can't find the server "OtherServerName" and tells me to run the store
> procedure "sp_addlinkedserver" to correct this. My question is:
> Where do I find this sp? Do I run it from the VS.net environment, at the
> console of one of the servers? What is the procedure to run it?
> Any help is greatly apperceived.
>
sql

Wednesday, March 21, 2012

Run Time Error '-2147467259(80004005)':

WE have couple of applications using sql and were working
till friday 01/02/04. This morning when users are trying
to access it giveing the error Run Time Error '-2147467259
(80004005)':
Invalid connection String.
Any Idea.
Application connects to 2 sql 6.5 servers and 1 sql 2000
server. I changed the TCP/Ip ports on one of the server
in server network Utility to 1521 and changed it back to
1433 . nothing else. has changed as far as I can think
of.. please help THanks in advanceReply back with the connection string syntax.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.

Friday, March 9, 2012

run both SQL 2000 Server and SQL 2005 Express ?

I have 2 development applications, one needs SQL 2000 server to run,
another needs SQL 2005 Express to run.
Can I run both on 1 PC ?
Jeff
Jeff wrote:
> I have 2 development applications, one needs SQL 2000 server to run,
> another needs SQL 2005 Express to run.
> Can I run both on 1 PC ?
> Jeff
Forgot to mention this is all running on a Windows XP Pro SP2 with 2 GB RAM.
Jeff
|||Not problem at all.
"Jeff" <jeff@.example.net> wrote in message
news:ez8HFJKoIHA.4904@.TK2MSFTNGP03.phx.gbl...
>I have 2 development applications, one needs SQL 2000 server to run,
>another needs SQL 2005 Express to run.
> Can I run both on 1 PC ?
> Jeff

run both SQL 2000 Server and SQL 2005 Express ?

I have 2 development applications, one needs SQL 2000 server to run,
another needs SQL 2005 Express to run.
Can I run both on 1 PC ?
JeffJeff wrote:
> I have 2 development applications, one needs SQL 2000 server to run,
> another needs SQL 2005 Express to run.
> Can I run both on 1 PC ?
> Jeff
Forgot to mention this is all running on a Windows XP Pro SP2 with 2 GB RAM.
Jeff|||Not problem at all.
"Jeff" <jeff@.example.net> wrote in message
news:ez8HFJKoIHA.4904@.TK2MSFTNGP03.phx.gbl...
>I have 2 development applications, one needs SQL 2000 server to run,
>another needs SQL 2005 Express to run.
> Can I run both on 1 PC ?
> Jeff