Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL syntax help Expand / Collapse
Author
Message
Posted Wednesday, December 6, 2006 6:37 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Saturday, May 31, 2014 1:21 PM
Points: 46, Visits: 193

I'm trying to get the following sql statement to run, but have issues with the quotations or??

Here is the statement:

SET @DestDB = 'FS84ZAP'                                                                       

exec ('use ' + @DestDB + ';UPDATE PS_PV_SRCH_RUN_CTL SET FILE_DIRECTORY = ''\\serverxxx\psoft\verity\''' + @DestDB + '''')

When I check syntax its ok.  When I click run, here is the error messge:

Error:

Server: Msg 170, Level 15, State 1, Line 1

Line 1: Incorrect syntax near 'FS84ZAP'.

Server: Msg 105, Level 15, State 1, Line 1

Unclosed quotation mark before the character string ''.

I've used single quotations above.  The statementwill run fine below minus the db variable:

exec ('use ' + @DestDB + ';UPDATE PS_PV_SRCH_RUN_CTL SET FILE_DIRECTORY = ''\\serverxxx\psoft\verity\'''

 

Appreciate help

 

Post #328617
Posted Wednesday, December 6, 2006 9:29 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Sunday, July 20, 2014 5:23 PM
Points: 4,576, Visits: 8,341

Replace

exec ('use ' + @DestDB + ';UPDATE PS_PV_SRCH_RUN_CTL SET FILE_DIRECTORY = ''\\serverxxx\psoft\verity\''' + @DestDB + '''')

with

print 'use ' + @DestDB + ';UPDATE PS_PV_SRCH_RUN_CTL SET FILE_DIRECTORY = ''\\serverxxx\psoft\verity\''' + @DestDB + ''''

and you'll see what's wrong with the syntax of your query.

Post #328634
Posted Thursday, December 7, 2006 2:39 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Saturday, May 31, 2014 1:21 PM
Points: 46, Visits: 193
Thnxs for you suggestion.  All is well.
Post #328926
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse