sql-server-2005

JTDS Connection problems to SQL Server - Works on 2000 but not 2005

I've been trying to get a java application connecting via the jtds jdbc to a couple of SQL servers. I have to connect via windows authentication. The connection string specified is: String connectionString = _"jdbc:jtds:sqlserver://"+server+":"+port+"/"+database+";domain="+domain;_ and I am getting the connection via: con = j...

Incrementing a counter for dateadd

Hello, I'm trying to increase the time between dates by a set amount. For example, I want to add two months to the time between date 1,2 and 3. I'm having trouble incrementing my 'date counter'... DECLARE @monthDiff int SET @monthDiff = 1; UPDATE [Table1] SET [Date] = DATEADD(MONTH, (SET @monthDiff = @monthDiff + 1), [Date]) WHERE ...

Group by to find difference

I have table table Car: Id Name ProductionCountry Containers : ID (GUID) CarId I want to get containers, where are cars from different countries So: Cars: 1 BMW X5 DE 2 BMW X3 DE 3 AUDI A6 MX 4 AUDI A1 FR 5 VOLVO S40 FR Containers Guid1 1 Guid1 2 Guid1 3 Guid2 4 Guid2 5 So in result I get Guid1 because in this container are c...

Replacing DB Trigger mechanism

Hi everyone. I'm using SQL Server (2005). Today i have some tables that everytime the data inside them changes i get DB trigger (implemented via the sql server trigger mechanism) and handles it. the problem is that the trigger mechanism has bad performance and handling with it is not exaclly afun thing to do. now to my question. is anyb...

select the first three details of a master-detail relationship in a view

I have a master detail relationship between a person and its friends: person id name -- ------ 1 Jones 2 Smith 3 Norris friends id personId friendName -- -------- ---------- 1 1 Alice 2 1 Bob 3 1 Charly 4 1 Deirdre 5 2 Elenor A person can have as many friends as he wants. I want to create...

Add login and user to SQL Server without using SMO

Hello, in our company's product, we attach a database to SQL Server, and we need to add credentials to some accounts to the catalog. Currently we're using SMO to do this, but this gives us problems (x86 vs x64, SQL Server 2005 vs 2008, etc) Is there's anyway of adding a login (to the server) and a user (to the catalog) using SQL? This...

sql server 2005 replication via remote IP

I want to push subscriber using IP address except server name. How can do this? Please give me an example or reference. ...

Transaction Log SQL Server

All, We often delete many rows from a table and even though we are using set rowcount 10000 most of the times we fill up the Transaction Log. Is there something to do to avoid this problem happening? Thanks, M ...

Is It Possible to Add SQL Reporting Service to SQL Server 2008 Express?

I joined a windows host who runs SQL Server 2008 Express (Negative Surprise)! I think this is wrong since a host should expect some medium companies join them so they should put at least standard version. I don't know much about dba, but this is my suggestion. Am i right? OK! Here is my question, the host has SQL Reporting Service as an...

changing SQL Server database collation

Is it possible to change collation for all objects under the database? For example, if I change the database collation, it should change all the objects (tables,procs,etc.) related to that database. ...

Any free tool for SQL server log recovery<SQL 2005)

Hi, By mistake I have updated all the rows of a table with same data for certain columns (missed the statement that contains where clause). Are there any free tools that can help me to restore old data for these rows. ...

How can i convert my Sql codes to Linq?

i try to convert my SQL code to linq but i cannot: Alter PROCEDURE sp_MatchCTallyToTask AS BEGIN select * from Task where MPDReference in( select MPDReference from Task intersect select ENG_CUSTOMERTALLY_CUSTOMERTASKNUMBER from dbo.ENG_CUSTOMERTALLY) END GO public List<Task> TaskList() { return engCtx.Tasks...

How to manually expire a SQL login account?

Hi. I am writing vb.net code to log a user into my application using SQL to authenticate the user. Each app user is an actual Microsoft SQL Server 2005 user. Now I need to test the login mechanism and for this I need to: 1) test against a SQL account that is locked. 2) test against a SQL account who's password has expired. Is there...

Replication with pull subscribers fails under Active Directory policy when using a dedicated replication account

I have a replication set up with pull subscribers and it's deployed in our corporate domain. I have requested to create a dedicated account to run this replication off of. On a pull subscription client in Sql Agent job I get this error: Message Unable to start execution of step 1 (reason: Error authenticating proxy DOMAIN\username, sys...

TSQL Searching Rows in another table

Two tables are given PilotGroup Table Pilot Plane Jon Smith A1-Fighter Jon Smith B1-Fighter Gravell A2-Fighter Jon Skeet A1-Fighter Jon Skeet B1-Fighter Jon Skeet A4-Fighter Gravell A5-Fighter SouthOperation Table Plane A1-Fighter B1-Fighter The task is to print the pilot names who is trained on ...

How to select xml in 1 stored procedure and pass selected nodes as parameters into another procedure

I have a stored proc that does inserts of “people”. I have an xml document with a bunch of people I want to insert. I want to call my stored proc like below and expect the stored proc to be called for each person in the xml. It is telling me that the stored proc “expects a parameter of @Id” and is failing. @Id is the first param and ...

SQL Server dynamic ORDER BY with mixed datatypes: is this a good idea?

I have stored procedure that returns results sorted dynamically. The parent folder (this is for content management) has a RankTypeID field that allows sorting by Rank (0), Start Date in ascending order (1), Start Date in descending order (2), and document title (3) Rank is an integer, date is smalldatetime, and title is a nvarchar. ......

len of varbinary

hello, would someone please explain why select len(0x0a000b) returns 3? does len count bytes? and why select left(0x0a000b, 1) returns nothing? i expected 0x0a (if len counts bytes)... i am using mssql 2005 thanks konstantin ...

Write stored procedure parameters to an XML Column

I have a need to take the parameters passed in to a Stored Procedure (SQL 2005) and write those values into an XML column as one xml document. Looking for an idea on how to start it. ...

TSQL Comparing two Sets

When two sets are given s1 ={ a,b,c,d} s2={b,c,d,a} (i.e) TableA Item a b c d TableB Item b c d a How to write Sql query to display "Elements in tableA and tableB are equal". [Without using SP or UDF] Output Elements in TableA and TableB contains identical sets ...