2

I need to find a view in SQL Server 2000, 2005 and 2008. Actually, I'd like to be able to find anything using a simple query. I tried one answer which did not work - How can I check if a View exists in a Database?

Is there a script to search for views or any other object that is guaranteed to work in all SQL Server versions I mentioned? I prefer something which does not need you to know table names and such to find a view.

Community
  • 1
  • 1
Trojan.ZBOT
  • 1,398
  • 2
  • 14
  • 23
  • If you are using `SQL Server Management Studio` you can simple press F6 and use the searching engine. – gotqn Nov 20 '13 at 19:01
  • Why did i get -1 for this question ? – Trojan.ZBOT Nov 20 '13 at 19:02
  • @gotqn - What does F6 do ? If I know, I can manually go to that menu. f6 does nothing for me. – Trojan.ZBOT Nov 20 '13 at 19:04
  • It should open your `Object Explorer` - http://technet.microsoft.com/en-us/library/ms174205.aspx and using it you can search for your view - http://technet.microsoft.com/en-us/library/ms173849.aspx – gotqn Nov 20 '13 at 19:27

2 Answers2

2

you may need this query

SELECT TABLE_NAME as ViewName,
VIEW_DEFINITION as ViewDefinition
FROM INFORMATION_SCHEMA.Views
lopushen
  • 1,117
  • 2
  • 11
  • 32
0

If you need SQL Server 2000 compatibility (so sys.views is not available) you can query INFORMATION_SCHEMA.VIEWS

For other types of objects the SQL Server 2000 view sysobjects is still available in later versions for backward compatibility reasons.

Martin Smith
  • 438,706
  • 87
  • 741
  • 845