Showing posts with label procedures. Show all posts
Showing posts with label procedures. Show all posts

Friday, March 9, 2012

Definition of Object Has Changed Since it was last compiles

All I'm having a weird problem.. I have 2 stored procedures that run 98% of the time without any issue but inconsistenly through the following error.

'The definition of object 'proc name goes here' has changed since it was compiled'

We have adding 'with recompile' to the proc but we still get this error - but not consistently. The stored proc is not changing nor is the table structure of any of the objects that are being used in the sp. Any idea to trace down the why this is happening or what objecte it thinks is changing? Let me know your thoughts.

Ken

We've started experiencing this, except:
- It's occurring 100% of the time on SQL 2K5, for a particular data set, but not for another data set on the same schema.
- It never occurred in SQL 2K.
- It only occurs on SQL 2K5 (w/ DB in 2K compatibility mode)

My first reaction, for our case, is that it's a broken 2K5/2K compatibility issue. We're doing something pretty shady - disabling a trigger on table B from within a trigger firing on table A. IOW:

Trigger A, Table A:
- Disable trigger B on table B
- UPDATE table B
- Re-enable trigger B

So I'm guessing SQL 2K5 is finally calling us out on this. But I'd still prefer a quick fix to rewriting the triggers. Have you had any luck with your issue?

Friday, February 17, 2012

Default User

What do I need to configure to make the sql tables and stored procedures I
create, be dbo owned, rather than owned by my id.
I can change the owner in each wizard, or create code, but I usually forget
and have to re do it.
PaulPaul
BOL says
The dbo is a user that has implied permissions to perform all activities in
the database. Any member of the sysadmin fixed server role who uses a
database is mapped to the special user inside each database called dbo.
Also, any object created by any member of the sysadmin fixed server role
belongs to dbo automatically.
For example, if user Andrew is a member of the sysadmin fixed server role
and creates a table T1, T1 belongs to dbo and is qualified as dbo.T1, not as
Andrew.T1. Conversely, if Andrew is not a member of the sysadmin fixed
server role but is a member only of the db_owner fixed database role and
creates a table T1, T1 belongs to Andrew and is qualified as Andrew.T1. The
table belongs to Andrew because he did not qualify the table as dbo.T1.
The dbo user cannot be deleted and is always present in every database.
Only objects created by members of the sysadmin fixed server role (or by the
dbo user) belong to dbo. Objects created by any other user who is not also a
member of the sysadmin fixed server role (including members of the db_owner
fixed database role):
a.. Belong to the user creating the object, not dbo.
b.. Are qualified with the name of the user who created the object.
"Paul" <nothanks@.btopenworld.com> wrote in message
news:7emdnYdtfvLVyqXbnZ2dnUVZ8v-dnZ2d@.bt.com...
> What do I need to configure to make the sql tables and stored procedures I
> create, be dbo owned, rather than owned by my id.
> I can change the owner in each wizard, or create code, but I usually
> forget and have to re do it.
> Paul
>|||Paul (nothanks@.btopenworld.com) writes:
> What do I need to configure to make the sql tables and stored procedures I
> create, be dbo owned, rather than owned by my id.
> I can change the owner in each wizard, or create code, but I usually
> forget and have to re do it.
Which version of SQL Server are you on? If you are on SQL 2000, the
only way out is to make yourself the database owner. On SQL 2005, you
can use ALTER USER to change your default schema.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns992546452A53Yazorman@.127.0.0.1...
> Paul (nothanks@.btopenworld.com) writes:
> Which version of SQL Server are you on? If you are on SQL 2000, the
> only way out is to make yourself the database owner. On SQL 2005, you
> can use ALTER USER to change your default schema.
>
I am using SQL2000, and I am a member of the db_owner role, but wizards and
not using the owner name defaults to my own id rather than dbo.|||BOL
I am using SQL2000, and con not see a sysadmin role to add myself too. I am
a member of the db_owner Role.
Paul
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23InYO1JjHHA.4064@.TK2MSFTNGP02.phx.gbl...
> Paul
> BOL says
> The dbo is a user that has implied permissions to perform all activities
> in the database. Any member of the sysadmin fixed server role who uses a
> database is mapped to the special user inside each database called dbo.
> Also, any object created by any member of the sysadmin fixed server role
> belongs to dbo automatically.
> For example, if user Andrew is a member of the sysadmin fixed server role
> and creates a table T1, T1 belongs to dbo and is qualified as dbo.T1, not
> as Andrew.T1. Conversely, if Andrew is not a member of the sysadmin fixed
> server role but is a member only of the db_owner fixed database role and
> creates a table T1, T1 belongs to Andrew and is qualified as Andrew.T1.
> The table belongs to Andrew because he did not qualify the table as
> dbo.T1.
> The dbo user cannot be deleted and is always present in every database.
> Only objects created by members of the sysadmin fixed server role (or by
> the dbo user) belong to dbo. Objects created by any other user who is not
> also a member of the sysadmin fixed server role (including members of the
> db_owner fixed database role):
> a.. Belong to the user creating the object, not dbo.
>
> b.. Are qualified with the name of the user who created the object.
> "Paul" <nothanks@.btopenworld.com> wrote in message
> news:7emdnYdtfvLVyqXbnZ2dnUVZ8v-dnZ2d@.bt.com...
>|||Members of db_owner and db_ddladmin can create objects owned
by dbo but they have to qualify the objects when creating
them. On 2000, you can't change that behavior. Members of
sysadmins server role will have their objects default to the
dbo owner.
You have to be a member of sysadmins to add a login to
sysadmins.
-Sue
On Wed, 9 May 2007 13:58:38 +0100, "Paul"
<nothanks@.btopenworld.com> wrote:

>"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
>news:Xns992546452A53Yazorman@.127.0.0.1...
>I am using SQL2000, and I am a member of the db_owner role, but wizards and
>not using the owner name defaults to my own id rather than dbo.
>

Default Stored Procedures

After a recent audit on our SQL servers, it was
recommended that we remove the following default
procedures where possible. I have not seen any security
checklists on removing these procedures. Should I remove
these if they are not needed? How are they removed? Thanks
for your help.
Xp_CmdShell
Sp_OACreate
Sp_OADestroy
Sp_OAGetErrorInfo
Sp_OAGetProperty
Sp_OAMethod
Sp_OASetProperty
Sp_OAStop
Xp_regaddmultistring
Xp_regdeletekey
Xp_regdeletevalue
Xp_regenumvalues
Xp_regread
Xp_regremovemultistring
Xp_regwriteMost of the extended stored procedures you listed above are considered dange
rous and could leave your installation and server prone to attack. You can
drop” extended stored procedures with the sp_DropExtendedProc system sto
red procedure and then actu
ally deleting the dll from the server.
Try reading SQL Server Security by Chip Andrews, David Litchfield, and bill
Grindlay (Osborne Press) Chapter 9 and Appendix A
Randy Dyess
www.Database-Security.Info|||There is no official Microsoft guidance on the removal of these stored
procedures. If you decide to remove these stored procedures, then you
should verify in a test environment prior to attempting this on a
production machine.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.

Tuesday, February 14, 2012

Default Schema within storded procedure

I'm migrating a dotnetnuke website from SQL Server 2000 to SQL Server 2005 and have run into a problem with one of the stored procedures.

The database objects seem to have upgraded successfully to use the db schema identifer from the dbowner identifier. However I am having a problem with a particular stored procedure trying to execute another stored procedure.

When the following procedure is called, it seems that the db engine has forgotten the schema context and therefore can't find the called procedure. Has anyone come across this before and is there a workaround other than modifing every SP that uses EXEC?

ALTER PROCEDURE [myschema].[dnn_Forum_StatisticsGet]

(

@.ModuleID int,

@.UpdateWindow int = 12,

@.TabId int

)

...

BEGIN

EXEC dnn_Forum_AA_StatisticsSiteUpdate 0, 0, @.ModuleID, @.TabId

END

...

What about full qualifying the procedure call or using the EXECUTE AS OWNER predicate ?

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Jens K. Suessmeyer wrote:

What about full qualifying the procedure call or using the EXECUTE AS OWNER predicate ?

Thanks for responding Jens. I've considered this approach but it is a last option. It would require modification of a number of procedures and I can't predict where the problem might occur. Ideally I need a solution where the behaviour of the EXEC statement defaults to what you have suggested.

Rgds

Colm

|||

Yep, this is the same question as someone asked me during the last session about Best Practices and Performance Tuning. I would not use implicit naming or schemas, do everything explicitly. Although this is just a bit more work and testing to do for you, you will be later on the safe side.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

The problem is that we are including components from 3rd parties that are expecting the default behaviour of the EXEC statement to default the schema correctly according to the invoking user. From what I can see this is not happening in SQL2005. In SQL 2000 the default was the dbo. Is this a bug in SQL 2005 or normal behaviour?

Rgds

Colm

Default Public Permissions and Guest

There are numerous articles about removing permissions from public, dropping
extended stored procedures and removing the guest account from the msdb
database. Has anyone found any documentation from Microsoft on what their
position is on making any of the afore mentioned changes. I'm reluctant to
make any changes to the default security model even though external audits
indicate that these changes should be made. Any advise would be appreciated
.Hi,
removing guest account from msdb and disallowing public with strong password
mechanism , encryption of data,ntfs file system , windows authentication
could help to prevent from sql injection issue...
please refer following articles :
http://www.microsoft.com/technet/pr...07.msp
x
http://www.microsoft.com/technet/pr...07.msp
x
Regards
--
Andy Davis
Activecrypt Team
---
SQL Server Encryption Software
http://www.activecrypt.com
"Rick" wrote:
[vbcol=seagreen]
> There are numerous articles about removing permissions from public, droppi
ng
> extended stored procedures and removing the guest account from the msdb
> database. Has anyone found any documentation from Microsoft on what their
> position is on making any of the afore mentioned changes. I'm reluctant t
o
> make any changes to the default security model even though external audits
> indicate that these changes should be made. Any advise would be appreciated.[/vbc
ol]|||Hi,
have you refer as i suggest !?
--
Andy Davis
Activecrypt Team
---
SQL Server Encryption Software
http://www.activecrypt.com
"Andy Davis" wrote:
[vbcol=seagreen]
> Hi,
> removing guest account from msdb and disallowing public with strong passwo
rd
> mechanism , encryption of data,ntfs file system , windows authentication
> could help to prevent from sql injection issue...
> please refer following articles :
> http://www.microsoft.com/technet/pr...07.m
spx
> http://www.microsoft.com/technet/pr...07.m
spx
> Regards
> --
> Andy Davis
> Activecrypt Team
> ---
> SQL Server Encryption Software
> http://www.activecrypt.com
>
> "Rick" wrote:
>|||I'm familiar with the article that was referenced, however it doesn't answer
my specific question which is; Can default permissions be revoked from publi
c
and still have Microsoft support the installation. This means revoking
execute from all system stored procedures and select form all catalogs, view
s
and tables from public.
"Andy Davis" wrote:
[vbcol=seagreen]
> Hi,
> have you refer as i suggest !?
> --
> Andy Davis
> Activecrypt Team
> ---
> SQL Server Encryption Software
> http://www.activecrypt.com
>
> "Andy Davis" wrote:
>|||Hi,
You can remove guest/public access but its not recomended , please refer
following thread FYI why it is not recomended
http://www.sql-server-performance.c...p?TOPIC_ID=3596
Regards
--
Andy Davis
Activecrypt Team
---
SQL Server Encryption Software
http://www.activecrypt.com
"Rick" wrote:
[vbcol=seagreen]
> I'm familiar with the article that was referenced, however it doesn't answ
er
> my specific question which is; Can default permissions be revoked from pub
lic
> and still have Microsoft support the installation. This means revoking
> execute from all system stored procedures and select form all catalogs, vi
ews
> and tables from public.
> "Andy Davis" wrote:
>