Showing posts with label aselect. Show all posts
Showing posts with label aselect. Show all posts

Thursday, March 22, 2012

Can't select from 1 table

Any ideas why I can't select anything from 1 table? If I try to execute a
select statement (even Top 1), the statement just hangs. We constantly have
to restart SQL Server to "free" up the problem, but it keeps coming back.
Any ideas what's going on?
Thanks.
Sql 2000
Have your tried to select data from the table using NOLOCK hint?
There can be some blocking problem (some locks on your table that do not
allow other locks). Use sp_lock system stored procedure to find the locks on
your table (especially look for X - eXclusive locks, identify your table by
object_id - use OBJECT_ID function to know the ID). Then you can use sp_who
system stored procedure to find the process (its spid is returned by
sp_lock) that puts those locks and finally you can kill the proper session
(using kill statement). You cal also use Enterprise Manager and its
Management section.
The remedies for blocking:
- always close (commit or rollback) transactions,
- keep transactions short,
- use the proper transaction isolation level.
If it is blocking problem, try to isolate the query or procedure causing the
problem (use Profiler to catch batch executions, locks being required and
lock escalations).
Regards
Pawel Potasinski
Uytkownik <-> napisa w wiadomoci
news:OPD%232lT0HHA.1484@.TK2MSFTNGP06.phx.gbl...
> Any ideas why I can't select anything from 1 table? If I try to execute a
> select statement (even Top 1), the statement just hangs. We constantly
> have to restart SQL Server to "free" up the problem, but it keeps coming
> back.
> Any ideas what's going on?
> Thanks.
> Sql 2000
>
|||Thanks...we just found that there was a lock on the table by a process id,
but this has happened several times in the last few days, whereas it never
used to happen.
Still looking into it. Thanks for the info.
"Pawel Potasinski" <pawel.potasinski@.gmail.com> wrote in message
news:eUxUwtT0HHA.4816@.TK2MSFTNGP04.phx.gbl...
> Have your tried to select data from the table using NOLOCK hint?
> There can be some blocking problem (some locks on your table that do not
> allow other locks). Use sp_lock system stored procedure to find the locks
> on your table (especially look for X - eXclusive locks, identify your
> table by object_id - use OBJECT_ID function to know the ID). Then you can
> use sp_who system stored procedure to find the process (its spid is
> returned by sp_lock) that puts those locks and finally you can kill the
> proper session (using kill statement). You cal also use Enterprise Manager
> and its Management section.
> The remedies for blocking:
> - always close (commit or rollback) transactions,
> - keep transactions short,
> - use the proper transaction isolation level.
> If it is blocking problem, try to isolate the query or procedure causing
> the problem (use Profiler to catch batch executions, locks being required
> and lock escalations).
> --
> Regards
> Pawel Potasinski
>
> Uytkownik <-> napisa w wiadomoci
> news:OPD%232lT0HHA.1484@.TK2MSFTNGP06.phx.gbl...
>

Can't select from 1 table

Any ideas why I can't select anything from 1 table? If I try to execute a
select statement (even Top 1), the statement just hangs. We constantly have
to restart SQL Server to "free" up the problem, but it keeps coming back.
Any ideas what's going on?
Thanks.
Sql 2000Have your tried to select data from the table using NOLOCK hint?
There can be some blocking problem (some locks on your table that do not
allow other locks). Use sp_lock system stored procedure to find the locks on
your table (especially look for X - eXclusive locks, identify your table by
object_id - use OBJECT_ID function to know the ID). Then you can use sp_who
system stored procedure to find the process (its spid is returned by
sp_lock) that puts those locks and finally you can kill the proper session
(using kill statement). You cal also use Enterprise Manager and its
Management section.
The remedies for blocking:
- always close (commit or rollback) transactions,
- keep transactions short,
- use the proper transaction isolation level.
If it is blocking problem, try to isolate the query or procedure causing the
problem (use Profiler to catch batch executions, locks being required and
lock escalations).
Regards
Pawel Potasinski
Uytkownik <-> napisa w wiadomoci
news:OPD%232lT0HHA.1484@.TK2MSFTNGP06.phx.gbl...
> Any ideas why I can't select anything from 1 table? If I try to execute a
> select statement (even Top 1), the statement just hangs. We constantly
> have to restart SQL Server to "free" up the problem, but it keeps coming
> back.
> Any ideas what's going on?
> Thanks.
> Sql 2000
>|||Thanks...we just found that there was a lock on the table by a process id,
but this has happened several times in the last few days, whereas it never
used to happen.
Still looking into it. Thanks for the info.
"Pawel Potasinski" <pawel.potasinski@.gmail.com> wrote in message
news:eUxUwtT0HHA.4816@.TK2MSFTNGP04.phx.gbl...
> Have your tried to select data from the table using NOLOCK hint?
> There can be some blocking problem (some locks on your table that do not
> allow other locks). Use sp_lock system stored procedure to find the locks
> on your table (especially look for X - eXclusive locks, identify your
> table by object_id - use OBJECT_ID function to know the ID). Then you can
> use sp_who system stored procedure to find the process (its spid is
> returned by sp_lock) that puts those locks and finally you can kill the
> proper session (using kill statement). You cal also use Enterprise Manager
> and its Management section.
> The remedies for blocking:
> - always close (commit or rollback) transactions,
> - keep transactions short,
> - use the proper transaction isolation level.
> If it is blocking problem, try to isolate the query or procedure causing
> the problem (use Profiler to catch batch executions, locks being required
> and lock escalations).
> --
> Regards
> Pawel Potasinski
>
> Uytkownik <-> napisa w wiadomoci
> news:OPD%232lT0HHA.1484@.TK2MSFTNGP06.phx.gbl...
>

Can't select a datetime field in a query without time portion

Hi,
I am doing some project with SQL Server 2000 and C#. I am using a
SELECT statement to get a column and to bind it to a dropdown list. The
column is a datetime format. I don't need time portion of it. Before I
tried any CONVERT functions my query looked like this:
SELECT DISTINCT DateEntered FROM TBL_PTM_Report
I can get the data this way but only with time portion in it. I read
about CONVERT but can't get it working. I am getting all kinds of error
messages from Visual Studio.
I tried the lowwoling:
SELECT COVVERT(CHAR(10), DateEntered, 101) FROM TBL_PTM_Report
It didn't work. I need data in the following format MM/DD/YYYY
Thank you,
Stan> SELECT COVVERT(CHAR(10), DateEntered, 101) FROM TBL_PTM_Report
CONVERT.
AMB
"suslishe@.mail.ru" wrote:

> Hi,
> I am doing some project with SQL Server 2000 and C#. I am using a
> SELECT statement to get a column and to bind it to a dropdown list. The
> column is a datetime format. I don't need time portion of it. Before I
> tried any CONVERT functions my query looked like this:
> SELECT DISTINCT DateEntered FROM TBL_PTM_Report
> I can get the data this way but only with time portion in it. I read
> about CONVERT but can't get it working. I am getting all kinds of error
> messages from Visual Studio.
> I tried the lowwoling:
>
> SELECT COVVERT(CHAR(10), DateEntered, 101) FROM TBL_PTM_Report
> It didn't work. I need data in the following format MM/DD/YYYY
> Thank you,
> Stan
>|||This was my typing mistake, sorry! The statement looks like this:
SELECT CONVERT(CHAR(10), DateEntered, 101) FROM TBL_PTM_Report|||I just ran this in query analyser and everything works! But Visual
Studio gives me an error.