Friday, 27 May 2011

Add/Remove values from Drop Down box at Run Time in MSCRM


Add/Remove values from Drop Down box at Run Time in MSCRM

//Write this code on Change Event of Main Drop Down Box, It will change the value in second drop down.

crmForm.all.leb_subcategoryoftopup.remove(0);
crmForm.all.leb_subcategoryoftopup.remove(1);
crmForm.all.leb_subcategoryoftopup.remove(2);
crmForm.all.leb_subcategoryoftopup.remove(3);
crmForm.all.leb_subcategoryoftopup.remove(4);

if(crmForm.all.leb_reasonfortopup.DataValue <5){
crmForm.all.leb_subcategoryoftopup.disabled=true;
}
else
{
crmForm.all.leb_subcategoryoftopup.disabled=false;


if(crmForm.all.leb_reasonfortopup.DataValue ==5)
{
crmForm.all.leb_subcategoryoftopup.AddOption("Smile Call Offer", 1);
crmForm.all.leb_subcategoryoftopup.AddOption("Complaint Compensation", 2);
crmForm.all.leb_subcategoryoftopup.AddOption("Promo Credit", 3);
}

if(crmForm.all.leb_reasonfortopup.DataValue ==6)
{
crmForm.all.leb_subcategoryoftopup.AddOption("False Answer refund", 4);
crmForm.all.leb_subcategoryoftopup.AddOption("Expired Balance Transfer", 5);
crmForm.all.leb_subcategoryoftopup.AddOption("Lost/Stolen Balance Transfer", 6);
crmForm.all.leb_subcategoryoftopup.AddOption("Voucher Error/Blocked", 7);
}

if(crmForm.all.leb_reasonfortopup.DataValue ==7)
{
crmForm.all.leb_subcategoryoftopup.AddOption("Expired Balance Transfer", 8);
crmForm.all.leb_subcategoryoftopup.AddOption("Balance Correction", 9);
crmForm.all.leb_subcategoryoftopup.AddOption("Online Top-up Decline", 10);
}



}

Wednesday, 25 May 2011

Create Separate File Group to create Indexing

Here are the steps to create separate file group for indexing on any table. We can use different file location (on hard disk) for file group to avoid the problem of space on hard disk.

step 1: 
Right Click Database -> Properties

Step 2: 
Click on file groups option - > Add  -> Enter some file name

Step 3:

Click on Files -> Add -> Enter some Database file name and Select FileGroup created in above Step-2

Step 4: 
Click Ok Or Click on Script on the top to create SQL Script and then run through that Script.
It will take some time.

Step 5 : Index Creation:
Go to Database - > Indexes - > Create New Index:
Enter some index name - > Click on Add -> select the field name




Step 6:
Click on Storage from left side.
Next to filegroup option select the filegroup created in step 2




Step 6:
Click Ok Or click on Script on the top to generate the Script and then run that script.

It will take some time to finish indexing depending on the size of database.





Tuesday, 17 May 2011

Update Statistics to Improve performance

You can improve query performance by using UPDATE STATISTICS or the stored proceduresp_updatestats to update statistics more frequently than the default updates.


Updating statistics ensures that queries compile with up-to-date statistics. However, updating statistics causes queries to recompile. We recommend not updating statistics too frequently because there is a performance tradeoff between improving query plans and the time it takes to recompile queries. The specific tradeoffs depend on your application. UPDATE STATISTICS can use tempdb to sort the sample of rows for building statistics.


USE AdventureWorks2008R2;
GO
EXEC sp_updatestats 

TO CREATE STATISTICS SCRIPT FOR ALL DATABASES on a DATABASE SERVER:
CREATE PROCEDURE SPUpdateStats
AS Set Nocount on Declare db Cursor For Select distinct(Databasename) as Name FROM T_TableReindexing(nolock) --Select name from master.dbo.sysdatabases where name in ('dbmonitor') and name --not in ('master','TempDB', 'msdb', 'model') Declare @dbname varchar(60) Declare @execmd nvarchar(150) Open db Fetch Next from db into @dbname While @@Fetch_status=0 begin if @dbname is null Begin Print 'null Value' Return end else Begin PRINT '###########################################################################' PRINT 'Update Statistics in ' + @dbname SELECT @execmd = 'USE ' + @dbname + ' EXEC sp_updatestats' Print (@execmd) PRINT '' End Fetch Next from db into @dbname end Close db Deallocate db

BCP Command


Open the Command Prompt and use the following command for quick and fast backup.

Selected Query:


BCP "select * from GBRVIEW.dbo.CDR_0(nolock) where charging_timestamp between '2011-05-01' and '2011-05-31 23:59:59.997' and CDR_SPECIFIC_ID not in (select CDR_SPECIFIC_ID from GBRVIEW.dbo.cdr201105(nolock))" queryOut V:\May_CDR_0_Archive\GBRVIEW_CDR_PartCDRMay11_MISSING2_May11.txt -c -T -S LEB-ODSMSSQL2




Whole table without any condition:

BCP gbrview.dbo.cdr201105 Out T:\cdrbACKUP\GBRCDR201105.txt -c -T -S LEB-ODSMSSQL2

Wednesday, 23 February 2011

what is Log Shipping in SQL Server

What is Log Shipping

Essentially, log shipping is the process of automating the backup of database and transaction log files on a production SQL server, and then restoring them onto a standby server. But this is not all. The key feature of log shipping is that is will automatically backup transaction logs throughout the day (for whatever interval you specify) and automatically restore them on the standby server. This in effect keeps the two SQL Servers in "synch". Should the production server fail, all you have to do is point the users to the new server, and you are all set. Well, its not really that easy, but it comes close if you put enough effort into your log shipping setup.

Read more detail from :
http://www.sql-server-performance.com/articles/clustering/log_shipping_70_p1.aspx

Benefits of Log Shipping

While I have already talked about some of the benefits of log shipping, let's take a more comprehensive look:
  • Log shipping doesn't require expensive hardware or software. While it is great if your standby server is similar in capacity to your production server, it is not a requirement. In addition, you can use the standby server for other tasks, helping to justify the cost of the standby server. Just keep in mind that if you do need to fail over, that this server will have to handle not one, but two loads. I like to make my standby server a development server. This way, I keep my developers off the production server, but don't put too much work load on the standby server.
  • Once log shipping has been implemented, it is relatively easy to maintain.
  • Assuming you have implemented log shipping correctly, it is very reliable.
  • The manual failover process is generally very short, typically 15 minutes or less.
  • Depending on how you have designed your log shipping process, very little, if any, data is lost should you have to failover. The amount of data loss, if any, is also dependent on why your production server failed.
  • Implementing log shipping is not technically difficult. Almost any DBA with several months or more of SQL Server 7 experience can successfully implement it.

Monday, 14 February 2011

SQL Query to find Who is Blocking database

Simple Script to get Blocking Info in SQL Server Database:


select * from
(select spID, blocked, program_name, loginame from sys.sysprocesses (nolock) where blocked <> 0) locks,
(select spID, blocked, program_name, loginame from sys.sysprocesses (nolock)) allprocess
where locks.blocked = allprocess.spId

How to Find blocking Information in SQL Server

Objective: Below script is to find the blocking information in SQL Server


Declare @wTable Table (spid int, blocked int, loginame varchar(100), dbName varchar(100), last_batch dateTime)

Insert into @wTable
select spid, blocked, loginame, db_name(dbid), last_batch from sys.sysprocesses (nolock)--where blocked <> 0
select spid,blocked,loginame,dbName,last_batch from @wtable where blocked <> 0
Union all
select spid,blocked,loginame,dbName,last_batch from @wtable where spId in(select blocked from @wtable where blocked <> 0)
order by blocked