Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any simple way to get procedure full code?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01336897
Message ID:
01336956
Vues:
18
This message has been marked as the solution to the initial question of the thread.
>>>Hi everybody,
>>>
>>>With this code
>>>
>>>
>>>declare @LongName varchar(max)
>>>--set @LongName = ''
>>>--
>>>--select @LongName = @LongName + ' ' + ISNULL(FirstName,'') from Registration
>>>--select @LongName as LongName
>>>set @LongName = ''
>>>select name from sys.procedures order by name
>>>SELECT @LongName = @LongName + char(13) + OBJECT_DEFINITION(OBJECT_ID) from sys.procedures where Name Like 'Registration%'
>>>print @LongName
>>>
>>>I only get the first N number of lines. Is there a way to get whole code of my procedures into some convenient text format without opening each one using SSMS?
>>>
>>>Thanks a lot in advance.
>>
>>You get all code, but the PRINT cuts it to 8000 chars.
>>try:
>>
>>declare @LongName varchar(max)
>>set @LongName = ''
>>select name from sys.procedures order by name
>>SELECT @LongName = @LongName + char(13) + OBJECT_DEFINITION(OBJECT_ID)
>>             from sys.procedures
>>              where Name Like 'Registration%'  AND
>>              is_ms_shipped = 0 --- Only user SP
>>print @LongName
>>
>>SELECT @LongName, LEN(@LongName)
>>
>

NOT TESTED!!!!
DECLARE @Test TABLE (Id INT IDENTITY(1,1), Code varchar(max))

INSERT INTO @Test (Code)
SELECT OBJECT_DEFINITION(OBJECT_ID)
            from sys.procedures
            where Name Like 'Registration%'  AND
            is_ms_shipped = 0
DECLARE @lnCurrent int, @lnMax int
DECLARE @LongName varchar(max)

SELECT @lnMax = MAX(Id) FROM @Test
SET @lnCurrent = 1
WHILE @lnCurrent <= @lnMax
      BEGIN
            SELECT @LongName = Code FROM @Test WHERE Id = @lnCurrent
            print @LongName
            SET @lnCurrent = @lnCurrent + 1
      END
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform