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

Tuesday, March 27, 2012

Clear the transaction log

Can someone tell me the procedure the clear out the transaction log so it
doesn't crash my server again in the future?
Thanks!
JonHow did it "crash your server"?
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Jon Glazer" <jglazer.delete.me@.adconn.com> wrote in message
news:LuA2e.456$UA4.181@.fe1.columbus.rr.com...
> Can someone tell me the procedure the clear out the transaction log so it
> doesn't crash my server again in the future?
> Thanks!
> Jon
>|||Well the procedure is to back it up on a regular basis so it can reuse the
space. Or set it to Simple recovery mode if you don't want or need Log
backups. These might be of interest:
http://www.nigelrivett.net/Transact...ileGrows_1.html Log File issues
http://www.support.microsoft.com/?id=317375 Log File Grows too big
http://www.support.microsoft.com/?id=110139 Log file filling up
http://www.mssqlserver.com/faq/logs-shrinklog.asp Shrink File
http://www.support.microsoft.com/?id=315512 Considerations for Autogrow
and AutoShrink
http://www.support.microsoft.com/?id=256650 INF: How to Shrink the SQL
Server 7.0 Tran Log
http://www.support.microsoft.com/?id=272318 INF: Shrinking Log in SQL
Server 2000 with DBCC SHRINKFILE
http://www.karaszi.com/SQLServer/info_dont_shrink.asp Shrinking
considerations
Andrew J. Kelly SQL MVP
"Jon Glazer" <jglazer.delete.me@.adconn.com> wrote in message
news:LuA2e.456$UA4.181@.fe1.columbus.rr.com...
> Can someone tell me the procedure the clear out the transaction log so it
> doesn't crash my server again in the future?
> Thanks!
> Jon
>

Clear SQl server Logs by run xp_cmdshell

how i can clear sql server logs by run xp_cmdshell stored procedure.
(my user in sql server is a admin).
i don't want use enterprise manager . i want write a query and use at xp_cmdshell .
befor thx.What logs are you talking about... SQLServer has error logs that you can cycle, the server keeps 5 logs active.

Or for the Transaction logs, you can use TQL to backup the transaction logs and truncate.

But do you use the Transaction logs, ie are you using them for Disaster recovery or such...
You can also turn off the transaction logs or at least turn them down. This is done buy changeing the databases logging method from Full (All Transactions Logged), to Bulk (Only bulk loading transactions), or Simple (No Logging).

There are also artilcles on SQLServercentral.com and MSDN on useing TSQL to shrink the logs and reduce wasted space.

Remember that All enterprise manager is is a front end for TSQL Commands to the database, all commands can be run from code.

Sunday, March 25, 2012

Cleaning unused stored procedure best practice?

I've recently inhereted an environment in which we have over 600 stored
procedures. The documentation is either very poor or non-existant and
am needing advice on how to determine if a stored procedure has been
used. Does SQL Server have any sort of ticker that indicates when a
stored procedure was last used?

Thanks and any additional information or experience would be greatly
appreciated.Unfortunately not. You could start by using Profiler to trace stored
procedure execution - that will give you a good idea of what is used
often, but of course it won't help to identify procs that are run once
a quarter or once a year.

Simon|||That's certainly better than anything I had. Although I will run this
for a month or two (we really don't have anything that runs longer
intervals), it will certainly give me the answer I need.

Thanks!

Clean up old stored procedures

Is there a way to find out if a stored procedure has not been run in a
while?
Mike W wrote:
> Is there a way to find out if a stored procedure has not been run in a
> while?
Not directly. The best you can do is create a server-side trace that
traps the SP:Starting event. You do not need to bind the TextData, only
the ObjectID, DatabaseID. Let it run until you feel you'll get the best
collection of procedures. You can resolve the object names against the
sysobjects table in each database or use object_name() for the currently
selected database.
I would obviously test the removal in the deve environment before
removing any procedures from production.
David Gugick
Imceda Software
www.imceda.com

Clean up old stored procedures

Is there a way to find out if a stored procedure has not been run in a
while?Mike W wrote:
> Is there a way to find out if a stored procedure has not been run in a
> while?
Not directly. The best you can do is create a server-side trace that
traps the SP:Starting event. You do not need to bind the TextData, only
the ObjectID, DatabaseID. Let it run until you feel you'll get the best
collection of procedures. You can resolve the object names against the
sysobjects table in each database or use object_name() for the currently
selected database.
I would obviously test the removal in the deve environment before
removing any procedures from production.
David Gugick
Imceda Software
www.imceda.comsqlsql

Clean up old stored procedures

Is there a way to find out if a stored procedure has not been run in a
while?Mike W wrote:
> Is there a way to find out if a stored procedure has not been run in a
> while?
Not directly. The best you can do is create a server-side trace that
traps the SP:Starting event. You do not need to bind the TextData, only
the ObjectID, DatabaseID. Let it run until you feel you'll get the best
collection of procedures. You can resolve the object names against the
sysobjects table in each database or use object_name() for the currently
selected database.
I would obviously test the removal in the deve environment before
removing any procedures from production.
David Gugick
Imceda Software
www.imceda.com

Clean Caches command vs recompile


Before I do performance check for stored procedure, I always clean the
caches using the following commands.
DBCC DROPCLEANBUFFERS
Go
DBCC FREEPROCCACHE
GO
But sometimes I think it's annoying as it basically purges all the caches
from the SQL server.
So if I just test one procedure's performance, I can just add 'WITH
recompile' keyword in the end, right?
is that the same thing since this way stored procedure will not use the
caches even caches exist.no, it's not the same thing. both 'with recompile' and 'dbcc freeprocbuffer'
will force recompile of the procedure, but 'dbcc dropcleanbuffers' will
purge the data cache (which is the reason it's not advisable to do it on a
production server).
dean
"Britney" <britneychen_2001@.yahoo.com> wrote in message
news:%23Ut4V3EFFHA.1084@.tk2msftngp13.phx.gbl...
>
> Before I do performance check for stored procedure, I always clean the
> caches using the following commands.
>
>
> DBCC DROPCLEANBUFFERS
> Go
> DBCC FREEPROCCACHE
> GO
>
> But sometimes I think it's annoying as it basically purges all the caches
> from the SQL server.
> So if I just test one procedure's performance, I can just add 'WITH
> recompile' keyword in the end, right?
> is that the same thing since this way stored procedure will not use the
> caches even caches exist.
>
>
>
>

Thursday, March 22, 2012

Class not registered error while using Stored procedure

Hi,

I had registered a COM DLL (CogUdf32.dll) as Assembly under the Adventure Works DW.

When i tried executing a method from it through MDX query:

SELECT

{ FILTER([Customer].[Customer].AllMembers, CogUdf32.CogInStr([Customer].[Customer].CurrentMember.Name,"USA") > 0) }

ON AXIS(0)

FROM [Adventure Works];

I am getting following error:

The following system error occurred: Class not registered .

Any pointers are welcome.

Thanks and Regards,
Santosh.

COM UDF's are turned off by default due to the security concerns.

It is better practice and it is safer to write your UDF's in .NET language and compile them as assemblies. But if you still need your COM UDF go to the "SQL Surface Area Configuration" tool avaliable through the start menu shortcut and enable COM UDF for Analysis Services.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

MY UDF's are written in .NET language. I am able to add them as COM DLL under Assemblies. But when i try to use the functions, i am getting these errors:

MDX:
SELECT
{ FILTER([Measures].[Sales Amount], CogUdf32.CogInStr([Measures].[Sales Amount],"*", 0) > 0) }
ON AXIS(0)
FROM [Adventure Works]

Error: The following system error occurred: Class not registered .

MDX:
SELECT
{ FILTER([Measures].[Sales Amount], CogUdf32.CCogRExp.CogInStr([Measures].[Sales Amount],"*", 0) > 0) }
ON AXIS(0)
FROM [Adventure Works]

Error: Query (2, 37) The '[CogUdf32].[CCogRExp].[CogInStr]' function does not exist.

Is there any method to find the registered classes/functions for the Assemblies added in Analysis Service.

Clarifications on Queue Service and Queue Readers

Hello,
This is info that I am still not certain about and I just need to make sure, my gut feeling is correct:

A.
When a procedure is triggered upon reception of a message in a queue, what happens when the procedure fails and rolls back?
1. Message is left on the Queue.
2. is the worker procedure triggered again for the same message by the queue?
3. I am hoping the Queue keeps on triggering workers until it is empty.

My scenario is that my queue reader procedure only reads one message at a time, thus I do not loop to receive many messages.

B.
For my scenario messages are independent and ordering does not matter.
Thus I want to ensure my Queue reader procedures execute simultaneously. Is reading the Top message in one reader somehow blocking the queue for any other reader procedures? I.e. if I have BEGIN TRANSACTION when reading messages of the Queue, is that effectively going prevent many reader procedures working simultaneously. Again, I want to ensure that Service broker is effectively spawning procedures that work simultaneously.

Thank you very much for the time,

LubomirOnly reading one message per invocation will together slow down you application enough so that the other things you're worried about will probably be minor by comparison. As long as there are enough seperate dialogs so that there's at least one dialog per queue read you should see parallelism because a receive only locks one conversation group. If I understand what you're doing you will have one one dialog per conversation group so you will lock on one dialog per transaction.|||

Hello,

A. Service Broker functionality is entirely driven by the normal transactional operations rules of SQL Server. All effects of any Service Broker verbs (BEGIN DIALOG, SEND, RECEIVE, END CONVERSATION etc) will be undone if the transaction is rolled back. So if a queue reder rollsback a RECEIVE, the messages will be back in the queue, available again for activation. Be careful dough, if you activated stored procedure rollsback frequently, you are in danger of triggering poison message detection mechanism. If the activated procedure rollsback the RECEIVE verb result 5 times in a row, the whole queue will be disabled. For details, see http://msdn2.microsoft.com/en-us/library/ms166137.aspx

And yes, queue readers will continue to be activated as long as there are messages in the queue available for receive. Also, queue readers will be activated each time a database comes online, like at server start up.

B. Queue readers can progress in paralel as long as there are multiple conversations available for processing. RECEIVE verb will lock the conversations on which it returned messages, so that no other queue reader processes messages from the same conversation(s). for more details, see the 'Conversation groups' topic in BOL, at http://msdn2.microsoft.com/en-us/library/ms166131(en-US,SQL.90).aspx

HTH,
~ Remus

|||Thank you very much for the prompt replies guys.
This makes perfect sense.

Lubomir

Clarifications on Queue Service and Queue Readers

Hello,
This is info that I am still not certain about and I just need to make sure, my gut feeling is correct:

A.
When a procedure is triggered upon reception of a message in a queue, what happens when the procedure fails and rolls back?
1. Message is left on the Queue.
2. is the worker procedure triggered again for the same message by the queue?
3. I am hoping the Queue keeps on triggering workers until it is empty.

My scenario is that my queue reader procedure only reads one message at a time, thus I do not loop to receive many messages.

B.
For my scenario messages are independent and ordering does not matter.
Thus I want to ensure my Queue reader procedures execute simultaneously. Is reading the Top message in one reader somehow blocking the queue for any other reader procedures? I.e. if I have BEGIN TRANSACTION when reading messages of the Queue, is that effectively going prevent many reader procedures working simultaneously. Again, I want to ensure that Service broker is effectively spawning procedures that work simultaneously.

Thank you very much for the time,

LubomirOnly reading one message per invocation will together slow down you application enough so that the other things you're worried about will probably be minor by comparison. As long as there are enough seperate dialogs so that there's at least one dialog per queue read you should see parallelism because a receive only locks one conversation group. If I understand what you're doing you will have one one dialog per conversation group so you will lock on one dialog per transaction.|||

Hello,

A. Service Broker functionality is entirely driven by the normal transactional operations rules of SQL Server. All effects of any Service Broker verbs (BEGIN DIALOG, SEND, RECEIVE, END CONVERSATION etc) will be undone if the transaction is rolled back. So if a queue reder rollsback a RECEIVE, the messages will be back in the queue, available again for activation. Be careful dough, if you activated stored procedure rollsback frequently, you are in danger of triggering poison message detection mechanism. If the activated procedure rollsback the RECEIVE verb result 5 times in a row, the whole queue will be disabled. For details, see http://msdn2.microsoft.com/en-us/library/ms166137.aspx

And yes, queue readers will continue to be activated as long as there are messages in the queue available for receive. Also, queue readers will be activated each time a database comes online, like at server start up.

B. Queue readers can progress in paralel as long as there are multiple conversations available for processing. RECEIVE verb will lock the conversations on which it returned messages, so that no other queue reader processes messages from the same conversation(s). for more details, see the 'Conversation groups' topic in BOL, at http://msdn2.microsoft.com/en-us/library/ms166131(en-US,SQL.90).aspx

HTH,
~ Remus

|||Thank you very much for the prompt replies guys.
This makes perfect sense.

Lubomirsqlsql

Tuesday, March 20, 2012

Clarification of execution in SQL2000 SP3A

Hi,
I need some clarification of a situation that we now have when moving to
SP3A. If we try and execute a stored procedure from another database it runs
on the database the stored procedure belongs to.
e.g. USE DatabaseA
Execute DatabaseB.dbo.upRunsp
The sp upRunsp will run on DatabaseB not DatabaseA
Is this an effect of cross DB ownership chaining being set off?
Thanks
Chris Wood
Alberta Department of Energy
CANADA
"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:e7MpPTmTEHA.1168@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I need some clarification of a situation that we now have when moving to
> SP3A. If we try and execute a stored procedure from another database it
runs
> on the database the stored procedure belongs to.
> e.g. USE DatabaseA
> Execute DatabaseB.dbo.upRunsp
> The sp upRunsp will run on DatabaseB not DatabaseA
> Is this an effect of cross DB ownership chaining being set off?
>
No. This has nothing to do with cross DB ownership chaining. When you
EXECUTE a procedure using a database-qualified name, the object names inside
the procedure are resolved of wrt the procedure's owner. When you run it
without qualifation, names are resolved wrt your current context.
compare the output of
EXECUTE sp_help --displays info about the currentdb.dbo.sysobjects
and
EXECUTE master.dbo.sp_help --displays info about master.dbo.sysobjects
And the only way to run a procedure in another database without a
database-qualified name is to put it in Master and prefix it with sp_. So
the only way to have one procedure run against different databases is to put
it in Master and prefix it with sp_.
David
|||David,
Did the behaviour change between Gold and SP3A?
Chris
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%238Lp6gmTEHA.2128@.TK2MSFTNGP11.phx.gbl...
> "Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
> news:e7MpPTmTEHA.1168@.TK2MSFTNGP11.phx.gbl...
> runs
> No. This has nothing to do with cross DB ownership chaining. When you
> EXECUTE a procedure using a database-qualified name, the object names
inside
> the procedure are resolved of wrt the procedure's owner. When you run it
> without qualifation, names are resolved wrt your current context.
> compare the output of
> EXECUTE sp_help --displays info about the currentdb.dbo.sysobjects
> and
> EXECUTE master.dbo.sp_help --displays info about master.dbo.sysobjects
> And the only way to run a procedure in another database without a
> database-qualified name is to put it in Master and prefix it with sp_. So
> the only way to have one procedure run against different databases is to
put
> it in Master and prefix it with sp_.
> David
>
>
|||"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:eTVRjlmTEHA.1472@.TK2MSFTNGP12.phx.gbl...
> David,
> Did the behaviour change between Gold and SP3A?
>
This behavior has been like that since at least 6.5.
David
|||David,
Just debugged this one better. Under SP2 if the default database is the one
you are on you can run xp_sendmail from master, while you are on your
default database, and look at a table on your default database without
needing to fully qualify it.
e.g. on DatabaseA
exec master..xp_sendmail @.recipients = '...',
@.query = 'SELECT FROM tablea where
This will work.
Under SP3A it gives an ODBC error 208 (42S02) unless I change the SELECT to
DatabaseA.dbo.tablea
We are using build 818 for testing.
Chris
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:eGGxE0mTEHA.760@.TK2MSFTNGP12.phx.gbl...
> "Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
> news:eTVRjlmTEHA.1472@.TK2MSFTNGP12.phx.gbl...
> This behavior has been like that since at least 6.5.
> David
>
|||Also. This only works this way if the database is your default database. It
does not matter about the permissions of the user just its default database
setting.
Chris
"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:e2yXy9xTEHA.2464@.TK2MSFTNGP10.phx.gbl...
> David,
> Just debugged this one better. Under SP2 if the default database is the
one
> you are on you can run xp_sendmail from master, while you are on your
> default database, and look at a table on your default database without
> needing to fully qualify it.
> e.g. on DatabaseA
> exec master..xp_sendmail @.recipients = '...',
> @.query = 'SELECT FROM tablea where
> This will work.
> Under SP3A it gives an ODBC error 208 (42S02) unless I change the SELECT
to
> DatabaseA.dbo.tablea
> We are using build 818 for testing.
> Chris
> "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> message news:eGGxE0mTEHA.760@.TK2MSFTNGP12.phx.gbl...
>
|||"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:O8LPRQyTEHA.808@.tk2msftngp13.phx.gbl...
> Also. This only works this way if the database is your default database.
It
> does not matter about the permissions of the user just its default
database
> setting.
>
Ahh. xp_sendmail executes that query over a different connection created
from within the extended stored procedure, but bound into the same
transaction. Normal rules of name resolution don't apply here, as it
depends entirely on how xp_sendmail creates the second connection and what
database it connects to. Perhaps there was a change to the implementation
of xp_sendmail in SP3.
David
|||Are all of the objects needed in the same database on the same server? We
had "cross database ownership" introduced in sp3. Is this checked?
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.
|||Vikram,
I thought that this may have been the problem but it is not. We have a
stored procedure in database A that included a xp_sendmail with a query that
ran against a table in database A. Prior to SP3 we did not have to fully
qualify the table in database A. Fully qualifying works for both SP2 and SP3
and that is what we had to do.
Thanks
Chris
"Vikram Jayaram [MS]" <vikramj@.online.microsoft.com> wrote in message
news:O%23j3ZkNXEHA.328@.cpmsftngxa10.phx.gbl...
> Are all of the objects needed in the same database on the same server? We
> had "cross database ownership" introduced in sp3. Is this checked?
>
> Vikram Jayaram
> Microsoft, SQL Server
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.
>
|||Vikram,
I thought that this may have been the problem but it is not. We have a
stored procedure in database A that included a xp_sendmail with a query that
ran against a table in database A. Prior to SP3 we did not have to fully
qualify the table in database A. Fully qualifying works for both SP2 and SP3
and that is what we had to do.
Thanks
Chris
"Vikram Jayaram [MS]" <vikramj@.online.microsoft.com> wrote in message
news:O%23j3ZkNXEHA.328@.cpmsftngxa10.phx.gbl...
> Are all of the objects needed in the same database on the same server? We
> had "cross database ownership" introduced in sp3. Is this checked?
>
> Vikram Jayaram
> Microsoft, SQL Server
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.
>
sqlsql

Clarification of execution in SQL2000 SP3A

Hi,
I need some clarification of a situation that we now have when moving to
SP3A. If we try and execute a stored procedure from another database it runs
on the database the stored procedure belongs to.
e.g. USE DatabaseA
Execute DatabaseB.dbo.upRunsp
The sp upRunsp will run on DatabaseB not DatabaseA
Is this an effect of cross DB ownership chaining being set off?
Thanks
Chris Wood
Alberta Department of Energy
CANADA"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:e7MpPTmTEHA.1168@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I need some clarification of a situation that we now have when moving to
> SP3A. If we try and execute a stored procedure from another database it
runs
> on the database the stored procedure belongs to.
> e.g. USE DatabaseA
> Execute DatabaseB.dbo.upRunsp
> The sp upRunsp will run on DatabaseB not DatabaseA
> Is this an effect of cross DB ownership chaining being set off?
>
No. This has nothing to do with cross DB ownership chaining. When you
EXECUTE a procedure using a database-qualified name, the object names inside
the procedure are resolved of wrt the procedure's owner. When you run it
without qualifation, names are resolved wrt your current context.
compare the output of
EXECUTE sp_help --displays info about the currentdb.dbo.sysobjects
and
EXECUTE master.dbo.sp_help --displays info about master.dbo.sysobjects
And the only way to run a procedure in another database without a
database-qualified name is to put it in Master and prefix it with sp_. So
the only way to have one procedure run against different databases is to put
it in Master and prefix it with sp_.
David|||David,
Did the behaviour change between Gold and SP3A?
Chris
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%238Lp6gmTEHA.2128@.TK2MSFTNGP11.phx.gbl...
> "Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
> news:e7MpPTmTEHA.1168@.TK2MSFTNGP11.phx.gbl...
> runs
> No. This has nothing to do with cross DB ownership chaining. When you
> EXECUTE a procedure using a database-qualified name, the object names
inside
> the procedure are resolved of wrt the procedure's owner. When you run it
> without qualifation, names are resolved wrt your current context.
> compare the output of
> EXECUTE sp_help --displays info about the currentdb.dbo.sysobjects
> and
> EXECUTE master.dbo.sp_help --displays info about master.dbo.sysobjects
> And the only way to run a procedure in another database without a
> database-qualified name is to put it in Master and prefix it with sp_. So
> the only way to have one procedure run against different databases is to
put
> it in Master and prefix it with sp_.
> David
>
>|||"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:eTVRjlmTEHA.1472@.TK2MSFTNGP12.phx.gbl...
> David,
> Did the behaviour change between Gold and SP3A?
>
This behavior has been like that since at least 6.5.
David|||David,
Just debugged this one better. Under SP2 if the default database is the one
you are on you can run xp_sendmail from master, while you are on your
default database, and look at a table on your default database without
needing to fully qualify it.
e.g. on DatabaseA
exec master..xp_sendmail @.recipients = '...',
@.query = 'SELECT FROM tablea where
This will work.
Under SP3A it gives an ODBC error 208 (42S02) unless I change the SELECT to
DatabaseA.dbo.tablea
We are using build 818 for testing.
Chris
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:eGGxE0mTEHA.760@.TK2MSFTNGP12.phx.gbl...
> "Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
> news:eTVRjlmTEHA.1472@.TK2MSFTNGP12.phx.gbl...
> This behavior has been like that since at least 6.5.
> David
>|||Also. This only works this way if the database is your default database. It
does not matter about the permissions of the user just its default database
setting.
Chris
"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:e2yXy9xTEHA.2464@.TK2MSFTNGP10.phx.gbl...
> David,
> Just debugged this one better. Under SP2 if the default database is the
one
> you are on you can run xp_sendmail from master, while you are on your
> default database, and look at a table on your default database without
> needing to fully qualify it.
> e.g. on DatabaseA
> exec master..xp_sendmail @.recipients = '...',
> @.query = 'SELECT FROM tablea where
> This will work.
> Under SP3A it gives an ODBC error 208 (42S02) unless I change the SELECT
to
> DatabaseA.dbo.tablea
> We are using build 818 for testing.
> Chris
> "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> message news:eGGxE0mTEHA.760@.TK2MSFTNGP12.phx.gbl...
>|||"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:O8LPRQyTEHA.808@.tk2msftngp13.phx.gbl...
> Also. This only works this way if the database is your default database.
It
> does not matter about the permissions of the user just its default
database
> setting.
>
Ahh. xp_sendmail executes that query over a different connection created
from within the extended stored procedure, but bound into the same
transaction. Normal rules of name resolution don't apply here, as it
depends entirely on how xp_sendmail creates the second connection and what
database it connects to. Perhaps there was a change to the implementation
of xp_sendmail in SP3.
David|||Are all of the objects needed in the same database on the same server? We
had "cross database ownership" introduced in sp3. Is this checked?
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.|||Vikram,
I thought that this may have been the problem but it is not. We have a
stored procedure in database A that included a xp_sendmail with a query that
ran against a table in database A. Prior to SP3 we did not have to fully
qualify the table in database A. Fully qualifying works for both SP2 and SP3
and that is what we had to do.
Thanks
Chris
"Vikram Jayaram [MS]" <vikramj@.online.microsoft.com> wrote in message
news:O%23j3ZkNXEHA.328@.cpmsftngxa10.phx.gbl...
> Are all of the objects needed in the same database on the same server? We
> had "cross database ownership" introduced in sp3. Is this checked?
>
> Vikram Jayaram
> Microsoft, SQL Server
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.
>

Clarification of execution in SQL2000 SP3A

Hi,
I need some clarification of a situation that we now have when moving to
SP3A. If we try and execute a stored procedure from another database it runs
on the database the stored procedure belongs to.
e.g. USE DatabaseA
Execute DatabaseB.dbo.upRunsp
The sp upRunsp will run on DatabaseB not DatabaseA
Is this an effect of cross DB ownership chaining being set off?
Thanks
Chris Wood
Alberta Department of Energy
CANADA"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:e7MpPTmTEHA.1168@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I need some clarification of a situation that we now have when moving to
> SP3A. If we try and execute a stored procedure from another database it
runs
> on the database the stored procedure belongs to.
> e.g. USE DatabaseA
> Execute DatabaseB.dbo.upRunsp
> The sp upRunsp will run on DatabaseB not DatabaseA
> Is this an effect of cross DB ownership chaining being set off?
>
No. This has nothing to do with cross DB ownership chaining. When you
EXECUTE a procedure using a database-qualified name, the object names inside
the procedure are resolved of wrt the procedure's owner. When you run it
without qualifation, names are resolved wrt your current context.
compare the output of
EXECUTE sp_help --displays info about the currentdb.dbo.sysobjects
and
EXECUTE master.dbo.sp_help --displays info about master.dbo.sysobjects
And the only way to run a procedure in another database without a
database-qualified name is to put it in Master and prefix it with sp_. So
the only way to have one procedure run against different databases is to put
it in Master and prefix it with sp_.
David|||David,
Did the behaviour change between Gold and SP3A?
Chris
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%238Lp6gmTEHA.2128@.TK2MSFTNGP11.phx.gbl...
> "Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
> news:e7MpPTmTEHA.1168@.TK2MSFTNGP11.phx.gbl...
> > Hi,
> >
> > I need some clarification of a situation that we now have when moving to
> > SP3A. If we try and execute a stored procedure from another database it
> runs
> > on the database the stored procedure belongs to.
> >
> > e.g. USE DatabaseA
> > Execute DatabaseB.dbo.upRunsp
> >
> > The sp upRunsp will run on DatabaseB not DatabaseA
> >
> > Is this an effect of cross DB ownership chaining being set off?
> >
> No. This has nothing to do with cross DB ownership chaining. When you
> EXECUTE a procedure using a database-qualified name, the object names
inside
> the procedure are resolved of wrt the procedure's owner. When you run it
> without qualifation, names are resolved wrt your current context.
> compare the output of
> EXECUTE sp_help --displays info about the currentdb.dbo.sysobjects
> and
> EXECUTE master.dbo.sp_help --displays info about master.dbo.sysobjects
> And the only way to run a procedure in another database without a
> database-qualified name is to put it in Master and prefix it with sp_. So
> the only way to have one procedure run against different databases is to
put
> it in Master and prefix it with sp_.
> David
>
>|||"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:eTVRjlmTEHA.1472@.TK2MSFTNGP12.phx.gbl...
> David,
> Did the behaviour change between Gold and SP3A?
>
This behavior has been like that since at least 6.5.
David|||David,
Just debugged this one better. Under SP2 if the default database is the one
you are on you can run xp_sendmail from master, while you are on your
default database, and look at a table on your default database without
needing to fully qualify it.
e.g. on DatabaseA
exec master..xp_sendmail @.recipients = '...',
@.query = 'SELECT FROM tablea where
This will work.
Under SP3A it gives an ODBC error 208 (42S02) unless I change the SELECT to
DatabaseA.dbo.tablea
We are using build 818 for testing.
Chris
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:eGGxE0mTEHA.760@.TK2MSFTNGP12.phx.gbl...
> "Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
> news:eTVRjlmTEHA.1472@.TK2MSFTNGP12.phx.gbl...
> > David,
> >
> > Did the behaviour change between Gold and SP3A?
> >
> This behavior has been like that since at least 6.5.
> David
>|||Also. This only works this way if the database is your default database. It
does not matter about the permissions of the user just its default database
setting.
Chris
"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:e2yXy9xTEHA.2464@.TK2MSFTNGP10.phx.gbl...
> David,
> Just debugged this one better. Under SP2 if the default database is the
one
> you are on you can run xp_sendmail from master, while you are on your
> default database, and look at a table on your default database without
> needing to fully qualify it.
> e.g. on DatabaseA
> exec master..xp_sendmail @.recipients = '...',
> @.query = 'SELECT FROM tablea where
> This will work.
> Under SP3A it gives an ODBC error 208 (42S02) unless I change the SELECT
to
> DatabaseA.dbo.tablea
> We are using build 818 for testing.
> Chris
> "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> message news:eGGxE0mTEHA.760@.TK2MSFTNGP12.phx.gbl...
> >
> > "Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
> > news:eTVRjlmTEHA.1472@.TK2MSFTNGP12.phx.gbl...
> > > David,
> > >
> > > Did the behaviour change between Gold and SP3A?
> > >
> >
> > This behavior has been like that since at least 6.5.
> >
> > David
> >
> >
>|||"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:O8LPRQyTEHA.808@.tk2msftngp13.phx.gbl...
> Also. This only works this way if the database is your default database.
It
> does not matter about the permissions of the user just its default
database
> setting.
>
Ahh. xp_sendmail executes that query over a different connection created
from within the extended stored procedure, but bound into the same
transaction. Normal rules of name resolution don't apply here, as it
depends entirely on how xp_sendmail creates the second connection and what
database it connects to. Perhaps there was a change to the implementation
of xp_sendmail in SP3.
David|||Are all of the objects needed in the same database on the same server? We
had "cross database ownership" introduced in sp3. Is this checked?
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.|||Vikram,
I thought that this may have been the problem but it is not. We have a
stored procedure in database A that included a xp_sendmail with a query that
ran against a table in database A. Prior to SP3 we did not have to fully
qualify the table in database A. Fully qualifying works for both SP2 and SP3
and that is what we had to do.
Thanks
Chris
"Vikram Jayaram [MS]" <vikramj@.online.microsoft.com> wrote in message
news:O%23j3ZkNXEHA.328@.cpmsftngxa10.phx.gbl...
> Are all of the objects needed in the same database on the same server? We
> had "cross database ownership" introduced in sp3. Is this checked?
>
> Vikram Jayaram
> Microsoft, SQL Server
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.
>

Friday, February 24, 2012

checking success of a request in a stored procedure

Hi,
Say I have a stored procedure which does two INSERT operation.
How can I check if the first INSERT succeeded in order to know if I
should carry on and do the second one ?

RegardsYou can check @.@.ERROR to see if an error was raised, or @.@.ROWCOUNT to
see how many rows were inserted - in some cases you might consider it
an error if no rows were inserted.

See here for much more information:

http://www.sommarskog.se/error-handling-II.html

Simon

Checking publications are subscribed to all subscribers

Hi All
How can I checked the publication are subscribed to all subscribers?
is there any stored procedure or method to do this?
Thanks alot
Tolga
Message posted via http://www.sqlmonster.com
Actually I found a script in internet like this, but its complicated to
understand...I could not understand how it works.. what are the comments at
the begining?
You can look the script at the following link...
http://www.selectstar.co.uk/kb/repli...umplog152.html
Can u explain this procedure?
Thanks
Tolga
Message posted via http://www.sqlmonster.com
|||The comments presumably just represent the trend of
thinking of the developer. Basically the code is a cursor
to loop through the list of publications and will check
that subscriber 'NY1325CMISRESM2' subscribes to each
publication. Note that each publication is iterated,
while the subscriber is hardcoded, so it doesn't really
do what it says on the tin
Rgds,
Paul Ibison

Sunday, February 19, 2012

Checking job status using SQL-DMO

I have a question I hope someone can help me with.

My situation:
I have a single-step job in SQL Server, which runs a stored procedure, A. This stored procedure invokes another stored procedure, B. In B, one of the statements is a 'BACKUP DATABASE' command, and a database is backed up to a file.

The job is started by an application. Once started, the application then uses the SQL-DMO property CurrentRunStatus to periodically check the status of the job. When the property returns the value SQLDMOJobExecution_Idle (indicating the job has completed), the application code then continues processing, and attempts to access the .dat file produced by the 'BACKUP DATABASE' command.

My problem:
On occasion, the application will hit the problem where either the backup file cannot be located, or the file is still being locked by another process (Error=The process cannot access the file because it is being used by another process).

Is anyone able to shed some light on this?

I assume that the job will only return a completed status after:
(a) both A and B have completed execution, and
(b) the BACKUP operation has completed

Is it possible that even though SQL Server indicates the job has finished, that the BACKUP operation still hasn't completely ended?

Thanks for any help,
AndrewDoesn't anyone have any ideas?

Should I be posting this elsewhere instead?|||Will VB/VBA (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sqldmo/dmoref_ex02_1gv7.asp) do?

-PatP

Checking is updation successfull

I am updating a table in store procedure. I want to check whether the statement has successfully updated the table or not. i know in mySql i can handle it using ROW_COUNT() function. but how can i do it in MS-SQL?You can use @.@.ROWCOUNT for getting number of rows affected by the last statement.|||Hey, thanks man... you saved my time on Google :)

Checking if String is NULL or EMPTY in SQL

I need to check in my Stored procedure if the information passed is null or empty so I can decided to insert the new value or keep the old. How do I accomplish this please in T-SQL. Thanks in advance.

IFISNULL(@.param)OR @.param =''THEN doSomething...
(Note the two apostrophes ' and ', not a quote mark!)
|||

Books online (help files that comes with SQL) is an amzing little app. Below is an example and the Syntax.

USE pubsGOSELECTAVG(ISNULL(price, $10.00))FROM titlesGOISNULL ( check_expression , replacement_value )
|||

Create Procedure mySpNameHere

@.InputValueHere VARCHAR(50) = NULL

AS

IF @.InputValue IS NULL OR @.InputValue = ''

/*Keep the old value*/

ELSE

/*Run the update statement here with your new value*/

|||

cheetahtech:

ISNULL ( check_expression , replacement_value )

Sorry. I got a blackout. Of course, ISNULL syntax is to be used in a query where you want to specify an alternative value, if the expression is NULL.

The correct way to check for NULL in a condition is IF @.Param IS NULL as rich freeman points out.

checking if a view is partitioned

Given a view can i check, using a query or stored procedure, if it is a
partitioned view or not ?
thanks
--
Vivek T S
Member Technical Staff (Inucom)select objectproperty(object_id('myview'),'isindexed')
1 for true
0 for false
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Vivek T S" <VivekTS@.discussions.microsoft.com> wrote in message
news:2D4F830B-BB6C-4EBC-A2D9-D1F6C6C03DC0@.microsoft.com...
> Given a view can i check, using a query or stored procedure, if it is a
> partitioned view or not ?
> thanks
> --
> Vivek T S
> Member Technical Staff (Inucom)

checking if a view is partitioned

Given a view can i check, using a query or stored procedure, if it is a
partitioned view or not ?
thanks
Vivek T S
Member Technical Staff (Inucom)
select objectproperty(object_id('myview'),'isindexed')
1 for true
0 for false
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Vivek T S" <VivekTS@.discussions.microsoft.com> wrote in message
news:2D4F830B-BB6C-4EBC-A2D9-D1F6C6C03DC0@.microsoft.com...
> Given a view can i check, using a query or stored procedure, if it is a
> partitioned view or not ?
> thanks
> --
> Vivek T S
> Member Technical Staff (Inucom)