declaring a scalar variable @@SA_CONSOLE_HOSTNAME
<p>//The query which I gave in looks like</p>

<p>//insert into tablename(host, instance) values(@SA_CONSOLE_HOSTNAME, value), in the tablename I have created columns host and instance where host would be my local machine name. I dont want to enter the machine name every time the code is run in a different system
so created a variable and assigned machine name to it, </p>

<p>//I have created a stub and passed the machinename to it</p>

<pre><code>String scriptAndStub;

scriptAndStub =
    "DECLARE @SA_CONSOLE_HOSTNAME VARCHAR(256)\n" + \\ creating a variable 
    "SET @SA_CONSOLE_HOSTNAME = @HOSTNAME@\n";
scriptAndStub += script;

executeScript.CommandText = scriptAndStub;
executeScript.Parameters.AddWithValue("@HOSTNAME@", Environment.MachineName); \\passing machine name 
</code></pre>

<p>//when I click the check syntax button on the text box its generating the error   </p>

<pre><code>private void btnSyntaxCheck_Click(object sender, EventArgs e)
        {
            try
            {
                tsStatus.Text = "Checking Syntax...";
                LogMessage(DA_Base.Constants.ERROR_LEVEL_DEBUG, "SQLScripting::SyntaxCheck", "Query: " + rtbScript.Text);
                using (SqlCommand myCommand = new SqlCommand(string.Empty, Connection))
                {
                   foreach (string script in Regex.Split(rtbScript.Text, "^GO\r?$", RegexOptions.Multiline | RegexOptions.IgnoreCase))
                      {
                           if (!String.IsNullOrEmpty(script))
                           {
                             myCommand.CommandText = "SET PARSEONLY ON\n" + script;
                             myCommand.ExecuteNonQuery();
                            }
                       }
                 }
                 tsStatus.Text = "Checking Syntax Complete. No errors reported.";
             }
             catch (Exception exc)  \\error has been caught here....
             {
                tsStatus.Text = exc.Message;
                MessageBox.Show(exc.Message, "SQL Syntax Check");
             }
         }
   }
} 
</code></pre>
