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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL Query to get values in Parameters !!!

Author  Topic 

khanewal
Starting Member

33 Posts

Posted - 2010-08-18 : 09:03:39
HI Friends,

Actually I got output but not sure how to insert this output into another table can you plz give me some idea,

thanks,

Query:

SELECT substring(docid,1,10)+substring(filename,1,4) AS [Documnet ID],x1 AS X,y1 AS Y,x2-x1 AS Width,y2-y1 AS Hight,c.pageid
FROM
training.dbo.main a
inner join training.dbo.main_pages b on b.mainid = a.mainid
inner join dbo.[objects] c on c.page_id = b.page_id



Results:

E.0626.0123 6 0 387 123 39
E.0626.0123 0 2148 638 190 39
E.0626.0125 0 0 373 175 40
E.0626.0127 0 2156 377 182 41
E.0626.0124 1275 2145 373 193 42
E.0626.0124 0 0 526 249 42
E.0626.0126 1154 2142 494 196 43

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-08-18 : 09:12:58
Insert into <table_name> (col1,col2,col3,....)
SELECT substring(docid,1,10)+substring(filename,1,4) AS [Documnet ID],x1 AS X,y1 AS Y,x2-x1 AS Width,y2-y1 AS Hight,c.pageid
FROM
training.dbo.main a
inner join training.dbo.main_pages b on b.mainid = a.mainid
inner join dbo.[objects] c on c.page_id = b.page_id

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-18 : 09:44:01
quote:
Originally posted by senthil_nagore

Insert into <table_name> (col1,col2,col3,....)
SELECT substring(docid,1,10)+substring(filename,1,4) AS [Documnet ID],x1 AS X,y1 AS Y,x2-x1 AS Width,y2-y1 AS Hight,c.pageid
FROM
training.dbo.main a
inner join training.dbo.main_pages b on b.mainid = a.mainid
inner join dbo.[objects] c on c.page_id = b.page_id

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/




make sure number of columns and datatype in insert list
should match with the select list columns.


Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

khanewal
Starting Member

33 Posts

Posted - 2010-08-18 : 19:47:57
I have to get one column value from the below query, how I will fit in the above query, to insert into table ???

SELECT b.FileGuid,b.X, b.Y, b.Width, b.Height FROM SERVER1.DBNAME.DBO.[FILENAME] a
JOIN SERVERNAME.DBNAME.DBO.TableName b ON
a.[guid] = b.fguid

Thanks,

1c5ec1fb-9018-4a60-bbfc-e27b455a0483 337 364 500 150
1c5ec1fb-9018-4a60-bbfc-e27b455a0483 337 364 500 150
1c5ec1fb-9018-4a60-bbfc-e27b455a0483 20 15 500 250
1c5ec1fb-9018-4a60-bbfc-e27b455a0483 20 15 500 250

Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-19 : 03:05:28
quote:
Originally posted by khanewal

I have to get one column value from the below query, how I will fit in the above query, to insert into table ???



Which column you want to get
You can go for -

INSERT INTO <Your Table> (Column list...)
SELECT <Desired Column list>
FROM
(
<Your original query>
) A


Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page
   

- Advertisement -