Go/***** object: storedprocedure [DBO]. [e_get_datetimestrguid] script Date: 12/27/2012 15:07:38 ******/set ansi_nulls ongoset quoted_identifier ongo -- ================ =================================-- Author: <HSG> -- create Date: <2012-12-27> -- Description: <obtain the unique ID of a date and time> -- call method: Execute DBO. e_get_datetimestrguid; -- ===================================================== ====== alter procedure [DBO]. [e_get_datetimestrguid] -- add the parameters for the stored procedure hereasbegin -- set nocount on added to prevent extra result sets from -- interfering with select statements. -- declare the return variable heredeclare @ t_dt varchar (30); declare @ rd_num float; declare @ rd_str varchar (10 ); -- add the T-SQL statements to compute the return value hereset @ t_dt = convert (varchar, getdate (), 21); Set @ t_dt = Replace (@ t_dt ,'-', ''); Set @ t_dt = Replace (@ t_dt, ':',''); Set @ t_dt = Replace (@ t_dt ,'. ', ''); Set @ t_dt = Replace (@ t_dt ,'',''); -- return the result of the function -- generate an elliptical machine count select @ rd_num = floor (RAND () * 99999); Set @ rd_str = convert (varchar, @ rd_num ); -- merge a select @ t_dt + @ rd_str; End
/***** Object: userdefinedfunction [DBO]. [a_get_datetimestrguid] script Date: 12/27/2012 14:33:29 ******/set ansi_nulls ongoset quoted_identifier ongo -- ================ =================================-- Author: <HSG> -- create Date: <2012-12-27> -- Description: <obtain the unique ID of a date and time> -- call method: Select DBO. a_get_datetimestrguid (); -- ===================================================== ====== alter function [DBO]. [a_get_datetimestrguid] () returns varchar (30) asbegin -- declare the return variant heredeclare @ t_dt varchar (30); declare @ rd_num float; declare @ rd_str varchar (10 ); -- add the T-SQL statements to compute the return value hereset @ t_dt = convert (varchar, getdate (), 21); Set @ t_dt = Replace (@ t_dt ,'-', ''); Set @ t_dt = Replace (@ t_dt, ':',''); Set @ t_dt = Replace (@ t_dt ,'. ', ''); Set @ t_dt = Replace (@ t_dt,'', ''); -- return the result of the functionreturn @ t_dt; End