July 28, 2010 at 3:45 pm
Use the CAST fuction. If your datetime column is in a format different from the server default you can also use CONVERT and specify the format/style of the date string.
CREATE VIEW View_DSA
AS
SELECT
CAST([CP Code] AS CHAR(<length>) AS [CP Code],
CAST([Time] AS DATETIME) AS [Time],
CAST([Volume] AS INT) AS Volume
FROM DSA
July 28, 2010 at 3:47 pm
its unfortunate that you can't change the table structure to be accurate, why do you need to change them?
however..
CREATE VIEW vDSA AS
SELECT
CAST([CP Code] AS CHAR(5)) AS [CP Code],
CAST([Time] AS DATETIME) AS [Time],
CAST([Volume] AS INT) AS [Volume]
FROM DSA
You might want to also look over: http://msdn.microsoft.com/en-us/library/ms187928.aspx
--------------------------
I long for a job where my databases dont have any pesky users accessing them 🙂
July 28, 2010 at 4:12 pm
Hi
Thankyou very much guys.
@torpkev .... I'm importing data from unformated flat file. If I use correct datatypes in my Table, I'm not able to import data which is why I use VARCHAR and I cant change Datatypes in the Table coz I keep importing new data in my Table, so If I change the Datatypes, as I told you before, I'm not able to import new data from Flat file.
Thanks
Viewing 3 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply