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
[HS] CHROME 6 + MOI = COUP DE GUEULE ![HS] CHROME 6 + MOI = COUP DE GUEULE ! par JeremyJeanson
Attention, le poste qui suit n'est pas la complainte d'une personne : Qui n'aime pas Chrome. D'un anti Google. D'un développeur qui a un poil énorme dans la main. Ceux qui me fréquentent savent que je change de navigateur favori tous les 2 ou 3 mois afin ...
Cliquez pour lire la suite de l'article par JeremyJeanson [WP7] UTILISER UN WRAPPANEL DANS UNE APPLICATION WINDOWS PHONE 7[WP7] UTILISER UN WRAPPANEL DANS UNE APPLICATION WINDOWS PHONE 7 par Audrey
Lors de la réalisation de ma 2ème application Windows Phone 7, j'ai souhaité utiliser un WrapPanel pour afficher plusieurs photos. Mais le contrôle WrapPanel ne fait pas parti de la liste des contrôles inclus dans le SDK de la version Beta des outils pour...
Cliquez pour lire la suite de l'article par Audrey [WP7] BESOIN D'AVOIR DES DONNéES EN CACHE[WP7] BESOIN D'AVOIR DES DONNéES EN CACHE par Nicolas
Les développeurs ASP.NET ont l'habitude de mettre des données en cache pour éviter de requêter a chaque fois la base de données. Et il est toujours utilie de penser que vos utilisateurs mobiles n'ont pas troujours une super connexion 3G/WIFI et un for...
Cliquez pour lire la suite de l'article par Nicolas [TFS] COMMENT FORCER LA SAISIE D'UN AREA OU ITERATION[TFS] COMMENT FORCER LA SAISIE D'UN AREA OU ITERATION par cyril
Lorsque l'on créé un Work Item dans TFS, il est possible de le classer dans un "area" et dans une "iteration". Dans la plupart des types de projet, un "area" correspond à une catégorie, une "iteration" à un numéro de version. Il est possible de cré...
Cliquez pour lire la suite de l'article par cyril SQL : FONCTIONS D'AGRéGATION MIN/MAX ET VALEURS NULLSQL : FONCTIONS D'AGRéGATION MIN/MAX ET VALEURS NULL par coq
Les fonctions d'agrégation comme MIN et MAX ignorent les valeurs NULL présentes dans le jeu de données sur lequel porte leur calcul, d'où le fameux message d'avertissement : Warning: Null value is eliminated by an aggregate or other SET operation...
Cliquez pour lire la suite de l'article par coq
Logiciels
Bureau de Gestion - ERP Devis Facturation (2.02)BUREAU DE GESTION - ERP DEVIS FACTURATION (2.02)
- Version gratuite du 10/06/2010
Le Bureau de Gestion est un logiciel dédié à la gestion de l'en...
Cliquez pour télécharger Bureau de Gestion - ERP Devis Facturation sDEVIS-FACTURES vlPRO (3.8.0)SDEVIS-FACTURES VLPRO (3.8.0)sDEVIS-FACTURES vlPRO a été mis au point pour permettre besoins des particuliers, créateurs, entr... Cliquez pour télécharger sDEVIS-FACTURES vlPRO LettresFaciles (5.6.0)LETTRESFACILES (5.6.0)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles MyPlanning 2010 (5.6.0)MYPLANNING 2010 (5.6.0)MyPlanning 2010 permet de créer des plannings sous la représentation de diagrammes. Plannings pré... Cliquez pour télécharger MyPlanning 2010 Emicsoft Mac DVD en iPad Convertisseur (3.1.16)EMICSOFT MAC DVD EN IPAD CONVERTISSEUR (3.1.16)Emicsoft Mac DVD en iPad Convertisseur, logiciel professionnel de convertir les fichiers DVD en i... Cliquez pour télécharger Emicsoft Mac DVD en iPad Convertisseur
|