Terminology question. In SSMS, when you list the various tables and right click on one, you get the 'Select Top 1000 Rows' & 'Edit Top 200 Rows', and depending on which on you click, it will take you to an interface that looks similar to the other, but clearly works differently. Does Microsoft have a specific name for these two interfaces? I had wanted to look up some settings for these and realized I don't even know what they're called. I've always called them Select Mode and Edit Mode, but searching that hasn't yielded anything useful.
The "Select top 1000 Rows" takes you to a query editor with a prewritten query in the below fore and automatically runs it:
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000) <Column Name>
[,<Column Name> ...
,<Column Name>]
FROM <Database Name>.<Schema Name>.<Object Name>
The window at the bottom is the results pane.
The "Edit Top 200 Rows" launches a query designer, based on the a similar query to the above (but the database name is omitted and the schema might be). Forget you ever saw this, and never use it again. The "feature" is actually full of bugs, it lacks functionality and support for a lot of features (especially newer ones, like temporal tables), and has some interesting "quirks". If you need to "edit" your data then write the appropriate INSERT, UPDATE and DELETE statements to alter your data.
Related
Decided to pick up Datagrip for my Postgres database.
I've worked with SSMS/MS SQL-Server a lot, and one of the nice things about SSMS is the option to select a table and then a menu option called "SCRIPT TO..." and it'll give another list of auto-generated select, update, delete, etc queries.
Does Datagrip have a similar function? I'm struggling to find it.
In DataGrip there is another concept of creating queries, editor-centered:
Live Templates. When you are in the editor you can quickly create any type of query. For example, for SELECT * FROM <table_name> just type sel and press Tab. Then choose the table. The same for INSERT (type ins). All live templates can be found in Preferences | Editor | Live Templates
Generate functionality: Alt+Ins or Cmd+N. It is not customizable but good to create objects.
Anyway, your point is fair and there is a feature request in DataGrips' tracker: https://youtrack.jetbrains.com/issue/DBE-2762. Please upvote and comment there.
SQL Developer 19.1 - worksheet editor doesn't show matching list of table names from the schema. Eg. If I were to write a SQL query such as:
select * from TMP_EMPLOYEE_MASTER;
I am expecting SQL Developer to show me the table name after I have typed first few letters of the table name (eg. TMP_EM). But looks like SQL developer doesn't seem to be helping at all in highlighting the matching table names.
I know that this feature exists in SQL Developer. Just wondering why it isn't working
Edit 1:
I tried below options but still not working:
CTL+spacebar.
Change the entries in the preferences as mentioned in the screenshot. But this didn't help. The auto complete/suggestion for table name is not coming at all.
I'm guessing you have more than 10 tables that start with TMP
Increase the filter for Auto-Complete to something higher than 10 - or type more letters, or use Ctrl+Spacebar to 'force' the completion feature to fire.
That option is located in Tools - Preferences; search for "complet" and you'll see Code Editor: Completion Insight. Check both "SQL Worksheet" and "PL/SQL Editor" checkboxes, adjust popup speed if necessary.
Works for me ...
Write this:
Select * From tablea
Want this:
Select c1, c2, c3 ... From tablea
SQL Server Management Studio provides intellisense to pick one column at a time. It takes a while for table with lots of columns.
I can use Script Table as =>Select To=> New Query Edit Window, and the copy/paste to my original script. however is there a less interruptive way?
I write SQL a lots, thanks for help!
Found this myself.
Type Select * From TableA in SSMS.
Exactly Select text Select * From TableA.
Use Ctrl+Shift+Q to pop up Query Designer window.
Click OK. "*" is replaced by "c1, c2, c3..."
Query Designer auto-populates all the columns. just open it & close. if you want only portion of columns, I found it is still easier to delete them on text editor than trying to use mouse to uncheck them on GUI.
Still hope to find a way to eliminate the Keyboard/mouse switch on step 4? seems there is no short-cut key for the OK button.
Update 2019-06-24
Above method does not work for table in SQL Azure. ApexSQL SQL formatter seems working well for me, it's free.
Update 2020-10-30
found a similar function in LINQPad, it allows me to auto-complete all properties in LINQ, See here
In SQL Server Management Studio if you expand the object explorer and then the node for the particular table in question then you can drag the columns node into the query window and this will type out all of the column names for you.
There are probably better ways to do this, but that's what I use.
Totally understand this answer is not specific to SSMS but in VSCode via the mssql extension:
Write this:
Select *
From TableX
Place cursor after the * and press Ctrl+Spacebar and option to insert all columns appears
If your object explorer is open then use drag & drop feature.
e.g. Northwind
Step 1: Expand the database by single click on plus icon or just double click on "Northwind"
Step 2: Expand tables "Tables"
Now you will see "Columns", "Keys", "Constraints" etc
Click on "Columns" to drag to your editor window.
You can try for other as well like "Keys", "Constraints".
But for "Indexes", did not work for me.
Hope you will find useful tips.
I have quite the request. A developer created our database that has multiple Layouts with a relationship tree that is very messy. Had another developer come in, take a look at it, he said that it would be too time consuming and painful to deconstruct our system, consider creating a script for now so that you can work around it until it can be fixed. Here's the dilemma: I've got information on one page that is supposed to reference information on a number of different pages utilizing tabs and portals. However, all the information is linked to a username. This username is not static/serialized or what have you. Therefore, if the issue is not caught right away a great deal of information can be linked to this person's 'page'. If the name is incorrect and someone tries to alter the username even slightly, it breaks that relationship and starts a new one. The information does not disappear, but it is basically sitting in limbo somewhere until you change the name back to the original. I've actually tried exporting the information, changing the information that doesn't match, i.e. changing a name from Jon.Smith to John.Smith, and then importing the information to a new 'page' for that person with unsuccessful results. Which brings me to my question, is a script going to be able to fix this problem? Likewise, are there any suggestions to how to create this script? I apologize, but I have very little experience with DataBase management at all, and am not sure why this project fell upon me. Any help would be GREATLY appreciated.
Well, as a general answer, just about anything that a user can do in FileMaker (and by user, I mean non-developer, so activities such as defining the database structure, writing scripts, etc., are excluded) can be scripted. So if you're able to "solve" the problem by resetting a field's value, for example, then, yes, a script can do that.
Regarding your specific trouble, a script probably doesn't need to export the records, but could reset the values for the field within FileMaker. This could be done either by looping through the records that need to be changed or by using the Replace Field Contents script step. So a script could do something like this:
Go to Layout[MyLayout] // Go to a layout that is attached to the table you need to search.
Perform Find[Restore] // Restore a find that will show the records you need to change.
Replace Field Contents[Table::Field; "New Value"]
Offering more advice than this would require actually seeing the database and understanding more about your specific needs.
wchsTech4, you are in luck because your problem is easy to fix. You don't even need a script.
BACK UP YOUR FILE(S) FIRST. Then:
1) Create two new fields:
id (person table)
Options for id: Auto-enter serial number
person_id (the table related to person)
2) Generate serial numbers for the new id field in the person table.
Navigate to the person layout.
'Records' > 'Show all records'
Click in the id field and select 'Records' > 'Replace field contents.'
Choose 'Replace with serial numbers' and accept the defaults. Be sure to check the box to update your next serial number.
3) Place the serial numbers you just generated in the related table.
Navigate to the related layout.
'Records' > 'Show all records'
Click in the person_id field and select 'Records' > 'Replace field contents.'
Choose 'Specify' next to 'Replace with calculated results.'
In the drop down on the top left, select the related person table.
Double click the id field (your calculation should be person::id, with person replaced with the name of your table).
Click 'OK' and then 'Replace.'
4) Change the relationship.
Select 'File' > 'Manage' > 'Database.'
Navigate to the relationship tab.
Change the relationship from being based on name to id.
5) Test everything. Should work.
There is a chance that your related records are being created in such a manner that you also need to modify a script, website, or something else not mentioned here to have your fix work going forward. That is important to investigate.
I have a (very simple and standard) UPDATE statement which works fine either directly in Query Analyser, or executed as a stored procedure in Query Analyser.
UPDATE A
SET
A.field1 = B.col1
, A.field2 = B.col2
FROM
tblA AS A INNER JOIN tblB AS B
ON A.pk1 = B.pk1 AND A.pk2 = B.pk2
Problem is when i execute the same stored proc via microsoft ADP (by double-clicking on the sproc name or using the Run option), it says "query ran successfully but did not return records" AND does NOT update the records when i inspect the tables directly.
Before anyone even says "syntax of MS-Access is different than SQLServer T-SQL", remember that with ADP everything happens on the server and one is actually passing thru to T-SQL.
Any bright ideas from any ADP gurus out there?
Gotcha. Responding to my own question for the benefit of anyone else.
Tools / Options / Advanced / Client-Server Settings / Default max records is set at 10,000 (presumably this is the default). Change this to 0 for unlimited.
My table had 100,000+ rows and whatever set of 10,000 it was updating was difficult to find ( among a sea of 90,000+ un-updated rows ). Hence the update did not work fully as expected.
Try and see whether the query gets executed on the SQL Server using SQL profiler.
Also, I think you might need to close the linked table & re-open it to see the updated records.
Does that work?
Run the query with SQL PRofiler running. Before you start the trace add in all the error events. This will give you any errors that the SQL Server is generating that the Access ADP might not be showing correctly (or at all).
Feel free to post them here.
Just as a reference, here's a paper I wrote on Update Queries that discusses some of the issues associated with when the fail.
http://www.fmsinc.com/microsoftaccess/query/snytax/update-query.html
I seem to remember that I always got the "didn't return any rows" message and had to simply turn off the messaging. It's because it isn't returning any rows!
as for the other - sometimes there's a primary key issue. Does the table being updated have a primary key in SQLServer? If so, check the view of the table in Access - sometimes that link doesn't come through. It's been a while, so I could be wrong, but I think you may need to look at the design view of the table while in access and add the primary key there.
EDIT: Additional thought:
in your debugging, try throwing in print statements to see what the values of your inputs are. Is it actually picking up the data from the table as you expect when you execute from access?