Simple SQL format question
-
I am having problems with the following SQL command: SELECT * FROM Classes ---Works like a charm SELECT * FROM Classes WHERE Class_Number = 2222 ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting the nvarchar value '11-1111' to data type int. ---I can understand that. Without quotes, sql thinks the Class_Number column is of type int (its actually nvarchar). So let me add quotes... _______________________________ SELECT * FROM Classes WHERE Class_Number = "2222" ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Invalid column name '2222'. Now that error has me stumped!!! What am I missing here?:mad:
-
I am having problems with the following SQL command: SELECT * FROM Classes ---Works like a charm SELECT * FROM Classes WHERE Class_Number = 2222 ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting the nvarchar value '11-1111' to data type int. ---I can understand that. Without quotes, sql thinks the Class_Number column is of type int (its actually nvarchar). So let me add quotes... _______________________________ SELECT * FROM Classes WHERE Class_Number = "2222" ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Invalid column name '2222'. Now that error has me stumped!!! What am I missing here?:mad:
Use single quote '2222' david
-
Use single quote '2222' david