Wednesday, May 11, 2011
Tuesday, April 26, 2011
HierachyID in Sql Server 2008

create table #region
(
nodeID hierarchyid,
regionID int identity(1,1),
regionName varchar(100),
)
-- First row
insert into #region(nodeID,regionName) values(hierarchyid::GetRoot(),'India')
go
-- Second row
declare @rootID hierarchyid = (select hierarchyid::GetRoot() from #region)
insert into #region (nodeID,regionName) values(@rootID.GetDescendant(NULL,NULL),'Kerala')
--Third row
declare @firstChild hierarchyid = @rootID.GetDescendant(NULL,NULL)
insert into #region (nodeID,regionName) values(@rootID.GetDescendant(@firstChild,NULL),'Tamilnadu')
-- Kerala -> Palakkad
select @rootID = CAST('/1/' as hierarchyid)
insert into #region (nodeID,regionName) values(@rootID.GetDescendant(NULL,NULL),'Palakkad')
-- Kerala -> Trivandrum
select @firstChild = @rootID.GetDescendant(NULL,NULL)
insert into #region (nodeID,regionName) values(@rootID.GetDescendant(@firstChild,NULL),'Trivandrum')
-- Kerala -> Calicut
declare @secondChild hierarchyid
select @secondChild = @rootID.GetDescendant(@firstChild,NULL)
insert into #region (nodeID,regionName) values(@rootID.GetDescendant(@secondChild,NULL),'Calicut')
-- Kerala -> Kannur
declare @thirdChild hierarchyid
select @thirdChild = @rootID.GetDescendant(@secondChild,NULL)
insert into #region (nodeID,regionName) values(@rootID.GetDescendant(@thirdChild,NULL),'Kannur')
-- Kerala -> Palakkad -> Mannarkkad
select @rootID = CAST('/1/1/' as hierarchyid)
insert into #region (nodeID,regionName) values(@rootID.GetDescendant(NULL,NULL),'Mannarkkad')
select * from #region
select nodeID.ToString(), regionName from #region
drop table #region
Difference between float and decimal
DECLARE @Float1 float, @Float2 float, @Float3 float, @Float4 float;
SET @Float1 = 54;
SET @Float2 = 3.1;
SET @Float3 = 0 + @Float1 + @Float2;
SELECT @Float3 - @Float1 - g@Float2 AS "Should be 0";

DECLARE @Float1 decimal(8,3), @Float2 decimal(8,3), @Float3 decimal(8,3), @Float4 decimal(8,3);
SET @Float1 = 54;
SET @Float2 = 3.1;
SET @Float3 = 0 + @Float1 + @Float2;
SELECT @Float3 - @Float1 - @Float2 AS "Should be 0";

SET @Float1 = 54;
SET @Float2 = 3.1;
SET @Float3 = 0 + @Float1 + @Float2;
SELECT @Float3 - @Float1 - g@Float2 AS "Should be 0";

DECLARE @Float1 decimal(8,3), @Float2 decimal(8,3), @Float3 decimal(8,3), @Float4 decimal(8,3);
SET @Float1 = 54;
SET @Float2 = 3.1;
SET @Float3 = 0 + @Float1 + @Float2;
SELECT @Float3 - @Float1 - @Float2 AS "Should be 0";

Monday, April 25, 2011
Friday, March 25, 2011
Client script inside C#
$(document).ready(function() {";
st += " if(" + sales_tot_qty.ToString() + "==" + selected_qty.ToString() + ")";
st += " {";
st += " $('#tabs').tabs('enable',1);";
st += " }";
st += " else";
st += " {";
st += " $('#tabs').tabs('disable',1);";
st += " }";
st += "});";
st += "";
Page.ClientScript.RegisterStartupScript(typeof(string), "tabswitch", st);
st += " if(" + sales_tot_qty.ToString() + "==" + selected_qty.ToString() + ")";
st += " {";
st += " $('#tabs').tabs('enable',1);";
st += " }";
st += " else";
st += " {";
st += " $('#tabs').tabs('disable',1);";
st += " }";
st += "});";
st += "";
Page.ClientScript.RegisterStartupScript(typeof(string), "tabswitch", st);
Subscribe to:
Posts (Atom)