How To Create A Sql Server Sequence Similar To Oracle?

Jun 2, 2008

In oracle, I can setup a sequence generating unique ids and query the next value (which is used as a unique identifer). I know sql server has the identity field but I need to query the next val so I can insert rows into multiple tables.

When a user submits a form, I want to take the dept info from the form (in c# asp.net 2.0) and grab the first two characters. Then query the next val from a table that holds an int.. During insert into two tables it would be something like "IT100" or "SL101". But it needs to be unique.

Is there a way to setup a table in sql server similar to a sequence where I can just query the next val (or some other way?). Remember, I cant do this as identity because I need the key being inserted in other tables during form submit.

 It seems very simple but I can't seem to find an answer online that allows me to query the next val in my code then perform the multiple inserts.

Thanks in advance for any assistance you can lend on this,

dev1aspnet

View 2 Replies


ADVERTISEMENT

Can I Implement A File System With SQL Server Similar To Oracle Content Services?

Apr 29, 2008

I need to implement a file system for an application that allows me to roll back to a point in time. I can do this with either a journaling file system (Unix based such as JFS) or with a database file system such as Oracle Internet File system (now Oracle Content Services). I would MUCH prefer to use SQL Server but cannot find anything that supports this other than a 2000 ppt referencing the then up and coming SQL Server .NET File System.

The application(s) in question are older and store data in proprietary data files and need to access a local (or mapped) drive in standard form (d:programsmyprogram).

Does SQL Server 2005 or 2008 support this type of access? I have searched but cannot find anything to support this.

Thanks.
B.W.

View 1 Replies View Related

How To Convert SQL Server Datetime To Oracle Timestamp (or Other Type With Similar Precision)?

Jul 10, 2007

In SQL Server I've created a linked server to an Oracle database. I am trying to insert (within the context of an sql server table trigger) an SQL Server datetime to an Oracle column with similar precision. Oracle timestamps are not compatible with sql server datetimes and I don't know how to convert the data (or if I should use a different type of column to store the data in Oracle). I have full control over the structure of the Oracle table so I can use a different type if timestamp is not best, but I need the destination column to have at least the same precision as the sql server datetime value. What is the easiest way to do this?

View 22 Replies View Related

How To Basically Copy Tables With New Names Rather Than Create Similar Tables From Similar Manual Input.

May 26, 2007

I have a table that I am basically reduplicating a couple of times for each part of this database that I want to create.Each table basically has the same data: The tables will be called motherTable, fatherTable, sonTable, daughterTable and so on.I am pretty much using the following in each column: UserID, MotherID(or FatherID or SonID, etc., etc. and so on for each unique table), FirstName, LastName, MiddleName, BirthPlace, Photo, Age.I don't see an option to copy a table and just modify the second ID part and rename that table accordingly.How can I make this an easier way of creating these similar tables without retyping all these columns over and over again?Thanks in advance. 

View 4 Replies View Related

Inserting Into Oracle Table That Has DATE_HIGH As A Partition And Need Oracle Sequence Used

May 11, 2007

Hi Everyone,



I've been searching for a solution for this for a week-ish, so I thought I would post my quesiton directly. Here is my scenario..



Source: MS SQL Server

Destination: Oracle 10g



The destination table has a partition set on a column called "DATE_HIGH". How do I populate this date high column in my package? Currently I just have a source object, and a destination object, but I'm unclear how to populate this field in the destination. I've read one blog that states "use OLE DB Command" - but that isn't enough information for me to implement - Can someone be more specific in these steps? Here is an example of what my newb-ness needs to understand



OLE DB Source (Select * from Table) ---> OLE DB Command (What query goes here?) --> OLE DB Destination.



Second part of my question: There is a second column called "ROW_NUM" and there is an Oracle Sequence provided to me... What objects do I need (Source, Destination, OLE DB Command etc...) and how do I call this sequence to populate on the fly as I'm loading data from my source?



If these are simple questions - my appologies, I am new to the product.



Best Regards,



Steve Collins

View 1 Replies View Related

HOW TO GET THE RESULTS IN THE SAME SEQUENCE IN ORACLE 9i AND SQL SERVER 2005?

Aug 13, 2006

In ORACLE 9i, I created the table test that show the tree structure of an organizaion with the following SQL statement:

CREATE TABLE TEST(
PARFOLDERNO NUMBER(8,0),
FOLDERNO NUMBER(8,0)
)

And select the data using the following SQL Statement:
SELECT PARFOLDERNO,FOLDERNO FROM TEST

The result is:
PARFOLDERNO FOLDERNO
0 2461
2461 2463
2461 2462
2462 2465
2462 2466
2463 2469
2463 2470

To show the subnodes of the root node 2461, the following SQL Statement is used:

SELECT PARFOLDERNO,FOLDERNO FROM TEST START WITH FOLDERNO=2461 CONNECT BY PRIOR FOLDERNO=PARFOLDERNO

the results:

PARFOLDERNO FOLDERNO
0 2461
2461 2463
2463 2469
2463 2470
2461 2462
2462 2465
2462 2466

I have created the table test with the same structure and the same data in SQL Server 2005. To show the subnodes of the root node 2461, the following SQL Statement is used:

WITH CTE_TEST(PARFOLDERNO,FOLDERNO)
AS
(
SELECT PARFOLDERNO,FOLDERNO FROM TEST WHERE FOLDERNO=2461
UNION ALL

SELECT TEST.PARFOLDERNO,TEST.FOLDERNO FROM TEST, CTE_TEST
WHERE TEST.PARFOLDERNO=CTE_TEST.FOLDERNO
)

SELECT PARFOLDERNO,FOLDERNO FROM CTE_TEST

PARFOLDERNO FOLDERNO

02461
24612463
24612462
24622465
24622466
24632469
24632470


The results are shown again in Oracle 9i and SQL Server 2005 as follwos:

Oracle 9i SQL Server 2005

PARFOLDERNO FOLDERNO PARFOLDERNO FOLDERNO
0 2461 0 2461
2461 2463 2461 2463
2463 2469 2461 2462
2463 2470 2462 2465
2461 2462 2462 2466
2462 2465 2463 2469
2462 2466 2463 2470

How can I get the result with the same sequence in SQL Server 2005?


Thanks!

View 11 Replies View Related

Oracle Sequence/Link 2 MS SQL SERVER 2005

Nov 30, 2006

hi,1. is there a statement in ms sql, what creates a sequence? cant findanything in web :-(-oracle: CREATE SEQUENCE XYZ INCREMENT BY 1 START WITH 1 NOCYCLECACHE 20;-ms sql: ???2. hwo do i create a link to another ms-sql databasethx a lot need help, urgend :-)

View 14 Replies View Related

COMMAND SIMILAR TO SPOOL IN ORACLE

Jan 16, 2002

Hi all,
I have a table with the list of tables I need to drop. So basically before droping those tables I need to disable the FK and PK constraints.
So I want to spool out the out of this script.
SELECT 'ALTER TABLE ' +
QUOTENAME( c.TABLE_NAME ) +
' NOCHECK CONSTRAINT ' +
QUOTENAME( c.CONSTRAINT_NAME ) AS ALTER_SCRIPT
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS c
WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'

Is there a way to store the output of this script in a .sql file so that I could execute it.
Any thoughts will help!
Thank you!

View 5 Replies View Related

Similar Option Of Oracle's ROWID

Oct 12, 2007



Hi,

Im a SQL server2000 user, do we have any option similar to Oracle's ROWID in sql server?

Rgds
Rajesh

View 1 Replies View Related

SQL Server 2012 :: Populate Value In Create Sequence?

Jul 29, 2015

I'm looking to see if there is a way to populate starting number for the sequence from a max value of a table.

CREATE SEQUENCE test_seq
AS [int]
START WITH (select max(col1)+1000 from table1)
INCREMENT BY 1
MINVALUE 1
MAXVALUE 2147483647
CACHE
GO

View 3 Replies View Related

Sqldatasource InsertCommand && Oracle Sequence.

Jan 10, 2006

I cannot get an Oracle sequence to work in an Sqldatasource InsertCommand:I've tried the following:
InsertCommand='INSERT INTO "WHSTSTICKETS" ("WHSTS_ID", "CUSTOMER_ID") VALUES (whsts_id.nextval,:CUSTOMER_ID)And: InsertCommand='INSERT INTO "WHSTSTICKETS" ("WHSTS_ID", "CUSTOMER_ID") VALUES (:Testing,:CUSTOMER_ID)<asp:Parameter DefaultValue="whsts_id.nextval" Name="testing" />AndInsertCommand='INSERT INTO "WHSTSTICKETS" ("WHSTS_ID", "CUSTOMER_ID") VALUES (whsts_id.nextval,:CUSTOMER_ID)
This is the classic error I get:ORA-01036: illegal variable name/numberI did review the asp.net forums before posting this.  As well, I've looked through the VWD 2005 documentation and cannot find the answer to this question.  Argg!  Any help is appreciated.   I've also worked to try and find out how to view the SQL that the Sqldatasource is generating, but I can't find the answer to this either.

View 8 Replies View Related

Need To Lookup An Oracle Sequence Value Within A Dataflow

Apr 18, 2007

I can successfully get an Oracle sequence value using an "Execute SQL Task" transform. I need to, however, be able to get the same type of value from within a dataflow. I've tried the "OLE DB Command" and the "Lookup" Transform without any luck.



With the lookup transform I run into the following problem. First of all for those of you who know about the Oracle Sequence it just returns the next value from a sequence generator using "mysequence.NEXTVAL". The lookup transform won't just return a value without providing a link. So what I attempted to do was create a derived column with a value of "0" and use the following SQL command in my lookup ( SELECT mysequence.NEXTVAL, 0 AS DUMMY from DUAL). I then linked the derived column to the DUMMY column and it appeared to work. I was able to get the sequence. However, it appears to cache the value and so for each row the sequence is the same and doesn't increment.



I then tried to unsuccessfully play around with nocache but had strange errors about "not a valid sql statement".



I then also tried the OLE DB Command with a SQL statement "SELECT mysequence.NEXTVAL FROM DUAL" but couldn't get that to work.



Does anyone have any ideas or recommendations. Please keep in mind that I HAVE to get the NEXTVAL from Oracle as this is a mandatory requirement since the source is Oracle Applications ERP and I can't make up my own sequences in SSIS or update that sequence after the fact since many other applications could be using that sequence besides me.



thanks

John

View 16 Replies View Related

Integration Services :: Oracle Sequence Number Within SSIS

Jul 22, 2015

For each row coming out of my data source, I would like to add the result of an Oracle query to it (select sequence.nextval from dual).

I need to acquire the sequence number before all my processes in my data flow, so I don't want to have a trigger in Oracle call nextval and do it automatically for me.

I also think getting the value of nextval inside of a variable at the beginning of the process would not work because it only increments the value once.

View 2 Replies View Related

Problem When From Sequence File Insert Into Oracle Destination Table In SSIS Package

Jun 20, 2006

Hi ,



i was used the Follwing DataFlow for my Package.using Oracle 8i



FalteFile Source -------------> Data Conversion --------------->OLEDB Destination (Oracle Data table)

using above control flow to map the Source file to Destination . When i run the SSIS Package teh Folwing Error i got

"Truncation Occur maydue to inserting data from data flow column "columnName " with a length of 50 "

regarding this Error i i understood its for happening Data Length . so that i was changed the Source Column Length Exactly Match with the The Destination table.

still i am getting this Error. pls any one give me a solution . SHould i Change the DataType also?

pls give your suggestion



Thanks & Regards

Jeyakumar.M

chennai

View 3 Replies View Related

How Can I Create A Sequence ?

Jul 16, 2001

Hi,

I would like to know how it is possible to create a sequence with sql server 2000
With Postgres SQL i create the sequence essai : create sequence essai START 1;
but i don't know what is the sql command.

Thanks in advance.

Marie

View 1 Replies View Related

How To Create Unique Field Or Sequence In View

Jun 5, 2012

I have created a view based on joining 3 tables, however, it is not possible to have a unique field in the view which I must need it and I must create index on some other fields. Is there any way to create sequence number or uniqie field in mssql view.

View 13 Replies View Related

Automated Drop/create Script Right Sequence

Apr 17, 2008

Greetings

I was directed to post this here. I am thinking of creating a script that generates another script for creating/dropping tables, indeces, FK, views, stored procedures..etc in the correct sequence in a specific database. I accept the fact this script is dangerous (like if I ran it on production server). But it sure will be very helpful when moving our SQL objects from development to qa and then to production. Is this worth it? Have you see anything that generates such a thing using sys.objects,sys.indexes,sys.foreign_keys etc?

Thanks

View 1 Replies View Related

How To Create A Sequence Generator Number In SSIS

Mar 28, 2006

Hi,

I got 5000 rows in source and when i am sending the data to destination it has to create a sequence generator number for each row.

Can any one help me which transformation do i need to take for doing this in SSIS.













View 10 Replies View Related

How To Create A Sequence Invoice Number And Insert Or Update To A Column?

Feb 22, 2005

Hi, can anyone teach me how to automatic create a invoice number and insert or update it to a column?

View 2 Replies View Related

Cannot Create A New Oracle Publisher

Apr 30, 2007


I got this error when create a Oracle Publisher:

Oracle server cannot be enabled as a Publisher because of the following error:
Additional inlonnation:
Unable to connect to Oracle database server 'abc€™ using the Microsoft OLEDB provider MsDAORA.
For addition ilorrnation, see SQL Server Eiror 21627 in Troubleshooting Oracle Publishers in sQL Server Books 0nline. (Microsoft sQL Server, Error: 21627)

The login works fine in SQL Plus.

My test server:


SQL Server 2005 Developer w/ SP2

Oracle Client installed on SQL Server DB

MSDAORA installed
Please help.

Regards,

d-cpt

View 3 Replies View Related

Array (or Similar Thing ) In Sql Server

Jul 4, 2005

I would like to write a fun or stored procedure to do some operation. It require me to know that what category is currently belong to certain people(people_table: category_table1               to           Many)However, when i use the select statement in stored proc, it return a set of result, not a scalar , therefore, i cannot use the variable to hold it. In addition, there are no array in SQL server.Question:1. Is there any way to hold the collection of result(like array)?2. Also, how to determine to use fun or stored procedure?(Since a integer is need to return by them)Thx

View 4 Replies View Related

How Can I Apply Transaction Log To The Other Similar SQL Server

Apr 26, 2001

I have two SQL 6.5 servers running independently. Both servers have almost identical databases. For example, we create purchase order in SQL server A. And post the same purchase order # for it's PO Receipt and PO Inspection in SQL server B. How can I apply all transactions entered from SQL server A to SQL server B, and vise versa at end of the day. How can I get help or training for writing codes for manipulating transaction log?

View 1 Replies View Related

Setting Up Oracle Linked Server : Need Help : Sql2005 Running On XP Linking In Oracle 10.2

Oct 26, 2006

Is there any step by step help sites for setting up SQL 2005 linked (oracle 10) server?

I find MSDN articles but they referance winNT and 2000, I'm not getting very far and I'm not a DBA but need to get this working asap.

View 1 Replies View Related

Data Access :: Accessing Oracle Tables From Server Via Oracle DBLINK?

May 8, 2015

we recently got a scenario that we need to get the data from oracle tables which is installed on third party servers. we have sqlserver installed on ourservers. so they have created a DBLINK in oracle server to our sqlserver and published the DBLINK name.

what are the next steps that i need to follow on my sqlserver in order to access the oracle tables ?

View 2 Replies View Related

Trouble With: Linked Server To Oracle Using OraOLEDB.ORacle Provider

Jan 11, 2007

Hi--

 

I am running SQL Server 2005 on Win2k3:

Microsoft SQL Server Management Studio      9.00.2047.00
Microsoft Analysis Services Client Tools      2005.090.2047.00
Microsoft Data Access Components (MDAC)      2000.086.1830.00 (srv03_sp1_rtm.050324-1447)
Microsoft MSXML      2.6 3.0 4.0 6.0
Microsoft Internet Explorer      6.0.3790.1830
Microsoft .NET Framework      2.0.50727.42
Operating System      5.2.3790


I have the OraOLEDB.Oracle provider installed to the (C:oraclexe) directory.

I am having problems querying from linked oracle server.  When i setup oracle as a linked server and purposely enter an incorrect password the query i run tells me i have an incorrect password.   So it at least knows that.  when i set the correct password and run a query I get this error:

(i replaced the real server name with "someServer".)

Msg 7399, Level 16, State 1, Line 1

The OLE DB provider "OraOLEDB.Oracle" for linked server "SomeServer" reported an error. The provider did not give any information about the error.

Msg 7303, Level 16, State 1, Line 1

Cannot initialize the data source object of OLE DB provider "OraOLEDB.Oracle" for linked server "SomeServer".

 

This is how I set up my Linked server:

Provider: "Oracle Provider for OLE DB"

Product Name: SomeServer

Data Source: SomeServer

Provider String:  "Provider=OraOLEDB.Oracle;Data Source=SomeServer;User Id=MyLogin;Password=MyPassword"

 

 

The query I run is:

Select * from [Someserver].[schema or database]..[tbl_name]

 

Any help???  What am i missing?

View 3 Replies View Related

How To Create Connection Manager For Oracle DB Using ODBC?

Jan 17, 2008

Hi,
I want to import data from Oracle database programmatically using ODBC connection manager. I was able to import data by creating an ODBC DSN and then using it BIDS with ADO.NET connection using ODBC data provider for Oracle. Now I want to do the same programmatically. How should I create a connection manager? I tried using code below


ConnectionManager cmOracle = this.package.Connections.Add("ADO.NET: ODBC");

cmOracle.Name = "OracleSourceConnection";

cmOracle.ConnectionString = "Dsn=MyDSN;uid=MyID;";

But I get an error when acquiring connection
ErrorCode=-1071611874

The connection manager "__" is an incorrect type. The type required is "__". The type available to the component is "__".
Which one of the connection managers given by Microsoft here should be used?
http://msdn2.microsoft.com/en-us/library/ms136093.aspx
Has anyone come across similar scenario?

Thanks


View 3 Replies View Related

Does SQL Server 2005 Has Similar Function Like Mysql_fetch_row ?

Mar 13, 2008

I just began to use SQL Server 2005 as database programming and
found out that I have to translate mysql_fetch_row into SQL Server 2005
but I cannot find some related functions/api, and I was wondering
Does SQL Server 2005 has similar function like mysql_fetch_row ?
Or if not, any advice how I can program to acheive similar functions ?
thank you in advance.

View 4 Replies View Related

How To Create A Transaction Commit/Rollback For Oracle DB In SSIS

Oct 8, 2007

I'm able to connect to the Oracle database to insert the data into multiple tables using OLEDB connection via Oracle Provider for OLEDB. However, i wish to create a transaction so that i'm able to rollback all the data in the case where the insertion fails in one of the table. May i know where should i start from?

View 4 Replies View Related

SQL Server 2014 :: Merge Similar Records From Excel?

May 19, 2015

I am working on a project that will require me to get a flat data file (excel spreadsheet) with hundreds of thousands of records. Each record is an Owner, and specifically what they own. There will be a field for OwnerName that I want to figure out a way to pull the data into a database like;

Table(Owners) - make sure owner is listed only once

Table(Properties) - joined to owners showing all properties that person owns

Now the tricky part, the owner names might not be exactly the same. Some records might have;

Smith, John
John Smith
Smith, John T
etc.

To make matters worse, this will be a continuous process. I will receive updated excel spreadsheets from time to time and will need to import the new records, many times overwriting the old data. For the good news, there should be an OwnerID that will be unique within the excel data. So as I am merging similar records into the Owners table, I should have a list of OwnerID's that can forever be used to link to the owner.

View 3 Replies View Related

SQL Server 2014 :: Similar Queries Produce Different Output?

Sep 22, 2015

create table #t1 (id int)
create table #t2 (id int)

insert into #t1 values (1)
insert into #t1 values (2)
insert into #t1 values (3)

insert into #t2 values (1)
insert into #t2 values (2)

Run the below quires, you will get 2 different outputs.Second is the desired output. I cant find reason for query1

-- Query1

select * from #t1 a left join #t2 b on a.id = b.id and b.id is null

-- Query1

select * from #t1 a left join #t2 b on a.id = b.id where b.id is null

View 3 Replies View Related

SQL Server 2014 :: Splitting Similar Data Into Separate Columns?

Aug 18, 2015

If you see below there are 2 customer names on 1 loan, most of them share the same lastname and address, I want to separate it with fields,LoanID, customer 1 Firstname, Customer 1 Lastname, Customer 2 FirstName, Customer 2 Lastname, Adddress,zip

Loan IDFirst NameLastnameAddressaddress 2CityStateZip
1236048Joey Yesen xxxx abc GROVE RDNULLCLEVELANDTX77327
1236048Dickey Yesen xxxx abc GROVE RDNULLCLEVELANDTX77327
1235983Randy Seany xxxx abc Haleyville StNULLAuroraCO80018
1235983Barry Seanyxxxx abc Haleyville StNULLAuroraCO80018

The query I am using

select
L.Loanid
,B.FirstMiddleName
,B.LastName
,MA.AddressLine1
,MA.AddressLine2
,MA.City
,MA.State
,MA.Zip

from Loan AS L

LEFT JOIN Status As S on S.LoanID = L.LoanID
LEFT JOIN Borrower B on B.LoanID = L.LoanID
LEFT JOIN MailingAddress MA on MA.LoanID = L.LoanID
where S.PrimStat = '1' and B.Deceased = '0'

View 3 Replies View Related

DB Design :: How To Avoid Similar Entries In Column List In Server

Sep 16, 2015

I am sharing one sql query and o/p:

select distinct  case 
          when LastStatusMessageIDName = 'Program completed with success' then 'Office 2013 SP1 Installed Successfully'
          when LastExecutionResult = '2013' then 'Machine Does not have Office 2013'
          when LastExecutionResult = '17023' then 'User cancelled installation'
          when LastExecutionResult = '17302' then 'Application failed due to low disk space.'

[Code] .....

The below is the output for the given query,here i want to see only one comment value in my list and the count is also sum of all where comment should be Application will be installed once machine is online(Bold columns o/p)

Comment  Machine Name
Application will be Installed once machine is Online 4
Application will be Installed once machine is Online 12
Application will be Installed once machine is Online 42
Application will be Installed once machine is Online 120
Machine Does not have Office 2013 25
User cancelled installation 32
Application failed due to low disk space 41
Office 2013 SP1 already Exist 60

I need o/p like below:in single line

Application will be Installed once machine is Online 178
Machine Does not have Office 2013 25
User cancelled installation 32
Application failed due to low disk space 41
Office 2013 SP1 already Exist 60

View 2 Replies View Related

How To Group Similar Column Name And Sum The Similar Column Name Together

Apr 10, 2008

Hey Gurus,

I have a problem on getting the sql statement which will group similar column name and sum their number together(another column).


A million thanks in advance.

View 5 Replies View Related







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