sql-server

SQL Server 2005 or 2008 for release

Hi to all, We have been using sql server 2005 during development and have had no real issues. Now at the time of the release, it has been suggested we go with SQL server 2008. The installation of it is a bit of a nightmare with all the configuration options and I am sure this will confuse the customers (even with documentation). Powers...

SQL Server warning message about nulls

This warning message I get from time to time from SQL server ... Warning: Null value is eliminated by an aggregate or other SET operation. Is this just saying that a value that was Null is being set to something other than Null. Why do I need to be 'warned' about this? ...

knowing if a string will be truncated when updating database

I'm working on a software that takes a csv file and put the data in a sqlserver. i'm testing it with bad data now and when i make a data string to long (in a line) to be imported in the database i got the error : String or binary data would be truncated the statement has been terminate. that's normal and that's what i should expect. Now ...

Is there a better way to sort this query?

We generate a lot of SQL procedurally and SQL Server is killing us. Because of some issues documented elsewhere we basically do SELECT TOP 2 ** 32 instead of TOP 100 PERCENT. Note: we must use the subqueries. Here's our query: SELECT * FROM ( SELECT [me].*, ROW_NUMBER() OVER( ORDER BY (SELECT(1)) ) AS rno__row__index FROM ( ...

How to use parameter with LIKE in Sql Server Compact Edition

I'm trying to parameterise a search query that uses the LIKE keyword with a wildcard. The original sql has dynamic sql like this: "AND JOB_POSTCODE LIKE '" + isPostCode + "%' " So I've tried this instead, but I get a FormatException: "AND JOB_POSTCODE LIKE @postcode + '%' " Edit: I guess the FormatException isn't going to be coming...

Does creating a nonclustered index on a SQL Server 2005 table prevent selects?

I'd like to create an index on a view I have but I need to make sure the data can still be read while the index is being created. I was reading an article that suggested that when creating a nonclustered index that the data is still readable if you specify the ONLINE=ON option (example below): CREATE UNIQUE CLUSTERED INDEX CLUST_IDX_SQ...

How to write a query for SQL Server 2008 that returns the dependencies of an object (Exactly what Management Studio shows with the "View Dependencies" menu)

Management Studio connected to SQL Server 2008 Right click on an object and choose "View Dependencies" Now you can navigate through de dependendies back and forth. How do I get the same information programmatically? (an SQL query?) ...

SQL Indexing - Computed Column vs Field Used by Computed Column

Quick question for the DBA's out there: Say I have 2 columns on my table, IsDeleted (bit) and DeletedDate (datetime). The table contains approx 10,000,000 rows. IsDeleted is a computed column that checks to see if DeletedDate is NULL; and it returns 1 if it is not, and 0 if it is. Querying this table will mainly be done on the IsDele...

SSIS data Import from MySql

I am working with SSIS and trying to import data from MySql to SQL Server. I am having issues trying to convert mySql datetimes to SQL Server Datetimes. Any suggestions? ...

sql server string trim

I need to trim a field in SQL Server table, when i use a select statement. The requirement is that this field populates the dropdownlist in .net page. The maximum length that the data needs to display is 20. If data length is more than that, then it should be cut to 20, if less then the data length should be the length of string. How ...

Generating Database Scripts in SQL Server Express

I generate change scripts for my database to keep it under source control, and a strange thing happens every time: I have a FlowFolder table, and clicking Generate Scripts creates the following two scripts: dbo.FlowFolder.Table.sql: USE [NC] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo]....

Returning from a stored procedure before it is finished executing

We have a stored procedure in which there are two parts. In part 1, failures need to be returned to the application, and the part must be completely executed before the stored procedure returns. Part 2 is a long process which needs to execute whenever the procedure is called, but all failures can be ignored (or handled elsewhere), howe...

How do you query for comments stackoverflow style?

I saw this question on meta: http://meta.stackoverflow.com/questions/33101/how-does-so-query-comments I wanted to set the record straight and ask the question in a proper technical way. Say I have 2 tables: Posts id content parent_id (null for questions, question_id for answer) Comments id body is_deleted post...

DROP INDEX never finishes...

I'm trying to drop an index that I have but when I execute the statement it just runs and runs (up to 30 mins before i stopped it last time). Has anyone ever run into this before? Any suggestions on how to free it up for deletion? ...

tsql update with nested select : easier way?

I got a nested query which I'm trying to run; however I have to screen for numbers with a -1 I have the following: update invoices set type = 5 where tranno like dbo._fnStripLeadZeroes(( select invoice_number from [bob.jupiter.com].webap.dbo.billinglog)) + '-1' with invoice_number(varchar15) and tranno(varchar10) am i approachi...

SQL: Select distinct values from 1 column

I want to select distinct values from only one column (the BoekingPlaatsId column) with this query: SELECT MAX(BoekingPlaatsId), BewonerId, Naam, VoorNaam FROM table GROUP BY BewonerId, Naam, VoorNaam How do I do that in SQL Server? ...

Is it possible to select data while a transaction is occuring?

I am using transactionscope to ensure that data is being read to the database correctly. However, I may have a need to select some data (from another page) while the transaction is running. Would it be possible to do this? I'm very noob when it comes to databases. I am using LinqToSQL and SQL Server 2005(dev)/2008(prod). ...

a SQL aggregation query

Hi there, I have an table with 2 columns, a date column and an int column and I want to sum the int columns per month where a month start on the 15th So the first result would be from today to the 15 of next month (Jan), the next row will be from the 16Jan to the 15Feb and so on until there are no more dates in the first column Makes ...

Free Schema Export for SQL Server 2008?

Not sure if this belongs here or on ServerFault, but I wonder if someone knows a free tool to export a SQL Server 2008 Schema? It's only for Tables and their Indexes, Foreign-Keys etc. and it needs to be a command line tool to run as part of a build process. If it can read a .net connection string, that would be awesome (hence the .net t...

How to fill a varbinary(MAX) column with a default image for all the records in SQL Server 2005 Express

I want to fill the varbinary(MAX) column of a SQL Server database table when ever a new record is created with a default picture. How do I do this using a trigger or in that case by any other means? Any help is highly appreciated. Thank You This is the T-SQL code I have tried: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TR...