-
Merging tables
Always please MS SQL only
And thanks in advance for you wonderful people: We need to import a database, merging tables. The snag is that one of the databases has a column of dates in datetime format. The other database has a column of dates entered as nvarchar in the format of 20040319 to represent 3-19-2004.
Is there a way to convert those nvarchar numbers to a format acceptable to Sequel's datetime column?
-
Yes.
example:
create table mydate(date nvarchar(10))
create table yourdate(date datetime)
insert into mydate select '20040329'
insert into mydate select '20030329'
insert into mydate select '20020227'
insert into mydate select '20041224'
insert into mydate select '20041201'
insert into yourdate select convert(datetime,date,112) from mydate
select * from yourdate
-
Merging info
Hi -- in your reply, can't get it to work. don't understand. I want to convert a column, not create a table. I cannot alter it and get it to work.
Any help?
-
select convert(datetime,date,112) from mydate
here date is the column name. I simulated your nVarchar COlumn table and a datetime column table in that example.
You have to use "convert" function to change the format to datetime (SQL Server acceptable format)
-
or you can use SUBSTRING Function to add "-" in between the date values.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|