Simply Connect SQL Server with Visual Studio Code & Run Queries

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to this tutorial on running your SQL Server so quitting your SQL Server databases within vs code vs code obviously being a very popular IDE commonly used um with python and other programming languages now there's a couple dependencies you'll need to have vs code installed and SQL server but once you've done that you can actually go into your extensions on the side pin here and simply type in Ms SQL and this will give you the option to install the SQL Server extension for vs code so that needs to be done primarily that will take a little bit of time you know up to uh 30 seconds maybe and then that will be successfully installed as an extension within vs code so that's step one as you can see we can connect to Microsoft SQL Server we can connect to um Azure SQL databases as well so we cover a lot of the transact SQL side of things and one nice Advantage here so you've also got the the dark mode that I've got another video displaying dark mode um in SQL server but it's quite hard to natively get this and of course the dark mode is a lot less jarring on the eyes so then what we need to do is we need to hit Ctrl shift p to open the command palette and type in SQL and from here we'll have the option Ms SQL connect and this is going to allow us to go ahead and connect our database up so it will just go ahead and install the the SQL tools again this this won't take much time I've slightly sped this part up from here you can select that you you want to use the language get rid of these pop-ups as well and again from here press Ctrl shift p open up the VS code command palette and now we need to look at managing the connection profiles so click there and this is there's some fairly simple steps here they sort of vary so you can follow along dependent on exactly how you want to configure this but in the server name we can just go ahead to our actual um in my case our Microsoft SQL Server instance and I'm just going to copy my server name for me it's my desktop server name so I can just go ahead and import that back in now there may be different ways you want to configure this you may want to connect to a certain database if so you can go back and get that an example of a sample database is adventureworks 2019 it may be something like that I'm integrated so I'm just going to go ahead and step skip the extra steps for the extra configuration you may have log on specific logons you want to connect to but this is the very basic way to do it and this will show you how easy it is to actually especially if you're running this locally and it's just sort of a development or test environment really easy to connect to to Microsoft SQL server and SQL Server management Studio through that that GUI so again we can expand here I do get a warning but I'll enable the certificate here and when I do this I can just go ahead and start to actually play around and query my databases so you see a popular sample database Adventure Works 2019 I do have another separate video to this and if you're interested in getting this sample data really powerful around 70 tables so I can right click and like you may have seen before we can just query select all our top 1000 and bigquery at maybe limit 1000 in t SQL within SQL server or Azure SQL it may be a top 1000 but this essentially just gives you the 1000 results from the desired table so already at this point we've managed to set up a SQL server within vs code we can now query it and we also get this nice vertical layout if you're using SQL Server management Studio you will see the query on top in a horizontal fashion the script and then the query output the query result Falls below horizontally so it's quite nice for a lot of people to have this um to have this vertical View so again I can close these down and just show how we can go ahead and actually start to query things manually so we can create a new file and here I'll just add a text file just to show you how simple it is and then we can save as and we will go ahead and just save this as a SQL file wherever you like so just call this test query save it as a SQL file and from there we're all configured to actually write some SQL we can see we've got our connections there and our query history and you can go ahead and just write your standard sort of um t-sql code so transact SQL SQL Server specific obviously for that rdbms and I could choose the columns I want so business entity ID potential potentially National number here so we've got the national ID number and then we just select the from destination maybe slightly different to how you make query within the context of a table in SQL Server management Studio here we're just going to write the server first so because we didn't specify uh well the database because we didn't specify one particular database then the schema and then the table obviously a schema just a logical grouping of some of those related tables that we have and again we can run this and it works perfectly we get that nice vertical output everything's quite easy to see the dark Mode's nice and I would suggest if you're using this in a test or development environment to give it a shot really easy to configure a really powerful and user-friendly like comment subscribe and share
Info
Channel: Matador Software
Views: 4,993
Rating: undefined out of 5
Keywords: sql, sql server, microsoft sql, ssms, sql server management studio, t sql, t-sql, transact sql, vs code, ide, coding, custom sql ide, custom sql editor, data, data analysis, data science, data engineering, data careers, learn data
Id: gaN3H9U7r-c
Channel Id: undefined
Length: 6min 4sec (364 seconds)
Published: Thu Feb 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.