Posts

SSMS 18.7.1 installation and news!

Image
Hello friends! November hitted hard for me and sometime you just need a little rest! But now i am here again so... Today we will talk about the SSMS aka SQL Server Management Studio . What is, How to install it and what features it introduces. Are you ready? go! SSMS 18.7.1 installation First step, go on the microsoft page and download the last SSMS:     Once downloaded the executable, execute it.   The installation process is eally easy so "Just Press the Install Button": Et voilà, the installation come to an end! Now you can use the last version of the SQL Server Management Studio. Ok but what is really the SSMS? Important:  The SSMS is nothing else than the graphics interface used to interact with the database engine. T-SQL commands are understood by the database engine and not by the SSMS.  By default when you install the SQL Server product you will not found the SMSS, if you wnat to use it you need to install it! SMSS 18.7.1 news! This time we have few news...

SQL Server, How to easily create a text file with the result of your query (another easy tips)

Image
Hello friends, Its the time for another " useful but fast & easy ” tips! The question of today is:   I have a query, a select on my database the "give me" a resultset which I need to export to a text file. How to produce the text file? maybe this operation must be schedulable. So, How to do it?  We can take advantage of the SqlCmd command that we have already used here: execute T-SQL commands from the command line   Just prepare your select as in the picture below and save it into a .SQL file.     Then open a command promp and type: SqlCmd -U xx -P yyyyy -i select.sql -o c:\dati.txt where    -U username -P password  -i the location of your script   -o is the file name that will be filled up with your data!     Et voilà!    That's all for today I wish you a great day! Luca Previous post: SQL SERVER, One thing you should definitely know about the UPDATE statement ...  

SQL SERVER, One thing you should definitely know about the UPDATE statement ...

Image
Hello friends, Today, waiting for the saturday, we talk about a simple thing that you really should know about the UPDATE statement . How many times have you seen updates done like this?    UPDATE ORDRIG SET NeatPrice = Price * (100-PercDiscount)/100, total = NeatPrice * Qty where id = XX   Notice that the result of the second field depends on the result of the first one . So in this case order matters. How does SQL Server behave in this case? Seems difficult but it is more easy than you could image!   Just learn this easy rule: The UPDATE does not see the results of its work.   Of course you can tray by yourself doing this simple update: CREATE TABLE #ORDRIG ( ID INT IDENTITY ( 1 , 1 ), PRICE FLOAT , NETPRICE FLOAT ) INSERT INTO #ORDRIG ( PRICE , NETPRICE ) VALUES ( 0 , 0 ) UPDATE #ORDRIG SET PRICE = 5 , NETPRICE = PRICE SELECT * FROM #ORDRIG   Et voilà! That's all for tod...

SQL Server, How to execute T-SQL commands from the command line (attention this post may contain easy but useful tips 😏 )

Image
Hello friends, You know, i love “ useful but fast & easy ” tips! The question of today: Have you ever needed to run T-SQL commands from the command line? Yes? So, How to do it? Well, an easy way is to use the sqlcmd command. But what is the SqlCmd? The SqlCmd is a command line utility that is part of the standard installation of SQL Server and that you can run from the command prompt. First you need to prepare a script that contains the T-SQL commands to execute. In my example i saved myscript.sql in C:\TEMP folder. Second , just open the command prompt   And type in: sqlcmd -U "XX" -P "YYYY" -S "ZZZZ" -i “c:\temp\MyScript.sql”   You need to specifiy only the login information using: -U username -P password -S the server name -i the location of your script           Et voilà!  That's all for today! Luca Previous post: SQL Server, How to Read a list of files in a folder and compare its name with the value stored into a column...