PDA

View Full Version : Unable to get view definition in vba



someusersend
04-13-2020, 12:36 PM
Hello,

I am unable to receive proper definition of SQL Server view in VBA.
The way I was doing it before was to execute this statement:

SELECT sys.sql_modules.definition FROM sys.sql_modules WHERE sys.sql_modules.object_id = object_id('<viewname>', 'V')And based on its result recordset I obtained the definition of a view that I expected:

CREATE VIEW [dbo].[<view name>] AS <sql statement>

It all worked fine on all instances of SQL Servers that I worked on before. (SQL Server 2016, SQL Server 2012).
Now I moved to Azure (to be specific this is the exact version: Microsoft SQL Azure (RTM) - 12.0.2000.8).

The problem that I am facing is that I am getting string that seems to be corrupt.
The length of this string is exactly the same as the length of the definition.
But it looks like this:26320
or this:26321
When I run the statement in SSMS, it returns the proper definition.

Does anyone have any idea what can be the reason?
Would really appreciate your help.