Entering a query in the conceptual order

Terence_HTerence_H South AfricaPosts: 2 Bronze 2
Not sure if this is even possibly, but it it was, the wizards at Redgate might be able to do it?

Is there not a way in which a sql query can be 'constructed' in text in the conceptual order of evaluation (ie - logicaly), but the translated by SQL prompt into the accepted sql query..

IE:
enter into editor:
from Books b
left join Authors a on a.id = b.authorID
where Title = 'My book'
select b.Title, b.ISBN, a.Name
order by 1

It is a little pedantic, but would save some 'scrolling' up and down. currently you first do ssf tableA and then go and fix your columns afterward... Would be nice if everything in life was 'logical' :cake:

:o

Just a thought, use it, don't use, but please don't judge
B)
Use it, don't use it, your choice - just don't judge me for speaking my mind

Best Answer

  • James RJames R Posts: 104 Silver 4
    Accepted Answer
    Hey @Terence_H ,

    Thanks for the suggestion!
    Unfortunately I'm not sure there's a lot we can do about the structure of SQL - it would certainly need a lot of thought put into it.

    It's definitely a cool idea though, could you post a suggestion to our Uservoice page https://redgate.uservoice.com/forums/94413-sql-prompt and potentially we'd get round to investigating the idea if it gets voted on.

    A workaround might be to make use of some existing snippet functionality in SQL Prompt. If you change the order of placeholders you can automatically get the cursor to move between code - potentially even back to the columns in a SELECT.

    For example, a simple modification of the 'ssf' snippet could look like 'SELECT $column$ FROM $table$', and if you list $column$ as the second placeholder it will prompt you to type the table name first, followed by the columns.

    Sorry I couldn't be more help!
    Regards,
    James
    Software Engineer
    Redgate Software

Answers

  • Terence_HTerence_H South AfricaPosts: 2 Bronze 2
    That is actually a brilliant idea.. I never thought of using the snippets like that.. Definitely going to list on uservoice and add the snippet
    Use it, don't use it, your choice - just don't judge me for speaking my mind
  • I'm with you! Every time I write a SQL query (about a bajillion times a day) I wish the syntax started with FROM instead of SELECT. I do the same thing--use the ssf snippet and trim the column list, then build out the JOINs.
Sign In or Register to comment.