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 |
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 |
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 |