Friday, February 24, 2012

How to know the Primary Key of a Table?

Hi,
I need a quey that gives me the Field(s) that form the Primary Key of the
Table. I can't find anything about it on google, does anybody knwo how to
achieve this?
Thanks a lot in advance,
PieterThis exact question was posted here or in .programming yesterday.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:O6YXAqwRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I need a quey that gives me the Field(s) that form the Primary Key of the
> Table. I can't find anything about it on google, does anybody knwo how to
> achieve this?
> Thanks a lot in advance,
> Pieter
>|||Thanks, I found it!
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:ekpn%231wRFHA.904@.tk2msftngp13.phx.gbl...
> This exact question was posted here or in .programming yesterday.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:O6YXAqwRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > I need a quey that gives me the Field(s) that form the Primary Key of
the
> > Table. I can't find anything about it on google, does anybody knwo how
to
> > achieve this?
> >
> > Thanks a lot in advance,
> >
> > Pieter
> >
> >
>|||Justo nel ittle remark: When i entered a new row directly in the Enterprise
Manager: I got this as 'query': "sp_executesql;1"
is this normal? does it only occur in that situation?
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:ekpn%231wRFHA.904@.tk2msftngp13.phx.gbl...
> This exact question was posted here or in .programming yesterday.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:O6YXAqwRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > I need a quey that gives me the Field(s) that form the Primary Key of
the
> > Table. I can't find anything about it on google, does anybody knwo how
to
> > achieve this?
> >
> > Thanks a lot in advance,
> >
> > Pieter
> >
> >
>|||I never use EM do modify data in the tables (Aaron has a FAQ on this at www.aspfaq.com), but it is
possible that EM uses prepared SQL or similar to do modifications...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message news:u2N$AQ0RFHA.356@.TK2MSFTNGP14.phx.gbl...
> Justo nel ittle remark: When i entered a new row directly in the Enterprise
> Manager: I got this as 'query': "sp_executesql;1"
> is this normal? does it only occur in that situation?
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:ekpn%231wRFHA.904@.tk2msftngp13.phx.gbl...
>> This exact question was posted here or in .programming yesterday.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
>> news:O6YXAqwRFHA.1392@.TK2MSFTNGP10.phx.gbl...
>> > Hi,
>> >
>> > I need a quey that gives me the Field(s) that form the Primary Key of
> the
>> > Table. I can't find anything about it on google, does anybody knwo how
> to
>> > achieve this?
>> >
>> > Thanks a lot in advance,
>> >
>> > Pieter
>> >
>> >
>>
>|||Hi Tibor,
i'm testing your really promising solution, unfortunately, when I'm doing
updates or isnert with the SqlDataAdapter of .NET, I alsogot the
"sp_executesql;1" as the used query isntead of the sql string.
You don't have any idea how to get the original Sql-suery from that
sp_executesql?
Thanks a lot in advance,
Pieter
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%232tNWf0RFHA.2448@.TK2MSFTNGP10.phx.gbl...
> I never use EM do modify data in the tables (Aaron has a FAQ on this at
www.aspfaq.com), but it is
> possible that EM uses prepared SQL or similar to do modifications...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:u2N$AQ0RFHA.356@.TK2MSFTNGP14.phx.gbl...
> > Justo nel ittle remark: When i entered a new row directly in the
Enterprise
> > Manager: I got this as 'query': "sp_executesql;1"
> > is this normal? does it only occur in that situation?
> >
> > "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
in
> > message news:ekpn%231wRFHA.904@.tk2msftngp13.phx.gbl...
> >> This exact question was posted here or in .programming yesterday.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> >> news:O6YXAqwRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> >> > Hi,
> >> >
> >> > I need a quey that gives me the Field(s) that form the Primary Key of
> > the
> >> > Table. I can't find anything about it on google, does anybody knwo
how
> > to
> >> > achieve this?
> >> >
> >> > Thanks a lot in advance,
> >> >
> >> > Pieter
> >> >
> >> >
> >>
> >>
> >
> >
>|||Hmm, the command has to be send at one point in time. Did you trace the whole session? I'm afraid
that I can't be of any more help, I'm more of an engine person and not a client tool person...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:uswywDYSFHA.1236@.TK2MSFTNGP14.phx.gbl...
> Hi Tibor,
> i'm testing your really promising solution, unfortunately, when I'm doing
> updates or isnert with the SqlDataAdapter of .NET, I alsogot the
> "sp_executesql;1" as the used query isntead of the sql string.
> You don't have any idea how to get the original Sql-suery from that
> sp_executesql?
> Thanks a lot in advance,
> Pieter
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:%232tNWf0RFHA.2448@.TK2MSFTNGP10.phx.gbl...
>> I never use EM do modify data in the tables (Aaron has a FAQ on this at
> www.aspfaq.com), but it is
>> possible that EM uses prepared SQL or similar to do modifications...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:u2N$AQ0RFHA.356@.TK2MSFTNGP14.phx.gbl...
>> > Justo nel ittle remark: When i entered a new row directly in the
> Enterprise
>> > Manager: I got this as 'query': "sp_executesql;1"
>> > is this normal? does it only occur in that situation?
>> >
>> > "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
> in
>> > message news:ekpn%231wRFHA.904@.tk2msftngp13.phx.gbl...
>> >> This exact question was posted here or in .programming yesterday.
>> >>
>> >> --
>> >> Tibor Karaszi, SQL Server MVP
>> >> http://www.karaszi.com/sqlserver/default.asp
>> >> http://www.solidqualitylearning.com/
>> >>
>> >>
>> >> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
>> >> news:O6YXAqwRFHA.1392@.TK2MSFTNGP10.phx.gbl...
>> >> > Hi,
>> >> >
>> >> > I need a quey that gives me the Field(s) that form the Primary Key of
>> > the
>> >> > Table. I can't find anything about it on google, does anybody knwo
> how
>> > to
>> >> > achieve this?
>> >> >
>> >> > Thanks a lot in advance,
>> >> >
>> >> > Pieter
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>|||And what about the fn_get_sql function? I found soem info about it, and I
guess it must be possible to do like the samething? but maybe this will give
me the exact SQL-string? If i put it in a trigger now, I get the code of the
Trigger, not the code of the SQL statement that fired thetrigger :-(
But apparently I should somehow be able to do it with the @.stmt_end and
@.stmt_start variables? Or am I wrong?
Pieter
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:O6mxNLbSFHA.3424@.TK2MSFTNGP10.phx.gbl...
> Hmm, the command has to be send at one point in time. Did you trace the
whole session? I'm afraid
> that I can't be of any more help, I'm more of an engine person and not a
client tool person...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> news:uswywDYSFHA.1236@.TK2MSFTNGP14.phx.gbl...
> > Hi Tibor,
> >
> > i'm testing your really promising solution, unfortunately, when I'm
doing
> > updates or isnert with the SqlDataAdapter of .NET, I alsogot the
> > "sp_executesql;1" as the used query isntead of the sql string.
> >
> > You don't have any idea how to get the original Sql-suery from that
> > sp_executesql?
> >
> > Thanks a lot in advance,
> >
> > Pieter
> >
> >
> > "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
in
> > message news:%232tNWf0RFHA.2448@.TK2MSFTNGP10.phx.gbl...
> >> I never use EM do modify data in the tables (Aaron has a FAQ on this at
> > www.aspfaq.com), but it is
> >> possible that EM uses prepared SQL or similar to do modifications...
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> > news:u2N$AQ0RFHA.356@.TK2MSFTNGP14.phx.gbl...
> >> > Justo nel ittle remark: When i entered a new row directly in the
> > Enterprise
> >> > Manager: I got this as 'query': "sp_executesql;1"
> >> > is this normal? does it only occur in that situation?
> >> >
> >> > "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
wrote
> > in
> >> > message news:ekpn%231wRFHA.904@.tk2msftngp13.phx.gbl...
> >> >> This exact question was posted here or in .programming yesterday.
> >> >>
> >> >> --
> >> >> Tibor Karaszi, SQL Server MVP
> >> >> http://www.karaszi.com/sqlserver/default.asp
> >> >> http://www.solidqualitylearning.com/
> >> >>
> >> >>
> >> >> "DraguVaso" <pietercoucke@.hotmail.com> wrote in message
> >> >> news:O6YXAqwRFHA.1392@.TK2MSFTNGP10.phx.gbl...
> >> >> > Hi,
> >> >> >
> >> >> > I need a quey that gives me the Field(s) that form the Primary Key
of
> >> > the
> >> >> > Table. I can't find anything about it on google, does anybody knwo
> > how
> >> > to
> >> >> > achieve this?
> >> >> >
> >> >> > Thanks a lot in advance,
> >> >> >
> >> >> > Pieter
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>

No comments:

Post a Comment