Solved

Mask password in sqlcmd command

Posted on 2010-09-10
3
1,576 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now