Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: Purge Utility Date: Wed, 13 Feb 2013 22:25:31 +0100 Organization: Erland Sommarskog Lines: 21 Message-ID: References: <695679d9-3eb9-44c8-a7fb-2e60ef2b8373@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx05.eternal-september.org; posting-host="e87282ec96c371b8272e2d14c79930f2"; logging-data="22265"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2q5QYU8sFhJl7BTw9rorM" User-Agent: Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) Cancel-Lock: sha1:b0a9NM4N1/wD2JewNy6SN9bjeQk= Xref: csiph.com comp.databases.ms-sqlserver:1386 JAW (jwilliam@aglresources.com) writes: > When I run code with the apostrophes like the above I get an error > saying that a syntax error exists. When I supplemented the code you posted with variable declarations and a CATCH block, the code executed successfully. Is your dynamically generated SQL producing an error? Did you look at the actual code? You seem to have a PRINT there? -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx