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 |
|
companionz
Yak Posting Veteran
54 Posts |
Posted - 2009-07-08 : 04:41:01
|
| i want to insert run time values into table how to do this?something like this:Declare @temp varchar(10)Declare @temp1 varchar(20)Declare @temp3 varchar(20)set @temp = 'asd'set @temp1 = 'asdfsdf'set @temp3 = 'testubg'insert into tempprintselect @temp, ''@temp1'+ @temp1 '', '@temp3 + '@temp3''Thanks,Sourav |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-08 : 04:49:11
|
table tempprint has how many columns ? What are the data type of these columns ?How do you want to insert into the table ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-08 : 04:56:57
|
| What do you expect from this?select @temp, ''@temp1'+ @temp1 '', '@temp3 + '@temp3''MadhivananFailing to plan is Planning to fail |
 |
|
|
companionz
Yak Posting Veteran
54 Posts |
Posted - 2009-07-08 : 05:04:48
|
| Table tempprint definition:Columns datatype-------- ---------Procname varcharprintdata varcharperiod datetimeits just that i want to insert values of multiple variables with the name of the variable in printdata column. Thanks,Sourav |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-08 : 05:12:12
|
maybe something like thisinsert into tempprint (Procname, printdata, period)select @temp, '@temp1 ' + @temp1 + ' ' + '@temp3 ' + @temp3, getdate() KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
companionz
Yak Posting Veteran
54 Posts |
Posted - 2009-07-08 : 05:20:06
|
| @khtanIt works but the issue is that i've around 20 variables that are to be inserted in printdata field.. Now the datatype for those variables are varchar, tinyint, datetime etc.. i mean mix of datatypes.. How to go about that?Thanks,Sourav |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-08 : 05:25:18
|
if it is not a string data type you have to convert to string before concatenatedeclare @temp4 intinsert into tempprint (Procname, printdata, period)select @temp, '@temp1 ' + @temp1 + ' ' + '@temp3 ' + @temp3 + ' ' + @temp4 ' + convert(varchar(10), @temp4), getdate() KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
companionz
Yak Posting Veteran
54 Posts |
Posted - 2009-07-08 : 10:00:08
|
| It helped.. Thanks |
 |
|
|
|
|
|
|
|