HiI'm a student and i'm trying to write a SP in MS SQL. I'm not very familiar with MS SQL but I worked with MySQL before.I have written a SP that creates a table (if it doesn't exist) and add 2 values in this table.SP code:CREATE PROCEDURE addHashValue( @hash1 varchar (16),@hash2 varchar (16), @string varchar (30)) ASbeginDeclare @SQL varchar(1000)-- check if table existsIF NOT EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].['+@hash1+']')AND OBJECTPROPERTY(id, N'IsUserTable') = 1)Begin-- create new tableSelect @SQL ='Create table '+@hash1+'( hashValue varchar(16) NOT NULL, solution varchar(30) NOT NULL)'exec(@sql)end-- add valuesselect @SQL = 'insert into '+@hash1+'(hashValue,solution) values('+@hash2+','+@string+')'exec(@SQL)end
test code:DECLARE @return_value intEXEC @return_value = [dbo].[addHashValue] @hash1 = N'e10adc3949ba59ab', @hash2 = N'be56e057f20f883e', @string = N'123456'SELECT 'Return Value' = @return_valueGO
When i try to run this I get the following error:Msg 207, Level 16, State 1, Line 1Invalid column name 'be56e057f20f883e'I've been looking for some definitions about this error, but found nothing that resolved the problem.I also tried to replace the insert with the actual insert (so without using parameters ) and the error remains the same.I hope someone can helpGrtz Oxillery