开发者

How do I figure out the type of the SQL Server 2008 R2 View definition

I was walking view definitions in a database today using sqlalchemy 0.6 (using get_view_definition()) and I ran across one that was larger than 4000 characters. MS seems to say (Information Schema Views for VIEWs) that shouldn't be returned. MS SQL Server Management Studio shows the whole thing (well at least the beginning and the end look right) if you ask for the design of the view. sqlalchemy returns a string truncated at 40开发者_Go百科00 characters (boo, hiss). How can I ask the database what type it wants to return for this piece of data instead of depending on what I suspect is out of date documentation. I'm assuming the type is probably varchar. I would just like to verify that.


The object definitions, including view definitions, can be retrieved from the sys.sql_modules view, or using the OBJECT_DEFINITION function. This includes the proper NVARCHAR(MAX) type that contains the untruncated definition of the object.

Other backward compatibility views like sys.syscomments or INFORMATION_SCHEMA.VIEWS contain a column of type NVARCHAR(4000) and such a type, by definition, must truncate the object definition after first 4k characters. Many cross platform tools will rely on the INFORMATION_SCHEMA views and perhaps sqlalchemy does the same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜