I have an existing SSDT solution and I want to add up the alter table scripts in the solutions and running on the SSDT solution such that the tables are updated according to the scripts?
Example: if I already have a table student with two columns sid and sname and I have a script which add up new column city to the table How can I do this such that table is updated?
So in your live database you have changed it and you want the change to be in SSDT?
If this is the case, do a schema compare with the project as the destination and database as the source - you can choose what to update and it will update the project instead of the database.
Related
Lets say I create a table in snowflake called Employee with EmployeeID and EmployeeName. I would check in the Create table script for this table to my github repo and get this deployed using sqitch. If in the next release, there is a need to add a new column to this table, can I accomplish this by just adding a new column to the existing Create table scripts. Does sqitch have the ability to compare github and my target DB to understand and generate ALTER scripts in this case?
Never mind, I did some more research and figured that Sqitch follows the imperative approach. Which means that it needs us to write the Alter statements in this case.
I need to do an Oracle data migration from 11g to 12c where schema changes are abundant. I have an excel sheet which describes all the schema changes. Excel sheet has the columns for 'old_table_name', 'old_column_name', 'old_value' and same for the new tables. Some values can be directly copied to the new table and some cannot be done that way.
For example I have to transform the old column value when it is moved to the new table. Some transformation are complex and they cannot be simply mapped. They should be transformed by joining with other tables in the old database. I was trying the Talend Open Studio Data Integration tool for this and found it is a bit complex to go ahead with that tool in my case. Does anyone have an idea of getting this done using Talend or any other tool? What is the ideal approach when doing a migration like this? I have included a sample of the excel sheet below which only has simple transformations.
The kind of converions shown in the spreadsheet can all be performed on the table itself using rename statements and/or basic ddl and dml statements. I would load the old table into the new database and perform these statement on the table.
alter table
old_table_one
rename to
new_table_one;
alter table
new_table_one
rename column
old_col_one
to
new_col_one;
update new_table_one
set new_col_one = 'A_NEW'
where new_col_one = 'A';
etc.
I Want to know the sourse of this table. How it is calculated from the table. I am using sql server r2 2008 and I searched for that table, but it is not there. It is formed by manipulating some rows of different tables. Is there any way to find it. I searched the corresponding table in VB 6 also. but it is not there. Is there Any way to find the source table?
Source in local variables is :
"Select * From #70554TempShiz52"
Tables with name starting with # or ## are temporary tables (Quick Overview: Temporary Tables in SQL Server 2005).
The table exists only as long as the connection in which table was created exists. It is accessible only from connection which has created it.
To find the table you should look for an appropriate statement CREATE TABLE #70554TempShiz52 in the code.
The table is exists in tempdb database. An admin can see it there using ssms (only when the connection is still open and table was not dropped). I usually put a breakpoint to achieve desired state. The name of the table looks like #70554TempShiz52__________...some number (to distinguish tables from other users).
I can be useful to use a name starting with ## for debugging because such a table is visible from other connections.
Am I missing something here? It seems that the only options to create a new table in a database project in VS2010 is:
Create a table object as a file, then create all constraints (defaults) as separate files, then create each index as a separate file, and primary key as a separate file and on and on...
Or
Create the entire table schema using the table designer in SSMS and then use the schema compare tool to create a single monolithic file of SQL statements for each element of the table and copy each block of code to a newly created file in VS.
This question was asked 2 years ago and I'm hoping the answer has changed.
Please tell me there's a hidden table designer for the database project in VS2010 that I have just overlooked.
I'm pretty sure there isn't one!
Can I ask why you need a table designer over creating and modifying creation script files for your new objects? Is there anything that this doesn't give you that a designer would?
I just noticed that VS 11 Beta now includes a designer, although it is rough around the edges (relationships, for example, still need to be typed by hand).
The way I use the database project in VS2010 is:
Create everything with SQL Server Management Studio.
Synchronize it into my database project.
When I need to change something, do it in SQL Server Management Studio.
Use Schema Comparisons to synchronize your database project.
Wow... can't believe no one has taken the time to answer this in all this time. Here's a sample of table creation script with some simple constraints.
CREATE TABLE [User]
(
UserID INT NOT NULL IDENTITY (1,1),
UserName NVARCHAR(20) NOT NULL,
UserPassword NVARCHAR(20) NOT NULL,
EmailAddress NVARCHAR(50) NOT NULL,
Location NVARCHAR(100),
MobileNumber VARCHAR(10),
CreatedDate DATETIME NOT NULL
CONSTRAINT User_CreatedDate_DF DEFAULT (GETDATE()),
CONSTRAINT User_UserID_PK PRIMARY KEY CLUSTERED (UserID),
CONSTRAINT User_UserName_UQ UNIQUE (UserName),
CONSTRAINT User_EmailAddress_CK CHECK (EmailAddress LIKE '%#%.%'),
CONSTRAINT User_MobileNumber_CK CHECK (MobileNumber LIKE '[2-9][0-9][0-9][2-9][0-9][0-9][0-9][0-9][0-9][0-9]')
)
You can use functions to embed in your check constraints, but again, this is a simplistic exaxmple.
As I commented here, the VS2010 reference states that there exist a Table Designer in this document.
But for some reason, no matter what kind of project I create (Server project 2008/2005, database project 2008/2005) I can't get the Table Designer being shown.
I have 62 columns in a table under SQL 2005 and LINQ to SQL doesn't handle the updates though the reading would work just fine, I tried re-adding the table to the model, created a new data model but nothing worked, I'm guessing I've hit the maximum number of columns limit on an object, can anyone explain that ?
I suspect there is some issue with an identity or timestamp column (something autogenerated on the SQL server). Make sure that any column that is autogenerated is marked that way in the model. You might also want to look at how it is handling concurrency. If you have triggers that update any values on the row after it is updated (changing values) and it is checking all columns on updates, this would cause the update to fail. Typically I create my tables with a timestamp column -- LINQ2SQL picks this up when I generate the model and uses it alone for concurrency.
Solved, either one of the following two
-I'm using a UniqueIdentifier column that was not set as Primary key
-Set Unique ID primary key, checked the properties of the same column in Server Explorer and it was still not showing as Primary key, refreshed the connection,dropped the same table on the model and voila.
So I assume I made a change to my model some time before, deleted the table from the model and added the same from the Server explorer without refreshing the connection and it never used to work.
Question is, does VS Server Explorer maintain it's own table schema and requires connection refresh everytime a change is made in the database ?
There is no limit to the number of columns LINQ to SQL will handle.
Have you got other tables updating successfully?
What else is different about how you are accessing the table content?