August 26, 2006 at 10:48 am
declare @recipe table (recipeID numeric(18,0) NOT NULL)
insert into @recipe(recipeID) values('4')
insert into @recipe(recipeID) values('5')
insert into @recipe(recipeID) values('6')
insert into @recipe(recipeID) values('7')
Declare @sql VarChar(1000)
select sql = '''2'''
DELETE from @recipe where recipeID in Exec (@SQL)
many thanks
August 26, 2006 at 11:52 am
Well, there's a number of things I'd do differently...
On the INSERT statements, you're not inserting string values so you don't need to encapsulate them in single-quotes.
When you declare @sql, why are you making it varchar data if you're just going to store a numeric value in it to compare against other numeric values?
Finally you shouldn't use the "in exec (@sql)". Perhaps if you could show a little more about what you're trying to do?
August 26, 2006 at 11:54 am
Exactly what you are trying to do ?
August 26, 2006 at 1:34 pm
Dunno if this is what you are looking for... and I haven't tested it 'cause I'm on vacation with no access to SQL...
declare @recipe table (recipeID numeric(18,0) NOT NULL)
insert into @recipe(recipeID) values(1)
insert into @recipe(recipeID) values(2)
insert into @recipe(recipeID) values(3)
insert into @recipe(recipeID) values(4)
insert into @recipe(recipeID) values(5)
insert into @recipe(recipeID) values(6)
insert into @recipe(recipeID) values(7)
Declare @ThingToDelete numeric(18,0)
select @ThingToDelete = 2
DELETE from @recipe where recipeID = @ThingToDelete
I also think that Numeric(18,0) is real overkill, here... you might want to just try INT which goes to (approx) 2 Billion.
If you are trying to delete multiple recipies based on a CSV list you're passing in, let us know 'cause that's a lot different...
--Jeff Moden
Change is inevitable... Change for the better is not.
August 27, 2006 at 1:14 am
Anyway it's good to learn some basics about syntax of the language before you try to use it.
_____________
Code for TallyGenerator
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply