Saturday 20 August 2016

Autogenerate GUID in SQL Table

Hi,
Today I was working on SQL Table creation and I had a requirement to generate a UniqueIdentifier automatically whenever a record is inserted into the table.

We can achieve this requirement by having Column datatype as 'UniqueIdentifier' and Default Value or Binding of the column property should be set to 'newid()'
Hope this helps.
--
Happy Coding

Gopinath

Thursday 18 August 2016

Get an item from JSON/Filter JSON

Hi,

Today I was working on JavaScript and I had a requirement to get one item from JSON object.
Here is the sample code for filtering.

var vJsonArr = [];
vJsonArr.push({ name: "k1", value: "abc" });
vJsonArr.push({ name: "k2", value: "def" });
vJsonArr.push({ name: "k3", value: "ghi" });
var vfound = vJsonArr.filter(function (item) { return item.name === 'k1'; });

Hope this helps.
--
Happy Coding

Gopinath