sql-server

SQL Server: trigger to fire only if a condition is met

I hope this is a simple enough question for any SQL people out there... We have a table which hold system configuration data, and this is tied to a history table via triggers so we can track who changed what, and when. I have a requirement to add another value in to this table, but it is one that will change frequently from code, and...

Sending Email alert in SQL Server 2000

Hi would like to send an email alert after checking the result of a query which will return the numbers of rows in a table. Does anyone have any ideas how I could do this in SQL Server 2000 in 2005 I would use a maintenence plan but not sure how in 2000? ...

Is it possible to use/access scalar functions with LINQ to SQL?

We have scalar functions in our database for returning things like "number of tasks for a customer" or "total invoice amount for a customer". We are experimenting and looking to try to do this w/o stored procedures ... normally we would just call this function in our stored procedure and return it as a single value. Is there a way t...

Confirm before delete/update in SQL Management Studio?

So for the second day in a row, someone has wiped out an entire table of data as opposed to the one row they were trying to delete because they didn't have the qualified where clause. I've been all up and down the mgmt studio options, but can't find a confirm option. I know other tools for other databases have it. ...

How can SQL procedures from the Master database help db developers?

There are a lot of procedures and functions in the master database of SQL Server that provide handy tools for the database developer. For instance, sp_help [database object] will provide several results sets with useful attributes of the specified object; sp_helptext [procedure or function name] will return the body of a procedure or f...

Error: Failed to generate a user instance of SQL Server

I'm trying to connect to an MDF. I've even gone to the lengths of re-installing sql server express entirely (it is now the only flavor of SQL installed on my box, where previously I had 05 dev and express). I've verified that the paths are all correct, and thus far my google-fu hasn't helped. The Full exception message is: Failed to g...

Slow DELETE statement in SQL Server need help reading execution plan and fixing

I have a delete statement that's going against one of my core application tables. The delete statement is using the table's primary key but is still taking around 30 seconds. As far as I can tell the execution plan needs to do about 12 checks in other tables where this table is a FK prior to doing the delete. I need help reading and u...

How can I change the database schema using a Statement.execute() in Java ( and SQL Server)?

I need to execute a SQL Server system stored procedure, programmatically, and since it executes in the current schema, I need to change it on the fly. Like this Statement st = connection.createStatement(); st.execute("EXEC SP_ADDUSER ' ', ' '"); But SP_ADDUSER only executes on the current schema set for the connection, so if I wanted ...

Do you generate your data dictionary?

Do you generate your data dictionary? If so, how? I use extended procedures in SQL Server 2005 to hold onto table and field information. I have some queries that create a dictionary out of them, but it's ... meh. Do you have a particular query or tool you use? Do you generate it off of your database diagrams? Googling for "data dictio...

Picking up a VB6 project for a non-VB6 guy

I have been given the task of modifying a VB6 project. Nothing incredibly serious, adding a couple forms and fixing a few bugs for the most part. The project uses SQL Server (if that is of any relevance). My background in programming has been VB/C# .NET, PHP, C++ and mostly MySQL although I have used SQL Server on a much smaller scale. ...

Hourly ODBC pull to SQL 2005

I'm trying to pull data from an ODBC app to SQL2005(dev ed) DB on an hourly basis. When I run SSIS the option to import all tables and views is grayed out and forces your to write a query. How would I go about setting up a SSIS integration service to update ALL 250 some tables on an hourly basis. ...

SQL: Numbering the rows returned by a SELECT statement.

Suppose I have a SELECT statement that returns some set of results. Is there some way I can number my results in the following way: SELECT TOP 3 Name FROM PuppyNames ORDER BY NumberOfVotes would give me... Fido Rover Freddy Krueger ...but I want... 1, Fido 2, Rover 3, Freddy Krueger where of course ...

How to enable debugging of stored procedures in visual studio?

Ok, this is driving me nuts. I've done just about everything I can to enable step through debugging of stored procedures of a sql server 2005 database. http://arjunachith.blogspot.com/2007/05/debugging-stored-procedures-debug.html http://msdn.microsoft.com/en-us/library/zefbf0t6(vs.71).aspx My currents setup: visual studio 2008 SP1...

How would you implement sequences in Microsoft SQL Server?

Does anyone have a good way of implementing something like a sequence in SQL server? Sometimes you just don't want to use a GUID, besides the fact that they are ugly as heck. Maybe the sequence you want isn't numeric? Besides, inserting a row and then asking the DB what the number just seems so hackish. ...

How to design a database schema that can be used with both MySQL and SQL Server?

I'd like to give customers a choice of the database engine, but also want to minimize my troubles of such a decision. The engines in question are MySQL (5 or later) and SQL Server (2005 or later). ...

Assign default value to a datacolumn in a select statement.

Hi, I want to assign default values to a column in my select sql query so that if the value of that column is null I get that default value in my recordset. Is there anyway to do this? Example: select col1 (some default value) from tblname; ...

SQL Table and column Parser for stored procedures

Is there an application , which can parse a given set of stored procedures (SQL Server 2000) and gets all tables and associated columns that are being used in it. The stored procedure can have tables from different databases. Output should be like TableA columnA columnC columnD TableB columnE columnF columnG I ha...

How to get ascms.exe from ascmd.cs -.csproj and -.sln files?

Hello, I have downloaded Samples for MS SQL Server 2005 and I don't know how to get an .exe file from files like ascmd.sln, ascmd.cs, ascmd.csproj. When I'm trying to launch an .sln file in Visual Studio there is an error like "The application for project C:\project_path\project_name is not installed". Do I need a C# compiler or some...

Rolling back and update command in Sql Server 2000

I have used an update command to update the whole table in an Sql Server 2000 database by mistake. I was actually meaning to update just one row. Now all the 2000 rows contain the update. Is there a way to roll back this change? ...

How to persuade ascmd.exe to make tables as output, not a XML file?

Hello, I'm trying to see data in my OLAP cube by ascmd utility. As input I put a MDX query, but only what I have as output (in command line) is a XML file. I tried to use -Tf text and -Tf csv parameters, but they don't work in the way I think they should (I have a XML on output all the time). I want to have on my output something like...