Difference between revisions of "Example of executing sql script by sqlcmd"
From MyWiki
(One intermediate revision by the same user not shown) | |||
Line 15: | Line 15: | ||
</source> | </source> | ||
+ | sqlcmd -S myServer\instanceName -i C:\myScript.sql<br> | ||
+ | Or to output to a text file <br> | ||
+ | sqlcmd -S myServer\instanceName -i C:\myScript.sql -o C:\EmpAdds.txt<br> |
Latest revision as of 13:15, 15 March 2017
USE AdventureWorks2012; GO SELECT p.FirstName + ' ' + p.LastName AS 'Employee Name', a.AddressLine1, a.AddressLine2 , a.City, a.PostalCode FROM Person.Person AS p INNER JOIN HumanResources.Employee AS e ON p.BusinessEntityID = e.BusinessEntityID INNER JOIN Person.BusinessEntityAddress bea ON bea.BusinessEntityID = e.BusinessEntityID INNER JOIN Person.Address AS a ON a.AddressID = bea.AddressID; GO
sqlcmd -S myServer\instanceName -i C:\myScript.sql
Or to output to a text file
sqlcmd -S myServer\instanceName -i C:\myScript.sql -o C:\EmpAdds.txt