Solved

Mask password in sqlcmd command

Posted on 2010-09-10
3
1,629 Views
Last Modified: 2012-05-10
How it is possible to avoid putting in light the password of one to use sql in a sqlcmd script?

Thanks

bibi
0
Comment
Question by:bibi92
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Larissa T earned 500 total points
ID: 33648330
from http://msdn.microsoft.com/en-us/library/ms162773.aspx



The SQLCMDPASSWORD environment variable lets you set a default password for the current session. Therefore, passwords do not have to be hard-coded into batch files.
0
 

Author Comment

by:bibi92
ID: 33715104
Thanks, I have tested this :

SET SQLCMDUSER=B00A
SET SQLCMDPASSWORD=toto
SET SQLCMDSERVER=SRVSERVER\TEST
SET SQLCMDDBNAME=dbname
sqlcmd  -Q "select count(*) from ATEST" -o d:\test.sql

But, I have this error:
Login failed for user 'B00A'.

Thanks
bibi
0
 

Author Closing Comment

by:bibi92
ID: 33715988
thanks bibi
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question