Can I BCP A Single Colume Into An Exsisting Table?
Sep 25, 2000
I need to update one column in a very large table. Can I bcp, bulk copy, bulk insert... one column from another table into an existing table? For example:
table RES column STATUS needs to be updated with the same column from another table (PROP).
I have looked at bcp but it looks like it wants to insert/update all columns in the row. I just need the one column updated and I need it done fast.
Any help would be appreciated.
Charlie.
View 3 Replies
ADVERTISEMENT
Jul 26, 2007
Hi,
I am trying to import data from an excel table into an existing table. Also there are more columns in the table than in the excel sheet.
I am not sure how to import to an existing table. Also during the import i have to add 9999 to the existing EmployeeID in the excel file.
Columns in the excel file:
EmployeeID
DepartmentName
UserName
FirstName
LastName
Email
WorkPhone
UserPassword
Active
Structure of the User_sys table in sql:
CREATE TABLE [dbo].[Users_sys](
[User_id] [bigint] NOT NULL,
[USer_name] [nvarchar](50) NULL,
[Given_Names] [nvarchar](50) NULL,
[Surname] [nvarchar](50) NULL,
[Email] [nvarchar](50)NULL,
[Phone_no] [nvarchar](50) NULL,
[Password] [varchar](50)NULL,
[Role_code] [nvarchar](50)NULL,
[Candidate_id] [int] NULL CONSTRAINT [DF_Users_sys_Candidate_id] DEFAULT ((0)),
[Business_admin] [bit] NULL CONSTRAINT [DF_Users_sys_Business_admin] DEFAULT ((0)),
[Active] [bit] NULL CONSTRAINT [DF_Users_sys_Active] DEFAULT ((0)),
[NotActive_date] [datetime] NULL,
[Activation_date] [datetime] NULL,
[Date_Entered] [datetime] NULL,
[User_Id_Ent] [int] NULL CONSTRAINT [DF_Users_sys_User_Id_Ent] DEFAULT ((0)),
[Date_Updated] [datetime] NULL,
[User_Id_Upd] [int] NULL CONSTRAINT [DF_Users_sys_User_Id_Upd] DEFAULT ((0)),
CONSTRAINT [PK_Users Table_sys] PRIMARY KEY CLUSTERED
(
[User_id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.
View 1 Replies
View Related
Feb 8, 2001
Hi, all, does anyone know of a way to change default values inside of a table without affecting existing values?
I have a table with default = 0 in usermask column. Some rows already have non 0 values in them. I now need to change the default to 1 but still want the non 0 values be there. I also want the new default to take effect when new rows are entered. What's the best and quickest way to do it?
Thanks for advice.
Richard
View 2 Replies
View Related
Apr 4, 2006
How can i combine my data in single row ? All data are in a single table sorted as employeeno, date
Code:
Employee No Date SALARY
1 10/30/2006 500
1 11/30/2006 1000
2 10/25/2006 800
3 10/26/2006 900
4 10/28/2006 1000
4 11/01/2006 8000
Should Appear
Code:
EmployeeNo Date1 OLDSALARY Date2 NEWSALARY
1 10/30/2006 500 11/30/2006 1000
2 10/25/2006 800
3 10/26/2006 900
4 10/28/2006 1000 11/01/2006 800
PLEASE HELP I REALLY NEED THE RIGHT QUERY FOR THIS OUTPUT.
THANKS IN ADVANCE
View 3 Replies
View Related
Feb 9, 2012
I'm trying to insert data into a table from two tables into a single table along with a hard coded value.
insert into TABLE1
(THING,PERSONORGROUP,ACCESSRIGHTS)
VALUES
((select SYSTEM_ID from TABLE2 where
AUTHOR IN (select SYSTEM_ID from TABLE2 where USER_ID
=('USER1'))),(select SYSTEM_ID from TABLE2 where USER_ID
=('USER2')),255)
I get the following-
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
Do I need to use a cursor?
View 5 Replies
View Related
Nov 19, 2015
There are 3 tables Property , PropertyExternalReference , PropertyAssesmentValuation which are common for 60 business rule
SELECT Â
 PE.PropertyExternalReferenceValue  [BAReferenceNumber]
, PA.DescriptionCode
  [PSDCode]
, PV.ValuationEffectiveDate
  [EffectiveDate]
, PV.PropertyListAlterationDate
  [ListAlterationDate]
[code]....
Can we push the data for the above query in a physical table and create index to make the query fast rather than using the same set  tables multiple timesÂ
View 11 Replies
View Related
Sep 29, 2014
i have 6 table in SQL Server and i have created one view and create single table by linking all the table,now i want to join two column like
Column A and Column B = Column C
e.g
A B C
Atul Jadhav Atuljadhav
Vijay vijayvijay
in 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 timestriger code as it is auto update column and every time (update, append, modify, delete) it should be update automatic
View 5 Replies
View Related
Nov 1, 2007
I have table "Clients" who have associated records in table "Mailings"
I want to populate a gridview using a single query that grabs all the info I need so that I may utilize the gridview's built in sorting.
I'm trying to return records containing the next upcoming mailing for each client.
The closest I can get is below:
I'm using GROUP BY because it allows me to return a single record for each client and the MIN part allows me to return the associated record in the mailings table for each client that contains the next upcoming 'send_date'
SELECT MIN(dbo.tbl_clients.client_last_name) AS exp_last_name, MIN(dbo.tbl_mailings.send_date) AS exp_send_date, MIN(dbo.tbl_mailings.user_id) AS exp_user_id, dbo.tbl_clients.client_id, MIN(dbo.tbl_mailings.mailing_id) AS exp_mailing_idFROM dbo.tbl_clients INNER JOIN
dbo.tbl_mailings ON dbo.tbl_clients.client_id = dbo.tbl_mailings.client_idWHERE (dbo.tbl_mailings.user_id = 1000)GROUP BY dbo.tbl_clients.client_id
The user_id set at 1000 part is what makes it rightly pull in all clients for a particular user. Problem is, by using the GROUP BY statement I'm just getting the lowest 'mailing_id' number and NOT the actual entry associated with mailing item I want to return. Same goes for the last_name field. Perhaps I need to have a subquery within my WHERE clause?Or am I barking up the wrong tree entirely..
View 7 Replies
View Related
Sep 28, 1999
I've managed to BCP in a single table form a backup DAT file into a database, but it took WAY to long (1 hour+ on a meaty server) and I can't understand why.
The table only had a few rows of data and only had a few small dependancy tables.
The table has a primary key, hence an index so the BCP becomes a logged operation but it still should not take this long.
Here is the BCP command line that I ran :-
bcp <dbname>.dbo.<tablename> in <DAT filename> /U sa /P /S <server> /m 1 /n
Could anyone please shed some light on this. Is there anyway of 'fast' bcp'ing this table into the database overwriting the existing one.
Failing that, is there any way of scripting the transfer of a table from one server to another.
Many thanks.
Dave
View 2 Replies
View Related
Mar 18, 2002
Does anyone know of a way to restore a single table using SQL 7.0? I know that I can build a dummy database and do a database restore, then copy the table from database to database. But....was wondering if there is a way to restore a single table from a backup. Is losing the ability to restore a single table one of the 'features' of 7.0?
View 1 Replies
View Related
Feb 15, 2001
Does anyone know if I can restore an individual table in SQL 7.0?
I know I can DTS from a copy of the database but how can I restore a table directly from a backup file.
Thanks
Ben
View 2 Replies
View Related
Oct 13, 2000
How can I restore just one table from the full backup? It was very easy with 6.5 but I am not sure whether it's possible with 7.0 and if it is possible, how to do it.
Thanks in advance.
View 2 Replies
View Related
Mar 15, 1999
I thought I had posted this question already, but didn't see it in
the list. I apologize if this is a repost.
I am running SQL Server 6.5 SP 4.
I am attempting to load a single table from backup, but continually get
the error about schemas not matching. Interestingly, it comes back with
a status 4, and not the status 3 indicating a mismatch on Ansi_Padding.
The statement I am using is
load table demhist from internal_tape with file=5,nounload
I have tried creating the table from scratch and using select * into...
I have tried both above with both settings of Ansi Padding. The table
I am trying to load contaings char columns which allow nulls. I have
experimented with loading 2 other tables. One of the other tables loads
and one doesn't. The one which does not load also has char columns which
allow nulls, while the one that does load does not have char columns
which allow nulls.
Is it a known problem or limitation on the table load that it cannot reload
tables that contain char columns which allow nulls?
View 4 Replies
View Related
Dec 15, 1998
Hi!
This morning, I needed to restore 1 table to a database because it had
accidentally been deleted (don't ask). Each time I tried to restore the
single table, I would select TOOLS| DATABASE BACKUP/RESTORE| RESTORE
tab from Enterprise Manager, then I select SINGLE TABLE, but am only
given the existing table names as choices to restore. This happens when
I select to restore 'FROM DEVICE' as well.
Am I doing something wrong or is this how MS SQL6.5 is supposed to
work? Am I only able to restore a corrupt table and not a missing
table? I ended up restoring the entire database...
Thanks for your help!
Toni Eibner
View 2 Replies
View Related
Sep 10, 2001
It appears that in SQL 2000 restoring a single table is a bit more tedious and less user friendly as in earlier versions (6.5). Can anyone explain in a nutshell the easiest/quickest way to restore a single table from a backup?
Thanks,
Christine
View 1 Replies
View Related
Nov 12, 2004
Hi all !
I have a table with no keys (temp table) which looks like this :
col1|col2|col3
001|A|.087
001|B|.032
001|C|.345
002|A|.324
002|B|.724
003|A|.088
003|C|.899
001|A|.087
001|A|.234
001|B|.032
As you see, there is some duplicate entries in it. I would like to get a list of all the rows that have the same col1 and col2 BUT different col3 value. The result should return col1=001 col2=A but NOT col1=001 col2=B. I tried a lot of queries with EXISTS, HAVING, etc... but nothing seems to work.
Anyone have an idea how I can do it ?
View 7 Replies
View Related
Apr 16, 2008
Is there a tool out there to backup only one table at time
in SQL Server 2005 ?
View 9 Replies
View Related
Dec 10, 2007
Is there a way to back up one table at a time?
View 2 Replies
View Related
Jul 20, 2005
We have one user who enters a transaction and then does a single rowupdate (updates all columns but only one is changing - this is due tothe way our sql is generated in the application), at this pointanother user enter a transaction and tries to update the same row (heunderstandably has to sit and wait while he is blocked by the originaluser). The original user then updates the same row again – at thispoint the second user is chosen as a deadlock victim and killed. If Itry and recreate this with any other tables(or pubs) I get my expectedbehaviour of the original user just doing 2 successful updates and thesecond user then completing his update once the original user haseither committed his changes or rolled back. The query plan indicatesthat a drop and insert of the row is happening (this is not the casewith any other tables where we get our expected behaviour). This onlyhappens when the index is clustered - if we use a non-clustered indexit does not occur.Is this expected behaviour? it seems dangerous to me as the firstuser has not commited or rolled back his updates. It was onlyhighlighted by a fault in our application that caused the secondupdate to be executed.I have some thoughts about it being something to do with a row lockbeing relased due to a delete / insest of the row in the second update(we see this in the execution plan).....Any help much appreciated as I am struggling to get my head round howthe second user was ever able to get hold of the resource.
View 1 Replies
View Related
Jan 18, 2008
Hi,
I need to display the datas in a table format. I have placed a table and now i need to use two different datasets for a single table. Those two different datasets are generated based on two different stored procedures. Those stored procedures retrieve data from two different sql tables. Can any one explain me how to use two different datasets for a single table. As far i have tried i was able to fetch only the first record of the other dataset. But i need to fetch all the records of both the dataset. Thanks in advance for any help.
Thanks,
Sangeethaa
View 11 Replies
View Related
Aug 25, 2015
I was writing a query to get the age and the retirement year for all the employees.And thought of using while loop so that I don't have to write IF conditions or case statements for all the ages.
I'm using the AdventureWorks2012 database.And the actual table looks like this.
SELECT * FROM HumanResources.Employee
*NOTE:- These tables are not the complete tables.
BusinessEntityID         JobTitle                 BirthDate       MaritalStatus     Gender
      1                Chief Executive Officer           1963-03-02  S              M
      2         Vice President of Engineering         1965-09-01        S                     F
     3             Engineering Manager          1968-12-13        M              M
     4             Senior Tool Designer              1969-01-23           S             M
[Code] ...
And after I wrote the query to get the age and the retirement year of all the employees I got 70 tables for all the ages from 30 to 70. As the starting age is 30 and the last age is 70 in the table.So,I just want to know how I can settle all the tables into a single table as a sinle result and not as multiple results.
The query for age and retirement year....
DECLARE @Counter INT
DECLARE @Duration INT
DECLARE @Result DATE
SET @Counter=(SELECT MIN(DATEDIFF(YY,BirthDate,GETDATE()))FROM HumanResources.Employee)
SET @Duration=30
[Code] .....
And the result tables.
BusinessEntityID   JobTitle   BirthDate   AGE   MaritalStatus   Gender   Retirement Year69  Â
Production Technician - WC60Â Â Â 1985-05-07Â Â 30Â Â SÂ Â Â MÂ Â Â 2045-08-25 22:36:38.160115Â Â
Production Technician - WC50Â Â Â 1985-07-01Â Â 30Â Â Â SÂ Â Â FÂ Â Â 2045-08-25 22:36:38.160133Â Â
Production Technician - WC40Â Â Â 1985-02-04Â Â Â 30Â Â Â SÂ Â Â MÂ Â Â 2045-08-25 22:36:38.160144
  Â
[Code] ....
And it goes like this for 70 times. So just want to know how I can merge those 70 tables into a single table.
View 2 Replies
View Related
Feb 15, 2006
Hi,
I have a problem. For some reason I needed to restore a single (large) table that shares a filegroup with other tables. I have a full backup of the database. How can I restore my particular table?
-- Srinivas
View 3 Replies
View Related
Jan 3, 2008
Is it possible to restore a single table in SQL. If so does anyone have any idea how to go about it. Thanks in advance for the help.
View 1 Replies
View Related
Aug 19, 2006
Hello everyone, I've got a bit of an SQL mystery that I'm not sure how to solve. For some reason I just cant get my head around it. Here's the scenario:
Table A:
_____________
BidID - Int identity
AuctionID - int
BiderName - varchar(50)
bidAmount - money
______________________
Now obviously each Bid will have a Unique ID using BidID but the other rows will contain multiple bids per user, on many different items possibly.
BidID AuctionID BiderName BidAmount
1 4005 joeblow 100.00
2 4005 janedoe 101.00
3 4005 joeblow 107.00
4 4006 joeblow 100.00
5 4006 janedoe 105.00
6 4006 joeblow 106.00
I need to find out which Auctions JoeBlow is bidding on, but I dont need a table with Rows for every single one of his bids, just a distinct auctionID for his top bid so in this case the only thing returned would be
3 4005 joeblow 107.00
6 4006 joeblow 106.00
Any clues? I've been through sub querys, and stored procedures, and I cant get anything to work quite right.
Thanks in advance for your help.
View 4 Replies
View Related
Sep 14, 2006
What’s the easiest way to check if a single value exists in a table column? I’m building a simple login page, and I want to get the username and check if it exists in my Users table. Here’s my SQL: SELECT UserID FROM UsersWHERE UserID = "admin" Could someone give me code to check for “admin” in my UserID column? Here’s some code I tried, using my SqlDataSource, but it returns an error “Could not load type 'System.Data.OleDb'” protected void Button1_Click(object sender, EventArgs e) { // Retreive the results from the SqlDataSource as a DataReader OleDbDataReader reader = (OleDbDataReader) SqlDataSource1.Select(DataSourceSelectArguments.Empty); // Read in the value if (reader.Read()) { } // Close the reader reader.Close(); } I don’t have to use the SqlDataSource, but originally thought it might be easier. I know how to use SqlDataSource to fill a whole GridView but this is different.
View 2 Replies
View Related
Feb 7, 2007
I would like to get single values from a huge sql server and put it into a table. let's say 4 by 4. How do I do that?
I have a connection string with a select statement that will only return a value. But, I do not know how to put that value into a table.
Thank you.
View 4 Replies
View Related
Dec 28, 2007
Does some know of an easy to understand way to encrypt a single table column? I have never worked with encryption before.
View 1 Replies
View Related
Oct 6, 2005
numbers 2 4 2Above is an example of my table with a single column. My problem is how to add all the numbers in that column to make it 8? The rows are also dynamic. Your help is highly appreciated.
View 4 Replies
View Related
Feb 19, 2006
I am giving the following statement outside the begin tran block in a stored procedure:
select * from table1 with (holdlock) where column1 = @colValue
I have the following two questions regarding above situation:
Being outside the begin tran block, will the select statement cause a lock to be held or it has to be within the begin tran block for the lock to be held?
Will the select statement hold a lock only on the row or rows matching the where clause, or it may lock a page or even the entire table in this situation?
Thanks
View 3 Replies
View Related
Aug 4, 2000
SELECT * on a 4000 row table is taking more than 12 seconds.
Other larger tables are not nearly as slow.
I've DBCC dbreindex'd, and dbcc showcontig shows density at 100%.
How can I figure out why this is happening?
What are some remedies?
Thanks for your help.
View 1 Replies
View Related
May 31, 2002
Hi guys,
How to make single table backup / or Restore individual table from the Database backup file.SQL server 6.5 got an option to do this...Anyone know in SQL 7.0 or 2000
I appreciate ur immediate reply!
Thanks
Rajeev
View 3 Replies
View Related
Oct 1, 2007
So here's the situation: I'm creating a front-end application to an SQL Server 2000 database and I need to create a new login to the database for the app.
Is it possible (or even; is it a good idea...) to create a logon that only has access to a single table?
Actually, I know it's possible - but I don't want to have to go through the hundreds of tables and deny access to them all! So I guess the question is;
Is there a quick and easy way of granting a login permissions to a single table only?
View 5 Replies
View Related
Jul 15, 2012
I have a table fields Register_date, Std_ID, course, version, CourseLearningDays, Batch_Time and Trainer_IDHOw to make Register_date and Batch_Time as primary key in the table.. What are the necessary datatype for these two fields.And one more do we have datatype called date and time in MS SQL Server...
View 1 Replies
View Related