|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SELECT, IN statement
Can someone tell me how to use a variable with the IN statement?
This works: declare @emp [varchar](20), @per [varchar](6), @seq [varchar](30) set @emp='025390' set @per='200401' set @seq='84' Select Employee, RegHrs, OvtHrs, RegPay, OvtPay into #tmppd from EMPayrollDetail where Employee = @emp AND Period = @per AND PostSeq = @seq When I try and use the IN statement I get a syntax error: declare @emp [varchar](20), @per [varchar](6), @seq [varchar](30) set @emp='025390' set @per='200401' set @seq='84,92,98,99' Select Employee, RegHrs, OvtHrs, RegPay, OvtPay into #tmppd from EMPayrollDetail where Employee = @emp AND Period = @per AND PostSeq IN @seq I've tried to make @seq ('84','92','98','99') but it doesn't like that either. Can I use a variable with the IN statement? Help ![]() |
|
#2
|
||||
|
||||
|
You need to put parenthesis around the variable. Ex:
PostSeq IN ( @seq ) |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > SELECT, IN statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|