Posts

Showing posts from November, 2008

Variable Value in Top Statement

i want create a Procedure that behave like this: declare @cnt int set @cnt =10 select top @cnt * from sw_user Where sw_user contains 20 records, and i want the variable to be the criteria of Top statement. so i can use this for a solution for this type of problem CREATE PROC Top10 @cnt int AS SET ROWCOUNT @cnt SELECT * FROM sw_user but some cases ROWCOUNT might not be work... so what, Note : This statement however is possible in SQL 2005, just add "()" in your variable like so: declare @cnt int set @cnt =10 select top (@cnt) * from sw_user

LINQ to XML : XElement and XAttribute

var _CountryLists = (from c in SW_Countries select new { c.ID, c.Name, c.Abbreviation }); var xml = new XElement("root",from c in _CountryLists select new XElement("nodes", new XAttribute("id", c.ID), new XAttribute("abb", c.Abbreviation), new XAttribute("name", c.Name))); return xml.ToString(); xml will return result like this... <root> <nodes id="13" abb="AUS" name="Australia" /> <nodes id="28" abb="MMR" name="Burma" /> <nodes id="33" abb="BRA" name="Brazil" /> <nodes id="35" abb="BTN" name="Bhutan" /> <nodes id="40" abb="CAN" name="Canada" /> <nodes id="43" abb="LKA" name="Sri Lanka" /> <nodes id="46" abb="CHN" name="China...