DECLARE @message VARCHAR(10)
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'{0}')
BEGIN
SET @message = '{1}'
END
ELSE
BEGIN
SET @message = 'NOT_OK'
END
PRINT(@message)
I execute above command from c# app.
How can I get print message? Im trying like this:
if(connection.State.ToString() == "Closed")
{
connection.Open();
}
SqlCommand newCmd = connection.CreateCommand();
newCmd.Connection = connection;
newCmd.CommandType = CommandType.Text;
newCmd.CommandText = string.Format(queriesMgr.getQuery(SqlQueriesID.IS_TABLE_EXISTS), "student", "OK");
SqlDataReader reader = newCmd.ExecuteReader();
if (reader.Read())
{
//not enter here(no data to read)
}
Anyone could tell me what Im doing wrong?