sql-server

Visual Studio database project designers

I have this huge legacy database that I'm trying to get under source control. I looked around here on stackoverflow and decided to use the Visual Studio 2008 database project, then committing stuff on svn. I successfully imported the schema into the project, but I can't find any way to use the user-friendly table designers with this kind...

How to INSERT an array of values in SQL Server 2005?

How do I write the SQL code to INSERT (or UPDATE) an array of values (with probably an attendant array of fieldnames, or with a matrix with them both) without simple iteration? ...

Is it possible to connect PHP to SQL Server Compact Edition?

Is it possible to connect PHP to a SQL Server Compact Edition database? What would be the best driver? ...

What is the best way to partition large tables in SQL Server?

In a recent project the "lead" developer designed a database schema where "larger" tables would be split across two separate databases with a view on the main database which would union the two separate database-tables together. The main database is what the application was driven off of so these tables looked and felt like ordinary tab...

Is there a way to script a table's data (temp tables too) in MS SQL 2000?

Given a table or a temp table, I'd like to run a procedure that will output a SQL script (i.e. a bunch of INSERT statements) that would populate the table. Is this possible in MS SQL Server 2000? Thanks! ...

How do I get back a 2 digit representation of a number in SQL 2000

I have a table on SQL2000 with a numeric column and I need the select to return a 01, 02, 03... It currently returns 1,2,3,...10,11... Thanks. ...

Generate table relationship diagram from existing schema (SQL Server)

Is there a tool around that would produce a diagram showing existing tables and their relationships given a connection to a database or by any other means? This is for SQL Server 2008 Express Edition. ...

Obfuscate / Mask / Scramble personal information

I'm looking for a homegrown way to scramble production data for use in development and test. I've built a couple of scripts that make random social security numbers, shift birth dates, scramble emails, etc. But I've come up against a wall trying to scramble customer names. I want to keep real names so we can still use or searches so r...

Suggestions for replication of data from MS Sql 2005 and MySql

My company currently has a transactional db running on Sql Server 2005. We are going to add a MySql (running on linux) reporting db. We'll need to get replication running from the MS-Sql db to the MySql db. It doesn't have to be real time but should be within a few minutes. I've got pretty good MSSql Dev skills and so-so dba skills but ...

Is there a "poor man's" alternative to RedGate for scripting out entire database schema?

I'm in a situation where I would to generate a script for a database that I could run on another server and get a database identical to the original one, but without any of the data. In essence, I want to end up with a big create script that captures the database schema. I am working in an environment that has SQL Server 2000 installe...

C# equivalent of sql server's IsNull() function

In sql server you can use the IsNull funtion to check if a value is null. I am wondering if there is anything similar in C#, rather than manually checking: For eg: myNewValue = IsNull(myValue, new MyValue()); instead of: if (myValue == null) myValue = new MyValue(); myNewValue = myValue; Thanks. ...

Is this an acceptable way to make a simple "scheduler" in C#?

I'm making a simple scheduler with C# in .Net. All it does is execute a simple select statement on a table in a SQL Server DB once per minute (this does not need to scale or anything... the db does not have a high load). Here is my proposed implementation: static void Main(string[] args) { while (true) { System.Threadi...

Simple way to programmatically get all stored procedures

Is there a way to get stored procedures from a SQL 2005 Express database using C#? I would like to export all of this data in the same manner that you can script it our using SQL Management Studio, without having to install the GUI. I've seen some references to do thing via the PowerShell but in the end a C# console app is what I reall...

Is it possible to order by any column given a stored procedure parameter in SQL Server?

I was looking into sorting tables by a column designated given some input, and from what I've found, there is no easy way to do this. The best I've found is a switch statement: SELECT Column1, Column2, Column3, Column4 FROM Table ORDER BY CASE WHEN @OrderBY = 'Column1' THEN Column1 WHEN @OrderBY = 'Column2' THEN Column2 ...

What are the real benefits of Visual Studio Team System Database Edition (GDR)?

Interested if anyone has used VSTS Database Edition extensively and, if so, which features did you find the most useful over the standard Visual Studio database projects? What are the most compelling features as opposed to alternative schema management options or tools like RedGate's SqlCompare etc? Edit: Microsoft just released the RT...

What factors that degrade the performance of a SQL Server 2000 Job?

We are currently running a SQL Job that archives data daily at every 10PM. However, the end users complains that from 10PM to 12, the page shows a time out error. Here's the pseudocode of the job while @jobArchive = 1 and @countProcecessedItem < @maxItem exec ArchiveItems @countProcecessedItem out if error occured s...

What utilities can provide database hits/duration per page?

SQL Server profiler is great for profiling SQL Server performance for web apps. However, when I'm testing my webapp I'd like a summary of database hits/duration per page. Does anybody know of any utilities for giving you this kind of information? ...

SQL Server 2005 Setting a variable to the result of a select query

How do I set a variable to the result of select query without using a stored procedure? ...

Benefits of using a Case statement over an If statement in a stored procedure?

Hi are there any pros / cons relating to the speed that a stored procedure executes when using an IF statement or choosing to use a CASE statement instead? ...

Executing a stored procedure within a stored procedure

Hi, I would like to execute a stored procedure within a stored procedure eg EXEC SP1 BEGIN EXEC SP2 END But I only want SP1 to finish after SP2 has finished running so I need to find a way for SP1 to wait for SP2 to finish before SP1 ends. Thanks ...