Show SQL Queries
-
Tuesday, May 15, 2012 9:48 AM
Hello
I am using SSMS with SQL Server 2008 Express.
If I change a table name, or change a column type I can do all this with the graphical interface within Management StudioBut I need the real SQL commands which are behind this activity
like "RENAME table..."
or
like ALTER TABLE `test` CHANGE `testid` `testid` INT( 10 ) NOT NULL ;
I need this commands for a SQL Update script later.
Is it possible to see the commands behind or see this in a window?
regards
Hans
All Replies
-
Tuesday, May 15, 2012 9:51 AM
Hello Hans,
Yes you can. In every dialog / wizard you will find an icon to create the script for the action, the GUI dialog / wizard would do.
You find it in the symbol bar at the left side; it's an icon with a script and a feather.
Olaf Helper
* cogito ergo sum * errare humanum est * quote erat demonstrandum *
Wenn ich denke, ist das ein Fehler und das beweise ich täglich
Blog Xing- Proposed As Answer by Sean GallardyMicrosoft Community Contributor Tuesday, May 15, 2012 12:23 PM
-
Tuesday, May 15, 2012 12:47 PM
Hi Olaf,
thank you for help.
Hmm, but for example of renaming a table:
In Management studio I cklick on the table, then right click with mouse on menu item "Rename" and I can rename the table. But then I see no SQL output and there is also no icon for "creating script".regards
Hans -
Tuesday, May 15, 2012 12:51 PM
Hans,
In that case, start SQL Profiler, connect to your instance and capture the rpc:completed and batch:completed events. Filter by your account and the name of the database in question.
-Sean
Sean Gallardy, MCC | Blog
-
Tuesday, May 15, 2012 12:54 PM
Hello Hans,
The option is only available in GUI dialogs / wizards, not when you rename directly in Object Explorer.
But you could use the SQL Server Profiler to capture the scripts for such actions or the sql statements send from other applications.
Olaf Helper
* cogito ergo sum * errare humanum est * quote erat demonstrandum *
Wenn ich denke, ist das ein Fehler und das beweise ich täglich
Blog Xing -
Tuesday, May 15, 2012 1:55 PM
Hello,
Is SQL Server Profiler also available for SQL Server Express editon?
regards
Hans
-
Tuesday, May 15, 2012 2:55 PM
Hans,
It is not included in the express edition. Profiler is a GUI tool that uses the system stored procedures already present in Express edition, so it is still possible to run a trace but you will have to do this all through t-sql.
Create Trace - http://msdn.microsoft.com/en-us/library/ms190362.aspx
Set Event - http://msdn.microsoft.com/en-us/library/ms186265.aspx
Set Filter - http://msdn.microsoft.com/en-us/library/ms174404.aspx
Set Status - http://msdn.microsoft.com/en-us/library/ms176034.aspx
fn_Trace_Gettable - http://msdn.microsoft.com/en-us/library/ms188425.aspx
Running traces with TSQL - http://sqlserverpedia.com/wiki/Running_Traces_with_TSQL
Sean Gallardy, MCC | Blog
- Proposed As Answer by amber zhangModerator Wednesday, May 16, 2012 2:15 AM
- Marked As Answer by amber zhangModerator Tuesday, May 22, 2012 7:08 AM
-
Thursday, May 17, 2012 6:20 AM
If you just want the syntax of Alter Table, maybe you can take some time to read the online manual
http://msdn.microsoft.com/en-us/library/ms190273(v=sql.105).aspx
- Marked As Answer by amber zhangModerator Tuesday, May 22, 2012 7:08 AM

