sql-server

Inserting a value into a SQL float column generates a weird result

I am working on a legacy ASP application. I am attempting to insert a value (40.33) into a field in SQL Server 2000 that happens to be a float type. Every place I can see (via some logging) in the application is sending 40.33 to the Stored Procedure. When I run SQL Profiler against the database while the call is happening, the value t...

What's the best storage for SQL Server 2000?

I want to access my sql server database files in a INTEL SS4000-E storage. It´s a NAS Storage. Could it be possible to work with it as a storage for sql server 2000? If not, what is the best solution? ...

How do I find out which line of which stored procedure an error occurred on?

When I try to run a particular stored procedure on my MS SQL 2005 database, I get an error like the following: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression The SP in query is very long and calls other SPs. This error is obviousl...

How do I compare an epoch time against 24 hours ago in SQL Server?

I am using MS SQL Server 2005, I have dates stored in epoch time (starting 1970) I need to create a statement that will affect any record that has not been updated in the last 24 hours. ...

Classic ASP: Page text translated from SQL table, a faster way?

Using classic ASP VBScript, coupled to MS SQL Server, we have a function that takes 3 integers, page_id, heading_id, language_id it looks up the page heading in a translation table... This table contains roughly 10,000 rows... The heading column is nvarchar(1000) plus the 3 int columns meaning it's around 2KiB per row max... so my qu...

Summarize aggregated data

I have a table like as follows: SoftwareName Count Country Project 15 Canada Visio 12 Canada Project 10 USA Visio 5 USA How do I query it to give me a summary like... SoftwareName Canada USA Total Project 15 10 25 Visio 12 ...

Select from different tables via SQL depending on flag

I have a script to extract certain data from a much bigger table, with one field in particular changing regularly, e.g. SELECT CASE @Flag WHEN 1 THEN t.field1 WHEN 2 THEN t.field2 WHEN 3 THEN t.field3 END as field, ...[A bunch of other fields] FROM table t However, the issue is now I want to do other processing on the d...

Algorithm to avoid SQL injection on MSSQL Server from C# code?

What would be the best way to avoid SQL injection on the C#.net platform. Please post an C# implementation if you have any. ...

Flatten a recordset in SQL Server?

Say you get a recordset like the following: | ID | Foo | Bar | Red | |-----|------|------|------| | 1 | 100 | NULL | NULL | | 1 | NULL | 200 | NULL | | 1 | NULL | NULL | 300 | | 2 | 400 | NULL | NULL | | ... | ... | ... | ... | -- etc. And you want: | ID | Foo | Bar | Red | |-----|-----|-----|-----| | 1 | 100 | ...

Reporting server:

Hi, i am trying to setup SQL Reporting services on windows vista, iis7 but i keep getting this error when i try http://localhost/Reports/Pages/Folder.aspx **Server Error in '/Reports' Application. Request is not available in this context Description: An unhandled exception occurred during the execution of the current web request. Plea...

Bulk Translation Of Table Contents

I'm currently performing a migration operation from a legacy database. I need to perform migration of millions of originating rows, breaking the original content apart into multiple destination parent / child rows. As it's not a simple 1 to 1 migration and the the resulting rows are parent / children row based on identity generated key...

SQL Server Full Text Search

How do I setup SQL full search in SQL Server Express 2005 and 2008? Are there any helpful queries that a dba should know? ...

SqlDataAdapter.Fill method slow

Why would a stored procedure that returns a table with 9 columns, 89 rows using this code take 60 seconds to execute (.NET 1.1) when it takes < 1 second to run in SQL Server Management Studio? It's being run on the local machine so little/no network latency, fast dev machine Dim command As SqlCommand = New SqlCommand(procName, CreateCo...

How can I enable Full-Text indexing using SQL Server Management Studio in SQL Server 2008 Express?

I did it using the commands as described here and it works but I want to do it using the SQL Management Studio. SQL Server 2008 Books Online says this: To create a full-text catalog: In Object Explorer, expand the server, expand Databases, and expand the database in which you want to create the full-text catalog. Exp...

How can I drop a table if it exists in SQL Server 2000?

I have a DTS package that drops a table then creates it and populates it but sometimes something happens and the package fails after the drop table. If it's rerun it fails cuz the table hasn't been created yet. Is there something like "if exists" for SQLServer 2000 like in MySQL? thanks. Edit Thanks everyone! I went with TrickyNix...

how to pass variables like arrays / datatable to SQL server ?

Sometimes you need to upgrade the database with many rows that you have in a datatable or you have an array full of data, instead of putting all this data together in a string and then splitting in SQL SERVER, or instead of iterating the datatable in the code row by row and updating database, is there any other way? Is there other type o...

Select one column DISTINCT SQL

Added: Working with SQL Server 2000 and 2005, so has to work on both. Also, value_rk is not a number/integer (Error: Operand data type uniqueidentifier is invalid for min operator) Is there a way to do a single column "DISTINCT" match when I don't care about the other columns returned? Example: **Table** Value A, Value L, Value P Valu...

Benefits of DataBinding over Manually Querying / Adding to Control

I've been a C# programmer for about 2 years total, and professionally for a little more than 1. I work at a company as a developer on an application that began before the days of .NET 2. My question is this: What is the benefit to use databinding from sql queries directly to a control over querying and manually adding items to the contr...

How to shrink a SQL Server Log file with Mirroring enabled?

I have several databases for my applications that use SQL Server 2005 mirroring to keep a nice copy of the data somewhere else. Works like a charm, however, the log file just seems to be growing and growing, one is at 15GB for a 3GB database. Normally, I can just shrink it - however an error pops up that this specifically cannot be ...

MS SQL 2005 Table to XML

I have a simple table in SQL Server 2005, I wish to convert this to XML (using the "FOR XML" clause). I'm having trouble getting my XML to look like the required output. I've tried looking through various tutorials on the web, but I am struggling. Can someone help? The table I have looks like this TYPE,GROUP,VALUE Books,Hardback,56 Bo...