Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

Odd behaviour from sys.dependencies

$
0
0

(SQL Server 2008 R2 SP1)

Hi all, I have an SSIS package that dynamically builds a set of SQL statements based on the dependencies in a set of procs. The SSIS package makes use of the dm function sys.dm_sql_referenced_entities to build up a distinct list of columns required from the source system. The code is run against every proc in the database into a working table, then a distinct list is used to pick up data from the source system.

We've been testing this for weeks and weeks in UAT, the day we're going live, UAT has fallen over with a really odd issue. Basically, very randomly, the values in the ImportColumn are presented with some characters returned with unexpected characters, only ever the first 4 digits, it can be different rows from the resultset and just to make it more complicated how often it returns is completely random.

As the SSIS package iterates through each table, I've lifted one of the scripts it builds to explain, this is extracting dependencies from a proc called staging.uspInstrumentHolding.

SELECTDISTINCT    Ref.referenced_database_name AS ImportDatabase,Ref.referenced_schema_name AS ImportViewSchemaName,SUBSTRING(Ref.referenced_entity_name,(CHARINDEX('_', Ref.referenced_entity_name)+1),LEN(Ref.referenced_entity_name))AS TableName,SUBSTRING(Ref.referenced_entity_name,1,(CHARINDEX('_', Ref.referenced_entity_name,1)-1))AS ConnectionName,Ref.referenced_minor_name AS ImportColumnFROM    sys.dm_sql_referenced_entities('Staging'+'.'+'uspInstrumentHolding','OBJECT')AS RefWHERE1=1AND Ref.referenced_minor_name ISNOTNULLAND ref.referenced_schema_name ='import'

The values that return in a strange state are only from the ImportColumn. I can run the script 7-8 times accurately, then the results will appear like this:

UNPOSTED
ꀨ⃗가⃗RL
ꀨ⃗가⃗AN
PCCVRT
䀨噠RE
䀨噠RT
䀨噠EF
䀨啨UV
䀨啨RT
䀨䒰TION
䀨䒰VT
䀨䒰EF
䀨䒰LT
䀨䎰RL
䀨䎰CTION
䒰忰AL
䀨亰UP
䶸忰F
ꀨ⃗ꗐ⃗TE
ꀨ⃗ꗐ⃗T
ꓘ⃗뿰⃗TL

Next time I run them, they look like this:

UNPOSTED
UNSERL
UNTRAN
PCCVRT
PCDIRE
PCINRT
PCIREF
PCORUV
PCSRRT
PDACTION
PDINVT
PDIREF
PDMULT
PDSERL
PDUACTION
PDUVAL
RPCOUP
RPREF
RBDATE
RBRAT
RBTITL

As you can see, only SOME of the values have returned in this state (and which values are returned in this state changes), it is only ever the first 4 characters and how often it occurs changes.

It's just so random, we're yet to identify a trend or reason for this, can anyone offer any suggestions?

Thanks

GW


Viewing all articles
Browse latest Browse all 15889

Trending Articles