November 17, 2011 at 4:42 pm
i have two tables....1st one has columns name RlseId and a datetime column..
2nd table has TrackID(primary key,automatic generated) , RlseId(foreign key of 1st table) and RlsTrackId...but no date time column...
whenever the RlsId is inserted into the 2nd table...TrackId is generated automatically...i want to get the TrackId for recent updates but the problem is RlsId got duplicates...
able to get RlsID on particular date & time from 1st table..but for the same Id i am not able to get TrackID from the 2nd table as RlsId got duplicates and no datetime column...
Is it acceptable to have duplicate RlseId values in table1 ?
November 18, 2011 at 2:10 am
yes...Duplicate is allowed for RlsID in both the tables...the table structure they created was very worst...
the table 2 does not have any datatime column...so i am not able to get the exact TrackID for the time what i expect from Table 2 due to duplicate rows in RlsId...
Thanks,
Charmer
November 18, 2011 at 2:17 am
anthony.green (11/17/2011)
please post the DDL and sample data of the objects in the problem
Charmer...pls post as asked above
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
November 18, 2011 at 4:04 pm
I thought this was it:
OPENROWSET
( { 'provider_name' , { 'datasource' ; 'user_id' ; 'password'
| 'provider_string' }
, { [ catalog. ] [ schema. ] object
| 'query'
}
| BULK 'data_file' ,
{ FORMATFILE = 'format_file_path' [ <bulk_options> ]
| SINGLE_BLOB | SINGLE_CLOB | SINGLE_NCLOB }
} )
<bulk_options> ::=
[ , CODEPAGE = { 'ACP' | 'OEM' | 'RAW' | 'code_page' } ]
[ , ERRORFILE = 'file_name' ]
[ , FIRSTROW = first_row ]
[ , LASTROW = last_row ]
[ , MAXERRORS = maximum_errors ]
[ , ROWS_PER_BATCH = rows_per_batch ]
November 18, 2011 at 4:39 pm
Steve Malley (11/18/2011)
I thought this was it:OPENROWSET
( { 'provider_name' , { 'datasource' ; 'user_id' ; 'password'
| 'provider_string' }
, { [ catalog. ] [ schema. ] object
| 'query'
}
| BULK 'data_file' ,
{ FORMATFILE = 'format_file_path' [ <bulk_options> ]
| SINGLE_BLOB | SINGLE_CLOB | SINGLE_NCLOB }
} )
<bulk_options> ::=
[ , CODEPAGE = { 'ACP' | 'OEM' | 'RAW' | 'code_page' } ]
[ , ERRORFILE = 'file_name' ]
[ , FIRSTROW = first_row ]
[ , LASTROW = last_row ]
[ , MAXERRORS = maximum_errors ]
[ , ROWS_PER_BATCH = rows_per_batch ]
That is not DDL. DDL is data definition language and is the structure of YOUR table or other object. Should look something like this:
CREATE TABLE tableName (column1 INT ID, column2 VARCHAR(25))
Jared
Jared
CE - Microsoft
November 19, 2011 at 4:05 am
p-nut (11/18/2011)
Steve Malley (11/18/2011)
I thought this was it:OPENROWSET
( { 'provider_name' , { 'datasource' ; 'user_id' ; 'password'
| 'provider_string' }
, { [ catalog. ] [ schema. ] object
| 'query'
}
| BULK 'data_file' ,
{ FORMATFILE = 'format_file_path' [ <bulk_options> ]
| SINGLE_BLOB | SINGLE_CLOB | SINGLE_NCLOB }
} )
<bulk_options> ::=
[ , CODEPAGE = { 'ACP' | 'OEM' | 'RAW' | 'code_page' } ]
[ , ERRORFILE = 'file_name' ]
[ , FIRSTROW = first_row ]
[ , LASTROW = last_row ]
[ , MAXERRORS = maximum_errors ]
[ , ROWS_PER_BATCH = rows_per_batch ]
That is not DDL. DDL is data definition language and is the structure of YOUR table or other object. Should look something like this:
CREATE TABLE tableName (column1 INT ID, column2 VARCHAR(25))
Jared
It looks like copy paste error. He pasted it in wrong window (thread). 😀
November 19, 2011 at 9:21 am
If table has primary/unique key and SELECT has not ORDER BY clause then
the result will be sorted by key. Otherwise no guarantee of sort order.
November 19, 2011 at 9:34 am
Don't miss the sequel of this thread... 😀
Last 5 rows - Part II aka Insertion order - GETDATE(), IDENTITY_INSERT, and others...
http://www.sqlservercentral.com/Forums/Topic1207526-391-1.aspx
November 19, 2011 at 10:06 pm
Clarence R. Assey (11/19/2011)
If table has primary/unique key and SELECT has not ORDER BY clause thenthe result will be sorted by key. Otherwise no guarantee of sort order.
Although the optimizer certainly has gotten better at selecting data ordered by key, there's still no guarantee that a SELECT will return data in order by the PK without an ORDER BY.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 21, 2011 at 3:18 am
Hi friends,
How to add a file into this?
my DDLs are stored in a notepad...
How can i import into this..?
Thanks,
Charmer
November 21, 2011 at 3:22 am
Charmer (11/21/2011)
Hi friends,How to add a file into this?
my DDLs are stored in a notepad...
How can i import into this..?
What? Where? How? Didn't get anything...
If it's not related with 'Last 5 Rows' question, please start a new thread with more information.
November 21, 2011 at 3:26 am
the DDLs are related to the question that i started..
so i would like to know how to import files?
Thanks,
Charmer
November 21, 2011 at 4:13 am
Dev (11/21/2011)
Charmer (11/21/2011)
Hi friends,How to add a file into this?
my DDLs are stored in a notepad...
How can i import into this..?
What? Where? How? Didn't get anything...
If it's not related with 'Last 5 Rows' question, please start a new thread with more information.
It is related to the topic which were discussed regarding finding records not having Date time column and having some duplicate rows...
Thanks,
Charmer
Viewing 13 posts - 46 through 57 (of 57 total)
You must be logged in to reply to this topic. Login to reply