Skip to content

Instantly share code, notes, and snippets.

Alex White alexdwhite

Block or report user

Report or block alexdwhite

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alexdwhite
alexdwhite / GetCardType.sql
Last active Feb 25, 2019
Function to determine credit card type from card number (SQL)
View GetCardType.sql
-- create the function in SQL
CREATE FUNCTION [dbo].[GetCardType] (@CardNum varchar(100))
RETURNS varchar(10)
AS
BEGIN
DECLARE @type varchar(10)
if (left(@CardNum, 1) = '4')
begin
@alexdwhite
alexdwhite / Sample SQL Update with Join statement
Created Mar 18, 2018
I wrote a joined updated statement today, and figured it would be good to get some generic code up here to reference in the future. Here is how to do a simple update that updates the values of one table, to another on a common key.
View Sample SQL Update with Join statement
update
a
set
a.Field1 = b.Field1,
a.Field2 = b.Field2
from tableA a
inner join tableB b on a.fKey = b.pKey
where a.pKey = @someValue
@alexdwhite
alexdwhite / SQLTempTableLoop
Last active Dec 29, 2015
SQL Temp Table Loop
View SQLTempTableLoop
-- This can be performed numerous ways, and can also be performed more efficiently, but I broke out the
-- sections so that they are easy to identify and understand
-- create temp table
declare @tbl table (id int identity, valueA int)
-- used for the loop
declare @ptr int, @max int, @valueA int
-- insert list of ID's into temp table
You can’t perform that action at this time.