SQL71508: The model already has an element that has the same name ABC_Role

[Origin]: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/25266466-cc27-4e60-a18f-22673e6507e8/sql71508-the-model-already-has-an-element-that-has-the-same-name-abcrole?forum=ssdt

Hello,

I am trying to  convert a VS2010 database project to a VS2012 database project. This database has a case-sensitive collation. But VS2012 seems to be ignoring the collations and complains about two objects with same name (in different case) to exist, in the same project.

For example, I have 2 database roles ABC_Role and Abc_Role. In ths case sensitive project, they should be recognized as 2 different roles but VS2012 database project doesn’t seem to like it. I tried to see if the same happens with tables too. And it behaves the same way. I tried messing with “Validating casing on Identifiers” setting on the Project Settings window, but that didn’t work.

Is there a way to make SSDT recognize the collation? Any help is appreciated.


Hima, To help the community better identify relevant thread, please don’t forget to mark as answer or vote as helpful if and answer helps.

Tuesday, April 16, 2013 8:27 PM
Avatar of Hima Nagisetty
Scottrade Inc

OK, I can repro this when converting a dbproj to a sqlsproj, but not when creating a new sqlproj and adding the objects.

The problem is in the upgraded project file. Open the .sqlproj project file and make sure that the ModelCollation is set to CS, this is what was the diff for me when upgrading:

<ModelCollation>1033,CS</ModelCollation>

To be sure, also check that:

<ValidateCasingOnIdentifiers>False</ValidateCasingOnIdentifiers>

<DefaultCollation>SQL_Latin1_General_CP437_BIN</DefaultCollation>


-GertD @ http://www.sqlproj.com

  • Marked as answer by Hima Nagisetty Thursday, April 18, 2013 8:55 PM
Thursday, April 18, 2013 8:25 PM
Puppet Lab
Advertisements

What is the difference between const and readonly?

[Origin]: https://stackoverflow.com/questions/55984/what-is-the-difference-between-const-and-readonly

Apart from the apparent difference of

  • having to declare the value at the time of a definition for a const VS readonly values can be computed dynamically but need to be assigned before the constructor exits.. after that it is frozen.
  • ‘const’s are implicitly static. You use a ClassName.ConstantName notation to access them.

There is a subtle difference. Consider a class defined in AssemblyA.

public class Const_V_Readonly
{
  public const int I_CONST_VALUE = 2;
  public readonly int I_RO_VALUE;
  public Const_V_Readonly()
  {
     I_RO_VALUE = 3;
  }
}

AssemblyB references AssemblyA and uses these values in code. When this is compiled,

  • in the case of the const value, it is like a find-replace, the value 2 is ‘baked into’ the AssemblyB‘s IL. This means that if tomorrow I’ll update I_CONST_VALUE to 20 in the future. AssemblyB would still have 2 till I recompile it.
  • in the case of the readonly value, it is like a ref to a memory location. The value is not baked into AssemblyB‘s IL. This means that if the memory location is updated, AssemblyB gets the new value without recompilation. So if I_RO_VALUE is updated to 30, you only need to build AssemblyA. All clients do not need to be recompiled.

So if you are confident that the value of the constant won’t change use a const.

public const int CM_IN_A_METER = 100;

But if you have a constant that may change (e.g. w.r.t. precision).. or when in doubt, use a readonly.

public readonly float PI = 3.14;

Update: Aku needs to get a mention coz he pointed this out first. Also I need to plug where I learned this.. Effective C# – Bill Wagner

shareedit

‘The format of the specified network name is invalid’ – IIS Error 0x800704BE

[Origin]: http://www.therealtimeweb.com/index.cfm/2011/10/24/iis-error-0x800704BE

Oh don’t you just love cryptic error messages that could mean one hundred and one things? Yeah, me too.

So in the interest of some poor soul (maybe it’s you 😉 searching on this topic in the year 2142 I decided to point out what resolved this issue for me.

Background: I am running Windows Server 2008 R2 with IIS inside a Hyper-V instance. The VM was configured with a static IP and each IIS site was configured to bind to that IP, and that IP alone.
I transferred the VM to Amazon EC2 (using the ec2-import-instance API) since I wanted to move away from having to maintain my own physical hardware. Long story short, once transferred I was unable to start any of the IIS sites, they all failed with the error ‘The format of the specified network name is invalid – Error 0x800704BE’.

I knew that this error was likely related to IP bindings of some kind (EC2 usually expects you to use DHCP for IP address assignment since even an elastic IP can change) so I tried binding a few IIS sites to ‘all’ IPs. Still the sites would not start, but throw the above error.

I dug deeper and used the netsh utility (Windows commandline) to show which the network configuration for the machine, and in particular which IPs the HTTP service listens to:

netsh http show iplisten

This listed just one (the previous static) IP of my VM – this was now wrong. So I removed the binding with

netsh http delete iplisten ipaddress=11.22.33.44 (where 11.22.33.44 is the actual IP that needs removing)

Next set the service up to listen to all IPs:

netsh http add iplisten ipaddress=0.0.0.0

I then restarted IIS using

1iisreset

and bingo, the sites started to work.

Hope this helps someone.

IIS does not list a website that matches the launch url

[Origin]: https://stackoverflow.com/questions/10716956/iis-does-not-list-a-website-that-matches-the-launch-url

I need to debug the website i ‘m developing (ASP.NET MVC3, Razor, .NET 4, VS2010 SP1 (as administrator)) in IIS7 (Vista Home) and getting the error:

IIS does not list a website that matches the launch url.

To test if it has to do something with the settings of the app, i did create from scratch an empty new ASP.NET MVC3 website, set for IIS, created virtual directory, launched with F5 and i worked fine!

I again did create a second website project with the exact same settings (just to be sure) and this also launched as expected.

This leads my to think that i have some configuration problem!? But what? In the past i used IIS very rare, so my knowledge is somehow limited in this direction.

Any hints?

shareedit

I hate answering my questions: in my question i stated that i was running VS under the administrator account. This was not true!!!

So the solution (for me) was to run VS2010 as administrator (Start->In Vista menu right click-> Run as administrator)…so simple.

As a side effect: VS2010 let me also create Virtual Directories without any problems (prior to that i got error messages stating that i have to manually adjust these)

shareedit

Aggregate bitwise-OR in a subquery

[Origin]: https://stackoverflow.com/questions/3981050/aggregate-bitwise-or-in-a-subquery

Given the following table:

CREATE TABLE BitValues ( n int )

Is it possible to compute the bitwise-OR of n for all rows within a subquery? For example, if BitValues contains these 4 rows:

+---+
| n |
+---+
| 1 |
| 2 |
| 4 |
| 3 |
+---+

I would expect the subquery to return 7. Is there a way to do this inline, without creating a UDF?

shareedit
WITH    Bits
          AS ( SELECT   1 AS BitMask
               UNION ALL
               SELECT   2
               UNION ALL
               SELECT   4
               UNION ALL
               SELECT   8
               UNION ALL
               SELECT   16
             )
    SELECT  SUM(DISTINCT BitMask)
    FROM    ( SELECT    1 AS n
              UNION ALL
              SELECT    2
              UNION ALL
              SELECT    3
              UNION ALL
              SELECT    4
              UNION ALL
              SELECT    5
              UNION ALL
              SELECT    6
            ) AS t
            JOIN Bits ON t.n &amp; Bits.BitMask &gt; 0
shareedit

I tried using COALESCE function and it works, example:

DECLARE @nOrTotal INT

SELECT @nOrTotal = COALESCE(@nOrTotal, 0) | nValor 
    FROM (SELECT 1 nValor
              UNION 
          SELECT 2
              UNION 
          SELECT 2) t

SELECT @nOrTotal

>> Result: 3

shareedit

Change Schema Name Of Table In SQL

[Origin]: https://stackoverflow.com/questions/15482838/change-schema-name-of-table-in-sql

I want to change schema name of table Employees in Database. In the current table Employeesdatabase schema name is dbo I want to change it to exe. How can I do it ?

Example:

FROM

dbo.Employees

TO

exe.Employees

I tried with this query:

ALTER SCHEMA exe TRANSFER dbo.Employees

But this gives me an error:

Cannot alter the schema ‘exe’, because it does not exist or you do not have permission.

What did I miss?

shareedit

Create Schema :

IF (NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'exe')) 
BEGIN
    EXEC ('CREATE SCHEMA [exe] AUTHORIZATION [dbo]')
END

ALTER Schema :

ALTER SCHEMA exe TRANSFER dbo.Employees
shareedit

XDOM API in UniVerse

[Origin]: https://stackoverflow.com/questions/1727776/xdom-api-in-universe

I am building an xml parser and constructor using the XDOM functions in UniVerse 10.1.0. Things are going fine until I get to use the XDOMAddChild function. I can add single elements fine using the handles but I get an error when adding a tree. The manuals indicate adding a tree is fine.

XDOMAddChild function

Syntax

XDOMAddChild(xmlHandle, xpathString, nsMap, nodeHandle, dupFlag)

Description

The XDOMAddChild function finds the xpathString in the context xmlHandle in the DOM structure and inserts a node nodeHandle as the last child of the found node. If the inserted node type is XDOM.ATTR.NODE, this node is inserted as an attribute.

Parameters

The following table describes each parameter of the syntax. Parameter Description

xmlHandle The handle to the context. [IN] xpathString Relative or absolute Xpath string. [IN] nsMap The map of namespaces which resolve the prefixes in the xpath string. Format is “xmlns=default_url xmlns:prefix1=prefix1_url xmlns:prefix2=prefix2_url”

For example: “xmlns=http://myproject.mycompany.com xmlns:a_prefix=a.mycompany.com” [IN]

nodeHandle Handle to a DOM subtree. If nodeHandle points to a DOM document, all of its children are inserted, in the same order. [IN]

dupFlag XDOM.DUP: Clones nodeHandle, and inserts the duplicate node. XDOM.NODUP: Inserts the original node. The subtree is also removed from its original location. [IN]

I accept the XDOM faults and flaws (particularly with building namespace prefixes) and an willing to work with them, But this one may be a show stopper with the current logic I am using. This is some test code:

$INCLUDE UNIVERSE.INCLUDE XML.H                                           
DATA.REQ = '<logonResponse></logonResponse>'
TEST.CHILD = '<logon>HELP</logon>'
NSMAP = ''
*
ERR$ = XDOMOpen(DATA.REQ, XML.FROM.STRING, DOM$H)                
  Status = XMLGetError(ERR$,errMsg)
  PRINT ERR$:',':errMsg 
ERR$ = XDOMOpen(TEST.CHILD, XML.FROM.STRING, CHILD$H)                
  Status = XMLGetError(ERR$,errMsg)
  PRINT ERR$:',':errMsg
ERR$ = XDOMLocate(DOM$H,'//logonResponse',NSMAP,NOD$H)                                   
  Status = XMLGetError(ERR$,errMsg)
  PRINT ERR$:',':errMsg
ERR$ = XDOMWrite(NOD$H,JUNK,XML.TO.STRING)
PRINT JUNK
ERR$ = XDOMWrite(CHILD$H,JUNK,XML.TO.STRING)
PRINT JUNK
ERR$ = XDOMAddChild(DOM$H, '',NSMAP,CHILD$H, XDOM.NODUP)
IF ERR$ = XML.SUCCESS THEN PRINT 'SUCCESS'
IF ERR$ = XML.ERROR THEN PRINT 'ERROR'
IF ERR$ = XML.INVALID.HANDLE THEN PRINT 'INVALID'
  Status = XMLGetError(ERR$,errMsg)
  PRINT ERR$:',':errMsg
END

I get this back….

1004,A DOM exception occured in function XDOMAddChild, DOM Exception code: 4

If I use XDOMCreateNode to create the TEST.CHILD element, the XDOMAddChild works fine. The only difference I can prove ids that the inserted node hanlde is different between teh 2 examples. The one that works the nodehandle is XDOM.ELEMENT.NODE (Type 1) and the one that fails in XDOM.DOC.NODE (Type 9).

Not sure where to go from here. Any code snippets, links, pointers; greatly appreciated

shareedit

An XML Document is a different kind of beast than an XML Element. A document must contain one, and only one element: the document root, which contains the other elements. It’s can’t directly contain attribute or text nodes. It can contain DTDs, processing instructions, and a declaration, all of which are forbidden for an element to contain. An element can contain nodes; either text, attributes or other elements. An element can’t contain a document.

You answered your own question here:

If I use XDOMCreateNode to create the TEST.CHILD element, the XDOMAddChild works fine. The only difference I can prove ids that the inserted node hanlde is different between teh 2 examples. The one that works the nodehandle is XDOM.ELEMENT.NODE (Type 1) and the one that fails in XDOM.DOC.NODE (Type 9).

Don’t use XDOMOpen, use XDOMCreateNode OR XDOMLocate. You need an element, attribute or text node. A document won’t work.

shareedit

I actually made a small blog post regarding U2 XDom errors just before Christmas.

I assume UniVerse and UniData use the same XDOM parsers, so you can should be able to work out what that error refers to from the Xalan documentation.

In this case, Error 4 refers to ‘WRONG_DOCUMENT_ERR’

Hope it helps somewhat…

shareedit

Thanks,

The crux of my problem was that I was confused about the “Document” type as opposed to the “element” type.

eg: You can only use XDOMLocate on the “Document” Type Node. I was trying to use this function on a “element” Type node. The code below will no work because the 2nd Locate is performed on an “element” Type node.

  XMLDOC = <rootNode><nodeItem><data>aaa</data></nodeItem><nodeItem><data>bbb</data></nodeItem></rootNode>
  ERR$ = XDOMLocate(DOM$H,'//rootNode','',NOD$H)
  ERR$ = XDOMLocateNode(NOD$H,XDOM.CHILD,XDOM.LAST.CHILD,XDOM.ELEMENT.NODE,SUBNOD$H)
  ERR$ = XDOMLocate(SUBNOD$H,'//nodeItem/data','',DATA$H)
  ERR$ = XDOMLocateNode(DATA$H, XDOM.CHILD, XDOM.FIRST.CHILD, XDOM.TEXT.NODE, TEXT.NODE)
  ERR$ = XDOMGetNodeValue(TEXT.NODE, DATA$VALUE)

DATA$VALUE will not be extracted to “bbb”. This is how to do it..

  ERR$ = XDOMLocate(DOM$H,'//rootNode/nodeItem[2]/data','',DATA$H)
  ERR$ = XDOMLocateNode(DATA$H, XDOM.CHILD, XDOM.FIRST.CHILD, XDOM.TEXT.NODE, TEXT.NODE)
  ERR$ = XDOMGetNodeValue(TEXT.NODE, DATA$VALUE)
All nodes are not created equal.
shareedit