Insert Into Where Data Doesnt Exist
Oct 12, 2007
Hi,
I'm having a few problems. It's probably a simple thing but I can't figure it out.
I need to add data to a table but only if it isn't already in the table.
This is my query so far...
sqlcmd.CommandText = "Insert into caseDetails (c#,fe,cl) Values(@a,@b,@c)"
I assumed that if I added
WHERE not exists (case# = @a)
It would work and insert when the c# doesn't equal @a but all I get are errors.
Can anyone help?
Thanks,
Steve
View 6 Replies
ADVERTISEMENT
Jul 20, 2004
hi !
i m new to asp.net databases in C# n having some problems.
let my introduce my congfigurations:
Visual studio .net enterprise edition on windows xp and
mdac 2.7 , sql server 7.0 desktop edition.(with windows authentication mode for SQL server)
Now the problem is when i wanna connect to the Northwind database in the sql server, using the following c sharp code, i get the SQL Exception : SQL Server doesnt exist or access dennied ...
here is the code:
using System;
using System.Data.SqlClient;
class Db1{
public static void Main(string[] args) {
SqlConnection conn = new SqlConnection();
conn.ConnectionString=
"Data Source=loaclhost;user id=sa;pwd=;Initial Catalog=NorthWind "
conn.Open();
----------
some1 has told me that when using windows authentication mode , we dont use user id , pass in the connection string , i have also done that as well but same is the result..
i m struck here , plz help me to work it out.
Thanks
View 1 Replies
View Related
Mar 4, 2006
Hi,
I did some tsql a year or so ago, it wasnt much but it allows me to do most things i need to do in my job.
I have created a new database for bookings, each booking has all the relevant details and also the date that it will occur. im trying to create a script that will look for the 10 soonest dates that there is no booking for. at first i thought it would be easy, but now once i have got round to creating it i cant seem to think of a way to make it work!
TABLE: BOOKINGS
FIELD: DATE_BOOKED
has anybody advice on how i can do this?
many thanks,
Ben
View 6 Replies
View Related
Feb 27, 2008
Hi, I was wondering how I can complete a column (which doesnt have an input one) with data.
For example:
I have a sql query which bring data of 3 columns
ID | FISRT NAME | LAST NAME
1 MIKE MORGAN
2 SARA JOHANES
So, I will insert that data in a FLAT FILE CONNECTION MANAGER, which I configured with 3 columns and I did the corresponding mapping in the FLAT FILE DESTINTATION.
Now, If I add one more column in the FLAT FILE CONNECTION MANAGER, I will not have it mapped to a input one, obviously. So, what I need is to add one more column to the flat file destination and complete it with zeros values in it.
Probably I can solve this part by introducing a DERIVED COLUMN and there I can configure the zeros that I want to add to the column. But I'm not sure if I can do that without having a input column.
So, the question will be, how can I add one column to a flat file which doesnt have a input and introduce any value that I want to it?
Hope I was clear
Thanks for your help.
Beli
View 4 Replies
View Related
Jun 21, 2005
Im using a store proc in SQL server.I use one table to store my hockey statistics data of each player in the league.When i submit my form i would like to check if there is any sheet of that player that allready exist .. If so then i do update.. if it does not exist i do the insert statement.Here the way i figured it out ! One store proc to do the work of the insert or update. And one to check if the player exist in the statistics table. But i just cant find a way to return a good value from my second store proc. Does my logic make sence ? any ideas ?thank you<code>create procedure Hockey_Player_UpdateForwardStatistics
@LeagueID int, @GamePlayerID int, @Games int
as
declare @PlayerID int
@PlayerID = Hockey_CheckPlayerStatistics(@LeagueID, @GamePlayerID)
if @PlayerID = 0begininsert into Hockey_PlayerStatistics( Games)values( @Games)end
ELSE
beginupdate Hockey_PlayerStatistics set Games = @Gameswhere LeagueID = @LeagueID and PlayerID = @PlayerIDend</code>
View 1 Replies
View Related
Nov 28, 2006
I want to make a query, stored procedure, or whatever which will only display the primary key where there does no exist a foreign key in linked table.For example. If I had two tables with a one to many relationship.A [Computer] has one or more [Hard Drives]. I want to select only those computers which do not have a Hard Drive(s) associated with them. That is, show all computers where the Computer_ID field in the [Hard Drives] table does not exist. This seems simple but I'm drawing a blank here.
View 1 Replies
View Related
Nov 5, 2007
Hi,I have a button with code to update a column in a table, and insert other values into another table.I currently have it working to update the column, but not insert.It gives an error message, but still updates the column. It doesn't insert, which leads me to believe the error is somewhere in the insert code..It isn't giving me any red squiggly lines in the code though, and the error doesn't show where its referring to, just giving a stack trace.. Error: Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near ')'.Incorrect syntax near '@User'.Stack: [SqlException (0x80131904): Incorrect syntax near ')'.Incorrect syntax near '@User'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +180 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2411 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +147 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1089 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +413 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115 detailproview.ExecuteInsert(String quantity) +452 detailproview.Button2_Command(Object sender, CommandEventArgs e) +79 System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +75 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4886 Code:private bool ExecuteUpdate(int quantity){ SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"; con.Open(); SqlCommand command = new SqlCommand(); command.Connection = con; TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1"); Label labname = (Label)FormView1.FindControl("Label3"); Label labid = (Label)FormView1.FindControl("Label13"); command.CommandText = "UPDATE Items SET Quantityavailable = Quantityavailable - @qty WHERE productID=@productID"; command.Parameters.Add("@qty", TextBox1.Text); command.Parameters.Add("@productID", labid.Text); command.ExecuteNonQuery(); con.Close(); return true;} private bool ExecuteInsert(String quantity) { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"; con.Open(); SqlCommand command = new SqlCommand(); command.Connection = con; TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1"); Label labname = (Label)FormView1.FindControl("Label3"); Label labid = (Label)FormView1.FindControl("Label13"); command.CommandText = "INSERT INTO Transactions (Usersname)VALUES (@User)"+ "INSERT INTO Transactions (Itemid)VALUES (@productID)"+ "INSERT INTO Transactions (itemname)VALUES (@Itemsname)"+ "INSERT INTO Transactions (Date)VALUES (+DateTime.Now.ToString() +)"+ "INSERT INTO Transactions (Qty)VALUES (@qty)"+ command.Parameters.Add("@User", System.Web.HttpContext.Current.User.Identity.Name); command.Parameters.Add("@Itemsname", labname.Text); command.Parameters.Add("@productID", labid.Text); command.Parameters.Add("@qty", TextBox1.Text); command.ExecuteNonQuery(); con.Close(); return true; }protected void Button2_Click(object sender, EventArgs e){ TextBox TextBox1 = FormView1.FindControl("TextBox1") as TextBox; ExecuteUpdate(Int32.Parse(TextBox1.Text) );}protected void Button2_Command(object sender, CommandEventArgs e) { if (e.CommandName == "Update") { TextBox TextBox1 = FormView1.FindControl("TextBox1") as TextBox; ExecuteInsert(TextBox1.Text); } }} If anyone can help, ill be very grateful!! Thanks!Jon
View 7 Replies
View Related
Sep 2, 2004
I have been looking for a solution for this for some time and have came up empty handed.
I have 2 servers development box and a live box. Time has passed and my live box has a lot of new data in the database and now I need to update the dev box so I can properly test with real data. Problem here is I want to keep the records that are in the dev box, update them if they exsist on the live box, because live server may or may not contain that record and isert all records that are not on the dev box database.
I hope I am making some sense here, I think I am just making it more difficult then it has to be.
Any suggestions?
Lito
View 1 Replies
View Related
Nov 24, 2005
Hello all,
I have a branch a data, now i need to search through a database to check whther it is exist in that database or not, any syggestion?
Example:
Now i have data 123, 234, 345. Let say data 123 and 234 is exist in that database, but data 345 is not exist in that database.
What SQL am i suitable to use to get those result exist(123, 234) and those result not exist (345)?
The database structure is someting like this:
ID NAME O_NAME
-- ----- --------
1 120 123
2 234 234
3 345 345
1) The data consider 'exist' if it exist in column NAME or column O_NAME (either one).
2) The data consider 'not exist' if it not exist in neither NAME column nor O_NAME column
After the SQL query, someting is expected:
Exist:
ID NAME O_NAME
-- ----- --------
1 120 123
2 234 234
Not Exist:
ID NAME O_NAME
-- ----- --------
3 345 345
I'll appreciate if anyone can provide me a solution..Thanks!
View 3 Replies
View Related
Apr 27, 2008
Hello everybody,
have following problem:
I need info from 2 Tables. from the Table 2 I just need 1 column. When i ask for this column the output I get is data repeating themselve many times.
Distinct, should give me unique data, but is doesnt....
the code:
SELECT DISTINCT FSenddate, FSupplyIDName, FSupplyerNumber,FBillNo,FSourceBillNo,FItemName,FItemModel,
FAuxQty,FAuxTaxPrice,FHeadSelfP0237
FROM vwICBill_26
WHERE FSenddate BETWEEN DATEADD(dd,-14,GETDATE()) AND GETDATE()
This code just works in Table1 (vwICBill_26)
but with table 2 (vwICBill_1)
SELECT DISTINCT vwICBill_26.FSenddate,vwICBill_26.FSupplyIDName,
vwICBill_26.FSupplyerNumber,vwICBill_26.FBillNo,
vwICBill_26.FSourceBillNo,vwICBill_26.FItemName,
vwICBill_26.FItemModel,vwICBill_26.FAuxQty,
vwICBill_26.FAuxTaxPrice,vwICBill_26.FHeadSelfP0237,
vwICBill_1.FDate,vwICBill_1.FContractBillNo
FROM vwICBill_26,vwICBill_1
WHERE vwICBill_26.FSenddate BETWEEN DATEADD(dd,-14,GETDATE()) AND GETDATE()
AND vwICBill_1.FContractBillNo=vwICBill_26.FSourceBillNo
The last sentence is the problem
I want that it shows me the data that is not equal.
As soon as I implement the not equal it shows me the massive repeating data.
I mean even without the last sentence I get this data output.
All together, I want a clear database output without data repeating.
Any ideas how it may work without DISTINCT?
I think this problem is a typical amateure problem, but I would apreciate help!
View 2 Replies
View Related
Jul 7, 2004
Hi,
I'm completely stuck in here.
I have two tables, for simplicity i'll call them tbl_X and tbl_Y and i'll call the unique key Ukey
I need to create a stored procedure that must be run daily on a scheduled time. When executed, it must compare these two tables and insert rows from tbl_X into tbl_Y when a row exists in tbl_Y but not in tbl_X.
The following code returns the rows that are in tbl_Y, but not in tbl_X:
----------
SELECT Ukey
FROM tbl_X
WHERE NOT EXISTS
(SELECT Ukey
FROM tbl_Y
WHERE tbl_Y.Ukey = tbl_X.Ukey)
----------
But....how do i insert these rows into tbl_X ?
I've tried to declare the tbl_Y.Ukey and use that to do an INSERT statement, but that didn't work out.
Any help or example code is highly appriciated!
View 1 Replies
View Related
Mar 8, 2005
I have two tables that I have to compare:
Table:PR
WBS1 WBS2 WBS3
123-456 1000 01
123-456 1000 02
123-456 2000 02
567-890 2000 01
567-890 2000 02
Table:PR_Template
WBS2 WBS3
1000 00
1000 01
1000 02
2000 00
2000 01
2000 02
After Insert I should have:
wbs1 wbs2 wbs3
123-456 1000 00
123-456 1000 01
123-456 1000 02
123-456 2000 00
123-456 2000 01
123-456 2000 02
567-890 1000 00
567-890 1000 01
567-890 1000 02
567-890 2000 00
567-890 2000 01
567-890 2000 02
Basically, I need to insert the wbs2 and wbs3 where it does not exist in each wbs1.
What I have now will find the values that need to be inserted for a particular project but I don't know how to go through each project and perform the insert:
Select * from PR_template Where Not Exists
(Select Wbs1, Wbs2, Wbs3 from PR where PR.WBS2 = PR_Template.WBS2
And PR.WBS3 = PR_Template.Wbs3 and pr.wbs1 = '123-456')
Order by wbs2, wbs3 asc
Thank You
View 11 Replies
View Related
Feb 17, 2014
How do I Use the insert code below only if a record does not exist in the cisect table? Then if it exists I just want to
update cisect
set ml_desc_0 = cus_type_desc
from artypfil_sql A join cisect c on a.cus_type_cd = c.sct_code
INSERT INTO [002].[dbo].[cisect]
([sct_code]
,[ml_desc_0]
,[syscreated]
,[syscreator]
[code]....
View 3 Replies
View Related
Jan 14, 2015
I am trying to come up with one statement that will INSERT a row if the primary key does not exist but APPEND if it does
Would the following statement be correct?
INSERT INTO Products (a,b,c) VALUES (2, Cotton Socks, $12) ON DUPLICATE KEY (b=Cotton Socks), (C=$12)
where a is the primary key?
View 3 Replies
View Related
Feb 29, 2008
I've got an access table with about 2 million rows. I'm using this to update a table in SQL that holds pretty much the exact same data, only with an added Identity column.
From week to week, the access table grows. For example, next week it may have 2.1 millions rows, the week after 2.2 million, etc.
The goal of the DTS is to keep the SQL table up to date w/ the access one. In the past, this has been done by deleting everything from the SQL Table and then importing the ENTIRE access table. This not only takes more time then need be, since the majority of the records *already* existed, but it also threw referential integrity out the door - other tables should be referencing the Identity in the SQL Table. IDEALLY, the only rows that would be transferred from the access file are ones that don't already exist in the SQL table.
I don't want to re-invent the wheel, and have to confess being a little under-schooled on all that SSIS has to offer. Is there a Data Flow Transformation that would solve this?? Any other advice? If all else fails, I'd probably just dump the entire access table to a temp table and then insert vals into the production table that don't exist, but even this would require more temp hard drive space then I'd like.
Thanks!
View 4 Replies
View Related
Sep 27, 2011
i need to write a query that insert in A table if and only if the row does not exist already in the table (the source is a select statement).
i tried the following:
insert into [A]
select * from [B]
where Not EXISTS (select * from [A])
table [A] is still empty, but it does not insert any thing! .. what i know is that the EXIST checks if the selected row exists in the subquery, ain't ?
View 9 Replies
View Related
Feb 27, 2008
Someone help me out .How to solve the problem.I built a stored procedure in MS SQL 2005 to bulk insert into a table by reading the .txt file. But my stored procedure throws an error. "Could not bulk insert. File ' @PathFileName ' does not exist." My stored given below :- CREATE PROCEDURE [dbo].[ps_CSV_Import] AS DECLARE @PathFileName varchar(2000) ----Step 1: Build Valid BULK INSERT Statement DECLARE @SQL varchar(2000) SELECT @PathFileName="D:Areazone.txt" BEGIN SET @SQL = "BULK INSERT Temp FROM '"+" @PathFileName "+"' WITH (FIELDTERMINATOR = '"",""') " END --Step 2: Execute BULK INSERT statement EXEC (@SQL) --Step 3: INSERT data into final table INSERT mstArea(Description,Refid) SELECT SUBSTRING(Description,2,DATALENGTH(Description)-1), SUBSTRING(RefId,1,DATALENGTH(RefId)-0) FROM Temp --Step 4: Empty temporary table TRUNCATE TABLE Temp Please help me ,if someone have any solution
View 26 Replies
View Related
Jul 23, 2005
Hi guys,i have a little problem here.im attempting to write a stored procedure that compares two tables ofthe same data structure and adds (inserts) extra records that exist intable1 to table2.My problem is that i dont have a unique identifier between the tables.i think someone said that i needed to build up a keyany ideas greatly appreciated ??C
View 1 Replies
View Related
Feb 29, 2008
Someone help me out .How to solve the problem.I built a stored procedure in MS SQL 2005 to bulk insert into a table by reading the .txt file. But my stored procedure throws an error."Could not bulk insert. File ' @PathFileName ' does not exist."My stored given below :-CREATE PROCEDURE [dbo].[ps_CSV_Import]AS DECLARE @PathFileName varchar(2000) ----Step 1: Build Valid BULK INSERT Statement DECLARE @SQL varchar(2000) SELECT @PathFileName="D:Areazone.txt" BEGIN SET @SQL = "BULK INSERT Temp FROM '"+" @PathFileName "+"' WITH (FIELDTERMINATOR = '"",""') " END--Step 2: Execute BULK INSERT statementEXEC (@SQL)--Step 3: INSERT data into final tableINSERT mstArea(Description,Refid)SELECT SUBSTRING(Description,2,DATALENGTH(Description)-1), SUBSTRING(RefId,1,DATALENGTH(RefId)-0) FROM Temp--Step 4: Empty temporary tableTRUNCATE TABLE TempPlease help me ,if someone have any solution
View 11 Replies
View Related
Apr 30, 2008
help on CREATE stored procedure delete and after insert where not exist
in one stored procedure
in table_B
Code Snippet
CREATE PROCEDURE [dbo].[delete_from_table_B]
@empID varchar(500)
as
DELETE FROM table_B
WHERE charindex(','+CONVERT(varchar,[empID])+',',','+@empID+',') > 0
---HELP from this ponit how to insert ? after where not exist
IF @@ROWCOUNT > 0
BEGIN
insert into
table_B
set (empID,ShiftDate,shiftType)
where not exist
select
empID,ShiftDate,shiftType
from
table_A
table_A
empID fname ShiftDate shiftType
----------------------------------------------------
111 aaaa 15/03/2008 1
111 aaaa 16/03/2008 2
111 aaaa 18/03/2008 3
111 aaaa 19/03/2008 4
111 aaaa 20/03/2008 5
111 aaaa 21/03/2008 6
999 qqq 21/03/2008 9
222 bbb 02/05/2008 7
222 bbb 03/05/2008 8
222 bbb 04/05/2008 9
222 bbb 05/05/2008 7
222 bbb 06/05/2008 9
222 bbb 07/05/2008 3
222 bbb 08/05/2008 4
222 bbb 09/05/2008 5
333 ccc 03/04/2008 9
333 ccc 04/04/2008 2
TABLE B
empID fname ShiftDate shiftType
----------------------------------------------------
111 aaaa 15/03/2008 1
111 aaaa 16/03/2008 2
111 aaaa 18/03/2008 3
111 aaaa 19/03/2008 4
111 aaaa 20/03/2008 5
111 aaaa 21/03/2008 6
TNX for the help
View 1 Replies
View Related
Oct 25, 2006
Hello
I am trying to bulk insert a text file into SQL 2005 table. When I execute the bulk insert I get the error
"Msg 4860, Level 16, State 1, Line 1. Cannot bulk load. The file "\ENDUSER-SQLEnduserTextB1020063.txt" does not exist."
The text file that it is saying does not exist I recently created thru my code. I can open the file but only when I rename the file will the Bulk Insert work. After creating the text file I am moving it to the server that SQL server is running on. Also if I run sp_FileExists it also says the file does not exist unless again I rename the file then this stored procedure recognizes the file. I dont' know if I have a permission issue or what is the problem. Any help would be appreiated.
Thanks
Chris
View 12 Replies
View Related
Dec 3, 2006
I am using INSERT into Vendors (.....) VALUES (....) form of insert statement. How can I make sure that the insert fails if thie new vendor's vendorname exists?
I cannot create a unique index on 'VendorName' column since it is more than 900 bytes and SQL Server will not allow to create index on a column bigger than 900 bytes.
View 8 Replies
View Related
Jan 7, 2014
CREATE TABLE #MyTable
(
Teams VARCHAR(10),
StartDate DATETIME,
Count INT
)
INSERT INTO #MyTable (Teams,StartDate,Count)
SELECT 'Team A', '01/01/2014',10
[Code] ....
'Team A' Has No records for '01/02/2014' and '01/03/2014' so I need to insert values of '01/01/2014' StartDate for Team A for the missing dates
So 'Team A' will now have 3 records
Team A2014-01-01 00:00:00.00010
Team A2014-01-02 00:00:00.00010
Team A2014-01-03 00:00:00.00010
'Team B' Has No records for '01/03/2014' so I need to insert values of '01/02/2014' StartDate for Team B for the missing date
So 'Team B' will now have 3 records
Team B2014-01-01 00:00:00.00030
Team B2014-01-02 00:00:00.00040
Team B2014-01-03 00:00:00.00040
As for 'Team C' we have values for all 3 dates, no inserts needed.
View 3 Replies
View Related
Jan 11, 2008
Can I delete the record if it exist before we do an insert at the DataFlow level base on a key of the record we are working on? Basically we want to keep history records and delete and reinsert any records that exist in the table.
View 5 Replies
View Related
Apr 11, 2007
My colleague is working on bulk insert task from SSIS and since the data file does not contain any valid delimeter one of the suggestion he got is to use a file format to address the issue. Thus a bcp command is used to generate the format file, as per below.
bcp <database name>.dbo.<table name> format nul -T -S <server name> -n -f out.fmt
The file file format was generated, from the data flow we added the BULK INSERT task and set the properties accordingly including the File Format and location of the file. Upon running the task itself we encountered the error as per below.
[Bulk Insert Task] Error: An error occurred with the following error message: "Cannot bulk load. The file "C:HFISTAT.fmt" does not exist.".
Progress: The Bulk Insert task is completed. - 100 percent complete
Task Bulk Insert Task failed
Have checked the file and it is in C: drive and it is not protected or read-only. Validated the output file and it is as per expected. Any help would be appreciated very much.
View 7 Replies
View Related
Feb 26, 2015
I am writing a query to return some production data. Basically i need to insert either 1 or 2 rows into a Table variable based on a decision as to does the production part make 1 or 2 items ( The Raw data does not allow for this it comes from a look up in my database)
I can retrieve all the source data i need easily but when i come to insert it into the table variable i need to insert 1 record if its a single part or 2 records if its a twin part. I know could use a cursor but im sure there has to be an easier way !
Below is the code i have at the moment
declare @startdate as datetime
declare @enddate as datetime
declare @Line as Integer
DECLARE @count INT
set @startdate = '2015-01-01'
set @enddate = '2015-01-31'
[Code] .....
View 1 Replies
View Related
Aug 28, 2006
Hi guys,
I have 4 child table that contain same fieldname. Data inside this 4 table might be redundant among the 4 table. I call it as tbl1, tbl2, tbl3 and tbl4 fieldname is id_cert. what i mean redundant is, let say in tbl1 got data 1001 maybe in tbl3 also got this id. So my problem is i want to check whatever data in this 4 tbl is not exist in master table call masTbl(fieldname to check is id_no). can I do this without using many inner join script and generate dunmp table? Pls help me on this. Thanks in advanced.
Regards,
Shaffiq
View 4 Replies
View Related
Dec 3, 2013
I have data as below: select ID,code,go,back from tableA
ID code go back
2 C US UK
2 A UK US
1 A US UK
1 Z UK US
1 C UK US
1 A US UK
I only want to pull out whole ID group which code Z exist. I tried as below:
select ID,code,go,back from tableA A
where exists
( select ID,go,back
from tableA B with (nolock)
where A.ID = B.ID
and A.code='Z')
But it only appear:
ID code go back
1 Z UK US
How can I appear with the group as well?
ID code go back
1 A US UK
1 Z UK US
1 C UK US
1 A US UK
View 3 Replies
View Related
Apr 1, 2005
I have a cube that is showing measures that don't exist. Let me give an example. This example will include 3 dimensions, product, location, and time. The fact table measure will be sales.
Here are the distinct values if you were to write a sql query against the dimensionl model that feeds the cube.
Product Location Time Sales
A X 1/04 200
B Y 1/04 100
A X 2/04 300
In the cube, if you were to look at product by location for just 2/04, you would see:
Product Location Sales
All Loc 300
A X 300
Y
All Loc
B X
Y
How do you get rid of the zero's or combinations that don't exist?
Thanks,
Doug
View 1 Replies
View Related
Jul 10, 2014
I have TABLE1 and TABLE2
TABLE1 (ref,RESOURCE01,RESOURCE02,RESOURCE03,RESOURCE04,R ESOURCE05)
TABLE2 (ref,RESOURCE01,RESOURCE02,RESOURCE03,RESOURCE04,R ESOURCE05)
If TABLE2 has a data in resource 01-05 that isn't in resource01-05 of TABLE1 then I want to added it to the next free slot where ref is the unique key.
Note TABLE2 doesnt have to have all of TABLE1
eg if
TABLE1
01 AAA BBB
02 CCC DDD EEE
03 AAA DDD
TABLE2
01 AAA CCC
02 CCC DDD EEE FFF
03
I would like TABLE1 to be updated to appear like
TABLE1
01 AAA BBB CCC
02 CCC DDD EEE FFF
03 AAA DDD
Where do I even start here?
View 4 Replies
View Related
Jan 3, 2007
Hello. A question please. To define a column of a table in SqlServer, Does it exist a boolean data type ?
Thanks...
View 4 Replies
View Related
Feb 7, 2008
Hi I've not done much work on reporting services before.
I've made a change on my page and i can see the change on the preview its just a drop down list containing the week number.
But i can see to get to deploy these changes when i build my package it builds fine but when i go to deploy it am getting this error message
The item '/Data sources' already exist
View 20 Replies
View Related
May 25, 2015
I am working on SSIS wehre I need to work on a flat file as a source and needed to import it to database. If the destination table have the record already, I need to update it and if not exist, I just need to import the whole data.
View 9 Replies
View Related