.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Schema changes executed out of order; how do I sync schema + data changes?

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :
Hi.  I've been having a problem with replication for some time now that I finally need to see if there's a better way to deal with.  My entire setup is SQL 2008; Standard on the server (publisher) and Express on the laptops (subscribers); I'm using Merge pull subscriptions and my situation is a lot like the classic travelling salesman example from the SQL docs (hence why I'm using Merge Pull).

Let's say I want to accomplish the following.  I have an existing database, with data in it, with Table A and Table B which have no relationship.  However, I'd like to do add a column, named Foo, to Table B which references the PK of Table A.  Furthermore, I'd like add a row to Table A, then make that the PK of that row the default value of the new column in Table B (all existing rows in B would have this value).  Finally, the new column in Table B must be set NOT NULL.

Normally, to do the above, I'd write a script like so to accomplish it:
a) Add row in Table A
b) Get ID of new row using @@Identity
c) Create column Foo in Table

View Complete Post

More Related Resource Links

Data Points: Updating Data in Linked Servers, Information Schema Views, and More


Every day a developer somewhere needs to write code to iterate through SQL ServerT system objects, query and update tables in linked servers, handle optimistic concurrency, and retrieve column and stored procedure metadata.

John Papa

MSDN Magazine November 2004

Metadata: Create a Database Schema Repository with Meta Data Services in SQL Server 2000


SQL Server 2000 Meta Data Services is a repository technology that stores and manages metadata for SQL Server. Instead of building database schemas over and over, Meta Data Services allows you to freeze an entire schema for use in other projects. You can also use these schemas for training, testing, or debugging. In this article, the authors will review the various components of Meta Data Services and show how it can be programmed using a Visual Basic client, XML, and XSLT. They will also show you how to manage and manipulate your metadata by generating a simple database schema using a SQL Server repository.

Alok Mehta and Ricardo Rodriguez

MSDN Magazine May 2003

data contract code generation for large/complex schema (HR-XML/OAGIS) - is there an alternative?

Hello, and thank you for reading.I am implementing a Service based on a predefined specification (HR-XML 3.0). As such, I am starting with the schema, and working my way back to code. There are a number of large Schema documents (which import yet more Schema documents) related to my implementation, provided by this specification.I am able to generate code using xsd.exe, by supplying the "main" and "supporting" xsd files as arguments. But there are several issues, and I am wondering if this is the right approach.- there are litterally hundreds of classes - the code file is half a meg in size- duplicate classes (ex. Type, Type1 - which both represent the same type)- there are classes declared as inheriting from a base class, but that base class is not generated/definedI understand that there are limitations to the types of Schema supported by svcutil.exe/xsd.exe when targeting the DataContractSerializer and even XmlSerializer. My question is two-fold:1. Are code generation "issues" fairly common when dealing with larger, modular xsd files? Has anyone had success with generating data contracts from OAGIS or HR-XML schema?2. Given the above issues, are there better approaches to this task, avoiding generating code and working with concrete objects? Does it make better sence to read and compose a SOAP message directly, while sti

Merge data from two different databases with the same schema

I am writing an iPhone web app for tracking business mileage. The app uses AJAX and HTML 5 manifest caching to enable offline use. The data is stored on the server in a SQL Server database with the following schema:  When there is no network available, the app stores new data in a local database with the same schema using SQLite on the iPhone. Once a connection is aquired, the app automatically uploads the new data to the main database for permanent storage. Now, here's the question: I have data from two databases with the same schema. How do I merge the new data into the main database using LINQ? The primary key IDs in the new data must be discarded and regenerated by the main database so that there are no ID conflicts, but the two relationships must be maintained properly. What is the easiest way to do this? Any help would be greatly appreciated.

Sanpshot Replication of all objects and Table Schema but no Data


Can this be done? I just want all database objects to be pushed out to a subscriber once a week via snapshot replication. Procs, tables, triggers, functions etc but I dont want any of the table data

Thanks in advance

data from SQL to XML with teh defined elemst frm the schema

with reference to the above link
i am able to take data from xml to sql
how do i d othe reverse
ie put data from SQL to XML with teh defined elemst frm the schema

Schema missing from Data Source definition


I am attempting to use a view from a SQL Server database in a data grid on my SP10 site. I set up the External Content Type, created the Data View... The data source reported a "non-specific error" from the server. Went back to my Data Source definition and noticed something: In the Data Source Properties window, the view's schema is missing. That is, the table shows "Table: .ViewName" instead of "Table: Schema.ViewName".

So I suspect this is the problem. However, how do I fix this? The configuration wizard shows all of the tables in the database, but omits the schema names. There is no apparent way to make sure that the schema names appear.

Trying to import excel data into dbo schema using odbc connection with sql server


I have written this vb.net code to import an excel spread sheet but need for it to imported into the dbo shema. When I look in the database the table name is me.tablename instead of dbo.tablename.

    Public Sub Main()
        Dim sheetname As String
        excelpath = "S:\Account Management\jkormann\DynamicScoring\GE_Money_MN.xls"
        ServerName = "server"
        DBName = "sf"
        'SchemaName = "dbo"
        InsertedTableName = Dts.Variables("strTableName").Value.ToString
        sheetname = Dts.Variables("strSheet").Value.ToString
        'ImporttoServer(CStr(ExcelPath), CStr(ServerName), CStr(DBName), CStr(SchemaName), CStr(InsertedTableName))
        ImporttoServer(CStr(ExcelPath), CStr(ServerName), CStr(DBName), CStr(InsertedTableName), CStr(sheetname))

        Dts.TaskResult = Dts.Results.Success

Updating Data-Tier Application project after schema change has been made in SSMS

I have successfully created a Data-Tier Application project within visual studio. How do I update these scripts to reflect the changes made by a DBA in SSMS?  Also, on another project we use Entity Framework which drops and recreates the database from within the application. I would also like to import these changes into the Data-Tier Application project.
I can figure out how to import the database into the project the very first time. But after a change has been made using another tool, how do I synchronize the project in visual studio?
When I create a schema comparison that points from database -> project, it correctly analyzes the schema changes. Am I missing how to update the project with these changes?
Thanks, I really would like a solution to this so I can use Data-Tier Applications instead of a third party tool.

How to extract a schema from a sql server database



  I need to extract or get the schema from tables in my databse and what is the best way to do it. Is there any third party tool to do it??


Any idea will be appreciated..



Contract-First Web Services: Schema-based Development with Windows Communication Foundation


Schema- first contract-first modeling of Web Services gives you the ability to model your contracts with an XML-centric mindset. This process keeps you focused on universally acceptable types and the hierarchical data structures that can be represented in XML.

Christian Weyer, Buddhike de Silva

MSDN Magazine October 2009

Sync Up: Manage Your Data Effectively With The Microsoft Sync Framework


Synchronization Services for ADO.NET provide a set of tools to help you synchronize data between two database sources, synchronize files between machines, and synchronize with an RSS or ATOM feed. Learn more here.

James Yip

MSDN Magazine April 2009

Class To Contract: Enrich Your XML Serialization With Schema Providers In The .NET Framework


The Microsoft .NET Framework 1.x provided minimal options for mapping classes to schemas and serializing objects to XML documents, making this sort of mapping quite a challenge. The .NET Framework 2.0 changes all this with Schema providers and the IXmlSerializable interface.

Keith Pijanowski

MSDN Magazine June 2006

Web Services: Extend the ASP.NET WebMethod Framework by Adding XML Schema Validation


WebMethods make the development of XML Web Services easier by encapsulating a good deal of functionality, but there is still a lot of underlying XML processing that you have to be responsible for. For example, WebMethods do not validate messages against the implied schema. Because they are not validated, the response that's returned can result in unintended consequences. To address this, the authors extend the WebMethod framework by adding XML Schema validation through a custom SoapExtension class.

Aaron Skonnard and Dan Sullivan

MSDN Magazine July 2003

Design: Place XML Message Design Ahead of Schema Planning to Improve Web Service Interoperability


Web Services are all about exchanging data in the form of XML messages. If you were about to design a database schema, you probably wouldn't let your tool do it for you. You'd hand-tool it yourself to ensure maximum efficiency. In this article, the author maintains that designing a Web Service should be no different. You should know what kind of data will be returned by Web Service requests and use the structure of that data to design the most efficient message format. Here you'll learn how to make that determination and how to build your Web Service around the message structure.

Yasser Shohoud

MSDN Magazine December 2002

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend