question

SarveshPandey-7139 avatar image
0 Votes"
SarveshPandey-7139 asked AmeliaGu-msft commented

How to extraxt views from SQL Server 2008R2

We have a SQL server 2008R2, we need to extract view create command but we couldn't find it and Generate scripts throws error message.
Any workaround or alternate way to extract create view command.

sql-server-generalsql-server-transact-sql
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What error message do you get when generating scripts?

0 Votes 0 ·

Generate scripts throws error message.

And which error do you get?



0 Votes 0 ·

Hi @SarveshPandey-7139,
How are things going on? Did the answers help you?
Please feel free to let us know if you have any other question.
If you find any post in the thread is helpful, you could kindly accept it as answer.

Best Regards,
Amelia

0 Votes 0 ·
AmeliaGu-msft avatar image
0 Votes"
AmeliaGu-msft answered

Hi @SarveshPandey-7139,
How are things going on?
Could you please share us the detailed error message?

Any workaround or alternate way to extract create view command.

You can script the view by right-click the view-> Script View as->CREATE To.
You also can get all views in the database using the following query:

 USE <Databasename>
 Go
 SELECT S.definition
 FROM sys.sql_modules S
 INNER JOIN sys.Objects O
 ON S.Object_id = O.Object_id
 WHERE O.type = 'v'

Please refer to this article which might help.

Best Regards,
Amelia


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

VaibhavChaudhari avatar image
0 Votes"
VaibhavChaudhari answered

Try running - sp_helptext <view name> and also see suggestions given here -

https://stackoverflow.com/questions/20189134/how-to-get-a-view-table-query-code-in-sql-server-2008-management-studio/46329520


Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.