Click here to Skip to main content
15,890,377 members
Articles / Database Development / SQL Server
Alternative
Tip/Trick

I don’t know why my boss always gets angry

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
14 Jun 2011CPOL 9K   2   5
Why don't you just use a query like this?SELECT CAST(serverproperty(N'servername') AS varchar(50)) AS [Server Name], db_name() AS [Database Name], SCHEMA_NAME(schema_id) AS [Schema Name], [name] AS [Object Name], [type_desc] AS [Object Type], [create_date] AS [Create...
Why don't you just use a query like this?

SELECT 
	CAST(serverproperty(N'servername') AS varchar(50)) AS [Server Name],
	db_name() AS [Database Name],
	SCHEMA_NAME(schema_id) AS [Schema Name],
	[name] AS [Object Name],
	[type_desc] AS [Object Type],
	[create_date] AS [Create Date],
	[modify_date] AS [Modified Date]
FROM sys.all_objects
WHERE
	[is_ms_shipped] = 0
ORDER BY
	[modify_date]


That will tell you the create date PLUS the modified date. You can easily filter the list by adding qualifiers to the WHERE statement.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Unknown
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: Hi John Kasra: Thanks a lot for your valuable clarificatio... Pin
Md. Marufuzzaman27-Jun-11 19:03
professionalMd. Marufuzzaman27-Jun-11 19:03 
GeneralHi John Kasra: Thanks a lot for your valuable clarification... Pin
Md. Marufuzzaman27-Jun-11 19:02
professionalMd. Marufuzzaman27-Jun-11 19:02 
GeneralIs this transect-sql give me the correct result after restor... Pin
Md. Marufuzzaman13-Jun-11 22:13
professionalMd. Marufuzzaman13-Jun-11 22:13 
GeneralRe: Correct. ALTER statements are unable to be used to re-creat... Pin
John B Oliver27-Jun-11 12:18
John B Oliver27-Jun-11 12:18 
Correct. ALTER statements are unable to be used to re-create a database.
With a system of over 1000 stored procedures, functions and views (not to mention indexes, foreign keys etc), the task of re-creating a database is not easy.
If your source control system only contains ALTER statements, then you have to find a way of creating the stored procedures in the first place. You could store both the ALTER and CREATE scripts, but you can guarantee there will be discrepancies between the two scripts.
This does render the [modify_date] field value redundant, but I'm happy to live with this as it doesn't really give you anything of benefit.

And all you need are 3 lines of code.
if not object_id('<owner>.<procname>', 'P') is null
drop procedure <owner>.<procname>;
go

create procedure <owner>.<procname>
...
GeneralLovely... Pin
Md. Marufuzzaman13-Jun-11 20:34
professionalMd. Marufuzzaman13-Jun-11 20:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.