sql-server

Creating an unlimited SqlServer Trace

On my app i am creating a real time trace (not sure how yet but i am!) and on the sp_trace_create function in SQlServer, i know that the @maxfilesize defaults to 5, but on my app its going to be stopped when the user wants to stop it...any ideas how this can be done? ...

Setting and resetting the DATEFORMAT in SQLServer 2005

Is there a way to query the current DATEFOMRAT SQLServer 2005 is currently using with T-SQL? I have an application that reads pregenerated INSERT-statements and executes them against a database. To make the the data to be inserted culture independent I store datetime-values represented in the invariant culture (month/day/year...) . The ...

Send message from SQL Server trigger

I need to signal a running application (Windows service) when certain things happen in SQL Server (2005). Is there a possibility to send a message from a trigger to an external application on the same system? ...

Dead-lock issue created by 2 SQL connections, each using transactions, each working with a different table, with a foreign key constraint between the two tables

Environment: I'm working on a C++ application that uses SQL Native Client 9.0 to communicate with a SQL Server 2000 database. Scenario: 2 connections are opened to the DBMS Each connection is set to use transactions A query on Connection1 works with TableA A query on Connection2 works with TableB TableB has a foreign key constraint o...

What problems can an NVARCHAR(3000) cause

I have an already large table that my clients are asking for me to extend the length of the notes field. The notes field is already an NVARCHAR(1000) and I am being asked to expand it to 3000. The long term solution is to move notes out of the table and create a notes table that uses an NVARCHAR(max) field that is only joined in when n...

Avg on datetime in Access

I am porting some queries from Access to T-SQL and those who wrote the queries used the Avg aggregate function on datetime columns. This is not supported in T-SQL and I can understand why - it doesn't make sense. What is getting averaged? So I was about to start reverse engineering what Access does when it aggregates datetime using Av...

Easiest way to import data from My Sql to Sql Server

For a new project I have to import the pre-existing data from MySql. In this site I have found many options, some including the installation of drivers. What is the fastest & easiest way to do it? Update: this would be just a one time import ...

Backup SQL Server while minimizing bandwidth

I want to implement an automated backup system for my site's SQL Server 2005 DB that will backup nightly to Amazon's S3 service. But since S3 charges both for space and bandwidth used, I would like to minimize the size of the files that I transfer in. What is the best way to achieve this? I should clarify that I'm not really talking so ...

updating primary key of master and child tables for large tables

Hi, I have a fairly huge database with a master table with a single column GUID (custom GUID like algorithm) as primary key, and 8 child tables that have foreign key relationships with this GUID column. All the tables have approximately 3-8 million records. None of these tables have any BLOB/CLOB/TEXT or any other fancy data types j...

Any clever way to fix 'string or binary data would be truncated' warning with LINQ

Is there a clever way to determine which field is causing 'string or binary data would be truncated' with LINQ. I've always ended up doing it manually by stepping through a debugger, but with a batch using 'SubmitChanges' I have to change my code to inserting a single row to find the culprit in a batch of rows. Am I missing something ...

MS SQL 2000 - Parameters in DTSRUN using xp_cmdshell

I am running the following: master..xp_cmdshell 'dtsrun /S ricmssql02 /U admindw /P letmein /N "scott - debug"' but also send parameters. I am seeing the following to do that: /A global_parameter_name:typeid=value And also that the whole thing can be repeated to send multiple. My questions are; What is the delimiter for multiple? What a...

How to detect duplicate rows in a SQL Server table?

What is the most efficient way to detect duplicates in a 10 column / 50K row table? I'm using MSSQL 8.0 ...

How do I perform an exact string match on a non-case sensitive field?

I would like to find all the rows in a table and match on an exact case sensitive string. Unfortunately, my table has the case insensitive collation. What is the most efficient way to perform this. Eg. I would like the following to return no rows: select * from sysobject where name = 'Sysbinobjs' For the answer assume @match is in...

How do I flush the PRINT buffer in TSQL?

I have a very long-running stored procedure in SQL Server 2005 that I'm trying to debug, and I'm using the 'print' command to do it. The problem is, I'm only getting the messages back from SQL Server at the very end of my sproc - I'd like to be able to flush the message buffer and see these messages immediately during the sproc's runtime...

What do I gain by adding a timestamp column called recordversion to a table in ms-sql?

What do I gain by adding a timestamp column called recordversion to a table in ms-sql? ...

maintaining ids in database that match client software enumerations

Lets say I have a table in a sql server 2000 database called TransactionType: CREATE TABLE [dbo].[TransactionType]( [ID] [int] NOT NULL, [Description] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, CONSTRAINT [PK_TransactionType] PRIMARY KEY CLUSTERED ( [ID] ASC ) ON [PRIMARY] ) ON [PRIMARY] I then have a t...

How do I convert an SQL Server SMALLDATETIME to a Unix timestamp?

How do I convert an SQL Server SMALLDATETIME to Unix Timestamp? date was stored as CAST(0x96040474 AS SmallDateTime) in MS Access DB. Data was dumped to SQL and I'm looking to convert those times to Unix Timestamps for MySQL. Thanks AO ...

How to Configure SQL Server 2005 Replication through a firewall?

What ports or modes of communication do you need to open up for SQL Server 2005 Transactional Replication? Main and slave are geographically separated. ...

How do you setup a linked server to an Oracle database on SQL 2000/2005?

I am able to create and execute a DTS package that copies tables from a remote Oracle database to a local SQL server, but want to setup the connection to the Oracle database as a linked server. The DTS package currently uses the Microsoft OLE DB Provider for Oracle with the following properties: Data Source: SERVER=(DESCRIPTION=(ADDRE...

Rollback a stored procedure call from inside a transaction using LINQ-to-SQL?

I have a C#.net winform program which runs with a SQL Server database. I am using LINQ-to-SQL. Is it possible to rollback the call to one or more stored procedures inside a transaction within my program using LINQ-to-SQL? Initially I thought it would make sense to manage the transaction inside the stored procedure but if I need to r...