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.
Author |
Topic |
atuljadhavnetafim
Starting Member
25 Posts |
Posted - 2014-09-29 : 01:32:38
|
Dear experti have 6 table in SQL Serverand i have created one view and create single table by linking all the table,now i want to join two column likeColumn A and Column B = Column Ce.gA B CAtul Jadhav AtuljadhavVijay vijayvijayin above exambe column A having firstName and Column B having second name and i want to join this two column in C column "atuljadhav"and if column B is blank then it join A value tow timesplease give me triger code as it is auto update column and every time (update, append, modify, delete) it should be update automaticplease helpAtul Jadhav |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2014-09-29 : 02:16:57
|
[CODE]CREATE TABLE TestConcat( A VARCHAR(100), B VARCHAR(100),C VARCHAR(200))GOCREATE TRIGGER Trg_TestConcatON TestConcatFOR INSERT, UPDATEAS UPDATE TestConcat SET C=A+ISNULL(B, A)GO-- Test Triggerinsert into TestConcat( A, B)SELECT 'Atul', 'Jadhav' union allSELECT 'Vijay', NULLSELECT * FROM TestConcat[/CODE]--Chandu |
|
|
atuljadhavnetafim
Starting Member
25 Posts |
Posted - 2014-09-29 : 04:57:39
|
thanks for replybut i don't want to create new tablei have already extra column and i just want to merge two column in that columnAtul Jadhav |
|
|
atuljadhavnetafim
Starting Member
25 Posts |
Posted - 2014-09-29 : 05:47:47
|
this code not workingi modify code as belowCREATE TRIGGER Trg_View_1ON View_1FOR INSERT, UPDATEASUPDATE View_1 SET payerCustomer = payer + ISNULL (Customer, Payer)GOAtul Jadhav |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2014-09-29 : 06:23:55
|
Why do you want to use UPDATE on view?You can simply change view definition to include new column.create view view_1asSelect column_a, column_b, column_a+ISNULL(column_b, column_a) as column_cfrom sometableHarsh Athalyehttp://in.linkedin.com/in/harshathalye/ |
|
|
atuljadhavnetafim
Starting Member
25 Posts |
Posted - 2014-09-29 : 07:11:35
|
becasue my view table is summary of all 6 tables and that view table linked in my local Excel sheet, if it is possible in original table than it is ok for mebut it update whenever i uploade new data in that tableAtul Jadhav |
|
|
|
|
|
|
|