Skip to main content

Posts

Showing posts from May, 2015

Pauls Draytek tips

To enable SIP ALG sys sip_alg 1 To disable SIP ALG  sys sip_alg0 To View SIP ALG status  sys sip_alg ? To commit sys settings to flash sys commit ===== To view open ports srv nat openport -v To view port mappings ( open ports in most instances preferred to port mappings ) srv nat portmap table

Check if column exists in MSSQL

if exists ( select * from sys . columns where Name = N 'columnName' and Object_ID = Object_ID ( N 'tableName' )) begin -- Column Exists end     The following does not look in fields   select * from sys.all_objects where name like '%[what you are looking for]%'

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,     EventDDL,     DatabaseName,     SchemaName,     ObjectName ) SELECT     N'Initial control',     OBJECT_DEFINITION([object_id]),     DB_NAME(),     OBJECT_SCHEMA_NAME([object_id]),     OBJECT_NAME([object_id]) FROM     sys.procedures; Step 3: Create a trigger to grab additional versions  U

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// ' )