Search code examples
sql-serverssms

SSMS - Generate Scripts - Data Only doesn't work with views?


I am trying to generate a data only script for a view using SSMS Generate Scripts feature. However, even though I select Data Only, it still only generates the view definition and not the data generated by the view. Is there something else I need to do?

I'm using SSMS for SQL Server 2014.


Solution

  • I know this is old, but I will answer it for other people who stumble on it.

    Generate Scripts -> Data Only is bugged for views.

    The easiest option without searching for other stored procedures or external tools is to copy the view contents into a table. Generate Scripts -> Data Only works fine with tables.

    For example,

    SELECT * 
    INTO NEWTABLE
    FROM dbo.Component
    

    Then you can do Generate Scripts on the NEWTABLE and select Data Only in Advanced and it will work.

    You can then delete the NEWTABLE.