-
Why do I get error here?
Hi all,
My stored proc is shown bellow, and I get an error saying "Implicit conversion of varchar to int is not allowed. Use CONVERT function." But I don't want to convert @sID into int. What should I do?
Please help.
Thanks, Sheila
-------------------------------------------------------------------
CREATE PROCEDURE spGetAllFromByID
(@Table varchar(50)
,@sID varchar(50)
,@ID int
)
AS
declare @cmd varchar(255)
select @cmd = ("Select * from " + @table + " where " + @sID + " = " + @ID)
exec (@cmd)
GO
-
Why do I get error here? (reply)
CREATE PROCEDURE spGetAllFromByID
(@Table varchar(50)
,@sID varchar(50)
,@ID int
)
AS
declare @cmd varchar(255)
select @cmd = ("Select * from " + @table + " where " + @sID + " = " + CONVERT(int, @ID))
exec (@cmd)
GO
------------
Sheila at 9/1/00 12:05:53 PM
Hi all,
My stored proc is shown bellow, and I get an error saying "Implicit conversion of varchar to int is not allowed. Use CONVERT function." But I don't want to convert @sID into int. What should I do?
Please help.
Thanks, Sheila
-------------------------------------------------------------------
CREATE PROCEDURE spGetAllFromByID
(@Table varchar(50)
,@sID varchar(50)
,@ID int
)
AS
declare @cmd varchar(255)
select @cmd = ("Select * from " + @table + " where " + @sID + " = " + @ID)
exec (@cmd)
GO
-
Why do I get error here? (reply)
My bad, I messed up the last one. This one is correct. Also @SID must be the name of the column that your are selecting the @ID from or this will fail.
CREATE PROCEDURE spGetAllFromByID
(@Table varchar(50)
,@sID varchar(50)
,@ID int
)
AS
declare @cmd varchar(255)
select @cmd = ("Select * from " + @table + " where " + @sID + " = " + CONVERT(varchar(5), @ID))
exec (@cmd)
GO
------------
Sheila at 9/1/00 12:05:53 PM
Hi all,
My stored proc is shown bellow, and I get an error saying "Implicit conversion of varchar to int is not allowed. Use CONVERT function." But I don't want to convert @sID into int. What should I do?
Please help.
Thanks, Sheila
-------------------------------------------------------------------
CREATE PROCEDURE spGetAllFromByID
(@Table varchar(50)
,@sID varchar(50)
,@ID int
)
AS
declare @cmd varchar(255)
select @cmd = ("Select * from " + @table + " where " + @sID + " = " + @ID)
exec (@cmd)
GO
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|