Wednesday, August 27, 2014

Computed Columns and CASE SQL Server

CASE
       WHEN shipdate is NULL AND orderdate < DATEADD( dd, -7, GETDATE()) THEN 3
       WHEN shipdate is NOT NULL THEN 2
       ELSE 1
END

Wednesday, August 20, 2014

How to convert type 'byte[]' to 'System.Data.Linq.Binary'

System.Data.Linq.Binary has a constructor taking 1 argument of byte[]:

var byt = new System.Data.Linq.Binary(bytes);

Friday, August 15, 2014

Get datakey value inside listview itemcommand

ListViewItem lvi = e.Item;
int id = Convert.ToInt32(ListView1.DataKeys[lvi.DataItemIndex].Value);

Tuesday, August 12, 2014

How do I use an INSERT statement's OUTPUT clause to get the identity value?

DECLARE @OutputTbl TABLE (ID INT)
 
DECLARE @ID int
 
INSERT INTO TBL(Name, Email)
OUTPUT INSERTED.ID INTO @OutputTbl(ID)
VALUES ('ABC', 'email@gmail.com')
 
SELECT @ID = ID FROM @OutputTbl ot

Friday, August 1, 2014

Disable button on form submit using jQuery

JQuery
<script>
    $('form').submit(function () {
        $(this).children('[type=submit]').prop('disabled'true);
    });
</script>