>DansTonCode();

Citation de code source en SQL167

 11 July 2014 à 09:41
CREATE FUNCTION [dbo].[get_number_of_workers] 
(
	 @number_of_workers varchar(10)

)
RETURNS int
AS
BEGIN


set @number_of_workers = replace(replace(replace(replace(LTRIM(RTRIM(@number_of_workers)), char(9), ''), char(10), ''), char(13),''), char(13)+char(10), '')

DECLARE @temp varchar(10)

SELECT
	@temp = number_of_workers 
FROM
	(SELECT LTRIM(RTRIM(@number_of_workers)) as number_of_workers) as temp
WHERE
	   number_of_workers like  '[0-9]'
	or number_of_workers like  '[0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9][0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9][0-9][0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
	or number_of_workers like  '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
	
	
RETURN CONVERT(INT, @temp)

END

Allez voir les citations similaires

Partagez cette citation

Prepare : 1.3890266418457ms Controller : 12.174844741821ms Render : 0.040054321289062ms Total : 13.603925704956ms array(17) { ["ru_oublock"]=> int(6048) ["ru_inblock"]=> int(672) ["ru_msgsnd"]=> int(0) ["ru_msgrcv"]=> int(0) ["ru_maxrss"]=> int(162840) ["ru_ixrss"]=> int(0) ["ru_idrss"]=> int(0) ["ru_minflt"]=> int(2394423) ["ru_majflt"]=> int(1) ["ru_nsignals"]=> int(0) ["ru_nvcsw"]=> int(11224) ["ru_nivcsw"]=> int(26899) ["ru_nswap"]=> int(0) ["ru_utime.tv_usec"]=> int(35607) ["ru_utime.tv_sec"]=> int(79) ["ru_stime.tv_usec"]=> int(982629) ["ru_stime.tv_sec"]=> int(10) }