c# - SQL Store queried data to one table (either temporary or not) -
i querying data 2 different servers , want store on table can use reference table in program.. (i using asp.net in programming)
have on command , please advise do.
select c.[pf_id] ,a.[requestdate] ,c.[pf_carrierused] ,b.[pieceprice] * b.[partquantity] ,c.[pf_type] ,c.[pf_ressupplier] ,c.[pf_rescustomer] ,c.[pf_trailernum] ,b.[partdesc] ,c.[pf_chargeback] ,c.[pf_chargetoplant] [cnctc-web01].[nop_pr].[dbo].[requests] join [cnctc-web01].[nop_pr].[dbo].[parts] b on a.[requestid] = b.[requestid] join [phriz-webapp01].[pftracking].[dbo].[tbl_pfexcel] c on b.[partnumber] '%'+c.pf_id+'%' a.[entityname] '%pta' , a.[requestdate] between '2015-04-20 00:00:00.000' , getdate()
the result of query wanted store in table use it.
additional :
when use temp_tables :
string or binary data truncated.
you can use insert
followed select
if table exists or can use select into
in order create new table.
see
insert temptable select c.[pf_id] ,a.[requestdate] ,c.[pf_carrierused] ,b.[pieceprice] * b.[partquantity] totalprice ,c.[pf_type] ,c.[pf_ressupplier] ,c.[pf_rescustomer] ,c.[pf_trailernum] ,b.[partdesc] ,c.[pf_chargeback] ,c.[pf_chargetoplant] [cnctc-web01].[nop_pr].[dbo].[requests] join [cnctc-web01].[nop_pr].[dbo].[parts] b on a.[requestid] = b.[requestid] join [phriz-webapp01].[pftracking].[dbo].[tbl_pfexcel] c on b.[partnumber] '%'+c.pf_id+'%' a.[entityname] '%pta' , a.[requestdate] between '2015-04-20 00:00:00.000' , getdate()
or
select c.[pf_id] ,a.[requestdate] ,c.[pf_carrierused] ,b.[pieceprice] * b.[partquantity] totalprice ,c.[pf_type] ,c.[pf_ressupplier] ,c.[pf_rescustomer] ,c.[pf_trailernum] ,b.[partdesc] ,c.[pf_chargeback] ,c.[pf_chargetoplant] temptable [cnctc-web01].[nop_pr].[dbo].[requests] join [cnctc-web01].[nop_pr].[dbo].[parts] b on a.[requestid] = b.[requestid] join [phriz-webapp01].[pftracking].[dbo].[tbl_pfexcel] c on b.[partnumber] '%'+c.pf_id+'%' a.[entityname] '%pta' , a.[requestdate] between '2015-04-20 00:00:00.000' , getdate()
edits.: select into
automatically create temptable columns , let available use.
Comments
Post a Comment