title: Inserting images from file path -- Not getting value on the select statement
body: <pre><code>DECLARE @imgString varchar(800)
  DECLARE @insertString varchar(3000)
  DECLARE @imgNumber int
  Declare @imgName varchar(100)
  
  SET @imgNumber = 1
  
  WHILE @imgNumber&lt;&gt; 101
  
  BEGIN
  
  SET @imgName = 'SELECT (items) FROM dbo.building_piclink'
  
  SET @imgString = 'C:\Documents and Settings\Administrator\Desktop\photos\' + @imgName
  
  SET @insertString = 'INSERT INTO dbo.building__ATTACH (DATA)
  SELECT * FROM OPENROWSET(BULK N''' + @imgString + ''', SINGLE_BLOB) as tempImg'
  
  SET @imgNumber = @imgNumber + 1
  
  END
  
  GO
  </code></pre>
  
  <p>I am having problems with the <code>@imgName</code>. I can't figure out how to get the value from the select statement not the (items) like below:</p>
  
  <pre><code>C:\Documents and Settings\Administrator\Desktop\photos\SELECT (items) FROM dbo.building_piclink
  </code></pre>
  
  <p>Thank you!</p>