sql - Are there any shortcuts for creating a table variable to match the columns in a view? -


i need create table variables within procedures, store top 25 rows view processing.

i need store these small batches in variables temporarily, because i'm performing numerous operations modify data within underlying tables, , of these operations cause rows no longer appear within view based on view criteria (this design).

i need keep data around entire processing session, , can't rely on view remain consistent through operation.

the problem is, since we're doing in many instances across multiple databases, if ever make changes columns in of our views, code becomes bug-prone since have make sure modify relevant table types - without making typos or mistakes, or overlooking anything.

so question is, can declare table variables (or table types, if necessary) stating "match current columns in view?"

that make things easier, since automatically keep relevant table variables in sync current layout of views in question, , eliminate headache comes trying keep straight manually.

if no such shortcut exists, guess we'll have create custom table types matching our views needed, @ least keep centralized possible.

if usage of type variable replaced temporary table like:

select * #temptable myview  

will job perfectly.

with select into, table created colomn , metadata avialable in select statement.

hope helps.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -