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 |
|
java148
Yak Posting Veteran
63 Posts |
Posted - 2011-11-09 : 16:50:17
|
where is the syntax error ? it said "Incorrect syntax near 'col1'", but my table has this column. Please help.Thanksuse test1GOcreate table #tmpTbl(col1 varchar(max), col2 varchar(max))GOinsert into #tmpTbl values('ddd', 'fff');GOselect col1, col2, GETDATE() into test1..ddd(col1, col2, insertTime)from #tmpTbl |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-11-09 : 17:03:07
|
quote: Originally posted by java148 where is the syntax error ? it said "Incorrect syntax near 'col1'", but my table has this column. Please help.Thanksuse test1GOcreate table #tmpTbl(col1 varchar(max), col2 varchar(max))GOinsert into #tmpTbl values('ddd', 'fff');GOselect col1, col2, GETDATE() as insertTimeinto test1..ddd(col1, col2, insertTime)from #tmpTbl
|
 |
|
|
java148
Yak Posting Veteran
63 Posts |
Posted - 2011-11-09 : 17:06:48
|
| thanks |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-11-09 : 17:09:35
|
Welcome |
 |
|
|
java148
Yak Posting Veteran
63 Posts |
Posted - 2011-11-09 : 21:25:37
|
this is my final version. Thankscreate table #tmpTbl(col1 varchar(max), col2 varchar(max))GOinsert into #tmpTbl values('ddd', 'fff');create table tmpTbl(col1 varchar(max), col2 varchar(max), insertTime datetime)insert into tmpTbl(col1 , col2 , insertTime)select col1 as col1, col2 as col2, GETDATE() as insertTime from #tmpTblselect * from tmpTbldrop table tmpTbl; |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-10 : 01:22:46
|
quote: Originally posted by java148 this is my final version. Thankscreate table #tmpTbl(col1 varchar(max), col2 varchar(max))GOinsert into #tmpTbl values('ddd', 'fff');create table tmpTbl(col1 varchar(max), col2 varchar(max), insertTime datetime)insert into tmpTbl(col1 , col2 , insertTime)select col1 as col1, col2 as col2, GETDATE() as insertTime from #tmpTblselect * from tmpTbldrop table tmpTbl;
i see lots of varchar(max) fields hereunless its abosolutely necessary dont use varchar(max) for storing the string data. always consider what will be maximum amount of data that you would require storing before determining data type. This will make sure you dont use up unnecessary resources and also retrieval operations will be much more optimised------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|