General discussion

Locked

Dynamic Views in MSSQL Server

By shibu ·
MS-SQLServer provides varchar datatype of maximum size 8000 characters. The problem I am facing is that I am creating a dynamic view whose statements runs more than 8000 characters and I am not able to hold more than 8000 characters in a local variable whose data type is varchar(8000). SQL Server does not allow TEXT datatype as local variable which if allowed would solve the problem.How do I generate a dynamic view which is more that 8000 characters?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Dynamic Views in MSSQL Server

by Glen_McLeod In reply to Dynamic Views in MSSQL Se ...

Try putting each of your clauses in separate variables then executing them as a unit.

Exec (@SelectClause + @FromClause + @WhereClause + @GroupByClause + @OrderByClause + @HavingClause)

I've never done it with something as big as what you describe, but this is relatively simple and worth a try.

Glen

Collapse -

Dynamic Views in MSSQL Server

by shibu In reply to Dynamic Views in MSSQL Se ...

Poster rated this answer

Collapse -

Dynamic Views in MSSQL Server

by jereg In reply to Dynamic Views in MSSQL Se ...

Upgrade to new version.

Back to Desktop Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums