p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: Using IN keyword in SQL to update records


Message #1 by dont worry <aspmailbox@y...> on Tue, 5 Mar 2002 13:16:47 -0800 (PST)
Thanks David,
I decided on the loop so I can truncate a string and
print out results.

--- David Cameron <dcameron@i...> wrote:
> You need to generate a SQL String inside the proc if
> you want to do this.
> 
> CREATE PROCEDURE Test
> @IDS VarChar(100), @Fld1 Int
> AS
> 
> SET NOCOUNT ON
> 
> DECLARE @SQL VarChar(1000)
> 
> SET @SQL = 'UPDATE MyTable SET Field1 = ' +
> CAST(@Fld1 AS VarChar(20)) + '
> WHERE
>     MyID IN (' + @IDS + ')'
> 
> 
> regards
> David Cameron
> nOw.b2b
> dcameron@i...
> 
> -----Original Message-----
> From: dont worry [mailto:aspmailbox@y...]
> Sent: Wednesday, 6 March 2002 8:17 AM
> To: Code Clinic
> Subject: [proasp_codeclinic] Using IN keyword in SQL
> to update records
> 
> 
> I've always used a loop when I needed to update many
> records.  In SQL Query Analyzer it seems that I
> could
> us the 'IN' key word to update multiple records at
> one
> time which would elimate the loop.  
> 
> Would this cause any unforseen problems?
> 
> 
> I'm going to try it in a store proc.  I wonder if I
> can call my stored proc with something like 
> updatedVals="5,6,8" as the int values to pass for
> the
> newly created update or will it bomb?
> 
> Thanks for any help
> 
> __________________________________________________
> Do You Yahoo!?
> Try FREE Yahoo! Mail - the world's greatest free
> email!
> http://mail.yahoo.com/
> 
> $subst('Email.Unsub').
> 
> 
> $subst('Email.Unsub').
> 


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

  Return to Index