![]() However, there are just as many, if not more, where it shouldn’t be used. I have found some applications for which this stored procedure was the ideal solution – I hinted at these in the first paragraph. It’s a balancing act that demands careful consideration. Just because it seems that you can’t do something, it doesn’t mean you shouldn’t. True, but I for one think that the opposite is also applicable. It has also been said that just because you can do something, it doesn’t mean you should. Anyone who has tried to pound data in SQL into a meaningful set of information, using a complicated set of business rules, will probably agree that SQL tends to discourage you from doing so, and the more fancy and creative you try to make your solution, the stronger that discouragement becomes. The SQL database engine’s primary role is the storage and retrieval of information, not the complex processing of it. There is a general rule which states that data manipulation of this sort is best left to the application or reporting levels of the system, and for good reason. It is for these exceptional cases that I decided to write a dynamic cross tab stored procedure. You’d like to export some data, already set out in the required format, to a text file.You are using a legacy application that you’d rather not fiddle with.You may be using a reporting solution that doesn’t provide this functionality.It won’t do to have the reporting system do it, nor is it feasible to build that functionality into the application. Sometimes, you just absolutely have to generate a cross tab in SQL. Simply tweet: I’ve just read GFritchey’s blog on restoring tabs with #SQLPrompt – see the #SuperSQLTip at. Like this? Share it with other SQL professionals using the social sharing buttons below. ![]() If you’re not a SQL Prompt user, download a free trial and see how much more productive you can be writing code every day. With SQL Prompt tab history, you’ll be protected and assisted when managing your tabs. Never again should you worry about forgetting to save a script or losing track of where it was on your disk. I can then browse through the script by scrolling on the right or browse the scripts by scrolling through them on the left. I get the tab, the scripts, its location on the disk and the last time I closed it. For example, if I know that one of my previously opened tabs contained scripts for setting up Extended Event sessions within Azure SQL Database, I can simply type session in the search window: I also get the ability to search across these tabs. This allows me to track down previously opened tabs, even if I didn’t save them. By clicking on Closed, I get a list of all the tabs going back in time that I’ve had open on this SSMS instance: This shows the tabs currently open, but you can see that there is a listing under All tabs for closed tabs. You can use the keyboard shortcut designated above, Ctrl+Q, or you can use a button installed on the button bar to get a history of the tabs you had open in your SSMS environment: There is also a literal history of the tabs on your system. Tab history can also reconnect the tabs to the databases they were connected to prior to closing them. Further, if you didn’t save that tab, no worries because tab history has all the T-SQL code, just as it was before you closed it, covering for you in the event of a problem. Reopening your tabs helps ensure that you see the same work as you did when you closed it. Once it’s enabled, you get a number of behaviors that can prove extremely helpful.įirst up, you can restore on launch all the tabs you had open when you last closed SSMS. You can enable or disable tab history according to your own preferences. Take a look at the Options for SQL Prompt and you’ll find a set of options under Tabs > History: SQL Prompt can help with both these problems. It’s also easy to get rid of tabs and scripts that you later wish you had back. It’s sometimes too easy to close SQL Server Management Studio (SSMS) without saving your work.
0 Comments
Leave a Reply. |