SQL Server 2005: problem with old SQL Server 2000 database - sql-server-2005

I attached database from SQL Server 2000 to SQL Server 2005 and it worked well but I had column called (Add Date) which had the Date time of input data and when I insert new data after attached data base to SQL Server 2005 the new data insert with same data 12.00 also it converted all old date to 12.00.
Please anyone help me how I can solved this problem also how can retrieved old Date time ?

I would start of with the obvious first
Check the columns properties to make there there isn't any default value being applied
Change the database compatablity level to make sure its set to SQL Server 2005 (90) (Right click on database Properties > Options Tab)
EDIT:
If you wanting to formated what date gets inserted into the (Add Date) field you can use the CONVERT or CAST function.

solution 1:
attach old database again, named it "old_bak"
and then write t-sql like this:
UPDATE XX
SET col = T.col
WHERE
XX.id = old_bak.dbo.XX.id
then the old data will retrieved!
solution 2:
rollback your database from .bak file
and execute your sql statement again
I doubt that your sql statement is "update", not "insert". or it won't be like that.

Related

Migrate table from Oracle to SQL Server

Migrate a table from Oracle to SQL Server.
I have used Toad to export (select * from table) into a pipe delimited .txt file so it can be used to be consumed in SQL Server. Now the Oracle table has a DATE column and the output from Toad for that column is (2/26/2016 3.05.10.000000 PM). This format is not being compatible for the datetime column in SQL Server side.
I feel we can convert the date in Oracle to a compatible SQL Server format for easier ingestion.
Please help me understand the conversion both from Oracle to a compatible SQL Server format.
Create Oracle Linked server in SQL Server with ODBC connection. and use that Linked server to play with Oracle and SQL Server tables using SQL Server.
You must understand that DATE datatypes are binary data. Using to_date() on a column that is already a DATE is inappropriate. It forces oracle to perform (behind the scenes) a to_char() on the DATE column in order to produce character data that is the required input to to_date(). Then, when you see (in your text csv file) that it has produced a "date" in some particular format, it is because oracle has then had to run the result of your to_date() back through to_char(), using the default NLS_DATE_FORMAT setting to produce a character string for the text output.
So your solution is this:
First, determine what text format of a date MSSQL wants when it uses this csv file. I don't know what that is, but for the sake of argument, let's say it is 'yyyy-mm-dd'. With that information, construct your SELECT in oracle like this:
select mycol1,
to_char(my_date_col,'yyyy-mm-dd'),
mycol2
from my_table;
That said, I agree with the others, why bother with this cumbersome process in the first place? Or even some other intermediary like SSIS? Why not just create a shared server in MSSQL and query the oracle table directly? Or create a database link in the Oracle DB and, using the oracle transparent gateway as the conduit, INSERT directly into the MSSQL table from Oracle? Either the linked server or the database link will be much faster than any external process.
I would suggest a best way to transfer Oracle table to SQL Serveris by using SSIS package.
You can have a Source as Oracle and your conversion issue can be fixed by Data
Conversion task and your Destination can be SQL Server.

SSIS not updating table after insert

I have an SSIS package that sends data from SQL 2014 to an Oracle 11G DB. No issues connecting or transferring the data to Oracle but it fails when updating the source SQL tables. SSIS give ORA-00971:missing SET keyword
Based on the below why would Oracle be looking for a SET keyword? The update statement is on the SQL database
I've switch connections to reflect the SQL tables (errors resolving the Oracle table names then)
UPDATE INTERFACE.dbo.TURN
SET INTERFACE.dbo.TURN.DUPLICADO =
INTERFACE.dbo.TURN.DUPLICADO + 100
WHERE EXISTS
(SELECT
*
FROM [REMOTEORA]..[REMOTEORA].[TURN_BALANCE] BO
WHERE BO.[TURN_BALANCE].[ID_TURN]=INTERFACE.dbo.TURN.N_TURNO AND BO.
[ID_PLACES]
= INTERFACE.dbo.TURN.ID_LUGAR AND
BO.DT_CLOSE =INTERFACE.dbo.TURNO.FIN_TURNO)
AND (INTERFACE.dbo.TURN.DUPLICADO < 100)
First changing the connection for the updating piece to the SQL server resolved the ORA error but the updates were still failing and calling TURN_BALANCE a column. Altering the table alias to four letters (BOYO) vs the two (BO) completely resolved the issue

Azure SQL in SQL Server Management Studio 17 - Can't edit data manually

I have a table, which I have clicked Edit top 200 rows, as I wish to flip a cell in one of my columns which is smallint from a 0 to a 1. Every time I change the cell's data from a 0 to a 1 it is automatically changed back to a 0.
It seems that all of my columns are immutable in this way, what am I missing so that I can edit data in my sql database table manually for testing? I am using SQL Server Management Studio 17.
When using Microsoft SQL Server Migration Assistant which converts a MySQL database to an MSSQL or Azure Sql database, triggers are generated for you during the migration and added to your SQL tables.
In my case, these were stopping me from updating and inserting to my table, so I deleted them.

Sql Server 2000 - table last modified

Does anyone know of ANY way to query a Sql Server 2000 database to find out when tables were last modified please?
It is unfortunately not stored in SQL 2000 unless you have custom columns storing that type of data for the table. So if you are looking for something built into SQL Server you are sadly out of luck.

How to automatically update database SQL Server?

I need a field (column) of my database to update automatically. For example, the field NUMBER for each record incrementing every minute. How can I do it? I am using SQL Server.
You're probably looking for something called SQL Server Agent jobs
here is a good starting point reference:
http://technet.microsoft.com/en-us/library/ms181153(v=sql.105).aspx
This allows you to run some sql code on a schedule of your choosing.
P.S.
If you have access to sql server management studio, the GUI is much nicer.
You can set up a SQL Agent job to run an update statement once a minute:
UPDATE tablename
SET NUMBER = NUMBER + 1
Job Agent is only for full SQL Server. Then best choise. If you using SQL express then can't. You can solve with update
UPDATE TABLE-NAME SET
VALUE = VALUE + 1