Kashif Nizam Qureshi


Leave a comment

Search String Through SQL Objects Like Procedures, Functions etc.

Search String Through SQL Objects Like Procedures, Functions etc.



DECLARE @DBCount INT
DECLARE @CNTR INT
DECLARE @SQL VARCHAR(8000)
DECLARE @dbname NVARCHAR(255)
DECLARE @SearchText NVARCHAR(255)

SET @SearchText = 'String to be Searched'

IF ISNULL(@SearchText,'') <> ''
BEGIN

DECLARE @DBs TABLE ([ID] INT IDENTITY(1,1), [NAME] VARCHAR(255))
INSERT INTO @DBs--drop table @DBs
SELECT [NAME] FROM Master.dbo.sysdatabases
WHERE [NAME] NOT IN ('MASTER', 'TEMPDB', 'MSDB', 'MODEL')
ORDER BY [NAME]

IF EXISTS(SELECT [NAME] FROM TEMPDB.DBO.SYSOBJECTS WHERE NAME LIKE '%#Results%')
BEGIN
DROP TABLE #Results
END

CREATE TABLE #Results([SERVERNAME] VARCHAR(255), [DBName] VARCHAR(255), [NAME] VARCHAR(255), XTYPE VARCHAR(255))

SELECT @DBCount = (SELECT MAX([ID]) FROM @DBs)
SET @CNTR = 1
WHILE @CNTR <= @DBCount
BEGIN
SELECT @dbname = (SELECT [NAME] FROM @DBs WHERE [ID] = @CNTR)
SELECT @SQL =
'USE [' + @dbname + '] insert into #Results
SELECT DISTINCT
--substring(sc.Text, charindex(''' + @SearchText + ''', sc.text, 1) - 20, 255) as ''text'',
@@SERVERNAME, ''' + @dbname + ''' AS [DBName], so.[name], so.xtype
FROM
sysobjects so WITH(NOLOCK)
inner join syscomments sc on so.id = sc.id
WHERE
sc.text like ''%'+ @SearchText + '%'''
--PRINT @sql
EXEC (@SQL)
SET @CNTR = @CNTR + 1
END

SELECT *
FROM #Results
ORDER BY DBName, XType, [Name]

END

Advertisements


Leave a comment

Import Export Sub Site SharePoint

Use the following to export a subsite.

Export-SPWeb “http://server/sites/ClaimsPortal/SampleOrder/” -Path “E:\Kashif\Site Backup\SampleOrder.cmp” -IncludeVersions All -includeusersecurity

Use the following to import a subsite. If your backup was broken into several files, just use the command to import the main file as shown below.

SampleOrder.cmp

SampleOrder1.cmp

SampleOrder2.cmp

Import-SPWeb “http://mthqspdev02:11631/sites/ClaimsPortal/SampleOrder/” -Path “C:\SampleOrder.cmp”  -includeusersecurity -UpdateVersions overwrite


Leave a comment

Running Code Without Visual Studio

Code:

 

Compile:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /out:”C:\Users\kashif.nizam\Go
ogle Drive\Office Work\Documents\_Systems\Muntajat\ConvertToExcel\ConvertToExcel
.exe” “C:\Users\kashif.nizam\Google Drive\Office Work\Documents\_Systems\Muntaja
t\ConvertToExcel\converttoexcel.cs” /r:”C:\Users\kashif.nizam\Google Drive\Offic
e Work\Documents\_Systems\Muntajat\ConvertToExcel\Microsoft.Office.Interop.Excel
.dll”

Run:

Double click on the following file

C:\Users\kashif.nizam\Google Drive\Office work\Documents\_Systems\Muntajat\ConvertToExcel\ConvertToExcel.exe


Leave a comment

Steps to Change Permission Mode of PWA 365

To change the permission mode of Project Online, Please follow the below steps.

Logged in with an Office 365 tenant admin account: Click Admin

permission-mode-for-365-1

Click SharePoint, that will take you to the SharePoint Admin Center:

permission-mode-for-365-2

From this page, select the PWA site collection (Link: https://PWATech.sharepoint.com/sites/pwa/) then click the Settings link under the Project Web App menu as displayed below

permission-mode-for-365-3

This will load the Settings page for the Project Web App site:

permission-mode-for-365-4

Select Project Permission Mode and press OK.


Leave a comment

Getting Project Server Custom Field Value In Javascript


<script src="/sites/PWA/SiteAssets/jquery-1.10.2.min.js"></script>

 $(document).ready(function() {
 


$( "div" ).each(function() {
  var HideCR = $(this).attr("guid");
  if(HideCR == "ddf1fbf7-826f-e611-940d-005056b8333d") //guid of custom field
    alert($(this).text());
          
  if(HideCR == "ab91c49b-0674-e611-940d-005056b8333d") //guid of custom field
    alert($(this).text());
});
          
 });
 
 
  
<span id="ms-rterangecursor-start"></span>
<span id="ms-rterangecursor-end"></span>


Leave a comment

Setting Project UID and Name in List Item Field

In a PDP we can have a list and clicking on new we would like to save Project UID and Name into list’s item fields. In the following code snippet, ProjUid and Owning Project are two SharePoint List Fields and they are being set by following js code.


<script src="/PWA/SiteAssets/jquery-1.10.2.min.js" type="text/javascript"></script><script type="text/javascript">

$(document).ready(function() {

 var Puid = window.parent.PDP_projUid;
 var project_name = window.parent.PDP_projName; 
  
 var subjectIDTextField1 = getElementByTitle("input","ProjUid");
 subjectIDTextField1.value = Puid; 
 
 var subjectIDTextField= getElementByTitle("input","Owning Project");
 subjectIDTextField.value = project_name; 
  
//Disabling field
 $(":input[title='Owning Project']").attr('disabled','disabled');

//Hiding field
var HidePUID = getElementByTitle("input","ProjUid");
                $(HidePUID).closest("tr").hide();

 });
 
function getElementByTitle(tagName,elementTitle)
{
//alert('2.3');
	var list = document.getElementsByTagName(tagName);
	var elementTag;
	for (i=0;i!=list.length;i++) {
	if (list[i].title == elementTitle) {
	elementTag = list[i];
	return elementTag;
	}
	}
}
    
 </script>