﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2012 / SQL Server 2012 -  T-SQL  / Bulk insert in procedure. Use of quotes for variables / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 13:22:46 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Bulk insert in procedure. Use of quotes for variables</title><link>http://www.sqlservercentral.com/Forums/Topic1422523-3077-1.aspx</link><description>hi,yes it helps a lot !thank you very much. I ll try this tomorrow at work</description><pubDate>Wed, 03 Apr 2013 16:58:39 GMT</pubDate><dc:creator>ohpenot</dc:creator></item><item><title>RE: Bulk insert in procedure. Use of quotes for variables</title><link>http://www.sqlservercentral.com/Forums/Topic1422523-3077-1.aspx</link><description>It all has to do about strings ...  And what is truely a string?First example does not have quotes in the string.-- Simple stringDECLARE @X VARCHAR(128);SET @X = 'A SIMPLE STRING';PRINT @X;Second example uses extra quote to denote usage as a literal, not a start of a string.  -- Escaping the quotesDECLARE @Y VARCHAR(128);SET @Y = 'A STRING WITH ''' + CONVERT(CHAR(10), GETDATE(), 101) + ''' QUOTES AROUND THE DATE';PRINT @Y;Third example uses the ANSI character for quote.-- Using CHAR()DECLARE @Z VARCHAR(128);SET @Z = 'A STRING WITH ' + CHAR(39) + CONVERT(CHAR(10), GETDATE(), 101) + CHAR(39) + ' QUOTES AROUND THE DATE';PRINT @Z;You can use the system function QUOTENAME() to make quoted strings.http://msdn.microsoft.com/en-us/library/ms176114.aspxYou can even change the character used for escaping (ESCAPE) in a LIKE statement.http://msdn.microsoft.com/en-us/library/ms179859.aspxI hope this helps.SincerelyJohn</description><pubDate>Tue, 02 Apr 2013 10:22:41 GMT</pubDate><dc:creator>j.miner</dc:creator></item><item><title>RE: Bulk insert in procedure. Use of quotes for variables</title><link>http://www.sqlservercentral.com/Forums/Topic1422523-3077-1.aspx</link><description>I t works using ''''SET @effacer = 'master.dbo.xp_cmdshell ''DEL '+ @chemin + @filename +''''but i don't understand why (tried everything)</description><pubDate>Thu, 21 Feb 2013 06:12:43 GMT</pubDate><dc:creator>ohpenot</dc:creator></item><item><title>Bulk insert in procedure. Use of quotes for variables</title><link>http://www.sqlservercentral.com/Forums/Topic1422523-3077-1.aspx</link><description>Hi everybody,I struggled with  a bulk insert in procedure and i eventually found a working piece of code. Except that i did'nt understand the general rules to wrap variables.Exemple :       N'BULK INSERT ' + QUOTENAME(@nomtable) + N'FROM ''' +        @chemin + @filename +       N''' WITH (FIELDTERMINATOR = '';'', ROWTERMINATOR = '''', FIRE_TRIGGERS)'This is working, but why are we using ''' ??Now something that's not working..SET @effacer = 'master.dbo.xp_cmdshell ''DEL '+ @chemin + @filenameEXECUTE (@effacer)Something wrong with quotes i guess....I'd like to understand the rule for this!</description><pubDate>Thu, 21 Feb 2013 06:09:25 GMT</pubDate><dc:creator>ohpenot</dc:creator></item></channel></rss>