|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
MSSQL Query contains single quotes
Hi all,
Now I need a little bit of patience here before I get told to post in the PHP forum I have already posted a similar query but thought I'd cover my bases (from a MSSQL point of view) by posting a question here:I am sending (via PHP MSSQL_QUERY) the following string: Use emeagolf declare @fix varchar(255) declare @f TABLE (f CHAR(4)) INSERT @f (f) Select CAST(Fixture_ID AS CHAR(4)) From Results Where COmpetitionType_ID = 1 Group By Fixture_ID SELECT @fix = COALESCE(@fix + ',[', '[') + f + ']' FROM @f Exec('SELECT * FROM (SELECT TOP 100 PERCENT SUM(r.Score) as Skore, pp.Name, Fixture_ID FROM dbo.Results AS r INNER JOIN dbo.Player AS pp ON pp.Player_ID = r.Player_ID WHERE (r.CompetitionType_ID = 1) GROUP BY r.Player_ID, pp.Name, Fixture_ID ORDER BY Skore DESC) AS TT PIVOT ( SUM(Skore) FOR [Fixture_ID] IN ('+@fix+') ) As p') I need to know, because I don't , whether SQL Server accepting a string (identical above) would have any issues with the ' ? I have already run this query in SQL Server and I know it works...but...when posted from PHP and going to SQL Server I'm wondering whether there is any SQL Server config settings that escape, remove, don't allow single quotations marks.The error seems to be at the first quotation mark in the COALESCE function - but what I would like to know is if SQL Server treats incoming sql queries differently (either a port setting, an internal option, etc) to when using studio manager application? I usually find SQL Server forgiving when sending queries to it, but not this time ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > MSSQL Query contains single quotes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|