I have to create a stored Procedure in a Database (SQL Server)
string query = "CREATE PROCEDURE queryName AS BEGIN " + sqlCommand + " END";
SqlConnection cnn;
SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder();
//builder["Provider"] = provider;
builder["Server"] = @"Themis\DEV";
builder["Integrated Security"] = "SSPI";
string connection_string = builder.ConnectionString;
cnn = new SqlConnection(connection_string);
cnn.Open();
SqlCommand sqlCmd = new SqlCommand(queryName, cnn);
sqlCmd.CommandText = query;
sqlCmd.Connection = cnn;
sqlCmd.CommandType = CommandType.Text;
sqlCmd.ExecuteNonQuery();
But I get an Errormessage
Incorrect syntax near INNER
The Procedure is like this
UPDATE description
INNER JOIN description1
ON description.resid_ = description1.resid_
SET description.polish = [description1].[polish]
WHERE (description1.polish <> '')
AND (description1.polish <> ( '-' ));
That is not a valid Update
using Join
syntax in SQL SERVER
. Try this way
UPDATE D
SET D.polish = [D1].[polish]
FROM description D
INNER JOIN description1 D1
ON D.resid_ = D1.resid_
WHERE D1.polish <> ''
AND D1.polish <> '-';
Where clause can be simplified using NOT IN
Where D1.polish NOT IN ('','-')
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments