Accueil > Forum > > > > sp_databases et sp_datainfo inexistant dans procedure stockée système ?
sp_databases et sp_datainfo inexistant dans procedure stockée système ?
vendredi 12 septembre 2008 à 10:59:34 |
sp_databases et sp_datainfo inexistant dans procedure stockée système ?

surfman
|
Bonjour à tous, J'ai un soucis, la procédure stockée système sp_databases n'existe plus, ainsi qu'une situé dessous ou dessus qui est sp_datainfo je ne sais plus exactement le nom (si quelqu'un pouvait me redonner ce nom ainsi que le code de cette procédure...). mon soucis est le suivant j'ai recrée sp_databases seulement en tant que procédure stockée et je voudrais le mettre en tant que procédure stockée système, comment faire ? Merci de m'éclairer :-s
|
|
vendredi 12 septembre 2008 à 10:59:59 |
Re : sp_databases et sp_datainfo inexistant dans procedure stockée système ?

surfman
|
j'ai oublié de préciser que ces procédures était dans la table master
|
|
vendredi 12 septembre 2008 à 14:16:47 |
Re : sp_databases et sp_datainfo inexistant dans procedure stockée système ?

crn_c21
|
Voici la proc sp_datatype_info parc ontre je ne sais comment la transformer en procédure système :
CREATE procedure [sys].[sp_datatype_info] ( @data_type int = 0, @ODBCVer tinyint = 2 ) as declare @mintype int declare @maxtype int
set @ODBCVer = isnull(@ODBCVer, 2) if @ODBCVer < 3 -- includes ODBC 1.0 as well set @ODBCVer = 2 else set @ODBCVer = 3
if @data_type = 0 begin select @mintype = -32768 select @maxtype = 32767 end else begin select @mintype = @data_type select @maxtype = @data_type end
select TYPE_NAME = convert(sysname, case when t.user_type_id > 255 then t.name else d.TYPE_NAME collate database_default end), DATA_TYPE = convert(smallint, -- backward-compatible ODBC types case when (d.ss_dtype = 240) then -- CLR UDT -4 when (d.ss_dtype = 241) then -- XML -10 else d.DATA_TYPE end), "PRECISION" = convert(int, case when (d.DATA_TYPE in (6,7,-150)) then d.data_precision -- FLOAT/REAL/sql_variant when (d.ss_dtype = 241) then 1073741823 -- XML is the same as ntext for pre-Yukon clients when d.ss_dtype in (106,108) and t.user_type_id <= 255 then @@max_precision -- DECIMAL/NUMERIC else OdbcPrec(t.system_type_id, t.max_length, t.precision) end), LITERAL_PREFIX = d.LITERAL_PREFIX, LITERAL_SUFFIX = d.LITERAL_SUFFIX, CREATE_PARAMS = e.CREATE_PARAMS, NULLABLE = convert(smallint, case when d.AUTO_INCREMENT = 1 then 0 -- IDENTITY else TypeProperty (t.name, 'AllowsNull') end), CASE_SENSITIVE = convert (smallint, case when d.ss_dtype = 241 then 1 -- SQL_SS_XML is always case sensitive when d.DATA_TYPE in (1, -1, 12, -8, -9, -10) then -- char/text/varchar/nchar/nvarchar/ntext case when 'a' <> 'A' then 1 else 0 end else 0 end), SEARCHABLE = d.SEARCHABLE, UNSIGNED_ATTRIBUTE = d.UNSIGNED_ATTRIBUTE, MONEY = d.MONEY, AUTO_INCREMENT = convert(smallint, case -- money/float/real/tinyint/smallmoney/smallint/int/decimal/numeric/bigint when d.ss_dtype in (60, 62, 59, 122, 48, 52, 56, 106, 108, 127) then d.AUTO_INCREMENT else null -- not applicable for other types end), LOCAL_TYPE_NAME = convert(sysname, case when t.user_type_id > 255 then t.name else d.LOCAL_TYPE_NAME collate database_default end), MINIMUM_SCALE = convert(smallint, case when d.ss_dtype in (106,108) and t.user_type_id > 255 then TypeProperty (t.name, 'Scale') else d.numeric_scale end), MAXIMUM_SCALE = convert(smallint, case when d.ss_dtype in (106,108) and d.AUTO_INCREMENT = 0 and t.user_type_id <= 255 then @@max_precision -- DECIMAL/NUMERIC when (d.ss_dtype in (106,108) and d.AUTO_INCREMENT = 1) or (d.ss_dtype in (98, 104)) then 0 -- DECIMAL/NUMERIC IDENTITY/SQL_VARIANT/BIT else TypeProperty (t.name, 'Scale') end), SQL_DATA_TYPE = convert(smallint, -- backward-compatible ODBC types case when (d.ss_dtype = 240) then -- CLR UDT -4 when (d.ss_dtype = 241) then -- XML -10 else d.SQL_DATA_TYPE end), SQL_DATETIME_SUB = d.SQL_DATETIME_SUB, NUM_PREC_RADIX = convert(int,d.RADIX), INTERVAL_PRECISION = convert(smallint,NULL), USERTYPE = convert(smallint, typeproperty(t.name, 'oldusertype'))
from sys.spt_datatype_info d inner join sys.types t on ( -- We have to return all system types and SQL UDTs (as Shiloh does), -- but no CLR UDTs. d.ss_dtype = t.system_type_id and ( d.ss_usertype = t.user_type_id or -- system UDTs & regular types ( t.system_type_id <> 240 and t.user_type_id > 255 and -- SQL UDTs d.ss_dtype <> 240 and d.ss_usertype = d.ss_dtype ) ) ) left outer join sys.spt_datatype_info_ext e on ( t.user_type_id = e.user_type and d.AUTO_INCREMENT = e.AUTO_INCREMENT )
where d.DATA_TYPE between @mintype and @maxtype and d.ODBCVer = @ODBCVer and (t.user_type_id <= 255 or d.AUTO_INCREMENT = 0)
order by 2, 12, 11, 20
|
|
mardi 16 septembre 2008 à 10:49:03 |
Re : sp_databases et sp_datainfo inexistant dans procedure stockée système ?

surfman
|
Merci beaucoup pour la copie du contenue de la procédure, mais j'ai toujours un soucis, lorsque je créer la procédure :
Msg 156, Niveau 15, État 1, Procédure sp_datatype_info, Ligne 52 Syntaxe incorrecte vers le mot clé 'precision'.
Quelqu'un serait-il m'aider ?
J'utilise SQL 2000
|
|
mardi 16 septembre 2008 à 12:47:44 |
Re : sp_databases et sp_datainfo inexistant dans procedure stockée système ?

surfman
|
Réponse acceptée !
C'est fou l'aide qu'on peut avoir... J'ai ENCORE une fois trouvé par moi même :
Création d'une procédure stockée SYSTEME :
" USE master go
DROP proc sp_xxxx (le nom de votre procédure stockée) go
SET QUOTED_IDENTIFIER ON go
-- -- Object will be created with MSShipped flag -- EXEC sp_MS_upd_sysobj_category 1 go
ICI METTRE LE CODE COMPLET DE VOTRE PROCEDURE STOCKEE go
GRANT EXEC ON sp_xxxx (le nom de votre procédure stockée) TO public go
-- -- Turn off MSShipped flag for any other SP's (not that we're creating any) -- EXEC sp_MS_upd_sysobj_category 2 go
-- -- Allow updates and hack sysobjects directly. Make sure sp is marked as with -- quoted identifiers and MSShipped -- exec sp_configure 'allow updates', 1 reconfigure with override go
update sysobjects set status = 0x80000009 where name = 'sp_xxxx (le nom de votre procédure stockée)' go
exec sp_configure 'allow updates', 0 reconfigure with override go "
Et pour ceux qui ont eu la boulette comme moi d'executer une procédure stockée, qui s'éfface ensuite automatiquement des procédures stockée système (si vous avez le malheur de la supprimer ensuite en tant que procédure stockée, vous perdez le code et la fonctionnalité, aucune protection... contre ce genre de bouse)
Voici SP_DATABASES :
" set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO
/* Procedure for 8.0 server */ Create proc [sp_databases] as set nocount on declare @name sysname declare @SQL nvarchar(600)
/* Use temporary table to sum up database size w/o using group by */ create table #databases ( DATABASE_NAME sysname NOT NULL, size int NOT NULL)
declare c1 cursor for select name from master.dbo.sysdatabases where has_dbaccess(name) = 1 -- Only look at databases to which we have access
open c1 fetch c1 into @name
while @@fetch_status >= 0 begin select @SQL = 'insert into #databases select N'''+ @name + ''', sum(size) from ' + QuoteName(@name) + '.dbo.sysfiles' /* Insert row for each database */ execute (@SQL) fetch c1 into @name end deallocate c1
select DATABASE_NAME, DATABASE_SIZE = size*8,/* Convert from 8192 byte pages to K */ REMARKS = convert(varchar(254),null) /* Remarks are NULL */ from #databases order by 1 "
et voici SP_DATATYPE_INFO :
" CREATE proc [sp_datatype_info] ( @data_type int = 0, @ODBCVer tinyint = 2 ) as declare @mintype int declare @maxtype int
set @ODBCVer = isnull(@ODBCVer, 2) if @ODBCVer < 3 -- includes ODBC 1.0 as well set @ODBCVer = 2 else set @ODBCVer = 3
if @data_type = 0 begin select @mintype = -32768 select @maxtype = 32767 end else begin select @mintype = @data_type select @maxtype = @data_type end
select TYPE_NAME = convert(sysname, case when t.user_type_id > 255 then t.name else d.TYPE_NAME collate database_default end), DATA_TYPE = convert(smallint, -- backward-compatible ODBC types case when (d.ss_dtype = 240) then -- CLR UDT -4 when (d.ss_dtype = 241) then -- XML -10 else d.DATA_TYPE end), "PRECISION" = convert(int, case when (d.DATA_TYPE in (6,7,-150)) then d.data_precision -- FLOAT/REAL/sql_variant when (d.ss_dtype = 241) then 1073741823 -- XML is the same as ntext for pre-Yukon clients when d.ss_dtype in (106,108) and t.user_type_id <= 255 then @@max_precision -- DECIMAL/NUMERIC else OdbcPrec(t.system_type_id, t.max_length, t.precision) end), LITERAL_PREFIX = d.LITERAL_PREFIX, LITERAL_SUFFIX = d.LITERAL_SUFFIX, CREATE_PARAMS = e.CREATE_PARAMS, NULLABLE = convert(smallint, case when d.AUTO_INCREMENT = 1 then 0 -- IDENTITY else TypeProperty (t.name, 'AllowsNull') end), CASE_SENSITIVE = convert (smallint, case when d.ss_dtype = 241 then 1 -- SQL_SS_XML is always case sensitive when d.DATA_TYPE in (1, -1, 12, -8, -9, -10) then -- char/text/varchar/nchar/nvarchar/ntext case when 'a' <> 'A' then 1 else 0 end else 0 end), SEARCHABLE = d.SEARCHABLE, UNSIGNED_ATTRIBUTE = d.UNSIGNED_ATTRIBUTE, MONEY = d.MONEY, AUTO_INCREMENT = convert(smallint, case -- money/float/real/tinyint/smallmoney/smallint/int/decimal/numeric/bigint when d.ss_dtype in (60, 62, 59, 122, 48, 52, 56, 106, 108, 127) then d.AUTO_INCREMENT else null -- not applicable for other types end), LOCAL_TYPE_NAME = convert(sysname, case when t.user_type_id > 255 then t.name else d.LOCAL_TYPE_NAME collate database_default end), MINIMUM_SCALE = convert(smallint, case when d.ss_dtype in (106,108) and t.user_type_id > 255 then TypeProperty (t.name, 'Scale') else d.numeric_scale end), MAXIMUM_SCALE = convert(smallint, case when d.ss_dtype in (106,108) and d.AUTO_INCREMENT = 0 and t.user_type_id <= 255 then @@max_precision -- DECIMAL/NUMERIC when (d.ss_dtype in (106,108) and d.AUTO_INCREMENT = 1) or (d.ss_dtype in (98, 104)) then 0 -- DECIMAL/NUMERIC IDENTITY/SQL_VARIANT/BIT else TypeProperty (t.name, 'Scale') end), SQL_DATA_TYPE = convert(smallint, -- backward-compatible ODBC types case when (d.ss_dtype = 240) then -- CLR UDT -4 when (d.ss_dtype = 241) then -- XML -10 else d.SQL_DATA_TYPE end), SQL_DATETIME_SUB = d.SQL_DATETIME_SUB, NUM_PREC_RADIX = convert(int,d.RADIX), INTERVAL_PRECISION = convert(smallint,NULL), USERTYPE = convert(smallint, typeproperty(t.name, 'oldusertype'))
from sys.spt_datatype_info d inner join sys.types t on ( -- We have to return all system types and SQL UDTs (as Shiloh does), -- but no CLR UDTs. d.ss_dtype = t.system_type_id and ( d.ss_usertype = t.user_type_id or -- system UDTs & regular types ( t.system_type_id <> 240 and t.user_type_id > 255 and -- SQL UDTs d.ss_dtype <> 240 and d.ss_usertype = d.ss_dtype ) ) ) left outer join sys.spt_datatype_info_ext e on ( t.user_type_id = e.user_type and d.AUTO_INCREMENT = e.AUTO_INCREMENT )
where d.DATA_TYPE between @mintype and @maxtype and d.ODBCVer = @ODBCVer and (t.user_type_id <= 255 or d.AUTO_INCREMENT = 0)
order by 2, 12, 11, 20 "
|
|
mardi 16 septembre 2008 à 12:50:40 |
Re : sp_databases et sp_datainfo inexistant dans procedure stockée système ?

surfman
|
Réponse acceptée !
Arf je me suis trompé pour SP_DATATYPE_INFO, le bon code est :
"
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO
/* Procedure for 8.0 server */ CREATE proc [sp_datatype_info] (@data_type int = 0, @ODBCVer tinyint = 2) as declare @mintype int declare @maxtype int
if @ODBCVer <> 3 select @ODBCVer = 2 if @data_type = 0 begin select @mintype = -32768 select @maxtype = 32767 end else begin select @mintype = @data_type select @maxtype = @data_type end
select convert(sysname,case when t.xusertype > 255 then t.name else d.TYPE_NAME collate database_default end) TYPE_NAME, d.DATA_TYPE, convert(int,case when d.DATA_TYPE in (6,7,-150) then d.data_precision /* FLOAT/REAL/sql_variant*/ when d.ss_dtype in (55,63,106,108) and t.xusertype <= 255 then @@max_precision /* DECIMAL/NUMERIC */ else OdbcPrec(t.xtype, t.length, t.xprec) end) "PRECISION", d.LITERAL_PREFIX, d.LITERAL_SUFFIX, e.CREATE_PARAMS, convert(smallint,case when d.AUTO_INCREMENT = 1 then 0 /* IDENTITY*/ else TypeProperty (t.name, 'AllowsNull') end) NULLABLE, d.CASE_SENSITIVE, d.SEARCHABLE, d.UNSIGNED_ATTRIBUTE, d.MONEY, d.AUTO_INCREMENT, convert(sysname,case when t.xusertype > 255 then t.name else d.LOCAL_TYPE_NAME collate database_default end) LOCAL_TYPE_NAME, convert(smallint,case when d.ss_dtype in (55,63,106,108) and t.xusertype > 255 then TypeProperty (t.name, 'Scale') else d.numeric_scale end) MINIMUM_SCALE, convert(smallint,case when d.ss_dtype in (55,63,106,108) and d.AUTO_INCREMENT = 0 and t.xusertype <= 255 then @@max_precision /* DECIMAL/NUMERIC */ when d.ss_dtype in (55,63,106,108) and d.AUTO_INCREMENT = 1 then 0 /* DECIMAL/NUMERIC IDENTITY*/ else TypeProperty (t.name, 'Scale') end) MAXIMUM_SCALE, d.SQL_DATA_TYPE, d.SQL_DATETIME_SUB, NUM_PREC_RADIX = convert(int,d.RADIX), INTERVAL_PRECISION = convert(smallint,NULL), USERTYPE = t.usertype from master.dbo.spt_datatype_info d INNER JOIN systypes t on d.ss_dtype = t.xtype LEFT OUTER JOIN master.dbo.spt_datatype_info_ext e on t.xusertype = e.user_type and isnull(d.AUTO_INCREMENT,0) = e.AUTO_INCREMENT where d.DATA_TYPE between @mintype and @maxtype and (d.ODBCVer is null or d.ODBCVer = @ODBCVer) and (t.xusertype <= 255 or isnull(d.AUTO_INCREMENT,0) = 0) order by 2, 12, 11, case when t.usertype=18 then 255 else t.usertype end "
Le code fourni plus haut et pour SQL 2005, or j'utilise SQL 2000
|
|
Cette discussion est classée dans : système, stockée, procédure, sp, databases
Répondre à ce message
Sujets en rapport avec ce message
Comment trouver le host dans une procédure stockée [ par btorchet ]
Bonjour,Je voudrais rerouver le host, nom de la machine, du poste a partir duquyel a été appelé une procédure stockée.Je connais host_name, quand je l
Like dans une procédure stockée [ par veronique1 ]
Bonjour à tous,j'utilise une requête dans une procédure stockée avec un like , la valeur provient d'un paramètre , et ma rquête ne fonctionne pas si j
Probleme avec Select Case [ par Geff ]
Bonjour à tous!J'ai un petit problème pour écrire une procédure stockée pour Sql Server 2000.Voici les données de mon problèmeJ'ai une table client et
Une procédure stockée pour : Ajouter OU Modifier OU Supprimer [ par Bowen123 ]
Bonjour,Je cherche a créer une procédure stockée pour ajouter,mettre a jour ou supprimer un element à partir d'un "id".Quelqu'un peut me mettre sur la
Paramètre de procédure stockée null [ par Leggoff ]
Bonjour à tous.Je souhaite passer en C# un paramètre null à une procédure stockée (Ma toute première procédure !).L'utilisation de null ne fonctionne
Procédure stockée [ par batobad ]
bonjourj'ai une base de données sur sql server qui contient quatre tables dont l'une, que j'ai appélée article, contient une clé primaire et trois clé
Abandon de transaction suite TimeOut dans procédure stockée [ par foxfred ]
Bonjour,Une procédure stockée appelée depuis une appli VB.Net effectue le traitement suivant :BEGIN TRANSACTION -- Suppression d'une contrainte dans
Récupérer le code d'une procédure stockée [ par yoannd ]
Bonjour les gens, Alors voila, je souhaite récupérer, au moyen d'une requete SQL, le code d'une procédure stockée (n'importe laquelle). Je sais que c
log procédure stockée (SQL Server) [ par jguillemette ]
bonjour,à partir d'un *.bat je lance un DTS qui exécute une procédure stockéla trace de l'exécution du *.bat est redigée dans un fichier logce dernier
PROMPT dans une procédure stockée [ par tedparker ]
Bonjour Est-il possible de demander des paramètres par un PROMPT dans une procédure PL SQL ? J'en ai super besoin. Je crée ma procédure dans un pack
Livres en rapport
|
Derniers Blogs
TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLETECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLE par ROMELARD Fabrice
Speakers: Julien Marechal, Gautier Confiant, Sébastien MEYER La session débute par le positionnement de la solution System Center par rapport aux concepts d'organisation ITIL. Le portail du catalogue de se...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : PLEINIèRE SECOND JOURTECHDAYS PARIS 2012 : PLEINIèRE SECOND JOUR par ROMELARD Fabrice
Après une première journée dédiée aux développeurs, cette seconde journée est dédiée au monde des entreprises et de ses applications. Ainsi, cette pleinière est dédiée à faire un 360 de l'évolution des applications Business aux demandes ac...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : RETOUR D'EXPéRIENCE SUR LA MISE EN PLACE D'UN CLOUD PRIVéTECHDAYS PARIS 2012 : RETOUR D'EXPéRIENCE SUR LA MISE EN PLACE D'UN CLOUD PRIVé par ROMELARD Fabrice
Speaker : Guillaume Rochette Cette session est dédiée à fournir le retour sur la mise en place d'un cloud privé (IaaS) par Osiatis pour son compte ou celui de ses clients. Ce projet s'est déroulé sur 4 mois et a permis de faire évoluer...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYSTECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYS par ROMELARD Fabrice
Speakers : Lionel Limozin et Alain Marty La session commence par une découverte de SharePoint à travers la mise en place d'un environnement SharePoint pour la gestion des Sessions animées par BeWise. Le besoin est très ba...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|