SSIS , SQL server and Vistual Studio Compability
Hi
I have dtsx package file which is downloaded from sql server forum. I want to inspect the content of dtsx package. I am new to Sql Server Integration Service. Please can someone guide me how to inspect the content of dtsx package
we are using "SQL Server 2012" .I have installed visual studio 2010 and Visual studio 2013.
When I open package in "Visual Studio 2010" it gives me error "Microsoft Visual Studio is unable load this document: To design integration service packages in sql server data tools (SSDT), SSDT has to be installed by one of these
editions of SQL Server 2012: Standard, Enterprise, Develper or Evaluation............".
When I tried to open this package in VS 2013 , I don't see the project template for "Integration Services Project".
thanks for help
Drew
thanks I can open dtsx package in VS2013. If I recompile this package can I deploy in SQL Server 2012?
Drew
Yes. If it was created in an earlier version it will get upgraded. And provided you use default deployment model (project deployment) in SQL 2012 you can just do right click and deploy to deploy the project.
You should have setup Integration Services Catalog prior to this as you deployed projects end up in IS catalog.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Similar Messages
-
hi, I would like to know if is it possible to install windows on macbook pro , because I need to have some application like SQL server and visual studio, and they could not be install on mac
Windows on a Mac
-
Licencing of Windows 8.1, SQL Server and Visual Studio
1. Windows 8 (OEM Version)
a. Is it legal to re-install Windows 8 OEM version on a PC (this might
be required because of formatting of PC hard disk)? Is there any upper limit on how many times a Windows 8 OEM version can be re-installed
on a PC?
b. Can I continue to use same Windows 8 OEM version even after upgrading
a PC (for example change of processor, change of hard disk, change of RAM etc.)
2. SQL Server (Developer and Express) Version:
a. Your site mentions that SQL Server Developer edition can be used for
software development and testing, but a software dealer whom I have approached says its not legal to use SQL Server Developer edition for
development in a software consultancy. Please clarify.
b. Is it legal to use SQL Server Express Edition for software development
purpose in a software consultancy?
3. Visual Studio Express Edition
a. Is it legal to use Visual Studio Express Edition for software development
purpose in a software consultancy?
I had emailed this query to [email protected] yesterday but I have not received any reply.This question is a bit broad for a forum post. What have you tried and where does it fail? This code will give a list of files in an app folder. It might get you started: [c# code, but should be easy to translate to VB]
public async Task<List<string>> GetFileListFromFolder() {
List<string> fileList = new List<string>();
StorageFolder storageFolder = await Package.Current.InstalledLocation.GetFolderAsync(@"myFolder\");
foreach (StorageFile fl in await storageFolder.GetFilesAsync())
fileList.Add(fl.Name);
return fileList;
I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me. -
Crystal reports integration with sql server and visual studio 2010
when I am trying to open a crystal report through code ( visual basic 2010 ) I get the error
the report has no tables
I am using SQL SERVER 2008 R2
HERE IS THE CODE I WROTE
Imports System.Data
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.Shared
Public Class frmRep
Dim objConnection As New OleDbConnection("Provider=SQLOLEDB;Data Source=ASHRAF-PC\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=TEST")
Dim objDataAdapter As New OleDbDataAdapter()
Dim objDataSet As New DataSet()
Private Sub CrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load
End Sub
Private Sub frmRep_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim cr As New ReportDocument
objDataAdapter.SelectCommand = New OleDbCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandType = CommandType.Text
objDataAdapter.SelectCommand.CommandText = "select * from bands"
objConnection.Open()
objDataAdapter.Fill(objDataSet, "bands")
objConnection.Close()
cr.Load("D:\MY VB 2010 PROJECTS\test2\test2\CrystalReport1.rpt")
cr.SetDataSource(objDataSet.Tables("bands"))
CrystalReportViewer1.ReportSource = cr
CrystalReportViewer1.Refresh()
End Sub
End ClassI suggest you post that question in a Crystal Reports forum.
Markus -
Hi all,
Long time ago, I manually created a Database (APGriMMRP) and 3 Tables (dbo.Table_1_XYcoordinates, dbo.Table_2_Soil, and dbo.Table_3_Water) in my SQL Server 2012 Management Studio (SSMS2012). The dbo.Table_1_XYcoordinates has the following columns: file_id,
Pt_ID, X, Y, Z, sample_id, Boring. The dbo.Table_2_Soil has the following columns: Boring, sample_date, sample_id, Unit, Arsenic, Chromium, Lead. The dbo.Table_3_Water has the following columns: Boring, sample_date, sample_id, Unit, Benzene, Ethylbenzene,
Pyrene. The dbo.Table_1_XYcoordinates is a Parent Table. The dbo.Table_2_Soil and the dbo.Table_3_Water are 2 Child Tables. The sample_id is key link for the relationship between the Parent Table and the Child Tables.
Problem #1) How can I print out or export these 3 dbo Tables?
Problem #2) If I right-click on the dbo Table, I see "Start PowerShell" and click on it. I get the following error messages: Warning: Failed to load the 'SQLAS' extension: An exception occurred in SMO while trying to manage a service.
--> Failed to retrieve data for this request. --> Invalid class. Warning: Could not obtain SQL Server Service information. An attemp to connect to WMI on 'NAB-WK-02657306' failed with the following error: An exception occurred in SMO while trying
to manage a service. --> Failed to retrieve data for this request. --> Invalid class. .... PS SQLSERVER:\SQL\NAB-WK-02657306\SQLEXPRESS\Databases\APGriMMRP\Table_1_XYcoordinates> What causes this set of error messages? How can
I get this problem fixed in my PC that is an end user of the Windows 7 LAN System? Note: I don't have the regular version of Microsoft Visual Studio 2012 in my PC. I just have the Microsoft 2012 Shell (Integrated) program in my PC.
Problem #3: I plan to create an XML Schema Collection in the "APGriMMRP" database for the Parent Table and the Child Tables. How can I handle the relationship between the Parent Table and the Child Table in the XML Schema Collection?
Problem #4: I plan to extract some results/data from the Parent Table and the Child Table by using XQuery. What kind of JOIN (Left or Right JOIN) should I use in the XQuerying?
Please kindly help, answer my questions, and advise me how to resolve these 4 problems.
Thanks in advance,
Scott ChangIn the future, I would recommend you to post your questions one by one, and to the appropriate forum. Of your questions it is really only #3 that fits into this forum. (And that is the one I will not answer, because I have worked very little with XSD.)
1) Not sure what you mean with "print" or "export", but when you right-click a database, you can select Tasks from the context menu and in this submenu you find "Export data".
2) I don't know why you get that error, but any particular reason you want to run PowerShell?
4) If you have tables, you query them with SQL, not XQuery. XQuery is when you query XML documents, but left and right joins are SQL things. There are no joins in XQuery.
As for left/right join, notice that these two are equivalent:
SELECT ...
FROM a LEFT JOIN b ON a.col = b.col
SELECT ...
FROM b RIGHT JOIN a ON a.col = b.col
But please never use RIGHT JOIN - it gives me a headache!
There is nothing that says that you should use any of the other. In fact, if you are returning rows from parent and child, I would expect an inner join, unless you want to cater for parents without children.
Here is an example where you can study the different join types and how they behave:
CREATE TABLE apple (a int NOT NULL PRIMARY KEY,
b varchar(23) NOT NULL)
INSERT apple(a, b)
VALUES(1, 'Granny Smith'),
(2, 'Gloster'),
(4, 'Ingrid-Marie'),
(5, 'Milenga')
CREATE TABLE orange(c int NOT NULL PRIMARY KEY,
d varchar(23) NOT NULL)
INSERT orange(c, d)
VALUES(1, 'Agent'),
(3, 'Netherlands'),
(4, 'Revolution')
SELECT a, b, c, d
FROM apple
CROSS JOIN orange
SELECT a, b, c, d
FROM apple
INNER JOIN orange ON apple.a = orange.c
SELECT a, b, c, d
FROM apple
LEFT OUTER JOIN orange ON apple.a = orange.c
SELECT a, b, c, d
FROM apple
RIGHT OUTER JOIN orange ON apple.a = orange.c
SELECT a, b, c, d
FROM apple
FULL OUTER JOIN orange ON apple.a = orange.c
go
DROP TABLE apple, orange
Erland Sommarskog, SQL Server MVP, [email protected] -
Hi all,
I learmed the basic stuff of XML, DTD, DOM, etc. long time ago. Now, I came back to resume my XML journey and try to learn the XML Schemas, XPath and XQuery. I have Microsoft SQL Server 2012 Management Studio (SSMS2012) in our computer network. From
Page 221 of the old Book "Beginning XML 2nd Edition" written by David Hunter, et.al., (published by Wrox), I copied the name5.xsd and name5.xml :
<?xml version="1.0"?>
<schema xmlns=http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.wrox.com/name" xmlns:target="http://www.wrox.com/name"
elementFormDefault="qualified">
<element name="name">
<complexType>
<sequence>
<element name="first" type="string"/>
<element name="middle" type="string"/>
<element name="last" type="string"/>
</sequence>
</complexType>
</element>
</schema>
<?xml version="1.0"?>
<name
xmlns=http://www.wrox.com/name"
xmlns:xsi="http://www.wrox.org/2001XMLSchema-instance"
xsi:schemaLocation="http://www.wrox.com/name name5.xsd"
title="Mr.">
<first>John</first>
<middle>Frizgerald</middle>
<last>Doe</last>
</name>
How can I execute these two files in my SSMS2012 for doing my first XML Schema trial?
Please kindly help, advise and respond.
Thanks in advance,
Scott ChangHi Eric Zhang, Thanks for your nice response.
1) I saw the CREATE XML SCHEMA COLLECTION (Transact-SQL) and tried its first example "Create XML schema collection in the database" in my SQL Server 2012 Management Studio (SSMS2012):
-- Create a sample database in which to load the XML schema collection.
-- Copied this set of code stsments from Microsoft Library (ms176009)
-- ColesMS12_20a.sql (saved in C:/Documents/SQL Server Management Studio)
-- 19 March 2015 1145 AM
CREATE DATABASE SampleDB
GO
USE SampleDB
GO
CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
N'<?xml version="1.0" encoding="UTF-16"?>
<xsd:schema targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
xmlns ="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:complexType name="StepType" mixed="true" >
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="tool" type="xsd:string" />
<xsd:element name="material" type="xsd:string" />
<xsd:element name="blueprint" type="xsd:string" />
<xsd:element name="specs" type="xsd:string" />
<xsd:element name="diag" type="xsd:string" />
</xsd:choice>
</xsd:complexType>
<xsd:element name="root">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="Location" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="step" type="StepType" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="LocationID" type="xsd:integer" use="required"/>
<xsd:attribute name="SetupHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="MachineHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="LaborHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="LotSize" type="xsd:decimal" use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>' ;
GO
-- Verify - list of collections in the database.
select *
from sys.xml_schema_collections
-- Verify - list of namespaces in the database.
select name
from sys.xml_schema_namespaces
-- Use it. Create a typed xml variable. Note collection name specified.
DECLARE @x xml (ManuInstructionsSchemaCollection)
GO
--Or create a typed xml column.
CREATE TABLE T (
i int primary key,
x xml (ManuInstructionsSchemaCollection))
GO
-- ////The following code statements are not used in order to create SampleDB
-- Clean up
---DROP TABLE T
---GO
---DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
---Go
---USE Master
---GO
---DROP DATABASE SampleDB
It worked and I got the following results:
1 4 NULL sys 2009-04-13 12:59:13.390 2012-02-10 20:16:02.097
65536 1 NULL ManuInstructionsSchemaCollection 2015-03-19 11:47:17.660 2015-03-19 11:47:17.660
http://www.w3.org/2001/XMLSchema
http://schemas.microsoft.com/sqlserver/2004/sqltypes
http://www.w3.org/XML/1998/namespace
http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions
But, I don't undertand (i) what SCHEMA COECTION is, (ii) what <xsd:schema targetNamespace=.....</xsd:complexType> are, (iii) How I can specify my "project specific" schema in the Microsoft SCHEMA COLLECTION to check my xml file.
2) I dived in the XQuery programmimng in SSMS2012 in the last few weeks. I used the examles of Ad-Hoc XML File Query by Seth Delconte (in
httpS://www.simple-talk.com/content/print.aspx?article=1756) in my SSMS2012. They worked. But I don't understand the (i) Importing XML data using a function, (ii) Using the XQuery contans()
function to find substrings, (iii)Efficiency comparisons in the article.
Please kindly help me in enlightening me to resolve the difficulties listed in 1) and 2).
Thanks,
Scott Chang -
Hi all,
In my SQL Server 2012 Management Studio (SSMS2012), I tried to create a Database (MacLochainnsDB) and a dbo Table (marvel). then I wanted insert 8 VALUES into the Table by using the following code:
USE master
IF EXISTS
(SELECT 1
FROM sys.databases
WHERE name = 'MacLochlainnsDB')
DROP DATABASE MacLochlainnsDB
GO
CREATE DATABASE MacLochlainnsDB
GO
CREATE TABLE [dbo].[marvel] (
[avenger_name] [char] (30) NULL)
INSERT INTO marvel
(avenger_name)
VALUES
('Hulk', 1),
('Iron Man', 2),
('Black Widow', 3),
('Thor', 4),
('Captain America', 5),
('Hawkeye', 6),
('Winter Soldier', 7),
('Iron Patriot', 8)
I got the following error Message:
Msg 110, Level 15, State 1, Line 5
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
How can I correct this problem?
Please kindly help and advise.
Thanks in advance,
Scott Chang
P. S.
The reason I tried to create the Database, dbo Table, and then to insert the VALUES is to learn the following thing:
You can query the entire node tree with the following xquery statement because it looks for the occurrence of any node with the /* search string:
DECLARE @x xml;
SET @x = N'<marvel>
<avenger_name>Captain America</avenger_name>
</marvel>';
SELECT @x.query('/*');
You can query the avenger_name elements from the marvel_xml table with the following syntax:
SELECT xml_table.query('/marvel/avenger_name')
FROM marvel_xml;
It returns the following set of avenger_name elements:
<avenger_name>Hulk</avenger_name>
<avenger_name>Iron Man</avenger_name>
<avenger_name>Black Widow</avenger_name>
<avenger_name>Thor</avenger_name>
<avenger_name>Captain America</avenger_name>
<avenger_name>Hawkeye</avenger_name>
<avenger_name>Winter Soldier</avenger_name>
<avenger_name>Iron Patriot</avenger_name>
You can query the fourth avenger_name element from the marvel_xml table with the following xquery statement:
SELECT xml_table.query('/marvel[4]/avenger_name')
FROM marvel_xml;
It returns the following avenger_name element:
<avenger_name>Thor</avenger_name>Hi Scott,
The master database records all the system-level information for a SQL Server system, so best practise would be not to create any user-defined
object within it.
To change your default database(master by default) of your login to another, follow the next steps so that next time when connected you don't have to use "USE dbname" to switch database.
Open SQL Server Management Studio
--> Go to Object explorer(the left panel by default layout)
--> Extend "Security"
--> Extend "Logins"
--> Right click on your login, click "propertites"
--> Choose the "Default database" at the bottom of the pop-up window.
--or simply by T-SQL
Exec sp_defaultdb @loginame='yourLogin', @defdb='youDB'
Regarding your question, you can reference the below.
SELECT * FROM master.sys.all_objects where name ='Marvel'
--OR
SELECT OBJECT_ID('master.dbo.Marvel') --if non empty result returns, the object exists
--usually the OBJECT_ID is used if a if statement as below
IF OBJECT_ID('master.dbo.Marvel') IS NOT NULL
PRINT ('TABLE EXISTS') --Or some other logic
What is the sys.all_objects? See
here.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
I am trying to do the tutorial for SQL Server Business Intelligence Studio, but I can't get the AdventureWorksDW to be recognized by it, when I try to connect to it.
I have tried to shut down, restart, downloaded a couple of different versions of AdventureWorksDW (I believe 2008 is the one I need), and tried to attach this AdventureWorksDW using SQL Server Management Studio 2008R2, but I cannot even do that! The instructions
for attaching a DB tell me to open Management Studio, then open a connection instance. But then I cannot find the database button to right click on, or the attach item in the menu that is supposed to be there with it.
I had installed AdventureWorks2008R2 previously and the SQL Server BIDS sees that, but of course I cannot do the tutorial without some serious mods if I do that. I have rebooted computer, closed and reopened the BIDS app, deleted and re-created the
OLE-DB connection in BIDS, but nothing works. What am I doing wrong? I've worked in mostly the Oracle world for most of my career so I'm not new to either DW or relational DB, but this one is driving me to pull my hair. Any help greatly appreciated!
BadgerThank you! Is this correct?
CREATE DATABASE AdventureWorksDW2008R2_data
ON
(FILENAME
=
'C:\SSIS Downloads\AdventureWorksDW2008R2_Data')
FOR
ATTACH_REBUILD_LOG
I tried this and it gives me a cannot find file specified error, but my file IS located at
C:\SSIS Downloads
error is:
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "C:\SSIS Downloads\AdventureWorksDW2008R2_Data". Operating system error 2: "2(The system cannot find the file specified.)".
I will continue to play with it, thanks very much!
Try as below,
sp_attach_single_file_db 'AdventureWorksDW2008R2'
,'C:\SSIS Downloads\AdventureWorksDW2008R2_Data.mdf'
Note: If you get any security issue then refer this link
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/232e4aaf-73cf-4eb8-9f6c-6a4fc91a6036/i-cant-attach-mdf-operating-system-error5
Regards, RSingh -
How do I create a view in SQL Server in Visual Studio Express 2013 for Desktop?
Hi
I've got a SQL Server database set up using the internal SQL Server in Visual Studio Express 2013 for Desktop. I want to create a view (using tables with one to many relationships) but I don't
know how to do it.
Where can I find a good tutorial on creating views in SQL Server in Visual Studio Express 2013 for Desktop? I think Visual Studio Express 2013 for Desktop doesn't have some view designer that
exists in the non-express version of Visual Studio (if I'm not mistaken). So I think I'd need a tutorial on how to do the actual SQL, unless there is some tool I don't know about.
ThanksHi ,
According to your description, if you install SQL Server SQL Server 2014 Express and SQL Server Manager Studio tools (SSMS), if you want to create a view, you can use SSMS. Then if you want to connect to and Diagram your SQL Express Database in Visual Studio
2013, you can attach the database file by using the .NET Framework Data Provider for SQL Server in Visual Studio, and create a database diagram via expanding the “Database Diagrams” node.
For more information, there is similar issue about how to connect to and Diagram your SQL Express Database in Visual Studio 2012 , you can review the following article,
http://blogs.msdn.com/b/bethmassi/archive/2011/10/27/how-to-connect-to-and-diagram-your-sql-express-database-in-visual-studio-lightswitch.aspx.
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
SQL Server 2005 Management Studio Local Server Connection Error
Sir, as you can see in above image,,, I have installed SQL SERVER 2005 Management Studio Express of 64 bit.
And when i have tried to connect it to local server it shows me above error...... Please guide me how should i fix it?Check
http://sqlserver-help.com/2011/06/19/help-whats-my-sql-server-name/
Balmukund Lakhani
Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
This posting is provided "AS IS" with no warranties, and confers no rights.
My Blog |
Team Blog | @Twitter
| Facebook
Author: SQL Server 2012 AlwaysOn -
Paperback, Kindle -
Silent SQL Server 2008 Management Studio install on Win7
Hi,
Is there a way to suppress Compatibility warning box while silently installing SQL Server 2008 Management Studio install on Win7?
Thanks,
HHi Kugler,
Even I was facing the same issue. It is because you may pending reboots on the target machine.
I also used the cmdline as below:
<PATH of EXE> /Q /IACCEPTSQLSERVERLICENSETERMS /ACTION=install /FEATURES=SSMS,ADV_SSMS /HIDECONSOLE
Before installation it is better to restart the target machine and start with the installation. -
Hi all,
In the Notepad, I created an xml file (ZenQroducts.xml) :
<Qroducts>
<Qroduct>
<SKU>1</SKU>
<Desc>Book</Desc>
</Qroduct>
<Qroduct>
<SKU>2</SKU>
<Desc>DVD</Desc>
</Qroduct>
<Qroduct>
<SKU>3</SKU>
<Desc>Video</Desc>
</Qroduct>
In my SQL Server 2012 Management Studio, I executed the following code:
--to create a new object Qroducts in a new database OPENXMLtesting
CREATE DATABASE OPENXMLtesting
GO
CREATE TABLE Qroducts(
sku INT Primary KEY,
qroduct_desc VARCHAR(30));
INSERT INTO Qroducts (sku, qroduct_desc)
SELECT X.qroduct.query('SKU').value('.', 'INT'),
X.qroduct.query('Desc').value('.', 'VARCHAR(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'H:\ZenQroducts.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('Qroducts/Qroduct') AS X(qroduct);
SELECT sku, qroduct_desc
FROM Qroducts;
I got the following message:
Msg 9400, Level 16, State 1, Line 6
XML parsing: line 13, character 12, unexpected end of input
I have no ideas why I got this "XML parsing:line 13, character12, unexpected end of input" message. Please kindly help, advise me on where I made mistake and how I can resolve this problem, and respond in this Forum.
Thanks in advance,
Scott Chang
Hi Manish, Thanks for your response.
Yes, it is a duplicate with Qroducts/Qroduct instead of Products/Product. I did it, because I don't know how to remove the existing "Products" database.
Again, I got the existing "Qroducts" database in this second trial!!?? I am comletely lost in doing "Importing XML file to SQL Table" now!! I think that I have not touched T-SQL and XML programming, since 2008. I
did not catch the new features of T-SQL 2008, XML, SQL/XML, XQuery, etc. for long time. Recently, I did not know what DECLARE, @x, SET,...were, and dived into the SQL/XML and XQuery programming. I knew the SQL Basics (SELECT, FROM, WHERE,..), creating
the names of databases and tables in SQL Server 2008/2012 Management Studio (Express) before. This morning, I found an old T-SQL 2008 Prgrammer's Guide that has the new features of SQL Server 2008 for T-SQL, XML, XQuery, etc. I just starting reading
it to know what DECLARE, @x, SET,... are. But, I still don't know where the existing databases "Products" and "Qroducts" (created by me) are - they are not in the Databases of SQL Server 2012 Management Studio I am using!!?? Could
you please kindly point out where the "Products" and "Qroducts" databases are?
Prashanth responded to my posted question too and he asked to to try his code: DECLARE @xml XML, SELECT @xml =' <Qroducts>.....SELECT product.value.....FROM @XML.nodes.....AS.... I just learned that his code is doing the thing we
want to do and print the results below the SQL Query. This is not what I need in doing my SQL/XML programming. I am reading/studying the new (2008) features of T-SQL, XQuery 1.0: An XML Query Language (Second Edition), and Microsoft XQuery Language Reference
(SQL Server 2012 Books Online) closely now. I hope that I can resume the T-SQL, XML Query, SQL/XML, XQuery in my SQL Server 2012 Management Studio soon.
Please tell me where the existing databases "Products" and "Qroducts" I created in my previous trials in my SQL Server 2012 Management Studio. This is what I need to know and to delete them, before I do this kind of "Importing
XML file to Table of SQL Server 2012 Management Studio" programming again.
Please kindly help, advise and respond again.
Many Thanks,
Scott Chang -
Hi all,
In my SQL Server 2012 Management Studio, I executed the following code:
CREATE TABLE Products(
sku INT Primary KEY,
product_desc VARCHAR(30));
INSERT INTO Products (sku, product_desc)
SELECT X.product.query('SKU').value('.', 'INT'),
X.product.query('Desc').value('.', 'VARCHAR(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'H:\ZenProducts.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('Products/Product') AS X(product);
SELECT sku, product_desc
FROM Products;
I got the following message:
Msg 9455, Level 16, State 1, Line 5
XML parsing: line 3, character 12, illegal qualified name character
I have no ideas why the "product" in the statement "SELECT X.product.query('SKU').value('.','INT')" is not legal qualified name charcter!!!??? Please kindly help, advise and respond.
Thanks in advance,
Scott ChangHi Manish, Thanks for your response.
Here is a copy of my ZenProducts.xml:
<Products>
<Product>
<SKU>1<</SKU>
<Desc>Book</Desc>
</Product>
<Product>
<SKU>2<</SKU>
<Desc>DVD</Desc>
</Product>
<Product>
<SKU>3<</SKU>
<Desc>Video</Desc>
</Product>
I found the wrong "<<" in my xml file and changed it to the right "<" for the statement<SKU>1</sku>. I executed the corrected code and I got the following new message:
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'Products' in the database.
I don't know how to remove the old, existing the 'Products' object in the database and execute the corrected code again. Please kindly help, advise and tell me how to resolve this new problem.
Many Thanks,
Scott Chang
P. S. I played with another project to get the 'Products' object in my database before. Frankly, I don't know where the old 'Products' object and the database are. Please enlighten me in resolving this matter more clearly.
You welcome Scott, As Olaf mentioned in this post, there was already a table exists , so need to drop your Products table.
Apart from this, I guess either you did not pasted the full XML file or what, I needed to have the ( </Products>)closing tag in your XML file as follows.
<Products>
<Product>
<SKU>1</SKU>
<Desc>Book</Desc>
</Product>
<Product>
<SKU>2</SKU>
<Desc>DVD</Desc>
</Product>
<Product>
<SKU>3</SKU>
<Desc>Video</Desc>
</Product>
</Products>
You can use following script to drop if your
Products table is already existing.
if exists(select 1 from sys.tables where name ='Products')
drop table Products
CREATE TABLE Products(
sku INT Primary KEY,
product_desc VARCHAR(30));
INSERT INTO Products (sku, product_desc)
SELECT X.product.query('SKU').value('.', 'INT'),
X.product.query('Desc').value('.', 'VARCHAR(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'H:\ZenProducts.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('Products/Product') AS X(product);
SELECT sku, product_desc
FROM Products;
Let us know if you face any other problem.
Thanks
Manish
Please click Mark as Answer if my post solved your problem and click
Vote as Helpful if this post was useful. -
Hi all,
I just started doing the XML Xquery programming in my SQL Server 2012 Management Studio. I executed the following code:
--query the XML Blob using a CTE (pulling from the XML file each time) Products
WITH XmlFile (Contents) AS (
SELECT CONVERT (XML, BulkColumn)
FROM OPENROWSET (BULK 'H:\Products.xml', SINGLE_BLOB) ) AS XmlData
SELECT *
FROM XmlFile
GO
I got the the following Msg:
Msg 491, Level 16, State 1, Line 4
A correlation name must be specified for the bulk rowset in the from clause.
How can I specify the correction name for the bulk rowset in my project?
Please kindly help, advise and respond.
Thanks in advance,
Scott ChangHello Scott,
You have to assign a table alias for the OPENROWSET =>
--query the XML Blob using a CTE (pulling from the XML file each time) Products
WITH XmlFile (Contents) AS (
SELECT CONVERT (XML, BulkColumn)
FROM OPENROWSET (BULK 'H:\Products.xml', SINGLE_BLOB) AS MyXML ) AS XmlData
SELECT *
FROM XmlFile
GO
Olaf Helper
[ Blog] [ Xing] [ MVP] -
SQL Developer, SQL Server and the ampersand
Hello,
I am connected to a SQL Server database (2008) and am having difficulty getting a query to run properly in SQL Developer (3.1.07).
Simplified Example
select table_field
from table
where table_field <> 'This & That';
Expected results
table_field
Other stuff
Other stuff
Other stuff
Actual results
table_field
Other stuff
This & That
This & That
I cannot seem to get SQL Developer to recognize the & as a literal ampersand. I've tried escaping it numerous ways, but it always thinks it is a variable.
The query works exactly as expected in MS SQL Management Studio and Toad. Of course, I can just run it in one of those but I'd like to try to get this to work in SQL Developer. Suggestions?
Please let me know if I can provide further information. Thanks.Hi,
SQL Developers worksheet is designed for Oracle, but we allow you to run statements against SQL Server and other non Oracle databases.
This can lead to some quirks, like the one you experienced.
Oracles SQL*Plus uses ampersand to define substitution variables.
Oracle SQL Developer has implemented the same concept.
Unfortunately this does not make sense when running something against a non Oracle database.
As a workaround, you can run the following SQL*Plus command in SQL Developer, before your SQL Server query.
SET DEFINE OFF;
select 'hello & goodbye';
The following maybe of some help as well.
http://dermotoneill.blogspot.com/2010/11/workheet-hints.html
http://dermotoneill.blogspot.com/2010/12/sql-server-and-sybase-browsing.html
Regards,
Dermot.
SQL Developer Team.
Maybe you are looking for
-
PR release strategy issue comes when Line items in PR added by two different persons, PR Release strategy(overall release) not getting triggered. Release strategy is working fine if i create PR with only one user id. Both id's maintained in classif
-
Which macbook for editing?
I'm wondering if the macbook air, macbook pro, or macbook pro with retina display will be better for video, and photo editing. I have a gaming computer and I just wanted a separate laptop for my photography and video editing. It will also be helpful
-
Imovie song does not start at the beginning after I edited the duration of the clip
my imovie song does not start at the begining after I edited the duration of my clips. The audio clip now starts in the middle of the song. This is occuring with the second song in my video. How do I adjust the audio to start at the beginning of the
-
Virus and Certificate not valid??
Hi, I was having issues with icloud and had to download icloud onto my laptop to retrieve my photos and music. I did this, got my photos and then started getting this message whenever I try to get onto any website except my homepage... There is a pro
-
Cannot access Startup Manager from boot
I'm trying to fix a friends computer, and I'm running into some issues. Here's the setup: She used her computer last night, and then shut it down. This morning, she tried to start it up, and after about 10 minutes of waiting, got the folder with a qu