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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2007-03-20 : 09:51:44
|
| Stuart writes "Hi being new to this game I have have an error when trying to inseet string into a table with datetime field.the date is not that important its the time that I use in later stepsI am creating a global temp table and then inserting values into itbelow is the code-- create the temp tableExecute ( 'create table ##progsch0 ([Time] [DateTime] , ' + '[' + @day7 + '] [varchar](100) ,' + '[' + @day1 + '] [varchar](100) ,' + '[' + @day2 + '] [varchar](100) ,' + '[' + @day3 + '] [varchar](100) ,' + '[' + @day4 + '] [varchar](100) ,' + '[' + @day5 + '] [varchar](100) ,' + '[' + @day6 + '] [varchar](100) )')set @Starttime = 'JUL 21,2006 5:30am'I am doing the insert in this manor becuase the @Starttime in code actually changes time and a new record in inserted into the temp table.Set @SQL = 'Insert into ##progsch0 (Time) Values(convert(varchar,Convert(datetime,'+ @Starttime +'),100))'PRINT @SQLexecute sp_executesql @SQLI may to doing this in the completely wrong manor.Any help would be greatful " |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-03-20 : 10:01:53
|
| set @Starttime = '20060721 05:30:00'insert ##progsch0 (Time) select @StarttimeNo need to use dynamic sql.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|