View From A Merge Of Two Tables

May 15, 2006

Hi,

I hope this is the right place to ask this question. If it is not,
please let me know a more appropriate place.

I have two tables.

CREATE TABLE tblEmployees
(
EmployeeID int identity NOT NULL,
LastName varchar(50) NULL,
FirstName varchar(50) NULL,
);

CREATE TABLE tlkpDept
(
DeptID char(5) NULL,
Name char(10) NULL,
LongName char(50) NULL
);

Now I want to create a view called AssignedTo. [The application I'm
doing, will track the status of our customer requests. Each request
can be assigned to either an individual employee or an entire
department]

I want the view to have two columns, ID and LongName. ID should be
either the DeptID or the EmployeeID. The LongName column should be
either the LongName or the FirstName + LastName.

I'm not even sure how to begin to write such a complex SQL.
EnterpriseManager is being less than helpful too.

Can anyone help?

Thanks in advance.

-Tom

View 4 Replies


ADVERTISEMENT

A View Is Not Replicating During Merge Replication

Jan 28, 2007

Hello,

I'm developing a VB.Net for a CE.NET device. I use SQL Server 2000. I use merge replication to synch with the CE.NET device.

I have this problem where a view is not replicating to the CE.NET but my table articles are replicating without problems. All the base tables for the view are replicating correctly.

Any ideas?

Thank you.

View 1 Replies View Related

Merge Replication Nested View Problem

Sep 20, 2007

Using SQL 2005 as pub and SQL EXPRESS as sub using Merge replication. Got the following error message

The schema script 'CD_InTransit_v_153.sch' could not be propagated to the subscriber.
Error Detail:
The schema script 'CD_InTransit_v_153.sch' could not be propagated to the subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001)
Get help: http://help/MSSQL_REPL-2147201001
Unable to replicate a view or function because the referenced objects or columns are not present on the Subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL20164)
Get help: http://help/MSSQL_REPL20164
Invalid object name 'dbo.Debit_v'. (Source: MSSQLServer, Error number: 208)
Get help: http://help/208

According to error message, it seems that debit_v is missing. However, I cannot control the sequence of view to replicate. How can I solve this problem

View 6 Replies View Related

Merge Replication Nested View Problem

Sep 21, 2007

Using SQL 2005 as pub and SQL EXPRESS as sub using Merge replication. Got the following error message

The schema script 'CD_InTransit_v_153.sch' could not be propagated to the subscriber.
Error Detail:
The schema script 'CD_InTransit_v_153.sch' could not be propagated to the subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001)
Get help: http://help/MSSQL_REPL-2147201001
Unable to replicate a view or function because the referenced objects or columns are not present on the Subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL20164)
Get help: http://help/MSSQL_REPL20164
Invalid object name 'dbo.Debit_v'. (Source: MSSQLServer, Error number: 208)
Get help: http://help/208

According to error message, it seems that debit_v is missing. However, I cannot control the sequence of view to replicate. How can I solve this problem

View 6 Replies View Related

Alter View Hangs - Merge Replication SQL 2005

Dec 18, 2006

Background - I have a publication that propigates schema changes. I have a view in which I want to remove a column.

Error - Going by what the BOL says, I use Alter View and delete the column from my select statement. I issue the alter view command against the Publication database and it just "churns". I do not get any locking errors or any other type of error, but the statement never completes execution. I watched it run for 10 minutes and cancelled the query. Executing the same statement against a copy of the database that is not being published executes in 1, 2 seconds.

Here is what I am doing:

Old View: Select table1.record_number, table1.record_date, table1.status_code, table2.status_desc,

table2.txt_sort_order

FROM table1 join table2 on table1.status_code = table2.status_code

The query I am executing:

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER VIEW myview

AS

Select table1.record_number, table1.record_date, table1.status_code, table2.status_desc

FROM table1 join table2 on table1.status_code = table2.status_code

View 1 Replies View Related

Merge Two Tables

Mar 22, 2006

Hello, I need your expert help:

I have two tables (ship2005 and ship2006) all with same structure
Sold_to
Week
Year
Units
Dollars
Style

I have to merge them together, and add some other columns from other tables
Custmstr (director) and stylemstr (style) based on Sold_to

In the format so I’m able to see 2005 week, 2006 week, 2005 unit, 2006 unit, 2005 dollars, 2006 dollars and so on.

This one is working, but forever…

where Custmstr.Sold_to *= ship2005.Sold_to
and Custmstr.Sold_to *= ship2006.Sold_To
and stylmstr.style_num *= ship2005.style_number
and stylmstr.style_num *= ship2006.style_number

And another thing: how can I populate the Year column for both?

Thank you very much

View 4 Replies View Related

Merge The Two Tables

Sep 22, 2006

Hello All,
I have two column firstname,lastname.I just want to merge both to one.
Like john ,david

it should be johndavid into one.Please its urgent

View 6 Replies View Related

How To Join/merge Tables

Nov 21, 2006

Hi guys! I'm trying to figure out how to join 3 tables, but I can't seem to find a solution. What I want to do is to put table 1, table 2 and table 3 into table_merged.
table_merged = table 1 + table 2 + table 3
 Is it possible to merge tables even if they have different fields?
 
Please help.
Onegai shimasu... 
 
Thanks in advance!

View 1 Replies View Related

Merge Two Fields From Two Different Tables Into One

Aug 24, 2004

If possible, I would like to create a view using two different tables, but with the fields merged (ie. create one table from two tables). The table structures are pretty much the same. Can you do this from a singe SQL statement? Any ideas? My only alternative is creating a temp file that inserts records from both tables, but I want to avoid doing that.

View 6 Replies View Related

MERGE Statement Into Two Tables

Aug 21, 2012

I am trying to update values in two tables (approx 1-2 million records).

I have decided to use a MERGE statement, however have been unsuccessful to do so.

Below is an example of the statement.

The error is receive is "Incorrect syntax near '('." right after the MERGE line.

Is it not possible to use this syntax ?

Example:
[CODE]
MERGE
( SELECT a.id, b.id2
FROM TableA A
JOIN TableB B

[Code]....

View 5 Replies View Related

SQL 2012 :: Merge Two Tables Into One

Feb 18, 2014

I have two totally different tables with completely different data fields. Also, there is no common relationship between these two tables. However, I want to pick few data fields from the each table and merge into a new table! Is this even possible?

View 9 Replies View Related

T-SQL (SS2K8) :: How To Merge Two Tables

May 27, 2014

I've One table that contains all current appointments booked as below.

RNappt_idclinic_idderived_location_idprovider_idappt_date_timeappt_date_endtime
1102186011435/27/14 8:305/27/14 9:00 AM
2102196011435/27/14 9:305/27/14 10:00 AM
3102206011435/27/14 10:305/27/14 11:00 AM
4102216011435/27/14 14:005/27/14 2:30 PM
5102226011435/27/14 16:005/27/14 4:30 PM
6102236011435/27/14 16:305/27/14 5:00 PM

for Same Clinic,location and Provider there's a schedule data for same day 24 hours

having every five mintues as below:

clinic_idderived_location_idprovider_idstart_timeendtimeunblock
601143 8:01 8:040
6011438:05 8:100
601143
60114313:0113:041
601143
60114313:5514:001
601143 1
60114317:5518:000
60114323:550:001

for rows having no start and endtime assume it as regular intervals.

So i need to show available appointment with duration one hour with the available schedule which is for every five minutes

Like My first appointment for today starts at 8:30 but 8- 8:30 is unblock so there could be an appointment but as this chunk is less than 60 so need to create it

For Schedule table below is what i've to create for temporary basis as this will be available in nightly load in a table.

DECLARE @num int=5
,@LASTtime TIME =CAST('23:55' as TIME)
,@Time TIME =CAST('00:00' as TIME)
,@Timeprev TIME =CAST('00:00' as TIME)
WHILE ( @Time<>@LASTtime)
BEGIN

[code]....

View 8 Replies View Related

Merge Tables And FileGroups

Dec 6, 2005

Hey all
For performance reasons i want to move the Merge Replication tables in a DB of mine (mainly MSMerge_Tomestone and MSMerge_Contents) to a seperate filegroup ... it's a heavy transactional DB and the index fragamentation rate is quite phenominal!

View 6 Replies View Related

Merge Join More Than 2 Tables

Nov 7, 2006

I need to take certain items of data from four different tables and out them into one table.

Unfortunately my source data's version of SQL does not support the LEFT JOIN keyword which has left me with a bit of a problem.

I saw the merge join in SSIS and used it to get data from two of the tables and stick them in the destination and it all worked fine.

That got me thinking, is it possible to create a second merge join transformation within the same data flow task for the remaining two tables and then join the output of both the merge joins to give me the data I need from all four tables in one output?





View 1 Replies View Related

Merge Tables On Unique Key Using Different Columns

May 15, 2008

hi guys,

i have 3 tables (T1, T2, T3), each with the same structure:
ID1 -> char(10)
ID2 -> char(12) NULL
ID3 -> char(10)
Value1 -> money
Value2 -> money
Value3 -> money
Note1 -> Text
Note2 -> Text

ID1+ID2+ID3 is the clusterd unique key in each table

what i want:
ID1, ID2, ID3 (with distinct occurencies of all 3 tables), T1.Value2, T2.Value2, T2.Value3, T3.Value1, T3.Note1

what i tried is to get all possible rows with

SELECT ID1,ID2,ID3 FROM T1
UNION
SELECT ID1,ID2,ID3 FROM T2
UNION
SELECT ID1,ID2,ID3 FROM T3

but i dont know how to join or add the other columns. maybe with

WITH RowList (ID1,ID2,ID3) AS ( ... code above.... ) SELECT ...


any ideas?
thx

View 10 Replies View Related

Transact SQL :: Merge Two Columns From Different Tables?

Oct 26, 2015

I have two temp. tables. I am trying to show the agents how makes the sales and the ones how didnt make sales based on the time that they clock in. One table is called #sales which has only the agents that make sales and other tables is #hours which has both agents that do not make sale. the problem is that I can not get both agents to show on my report. I tried different ways but I could not. #sales table uses (select statement from AmountStats table that stores only the agents who make sale). #hours table uses different tables to store all gents who makes sale and ones that are not making sale. 

declare
@start datetime,
@end datetime,
@campaignId uniqueidentifier,
@campaignName varchar(250),
@segment varchar(50)

set @start = '2015-10-07'
set @end = '2015-10-20'

[code]....

how to merge these two columns from #sales and #hours tables without duplication.

View 6 Replies View Related

Deleted Merge Repication Job.. How Can I Know Which Tables Are In That Replication Job?

Apr 6, 2001

Hi, eveyone..
I have a problem.
One of developer deleted Merge Replication Job.
However there is no doc for that replication.
What I want to know is like this:
which tables are in that replication?
Is there any system or user tables track down these replication as well as configuration in that replication?

Thanks in advance:-))
Jay

View 1 Replies View Related

SQL Server 2012 :: Merge Data From Two Tables

Feb 3, 2014

Merging table :

--------Dummy TABLE

create table #Tbl1 (date1 date,WSH varchar(10),ITN int,Executions int)
insert into #Tbl1 (date1 , WSH , ITN , Executions)
select '20130202' ,'ABC', 1 , 100
union all
select '20130203' ,'DEF', 1 , 200

[Code] .....

I want Result like this :

date1 WSH ITNExecutionsMCGPositions
2013-02-02 ABC 1 100 2 500
2013-02-03 DEF1 200 NULL NULL
2013-02-05 NULLNULL NULL 2 600

View 2 Replies View Related

Merge Tables And Collect Origin Info

Apr 29, 2015

If you have 2 tables with the same columns and you would like to see all distinct records in a result of a select and also the information in the records which table the record comes from (for instance: from table A or from table B or bot tables contain it) what should you do?

View 5 Replies View Related

T-SQL (SS2K8) :: Merge Statement MULTIPLE INSERT Into Different Tables

Jul 23, 2014

Can we insert into multiple table using merge statement?I'm using SQL Server 2008 R2 and below is my MERGE query...

-> I'm checking if the record exist in Contact table or not. If it exist then I will insert into employee table else I will insert into contact table then employee table.

WITH Cont as
( Select ContactID from Contact where ContactID=@ContactID)
MERGE Employee as NewEmp
Using Cont as con

[code]...

View 2 Replies View Related

SQL 2012 :: Error In Conflicts Tables In Merge Replication

Feb 13, 2015

There is an error in one of my merge publication. The error is,

The change for the row with article nickname 2336003 (test), rowguidcol {436456F0-F5AD-E411-80CF-5CF3FC1D2D76} could not be applied at the destination. Further information about the failure reason can be found in the conflict logging tables.

When i checked my tables I got following values in rowguid column

publication 436456F0-F5AD-E411-80CF-5CF3FC1D2D76
subscriptionD824D120-23AD-E411-80E3-00155D0E1001
conflict tables 689C6A61-5359-4BB5-BECD-B03F5F94D79A

View 0 Replies View Related

Data Mining :: Merge Two Or More Columns In Separate Tables

Jul 14, 2015

SQL 2008R2

Request is to merge or join or case stmt or union or... from up to four unique columns all in separate tables to new combined table (matrix) of results from said.

What is example of best method to do this ?

View 2 Replies View Related

Merge Data From Two Tables Into One Table - No Updates/only Insert

Sep 10, 2007


Hi all,,

I posted the questions in sql forum and got good sql statement to work with it.. However, I want to see if there is a way to do it in SSIS..

May be this is really basic questions but I am having hard time to do it in sql server 2005 SSIS..

I have a flat file that I want to merge with table in SQL server 2005.

1> I have successfully created a data flow task to import data from flat file to Table X (new table I created for this package).

Now here is my question.
I have a Table A already in the database with the same column structure as of TableX (Both the tables have 20 columns/same Name/Same design).

I want to merge Table A and Table X and stored the data in TableA. However, I just don't want to merge blindly, I need to insert a new row in Table A only if the same row does not exist in Table A (there is no primary key, i am looking certain fields to see if the rows are same)..

Here is an example:
Table A
--------------
1 test test1 test2 test3 test4 test5
2 test test6 test7 test8 test9 test10

Table X
------------
1 test test1 test2 test99 test4 test5
2 test test98 test97 test 96 test95 test94
--------------------------------------------------------
Now, I want to only insert row 2 of Table X since there is match on 4 of the fields in row1..
The new Table A should look like

NEW Table A'
-----------------

test test1 test2 test3 test4 test5
test test6 test7 test8 test9 test10
test test98 test97 test 96 test95 test94


------------------------------------
I think, I could do this using Execute SQL task and write all the code in sql, but that will be cumbersome and time consuming.. Is there a simpler way to achieve this?

Thanks in advance.

View 6 Replies View Related

Merge Replication Replicate Master And Related Tables

Jan 19, 2007



hi all,

Could we configure a merge replication such as replicate the master table and its all related tables (relation deep could be 1.)

We dont want to manually find master table relations and configure replication for the related tables.

please help for that configuration

kinds

View 5 Replies View Related

A Custom Component For Use As A VIEW In SSIS- Is It Possible To Create One MERGE Like Component With More Than 2 Inputs

Aug 13, 2007

Hi all
I'm into a project which uses a lot of views for joining 2 or more tables. Using the MERGE component in SSIS will be a huge effort coz it only has 2 inputs and I gotta SORT the input too.
Isnt it possible to have a VIEW like component that joins more than 2 tables and DOESNT need sorting??
(I've thought about creating views in database engine but it breaks my data floe in SSIS and is'nt a practical solution)

View 4 Replies View Related

Merge Replication Conflict Tables Stored Proces And Views

May 4, 2006

We have merge replication running with anamous subscribers
We have generested lots of views tables and stored procedures like
sp_ins_C435D35DDEC04FE2517CCD52A9024EC4

ctsv_07BA7383A12B4654B4D3A69B3053B227
aonflict_DH_tblReplicationRegion

How do we get rud of these I am concerned it will fill up the publisher database
Can any one advise

View 1 Replies View Related

T-SQL (SS2K8) :: Delete And Merge Duplicate Records From Joined Tables?

Oct 21, 2014

Im trying to delete duplicate records from the output of the query below, if they also meet certain conditions ie 'different address type' then I would merge the records. From the following query how do I go about achieving one and/or the other from either the output, or as an extension of the query itself?

SELECT
a1z103acno AccountNumber
, a1z103frnm FirstName
, a1z103lanm LastName
, a1z103ornm OrgName
, a3z103adr1 AddressLine1
, A3z103city City
, A3z103st State

[code]...

View 1 Replies View Related

Merge Two Tables Into A Single Table Based On The Matching Timestamp

Aug 2, 2013

Two tables:

table #1 = timestamp, servername1(never changes), value(int)
Table #2 = timestamp, servername2(never changes), value(int)

What I need to do is merge the two tables into a single table based on the matching timestamp:

timestamp, servername1, servername2 as headers then values under
"1/1/1-1:10:1" , "10" , "10" - as an example
"1/1/1-1:20:1" , "20" , "21" - as an example
"1/1/1-1:30:1" , "1" , "5" - as an example

Powershell or MSSQL 2008 queries work.

I have a powershell script atm that can create the table and then throw it back into the database but its very slow because of the amount of records.

The table is for some performance stat collection app.

Table #1 records a timestamp, the servername (which is the same over and over in the table) and the value of the performance object.
Table #2 is the same collection but for a different server.

The layout in the database is terrible but this is what I get to work with.

View 3 Replies View Related

SSIS: JOINING TABLES FROM TWO SERVERS - BETTER WAY THAN SORT -&&> MERGE JOIN?

Jan 20, 2006

Setup:

I need to run an Insert query which pulls data from a table located on server A database AA Table AAA conditional on (or JOINED with) Table BBB in database BB sever B. In SQL 2000 it could be done as:

From Server A:
sp_addlinkedserver B
INSERT dbo.ResultsTable
SELECT SourceTable.* FROM B.BB.dbo.BBB SourceTable
INNER JOIN A.AA.dbo.AAA ConditionTable ON SourceTable.RecID = ConditionTable.RecID
sp_dropserver B


In SSIS one of the possible solutions is to use a package which does the following:
OPEN A + OPEN B-> SORT A + SORT B->MERGE JOIN A and B->OUTPUT RESULT

The problem with this approach is that it's extremely slow for large datafiles (50M records each)

Questions:

1) In the procedure above could the SORT step be avoided?
2) Is there another approach to run cross-servers JOIN in SSIS?

Thank you

View 3 Replies View Related

Can't View Tables In EM!

Sep 25, 2002

I have suddenly lost the ability to view the tables for one of my database via Enterprise Manager. It just sits at an hourglass and never returns!
Alos, if I attempt to link to the tables via MSAccess's ODBC interface, I get a timeout.

I am able to view the table list for other user databases, as well as the system databases.

I am able to view other object list (like SPs) for the database in question, via Enterprise Manager.

I am able to perform a select query against the sysobjects table for the database in question.

Any ideas on why Enterprise Manager, and ODBC links, are hanging while trying to access the tables for one particular user database?

Any help is appreciated.

All other functions appear normal. If I can't figure anything out, or no one has any other ideas, I will try rebooting the server after the users are gone for the day.

View 4 Replies View Related

Sql EX 05 Can't View DB And Tables

Nov 28, 2005

Hi, I€™m new to sql ex 2005 and have a couple of questions I can€™t find the answers to.   Q.1   I am working with VS web dev ex 2005 and I€™m trying to backup my db,  is it as simple as copying the .mdf file? Or should I create a text file, or something else?   Q.2  How do I view the content of the db in my web programs in the sql server 2005 ex?  I can€™t figure out what to do, to view the content.  I have tried to find tutorials on ex 05 but can€™t find answers to my questions.   Help would be appreciated. Thank you.

View 7 Replies View Related

Transact SQL :: Merge Two Tables Data On Behalf Of ID In Comma Separated Manner?

Jul 2, 2015

Picture tells all what i need. Anyway i want to combine upper two tables data like below result sets. Means they should be grouped by bsns_id and its description should be comma separated taken from 2nd table. In sql server 2012 ....

View 5 Replies View Related

View 2 Tables With A Certain Criteria

Aug 28, 2000

Is it possible to to view 2 tables with a common field name and display it in the following way

Name telephon no.

John 123-4567
789-4561
987-6543
Peter 159-7536
654-9874
896-3214
456-9874
without repeating the name in each row.
Thanks

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved