sql-server-2008

SQL Server replication testing

I'd like to write a sql script to do a basic smoke test to check that the replication setup on my server is correct. I think a simple set of CRUD operations against the tables that are supposed to be replicated will achieve what I'm after and I imagine the workflow will look something like this: INSERT a row into a replicated table in...

UNIQUE - way to have unique rows in table ?

I have problem with unique rows in db table, now it is posible to do that: id | Name | LastName | City ------------------------------------- 1 | John | Moore | London 2 | John | Moore | London when i use UNIQUE attribute in all columns i have errors inserting second Moore even it is different Name :/ how use UNIQUE (...

combine 2 query - sql server 2008 question

I have this query: select count (convert(varchar(50), TmpDate, 103 )),convert(varchar(50), TmpDate, 103 ) from MEN group by TmpDate order by TmpDate desc and I need to count how many rows it returns how I can combine select count (..... and query1 ? I need it in one query thanks in advance ...

SQL Server Sequence number issue

Hello, Last week Damir Sudarevic in this community helped with this query to generate a seq number. I have one issue with couple of issues with this one. For some reason records are not displayed by OrderDetailsID in spite of specifying it in order by. The two columns in the query below seq and seqNo displays records as shown below Se...

How can I tell if a database table is being accessed anymore? Want something like a "SELECT trigger"

I have a very large database with hundreds of tables, and after many, many product upgrades, I'm sure half of them aren't being used anymore. How can I tell if a table is is actively being selected from? I can't just use Profiler - not only do I want to watch for more than a few days, but there are thousands of stored procedures as well,...

SQL Server 2008 Change Tracking

We want to use Change Tracking to implement a two-way sync between a SQL Server 2008 Enterprise/Standard instance, and an Express 2008 instance. When we read the remote changes, and then make the adjustments on the local server, how can we keep those statements from being change tracked? I foresee endless loops of one server tracking a...

MS Jdbc driver sqljdbc 2.0 driver fails to connect to SQL Server 2008

Hi all, We have a well-defined problem that points to a problem with Microsoft's JDBC 2.0 driver for JDK 1.6 ("sqljdbc4.jar"). I may be wrong. I've been wrong before. I wanted to see if I'm missing anything. any insights? Anyone seen this before? Usecase: use ant "sql" task to run a simple sql query. All queries fail jdbc driver...

Reporting Services: Creating user defined functions in report query. Is it real?

Is it possible to create and use a user defined function in a report query? Something like this: if OBJECT_ID('userFunc', 'TF') is not null drop function userFunc go create function userFunc(@id int) returns @tbl table ([id] int) begin insert into @tbl (id) values(@id) return end go select * from userFunc(1) if OBJECT_ID('userFunc',...

Why doesn't STDifference between a LINESTRING and a POINT on the line string yield a MULTILINESTRING of the two pieces?

DECLARE @Route geography SET @Route = geography::STLineFromText('LINESTRING(-0.175 51.0, -0.175 59.0)',4326) DECLARE @Route2 geography SET @Route2 = @Route.STDifference(geography::STPointFromText('POINT(-0.175 52)', 4326)) SELECT @Route2 Why does @Route2 evaluate to LINESTRING (-0.175 59, -0.175 51) instead of a MULTILINESTRING consi...

TSQL make trigger fail silently

I have some code in an after insert trigger that may potentially fail. Such a failure isn't crucial and should not rollback the transaction. How can I trap the error inside the trigger and have the rest of the transaction execute normally? The example below shows what I mean. The trigger intentionally creates an error condition with th...

Using Like comparison over multiple patterns

I would like to be able to match a single field based upon multiple patterns contained in another table, kind of like and IN clause for LIKE comparisons. The following query obviously doesn't work, but it expresses what I am trying to accomplish. SELECT * FROM TableA WHERE TableA.RegCode Like ( SELECT '%' + TableB.PartialRegCode ...

Cannot Open table from SQL Server 2008 on SSMS 2005

I am using SSMS 2005 on my local workstation and have not yet installed SSMS2008 on it. When I connect to a SQL Server 2008 instance and try to "open" a table from SSMS2005 I cannot open. Instead I get an error (popup) that says: Unspecified Error (MS Visual Database Tools) I have tried this on 2 SQL Server 2008 Instances, I ...

Saving duration info to SQL Server

I have a WPF app, where one of the fields has a numeric input box for length of a phone call, called ActivityDuration. Previously this has been saved as an Integer value that respresents minutes. However, the client now wishes to record meetings using the same table, but meetings can last for 4-5 hours so entering 240 minutes doesn't se...

Can SQL Server Pivot without knowing the resulting column names?

I have a table that looks like this: Month Site Val 2009-12 Microsoft 10 2009-11 Microsoft 12 2009-10 Microsoft 13 2009-12 Google 20 2009-11 Google 21 2009-10 Google 22 And I want to get a 2-dimension table that gives me the "Val" for each site's month, like: Mont...

Architecture design help

I'm looking for some input on my current project architecture. There are three components: Server, Desktop, and Mobile Device. I have 2 goals: 1) Send data (Approx. no more than 100 KB of text) from the Desktop (multi platform client application running on windows XP/Vista/7, and Mac OS X) to a server (Windows Server 2008, IIS 7, WCF ...

How to automatically synchronize tables in different databases

Hello everyone! Little background: I'm working in a large company with a lot of branches. We have several applications with separated databases sometimes on different servers. But every database contains a table with a list of branches and their relationships. I want to automatically synchronize these tables when one of them changed. M...

How To Apply Security Patches

I want to ask 1 simple question in SQL SERVER..... How To Apply Security Patches in SQL SERVER 2000 and above. ...

Using a database table as a queue

I want to use a database table as a queue. I want to insert in it and take elements from it in the inserted order (FIFO). My main consideration is performance because I have thousands of these transactions each second. So I want to use a SQL query that gives me the first element without searching the whole table. I do not remove a row wh...

SQL Server 2008 fulltext catalogs: more than one language?

I have one table and I want to create two fulltext catalogues, one in German, and one in English. My problem is: I can only create one fulltext catalog per table, but I want to create a fulltext catalog for English language and German language. I cannot use an indexed view. Is there any way to fix my problem? ...

Is there a tool to check the minimum privileges required for a set of sql?

If I have a set of SQL (ie. a script containing arbitrary SQL statements), is there any way of finding out what the minimum permissions are required to execute the SQL? (I'm thinking of something similar to the "Permissions required by the application" area in Visual Studio when viewing the Security tab on the project properties page of...