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

Thursday, March 29, 2012

Equality comparison of xml fields

I have a stored procedure that has an xml input parameter, and the routine will proceed only when the inputted xml is equal to the stored xml field. Is there some sort of equals comparison for this?

* The xml field is typed DOCUMENT.XML data type instances are incomparable. XML data type preserves the content information of the XML instances and may not be an exact copy of the user-supplied XML data. Comparison depends upons the application semantics.

I can suggest the following for your application:

1) Extract scalar values (using the value() method) from the XML parameter and compare with scalar values in the stored XML field

2) Convert the XML parameter to a string representation and compare with a string representation of the stored XML field

3) Add a column that stores a hashed value of the XML instances. Get the hash value of the XML parameter and make a comparison of the hashed values. For a hash match, use #1 or #2 to ensure that the match is indeed correct. There are well known hashing methods (SHA-1 for example) that can yield good hash matches.

Hope this helps.

Thank you.|||Thanks Shankar for the reply. What I would do is break down this xml chunk into smaller content and perform the above as you suggested.

Enumerating Stored Procedure dependencies using SQL-DMO

I have the following (VB.NET) code:
For some reason, I can't get this code to return anything but a ResultSet
with 0 rows. Any ideas?
Public Function GetDependencies(ByVal db As SQLDMO.Database2) As String
Dim objSP As SQLDMO.StoredProcedure2 = db.StoredProcedures.Item(Me.Text)
Dim objQueryResults As SQLDMO.QueryResults = _
objSP.EnumDependencies(SQLDMO.SQLDMO_DEPENDENCY_TYPE.SQLDMODep_Valid)
Dim sb As New System.Text.StringBuilder(4096)
Dim writer As New System.IO.StringWriter(sb)
For i As Integer = 1 To objQueryResults.ResultSets
objQueryResults.CurrentResultSet = i
For j As Integer = 1 To objQueryResults.Rows
For k As Integer = 1 To objQueryResults.Columns
writer.Write(objQueryResults.ColumnName(k) & ": ")
writer.WriteLine(objQueryResults.GetColumnString(j, k))
Next
Next
Next
writer.Flush()
writer.Close()
Return sb.ToString()
End Function
Developer ExtraordinaireHi
Don't forget, in SQL 7.0 and 2000, dependency information is not guaranteed
to be correct due the Deferred Name resolution.
Have you looked in sysdepends if there is information there.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
<developerExtraordinaire@.spamMeAndDie.com> wrote in message
news:ewd2zkeGFHA.1740@.TK2MSFTNGP09.phx.gbl...
> I have the following (VB.NET) code:
> For some reason, I can't get this code to return anything but a ResultSet
> with 0 rows. Any ideas?
> Public Function GetDependencies(ByVal db As SQLDMO.Database2) As String
> Dim objSP As SQLDMO.StoredProcedure2 =
db.StoredProcedures.Item(Me.Text)
> Dim objQueryResults As SQLDMO.QueryResults = _
> objSP.EnumDependencies(SQLDMO.SQLDMO_DEPENDENCY_TYPE.SQLDMODep_Valid)
> Dim sb As New System.Text.StringBuilder(4096)
> Dim writer As New System.IO.StringWriter(sb)
> For i As Integer = 1 To objQueryResults.ResultSets
> objQueryResults.CurrentResultSet = i
> For j As Integer = 1 To objQueryResults.Rows
> For k As Integer = 1 To objQueryResults.Columns
> writer.Write(objQueryResults.ColumnName(k) & ": ")
> writer.WriteLine(objQueryResults.GetColumnString(j, k))
> Next
> Next
> Next
> writer.Flush()
> writer.Close()
> Return sb.ToString()
> End Function
>
> Developer Extraordinaire
>

Enumerating Role Permissions with SMO

Hi,

I am attempting to enumerate role permissions using SMO. I can enumerate the permissions on a atbel, view, or store procedure no problem. When I try to enumerate the permissions that a role has I get the following error:

'Operation not supported on SQL Server 2000'

Can anyone help me in sorting this out. I had the permissions enumerated in DMO but I just can't seem to get it to work in SMO.

Thanks,

James

Just to make sure that I answer this correctly: are you connecting to SQL Server 2000 or SQL Servert 2005?|||

Hi,

I am connecting to SQL2K. I have not problem getting the permissions on a table, view, stored procedure, or function. Its only when I try to get the permissions for a role or user.

James

|||

SMO has aligned the meaning of User.EnumObjectPermissions with all other objects (such as Table). This means that you would enumerate the permissions that have granted or denied to a principal for a User object; not the permissions that have been granted to the User object (which represents a database user). SQL Server 2005 has implemented this (it was not possible for SQL Server 2000) so that clarifies the message you get.

You should be able to call Database.EnumObjectPermissions(User.Name) to obtain the results that you expect.

|||

Thanks,

that worked a treat.

James

|||

Hi,

I am also working on the table permissions.

ObjectPermissionInfo[] objPer = database.EnumObjectPermissions(database.UserName);


But, from this point how could I display all permissions for a table? Could you please send me a sample code?

Thanks in advance.

sql

Enumerating Role Permissions with SMO

Hi,

I am attempting to enumerate role permissions using SMO. I can enumerate the permissions on a atbel, view, or store procedure no problem. When I try to enumerate the permissions that a role has I get the following error:

'Operation not supported on SQL Server 2000'

Can anyone help me in sorting this out. I had the permissions enumerated in DMO but I just can't seem to get it to work in SMO.

Thanks,

James

Just to make sure that I answer this correctly: are you connecting to SQL Server 2000 or SQL Servert 2005?|||

Hi,

I am connecting to SQL2K. I have not problem getting the permissions on a table, view, stored procedure, or function. Its only when I try to get the permissions for a role or user.

James

|||

SMO has aligned the meaning of User.EnumObjectPermissions with all other objects (such as Table). This means that you would enumerate the permissions that have granted or denied to a principal for a User object; not the permissions that have been granted to the User object (which represents a database user). SQL Server 2005 has implemented this (it was not possible for SQL Server 2000) so that clarifies the message you get.

You should be able to call Database.EnumObjectPermissions(User.Name) to obtain the results that you expect.

|||

Thanks,

that worked a treat.

James

|||

Hi,

I am also working on the table permissions.

ObjectPermissionInfo[] objPer = database.EnumObjectPermissions(database.UserName);


But, from this point how could I display all permissions for a table? Could you please send me a sample code?

Thanks in advance.

Thursday, March 22, 2012

Enterprise Mgr Can Not Sort?

Why can I not sort my stored procedure listing by creation date?

I am seeing these dates (omitted the time as not relevant)

2004-03-06
2004-05-14
2004-05-18
2004-03-06

After clicking the 'Create Date' header.

What gives??Brian (bonei@.vafb.com) writes:
> Why can I not sort my stored procedure listing by creation date?
> I am seeing these dates (omitted the time as not relevant)
> 2004-03-06
> 2004-05-14
> 2004-05-18
> 2004-03-06
> After clicking the 'Create Date' header.
> What gives??

I vaguely recall having seen incorrect date formatting in Enterprise
Manager before, although I think that was the Jobs listing. Looking
now, I cannot see anything funny. Maybe there was a bug that was fixed
in a service pack? I'm running SP3, and you? Then again, regional
settings may also matter.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Monday, March 19, 2012

Enterprise Manager reporting wrong server version

I am running MS SQL 2000.

I recently ran a procedure in Query Analyzer from the Master db to
clear out all replication information so I could start/recreate it
again.

After I ran this procedure Enterprise Manager no longer showed the
registered server in the tree. When I tried to re-register it gave me
the following message:

"A connection could not be established to ([Database Name])"

"Reason: [SQL-DMO]Sql Server ([Database Name]) must be upgraded to
version 7.0 or later to be administered by this version of SQL-DMO"

"Please verify that sql is running and check your SQL server
registration properties (by right click on the ([Database Name]) node)
and try again."

I ran the following procedure:

<code>
exec sp_configure N'allow updates', 1
go
reconfigure with override
go

DECLARE @.name varchar(129)
DECLARE @.username varchar(129)
DECLARE @.insname varchar(129)
DECLARE @.delname varchar(129)
DECLARE @.updname varchar(129)
set @.insname=''
set @.updname=''
set @.delname=''

DECLARE list_triggers CURSOR FOR
select distinct replace(artid,'-',''), sysusers.name from
sysmergearticles,sysobjects, sysusers where
sysmergearticles.objid=sysobjects.id
and sysusers.uid=sysobjects.uid

OPEN list_triggers

FETCH NEXT FROM list_triggers INTO @.name, @.username
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping trigger ins_' +@.name
select @.insname='drop trigger ' +@.username+'.ins_'+@.name
exec (@.insname)
PRINT 'dropping trigger upd_' +@.name
select @.updname='drop trigger ' +@.username+'.upd_'+@.name
exec (@.delname)
PRINT 'dropping trigger del_' +@.name
select @.delname='drop trigger ' +@.username+'.del_'+@.name
exec (@.updname)
FETCH NEXT FROM list_triggers INTO @.name, @.username
END

CLOSE list_triggers
DEALLOCATE list_triggers
go

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[syspublications]') and OBJECTPROPERTY(id,
N'IsUserTable')
= 1) begin DECLARE @.name varchar(129)
DECLARE list_pubs CURSOR FOR
SELECT name FROM syspublications

OPEN list_pubs

FETCH NEXT FROM list_pubs INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping publication ' +@.name
EXEC sp_dropsubscription @.publication=@.name, @.article='all',
@.subscriber
='all'
EXEC sp_droppublication @.name
FETCH NEXT FROM list_pubs INTO @.name
END

CLOSE list_pubs
DEALLOCATE list_pubs
end
GO

DECLARE @.name varchar(129)
DECLARE list_replicated_tables CURSOR FOR
SELECT name FROM sysobjects WHERE replinfo <>0
UNION
SELECT name FROM sysmergearticles

OPEN list_replicated_tables

FETCH NEXT FROM list_replicated_tables INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'unmarking replicated table ' +@.name
--select @.name='drop Table ' + @.name
EXEC sp_msunmarkreplinfo @.name
FETCH NEXT FROM list_replicated_tables INTO @.name
END

CLOSE list_replicated_tables
DEALLOCATE list_replicated_tables

GO

UPDATE syscolumns set colstat = colstat & ~4096 WHERE colstat &4096
<>0
GO

UPDATE sysobjects set replinfo=0
GO

DECLARE @.name nvarchar(129)
DECLARE list_views CURSOR FOR
SELECT name FROM sysobjects WHERE type='V' and (name like 'syncobj_%'
or
name
like 'ctsv_%' or name like 'tsvw_%' or name like 'ms_bi%')

OPEN list_views

FETCH NEXT FROM list_views INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping View ' +@.name
select @.name='drop View ' + @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_views INTO @.name
END

CLOSE list_views
DEALLOCATE list_views

GO

DECLARE @.name nvarchar(129)
DECLARE list_procs CURSOR FOR
SELECT name FROM sysobjects WHERE type='p' and (name like 'sp_ins_%'
or
name
like 'sp_MSdel_%' or name like 'sp_MSins_%'or name like 'sp_MSupd_%' or
name
like 'sp_sel_%' or name like 'sp_upd_%')

OPEN list_procs

FETCH NEXT FROM list_procs INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping procs ' +@.name
select @.name='drop procedure ' + @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_procs INTO @.name
END

CLOSE list_procs
DEALLOCATE list_procs

GO

DECLARE @.name nvarchar(129)
DECLARE list_conflict_tables CURSOR FOR
SELECT name From sysobjects WHERE type='u' and name like '_onflict%'

OPEN list_conflict_tables

FETCH NEXT FROM list_conflict_tables INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping conflict_tables ' +@.name
select @.name='drop Table ' + @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_conflict_tables INTO @.name
END

CLOSE list_conflict_tables
DEALLOCATE list_conflict_tables

GO

UPDATE syscolumns set colstat=2 WHERE name='rowguid'

GO

Declare @.name nvarchar(200), @.constraint nvarchar(200)
DECLARE list_rowguid_constraints CURSOR FOR
select sysusers.name+'.'+object_name(sysobjects.parent_ob j),
sysobjects.name
from sysobjects, syscolumns,sysusers where sysobjects.type ='d' and
syscolumns.id=sysobjects.parent_obj
and sysusers.uid=sysobjects.uid
and syscolumns.name='rowguid'

OPEN list_rowguid_constraints

FETCH NEXT FROM list_rowguid_constraints INTO @.name, @.constraint WHILE
@.@.FETCH_STATUS = 0 BEGIN
PRINT 'dropping rowguid constraints ' +@.name
select @.name='ALTER TABLE ' + rtrim(@.name) + ' DROP CONSTRAINT '
+@.constraint
print @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_rowguid_constraints INTO @.name, @.constraint END

CLOSE list_rowguid_constraints
DEALLOCATE list_rowguid_constraints

GO

Declare @.name nvarchar(129), @.constraint nvarchar(129)
DECLARE list_rowguid_indexes CURSOR FOR
select sysusers.name+'.'+object_name(sysindexes.id), sysindexes.name
from
sysindexes, sysobjects,sysusers where sysindexes.name like 'index%' and
sysobjects.id=sysindexes.id and sysusers.uid=sysobjects.uid

OPEN list_rowguid_indexes

FETCH NEXT FROM list_rowguid_indexes INTO @.name, @.constraint WHILE
@.@.FETCH_STATUS = 0 BEGIN
PRINT 'dropping rowguid indexes ' +@.name
select @.name='drop index ' + rtrim(@.name ) + '.' +@.constraint
EXEC sp_executesql @.name
FETCH NEXT FROM list_rowguid_indexes INTO @.name, @.constraint END

CLOSE list_rowguid_indexes
DEALLOCATE list_rowguid_indexes
GO

Declare @.name nvarchar(129), @.constraint nvarchar(129)
DECLARE list_ms_bidi_tables CURSOR FOR
select sysusers.name+'.'+sysobjects.name from
sysobjects,sysusers where sysobjects.name like 'ms_bi%'
and sysusers.uid=sysobjects.uid
and sysobjects.type='u'

OPEN list_ms_bidi_tables

FETCH NEXT FROM list_ms_bidi_tables INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping ms_bidi ' +@.name
select @.name='drop table ' + rtrim(@.name )
EXEC sp_executesql @.name
FETCH NEXT FROM list_ms_bidi_tables INTO @.name
END

CLOSE list_ms_bidi_tables
DEALLOCATE list_ms_bidi_tables

GO

Declare @.name nvarchar(129)
DECLARE list_rowguid_columns CURSOR FOR
select sysusers.name+'.'+object_name(syscolumns.id) from syscolumns,
sysobjects,sysusers where syscolumns.name like 'rowguid' and
object_Name(sysobjects.id) not like 'msmerge%'
and sysobjects.id=syscolumns.id
and sysusers.uid=sysobjects.uid
and sysobjects.type='u' order by 1

OPEN list_rowguid_columns

FETCH NEXT FROM list_rowguid_columns INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping rowguid columns ' +@.name
select @.name='Alter Table ' + rtrim(@.name ) + ' drop column rowguid'
print @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_rowguid_columns INTO @.name
END

CLOSE list_rowguid_columns
DEALLOCATE list_rowguid_columns
go

Declare @.name nvarchar(129)
DECLARE list_views CURSOR FOR

select name From sysobjects where type ='v' and status =-1073741824 and
name
<>'sysmergeextendedarticlesview'

OPEN list_views

FETCH NEXT FROM list_views INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping replication views ' +@.name
select @.name='drop view ' + rtrim(@.name )
print @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_views INTO @.name
END

CLOSE list_views
DEALLOCATE list_views
go
Declare @.name nvarchar(129)
DECLARE list_procs CURSOR FOR

select name From sysobjects where type ='p' and status = -536870912

OPEN list_procs

FETCH NEXT FROM list_procs INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping replication procedure ' +@.name
select @.name='drop procedure ' + rtrim(@.name )
print @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_procs INTO @.name
END

CLOSE list_procs
DEALLOCATE list_procs

go

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysmergepublications]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysmergepublications
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysmergesubscriptions]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysmergesubscriptions
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[syssubscriptions]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM syssubscriptions
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysarticleupdates]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysarticleupdates
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[systranschemas]') and OBJECTPROPERTY(id,
N'IsUserTable')
= 1)
DELETE FROM systranschemas
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysmergearticles]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysmergearticles
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysmergeschemaarticles]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysmergeschemaarticles
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysmergesubscriptions]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysmergesubscriptions
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysarticles]') and OBJECTPROPERTY(id,
N'IsUserTable') =
1)
DELETE FROM sysarticles
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysschemaarticles]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysschemaarticles
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[syspublications]') and OBJECTPROPERTY(id,
N'IsUserTable')
= 1)
DELETE FROM syspublications
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysmergeschemachange]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysmergeschemachange
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysmergesubsetfilters]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM sysmergesubsetfilters
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSdynamicsnapshotjobs]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSdynamicsnapshotjobs
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSdynamicsnapshotviews]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSdynamicsnapshotviews
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSmerge_altsyncpartners]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSmerge_altsyncpartners
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSmerge_contents]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSmerge_contents
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSmerge_delete_conflicts]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSmerge_delete_conflicts
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSmerge_errorlineage]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSmerge_errorlineage
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSmerge_genhistory]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSmerge_genhistory
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSmerge_replinfo]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSmerge_replinfo
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSmerge_tombstone]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSmerge_tombstone
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSpub_identity_range]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSpub_identity_range
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSrepl_identity_range]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSrepl_identity_range
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSreplication_subscriptions]') and
OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSreplication_subscriptions
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[MSsubscription_agents]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
DELETE FROM MSsubscription_agents
GO

if not exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[syssubscriptions]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
create table syssubscriptions (artid int, srvid smallint, dest_db
sysname,
status tinyint, sync_type tinyint, login_name sysname,
subscription_type
int, distribution_jobid binary, timestamp timestamp,update_mode
tinyint,
loopback_detection tinyint, queued_reinit bit)

CREATE TABLE [dbo].[syspublications] (
[description] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[name] [sysname] NOT NULL ,
[pubid] [int] IDENTITY (1, 1) NOT NULL ,
[repl_freq] [tinyint] NOT NULL ,
[status] [tinyint] NOT NULL ,
[sync_method] [tinyint] NOT NULL ,
[snapshot_jobid] [binary] (16) NULL ,
[independent_agent] [bit] NOT NULL ,
[immediate_sync] [bit] NOT NULL ,
[enabled_for_internet] [bit] NOT NULL ,
[allow_push] [bit] NOT NULL ,
[allow_pull] [bit] NOT NULL ,
[allow_anonymous] [bit] NOT NULL ,
[immediate_sync_ready] [bit] NOT NULL ,
[allow_sync_tran] [bit] NOT NULL ,
[autogen_sync_procs] [bit] NOT NULL ,
[retention] [int] NULL ,
[allow_queued_tran] [bit] NOT NULL ,
[snapshot_in_defaultfolder] [bit] NOT NULL ,
[alt_snapshot_folder] [nvarchar] (255) COLLATE
SQL_Latin1_General_CP1_CI_AS
NULL ,
[pre_snapshot_script] [nvarchar] (255) COLLATE
SQL_Latin1_General_CP1_CI_AS
NULL ,
[post_snapshot_script] [nvarchar] (255) COLLATE
SQL_Latin1_General_CP1_CI_AS
NULL ,
[compress_snapshot] [bit] NOT NULL ,
[ftp_address] [sysname] NULL ,
[ftp_port] [int] NOT NULL ,
[ftp_subdirectory] [nvarchar] (255) COLLATE
SQL_Latin1_General_CP1_CI_AS
NULL ,
[ftp_login] [sysname] NULL ,
[ftp_password] [nvarchar] (524) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[allow_dts] [bit] NOT NULL ,
[allow_subscription_copy] [bit] NOT NULL ,
[centralized_conflicts] [bit] NULL ,
[conflict_retention] [int] NULL ,
[conflict_policy] [int] NULL ,
[queue_type] [int] NULL ,
[ad_guidname] [sysname] NULL ,
[backward_comp_level] [int] NOT NULL
) ON [PRIMARY]
GO
create view sysextendedarticlesview
as
SELECT *
FROM sysarticles
UNION ALL
SELECT artid, NULL, creation_script, NULL, description,
dest_object,
NULL, NULL, NULL, name, objid, pubid, pre_creation_cmd, status, NULL,
type,
NULL,
schema_option, dest_owner
FROM sysschemaarticles
go

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysarticles]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[sysarticles]
GO

CREATE TABLE [dbo].[sysarticles] (
[artid] [int] IDENTITY (1, 1) NOT NULL ,
[columns] [varbinary] (32) NULL ,
[creation_script] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL
,
[del_cmd] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[description] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[dest_table] [sysname] NOT NULL ,
[filter] [int] NOT NULL ,
[filter_clause] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ins_cmd] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[name] [sysname] NOT NULL ,
[objid] [int] NOT NULL ,
[pubid] [int] NOT NULL ,
[pre_creation_cmd] [tinyint] NOT NULL ,
[status] [tinyint] NOT NULL ,
[sync_objid] [int] NOT NULL ,
[type] [tinyint] NOT NULL ,
[upd_cmd] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[schema_option] [binary] (8) NULL ,
[dest_owner] [sysname] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[sysschemaarticles]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[sysschemaarticles]
GO

CREATE TABLE [dbo].[sysschemaarticles] (
[artid] [int] NOT NULL ,
[creation_script] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL
,
[description] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[dest_object] [sysname] NOT NULL ,
[name] [sysname] NOT NULL ,
[objid] [int] NOT NULL ,
[pubid] [int] NOT NULL ,
[pre_creation_cmd] [tinyint] NOT NULL ,
[status] [int] NOT NULL ,
[type] [tinyint] NOT NULL ,
[schema_option] [binary] (8) NULL ,
[dest_owner] [sysname] NULL
) ON [PRIMARY]
GO

declare @.dbname varchar(130)
select @.dbname ='sp_replicationdboption
'+char(39)+db_name()+char(39)+',''merge publish'',''false'''
exec (@.dbname)
select @.dbname ='sp_replicationdboption
'+char(39)+db_name()+char(39)+',''publish'',''fals e'''
exec (@.dbname)

reconfigure with override
go

select db_name()
</code>

Can any one please help me as this is a production machine and needs
fixing ASAP.

Regards,

BenBenzine (bfausti@.gmail.com) writes:

Quote:

Originally Posted by

I recently ran a procedure in Query Analyzer from the Master db to
clear out all replication information so I could start/recreate it
again.
>
After I ran this procedure Enterprise Manager no longer showed the
registered server in the tree. When I tried to re-register it gave me
the following message:
>
"A connection could not be established to ([Database Name])"
>
"Reason: [SQL-DMO]Sql Server ([Database Name]) must be upgraded to
version 7.0 or later to be administered by this version of SQL-DMO"
>
"Please verify that sql is running and check your SQL server
registration properties (by right click on the ([Database Name]) node)
and try again."
>...
Can any one please help me as this is a production machine and needs
fixing ASAP.


OK, so you've learnt a lesson for the next time: run in test before you
run in production.

You run a script that performs a lot of updates to the system tables,
and in many cases to undocumented columns, and now you wonder why your
server is hosed?

I can't tell if there were was more that was harmful, but this cursor
definitely was:

SELECT name FROM sysobjects WHERE type='P' and (name like 'sp_ins_%'
or name like 'sp_MSdel_%' or name like 'sp_MSins_%'or
name like 'sp_MSupd_%' or name like 'sp_sel_%' or name like 'sp_upd_%')

OPEN list_procs

FETCH NEXT FROM list_procs INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping procs ' +@.name
select @.name='drop procedure ' + @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_procs INTO @.name
END

The SELECT hits 30 system procedures on my server, and far from all
are related to replication, for instance sp_updatestats and
sp_updateextendedproperty.

I would recommand that you at first possible maintenance window, detach
all databases and use the rebuildm tool to rebuild the master database.
Or simply reinstall SQL Server. Whatever, don't forget to reapply the
service pack.

If it's difficult to find the time for a reinstall, I suggest that you
open a case with Microsoft. I don't really want to guide you which
scripts to run, as my guidance could be wrong.

--
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|||Thank you for your reply.

Unfortunately I didn't have the luxury of a test environment, so I
took a big risk I know. Thankfully we had backups running on Veritas, I
restored to a previous version of the master and msdb databases and
this fixed my problem.

Erland Sommarskog wrote:

Quote:

Originally Posted by

Benzine (bfausti@.gmail.com) writes:

Quote:

Originally Posted by

I recently ran a procedure in Query Analyzer from the Master db to
clear out all replication information so I could start/recreate it
again.

After I ran this procedure Enterprise Manager no longer showed the
registered server in the tree. When I tried to re-register it gave me
the following message:

"A connection could not be established to ([Database Name])"

"Reason: [SQL-DMO]Sql Server ([Database Name]) must be upgraded to
version 7.0 or later to be administered by this version of SQL-DMO"

"Please verify that sql is running and check your SQL server
registration properties (by right click on the ([Database Name]) node)
and try again."
...
Can any one please help me as this is a production machine and needs
fixing ASAP.


>
OK, so you've learnt a lesson for the next time: run in test before you
run in production.
>
You run a script that performs a lot of updates to the system tables,
and in many cases to undocumented columns, and now you wonder why your
server is hosed?
>
I can't tell if there were was more that was harmful, but this cursor
definitely was:
>
SELECT name FROM sysobjects WHERE type='P' and (name like 'sp_ins_%'
or name like 'sp_MSdel_%' or name like 'sp_MSins_%'or
name like 'sp_MSupd_%' or name like 'sp_sel_%' or name like 'sp_upd_%')
>
OPEN list_procs
>
FETCH NEXT FROM list_procs INTO @.name
WHILE @.@.FETCH_STATUS = 0
BEGIN
PRINT 'dropping procs ' +@.name
select @.name='drop procedure ' + @.name
EXEC sp_executesql @.name
FETCH NEXT FROM list_procs INTO @.name
END
>
The SELECT hits 30 system procedures on my server, and far from all
are related to replication, for instance sp_updatestats and
sp_updateextendedproperty.
>
I would recommand that you at first possible maintenance window, detach
all databases and use the rebuildm tool to rebuild the master database.
Or simply reinstall SQL Server. Whatever, don't forget to reapply the
service pack.
>
If it's difficult to find the time for a reinstall, I suggest that you
open a case with Microsoft. I don't really want to guide you which
scripts to run, as my guidance could be wrong.
>
--
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

Friday, February 24, 2012

Enterprise Manager Collision

Is there a setting for enterprise manager, to prevent two instances
from having the same stored procedure or any other object open and
overwritting one another?Hi

No. As you could submit code through ISQL, OSQL, Query Analyzer, Enterprise
Manager, ADO etc.

Team co-ordination is required, usually only 1 person is allowed to make
changes to the development server after the other developers submit their
code to him.

Regards
----------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@.epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

<jw56578@.gmail.com> wrote in message
news:1114556996.995967.159010@.z14g2000cwz.googlegr oups.com...
> Is there a setting for enterprise manager, to prevent two instances
> from having the same stored procedure or any other object open and
> overwritting one another?|||What you are hinting at is an underlying problem that every development
shop faces when more than one person needs to modify the same schema at
the same time.

I would ask the question "How do you manage changes for the non SQL
code in the system?" the answer to which *should* be the same in any
development team - "we use the source control system". Using source
control is obvious for C++, Java, HTML etc. but not for SQL code as it
has some unique requirements, not least of which being that you cannot
simply drop and replace a target database with a brand new one that has
no data in it!

What you need is to be able to simply modify the schema creation
scripts under source control to regulate multiple developers modifying
the same schema. This, for example, is the way you would work if you
were developing a brand new database that doesn't exist in production
yet. To release the latest version of the database you simply build a
brand new one from the create scripts and deliver that.

But what if you already have a production database? You can't just
throw it away, you need to carefully modify it to bring it up to the
new schema level.

This is where a tool called DB Ghost (www.dbghost.com) comes in. It
will build a brand new database from the scripts in source control,
which verifies that no syntax or dependency problems exist. It then
uses that database as the source for a compare and upgrade of an
existing database i.e. production. This keeps all data in place and
means that you will have a target schema that absolutely matches a
defined, labelled set of create scripts under source control.

This is called the "DB Ghost Process" and it is simply the best change
management solution I have ever seen as it is the only tool that works
with source code.

The more people use the product, the more they love it as it makes so
much sense.|||No. Use a source control system such as Microsoft Source Safe for that.

--
David Portas
SQL Server MVP
--

Friday, February 17, 2012

Enterprise manager

Hi,
Does anyone know wich stored procedure enterprise manager call
when listing databases?
Marcin S.Try using sp_helpdb ?
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Marcin S." wrote:

> Hi,
> Does anyone know wich stored procedure enterprise manager call
> when listing databases?
>
> --
> Marcin S.|||Hi,
I don't thinks it uses this SP becouse i does not list all DB:s
Marcin S.
"Jens Sü?meyer" wrote:
> Try using sp_helpdb ?
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "Marcin S." wrote:
>|||Hi,
I don't thinks it uses this SP becouse i does not list all DB:s
Marcin S.
"Jens Sü?meyer" wrote:
> Try using sp_helpdb ?
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "Marcin S." wrote:
>|||sp_helpdb lists all the databases you have access to. Enterprise Manager
doesn't use sp_helpdb, it just uses master..sysdatabases directly.
Jacco Schalkwijk
SQL Server MVP
"Marcin S." <MarcinS@.discussions.microsoft.com> wrote in message
news:4343496D-4978-44B0-B0C9-1625555ED99A@.microsoft.com...
> Hi,
> I don't thinks it uses this SP becouse i does not list all DB:s
>
> --
> Marcin S.
>
> "Jens Smeyer" wrote:
>|||Hi,
Just run the SQL Profiler and click the databases in Eneterprise manager.
You could see all the Queries and stored procedures fired to get the result.
Thanks
Hari
SQL Server MVP
"Marcin S." <MarcinS@.discussions.microsoft.com> wrote in message
news:4CB59A10-BA8A-4D96-AEAF-EEFE1BB39FBE@.microsoft.com...
> Hi,
> Does anyone know wich stored procedure enterprise manager call
> when listing databases?
>
> --
> Marcin S.

Wednesday, February 15, 2012

entering store procedure result to table

Hello there
is there a way to enter store procedure result to table?insert into tblname
exec stored_proc1
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/
"Roy Goldhammer" wrote:

> Hello there
> is there a way to enter store procedure result to table?
>
>|||Thankes A lot
"Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
news:DB2F9A89-FFC1-4B17-ABBD-3A45C8B24867@.microsoft.com...
> insert into tblname
> exec stored_proc1
> --
> -Omnibuzz (The SQL GC)
> http://omnibuzz-sql.blogspot.com/
>
> "Roy Goldhammer" wrote:
>|||Whell Omnibuzz.
Now i need to enter it to function in order to use it as generic function
My function looks like this:
create function fnDir(@.Path as varchar(8000))
returns @.ret table(FileName varchar(1000))
as
begin
DECLARE @.dir varchar(1000)
set @.dir = 'dir ' + @.Path + '/b'
insert @.ret
exec master..xp_cmdshell @.DIR
end
and it gives me error:
EXECUTE cannot be used as a source when inserting into a table variable.
how can i solve it?
"Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
news:DB2F9A89-FFC1-4B17-ABBD-3A45C8B24867@.microsoft.com...
> insert into tblname
> exec stored_proc1
> --
> -Omnibuzz (The SQL GC)
> http://omnibuzz-sql.blogspot.com/
>
> "Roy Goldhammer" wrote:
>|||Roy,shalom
The error message is pretty clear. You cannot use EXEC command within a UDF.
Instead , create a stored procedure
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:ehGpAc5kGHA.3816@.TK2MSFTNGP02.phx.gbl...
> Whell Omnibuzz.
> Now i need to enter it to function in order to use it as generic function
> My function looks like this:
> create function fnDir(@.Path as varchar(8000))
> returns @.ret table(FileName varchar(1000))
> as
> begin
> DECLARE @.dir varchar(1000)
> set @.dir = 'dir ' + @.Path + '/b'
> insert @.ret
> exec master..xp_cmdshell @.DIR
> end
> and it gives me error:
> EXECUTE cannot be used as a source when inserting into a table variable.
> how can i solve it?
> "Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
> news:DB2F9A89-FFC1-4B17-ABBD-3A45C8B24867@.microsoft.com...
>|||Whell Uri.
I need it because other wants to use it as select *
from [process]
the only way i know to use it is by that
do you have any idea?
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:ui9Sbh5kGHA.896@.TK2MSFTNGP04.phx.gbl...
> Roy,shalom
> The error message is pretty clear. You cannot use EXEC command within a
> UDF. Instead , create a stored procedure
>
>
>
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:ehGpAc5kGHA.3816@.TK2MSFTNGP02.phx.gbl...
>|||> Whell Uri.
> I need it because other wants to use it as select *
> from [process]
> the only way i know to use it is by that
> do you have any idea?
Yes, teach them to use EXEC [process];|||Roy
I'm a little bit . What is prevent you from using this code inside
the SP, ahhh I see because someone wants to run SELECT *, so
you can run EXEC sp and that will returt the same data , does it matter to
him?
And as you probably know that using SELECT * in the production is considered
a bad practice
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:%23yHLBo5kGHA.3588@.TK2MSFTNGP02.phx.gbl...
> Whell Uri.
> I need it because other wants to use it as select *
> from [process]
> the only way i know to use it is by that
> do you have any idea?
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:ui9Sbh5kGHA.896@.TK2MSFTNGP04.phx.gbl...
>|||In SQL 2005 you could use a CLR function in SQL 2000, however, you could use
sp_OA* system procedures to instantiate a file system object
("Scripting.FileSystemObject") then traverse the selected folder to get a
list of file names to return as the result of the function.
What's your version? Anyway, there are many good examples in Books Online
(and elsewhere on MSDN).
ML
http://milambda.blogspot.com/|||Whell Aaron
they need it for anoter sql in order to add it to join.
how can i do it with store procedue?
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:%2354Ptv5kGHA.4816@.TK2MSFTNGP05.phx.gbl...
>
> Yes, teach them to use EXEC [process];
>
>