Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6196565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:39:56+00:00 2026-05-24T03:39:56+00:00

I am moving data from different source types like Oracle, MySQL, Access, Sharepoint etc

  • 0

I am moving data from different source types like Oracle, MySQL, Access, Sharepoint etc to SQL.

A SQL script is generated in c# like this:

with cte (ID, changedate, SupplierID) 
as (
SELECT 1720,  '1997-12-17 12:00:00 AM',  763
UNION ALL
SELECT 1721,  '1900-01-01 12:00:00 AM',  114)
 select * into components8_2_2011_3  from cte

The datatime fields is created as varchar which is wrong.

In C# I can see that the column type is datetime, but MSSQL does not recognize the string as datetime.

How would I go about getting the above script to create a datetime field WITHOUT adding a CAST statement to the changeDate field?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:39:58+00:00Added an answer on May 24, 2026 at 3:39 am

    How about using a “guide row”

    with cte (ID, changedate, SupplierID) as (
       --type but no data
       select 0, getdate(), 0 where 0=1 union 
    
       SELECT 1720,  '1997-12-17 12:00:00 AM',  763
       UNION ALL
       SELECT 1721,  '1900-01-01 12:00:00 AM',  114
    )
    select * into components8_2_2011_3  from cte
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When moving a file from old.package to new.package I want two things to happen:
I am interested in moving a number of my projects from Visual Studio and
My team is moving from Visual SourceSafe to Subversion soon, while developing/supporting a legacy
We are planning on moving for MS Source Safe (ouch) to SVN. We are
We're looking at moving from a check-out/edit/check-in style of version control system to Subversion,
Moving through the maze forward is pretty easy, but I can't seem to figure
Before moving on to use SVN, I used to manage my project by simply
Simply moving the file to ~/.Trash/ will not work, as if the file os
After moving to .NET 2.0+ is there ever a reason to still use the
When moving my .Net Compact Framework application to the SD-card of a Windows CE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.