Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi all -In a 'Select..Into' query I'm setting up a few columns as placeholders to be filled in later. If I have as part of my select statement 'Null as ColumnName', the new column is set by default to be an integer type. If I want to put a date in it, I've got a problem. Is there a syntax for setting the data type in the select statement?Thanks much,Tricia
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-10-02 : 03:14:39
yup. use cast
SELECT othercolumns, CAST(NULL AS datetime) AS datecolumn, CAST(NULL AS varchar(12)) AS varcharclumn, CAST(NULL AS Numeric(10,2)) AS Numericcolumn,...INTO #NewTableFROM SOurce