I am using razor with C# and I need to declare a variable in SQL but it will not work.
insert_data = db.Query("DECLARE @myid INT");
I get the following error
There was an error parsing the query. [ Token line number = 1,Token line offset = 1,Token in error = DECLARE ]
EDIT:
I am trying to put data into one table, then get its unique ID and insert it into another.
insert_data = db.Query("INSERT INTO sorted (sorted_words) SELECT '" + sorted_word + "' WHERE NOT EXISTS (SELECT sorted_words FROM sorted WHERE sorted_words = '" + sorted_word + "')");
insert_data = db.Query("DECLARE @myid BIGINT");
insert_data = db.Query("SET @myid = scope_identity()");
insert_data = db.Query("INSERT INTO words (words, sorted_id) SELECT '" + word + "', @myid WHERE NOT EXISTS (SELECT words FROM words WHERE words = '" + word + "')");