Can DTS Automatically Create Primary Key Values Upon Export?
May 5, 2004
I have two practice tables I have created and want to export the values of one into the source table. I want to know if I can export into a table and have the destination table automatically give a primary key value to a record? I haven't been able to figure this out even after fiddling with the "Enable identity insert" checkbox under the Column Mappings tab. I have created source tables with and without primary keys and neither works because of the fact that I need to have a value for a primary key in order to INSERT into the destination.
Do I have to copy the source records into a staging table and assign the PK values myself by hand? This can't be the answer.
ddave
View 2 Replies
ADVERTISEMENT
Jun 10, 2008
I would like to get the primary key values in a DML CREATE TRIGGER as follows:
CustomerID = 12 AND InvoiceID = 50
I create the DML trigger for UPDATE and DELETE only, how do I retrieve the values as above ?
Jon Galloway provided a sample in http://weblogs.asp.net/jgalloway/archive/2008/01.aspx but the Primary Key Field and Primary Key Value were inserted into separate columns while I need to combine the Primary Key Field and Primary Key Value into 1 single field, using his example, I want to form the primary key as:
ScoreId = 423
ScoreId = 3064
etc.
Note that his example only show a single primary key in a table whereas I need to handle multiple primary keys in a table.
View 4 Replies
View Related
Feb 11, 2015
For a new project. I need to create random alphanumeric characters as primary key values when inserting a record.
eg: cmSbXsFE3l8
It can start from 4 digit characters and can grow to 6, 7 as required
The database will involve more than 10000 concurrent users.
I don't want to use guid or auto increment integer or sequence.
View 9 Replies
View Related
Sep 13, 2006
Ok, I'm really new at this, but I am looking for a way to automatically insert new records into tables. I have one primary table with a primary key id that is automatically generated on insert and 3 other tables that have foreign keys pointing to the primary key. Is there a way to automatically create new records in the foreign tables that will have the new id? Would this be a job for a trigger, stored procedure? I admit I haven't studied up on those yet--I am learning things as I need them. Thanks.
View 4 Replies
View Related
Jan 4, 2008
How can I Export Database with foreing Key and primary key.
Operation is that
SQL2005 Management Studio/Database/Tasks/Export Data
Before Version is SQL2000 we can Selected Copy Object and data between server and then Use Default Options click checked and Select Copy Index, Copy Foreing Primary key vs vs
But this options is not found in the SQL2005 Management Studio/Database/Tasks/Export Data wizard or I can't found it.
How can I export foreing Key and primary key with SQL2005 Management Studio/Database/Tasks/Export Data wizard.
Best Regards,
Athena.
View 1 Replies
View Related
Aug 13, 2007
Hi,
I am new to SQL Server platform, i want to define primary keys automatically other than using an identity. For a table called indicator i want it primary keys to be like ind_001, ind_002, ind_003 and so on.
Can anybody help me on how to do this? I am new to this platform so i will appreciate it if suggestions are explained very clearly. Thank you
View 1 Replies
View Related
May 29, 2015
We have several Sql Server 2014 AlwaysOn Availability Groups set up in our test lab and use a combination of SCDPM and Maintenance Plans to back up the databases in them.
Our applications always work well regardless of which of the physical servers are, at any given time, designated the "Primary" for a database. Automatic failover works fine.
There are other applications, such as SQL Server built-in backup and System Center DPM that only work properly when the databases are currently hosted where originally intended.
During the normal course of Windows Updates, etc., machines will occasionally be rebooted in the middle of the night. When they come back up, we would like them to "reclaim" the databases that properly belong to them, in an orderly fashion of course (when the "Synchronization State = Sychronized"). We have lots of these test servers and we do not have staff watching the servers in the middle of the night.
Is there an automatic way to accomplish this?
View 8 Replies
View Related
Sep 14, 2006
Is it possible to have a report automatically export the results to Excel, when the report is generated? ...rather than having to select the format and click Export? .Pl let me know-Thanks.
View 1 Replies
View Related
Aug 8, 2007
Hi,
I am new to SQl Server, i have created a logical model for a database that i am creating for a project. Is there a way i can assign automatic values to my Primary Key (PK) Column other than using an identity?
For example i have a table called indicator for which the Primary Key (PK) is indicator_identifier; i want the primary key values to be
ind_0001
ind_0002
ind_0003
Please note that i may be populating the tables from a VB.NET form
Please can anybody help me?
View 2 Replies
View Related
Oct 14, 2015
I am trying to audit data quality based on some defined data quality rules. The rules are stored in tables and processed using stored procedures. I am facing a problem while generating audits. Let's say I am trying to audit data in OrderDetail table. The table design is mentioned below...I inserted some sample data into the table using RedGate data generator.The audit table output I am expecting is as mentioned in the screenshot below
Its the PrimaryKeyAttributeValues column I am facing problems with. I am using STUFF function within a dynamic SQL query to get the primary key's as a list of comma separated values.
View 2 Replies
View Related
Oct 4, 2007
I am building code to look into the database and create "CRUD" stored procedure scripts automatically for each table.
I am in the finishing stages as my procedures take into consideration all necessary parameters and keys wheter they are natural or identity. It also takes into consideration User Defined Types.
I am working on the section which defines the parameters and their default values. ie.
CREATE PROCEDURE [dbo].[TransactionHistoryInsertOne]
(
@ProductID Int = 0,
@ReferenceOrderID Int = 0,
@ReferenceOrderLineID Int = 0,
@TransactionDate DateTime = '1/1/1900', <-- Possibly arbitrary
@TransactionType nchar(1) = '?' <---- How to get this.
@Quantity Int = 0,
@ActualCost Money = 0,
@ModifiedDate DateTime = '1/1/1900'
)
AS...
I have three problems remaining.
1. Using the AdventureWorks database as a data model, I run into the TransactionType field in the TransactionHistory table, a non-nullable nchar(1). How do I determine and use any default values that may be defined for this object?
2. Do UDTs have default values already defined?
3. How do I make sure I am not arbitrarily setting the default values?
Here i my select statement into the system tables:
SELECT C.*, T.name as xtypename, U.name as xutypename, S.*, so.*
FROM syscolumns C
left join systypes T on (C.xtype = T.xtype) and (T.xtype = T.xusertype)
left join systypes U on C.xusertype = U.xusertype
left join sys.all_columns S on (C.id = S.object_id) and (C.name = S.name)
left join sysobjects so on S.default_object_id = so.id
WHERE (C.id = [TableId])";
Thanks for any help
View 1 Replies
View Related
Apr 10, 2008
im running an INSERT statement and I need one of the fields (RecordID) to be automatically generated.
Its a unique identifier type.
INSERT INTO swdata.dbo.Reports_PI
(RecordID , SD1AverageSCResTime
)
VALUES
(,xxxxxxxxxxx
,@SD1AverageCallResolutionTime
,@SD2CountAllCalls
,@SD3PercentClosedIn24Hours
)
Is there a keyword or value I can put in xxxxxxxxx that will automiatically generate a unique identifier as the record is created?
Thanks,
View 1 Replies
View Related
Nov 14, 2005
In the table, there is a record which has several field. every month, the function will create a same record. that means, the first month, one record. the secord month, two reocrds, ..... for a years. will have same 12 record. so what function can do this? Thanks.
View 2 Replies
View Related
Jul 20, 2005
Hello everybody!I'm using the 'Data Sources (ODBC)' program that comes with windows tocreate the odbc connections I need. Although that is quite fast and easy Iwould like to have it more automated, since I'm using the same parametersall the time.Can anybody tell me (or give pointers to) how that is done?regards--Johnny Ljunggren
View 2 Replies
View Related
Apr 14, 2008
hi,
i have 2 tables where i require an unique ID over both. I googled a bit and discovered that i need to create an own table for this which holds the last value (because mssql unfortunately does not support sequences).
i did this but my problem now is that i want to automatically set the id of my tables with a trigger on INSERT.
hope this is possible .. or anyone have other suggestions?
thanks a lot!
View 4 Replies
View Related
Apr 26, 2007
I have created a report, and am setting default values for the parameters. Once the default parameters is set, the report automatically generates. Is there a way to make it not automatically generate the report? We are setting the parameters with values that will get the end user the most recent data, but alot of times, they will want to pull older data as well. We don't want them to have to wait for the report to automatically generate before they can change the parameter values
View 1 Replies
View Related
May 2, 2006
Hi, all,
I have a question about adding a unique key column to an existing table.
what i trying to do is that: I have already created a table, now i wanna add a ID column to this table, and generate the values for ID column from 1 to the existing row number. How can I get this done?
Thanks a lot in advance for any guidance.
View 6 Replies
View Related
Nov 10, 2006
If all the parameters for a report have default values, the report runs automatically as soon as you open it. Is there a way to prevent this?
View 9 Replies
View Related
May 14, 2006
Hi,
I need help in looking at sample script to perform automatic creation for weekly partitioned tables and also update the partitioned view accordingly.
Any helps are very much appreciated!
Thanks,
G
View 1 Replies
View Related
May 12, 2007
Hi frdz, I m creating my web-application in asp.net with C# 2005 and using sql server 2005. I have created the stored procedure for the insert,update. I want to know how to write the mathematical calculations in the stored procedure.. Pls tell me from the below stored procedure were i m making the mistake ?? As the discount and the total amount are not calculated by itself....and stored in the database How to convert the @discpercent numeric(5,2) to@discpercent ="NoDiscount" should be displayed when no discount is being given to the customers.... ALTER PROCEDURE CalculationStoredProcedure
@accountid int output,
@accountname varchar(20),
@opbal numeric(10, 2),
@opbalcode char(2),
@total numeric(10, 2),
@clbal numeric(10, 2),
@clbalcode char(2),
@discpercent numeric(5,2),
@discamt numeric(10, 2)
as
begin
set nocount on
if @opbal IS NULL OR @opbal = 0
begin
select @opbal=0
select @opbalcode= ' '
select @clbal= 0
select @total= 0
select @clbalcode= ' '
@discpercent ="NoDiscount"
@discamt=0
end
select @accountid = isnull(max(accountid),0) + 1 from accountmaster
select @total=@opbal - @clbal from accountmaster
select @discamt=@total* @discpercent/100 from accountmaster
begin
insert into accountmaster
(
accountname,opbal,opbalcode,clbal,clbalcode
)
values
(
@accountname,@opbal,@opbalcode,@clbal,@clbalcode
)
end
set nocount off
end
Thanxs in adv...
View 7 Replies
View Related
Aug 5, 2015
I need to deploy the trigger in database whenever new DB is creating on the server.
View 6 Replies
View Related
Jun 7, 2005
Hi,
i am using the enterprise manager of our sql server 2000. i want to
export some (not all) tables from one DB to another one with all the
data inside these tables AND the primary keys. if i do i only receive
the tables with the data but all primary keys and indexes will be lost.
how to do it?
thanks, tobi
View 7 Replies
View Related
Nov 14, 2003
Can someone tell me if there's a way to export data from one database to another without losing the primary key information that has been set in the source database?
Please respond to URL. Thanks!
CC
View 1 Replies
View Related
Jul 23, 2005
When I export a table from my local SQL Server to my web-host's SQLServer, the primary key never seems to export. This happens whether Iuse the "Copy tables and views..." option or the "Copy objects anddata..." option. Anybody know why this happens?
View 3 Replies
View Related
Feb 7, 2008
Currently, I'm exporting a database from production to local (test)machine. I've done this several times without problem, but during thelast few days, the primary keys have failed to export. Would anyoneknow what options might keep the keys from exporting?Thanks,Louis
View 3 Replies
View Related
Sep 25, 2015
Is there a way that I can do this at the table level to automatically handle the rounding of seconds, etc. down to the minute automatically without having to use a trigger?
Here is a very basic example of what I am trying to do:
--example: '09-22-2007 15:07:18.850' this is the value inserted into the table by the code
select getdate()
--example: '2007-09-22 15:07:00.000' this is the value I want to store in the table
select dateadd(mi, datediff(mi, 0, getdate()), 0)
View 24 Replies
View Related
Jun 10, 2014
How to create insert statements of the data from a table for top 'n' rows. I know we can create using generate scripts wizard, but we can't customize the number of rows. In my scenario i got a database with 10 tables where every table got millions of records, but the requirement is to sample out only top 10000 records from each table.
I am planning to generate table CREATE statements from GENERATE Scripts wizard and add this INSERT STATEMENT at the bottom.
EX : INSERT [dbo].[table] ([SERIALID], [BATCHID] VALUES (126751, '9100278GC4PM1', )
View 4 Replies
View Related
Oct 31, 2015
I have an existing MS SQL database (2008 R2). I have a very simple SQL script. I need to automate this script means wants to create a job which runs on a Friday basis and save the output results of the query as a excel file and then automatically sends the mail to everyone.
View 9 Replies
View Related
Jun 17, 2015
A common partitioning scenario is when the partition column has the same value for every record in the partition, as opposed to a range of values. Am I the only person who wonders why there isn't an option to automatically partition a table based on the unique values of the partition column? Instead of defining a partition function with constants, you ought to be able to just give it the column and be done. This would be particularly valuable for tables partitioned on a weekly or monthly date; when new data is added it could simply create a new partition if one doesn't already exist.
View 4 Replies
View Related
May 20, 2008
the subject pretty much says it all, I want to be able to do the following in in VB.net code):
{[If [table with this name] already exists [in this sql database] then [ don't create another one] else [create it and populate it with these values]}
How would I do this?
View 3 Replies
View Related
May 28, 2002
l would like to run a health check on my newly designed database to ensure that l've covered all the necessary points to ensure that l have a good database. Is there there such a procedure?
If l want to create a primary key on a table with duplicates, how would l achive that? l tried to create a new table then create the pk. then ran the following script to populate
instert into tabB
select * distinct tabA
It did not work. Please advive
View 1 Replies
View Related
Mar 21, 2002
Can I avoid cursor (use while of if statement instead ) if for example I have two sales people for the same company and I need one row per company?
View 1 Replies
View Related
Jul 20, 2005
Hello group:I've done alot of reading on this subject somewhat and have found thatmany people have many different opinions on this subject. My questioncenters mainly around using a lookup table to enable users to select apre-defined list of values.I have developed a practice myself of avoiding AutoNumber type datafields for primary keys where the primary key will be related to achild table. Nevertheless, what do most users do with lookup tables?My thoughts are to create a small key value for each value in thelookup table. For example:I might have a Carriers table which shows a list of carriers that Imight ship an order by. One of the entries may be 'Air Freight -Overnight', or 'Air Freight - 2nd Day Air'. I've seen a few exampleswhere the primary key field for each entry like these would beautonumber, or at least, a numeric value. What I like to do is createmy own key, like for 'Air Freight - Overnight', I might use 'AFO' forthe key, and for 'Air Freight - 2nd Day Air', I might use 'AF2'. Anythoughts on this? Mine are that even tho the users may never see thisvalue - I, as the developer will see it and I tend to prefer a keyvalue based on real data that means something other than anauto-incremented number. In referencing the well-known Northwind.mdbdatabase, I noticed their Categories table used a number field value,like 1, 2, 3....etc, but their customers table used values like'ALFKI' to represent their key values.What are some other thoughts out there? I'm working with Accesscurrently, but this project is about to move to SQL Server.James
View 3 Replies
View Related