SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL Query to get values in Parameters !!!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

khanewal
Starting Member

Australia
33 Posts

Posted - 08/18/2010 :  09:03:39  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
1007 Posts

Posted - 08/18/2010 :  09:12:58  Show Profile  Visit senthil_nagore's Homepage  Send senthil_nagore a Yahoo! Message  Reply with Quote
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

India
841 Posts

Posted - 08/18/2010 :  09:44:01  Show Profile  Reply with Quote
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

Australia
33 Posts

Posted - 08/18/2010 :  19:47:57  Show Profile  Reply with Quote
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

India
841 Posts

Posted - 08/19/2010 :  03:05:28  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000