Author |
Topic |
ranjeetsingh_6
Posting Yak Master
125 Posts |
Posted - 2006-09-09 : 04:38:20
|
HiI want to insert values in a table like asdeclare @name varchar(10)set @name='Ranjeet'INSERT INTO TempAddPlace values (select id from Tablename,@name)means want to insert some select records from a table and also some variable.Ranjeet Kumar Singh |
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-09-09 : 04:53:18
|
Somthing like this ??INSERT INTO TempAddPlace values (select id,@name from Tablename)Chirag |
|
|
ranjeetsingh_6
Posting Yak Master
125 Posts |
Posted - 2006-09-09 : 04:56:48
|
Hivariable @name have calculated value not come from a TableRanjeet Kumar Singh |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-09-09 : 05:00:55
|
Post what are you trying to do??Yeah, if you want insert the calculated value into any column then this is the method to do so... Chirag |
|
|
ranjeetsingh_6
Posting Yak Master
125 Posts |
Posted - 2006-09-09 : 05:08:33
|
Hideclare @place varchar(50)set @place='London'(This value Comeing from search a table and have a large code of function )INSERT INTO TempAddPlace values (select id from Tablename,@place)Ranjeet Kumar Singh |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-09-09 : 05:13:44
|
oks, so what you want to do with @place variable, you require to insert the value 'London' in some column of TempAddPlace or London is the Table and you want to do cross join with the < TableName >and then insert the values into TempAddPlace???Chirag |
|
|
ranjeetsingh_6
Posting Yak Master
125 Posts |
Posted - 2006-09-09 : 05:26:02
|
This is my function to Find place this will return place CREATE FUNCTION place(@lat float,@log float) RETURNS varchar(128) AS BEGIN declare @la11 float,@lon1 float,@var varchar(30),@latv1 varchar(30),@lonv1 varchar(30),@latmap varchar(30),@lonmap varchar(30),@latv11 varchar(30),@lonv11 varchar(30), @dis floatselect @la11 = Lat FROM VEHICLETRACK where lat=@lat and lon=@logselect @lon1 = Lon FROM VEHICLETRACK where lat=@lat and lon=@logselect @var=CONVERT(varchar(30),@la11,0)select @latv1=SUBSTRING(@var,1,9)select @var=CONVERT(varchar(30),@lon1,0)select @lonv1=SUBSTRING(@var,1,9)--select @latv1,@lonv1declare @count integerselect @count=count(name) from Map_Places_Indiadeclare @i integer,@CID integerset @i=1--set @CID=@iwhile @i<@countbeginselect @la11 = Lat FROM Map_Places_India where id=@iselect @lon1 = Lon FROM Map_Places_India where id=@iselect @var=CONVERT(varchar(30),@la11,0)select @latv11=SUBSTRING(@var,1,9)select @var=CONVERT(varchar(30),@lon1,0)select @lonv11=SUBSTRING(@var,1,9)if @i=1 beginset @dis=dbo.distance(@latv1,@latv11,@lonv1,@lonv11)--set select @CID= id from Map_Places_India where id=@iset @CID=@iendelsebegindeclare @zz floatset @zz=dbo.distance(@latv1,@latv11,@lonv1,@lonv11)if @zz<@disbeginset @dis=@zz--set select @CID= id from Map_Places_India where id=@iset @CID=@iendendset @i=@i+1enddeclare @position varchar(50)--select @i as Counter--select @CID as CIDselect @position= name from Map_Places_India where id=@CIDdeclare @place varchar(50)--select @dis as Distance + 'Km From'+ @position--select @position as Position declare @place1 varchar(128)SELECT @place1=CONVERT(varchar(30), @dis) +' ' + 'Km. From'+' ' + CONVERT(varchar(30), @position)RETURN( @place1) END declare @name varchar(10)set @name=dbo.place(28.89765432,77.2345678) INSERT INTO TempAddPlace values (select id from Tablename,@name) Ranjeet Kumar Singh |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-09-09 : 05:31:17
|
I guess you want somthing like this Insert Into TempAddPlaceSelect Dbo.Place(28.89765432,77.2345678) ???Or post the table structure of TempAddPlace...Chirag |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|