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.
| Author |
Topic |
|
shaoen01
Yak Posting Veteran
78 Posts |
Posted - 2006-01-17 : 01:02:13
|
| Currently, my this delete method gives me an error msg: Syntax error converting the varchar value 'DELETE FROM BRANPROM WHERE PROMOTIONID IN (21) AND BRANCHID=' to a column of data type int. If anyone can provide me another alternative to delete multiple rows not using dynamic sql, i am at all ears. However, cant seem to find any method for deleting without using the EXEC.I have posted a topic before:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=60179ThanksCREATE PROCEDURE [DELETEBRANCHPROM](@PROMOTIONIDS VARCHAR (500),@BRANCHID INT)AsDECLARE @SQL VARCHAR(500)SET @SQL = 'DELETE FROM BRANPROM WHERE PROMOTIONID IN (' + @PROMOTIONIDS + ') AND BRANCHID=' + @BRANCHIDEXEC(@SQL)GO |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-17 : 01:36:32
|
you need to convert the @BRANCHID from INT to VARCHAR before concat.SET @SQL = 'DELETE FROM BRANPROM WHERE PROMOTIONID IN (' +@PROMOTIONIDS + ') AND BRANCHID=' + convert(varchar(10), @BRANCHID)-----------------'KH' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
shaoen01
Yak Posting Veteran
78 Posts |
Posted - 2006-01-18 : 09:12:59
|
This was explained another member, thats why i think its better to not use dynamic sql.There are two downsides to this (compared to the other approach that has been suggested), but that doens'tmean its wrong - just thought you might like to know!1) The user has to have SELECT access to the MSTRITEM and ITEMIMAG tables. Without the dynamic SQLthey would only need EXECUTE permission on the SProc itself - which is obviously a lot tighter - with SELECTpermission they can just hook up, say, Excel to the DB and start pulling data at will ... and successful hackerscan do too!quote: Originally posted by madhivanan It seems you didnt follow fully on the above topicWhat is the difficulty in using the methods suggested here?http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=60179MadhivananFailing to plan is Planning to fail
|
 |
|
|
|
|
|