Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Help Needed understaing why SQL Query Gets changed

Author  Topic 

Pete_N
Posting Yak Master

181 Posts

Posted - 2011-01-20 : 23:01:43
SQL 2008

I am running a long query that imports an XML file into a table.

The query I am using is ;

SELECT @SQLINSERT =
'Insert INTO CashbacsMain.dbo.tbReports (ReportType, ClientNo, ReportDate, ReportFile)
VALUES (''' + @INPUTREPORT +''',''' + @Licence +''',''' + @strdate + ''', (SELECT * FROM OPENROWSET (BULK ''C:\SilverlightDevolopment\ProcessingXML\PROCESSINGXML.XML'', SINGLE_BLOB) AS x))'

if I do a straight Print @SQLINSERT i get the following ;

Insert INTO CashbacsMain.dbo.tbReports (ReportType, ClientNo, ReportDate, ReportFile)
VALUES ('Input Report','999999','2010-12-13', (SELECT * FROM OPENROWSET (BULK 'C:\SilverlightDevolopment\ProcessingXML\PROCESSINGXML.XML', SINGLE_BLOB) A

canb anyone suggest why the SQL statement is getting changed?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-01-20 : 23:11:33
what was changed ? Are you referring to the last few character got truncated ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Pete_N
Posting Yak Master

181 Posts

Posted - 2011-01-20 : 23:17:26
It's always the simple tings that catch us out. You are spot on .. I had not defined @SQLInsert large enough ..

Teach me to work 23 hours on the trot !
Go to Top of Page
   

- Advertisement -