Skip to content

Instantly share code, notes, and snippets.

View jotapardo's full-sized avatar
🏠
Working from home

Javier Pardo jotapardo

🏠
Working from home
  • Colombia
View GitHub Profile
@jotapardo
jotapardo / dbo.TRY_CAST.sql
Last active June 1, 2022 13:11
TRY_CAST Function for SQL Server 2008
DECLARE @strSQL NVARCHAR(1000)
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[TRY_CAST]'))
BEGIN
SET @strSQL = 'CREATE FUNCTION [dbo].[TRY_CAST] () RETURNS INT AS BEGIN RETURN 0 END'
EXEC sys.sp_executesql @strSQL
END
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON