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 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
PROCEDURE MYSQLPROCEDURE MYSQL par gearmat
Cliquez pour lire la suite par gearmat
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|