Skip to Content
0
Former Member
Mar 06, 2006 at 10:23 AM

How to store user value into variable

9 Views

Hi all,

I'm struggling with SQL queries and variables.

Is there a way to get value from user and store it to variable? I need to do some checking/validation to the user values before passing them to main query.

For example:

 DECLARE @myvar AS int
 SET @myvar = [%0]        

 IF (@myvar < 100)
 BEGIN
   SET @myvar = 100
 END

 SELECT * FROM OCRD T0 WHERE T0.CardCode>@myvar

SQL Server errors:

1). [Microsoft][ODBC SQL Server Driver][SQL Server]Must specify table to select from. 
2). [Microsoft][ODBC SQL Server Driver][SQL Server]Statement 'Search Function' (s) could not be prepared.

Kind regards,

Jani