Posts

Showing posts from June, 2012

SQL User Migration Script 2000

USE master GO IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL   DROP PROCEDURE sp_hexadecimal GO CREATE PROCEDURE sp_hexadecimal     @binvalue varbinary(256),     @hexvalue varchar(256) OUTPUT AS DECLARE @charvalue varchar(256) DECLARE @i int DECLARE @length int DECLARE @hexstring char(16) SELECT @charvalue = '0x' SELECT @i = 1 SELECT @length = DATALENGTH (@binvalue) SELECT @hexstring = '0123456789ABCDEF' WHILE (@i <= @length) BEGIN   DECLARE @tempint int   DECLARE @firstint int   DECLARE @secondint int   SELECT @tempint = CONVERT(int, SUBSTRING(@binvalue,@i,1))   SELECT @firstint = FLOOR(@tempint/16)   SELECT @secondint = @tempint - (@firstint*16)   SELECT @charvalue = @charvalue +     SUBSTRING(@hexstring, @firstint+1, 1) +     SUBSTRING(@hexstring, @secondint+1, 1)   SELECT @i = @i + 1 END SELECT @hexvalue = @charvalue GO IF OBJECT_ID ('sp_help_revlogin') IS NOT NUL...

SQL Tips

Execute an Operating System Command From Within SQL Server. The xp_cmdshell extended store procedure makes it possible to execute operating system commands from within SQL Server. Example: EXEC Master..xp_cmdshell 'Dir c:\' What is SQL*Loader? SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. One can load data into an Oracle database by using the sqlldr (sqlload on some platforms) utility. What is a Recovery Model? Answer : A recovery model is a database property that controls the basic behavior of the backup and restores operations for a database. Recovery models determine how transactions are logged, which logs require backups and the kinds of restore operations available to the DBA. A new database inherits its recovery model from the model database. Recovery models simplify recovery planning, backup and recovery procedures, clarify tradeoff among system operational requirements and clarify tradeoffs among availability and...

Simple JoinQuery

select a.*, b.* from [Test].[Reimbursement_Master] as a,[Test].[Reimbursement_Transaction] as b where a.ReimbursementID = b.ReimbursementID and a.[EnteredDate] >='2007-02-19'

Rename Table

exec sp_rename '[College].[Employeemaster]',' Employeemaster   _FY0708';

Identifying Queries Running Slower Than Normal

By  Ian Stirk , 2008/08/07 Summary The utility described in this article allows you to quickly identify which queries are running slower than expected on SQL Server 2005. Recognising these queries will allow you to take corrective targeted action to improve their performance. Various possible solutions are proposed. Introduction As part of your normal monitoring it makes sense to ensure the runtime duration your queries does not deviate significantly from the expected norm. Identifying these queries will allow you to target your efforts and correct any performance problems in a timely manner. A query can start to run slower for many reasons, including: an increased number of users (resulting in more waiting on resources), increased volume of data to process, too much context switching for parallel queries, and slower hardware. When a query is run, its query plan is cached to improve subsequent run of the query. Many interesting details relating to the query are rec...