Tag: sql-server-2005

TSQL Help (SQL Server 2005)

I have been playing around with a quite complex SQL Statement for a few days, and have gotten most of it working correctly. I am having trouble with one last part, and was wondering if anyone could shed some light on the issue, as I have no idea why it isnt working: INSERT INTO ExistingClientsAccounts_IMPORT […]

SQL Server 2005 Replication Debugging Suggestions

I have a replication setup it was up and running yesterday, now I can’t connect to the distributor and I don’t know why. The publisher is on a Domain and talks to the subscriber (not on the domain) via VPN. I can ping the publisher from the subscriber and vice-versa. I can log in to […]

Need help creating complex T-SQL SELECT statement

I am trying to make SELECT statement for following situation and need help to make this SELECT statement. It’s SQL Server 2005. When the select statement is run, it should return rows which have SentDate as NULL assuming that there are no duplicate PersonID in table. It will return result set with Status as ‘Initial […]

SQL Server: pause a trigger

I am working with SQL Server 2005 and I have trigger on a table that will copy an deletions into another table. I cannot remove this trigger completely. My problem is that we have now developed an archiving strategy for this table. I need a way of “pausing” a trigger when the stored proc that […]

How to copy from a database to a text file using VBScript?

I have an example in C# code, but it is using streamWriter. It must be involving with FileSystemObject rite. If yes, what are methods should I use? I want to code using VBScript WSH, and my database is MS SQL Server 2005. Any solution, references, or guide are helpful. using (StreamWriter tw = File.AppendText(“c:\\INMS.txt”)) { […]

SQL Command to execute multiple times?

I have situations that I need to write multiple rows of the same value to setup some tables. Say I have to add 120 rows with two columns populated. I am looking for a shortcut, instead of having the Insert line repeated n times. How to do this?

Pivoting tables

I have a table like this: serialnumber partnb id actual nominal 1 1 AGR 15,2176803 15,2 1 1 APR 5,8060656 5,8 1 1 DCI 61,9512259 62 1 43 AGR 15,4178727 15,4 1 43 APR 7,235779 7,2 1 43 DCI 52,0080535 52 2 2 AGR 15,2097009 15,2 2 2 APR 5,8009968 5,8 2 2 DCI 61,9582795 […]

How to move a database using a differential backup?

I’m using SQL Server 2005. I need to move a database to a new server with minimum downtime. Currently my option is to take everything offline, perform a backup, copy the backup to the new server, restore the backup and bring everything back online. The problem here is that the backup file is about 10Gb, […]

if statements in sql query

Good morning all. I have an issue with a query. I want to select something in a query only if another field is somethingelse. The below query will better explain select Case isnull(rl.reason,’Not Found’) When ‘D’ then ‘Discontinued’ When ‘N’ then ‘Not Found’ When ‘I’ then ‘Inactive’ When ‘C’ then ‘No Cost’ When ” then […]

Update records only when ID matches

How would I update data in a table in a separate database based on the records in the current database? For instance I want to update the field “status” in the database called “database_old” with the value contained in the database “database_new” . My current data exists in the database “database_new”. I want to only […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.