sql-server

In SQL Server, how to move/import a multiple .trc files to a trace table

I have a set of rollover .trc files recorded with Sql Profiler. mytrace.trc mytrace_1.trc mytrace_2.trc mytrace_3.trc I can import the first one using this command: use [my-database] SELECT * INTO trace_folder FROM::fn_trace_gettable('C:\mytrace.trc', 4) However, this only appears to load the first file, not all four. ...

I'm looking for a reliable way to verify T-SQL stored procedures. Anybody got one?

Hi all-- We're upgrading from SQL Server 2005 to 2008. Almost every database in the 2005 instance is set to 2000 compatibility mode, but we're jumping to 2008. Our testing is complete, but what we've learned is that we need to get faster at it. I've discovered some stored procedures that either SELECT data from missing tables or try to...

convert to UDF from select statement

How would one go about converting this into a scalar UDF? I'll pass the product_id to the UDF. Running SQL 2k5 SELECT sum(qty) as qty, product_id FROM vProductQuantity WHERE product_id = @product_id GROUP BY product_id ...

Insert into Table from #tempTable fails

I am simply taking the data from a Table and insert it into #tempTable then delete the data, and insert it back to the table. I get "Insert Error: Column name or number of supplied values does not match table definition." Error. Here are the lines I am running. SELECT * INTO #tempTable FROM dbo.ProductSales SELECT * FROM #tempTable ...

Delete all records that have no foreign key constraints

I have a SQL 2005 table with millions of rows in it that is being hit by users all day and night. This table is referenced by 20 or so other tables that have foreign key constraints. What I am needing to do on a regular basis is delete all records from this table where the "Active" field is set to false AND there are no other records in ...

Hyphen vs Dash : Replace Dash with Hyphen

Alright so we had a problem recently In reporting services some of the String Columns were appearing as gibberish Chinese characters. On further investigation we found it is the hyphen. Well that's what we though first. On further investigation we found it a dash (or en dash) . Basically the reason this has happened is people copy pas...

SubSonic missing stored procedures in StoredProcedures.cs when generated with SubCommander sonic.exe

We have been using SubSonic to generate our DAL with a lot of success on VS2005 and SubSonic Tools 2.0.3. SubSonic Tools do not work on VS2008 (as far as we can work out) so we have tried to use SubCommander\sonic.exe and are now hitting some problems. When we regenerate the project using SubCommander\sonic.exe and try to compile we ge...

sp_procedure_params_managed - how to eliminate these calls from EnterpriseLibrary?

We noticed in a SQL Server Profiler trace that this proc is being called: sp_procedure_params_managed Each call has 350+ reads in the trace! We are using Microsoft.Practices.EnterpriseLibrary.Data in an ASP.NET front end. How can we eliminate these stored procedure calls? We are not explicitly calling it in code. I'm running Sql Ser...

Can't install Server tools with SSIS on top of Express Edition

I have a SQL Server Express edition with management studio and i'm trying to use the enterprise disks ("SQL Server 2005" Enterprise Edition 32-bit Server Applications") and I can't get it to give me the option of installing the server components or a server instance. What am I missing? ...

Custom SQL Server driver

I had a crazy thought about writing my own SQL Server driver to make it work something like non-blocking http client, so it won't be thread thirsty and could handle lots of db queries within one thread. I tried to look over google for some guidelines about implementing SQL Server client protocol, but found none really, where do those gu...

SQL Server Express performance issue

Hi folks ! I know my questions will sound silly and probably nobody will have perfect answer but since I am in a complete dead-end with the situation it will make me feel better to post it here. So... I have a SQL Server Express database that's 500 Mb. It contains 5 tables and maybe 30 stored procedure. This database is use to store a...

Database design 1 to 1 relationship

I design my database incorrectly, should I fix this while its in development? "user" table is suppose to have a 1.1 relationship with "userprofile" table however the actual design the "user" table has a 1.* relationship with "userprofile" table. Everything works! but should it be fixed anyways? ...

SQL Server stored procedure + set error message from the records of a table

Hello, My question is I have a table with the set of records. I am calling a stored procedure for some other purpose. But when ever it finds some duplicate records. It need to return as error message back to php. C1 C2 c3 abc 32 21.03.2010 def 35 ...

find the all the stored procedures and jobs in sql server 2000

Hi, In SQL SERVER 2005 This query works fine : Select * from sys.procedures where object_definition(object_id) like '%J%' SELECT * FROM MSDB.DBO.SYSJOBS WHERE NAME LIKE '%J%' but in sql server 2000 it is not working. Here i need to find the all the stored procedures and jobs which matches my string ? how to find in sql server 2000 ? ...

sql: delete a subtree table(id, Parentid) , delete a item with all his children

I have a table like this foo(id, parentId) -- there is a FK constraint from parentId to id and I need to delete an item with all his children and children of the children etc. anybody knows how ? ...

SQL Server becomes slow after restart

We use SQL Server 2005 on an Windwos Server 2008. Ther Server has 48 GB RAM. SQL Server is configured to use 40 GB RAM. There is only one database hosted (About 70 GB). The only app beside SQL Server is our App-Server which connects the clients to the database. Now we encounter the following problem: After a restart of the server our t...

Sql Server query performance

I have a stored procedure on a busy database which constantly come out top in the list of expensive queries (by some way). The query is very simple, it takes a single parameter (@ID, int) which is the primary key of the table, and selects the record that matches that ID. The primary key is an identity field with a clustered index, so I...

How many records can i store in a Sql server table before it's getting ugly?

Hi, i've been asked to do some performance tests for a new system. It is only just running with a few client, but as they expect to grow, these are the numbers i work with for my test: 200 clients, 4 years of data, and the data changes per.... 5 minutes. So for every 5 minutes for every client there is 1 record. That means 365*24*12 = ...

"Ambiguous column name" error on one particular server

This simple query throws the "Ambiguous column name TaskID" error on one db-server only. This is ridiculous. We tested this with the same database structure on different servers and different versions of ms sql (2005/2008), and it's only THIS particular client's server that throws the error. I'm actually frustrated. SELECT Tasks.TaskID ...

Optimal search queries

Following on from my last question http://stackoverflow.com/questions/2788082/sql-server-query-performance, and discovering that my method of allowing optional parameters in a search query is sub optimal, does anyone have guidelines on how to approach this? For example, say I have an application table, a customer table and a contact det...