Sunday, 16 December 2012

Windows phone 8 emulator

I have come accross these problems when installing Windows phone 8 emulator in vmware player.

1. CPU
- needs to support virtualization and it needs to be enabled in BIOS

2. operating system
- 64 bit
- needs to be some which supports SLAT (Windows 8, Windows Server 2012 ...)
- needs to have Hyper-V enabled

3. VMware settings
- Edit vmx file and add this configuration hypervisor.cpuid.v0 = "FALSE",  mce.enable = "TRUE"
- Processors setting - enable Virtualize Intel VT-x/EPT or AMD-V/RVI
- Processors setting - setup at least two cores
- Memory settings - setup enough memory for virtual machine

4. Windows Mobile 8 SDK
- will download and install all required prerequisities, it is good to have prepared steps above


Sources:
Windows 8 Hyper-V will require SLAT (Second Level Address Translation)
MachineSLATStatusCheck
Windows Server 2012 and Hyper-V
Hyper-V in Workstation 8
Windows Phone SDK

Monday, 11 June 2012

MSSQL trace file analysis

Today I was looking for a way how to access MSSQL server trace data from TSQL. The solution is to import data to database via function fn_trace_gettable.

SELECT * INTO temp_trc
FROM fn_trace_gettable('c:\temp\trace.trc', default);

Tuesday, 17 January 2012

Issue to restore of replicated database solved

Restore of backuped database which used replications can be a problem. Database was restored successfully but it was still marked as part of publication (see is_published in sys.databases). There was not possible to truncate, alter structure of tables etc.

This issue can be resolved by running this command on database:

exec sp_removedbreplication 'database_name'

Tuesday, 20 December 2011

How to Export Image column to file on MSSQL II

Another way how to export binary data from database. It is possible to use bcp utility.

bcp "SELECT img FROM db_name.dbo.Images WHERE ID = 1" queryout "c:\001.jpg" -T -S server

Once you run it you will be asked for the file storage type (no change required), prefix-length (needs to be 0), length of field and field terminator (no change)

Wednesday, 30 November 2011

Update of XML data

Code snippet for updating specific data in xml column in mssql

declare @date datetime
set @date = GETDATE()

UPDATE XmlDocuments
SET    xmlmetadata.modify ('replace value of (/Header/Date/text())[1] with sql:variable("@date")') 
WHERE ID = '1000001'

Friday, 16 September 2011

Bulk update of Image data in MSSQL

This is just simple example how to do update of image data in Microsoft SQL database.

UPDATE Images SET Img = (SELECT BulkColumn AS Img FROM OPENROWSET(BULK N'C:\NoImage.TIF', SINGLE_BLOB) AS [Document])

Friday, 1 July 2011

How to Export Image column to file on MSSQL

It is not that easy how it looks like:) Used the same approach as it is in the answer below but completed the example.

1. Enable the extended stored procedures:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO

2. Use sp_OA stored procedures

DECLARE @objStream INT
DECLARE @imageBinary VARBINARY(MAX)
DECLARE @filePath VARCHAR(8000)

SELECT @imageBinary = img
FROM Images
WHERE ID = 1

SET @filePath = 'c:\img_1.jpg'

EXEC sp_OACreate 'ADODB.Stream', @objStream OUTPUT
EXEC sp_OASetProperty @objStream, 'Type', 1
EXEC sp_OAMethod @objStream, 'Open'
EXEC sp_OAMethod @objStream, 'Write', NULL, @imageBinary
EXEC sp_OAMethod @objStream, 'SaveToFile', NULL,@filePath, 2
EXEC sp_OAMethod @objStream, 'Close'
EXEC sp_OADestroy @objStream 

Resources:
How to export a ms sql image column to a file