TommyMac501
asked on
What is wrong with this SQL statement?, C# is giving me errors..
I'm new to C#, but this SQL statement is giving me errors; "SQLException Unhandled, Incorrect syntax near "*""
Here is the code:
SqlCommand command = conn.CreateCommand();
command.CommandText = "DELETE * FROM MASTER";
command.CommandType = CommandType.Text;
SqlDataReader reader = command.ExecuteReader();
Since when can't I use an "*" in a SQL statement? If I change the statement to a simple "DELETE FROM MASTER" it works fine. - confused..
Here is the code:
SqlCommand command = conn.CreateCommand();
command.CommandText = "DELETE * FROM MASTER";
command.CommandType = CommandType.Text;
SqlDataReader reader = command.ExecuteReader();
Since when can't I use an "*" in a SQL statement? If I change the statement to a simple "DELETE FROM MASTER" it works fine. - confused..
what is the database? not all database systems allow the * in the DELETE statement.
ASKER
SQL Server.
for the reference:
http://msdn.microsoft.com/en-us/library/ms189835.aspx
sql server does not allow the *
while ms access does:
http://msdn.microsoft.com/en-us/library/bb177896.aspx
http://msdn.microsoft.com/en-us/library/ms189835.aspx
sql server does not allow the *
while ms access does:
http://msdn.microsoft.com/en-us/library/bb177896.aspx
ASKER
Is that rule only for the SQLDataReader?. I use the "*" in my queries all the time, including directly through the Query Analyzer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oops. duhhh.. Since I usually use the DELETE in conjunction with WHERE, I overlooked it. I was thinking "TRUNCATE TABLE".. My Bad...