标签归档:sql server 2005

cmd中命令修改sql server 2005的sa密码

最近在修改一部分服务器的数据库密码,遇到一台服务器的sql server竟然没安装management studio,因为平时都是有管理系统,不用直接在服务器操作sql,因此也没发现。密码还是得改,既然没有图形工具,就想个其他方法吧。

系统自带一个sqlcmd实用工具,开始–运行–sqlcmd.exe即可打开。修改sa密码的命令就是:

1> alter login sa with password = N’newpassword’
2> go

将newpassword改成你需要设置的密码即可。后来仔细查了下sqlcmd,发现功能还是很多的,可以使用很多的参数:

Sqlcmd
  [-U login id] [-P password] [-S server] [-H hostname] 
  [-E trusted connection] [-d use database name] [-l login timeout]
  [-t query timeout] [-h headers] [-s colseparator] [-w screen width]
  [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
  [-c cmdend] [-L[c] list servers[clean output]] [-q "cmdline query"]
  [-Q "cmdline query" and exit] [-m errorlevel] [-V severitylevel]
  [-W remove trailing spaces] [-u unicode output]
  [-r[0|1] msgs to stderr] [-i inputfile] [-o outputfile]
  [-f <codepage> | i:<codepage>[,o:<codepage>]]
  [-k[1|2] remove[replace] control characters]
  [-y variable length type display width]
  [-Y fixed length type display width]
  [-p[1] print statistics[colon format]]
  [-R use client regional setting] [-b On error batch abort]
  [-v var = "value"...]
  [-X[1] disable commands[and exit with warning]]
  [-? show syntax summary]

有兴趣的小伙伴可以试下,微软官方也有教程的:sqlcmd实用工具教程