Red Gate forums :: View topic - Issue with SELECT and the word FROM in DB Objects
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product support center
SQL Prompt 5
SQL Prompt 5 forum

Issue with SELECT and the word FROM in DB Objects

Search in SQL Prompt 5 forum
Post new topic   Reply to topic
Jump to:  
Author Message
rldawg



Joined: 18 Nov 2008
Posts: 10
Location: United States

PostPosted: Wed May 16, 2012 2:39 pm    Post subject: Issue with SELECT and the word FROM in DB Objects Reply with quote

In settings, I have "List all database columns after a SELECT statemet" unchecked.

So in order to get column suggestions, what I willl normally do is type SELECT<enter/newline> and then type FROM <tablename> and then move back up to the select line so that I can get column suggestions.

After the most recent update when i type FROM ... the suggestion box pops up and shows me a list of a couple views i have i.e. vwCompanyNameAddressFromContact that have the word FROM in them and if I hit a space, it will use that view instead of the FROM that I typed.

I guess the new feature is to do matching within the object name vs the start of the object name.

This is more than annoying when your object has the word FROM in it. Can we come up with a better solution?
Back to top
View user's profile Send private message
Paul Stephenson



Joined: 23 Jul 2010
Posts: 108
Location: Cambridge, UK

PostPosted: Thu May 17, 2012 10:00 am    Post subject: Reply with quote

Hi rldawg,

I see your point: the partial matching is now suggesting more items and therefore has a better chance of matching one of your tables or views when you really wanted the word FROM.

The keyword FROM itself is not being shown because it's not valid SQL straight after a SELECT -- if it were, then FROM would be the top choice.

One option would be to use the ssf<tab> snippet to start your queries. This puts in SELECT * FROM and offers you the table list straight away (saving keystrokes!). Then, when you want the columns, you can either go to the * and press Tab to expand them all, or delete the * and press Ctrl+Space to get the column list as normal. You can edit the ssf snippet to include a newline by going to SQL Prompt 5 > Snippet Manager.... Alternatively you could format the SQL afterwards with Ctrl+K Ctrl+Y.

Another option is to create your own snippet (e.g. sf) that contains this:
Code:
SELECT
FROM

(with a space after the FROM). Then when you type sf<tab> it'll show you the table list immediately, giving you your previous behaviour as well as saving keystrokes.

Finally, you could stop using Space as a completion character, if your fingers can be retrained Smile. Then the word FROM would come out fine when you type it, without completing to anything.
_________________
Paul Stephenson
Project Manager, Red Gate
Back to top
View user's profile Send private message Send e-mail
rldawg



Joined: 18 Nov 2008
Posts: 10
Location: United States

PostPosted: Thu May 17, 2012 1:44 pm    Post subject: Reply with quote

"The keyword FROM itself is not being shown because it's not valid SQL straight after a SELECT -- if it were, then FROM would be the top choice"

I will say that my method worked in previous versions...but I can not be sure.

Once i get the FROM typed in SQL prompt doesn't have a problem suggesting table names for me (perhaps knowing that I am trying to do in order to get a proper column list suggested to me). Normally if things are syntactically out of whack, SQL prompt will stop making suggestions.

Howver, I think you gave me some good alternatives that I will try and then report back. Thanks.
Back to top
View user's profile Send private message
rldawg



Joined: 18 Nov 2008
Posts: 10
Location: United States

PostPosted: Thu May 17, 2012 1:54 pm    Post subject: Reply with quote

Quick followup: The sf snippet idea is brilliant. As soon as I do that, SQL Prompt immediately suggests objects with no extra key strokes.

Thanks!
Back to top
View user's profile Send private message
Paul Stephenson



Joined: 23 Jul 2010
Posts: 108
Location: Cambridge, UK

PostPosted: Thu May 17, 2012 2:14 pm    Post subject: Reply with quote

I'm glad that's working well for you.

Although SQL Prompt often stops suggesting with invalid SQL, it does suggest tables after SELECT FROM, possibly deliberately so that you can enter the table name before the columns as you're trying to do.

Nothing has changed in this area since previous versions except the partial matching. I think the problem is just the combination of using Space as a completion character and having tables (or views) that contain the string "From".
_________________
Paul Stephenson
Project Manager, Red Gate
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group