Feeds:
Posts
Comments

Split Decimal Values

Select Floor(568.05)

Output : 568

Select Floor(-568.05)

Output : -569

Select Floor(Abs(-568.05))*-1

Output : 568

Select ParseName(-568.05,2)

Output : -568

Select ParseName(-568.05,1)

Output : 05

Initial powershell Configuration

1.Open Powershell in windows Server With Local Administrator login

1pw

2pw

  2. enter Get-ExecutionPolicy on the prompt
   3. output restricted then change to Remote Signed Using Set-ExecutionPolicy RemoteSigned

3pw

4.paste the below code in notepad and save as <file name> with ps1 ext

###################################################################

function print-file($file) {

begin {

function internal-printfile($thefile) {

if ($thefile -is [string]) {$filename = $thefile }

else {

if ($thefile.FullName -is [string] ) { $filename = $THEfile.FullName }

}

$start = new-object System.Diagnostics.ProcessStartInfo $filename

$start.Verb = “print”

[System.Diagnostics.Process]::Start($start)

}

if ($file -ne $null) {

$filespecified = $true;

internal-printfile $file

}

}

process{if (!$filespecified) { write-Host process ; internal-printfile $_ } }

}

#dir *.pdf -r | print-file

$DestFileName=”E:\test1.pdf”     #PDF Path

print-file -file $DestFileName

###############################################################

5.Run the File from saved location in powershell

4pw

 

 

Note :- Which file type  want to print the machine have a viewer for a particular file type.

and default printer also configured on that machine.

 

http://www.mssqltips.com/sql-server-tip-category/9/performance-tuning/

http://www.sql-server-performance.com/2007/gen-tips/

http://www.codeproject.com/Articles/22853/SQL-Server-Performance-Tips-and-Guidelines

http://social.technet.microsoft.com/wiki/contents/articles/5957.sql-server-performance-survival-guide.aspx

1.Apply a service pack or hotfix SQL Server 2005 to a failover cluster instance

With SQL Server 2005, Microsoft tried to be helpful in enabling its installer to apply the service pack or hotfix automatically on the passive node(s) in a cluster. In my own experience, this has not worked out too well.

Very often, when the installer flagged the upgrade status of the service pack ot the hotfix as failure next to Database Service, the information I found in the log file was that attempt to patch the passive node had failed. You could scour the log files, google the internet, and/or open a Microsoft support case to troubleshoot the problem, rectify the root cause for failure to patch the passive node, and move on. But that may be a lengthy process, although sometimes you do not have a choice but to go through it.

In many cases, I have found the following simple solution to work well (the description assumes that we have node A and node B, and node A currently owns the SQL Server resource group):

  • Use Cluster Administrator to pause the passive node, i.e. node B
  • Re-apply the service pack or the hotfix on node A (i.e. the active node–the node that owns the SQL Server resource group). Because node B is paused, the installer will not try to help you out in applying the service pack or hotfix there. And re-applying the service pack or hotfix will usually succeed.
  • Un-pause node B.
  • If you need to reboot the patched node A, go ahead and reboot it. After node A has come back online, make sure that the SQL Server resource group is on node B. If not, move it there.
  • Pause node A with Cluster Administrator.
  • Apply the service pack or hotfix on node B. Again, this should typically succeed (unless there is some other issue).
  • Un-pause node A, and reboot node B, if necessary.

In essence, you may want to patch all the nodes manually yourself.

I’m not suggesting that this is a cure all for all the problems of patching a clustered SQL Server 2005. But it has worked quite well for me when the problem was a failed attempt to patch the passive node.

 

2.Apply a service pack or hotfix SQL Server 2008 to a failover cluster instance

Installing Service Pack SQL Server 2008 in failover cluster is very different than the SQL Server 2005 cluster failover.

With SQL Server 2005, when you start installing cluster service pack (or hotfix), it must be launched on the active node (node that hosts the instance). When installing the Setup will launch simultaneously  “remote silence” on all passive nodes. All nodes in the cluster containing the SQL Server instance are updated in the same time.

With SQL Server 2008, to reduce the downtime, we have revised the method of deployment. Now if you want to apply a service pack (or hotfix), you must install in first on the passive nodes. The passive nodes are updated before the active node.

Therefore, for your instance SQL Server 2008  in failover cluster, you must follow the scenario below for the application of Service Pack, Cumulative Update or Hotfix :

1.  Apply the hotfix on pasive node N2
2.  Reboot the passive node N2
3.  Failover on SQL resource : the passive node become the active node
4.  Apply the hotfix on the passive node N1
5.  Reboot the passive node N1

You can check the version of SQL server with the following query:

SELECT

SERVERPROPERTY(‘IsClustered’) as _1_Means_Clustered ,
SERVERPROPERTY(‘Edition’) as Edition ,
SERVERPROPERTY(‘ProductVersion’) as Version  ,
SERVERPROPERTY(‘ComputerNamePhysicalNetBIOS’) as ActiveNode

 

Links:-

http://sqlblog.com/blogs/linchi_shea/archive/2009/10/04/pause-the-passive-node-to-apply-sql2005-service-pack-or-hotfix.aspx

http://blogs.technet.com/b/mdegre/archive/2010/01/16/apply-a-sql-server-2008-service-pack-or-hotfix-to-a-failover-cluster-instance.aspx

Declare @Month as Int

Set @Month=2

SELECT VisitID,PatientID,ImageId,Trans_No,DATEADD(DAY, DATEDIFF(DAY, VisitDate,
CONVERT(DATETIME, CAST(YEAR(VisitDate) AS VARCHAR(4))
+ RIGHT(‘0’+CAST(DAY(VisitDate) AS VARCHAR(2)),2) +
+ RIGHT(‘0’+CAST(MONTH(VisitDate) AS VARCHAR(2)),2), 112)), VisitDate) As VDate
From SN_Visits_Image
Where Year(VisitDate)=2013 And Day(VisitDate)=1 And Month(VisitDate)=@Month
Update SN_Visits_Image Set VisitDate = VT.VDate
From
SN_Visits_Image SVI Inner join
(
SELECT VisitID,PatientID,ImageId,ImageFileName,Trans_No,DATEADD(DAY, DATEDIFF(DAY, VisitDate,
CONVERT(DATETIME, CAST(YEAR(VisitDate) AS VARCHAR(4))
+ RIGHT(‘0’+CAST(DAY(VisitDate) AS VARCHAR(2)),2) +
+ RIGHT(‘0’+CAST(MONTH(VisitDate) AS VARCHAR(2)),2), 112)), VisitDate) As VDate
From SN_Visits_Image
Where Year(VisitDate)=2013 And Day(VisitDate)=1 And Month(VisitDate)=@Month
) VT on
SVI.VisitID = VT.VisitID And SVI.PatientID = VT.PatientID And SVI.ImageId = VT.ImageId And SVI.ImageFileName = VT.ImageFileName
And SVI.Trans_No = VT.Trans_No

 

02010504060703080911101312141716151918

Create Function Dbo.Part
(@Value Varchar(8000)
,@Part Int
,@Sep Char(1)=’-‘
)Returns Varchar(8000)
As Begin
Declare @Start Int
Declare @Finish Int
Set @Start=1
Set @Finish=CharIndex(@Sep,@Value,@Start)
While (@Part>1 And @Finish>0)Begin
Set @Start=@Finish+1
Set @Finish=CharIndex(@Sep,@Value,@Start)
Set @Part=@Part-1
End
If @Part>1 Set @Start=Len(@Value)+1 — Not found
If @Finish=0 Set @Finish=Len(@Value)+1 — Last token on line
Return SubString(@Value,@Start,@Finish-@Start)
End

 

DECLARE @MRDNUMBER VARCHAR(10)
DECLARE @STRQUERY VARCHAR(MAX),@STROD VARCHAR(100),@STROS VARCHAR(100)
DECLARE @RECVALUE VARCHAR(50)
DECLARE @RECCNT INT,@CNT VARCHAR(2)

SET @MRDNUMBER=’1665773′

SET @RECVALUE = (SELECT TOP 1 FN_OD_FMETHOD FROM MR_FUNDUS WHERE FN_MRD_NUMBER=@MRDNUMBER)

SET @RECCNT = (Select Count(Value) FROM DBO.FN_SPLIT(@RECVALUE,’#’))

SET @CNT=1
SET @STRQUERY = ”
SET @STROD = ”
SET @STROS = ”

WHILE (@RECCNT > 0)

BEGIN
SET @STROD = @STROD + ‘ODMETHOD’ + @CNT + ‘+’ + CHAR(39) + ‘,’ + CHAR(39) + ‘+’
SET @STROS = @STROS + ‘OSMETHOD’ + @CNT + ‘+’ + CHAR(39) + ‘,’ + CHAR(39) + ‘+’

SET @STRQUERY = @STRQUERY + ‘,(SELECT MPM_PARAMETER_VALUE FROM MR_PARAMETER_MASTER1 WHERE MPM_PARAMETER_CD=DBO.PART(FN_OD_FMETHOD,’ + @CNT +’ ,’ + CHAR(39) + ‘#’ + CHAR(39) + ‘)) As ODMETHOD’ + @CNT
SET @STRQUERY = @STRQUERY + ‘,(SELECT MPM_PARAMETER_VALUE FROM MR_PARAMETER_MASTER1 WHERE MPM_PARAMETER_CD=DBO.PART(FN_OS_FMETHOD,’ + @CNT +’ ,’ + CHAR(39) + ‘#’ + CHAR(39) + ‘)) As OSMETHOD’ + @CNT

SET @RECCNT = @RECCNT – 1
SET @CNT = @CNT + 1
END
SET @STROD = (SELECT SUBSTRING(@STROD,1,LEN(@STROD)-5))
SET @STROS = (SELECT SUBSTRING(@STROS,1,LEN(@STROS)-5))

SET @STRQUERY = ‘SELECT FN_MRD_NUMBER,
FN_OD_MCLARITY,
FN_OD_TYPE as ODTYPE,
FN_OD_SHAPE,FN_OD_COLOR,FN_OD_CUP,FN_OD_CD_RATIO,FN_OD_MARGIN,FN_OD_PRETINA,FN_OD_NRR_RIM,
FN_OD_N_VESSELS,FN_OD_VITREOUS,FN_OD_V_ABNORMAL,FN_OD_DISC,
FN_OD_DISC_ABNORMALITY,FN_OD_MACULA,FN_OD_MACULA_ABNORMAL,
FN_OD_RVESSELS,FN_OD_RVESSELS_ABNORMAL,FN_OD_POSTERIOR_POLE,FN_OD_POSTERIOR_POLE_ABNORMALITY,
FN_OS_FMETHOD as OSMETHOD,
FN_OS_MCLARITY,
FN_OS_TYPE,FN_OS_SHAPE,FN_OS_COLOR,FN_OS_CUP,
FN_OS_CD_RATIO,FN_OS_MARGIN,FN_OS_PRETINA,
FN_OS_NRR_RIM,FN_OS_N_VESSELS,FN_OS_VITREOUS,
FN_OS_V_ABNORMAL,FN_OS_DISC,FN_OS_DISC_ABNORMALITY,FN_OS_MACULA,FN_OS_MACULA_ABNORMAL,FN_OS_RVESSELS,FN_OS_RVESSELS_ABNORMAL,FN_OS_POSTERIOR_POLE,
FN_OS_POSTERIOR_POLE_ABNORMALITY,FN_CRT_DATE’ + @STRQUERY + ‘ FROM DBO.MR_FUNDUS WHERE FN_MRD_NUMBER=’ + CHAR(39) + @MRDNUMBER + CHAR(39)
SET @STRQUERY = ‘SELECT TOP 1 FN_MRD_NUMBER,ISNULL(‘ + @STROD + ‘,’+ CHAR(39) + ‘–‘ + CHAR(39) + ‘) AS ODMETHOD,
FN_OD_MCLARITY,
ODTYPE,
FN_OD_SHAPE,FN_OD_COLOR,FN_OD_CUP,FN_OD_CD_RATIO,FN_OD_MARGIN,FN_OD_PRETINA,FN_OD_NRR_RIM,
FN_OD_N_VESSELS,FN_OD_VITREOUS,FN_OD_V_ABNORMAL,FN_OD_DISC,
FN_OD_DISC_ABNORMALITY,FN_OD_MACULA,FN_OD_MACULA_ABNORMAL,
FN_OD_RVESSELS,FN_OD_RVESSELS_ABNORMAL,FN_OD_POSTERIOR_POLE,FN_OD_POSTERIOR_POLE_ABNORMALITY,
ISNULL(‘ + @STROS + ‘,’+ CHAR(39) + ‘–‘ + CHAR(39) + ‘) AS OSMETHOD,
FN_OS_MCLARITY,
FN_OS_TYPE,FN_OS_SHAPE,FN_OS_COLOR,FN_OS_CUP,
FN_OS_CD_RATIO,FN_OS_MARGIN,FN_OS_PRETINA,
FN_OS_NRR_RIM,FN_OS_N_VESSELS,FN_OS_VITREOUS,
FN_OS_V_ABNORMAL,FN_OS_DISC,FN_OS_DISC_ABNORMALITY,FN_OS_MACULA,FN_OS_MACULA_ABNORMAL,FN_OS_RVESSELS,FN_OS_RVESSELS_ABNORMAL,FN_OS_POSTERIOR_POLE,
FN_OS_POSTERIOR_POLE_ABNORMALITY,FN_CRT_DATE FROM (‘ + @STRQUERY + ‘)V ORDER BY FN_CRT_DATE DESC’

EXECUTE(@STRQUERY)