Is it possible to create a VIEW from within a stored procedure?

  • I know I can create a table within, but it doesn't seem to like VIEWS!

  • You can if it's dynamic sql within an exec statement.. something like this is possible :

    Create proc a

    AS

    exec('

    create view b

    as

    select getdate() as Today'

    )

    GO

    exec a

    select * from b

    drop proc a

    drop view b

  • Excellent. Thanks a bunch. I'm having to great a stored proc for a large VIEW, instead of having it inside the TSQL JOBs window which is foolishly truncated to only 3000 characters.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply