Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using IN clause with data parameters in a stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-15 : 08:28:51
Bill writes "I am using sql for paging instead ADO. This way I don't have to move the volume back and forth. The HTML page has a multilpe select box value that I have converted into an array for the IN clause to search for the results. This is how I'm approaching this:

Declare @sSQL varchar(1500)

set @sSQL ='SELECT HistoryID, EquipID, Engineer, Region, Contact, DatePurchased, StateCode, '+
'Location, Status, Condition, PurchasePrice '+
'FROM tblEquipment WHERE EquipmentType IN (' + @sEquip + ')'
set @sSQL = @sSQL + 'AND (DateModified >= CAST(' + @dtmStart + ' AS smalldatetime))'
set @sSQL = @sSQL + 'AND DateModified <= ' + CAST(@dtmEnd AS smalldatetime)
set @sSQL = @sSQL + 'ORDER BY DateModified, Region, Engineer'


-- Insert the rows from tblItems into the temp. table
INSERT INTO #TempItems (HistoryID, EquipID, Engineer, Region, Contact, DatePurchased, StateCode,
Location, Status, Condition, PurchasePrice)

-- @sEquip = 'pump','motor'

EXEC(@sSQL)

I get the following error:
"Syntax error converting character string to smalldatetime data type."

OS : Windows2000Server sp2, SQL Server 2000

I hope this is a nice hard question for you. Thanks for considering it."
   

- Advertisement -