Community
    • Login

    Using Notepad++ for SQL

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    3 Posts 3 Posters 108.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CrimsoN44BananAC
      CrimsoN44BananA
      last edited by

      I am a newbie. How do I get started using Notepad++ with sql? I downloaded it from the website. Chose sql as my language. Now what?

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        Notepad++ is a text editor, so you can now use it to edit your SQL file. After selecting the Language > SQL, Notepad++ will highlight SQL syntax as you type. Try typing some SQL, like

        SELECT "Hi";
        SELECT * FROM mydatabase WHERE id LIKE 'ID%';
        

        You will see color, bold, and other possible formatting applied to the text you type. If you save the file as something.sql, and then load something.sql in your SQL client, the client will run the SQL commands from that file. If you have an existing somethingElse.sql file, you can open it in Notepad++, which will auto-recognize that it’s SQL and apply the syntax highlighting, allowing you to edit it and save it.

        By using the Run > Run dialog, you can run an arbitrary command. For example, if your SQL client has a command-line mode accessed thru sqlclient.exe, you could type

        c:\path\to\sqlclient.exe $(FILE_NAME)
        

        If you just run it, that probably won’t show you any results… but if you ran

        cmd /k c:\path\to\sqlclient.exe $(FILE_NAME)
        

        It will open a new cmd.exe Windows command prompt, and show the output from that file.

        If instead of running, you hit “SAVE”, you can give it a name (which will end up later in the Run menu), and/or a keyboard shortcut, so that you can easily re-use that many times.

        If you want to do something more fancy, use the NppExec plugin, which includes a better batch/scripting language. Once again, you can save the NppExec script, and make it show up in the Macro menu.

        If Python is a programming language you know or could learn (or if, like me, you know enough other programming languages that you can fake the Python), then the Python Script plugin will allow you to do even fancier stuff. (Python is a complete programming language, and has many libraries written, which could act as an interface between your SQL source file and your database engine; PythonScript has access to a full python2.7 interpreter. For example, you could write a script in Python which executes the commands from your SQL, grabs the results from your database engine, and displays them in Notepad++, either inline with your original SQL code, or in a new text document. You are really limited only by your imagination and knowledge of Python.)

        If you are just learning SQL, and were asking us to tell you how to write SQL syntax… there are plenty of tutorials and books available for learning SQL (and you can then use NPP in the place of whatever text editor they suggest using).

        If you wanted something different than I explained, please clarify, and we can help you through how NPP can help you with your tasks.

        1 Reply Last reply Reply Quote 1
        • Frank OrellanaF
          Frank Orellana
          last edited by

          I recommend you use an online sql console so you can get started with sql, it will simulate a database where you can create tables, insert data into them and query them, for example:

          http://sqlfiddle.com/#!9/4bd6b/1

          Notepad++ is just a text editor so you will be able later to save and edit your sql files in it, but for learning you will need a database and start working with it.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors