Saturday, November 7, 2009

SSIS 2008 / SQL 2008 / .NET Data Types







































SQL ServerSSIS.NETSQL CLR (System.Data.SqlTypes namespace)
bigintDT_I8Int64SqlInt64
binaryDT_BYTESByte[]SqlBytes, SqlBinary
bitDT_BOOLBooleanSqlBoolean
charDT_STRNoneNone
cursorNoneNoneNone
dateDT_DATEDateTimeSqlDateTime
datetimeDT_DBTIMESTAMPDateTimeSqlDateTime
datetime2DT_DBTIMESTAMP2DateTimeSqlDateTime
decimalDT_DECIMALDecimalSqlDecimal
floatDT_R8DoubleSqlDouble
imageDT_IMAGENoneNone
intDT_I4Int32SqlInt32
moneyDT_CYDecimalSqlMoney
ncharDT_WSTRString, Char[]SqlChars, SqlString
ntextDT_NTEXTNoneNone
numericDT_NUMERICDecimalSqlDecimal
nvarcharDT_WSTRString, Char[]SqlChars, SqlString
realDT_R4SingleSqlSingle
rowversion
Byte[]None
smalldatetimeDT_DBTIMESTAMPDateTimeSqlDateTime
smallintDT_I2Int16SqlInt16
smallmoneyDT_CYDecimalSqlMoney
sql_variant
ObjectNone
table
NoneNone
textDT_TEXTNoneNone
timeDT_DBTIME2TimespanTimeSpan
timestampDT_BYTESNoneNone
tinyintDT_UI1ByteSqlByte
uniqueidentifierDT_GUIDGuidSqlGuid
varbinary DT_BYTESByte[]SqlBytes, SqlBinary
varcharDT_STRNoneNone
xmlDT_WSTRNoneSqlXml



Sources :
Mapping SQL Server 2008 data types to SSIS
Mapping SQL Server 2008 data types to .NET / CLR

Thursday, November 5, 2009

Off-topic : Social Media

I use RSS, Twitter etc to follow the SQL Server community.

Here is an interesting article on where social media is going...
Six Social Media Trends for 2010

Wednesday, November 4, 2009

Moving Unique Constraints & Indexes

Really good script for Moving Unique Constraints & Indexes across Partitions (subscriber only)

http://www.sqlservercentral.com/articles/Index+Management/64037/

Thursday, October 29, 2009

Configuring MSDTC (Distributed Transaction Co-ordinator)

MSDTC is required if transactions span multiple servers (i.e. linked servers, ugh!)

Firstly, the SERVICE needs to be running >



Secondly, you need to allow communication (Allow Inbound and Allow Outbound tickboxes below) >

Wednesday, October 28, 2009

Dynamic Management Objects : sys.dm_exec_query_stats

Sys.dm_exec_query_stats is a dmv (dynamic management view) which stores summary information about queries in the query cache.

Sys.dm_exec_sql_text(sql_handle) is a function that returns the executed command from sql_handle.

Putting them together with CROSS APPLY (APPLY lets you join the output of a function), you can see what is being run and how often.


SELECT t.text , s.*
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text(sql_handle) t CT * FROM(SELECT coalesce(object_name(s2.objectid)%'
ORDER BY execution_count DESC

This provides you 35 columns summarising query activity and includes counts, times, reads, writes statistics.

SQLDenis has provided a great query, which i've slightly adapted to order by the the most commonly executed queries.
It tells you where the sql is called from (ProcedureName) or replaces it with 'Ad-hoc' if not called from a procedure. >

SELECT * FROM(SELECT COALESCE(OBJECT_NAME(s2.objectid),'Ad-Hoc') AS ProcedureName,execution_count,
(SELECT TOP 1 SUBSTRING(s2.TEXT,statement_start_offset / 2+1 ,
( (CASE WHEN statement_end_offset = -1
THEN (LEN(CONVERT(NVARCHAR(MAX),s2.TEXT)) * 2)
ELSE statement_end_offset END) - statement_start_offset) / 2+1)) AS sql_statement,
last_execution_time
FROM sys.dm_exec_query_stats AS s1
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s2 ) x
WHERE sql_statement NOT like 'SELECT * FROM(SELECT coalesce(object_name(s2.objectid)%'
ORDER BY execution_count DESC


SQLDenis's original post >http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/finding-out-how-many-times-a-table-is-be-2008

MSDN Reference : http://msdn.microsoft.com/en-us/library/ms189741.aspx