Showing posts with label primary. Show all posts
Showing posts with label primary. Show all posts

Wednesday, March 21, 2012

Name of primary key

What 's the way to know
the name of the column that is
the primary key of a tableTry this one:

select 'Table ['+su.name+'.'+so.name+']',sc.name
from sysindexes sy
join sysobjects so on so.id=sy.id and so.xtype='U'
join sysusers su on su.uid=so.uid
join sysindexkeys si on si.id=so.id and si.indid=sy.indid
join syscolumns sc on sc.id=so.id and sc.colid=si.colid
join sysobjects sop on sop.parent_obj=so.id and sop.xtype='PK' and sop.name=sy.name
where sy.indid not in(0,255)|||Thank you

forgot that existed sysindexes|||Thank you very much

Naive Question on Export Data

Hi All,
When data is exported, to another database, the primary keys are not
available in the exported tables. Is there a way to export the data in the
tables along with all the properties of the table, I mean creating a ditto
copy of the original table along with data.
Thanks
kd
If you want a replica of the database, I suggest you use backup and restore.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"kd" <kd@.discussions.microsoft.com> wrote in message
news:948F9BFC-7F18-4BFA-9572-F516066E539F@.microsoft.com...
> Hi All,
> When data is exported, to another database, the primary keys are not
> available in the exported tables. Is there a way to export the data in the
> tables along with all the properties of the table, I mean creating a ditto
> copy of the original table along with data.
> Thanks
> kd
>

Friday, March 9, 2012

mysql immediate assistance needed please.

Objective:
The primary table I loaded into MySql has 2.5 MM records: ID, Ticker,
Date, Price; and all works well. My need is to write a QUERY to export
outfile?) multiple text files. For example, I have 6 years worth of
data, and need to generate 1 file per day that contains all the Tickers
and Prices for that day. Furthermore, I need the text file name to be
the name of the date (e.g. April 4, 1998 with 1000 Tickers & Prices
would result in a file that was named "040498.txt" (either csv or tab
delimited).

Is this possible? If so, can someone please help me in this effort...the
alternative is not pretty.

Thanks in advance!
> Trevor

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!tread (trevor_read@.hotmail.com) writes:
> The primary table I loaded into MySql has 2.5 MM records: ID, Ticker,
> Date, Price; and all works well. My need is to write a QUERY to export
> outfile?) multiple text files. For example, I have 6 years worth of
> data, and need to generate 1 file per day that contains all the Tickers
> and Prices for that day. Furthermore, I need the text file name to be
> the name of the date (e.g. April 4, 1998 with 1000 Tickers & Prices
> would result in a file that was named "040498.txt" (either csv or tab
> delimited).
> Is this possible? If so, can someone please help me in this effort...the
> alternative is not pretty.

The easiest way to do this for MS SQL Server, would be to use the
BCP command-line utility with the queryout function, packaged in
some script that handles the file naming.

But since you are using MySQL and need immediate assistance, you should
probably look around and try to find a MySQL forum to get some more
relevant response.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp