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 |
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2005-11-14 : 12:54:59
|
This queryselect 'col1' as Col1,null as col2 into #testinsert into #testselect 'col1','fkljasfhajksfa' gives me an error stating "Syntax error converting the varchar value 'fkljasfhajksfa' to a column of data type int" How do I solve this?ThanksKarunakaran |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-11-14 : 13:20:04
|
| select 'col1' as Col1,convert(varchar(20),null) as col2 into #testinsert into #testselect 'col1','fkljasfhajksfa'==========================================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. |
 |
|
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2005-11-14 : 13:37:23
|
quote: Originally posted by nr select 'col1' as Col1,convert(varchar(20),null) as col2 into #testinsert into #testselect 'col1','fkljasfhajksfa'
Solved it with Cast..Thanks nrKarunakaran |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-15 : 01:51:23
|
| >>gives me an error stating "Syntax error converting the varchar value 'fkljasfhajksfa' to a column of data type int" It is because col2 will be int by defaultYou can also use thisselect 'col1' as Col1,' ' as col2 into #testinsert into #testselect 'col1','fkljasfhajksfa'MadhivananFailing to plan is Planning to fail |
 |
|
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2005-11-15 : 05:09:58
|
quote: Originally posted by madhivanan You can also use thisselect 'col1' as Col1,' ' as col2 into #testinsert into #testselect 'col1','fkljasfhajksfa'
Thats how I tried it first, but it was giving string truncation error because for col2 the length it takes is 1.ThanksKarunakaran |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-15 : 06:35:18
|
Well. In that case you need to specify the data length MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|