Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Multiple rows 2

Status
Not open for further replies.

dembyg

Programmer
Oct 20, 2001
58
US
I created a store procedure that should delete mulitple rows however it is not working.. can anyone help me.


************* Start of code
EXEC('SELECT * FROM tblqaCorrespdence WHERE iIndex IN (' + @tmpIndex + ')')


************* End of code
These are the values that need to pass - Execute spTest(1,2,4,6,7)
 
************* Start of code
EXEC('SELECT * FROM tblqaCorrespdence WHERE iIndex IN (' + @tmpIndex + ')')


************* End of code
These are the values that need to pass - Execute spTest(1,2,4,6,7)

Shouldn't the SELECT be a DELETE?

John Pasko
"No matter where you go, there you are." -- Buckaroo Bonzai
 
Dennis,

heh, I use a SB Triple Espresso IV Drip.

John Pasko
"No matter where you go, there you are." -- Buckaroo Bonzai
 
OPPs i forgot to change my select to delete thanks... However it still does not work when running the code in Query analizer i recieve an error message ---Line 1: Incorrect syntax near 'number'.
 
After running the following code in Query Analizer
PRINT('Delete * FROM tblqaCorrespdence WHERE iIndex IN (' + 74 + ')')

I recieve the following error..

Syntax error converting the varchar value 'Delete * FROM tblqaCorrespdence WHERE iIndex IN (' to a column of data type int.

 
Thanks the code you wrote works however i need to delete multiple rows example ---
print('SELECT * FROM tblqaCorrespdence WHERE iIndex IN (' + convert(varchar,11,12,13) + ')')
addition tmpindex data type equals int instead of varchar...
Thank you for your assistance
 
This is what you want
declare @tmpIndex varchar(50)
select @tmpIndex = '12,13,14'
print(DELETE tblqaCorrespdence WHERE iIndex IN (' + @tmpIndex + ')')

I don't know how tmpIndex can be an int in our case since it has multiple values

Denis The SQL Menace
SQL blog:
Personal Blog:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top