2

Possible Duplicate:
How to see query history in SQL Server Management Studio

I have created a table by create command in sql server, I executed the query from query analyzer and then I closed the query analyzer. Now I want to see that query by which I created the table how can I do it?

Community
  • 1
  • 1
Zia ur Rahman
  • 1,411
  • 4
  • 26
  • 43
  • 1
    Unless you saved the DDL/DML you executed in Query Analyser (or SQL Server Management Studio) and saved it there is no way (unless you were running SQL Profiler at the time) to recover the exact statements you executed. The tooling will generate scripts for you based on the table schema but they won't magically output what you executed in QA. – Kev Jan 16 '12 at 15:39

2 Answers2

1

Right-click on the Table in your Object Explorer and select Script Table as... -> CREATE to -> New Query Editor Window.

  • 1
    YES, i can see the query but its not like the query that i have written, some changes are made to this query. – Zia ur Rahman Jan 16 '12 at 15:18
  • The query SSMS will give you is all that it has stored; you'll have to reverse engineer the query to your liking and save the query for future reference. – Ben Brocka Jan 16 '12 at 15:41
1

In general - NO. But you can get just similar script by various scripting modules, including supplied with Sql Server 2000 (Enterprise Manager and Query Analyzer Script Table as context menu)

OR

exec sp_help 'tablename'

May provide you sufficient information for your needs

Oleg Dok
  • 21,109
  • 4
  • 45
  • 54