SSMS Copy and Paste Without Header - header

How do I copy and paste one record from SSMS 2012 without the header (when it comes along without me asking for it)? In SSMS, Tools -> Options -> Query Results -> SQL Server -> Results to Grid -> "Include column headers when copying or saving the results" is unchecked. Sometimes I would like to copy the header, however most of the time I would like to copy and paste one record into Excel and the header comes along uninvited - either when I do ctrl + C or just right click and "Copy". I've tried rebooting my computer to be sure it wasn't some sort of cached functionality but I can't seem to shake the header. Please help!

I don't have a root cause. However, a comment on a blog led me to realise that the problem only exists when you right click and go 'Select Top X' or similar. If you go 'new query' and manually enter that query, you can then copy without headers.
I'm still looking for the root cause and a complete solution. Will update my post if I discover anything further.

I think it is looking at the wrong setting value.
I unchecked Tools -> Options -> Query Results -> SQL Server -> Results to Text -> "Include column headers in the result set"
Opened a new query window and the functionality worked as expected i.e. Ctrl-C copied just the Grid cell contents, Shift-Ctrl-C included the headings.

If you select the records in Edit-mode of the grid then the Headers will not be copied in a CTRL+C and CTRL+V action

If option that you have described is unchecked, then Ctrl-C should copy data without headers. Have just verified it.

If you have already unchecked "Include column headers in the result set" through Tools -> Options -> Query Results -> SQL Server -> Results to Text -> "Include column headers in the result set" and your still having issues.
Copy your entire query
Open New Query Window
Paste query
Run Query
Ctrl + C or right click, copy.
This worked for me when working with Excel.

In addition to checking the Results to Grid settings under Tools -> Options, check the properties of the query itself. Right click in the query window, select "Query Options..." and inspect the check boxes in Results -> Grid. The "Select Top 1000 Rows" query from the table context menu defaults to include column headers when copying or saving results. If you're using a query window opened by the select top 1000 function, the query property is the likely culprit.

To maybe save someone else 15 mins of frustration researching this:
I just experienced this problem, which persisted after unchecking Tools -> Options -> Query Results -> SQL Server -> Results to Grid -> "Include column headers when copying or saving the results
I had to restart SSMS for the changes to take effect.

This post is now a bit old, but the default is not to include headers. I ran across this problem, reset my settings to default since I didn't have my customized settings anyways. This fixed the problem for me.

Related

Export Excel Function as a SQL request result

I am facing a weird behavior while exporting an output coming from oracle SQL. I am launching the below query:
select '=sum(1,2)' from dual
Then I right click on the output data and I export it to excel.
I am getting the following result in excel:
The function is presented as a string (the result in the cell is not "3", but rather "=sum(1,2)".
In order to fix this I had to click on the function then click on the Enter button on the keyboard.
excel file picture
Is there a way to force excel to directly understand that the string is a function ?
(I'm assuing you are on SQL Developer here)
There might be other ways, but a little trick I've used in the past is rather tahn Right Click => Export, simply do: Select-All, Copy. Then just Paste into Excel and that seems to preserve the formula definition.
A little animated GIF showing that here
https://imgur.com/a/SJDFjuz
Using the following Macro will fix it. Its a work around to this behavior
for each c in activesheet.usedrange.columns("AD").cells: c.formula=c.formula: next

How to select current row in SAP GUI Grid View with VBA Macro?

I am trying to automate a repetitive task in the SAP GUI. I need to search for an order number, select the row that the order number is in and then click a button to complete the task. I have recorded a macro which gives me:
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").pressToolbarButton "&FIND"
session.findById("wnd[1]/usr/txtGS_SEARCH-VALUE").text = "4521305207"
session.findById("wnd[1]/usr/txtGS_SEARCH-VALUE").caretPosition = 10
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[12]").press
session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").currentCellColumn = ""
session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").selectedRows = "2894"
session.findById("wnd[0]/tbar[1]/btn[14]").press
session.findById("wnd[1]/usr/chk[1,6]").selected = true
The line:
session.findById("wnd[1]/usr/txtGS_SEARCH-VALUE").text = "4521305207"
Corresponds to the order I want to search, but if I change this value it still tries to process the same order that the macro was recorded on, I'm assuming because of the line:
session.findById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").selectedRows = "2894"
Does anyone know how I would go about finding the number of the row which corresponds to the outcome of the SEARCH-VALUE and then using that as the .selectedRows = ""?
First of all I'd really recommend you add a reference to the native SAP library. Go to your VBA Editor, click Tools, then References, then Browse, and find this file: "C:\Program Files\SAP\FrontEnd\SAPgui\sapfewse.ocx". Add it, and now you'll have types and libraries and coding for SAP will be a lot easier, safer, and slightly faster (Variant types in VBA impose a tiny overhead that in this case is totally unnecessary). Get familiar with this new library if you are going to do any SAP scripting more than once.
Second, about this problem, what you have is a shell, of type GuiShell, which inherits from GuiGridView. GuiGridView looks like a table, a classic Excel-like set of rows and columns. In your transaction, is showing you a big list of orders, in which you go click the "Find" button, put the order you're looking for, and then close the Search Window. Back to your (Grid)Shell, this cell has been selected (Grid has properties SelectedCells, SelectedRows, SelectedColumns that get all set when you go find something), but then you go and modify the value of SelectedRows to a specific one.
So yeah, upon find, a cell has been selected, so all you need is to query its row and then assign it where you need:
Dim numrRow As Long
numrRow = session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell").CurrentCellRow
session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectedRows = numrRow
where "thisShell" is however you do to find a reference to the Shell (session.findByID("blabla") for example, but I'd advise to reduce all the findByID's, they're very slow and type-unsafe).
If you need help about this SAP libraries, feel free to maybe make some new post and ping me on the comments about it.

How to paste multiple environment variables in IntelliJ

Is there a way to add multiple environment variables in IntelliJ? When one sends me a list of variables I can add them one by one by clicking + in this window
But it's quite annoying to do for 10 or 20 variables every time. I can copy all variables from Environment variables field but we cannot paste there. Is there any way to do it?
Yes, it's totally possible to paste all environment variables at once in this screen but they need to be in a specific format.
Click on the ... button to the right of environment variables to show the dialog you have in your first screenshot.
Now you can use the Paste button but the values in your clipboard have to be in a specific format for pasting to work. In your case that clipboard info would be something like this:
APP_PORT=8080
DB_URL=jdbc:mysql...
DB_USER=javausers
DB_PASSWORD=javausers
APP_LOGGING_LEVEL=DEBUG
Try copying the value above and use the paste button (not Ctrl+v). If you don't have your data in this format you can try formatting it using a text replace tool online.
Also if you select all of the values in that dialog and click the copy button you can get the values in the same format that will work with importing. Warning: clicking Ctrl+c will not copy the values in the same format as the copy button in the dialog.
You could use "Paste" button at the bottom of the variables list.
Yes, just:
Click on the three dots (...) button of the Environment variables option. On the Windows version, the button is a little folder icon.
Select all the variables on the showed popup (name and value) and click on the "Copy" button. Close the popup.
Choose the other configuration, open his Environment variables option and click on the "Paste" button.
I am not sure if the (...) option is available in the community edition also.
This is how i was able to add them to the configuration. Just select the environment variables you want to import into the desired configuration.
E.g: If you have variables like
min_instance_count: 1
max_instance_count: 2
min_memory: 2
max_memory: 2
Replace the colons/other delimiters with = :
min_instance_count= 1
max_instance_count= 2
min_memory= 2
max_memory= 2
Now import the variables by copy-pasting (the clipboard sign).
You can simply paste a ; concatenated list of environment variables (and their values) into the Environment Variables dialog box.
E.g. paste in:
AWS_DYNAMO_ENDPOINT=http://localhost:4569;AWS_REGION=us-east-1;sample_var=sample
and get:

Repeating headers doesn't work in SSRS 2012

I have followed these instructions found in several places on the internet https://www.interfacett.com/blogs/repeating-freezing-column-headers-ssrs-tables/
to get the headers to repeat on every page and it doesn't work. Are there any other suggestions for getting this to work?
First Page:
and the next page:
Try setting the next static column over (usually right below the first column in the advanced mode list) to repeat on next page as well. Sometimes this works. Otherwise, you might want to try generating a new table and it might work with the new one. SSRS is finicky with this for whatever reason.

Import Data Wizard Does Not Like Data Type I Choose For A Column

Does anybody else have this same problem, when you import data from Excel file to MSSQL Server 2005, if some column contains mostly numeric data, but even if you set the column type to varchar, the wizard fails to import those fields that fail to parse as numbers?
Try this (Note: These instructions are based on Excel 2007)...
The following steps should force Excel to treat the column as text:
Open your spreadsheet with Excel.
Select the whole column that contains your "mostly numeric data" by clicking on the column header.
Click on the Data tab on the ribbon menu.
Select Text to Columns. This will bring up the Convert Text to Columns Wizard.
-On Step 1: Click Next
-On Step 2: Click Next
-On Step 3: Select Text and click Finish
Save your Excel sheet.
Retry the import using the SQL Server 2005 Import Data Wizard.
You need to edit the connection string that SSIS uses. Add this to the end of the string "IMEX=1;" (No quotes) That tells SSIS/jet to not try and figure out what the data types are. Just import them.
You might try tweaking Jet settings for importing Excel data. You can force the Jet engine to sample the entire sheet when trying to determine the column type during a given import. Change the following registry key (after making a backup first) and see if that doesn't do it:
HKLM\Software\Microsoft\Jet\4.0\Engines\Excel
Or on x64
HKLM\Software\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel
Set the value TypeGuessRows equal to zero. This will force Jet to sample all rows to determine the column type.
Create a new column that is an apostophe + the contents of the column you want to import. This will force it to be a string
="'"&E2
Adding IMEX=1 BEFORE the HDR setting worked for me.
This is the best solution:
Click File on the ribbon menu, and then click on Options.
Click Advanced, and then under When calculating this workbook, select the Set precision as displayed check box, and then click OK.
Click OK.
In the worksheet, select the cells that you want to format.
On the Home tab, click the Dialog Box Launcher Button image next to
Number.
In the Category box, click Number.
In the Decimal places box, enter the number of decimal places that
you want to display.