sql-server-2005

Error while connecting remotely

Hi, i m using sql server 2005 with service pack-2. When I connect sql server with by registering the remote server with IP, username and password. I have done all the neccessary setting for connecting remotely "SQL Server 2005 Surface Area Configuration". i got following error while connection: This version of Microsoft SQL Server M...

Automated Update SQL Server

Hello, I have a table of topics, topics might have an automatic publish date, I want to make SQL Server auto publishes them. Previously I made it in code on each call to any method of the topics adapter, but I wanna make it automatically in SQL Server. Can I? It might be some kinda scheduled job or something like that. I'm using SQL...

TSQL to identify long Float values.

I'm dealing with a legacy system where I need to identify some bad records based on a column with a data type of Float. Good records have a value of... 1 2 1.01 2.01 Bad records are anything such as.. 1.009999999999999 2.003423785643000 3.009999990463260 I've tried a number of select statements where I Convert to Decimal and cast ...

SSIS Update Table Values from Another Table

I want to update TableA with values from TableB on a nightly basis. Right now, I'm trying to do this with SSIS 2005 using a Script Task with the SQL in it. Each time I try to do the update in this manner, I get a time-out error. Is there a better way to do this in SSIS? Current information below: Public Sub Main() Const Compone...

How to get the parent given a child in SQL SERVER 2005

I have a table like this childid parentid ------------------------ 1 0 2 1 3 2 4 2 5 3 6 4 7 0 8 7 9 8 10 1 If I give a childid as 5, the parentid will be 1(output) If I give a childid as 9, the parentid will be 7.(output) i.e. the root parentid is 0 and the query should stop there. How to solve su...

SQL Completely Empty Database

I am writing an install script that installs all tables, stored procedures, views, full text indexs, users ect. It all works fine if the user has all the correct permissions and the script runs from start to finish. However if the script dies somewhere midway through then it cannot just be run again. To accomplish this I want to basica...

How to create a new stored procedure template for Visual Studio?

I would like to create a template for new stored procedures for our development team. However, I can't seem to create template items for Database objects. I know for DLL/C#-related items, it's as simple as "File > Export Template ..." How can I add new SQL templates to my Database project? Here's my template: IF EXISTS (select 1 fro...

General Network Error accessing SQL Server 2005 from Access 2000

We are encountering problem in using Access 2000 (.ADP) as our front-end and SQL 2005 as our back-end and we have more then 50 users: [DBNETLIB][ConnectionWrite (send()).]General network error. Check your network documentation. It was working fine for the last years, but now the system keeps kicking out the user. They always receive an...

SQL Server won't use my index

I have a fairly simple query: SELECT col1, col2… FROM dbo.My_Table WHERE col1 = @col1 AND col2 = @col2 AND col3 <= @col3 It was performing horribly, so I added an index on col1, col2, col3 (int, bit, and datetime). When I checked the query plan it was ignoring my index. I tried reordering the columns in t...

Calculating the closest future periodic payment date in SQL

I'm working on an application that deals with periodic payments Payments are done fortnightly i.e. payment 1: 2009-06-01 payment 2: 2009-06-15 payment 3: 2009-06-29 and now I need a SQL statement that can calculate the closest next payment date from a given date in the WHERE clause i.e. SELECT ... FROM ... WHERE someDate < [CALCUL...

How to implement a conditional Upsert stored procedure?

I'm trying to implement your basic UPSERT functionality, but with a twist: sometimes I don't want to actually update an existing row. Essentially I'm trying to synchronize some data between different repositories, and an Upsert function seemed like the way to go. So based largely on Sam Saffron's answer to this question, as well as som...

Extract an SQL Server 2005 database's structure to XML

This is something I know can be done somehow, because I've done it before, but I can't for the life of me remember how. I want to export the structure of an SQL Server database to an XML file. The one that I have from last time we did this has this kind of structure: <Data> <Details> <Server>Server Name</Server> <D...

domain redirect without changing url

Hi, I'm building a sitebuilder project. The database and all other ASP.NET code is ready but I don't know how to handle domain names, because I will have only one site in IIS7 but more than a hundred sites are gonna publish from my site. (Like the sitebuilder you can find on the internet.) When users go the page, ex: www.myname1.com, it ...

E mail id storing

how we can store the e mail id into a database? i mean which datatype is used for storing e mail id's. ...

How to check a meeting time in C#

I have a meeting time starts from 6.00 AM to 9.00 PM in drop down with drop down value storing as 1 to 6.00 AM and 2 to 6.30 AM...... till 9.00 PM .I have kept drop down value as number since it is difficult to play with AM and PM so in database it stores as number. It has from time and to time 2 drop down... I donot want to have overlap...

Best approach for authorisation rules

I'm wonder about best approach of implementation auth. rules in Client-Server app using Business Objects. I've noticed common tactic is: - on DB side: implement one role for application, used for all app's users - definition users right and roles and assign users to proper group - Client side: add to Business Object's getters/setters r...

SQL Mirroring End Points

We have a SQL 2005 database server which uses high safety (synchronous, no automatic failover, no witness) mirroring to keep our disaster recovery site in a sort of warm standby. I was about to make some changes to the principle DB the other night preparatory to a new version of the app which uses it when I noticed that the mirroring had...

How do I find out what tables have data in a file in SQL Server?

I want to drop a now supposedly redundant file in SQL Server (2005), but when I try to drop it I am told that the file is not empty. Does anyone know of a way to find out what data is still in this file so I can make whatever changes I need to allow me to drop it? ...

How can I create a SQL unique constraint based on 2 columns ?

I have a Table like this one: |UserId | ContactID | ContactName --------------------------------------- | 12456 | Ax759 | Joe Smith | 12456 | Ax760 | Mary Smith | 12458 | Ax739 | Carl Lewis | 12460 | Ax759 | Chuck Norris | 12460 | Bx759 | Bruce Lee I need to add a constraint to this table s...

How do I remove "duplicate" rows from a view?

I have a view which was working fine when I was joining my main table: LEFT OUTER JOIN OFFICE ON CLIENT.CASE_OFFICE = OFFICE.TABLE_CODE. However I needed to add the following join: LEFT OUTER JOIN OFFICE_MIS ON CLIENT.REFERRAL_OFFICE = OFFICE_MIS.TABLE_CODE Although I added DISTINCT, I still get a "duplicate" row. I say "duplicat...