Skip to main content

Posts

T-SQL MSSQL Cursor performance

I was comparing the performance of different cursors in MS SQL I was working with about 4 million rows in the following example FORWARD_ONLY STATIC READ_ONLY Apr 23 2015  4:50PM CURSOR OPENED Apr 23 2015  4:53PM LOOP FINISHED Apr 23 2015  4:53PM DEALLALLOCATED Apr 23 2015  4:53PM FORWARD_ONLY FAST_FORWARD READ_ONLY Apr 23 2015  4:53PM CURSOR OPENED Apr 23 2015  4:59PM LOOP FINISHED Apr 23 2015  4:59PM DEALLALLOCATED Apr 23 2015  4:59PM FORWARD_ONLY KEYSET READ_ONLY Apr 23 2015  5:00PM CURSOR OPENED Apr 23 2015  5:10PM LOOP FINISHED Apr 23 2015  5:10PM DEALLALLOCATED Apr 23 2015  5:10PM FORWARD_ONLY DYNAMIC READ_ONLY Apr 23 2015  5:10PM CURSOR OPENED Apr 23 2015  5:16PM LOOP FINISHED Apr 23 2015  5:16PM DEALLALLOCATED

Version Control of Stored Procedures - MSSQL

http://dba.stackexchange.com/questions/33541/how-to-keep-history-of-sql-server-stored-procedure-revisions/100628#100628 Step 1: Create a database and table to store the version info USE Utility; GO CREATE TABLE dbo.ProcedureChanges (     EventDate    DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,     EventType    NVARCHAR(100),     EventDDL     NVARCHAR(MAX),     DatabaseName NVARCHAR(255),     SchemaName   NVARCHAR(255),     ObjectName   NVARCHAR(255),     HostName     NVARCHAR(255),     IPAddress    VARCHAR(32),     ProgramName  NVARCHAR(255),     LoginName    NVARCHAR(255) ); Step 2: Grab the initial version USE YourDB; GO INSERT Utility.dbo.ProcedureChanges (     EventType,   ...

How to change the timezone in linux

From http://www.thegeekstuff.com/2010/09/change-timezone-in-linux/ Delete (or perhaps better, rename) the current localtime file in etc. # cd /etc # rm localtime Create a link to the preferred time # cd /etc # ln -s /usr/share/zoneinfo/Australia/Sydney localtime The system will see the time change immediately. Services like mysql will need a restart to pick it up

Concatenate all columns into one field in MS SQL

There is a lot in this query. Get all column names and return all rows as a single column DECLARE @s VARCHAR(MAX) SELECT @S = ISNULL(@s+'+','') + ' CONVERT( VARCHAR  ,' + c.name + ')  + ''::''' FROM  sys.all_columns c join sys.tables  t             ON  c.object_id = t.object_id WHERE t.name = '//Table Name//' SELECT @S EXEC( 'SELECT ' +  @s + ' FROM //Table Name// ' )

SElinux prevents MSSQL connection from PHP

From PHP.net If someone encounters the interesting problem in which PHP can connect to a MSSQL server from the command line but not when running as an Apache module: SELinux prevents Apache (and therefore all Apache modules) from making remote connections by default. This solved the problem in CentOS: # setsebool -P httpd_can_network_connect=1