Friday, May 27, 2011

How to transfer blogspot blog to another account


1.First Sign into your blogger dashboard. Click on the settings link next to your blog name.[see the below screenshot]



2.Now,click on the Permissions


3.Before transfering your blog ie. before making someone admin,you need to first invite him and make him as author.Click on the 'ADD AUTHORS' button to add.


4.Enter the person's email id and click on the INVITE button.



5.After inviting him,blogger will send an email to that person asking him to visit a link and confirm that he is willing to contribute to your blog.


6.Once the invitee confirmed,go to the permissions page once again.Now,you will see an option to grant admin privileges to your partner.Click on the 'grant admin privileges' link and confirm.






7.Now,your blog has two admins.You will see the admin 'remove' link next to the author's name.Remove your's as admin(and also as author).Now your blog will be transfered from your account to your partner's.


That's it! Now,you easily transfered your blog from one account to another account.

Thursday, May 26, 2011

Deadlock in SQL Server

Deadlocks can be a pain to debug since they're so rare and unpredictable. The problem lies in repeating them in your dev environment. That's why it's crucial to have as much information about them from the production environment as possible.

Deadlocks occur when two (or more) processes are holding locks on resources and are waiting for locks on resources in such a way that they will never resolve.

Here I'm discussing a one of the way to monitor the Deadlocks.

How to Trace Deadlocks?
Get Info By ID

DBCC INPUTBUFFER(55)

Deadlocks can be traced by turning on two specific flags:
dbcc traceon (1204, 3605, -1)
go
dbcc tracestatus(-1)
Go

Deadlocks trace output can be examined in SQL Server log.

How to Avoid Deadlocks?
Here are some tips on how to avoid deadlocking on your SQL Server:
  • Ensure the database design is properly normalized.
  • Have the application access server objects in the same order each time.
  • During transactions, don’t allow any user input. Collect it before the transaction begins.
  • Avoid cursors.
  • Keep transactions as short as possible. One way to help accomplish this is to reduce the number of round trips between your application and SQL Server by using stored procedures or keeping transactions with a single batch. Another way of reducing the time a transaction takes to complete is to make sure you are not performing the same reads over and over again. If your application does need to read the same data more than once, cache it by storing it in a variable or an array, and then re-reading it from there, not from SQL Server.
  • Reduce lock time. Try to develop your application so that it grabs locks at the latest possible time, and then releases them at the very earliest time.
  • If appropriate, reduce lock escalation by using the ROWLOCK or PAGLOCK.
  • Consider using the NOLOCK hint to prevent locking if the data being locked is not modified often.
  • If appropriate, use as low of an isolation level as possible for the user connection running the transaction.  
  • Consider using bound connections.



Thursday, May 5, 2011

Concatenation in SELECT and SPLIT functions with Transact SQL

Scalar UDF with variable concatenation in SELECT 

CREATE FUNCTION dbo.udf_select_concat ( @c INT )
    RETURNS VARCHAR(MAX) AS BEGIN
    DECLARE @p VARCHAR(MAX) ;
           SET @p = '' ;
        SELECT @p = @p + ProductName + ','
          FROM Products
         WHERE CategoryId = @c ;
    RETURN @p
    END
And, as for its usage:
    SELECT CategoryId, dbo.udf_select_concat( CategoryId )
      FROM Products
     GROUP BY CategoryId ;

SPLIT Function
CREATE FUNCTION [dbo].[Split]
(
@RowData NVARCHAR(MAX),
@Delimeter NVARCHAR(MAX)
)
RETURNS @RtnValue TABLE
(
ID INT IDENTITY(1,1),
Data NVARCHAR(MAX)
)
AS
BEGIN
DECLARE @Iterator INT
SET @Iterator = 1
DECLARE @FoundIndex INT
SET @FoundIndex = CHARINDEX(@Delimeter,@RowData)
WHILE (@FoundIndex>0)
BEGIN
INSERT INTO @RtnValue (data)
SELECT
Data = LTRIM(RTRIM(SUBSTRING(@RowData, 1, @FoundIndex - 1)))
SET @RowData = SUBSTRING(@RowData,
@FoundIndex + DATALENGTH(@Delimeter) / 2,
LEN(@RowData))
SET @Iterator = @Iterator + 1
SET @FoundIndex = CHARINDEX(@Delimeter, @RowData)
END

INSERT INTO @RtnValue (Data)
SELECT Data = LTRIM(RTRIM(@RowData))
RETURN
END

GO

Sources : http://balavardhanreddy.over-blog.com/15-categorie-10814096.html
               http://www.projectdmx.com/tsql/rowconcatenate.aspx


Can not put more than one ModalPopup control in one page?

To Show one popup Panel from multiple controls, use one ModalPopupExtender bound to an invisible 'dummy' control, then call ModalPopupExtender.Show() from the OnClick Event of each control you wish to show the popup.

This example is most related with control are added inside of the grid view and also add checkboxlist control inside of the ModelPopup.

CSS
.modalBackground {
FILTER: alpha(opacity=70); BACKGROUND-COLOR: #fff; opacity: 0.7px
}
.modalPopup {
BORDER-BOTTOM: #ccc 3px solid; BORDER-LEFT: #ccc 3px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fff; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; BORDER-TOP: #ccc 3px solid; BORDER-RIGHT: #ccc 3px solid; PADDING-TOP: 5px;
}



ASPX
 <asp:Button ID="btnFade" runat="server" Text="" visible="true" Width="0"/> 
 <asp:ModalPopupExtender 
BackgroundCssClass="modalBackground" 
DropShadow="true" 
CancelControlID="btnCancel" 
runat="server" 
PopupControlID="pnlModelPopup" 
id="ModalPopupExtender1" 
TargetControlID="btnFade">
</asp:ModalPopupExtender> 
<asp:Panel ID="pnlModelPopup" runat="server" CssClass="modalPopup" style="display:none;"> 
<table >
<tr>
<td>Add / Modify Competencies<br /><br /> </td>
</tr>
<tr>
<td>
<div style="height:200px; border-style:solid; border-width:thin; overflow: auto; width:100%;" runat="server">
<asp:CheckBoxList ID="chklstCompetencies" runat="server"  RepeatColumns="0" >
</asp:CheckBoxList>
</div>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSave" runat="server" Text="Save" /> 
<asp:Button ID="btnCancel" runat="server" Text="Cancel" /> 
</td>
</tr>
</table>


</asp:Panel> 


In Codebehind any event if you want to fire for this ModelPopup then use this.
' show the modal popup
           popupLink_ModalPopupExtender.Show()


If you need to use Save button with some process in Code behind following property need to be deleted from the asp:ModalPopupExtender
OkControlID="btnOk"