Showing posts with label modified. Show all posts
Showing posts with label modified. Show all posts

Monday, March 26, 2012

Please help - Missing sqlbw.exe of SQL Server 2005

Recently, my SQL server infected with virus which modified some of .exe files on the server. Unfortunatly, the auti-virus software found those infected .exe files and removed them from server including the sqlbw.exe. Now I can't run the management studio. I tried to reinstall the only the management tools but failed. It said that my version is incorrect. I also tried to apply the SP1 but failed too. What can I do to recover only the management studio? I don't want to uninstall the SQL server because I have live database running on it. Please help.

If you cannot have a downtime to the databases then only way is to install another instance of SQL and use those tools to use this database.|||Have you tried uninstalling the original tools?|||

Why are you trying to run sqlbw.exe? You can launch management studio using sqlwb.exe and not sqlbw.exe

Thanks,

Sravanthi

Friday, March 9, 2012

pk_dtproperties Question

I'm having some weird locking in SQL Server 2000 and I look the locks with a
modified sp_locks it shows thousands of the locks below. But I can't find
any code or SQL scripts that use that table and the table has 0 rows.
Has anyone seen this?
thanks
Johh
PrePressAutomation pk_dtproperties DB S
PrePressAutomation pk_dtproperties KEY Range
PrePressAutomation pk_dtproperties PAG IS
PrePressAutomation pk_dtproperties PAG IX
PrePressAutomation pk_dtproperties TAB IS
PrePressAutomation pk_dtproperties TAB Sch-SHi
pk_dtproperties is the primary key on dtproperties which is used for
database diagrams
http://groups.google.com/groups?hl=en&lr=&threadm=eyjuHEShEHA.2620%40TK2MSFTNGP10.phx.gbl&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26scoring%3Dd%26q%3Dpk_dtproperties
John
"John" wrote:
> I'm having some weird locking in SQL Server 2000 and I look the locks with a
> modified sp_locks it shows thousands of the locks below. But I can't find
> any code or SQL scripts that use that table and the table has 0 rows.
> Has anyone seen this?
> thanks
> Johh
> PrePressAutomation pk_dtproperties DB S
> PrePressAutomation pk_dtproperties KEY Range
> PrePressAutomation pk_dtproperties PAG IS
> PrePressAutomation pk_dtproperties PAG IX
> PrePressAutomation pk_dtproperties TAB IS
> PrePressAutomation pk_dtproperties TAB Sch-S
>|||Thank you John, but I don't have any database diagrams on that server. I
also tried to delete the table, but in SQL 2000 sp3a It's a system table and
will not let me delete it. Do you have any clues I'm getting locks on this
table?
Thank you
John
"John Bell" wrote:
> Hi
> pk_dtproperties is the primary key on dtproperties which is used for
> database diagrams
> http://groups.google.com/groups?hl=en&lr=&threadm=eyjuHEShEHA.2620%40TK2MSFTNGP10.phx.gbl&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26scoring%3Dd%26q%3Dpk_dtproperties
> John
> "John" wrote:
> > I'm having some weird locking in SQL Server 2000 and I look the locks with a
> > modified sp_locks it shows thousands of the locks below. But I can't find
> > any code or SQL scripts that use that table and the table has 0 rows.
> >
> > Has anyone seen this?
> > thanks
> > Johh
> >
> > PrePressAutomation pk_dtproperties DB S
> > PrePressAutomation pk_dtproperties KEY Range
> > PrePressAutomation pk_dtproperties PAG IS
> > PrePressAutomation pk_dtproperties PAG IX
> > PrePressAutomation pk_dtproperties TAB IS
> > PrePressAutomation pk_dtproperties TAB Sch-S
> >|||Hi John
I don't know why this should be. You may want to check the inputbuffer
for that spid http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_dbcc_8v8y.asp
You may also want to check what SQLAgent and NT jobs are scheduled,
and if there are any services.
Failing that you may want to see if stopping/starting the SQL Server
service
removes the problem.
John
"John" <John@.discussions.microsoft.com> wrote in message news:<2143B280-2453-4BB4-81F0-DAF461E1050A@.microsoft.com>...
> Thank you John, but I don't have any database diagrams on that server. I
> also tried to delete the table, but in SQL 2000 sp3a It's a system table and
> will not let me delete it. Do you have any clues I'm getting locks on this
> table?
> Thank you
> John
> "John Bell" wrote:
> > Hi
> >
> > pk_dtproperties is the primary key on dtproperties which is used for
> > database diagrams
> >
> > http://groups.google.com/groups?hl=en&lr=&threadm=eyjuHEShEHA.2620%40TK2MSFTNGP10.phx.gbl&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26scoring%3Dd%26q%3Dpk_dtproperties
> >
> > John
> >
> > "John" wrote:
> >
> > > I'm having some weird locking in SQL Server 2000 and I look the locks with a
> > > modified sp_locks it shows thousands of the locks below. But I can't find
> > > any code or SQL scripts that use that table and the table has 0 rows.
> > >
> > > Has anyone seen this?
> > > thanks
> > > Johh
> > >
> > > PrePressAutomation pk_dtproperties DB S
> > > PrePressAutomation pk_dtproperties KEY Range
> > > PrePressAutomation pk_dtproperties PAG IS
> > > PrePressAutomation pk_dtproperties PAG IX
> > > PrePressAutomation pk_dtproperties TAB IS
> > > PrePressAutomation pk_dtproperties TAB Sch-S
> > >

Wednesday, March 7, 2012

PIVOT with dynamic columns names created

I am trying to do a PIVOT on a query result, but the column names created by the PIVOT function are dynamic.

For example (modified from the SQL Server 2005 Books Online documentation on the PIVOT operator) :

SELECT
Division,
[2] AS CurrentPeriod,
[1] AS PreviousPeriod
FROM
(
SELECT
Period,
Division,
Sales_Amount
FROM
Sales.SalesOrderHeader
WHERE
(
Period = @.period
OR Period = @.period - 1
)
) p
PIVOT
(
SUM (Sales_Amount)
FOR Period IN ( [2], [1] )
) AS pvt

Let's assume that any value 2 is selected for the @.period parameter, and returns the sales by division for periods 2 and 1 (2 minus 1).

Division CurrentPeriod PreviousPeriod
A 400 3000
B 400 100
C 470 300
D 800 2500
E 1000 1900

What if the value @.period were to be changed, to say period 4 and it should returns the sales for periods 4 and 3 for example, is there a way I can change to code above to still perform the PIVOT while dynamically accepting the period values 4 and 3, applying it to the columns names in the first SELECT statement and the FOR ... IN clause in the PIVOT statement ?

Need a way to represent the following [2] and [1] column names dynamically depending on the value in the @.period parameter.

[2] AS CurrentPeriod,
[1] AS PreviousPeriod

FOR Period IN ( [2], [1] )

I have tried to use the @.period but it doesn't work.

Thanks in advance.

Kenny

This is a one drawback to the current Pivot feature. You will have to use dynamic sql for this.

Itzik has written a good article on this.

http://www.sqlmag.com/Article/ArticleID/94268/sql_server_94268.html