zberg007
asked on
How to Convert varchar Date String into DateTime in a Stored Procedure
I have this stored procedure:
I need to modify it so that as it's buk inserting date fields, it converts them into the datetime values for my datetime columns.
Any easy way to do this?
USE [ETL]
GO
/****** Object: StoredProcedure [dbo].[LoadALSTable] Script Date: 03/02/2011 17:33:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[LoadALSTable]
AS
SET NOCOUNT ON
TRUNCATE TABLE dbo.ALSImportTable
BULK INSERT dbo.ALSImportTable FROM 'C:\Sites\_IMPORT.csv'
WITH (FIELDTERMINATOR = ',', FIRSTROW = 2)
RETURN (@@ERROR)
I need to modify it so that as it's buk inserting date fields, it converts them into the datetime values for my datetime columns.
Any easy way to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both of these experts helped on this solution. Thanks!
if non datetime data occured.
Better you use bulk Insert as same varchar datatype and then convert that column data type.
How ever dbaSQL sugesstion is good for converting Varchar data to datetime