"collapse all' or "toggle outline" in SQL Server Management Studio 2008 - sql-server-2008

A new feature in SQL Server Management Studio 2008 is 'outlining' (the ability to collapse regions). It is awesome. However, by default all regions are expanded. I can't seem to find a way to 'collapse all' (also called 'toggle outline' in Visual Studio). Is anyone aware of a way to do this? I've been tasked with reviewing a 3,000 line stored procedure, and collapsing regions one-by-one is cumbersome.

This isn't a shortcut key, but there is a menu option in the Query Editor to do this.
Open your query and then go to Edit > Outlining > Toggle All Outlining.
This will toggle (i.e. expand/collapse) all nodes in the query.

It appears this feature does not exist. It has been recommended to Microsoft. I suggest voting it up;
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=368542
As a work-around, I'm using Notepad++ to edit locally. Its region identification isn't as good, but it's better than nothing.

A workaround is to use BEGIN and END.
BEGIN -- comment on/explain the region/outlined section
/*
TSQL goes here
*/
END
You will then be able to collapse the BEGIN.

In ssms 2017 -> There is an option in Tools > Options {see image}
The below illustrates #Triynko update to #Shawns answer

There is a free 3rd party add-in for SSMS called, SSMS Tools Pack. It provides several useful features, which includes collapsable regions and debug sections. By default, the regions are collapsed when you first open a .sql script.
http://www.ssmstoolspack.com/Features?f=9
For example:
--#region You can place comments here which are visible when the region is collapsed.
if object_id('MyTable') is null
begin
create table MyTable
(
constraint [pk_mytable] primary key clustered ( mytable_id ),
mytable_id int not null
);
end;
--#endregion

If you open a .sql script in Visual Studio then you can collapse the code in there.

In my condition it was "Maximun Script Size" default is 1MB, mine was above 1Mb changed it to 5MB it works
Path is
Tools >> Options >> Text Editor >> TransactSQL >> Intellisense >> Maximum Script Size

An option that I found helpful...
Edit.ToggleAllOutlining
In SSMS 2019 -> Tools > Options > Environment > Keyboard, then click on command Edit.ToggleAllOutlining and Assign your new shortcut keys.
Screenshot of Option
Screenshot of Caution
I used Ctrl+K, Ctrl+T.
Then put a GO in the beginning of Query and GO after any region I wanted collapsed. I tried BEGIN END, but it collapsed entire Query.
Try it out with the following:
/*
Toggle using Tools > Options > Environment > Keyboard
Search for "Toggle"
Select Edit.TogleAllOutlining
Enter Global Shortcut key. Do not use common keys like ctrl-A, ctrl-c, ctrl-v, etc...
Pay attention to "Shortcut currently used by: (dropdown values)"
I used ctrl-k, ctrl-t
*/
GO
--Do something
Declare #Something varchar(max)
GO
/*First Region*/
select 'parent - this will be toggled'
select 'sub query - toggled with parent'
GO
/*Second Region*/
select 'parent - this will be toggled too'
select 'sub query - toggled with parent'
GO

Ctrl+M,Ctrl+A is the default in SSMS 17.X.
You can change this by going to Tools > Options > Environment > Keyboard, then click on command Edit.CollapseAllOutlining and Assign your new shortcut keys.

CTRL + M then CTRL + L
collapse / decollapse all in visual studio 2022

This feature was implemented in SQL Server Management Studio 2012 and is available for editions beyond also using CTRL + M etc - https://msdn.microsoft.com/en-us/library/ms174205(v=sql.110).aspx

Related

SSIS - Loop Through Active Directory

Disclaimer: new to SSIS and Active Directory
I have a need to extract all users within a particular Active Directory (AD) domain and import them into Excel. I have followed this: https://www.itnota.com/query-ldap-in-visual-studio-ssis/ in order to create my SSIS package. My SQL is:
LDAP://DC=JOHN,DC=JANE,DC=DOE;(&(objectCategory=person)(objectClass=user)(name=a*));Name,sAMAccountName
As you know there is a 1,000 row limit when pulling from the AD. In my SQL I currently have (name=a*) to test the process and it works. I need to know how to setup a loop with variables to pull all records and import into Excel (or whatever you experts recommend). Also, how do I know what the other field names are that are available to pull?
Thanks in advance.
How do I see what's in Active Directory
Tool recommendations are off topic for the site but a tool that you can download, no install required, is AD Explorer It's a MS tool that allows you to view your domain. Highly recommend people that need to see what's in AD use something like this as it shows you your basic structure.
What's my domain controller?
Start -> Command Prompt
Type set | find /i "userdnsdomain" and look for USERDNSDOMAIN and put that value in the connect dialog and I save it because I don't want to enter this every time.
Search/Find and then look yourself up. Here I'm going to find my account by using my sAMAccountName
The search results show only one user but there could have been multiples since I did a contains relationship.
Double clicking the value in the bottom results section causes the under pane window to update with the details of the search result.
This is nice because while the right side shows all the properties associated to my account, it's also updated the left pane to navigate to the CN. In my case it's CN=Users but again, it could be something else in your specific environment.
You might discover an interesting categorization for your particular domain. At a very large client, I discovered that my target users were all under a CN
(Canonical Name, I think) so I could use that in my AD query.
There are things you'll see here that you sure would like to bring into a data flow but you won't be able to. Like the memberOf that's a complex type and there's no equivalent in the data flow data types for it. I think Integer8 is also something that didn't work.
Loop the loop
The "trick" here is that we'll need to take advantage of the
The name of the AD provider has changed since I last looked at this. In VS 2017, I see the OLE DB Provider name as "OLE DB Provider for Microsoft Directory Service"
Put in your query and you should get results back. Let that happen so the metadata is set.
An ADO.NET source does not support parameterization as the OLE DB does. However, you can apply an Expression on the Data Flow which surfaces the component and that's what we'll do.
Click out of the Data Flow and back into the Control Flow and right click on the Data Flow and select Properties. In that properties window, find Expressions and click the ellipses ... Up pops the Property Expressions Editor
Find the ADO.NET source under Property and in the Expressions section, click the Ellipses.
Here, we'll use your same source query just to prove we're doing the right things
"LDAP://DC=JOHN,DC=JANE,DC=DOE;(&(objectCategory=person)(objectClass=user)(name=" + "a" + "*));Name,sAMAccountName"
We're doing string building here so the problem we're left to solve is how we can substitute something for the "a" in the above query.
The laziest route would be to
Create an SSIS variable of type String called CurrentLetter and initialize it to a
Update the expression we just created to be "LDAP://DC=JOHN,DC=JANE,DC=DOE;(&(objectCategory=person)(objectClass=user)(name=" + #[USer::CurrentLetter] + "*));Name,sAMAccountName"
Add a Foreach Loop Container (FELC) to your Control Flow.
Configure the FELC with an enumerator of "Foreach Item Enumerator"
Click the Columns...
Click Add (this results in Column 0 with data type String) so click OK
Fill the collection with each letter of the alphabet
In the Variable Mappings tab, assign Variable User::CurrentLetter to Index 0
Click OK
Old blog posts on the matter because I like clicks
https://billfellows.blogspot.com/2011/04/active-directory-ssis-data-source.html
http://billfellows.blogspot.com/2013/11/biml-active-directory-ssis-data-source.html

maple code output does not display on the screen

I've just downloaded the Maple 2020 trial version and I have zero experience on Maple programming. My problem is: when I do simple calculations such as 3+5 or 2*3, the result displays on the screen but, for other functions such as
factor(x^2+2x+1);
or assigning variables can't be done:
n:= 5;
m:=7;
m+n;
I do not see any results on the display screen after the enter.
Where am I doing wrong?
It seems like, I need to change some configurations of the Maple. After doing some search online, I found these suggestions in a web site. I have applied the following steps and my problem is solved: (Remember to apply globally not for the session.)
Open a new blank worksheet
On the toolbar, access Tools->Options.
Select the 'Display' tab
Ensure that the first entry is set to 'Maple Notation', and the second entry is set to '2-D Math Notation'
Click 'Apply to session' at the bottom left
On the toolbar, access Tools->Options again
Select the 'Interface' tab
Ensure that the entry 'Default format for new worksheet' is set to 'Worksheet'
Click 'Apply to session' at the bottom left
Now open a new worksheet in the same session. There should be a prompt '>'.
At the prompt, type 'version();' without the single quotes, but with the trailing semi-colon. This ought to return details of the precise Maple version you are running. If it returns something like
User Interface: 1133417
Kernel: 1133417
Library: 1133417
(precise numbers may be different), then you ought to be good to go - so try something simple like 1+1; at the next command prompt, (remember the semicolon).

PhpStorm: fill-in default parameter values with keystroke

Is there a shortcut for PhpStorm (or other JetBrains IDE, they're likely to be the same) that will automagically fill in default parameter values for method calls?
IE, I'm typing in:
$form->generateSelectBox("weekly_snapshot_id", "Weekly snapshot", ...loads of default values here..., "value I actually wanted to set");
and I'd actually just like to type:
$form->generateSelectBox("weekly_snapshot_id", "Weekly snapshot");
put the cursor inside the argument list and hit CTRL + WHATEVS and get ...loads of default values here... automagically completed for me.
Haven't found anything in the dox, google or previous questions that might do this, some tantalising hints about IntelliJ plugins that did this out there but nothing for PhpStorm specifically.
Screenshot as requested: (I select 'params' not cust_id)
You'll be able to do that via Ctrl+Space suggestion list starting PhpStorm version 2019.2: https://youtrack.jetbrains.com/issue/WI-45683

All column names in my view are underlined in red in SSMS

I created the view View_DefectDaysOutstanding3. when I select to see the data, it gives the data, but why in the select statement all the fields are underlined in red as error?
SELECT TOP 1000 [ID]
,[Severity]
,[AvgDaysOutstanding]
,[ReportMonth]
,[ReportYearMonth]
,[#OfBugs]
,[projid]
,[folderid]
FROM [SoftwarePlanner].[dbo].[View_DefectDaysOutstanding3]
order by ReportYearMonth
Have you refreshed your Intellisense cache?
Keyboard shortcut:
Ctrl + Shift + R
Or, using the menu: Edit -> IntelliSense -> Refresh Local Cache
Go to Edit > IntelliSense > select "Refresh Local Cache".
You need to refresh your cache after you create new tables/add columns/ new views etc

Problem with the row count transform

I currently deployed an SSIS package (Developed on the 2005 version) (developed on my local server) in a pre production environment for testing. I have used the Row count transform to get a count of good/bad records. It works fine on my local system . However when i deploy this on the pre prod server, the row count does not work! (as in it does not recognize the vairbales i have assigned to the relevant transofm - no drop down abvaliable in the variables attribute part. tried deleting and adding a new transoform.. no luck.
Strangely this does not work for any of the other packages also present/deployed on the same server (tried this out by dropping an rc tramsform onto an existing package... same problem)
Any suggestions?
Thanks a tonne
If you are having problem with the row count transform, another alternative that we use here at my company is creating a script component and incrementing a rowcnt variable by one. The performance is just as good-just add this code:
Public Overrides Sub PostExecute()
MyBase.PostExecute()
Me.Variables.rowcnt = Me.Variables.rowcnt + 1
End Sub
This certainly seems odd. Are you saying that when you are in the Advanced Editor for Row Count, under Custom Properties, that the drop down beside VariableName has no options? You should at least see all of the System:: variables.
If the User:: variables are not listed, my first suspicion is that they do not have the correct scope to be visible in the Data Flow Task where you have your RowCount.
When you go up to the Control Flow, and get the Variables list, do you see your user variable there? What is the scope of it?
Note that I recognize that none of this fits with "it works locally but doesn't work when copied to the server", but it is at least where I would start...