| Author |
Topic |
|
paintbawler1
Starting Member
1 Post |
Posted - 2007-09-13 : 11:36:35
|
I've created a stored procedure that is supposed to execute w/ multiple char values as the parameter, but I keep getting an error that no one I've talked to can help me with. Here is the stored procedure:ALTER PROCEDURE [dbo].[FindPlayer] @PlayID VARCHAR(100)ASDECLARE @SQL VARCHAR(1000)SELECT @SQL = 'SELECT * FROM Players 'SELECT @SQL = @SQL + ' WHERE PlayerID = (' + @PlayID + ')'EXEC(@SQL)Here is the execute statement:EXEC FindPlayer "'ALESH01','ASHTH01'" And here is the error I get when I do execute:Msg 102, Level 15, State 1, Line 1Incorrect syntax near ','. Now I've got this SP to work with just passing one char value as the parameter, but when I try two char values I ALWAYS get that error. I've tried multiple different placements of the quotes and comma, but still have had no luck. Hope someone can help me out. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-13 : 11:44:36
|
EXEC FindPlayer 'ALESH01,ASHTH01' E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-13 : 11:47:36
|
[code]ALTER PROCEDURE [dbo].[FindPlayer] @PlayID VARCHAR(100)ASDECLARE @SQL VARCHAR(1000)SET @SQL = 'SELECT * FROM Players 'SET @SQL = @SQL + ' WHERE PlayerID IN (''' + REPLACE(@PlayID, ',', ''',''') + ''')'--print @sqlEXEC(@SQL)[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-13 : 13:51:55
|
Not if you see the changes I have made to the SP too... E 12°55'05.25"N 56°04'39.16" |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-13 : 14:04:20
|
The only time I could get a post in edge-ways was when he took a week's holiday |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-13 : 14:12:03
|
What to do?I am commuting 400 miles by flying to Stockholm on mondays, and fly back home 400 more miles on fridays.All weekdays I am sitting in a hotelroom. Only pleasure is watching TV and surfing the Net. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-13 : 14:15:23
|
| Get a life, then we can give up ours! |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-13 : 14:21:31
|
The bright side is that this assigment is due October 31!Then I get normal life back. And with a new DBA due on 22-23 november, there will be not much time to spend here.Next assignment is to Copenhagen for six months. Then I can drive home every night, instead of sitting here. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-13 : 14:35:39
|
| Just in time for the long Winter evenings?! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|