This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[fnRemoveSpaces]( | |
@string_text VARCHAR(MAX), | |
@threshold int = 3 | |
) | |
RETURNS VARCHAR(MAX) | |
AS | |
BEGIN | |
DECLARE @tempText AS VARCHAR(MAX) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IsLowerCase]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) | |
DROP FUNCTION [dbo].[IsLowerCase] | |
GO | |
CREATE FUNCTION [dbo].[IsLowerCase] | |
( | |
@Char char | |
) | |
RETURNS BIT WITH SCHEMABINDING |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create function dbo.string2Date(@myDate nchar(50)) | |
returns datetime | |
as | |
begin | |
if isDate(@myDate) = 1 | |
return cast(@myDate as datetime) | |
return null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION Int2Time(@Time varchar(10), @amPM char(1)) | |
-- returns a dateTime value for the date and time specified. | |
-- expects a 'numeric' value for time...will excuse any characters | |
RETURNS SMALLDATETIME | |
AS | |
BEGIN | |
DECLARE @vTime AS VARCHAR(4), @Hour AS VARCHAR(2), @Minute AS VARCHAR(2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--SET ANSI_NULLS ON | |
--GO | |
--SET QUOTED_IDENTIFIER ON | |
--GO | |
--IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = | |
--OBJECT_ID(N'[dbo].[FormatSSN]') AND TYPE IN (N'FN', N'IF', N'TF', N'FS', N'FT')) | |
--DROP FUNCTION [dbo].[FormatSSN] | |
--GO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF EXISTS(SELECT * FROM information_Schema.routines WHERE Specific_Name = 'LogStatus' ) | |
DROP PROCEDURE LogStatus | |
GO | |
CREATE PROCEDURE dbo.LogStatus(@Msg AS VARCHAR(MAX)=NULL) | |
AS | |
BEGIN | |
DECLARE @CurrTime AS VARCHAR(100) | |
SET @CurrTime = GETDATE() | |
set @msg = (select [Name] from sys.Filegroups where is_default=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[FormatPhoneNumber] (@UnformattedPhoneNumber varchar(50)) | |
RETURNS varchar(12) | |
AS | |
BEGIN | |
DECLARE @FormattedPhoneNumber varchar(12) | |
SET @FormattedPhoneNumber = REPLACE(REPLACE(@UnformattedPhoneNumber,' ',''),'-','') | |
SET @FormattedPhoneNumber = CASE | |
WHEN ISNUMERIC(@FormattedPhoneNumber) = 1 AND LEN(@FormattedPhoneNumber) = 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dates = { | |
convert:function(d) { | |
// Converts the date in d to a date-object. The input can be: | |
// a date object: returned without modification | |
// an array : Interpreted as [year,month,day]. NOTE: month is 0-11. | |
// a number : Interpreted as number of milliseconds | |
// since 1 Jan 1970 (a timestamp) | |
// a string : Any format supported by the javascript engine, like | |
// "YYYY/MM/DD", "MM/DD/YYYY", "Jan 31 2009" etc. | |
// an object : Interpreted as an object with year, month and date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example 1 :- sum of array | |
var numberArray = [1,2,3,4,5,6,7,8,9,10]; | |
//for version | |
var sum = 0; | |
for (var counter=0; counter < numberArray.length; counter++){ | |
sum += numberArray[counter] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example 1 :- contains 5 | |
var numberArray = [1,2,3,4,5,6,7,8,9,10]; | |
//for Version | |
var hasFive = false; | |
for (var counter=0; counter < numberArray.length; counter++){ | |
if (numberArray[counter] === 5){ | |
hasFive = true; | |
break; |