Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
SilentCodingOne
Starting Member
20 Posts |
Posted - 2008-12-21 : 23:31:16
|
I'm working on a homework problem where I need to create a script file that will be run from SQLCMD. The script needs to query the Northwind database and based on the company passed to it from the SQLCMD line produce an output file containing a list of the employees who have sold to that company. Whenever I run it I get the following error message:Msg 126, Level 15, State 1, Server BILL-PC, Line 5Invalid pseudocolumn "$companyName".Here is the SQLCMD like:sqlcmd -i C:\query4.sql -v companyName=Island Trading -o C:\output.txtHere is the code in my script file:USE NorthwindSELECT DISTINCT FirstName, LastName FROM dbo.EmployeesINNER JOIN dbo.Orders ON Employees.EmployeeID = Orders.EmployeeIDWHERE Orders.CustomerID = (SELECT CustomerID FROM Customers WHERE CompanyName = ($companyName))Any help would be appreciatedThanks |
|
SilentCodingOne
Starting Member
20 Posts |
Posted - 2008-12-22 : 23:09:56
|
For anyone else who may run into a similar issue the problem was wth how I worded Island Trading in the sqlcmd. The following is the correct syntax:sqlcmd -i C:\query4.sql -v companyName = "'Island Trading'" -o C:\output.txt |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|