declare @vSQL varchar(1000)
declare @n int
set @n=5
set @vSQL='select Top 1 EmpSalary From
(Select Distinct Top ' + convert(varchar, @n) + ' EmpSalary
from EmpsInfo order by EmpSalary desc) a
order by EmpSalary'
exec(@vSQL)
declare @retstr varchar(8000)
select @retstr = COALESCE(@retstr + ',','') + cast(memno as varchar) from sample where sno=1
print @retstr
Tuesday, March 24, 2009
preparing Insert statement for the ros exst in table -sql server
Declare @qt as varchar(1000)
set @qt = ''''
print @qt
select 'insert into program values ',ProgramID, ',', ProgramCode ,',', @qt+ Description + @qt from program
set @qt = ''''
print @qt
select 'insert into program values ',ProgramID, ',', ProgramCode ,',', @qt+ Description + @qt from program
Monday, March 23, 2009
Regular expression for a Foramt 'XX99999X'
function validationForXYZ()
{
var iKeyCode,strKey;
if(window.event)
iKeyCode = window.event.keyCode;
if ((iKeyCode > 96) && (iKeyCode < keycode =" iKeyCode-32;" ikeycode =" window.event.keyCode;" strkey =" String.fromCharCode(iKeyCode);" obj =" document.getElementById('txtAgencyCIN');" value =" obj.value.toUpperCase();" xyzval =" obj.value" validchars =" /^[A-Z]{1,2}$/;">=3) && (XYZVal.length <= 7)) //checking next 5 chars of numbers
validChars = /^[A-Z]{2}[0-9]{1,5}$/;
else if (XYZVal.length ==8)
validChars = /^[A-Z]{2}[0-9]{5}[A-Z]$/; //again last two if chars
else
return false;
if(!validChars.test(XYZVal))
{
alert("Invalid XYZ format: If present, it must be 8 characters in the format: 'XX99999X'. (eg. AB74819R)");
return false;
}
}
{
var iKeyCode,strKey;
if(window.event)
iKeyCode = window.event.keyCode;
if ((iKeyCode > 96) && (iKeyCode < keycode =" iKeyCode-32;" ikeycode =" window.event.keyCode;" strkey =" String.fromCharCode(iKeyCode);" obj =" document.getElementById('txtAgencyCIN');" value =" obj.value.toUpperCase();" xyzval =" obj.value" validchars =" /^[A-Z]{1,2}$/;">=3) && (XYZVal.length <= 7)) //checking next 5 chars of numbers
validChars = /^[A-Z]{2}[0-9]{1,5}$/;
else if (XYZVal.length ==8)
validChars = /^[A-Z]{2}[0-9]{5}[A-Z]$/; //again last two if chars
else
return false;
if(!validChars.test(XYZVal))
{
alert("Invalid XYZ format: If present, it must be 8 characters in the format: 'XX99999X'. (eg. AB74819R)");
return false;
}
}
Saturday, March 21, 2009
Friday, March 20, 2009
options for a Question and Tips of DataTable and DataView
lblQ.Text = "what is the result of the following equation?";
Panel1.Controls.Add(lblQ);
rdOptions.Items.Add(First(dt.Rows[intOpt][2].ToString()));
rdOptions.RepeatDirection = RepeatDirection.Horizontal;
rdOptions.RepeatLayout = RepeatLayout.Table;
rdOptions.RepeatColumns = 2;
rdOptions.Width = 400;
rdOptions.CellSpacing = 3;
rdOptions.CellPadding = 3;
Panel1.Controls.Add(rdOptions);
Rowfilter on DT using DataView
-------------------------------
DataView dvSearchResults = dt.DefaultView;
dvSearchResults.RowFilter = "Name LIKE " + "'" + lastname + "%" + "'";
Removing the rows in the column 'Name' containing "Unknown"
------------------------------------------------------------
DataRow[] unknownRecords=ResultsTable.Select("Name='Unknown *'");
foreach(DataRow drUnknownRecs in unknownRecords)
ResultsTable.Rows.Remove(drUnknownRecs);
Querying using DataRow[] object and select Method(XYZ- col name)
--------------------------------------------------
DataRow[] flagDeletedRecords=dtChildActivity.Select("XYZ=1");
Like Operator in DataTable using DataTable.Select
------------------------------------------------
Select("Code LIKE '" + lastWord + "%'" );
Panel1.Controls.Add(lblQ);
rdOptions.Items.Add(First(dt.Rows[intOpt][2].ToString()));
rdOptions.RepeatDirection = RepeatDirection.Horizontal;
rdOptions.RepeatLayout = RepeatLayout.Table;
rdOptions.RepeatColumns = 2;
rdOptions.Width = 400;
rdOptions.CellSpacing = 3;
rdOptions.CellPadding = 3;
Panel1.Controls.Add(rdOptions);
Rowfilter on DT using DataView
-------------------------------
DataView dvSearchResults = dt.DefaultView;
dvSearchResults.RowFilter = "Name LIKE " + "'" + lastname + "%" + "'";
Removing the rows in the column 'Name' containing "Unknown"
------------------------------------------------------------
DataRow[] unknownRecords=ResultsTable.Select("Name='Unknown *'");
foreach(DataRow drUnknownRecs in unknownRecords)
ResultsTable.Rows.Remove(drUnknownRecs);
Querying using DataRow[] object and select Method(XYZ- col name)
--------------------------------------------------
DataRow[] flagDeletedRecords=dtChildActivity.Select("XYZ=1");
Like Operator in DataTable using DataTable.Select
------------------------------------------------
Select("Code LIKE '" + lastWord + "%'" );
searching for a word in a column
searching for word Manager in the column 'Job Title' and make it bold if it have
=CONCATENATE("<DIV",IF(ISERROR(SEARCH("Manager",[Job Title],1))," "," style='font-weight:bold;'"),">",[First Name]," ",[Last Name],"</DIV>")
=CONCATENATE("<DIV",IF(ISERROR(SEARCH("Manager",[Job Title],1))," "," style='font-weight:bold;'"),">",[First Name]," ",[Last Name],"</DIV>")
Restoring the Quick Launch Bar in Web Part Pages
You'll notice that when creating Web Part Pages in SharePoint 2007 that the Quick Launch Bar is not included in the template. Here are the quick instructions (that require SharePoint Designer) to restore the Quick Launch Bar:
Open the web part page in SharePoint designer
Find and delete the following two lines:
asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"
asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"
Save the file
Open the web part page in SharePoint designer
Find and delete the following two lines:
asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"
asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"
Save the file
SPSite and SPWeb
using(SPSite oSiteCollection = new SPSite("http://Server_Name"))
{
using(SPWeb oWebsite = oSiteCollection.OpenWeb("Website_URL"))
{
using(SPWeb oWebsiteRoot = oSiteCollection.RootWeb)
{
...
}
}
}
{
using(SPWeb oWebsite = oSiteCollection.OpenWeb("Website_URL"))
{
using(SPWeb oWebsiteRoot = oSiteCollection.RootWeb)
{
...
}
}
}
Subscribe to:
Posts (Atom)