Posts

Showing posts from 2010

search text in Stored Procedures

Do you want to find any text in Stored Procedures in SQL Server Database ?
"select * from INFORMATION_SCHEMA.ROUTINES" returns Procedure,Function exist in specific database. You will see objects and details in columns.
P.S:Please do not hesitate to share your comments.

Notes about Merge Replication

some usefull stored procedures you may use during merge replication;
* - EXEC sp_adjustpublisheridentityrange @publication='Publication_Name' //adjust identity range,if you get any error related with identity renge , you can reset identity offset managed by agent
* - EXEC sp_helpmergearticle @publication='Publication_Name' //retrieve article(s) information in given Publication_Name
* - EXEC sp_changemergearticle @publication='Publication_Name', @article = 'Article_Name' , @Property = 'identityrangemanagementoption', //What would you like to do.ie disable identity management by agent @Value = 'Manual', @force_invalidate_snapshot = 0
//change article property ( http://msdn.microsoft.com/en-us/library/ms174386.aspx )


ERROR MESSAGE :
The Publisher failed to allocate a new set of identity ranges for the subscription.
This can occur when a Publisher or a republishing Subscriber has run out of identity ranges to allocate to its own Subscribers or when an identity column data type does not support an additional identity range allocation. If a republishing Subscriber has run out of identity ranges, synchronize the republishing Subscriber to obtain more identity ranges before restarting the synchronization.
If a Publisher runs out of identit (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147199417)
EXECUTE : sp_adjustpublisheridentityrange @publication='PUBLISHED_DATABASE_NAME' (ref : http://msdn.microsoft.com/en-us/library/ms181527.aspx )

set Not For Replication True via Stored Procedure

Some administrator may not prefer to use SQL Server Management Studio for the strictions such as timeout or following Foreign Key exists;
To set or UnSet "Not for Replication" property of any column you want to use in Replication;
DECLARE @ObjectID INT = OBJECT_ID('dbo.tFileProvider') //get Object Id

execsys.sp_identitycolumnforreplication @object_id = 246291937, @value = 1 //0 : No ; 1 : yes

How to copy last updated file into other location by command batch

this scripts copy lastlly updated file from given path into target path.It looks only selected directory it does not look for sub-directory. just create xxx.bat and call with 2 parameters usage : xxx.bat source_path target_path ex: command.bat d:\sil\from d:\sil\to
::Copy Files Made Or Modified Today @echo off
set y=0 set source=%1 set dest=%2 pushd "%source%" for /f %%a in ('dir /b /a-d /o-d') do call :PROCESS "%%a" popd goto :eof :PROCESS if %y%==0 copy %1 "%dest%" if %y%==0 set y=1

The key specified to compute a hash value is expired, only active keys are valid , 0x8004A106

if you have an error message that's code 0x8004A106 during log in Microsoft CRM 4.0,
Please follow the imnstructions below;
1-Make sure "Microsoft CRM Asynchronous Processing Service" is running.(start>run type services.msc)
2-Execute Microsoft.Crm.Tools.WRPCKeyRenewal.exe with parameter /R ( Microsoft.Crm.Tools.WRPCKeyRenewal.exe /R ) from
:\ \Microsoft Dynamics CRM\Tools ( for example - C:\Program Files\Microsoft Dynamics CRM\Tools )

Bingo! it will work...

Install Microsoft Visual C++ runtime without internet accessing in Microsoft CRM 4.0 Data Migration Manager

1- Download Vcredist.exe from http://www.microsoft.com/downloads/details.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en for 32 bit
http://www.microsoft.com/downloads/details.aspx?familyid=90548130-4468-4BBC-9673-D6ACABD5D13B&displaylang=en for 64 bit.

2-Copy VCRedist.exe into Microsoft CRM 4.0 Data setup directory\VCRedist\.
( if \VCRedist not exists.Create it Manually)

3-Run Data Migration Manager Installation Wizard.

good lucks.

Some tricks and codes in VBScript

'Sample VBScript to kill a program

Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'application.exe'"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next

WScript.Quit

' End of WMI Example of a Kill Process



'Sample VBScript to create a file

Dim oAPI, oBag
Set oAPI = CreateObject(“MOM.ScriptAPI”)
Set oBag = oAPI.CreatePropertyBag()
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
strFile = “C:\myfile.log”

If objFSO.FileExists(strFile) Then
Call oBag.AddValue(“Status”,”Ok”)
Call oAPI.Return(oBag)
Else
Call oBag.AddValue(“Status”,”Error”)
Call oAPI.Return(oBag)
End If

' End of creating …

how to execute query from VBScript in script two state monitor SCOM

here is code :

'define and create objects for passing values in 2 state to SCOM
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()


StrConnect = "PROVIDER=SQLOLEDB.1;Integrated Security=SSPI;INITIAL CATALOG=DBName;DATA SOURCE=ServerName"
Set cnt = CreateObject("ADODB.Connection")
cnt.Open StrConnect

set recordSet = CreateObject("ADODB.Recordset")
SQLStr = " select * from .... "

recordSet.Open SQLStr, cnt,1,1

TotalRecords = recordSet.RecordCount

recordSet.Close : set recordSet = nothing
cnt.Close : set cnt = nothing

'We have to handle Status value from SCOM and create rule for each state
If TotalRecords >= 0 Then
Call oBag.AddValue("Status","ERROR")
Else
Call oBag.AddValue("Status","OK")
End If

Call oAPI.Return(oBag)

Credential while creating site in Share Point Portal

Call SPSecurity.CodeToRunElevated for executing CreateSite() method.This statement makes credential scope over Share Point server.

exeample:
SPSecurity.CodeToRunElevated elevatedGetSitesAndGroups = new SPSecurity.CodeToRunElevated(method which owns CreateSite method);
SPSecurity.RunWithElevatedPrivileges(elevatedGetSitesAndGroups);