Skip to main content
Tweeted twitter.com/#!/StackDBAs/status/67098634004611072
title
Link
gbn
  • 70.1k
  • 8
  • 165
  • 242

stored procedures and Stored procedure parameters using tsql functions in paramaters calls?

edited tags
Link
Leigh Riffel
  • 23.9k
  • 17
  • 79
  • 155
Source Link
george9170
  • 301
  • 1
  • 5
  • 12

stored procedures and using tsql functions in paramaters calls

Environment sql server 2005 sp3

I have a stored proc that takes an INT as input. I want to CAST a CHAR to an INT during the call to the stored proc. it seems I cannot do that. I get a syntax error before @foo. I do not see it can someone help me find it please. Thank you very much.

CREATE PROCEDURE testme
@test AS INT
AS
BEGIN
SELECT @TEST
END

    DECLARE @foo AS CHAR(6)
set @foo = '11test'
EXEC testMe @test = CAST(Substring(@foo,1,2) as int)