DECLARE @xmlFileName VARCHAR(300)
SELECT @xmlFileName = 'D:\Desc\desc2012.xml.part2.xml'
EXEC('
INSERT INTO XmlImportTest(xmlFileName, xml_data)
SELECT ''' + @xmlFileName + ''', xmlData
FROM
(
SELECT *
FROM OPENROWSET (BULK ''' + @xmlFileName + ''' , SINGLE_BLOB) AS XMLDATA
) AS FileImport (XMLDATA)
')
GO
If DTD Error occurred use following code
DECLARE @xmlFileName VARCHAR(300)
SELECT @xmlFileName = 'D:\Desc\desc2012.xml.part2.xml'
EXEC('
INSERT INTO XmlImportTest(xmlFileName, xml_data)
SELECT ''' + @xmlFileName + ''', xmlData
FROM
(
SELECT CONVERT(xml, BulkColumn, 2)
FROM OPENROWSET (BULK ''' + @xmlFileName + ''' , SINGLE_BLOB) AS XMLDATA
) AS FileImport (XMLDATA)
')
GO
Thursday, March 29, 2012
SQL Server 2012 Tutorials and Sample Databases
Microsoft SQL Server 2012 has released RTM recently. No doubt that you're interested to learn new features of the new version. If so then it is useful to have the tutorials and sample databases installed on your server. You can get them using below links;
Tutorials here
Sample Databases here
Note that sample databases are just data files (No log file). You need to attach it to your server to create the databases. Use the following T-SQL script.
CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'D:\SQL Server\DATA\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG
Enjoy with the new version of SQL Server.
Tutorials here
Sample Databases here
Note that sample databases are just data files (No log file). You need to attach it to your server to create the databases. Use the following T-SQL script.
CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'D:\SQL Server\DATA\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG
Enjoy with the new version of SQL Server.