April 4, 2013 at 10:50 pm
The Following procedure gives error 8114 at line 10 : if instead of @sec_id i simply write 1 as sec id it works else it gives error unable to convert data type varchar to bigint . Please Help .
CREATE PROCEDURE [dbo].[Get_Ques_id_for_can]
(@candidate_id varchar(max),@Exam_id varchar(max),@sec_id bigint)
AS
BEGIN
declare @table_query varchar(max)
declare @table varchar(max)
set @table=@candidate_ID+@Exam_id
set @table_query='SELECT [ID], [Question_ID] FROM ['+@table+'] WHERE [Section_ID]='+@sec_id
EXEC(@table_query)
END
April 4, 2013 at 11:58 pm
Try
set @table_query='SELECT [ID], [Question_ID] FROM ['+@table+'] WHERE [Section_ID]='+convert(@sec_id as varchar(50))
April 5, 2013 at 12:04 am
In database [Section_ID] has datatype bigint
April 5, 2013 at 12:15 am
You are using dynamic string so the type of the variable does not matter.
Moreover you are getting this error when trying to concatenate the integer variable with varchar string 'Select ....'
April 5, 2013 at 12:19 am
It worked . Thanks a lot!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy