I want to generate the database script of sql server 2008. I want to generate only updates from particular date. how to do this?
Your question is kind of unclear. Do you want to generate a database script that creates the tables or inserts data?
If it is data you can create selects that outputs what would be valid inserts:
create table test (a int, b int, c int);
select 'insert into test (a,b,c) values
('+convert(varchar, a)+','+convert(varchar, b)+','+convert(varchar, c)+');'
from test
On the select you could add a where clause where you only obtain data from a given date.
Edit:
It looks like someone has discussed how to find changes between databases already on some other discussion forum. Have a look at:
http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=27234
Related
I don't know if SQL SERVER have this feature.
Operation over a period of time,you can export the corresponding sql statement script.contain "insert,update,delete,alter table etc".
For example:Every night,I open generated .sql file,I can see full day operation.in this file,contains many sql statement as follow
insert into ...
update ....
delete ...
create table ...
drop table ...
alter table ...
My English is not better,please forgive me.
Thanks.
No - sql server does not provide this functionality. But at the others suggest, perhaps your goal can be achieved in a different fashion.
ETL Script to dynamically map multiple execute sql resultset to multiple tables (table name based on sql file provided)
I have a source folder with sql files ( I can put it up as stored procedures as well ) . I know how to loop and execute sql tasks in a foreach container. Now the part where I'm stuck is I need to use the final result set of each sql queries and shove it into a table with the same name as the sql file.
So, Folder -> script1.sql , script2.sql etc -> ETL -> goes to table script1, table script2 etc.
EDIT : Based on the comment made by Joe, I just want to say that I'm aware of using insert within a script but I need to insert it onto a table in a different server.And Linked servers are not the ideal solutions
Any psuedocode or link to tutorials will be extremely helpful . Thanks!
I would add the table creation to the script. It is probably the simplest way to do this. If your script is Select SomeField From Table1, you could change it to Select SomeField Into Table script1 From Table1. Then there is no need to map in SSIS which is not easy to do from my experience.
I have one table named "Staff" in access and also have this table(same name) in SQL 2008.
Both table have thousands of records. I want to merge records from the access table to sql table without affecting the existing records in sql. Normally, I just export using OCBC driver and that works fine if that table doesn't exist in sql server. Please advise. Thanks.
A simple append query from the local access table to the linked sql server table should work just fine in this case.
So, just drop in the first (from) table into the query builder. Then change the query type to append, and you are prompted for the append table name.
From that point on, just drop in the columns you want (do not drop in the PK column, as they need not be used nor transferred in this case).
You can also type in the sql directly in the query builder. Either way, you will wind up with something like:
INSERT INTO dbo_custsql
( ADMINID, Amount, Notes, Status )
SELECT ADMINID, Amount, Notes, Status
FROM custsql1;
This may help: http://www.red-gate.com/products/sql-development/sql-compare/
Or you could write a simple program to read from each data set and do the comparison, adding, updating, and deleting, etc.
I have one problem in which i simply want to know how i can create a table that can easily Used as a back end for my solution that is in Vb 2010.
I also want to know that when we choose a data source in a vb.net that is for sql server Which we want to choose....simply which can be used Because there is 2 or 3 with little different name.....
I'm struggling to understand your question, but in an effort to help:
I'm guessing that you want to programmatically create a table to be used by other parts of your VB application, but that you need to ensure the table name is unique...? If I'm right in that assumption, then see below.
You can use this query:
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE table_type = 'BASE TABLE'
To get a list of table names currently in your database. You can compare the TABLE_NAME column values with your desired table name. If it exists already, change the name by adding an differentiator, eg: MyTable, MyTable1, MyTable2 etc.
Alternatively, SQL Server accepts Guids as table names.
Disclaimer: IMHO, If your table is not going to be temporary deciding table names in this manner is a pretty ugly solution and lacks supportability.
I have 2 Oracle questions
How do I translate this SQL Server statement to work on Oracle?
Create table MyCount(Line int identity(1,1))
What is the equivalent of SQL Servers Image type for storing pictures in an Orace database?
You don't need to use triggers for this if you manage the inserts:
CREATE SEQUENCE seq;
CREATE TABLE mycount
(
line NUMBER(10,0)
);
Then, to insert a value:
INSERT INTO mycount(line) VALUES (seq.nextval);
For images, you can use BLOBs to store any binary data or BFILE to manage more or less as a BLOB but the data is stored on file system, for instance a jpg file.
References:
Create Sequence reference.
Create table reference.
Oracle® Database Application Developer's Guide - Large Objects.
1: You'll have to create a sequence and a trigger
CREATE SEQUENCE MyCountIdSeq;
CREATE TABLE MyCount (
Line INTEGER NOT NULL,
...
);
CREATE TRIGGER MyCountInsTrg BEFORE INSERT ON MyCount FOR EACH ROW AS
BEGIN
SELECT MyCountIdSeq.NEXTVAL INTO :new.Line
END;
/
2: BLOB.
Our tools can answer these questions for you. I'm talking about Oracle SQL Developer.
First - it has a Create Table wizard - and 12/18c Database supports native implementation of Identity columns.
And your new table DDL
CREATE TABLE MYCOUNT
(
LINE INT GENERATED ALWAYS AS IDENTITY NOT NULL
);
Also, we have a Translator - it can take SQL Server bits and turn them into equivalent Oracle bits. There's a full-blown migration wizard which will capture and convert your entire data model.
But for one-offs, you can use your Scratchpad. It's available under the Tools, Migrations menu.
Here it is taking your code and giving you something that would work in any Oracle Database.
Definitely use the identity feature in 12/18c if you're on that version of Oracle. Fewer db objects to maintain.