[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

escaping in MSSQL script?

Chris McMahon

1/11/2006 10:09:00 PM



Hi...
Can anyone suggest the proper way to escape the backslashes in the
directory name in the following script?


d = c.run("ALTER DATABASE fooDB MODIFY FILE (NAME = foo_log, FILENAME =
'C:\\Program Files\Microsoft SQL
Server\MSSQL\fooPlus\fooPlus_log.LDF'")

The obvious solutions yield either "Incorrect syntax..." or "Invalid
escape character syntax" messages.

Thanks...
-CHris

7 Answers

David Vallner

1/11/2006 10:31:00 PM

0

Chris McMahon wrote:

>Hi...
>Can anyone suggest the proper way to escape the backslashes in the
>directory name in the following script?
>
>
>d = c.run("ALTER DATABASE fooDB MODIFY FILE (NAME = foo_log, FILENAME =
>'C:\\Program Files\Microsoft SQL
>Server\MSSQL\fooPlus\fooPlus_log.LDF'")
>
>The obvious solutions yield either "Incorrect syntax..." or "Invalid
>escape character syntax" messages.
>
>Thanks...
>-CHris
>
>
>
>
Four backslashes should work. Wildly guessing only.


Chris McMahon

1/11/2006 10:43:00 PM

0

Good guess, but

'C:\\\\Program Files\\Microsoft
SQLServer\MSSQL\\fooPlus\\fooPlus_log.LDF'

yields

Incorrect syntax near 'C:\\Program Files\Microsoft SQL
Server\MSSQL\data\fooPlus\fooPlus_log.LDF'

jeem.hughes

1/11/2006 10:53:00 PM

0

Shouldn't you have c:\\what\\ever or c:\what\ever? It's not a URL :)

David Vallner

1/11/2006 11:35:00 PM

0

Chris McMahon wrote:

>Good guess, but
>
>'C:\\\\Program Files\\Microsoft
>SQLServer\MSSQL\\fooPlus\\fooPlus_log.LDF'
>
>yields
>
>Incorrect syntax near 'C:\\Program Files\Microsoft SQL
>Server\MSSQL\data\fooPlus\fooPlus_log.LDF'
>
>
>
>
I meant four backslashes -everywhere-. Gets escaped to two backslashes
by Ruby, then to one backslash by MS SQL.

David Vallner


Joby Bednar

1/12/2006 12:16:00 AM

0

d = c.run("...'c:\\\\blah..'..")

rather than using double quotes which processes escapes within, use
single quotes and use \' when you need single quotes within?

d = c.run('...\'c:\\blah..\'..')

-Joby

lists

1/12/2006 12:26:00 AM

0

Joby Bednar wrote:
> d = c.run("...'c:\\\\blah..'..")
>
> rather than using double quotes which processes escapes within, use
> single quotes and use \' when you need single quotes within?
>
> d = c.run('...\'c:\\blah..\'..')
> -Joby

you still need to escape backslashes even when using single-quoted string
literals. (maybe you're referring to php?)

--moogs





David Vallner

1/12/2006 2:07:00 AM

0

moogs wrote:

>
> you still need to escape backslashes even when using single-quoted
> string literals. (maybe you're referring to php?)
>
> --moogs
>
Doesn't Ruby have a general delimiter wart for raw strings? I know
Python has, can't recall about Ruby.

David Vallner