﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 7,2000 / T-SQL  / Executing scripts from C# using sqlcmd.exe / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 10:25:06 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Executing scripts from C# using sqlcmd.exe</title><link>http://www.sqlservercentral.com/Forums/Topic572280-8-1.aspx</link><description>[quote][b]sumit kende (9/19/2008)[/b][hr]How to use sqlcmd utility with blank password. sa user having blank password. Following code gives error :=&amp;gt; Sqlcmd: '-P': Missing argument. Enter '-?' for help. I tried with console application in .net 2008static void Main(string[] args)        { string fileName = @"C:\Createtable.sql";            ProcessStartInfo info = new ProcessStartInfo("sqlcmd", @" -S DEV023\SQL2K -U sa -d pubs -o C:\sqlout.txt -i  """ + @fileName + @""" -P");            info.UseShellExecute = false;            info.CreateNoWindow = true;            info.WindowStyle = ProcessWindowStyle.Hidden;            info.RedirectStandardOutput = true;            Process p = new Process();            p.StartInfo = info;            p.Start();}[/quote]Only way to do it is with a "trusted connection".  I don't have the precise syntax, but I'll just bet it's in Books Online.</description><pubDate>Fri, 19 Sep 2008 20:58:54 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>Executing scripts from C# using sqlcmd.exe</title><link>http://www.sqlservercentral.com/Forums/Topic572280-8-1.aspx</link><description>How to use sqlcmd utility with blank password. sa user having blank password. Following code gives error :=&amp;gt; Sqlcmd: '-P': Missing argument. Enter '-?' for help. I tried with console application in .net 2008static void Main(string[] args)        { string fileName = @"C:\Createtable.sql";            ProcessStartInfo info = new ProcessStartInfo("sqlcmd", @" -S DEV023\SQL2K -U sa -d pubs -o C:\sqlout.txt -i  """ + @fileName + @""" -P");            info.UseShellExecute = false;            info.CreateNoWindow = true;            info.WindowStyle = ProcessWindowStyle.Hidden;            info.RedirectStandardOutput = true;            Process p = new Process();            p.StartInfo = info;            p.Start();}</description><pubDate>Fri, 19 Sep 2008 00:10:54 GMT</pubDate><dc:creator>sumit kende</dc:creator></item></channel></rss>