sql-server

tcp\ip server tracking database changes

I have a tcp\server ( .NET 3.5 ) that notifies connected clients about aah interesting events. These events occur because an aspx website is writing stuff to a database( SQL 2005 ) What would be a good way for this server to monitor the database so to speak can the db push info to the server in any way? any suggestions thoughts welcome ...

Is there some database-independent way get data change notifications at the field level?

Currently, using SQL Server 2005, I poll a "windows events" database to determine changes in a table called WINDOWS_EVENTS, which has a timestamp field. Looking at the timestamp I can determine if the row changed, but not what field in that row changed. Is there some generic (i.e. database independent way) to detect field level changes?...

Log usage of database tables, functions, stored procedures, views etc

I work on a system that is based on a SQL server database that has a lot of years of development on it. It is not huge in data volume (a few GB) but it has a lot of complexity (hundreds of tables, hundreds of stored procedures). I want to start by cleaning out the stuff that isn't used any more. We have a weekly/monthly/quarterly/annual...

What is a minimum SQL Server role allowing trigger creation/dropping?

Prerequisite: There is client/server application written in Delphi32. The RDBMS is SQL Server 2005. A certain application functionality requires creation/dropping of triggers (from the application using ad hoc DDL statements) in the target database. Problem: If a user belongs to roles sysadmin there is no problem to create/drop trigg...

SQL query help, ms sql server 2005 (group by and having)

I writing a query within ms sql server 2005 and having some trouble getting it to run. I need my query to include: Include all docs from Date Range 2009-07-20 to 2009-08-04 Include a Sum column using the 'Size' field Include a record count column Group By Name select Name, count(*) AS FileCount, SUM(Size) From alldocs Group by DirNa...

Detect local SQL server installation with C#(32 bit as well as 64 bit)

How can I detect if SQL is installed on the local machine using C#? Is it possible to check a remote machine? ...

Count(*) vs Count(1)

Hi, just wondering if any of you guys use Count(1) over Count(*) and if there is a noticeable difference for SQL Server 2005 in performance? Or is this just a legacy habit that has been brought forward from days gone past? ...

How do I update a XML string in an ntext column in SQL Server?

have a SQL table with 2 columns. ID(int) and Value(ntext) The value rows have all sorts of xml strings in them. ID Value -- ------------------ 1 <ROOT><Type current="TypeA"/></ROOT> 2 <XML><Name current="MyName"/><XML> 3 <TYPE><Colour current="Yellow"/><TYPE> 4 <TYPE><Colour current="Yellow" Size="Large"/><TYPE> 5 <...

How can I get my app to run on Windows Server 2008?

I have created a console application in C# using .NET 2.0. I have tested the application on the 32 and 64 bit versions of Windows Server 2003 and it is working properly. When I tried to run the application on Windows Server 2008, but it doesn't work. Later, someone told me to turn off UAC (User Access Control and Data Execution Preventio...

SQL - Query Phonenumber that are stored inconsistently

Hi, we a phonenumber field in our database and I would like to do a simple lookup query like: SELECT * FROM TABLE WHERE Phonenumber = '555123456' But since the phonenumbers are entered by users and are not normalized, we don't really know what they look like. Could be: +555-123456 or (555) 123 456 or 555-12-34-56 or som...

Post build on database project

In Visual Studio 2008, I have this database project to manage my SQL Server 2008 database. This has a prebuild and postbuild SQL Script that contains an example like this: :r .\myfile.sql What does this mean? ...

SQL Server 2005 - SQL Statement to remove clustered keys from tables based on a query on tablenames?

I am trying to restore a backup of a Microsoft Dynamics NAV database, which unfortunately fails as it tries to set a CLUSTERED KEY for the tables which already have clustered keys. In NAV, every company in the database gets its own copy of the tables, prefixed with the Company's name, e.g. COMPANY$User_Setup. I'd therefore like to remov...

sql query, wildcard, MS SQL SERVER 2005

I need my query to pull all DirName's what have the following prefix 'site/test/test/' is the correct syntax a '*' SELECT DirName, count(*) AS FileCount, SUM(Size)/1024 as 'SizeKB' FROM alldocs Where DirName = 'site/test/test/*' GROUP BY dirName ORDER BY DirName ...

What is the type of XQuery passed to SQL Server XML Data Type methods?

According to BOL on value() Method (xml Data Type), value() method takes two arguments XQuery SQLType Do I need to pass varchar or nvarchar to value()? How can I find out what kind of type XQuery or SQLType expects? End Goal: To create utility UDF/sprocs that uses XML Data Type methods. ...

Need help with recursion in SQL Server 2005

I am representing a tree in a table, and I need to be able to get the root node (TOP ID) of a specific element. The root node always has a ParentID of null. For example, if the table looks like this: ID ParentID 1 null 2 null 3 null 4 2 5 1 6 2 7 6 8 4 9 8 10 6 When ID=10, the TOP ID = 2; when ID=9, the TOP ID =...

SQL Server Default Instance: If you change host machine's name...

Say I have a Server named "MyServerABC", on which I have Sql Server 2005 installed with a Default Instance. Thus I can always connect to my sql server just by specifying "MyServerABC". Now, I change my server's name to "MyServerDEF". Will I now be able to connect to the sql server by just specifying "MyServerDEF"? Are there any hol...

Deleting records from SQL Server table without cursor

I am trying to selectively delete records from a SQL Server 2005 table without looping through a cursor. The table can contain many records (sometimes > 500,000) so looping is too slow. Data: ID, UnitID, Day, Interval, Amount 1 100 10 21 9.345 2 100 10 22 9.367 3 200 11 21 4.150 4 300 ...

SQL Server Linked Server with different active directory domain credentials

I have a remote database I need to create a linked server to. The problem is it's been set up with my group's functional account an not my own. The only way I can think of doing this is logging out of my personal work account and then back in with out functional account and then set up the link that way, but that is impractical. So my ...

Per-entity autoincrement field in SQL Server?

I have a table, "foo", in my database with primary key "fooID." I have a second table, "fooAttributes," with a foreign key that references foo.fooID. I'd like to have a composite key on the fooAttributes table (fooID, attributeNumber), where attributeNumber increments automagically on a per-foo basis when I insert a new attribute. So f...

Does anyone see a performance issue with my logon Trigger?

Does anyone see a performance issue with my logon Trigger? I'm trying to reduce the overhead and prevent any performance issues before I push this trigger to my production SQL Server. I currently have the logon trigger working on my Development sql server. I let it run over the past weekend and it put 50,000+ rows into my audit log ta...