sql-server

Crystal Reports assumes wrong datatype of column from stored proc

What can be the reason that Crystal Reports Engine sometimes thinks that a field, that is returned from some stored procedure, that is in fact is of type money, is a varchar 255? Because of that I cannot apply any number formatting. ...

How can i obtain an Sql Language name from a .Net Culture.

Hello i'm using SQL server full-text search. when i use the FreeText predicate it need the language as parameter, but sql parameters name is different from .net culture names. So my question is How can i obtain an Sql Language name from a .Net Culture. ...

Move Model Database (How to change default database location)

I'm not sure if this would belong on Stack Overflow or Server Fault, so if it belongs on Server Fault please let me know. Anyway, here's the problem. I've got an install of SQL Server 2008 on a server on the local c drive. The c drive is not a large drive, and as such i want all new databases created on the server to be created on the...

convert empty space to null

I am using sql server. I have a table and the columns on this table contains empty spaces for some records. Now i need to move the data to another table and replace the empty spaces with NULL value. I tried to use REPLACE(ltrim(rtrim(col1)),' ',NULL) but it doesn't work. Because it will convert all the value of col1 to NULL. I just n...

Shortest way to restore SQL Server database

I have to restore various SQL server databases several times a day (for development purposes). In SSMS interface it takes forever and it is even longer to type RESTORE DATABASE command with all it's paths. Ideally I would like to double-click a BAK file right in Windows Explorer and run something to restore it. Any way to achieve this...

SQL Server Compare similar tables with query

Simple concept we are basically doing some auditing, comparing what came in, and what actually happened during processing. I am looking for a better way to execute a query that can do side by side table comparisons with columns that are slightly differnt in name and potentialy type. DB Layout: Table (* is the join condition) Log (Un-a...

need help understanding UPDATE...FROM...

hello, please help me to understand how the T-SQL's UPDATE FROM query works. the sample query below results in value-inc, value-dec value-inc, value-dec value-inc, value-dec value-inc, value-dec value-inc, value-dec value-inc, value-dec i expected this: null, 'value-dec' null, 'value-dec' null, 'value-inc' nul...

VB.NET DataSet not working with view with linked SQL Server

I am in DataGrid hell right now but that's another post. Anyway, I wrote a view with a union query in SQL Server that grabs data from a linked SQL server. Anytime I try to add this object as a dataset in VB.NET it completely bombs out on me with this ugly error message... ERROR [42000] [Microsoft] [ODBC SQL Server Driver] [SQL Server]...

How to Implement Exchange like availability monitoring of internal SQL Server

We have an internal app(Thick Client) that relies on our central SQL server. The app is a Desktop app that allows the users to work in "Offline" mode (e.g. Outlook). What I need to accomplish is a way to accurately tell if SQL is available or not. What I have so far: I currently use the following method --> internal static void Che...

SQL if no rows are returned do this....

I have a select statement and I want to say if this select statement does not return any rows then put a '' in every cell. How do I do this? ...

SQL Monitoring and Interjection

From another thread that gave me the information on how to add monitoring to an SQL Server... http://stackoverflow.com/questions/3586736/see-sql-from-entityframework-with-collection-like-queries This works well, but I want to take it a step further. I'd like to be able to add comments into the log when Transactions are happening. I w...

SQL Server 2005 - searching for value in XML field

Hello, I'm trying to query a particular value in an XML field. I've seen lots of examples, but they don't seem to be what I'm looking for Supposing my xml field is called XMLAttributes and table TableName, and the complete xml value is like the below: <Attribute name="First2Digits" value="12" /> <Attribute name="PurchaseXXXUniqueID" ...

Error adding connection in Server Explorer: "Unable to add data connection. ExecuteScalar requires an open and available connection."

I'm using Visual Studio 2008, and my database is SQL Server 2000. I want to add a connection to the Server Explorer in VS. The Data source is Microsoft SQL Server (SqlClient). After entering in all my information and I click Test Connection, it is successful. But when I click OK, I get the error: Unable to add data connection. Execute...

What SQL Server DataType should I use for a Text field which will be JOINED, "LIKE'd" and Queried against alot?

The title really says it all, a bit more info though for those who bothered to click. Strings will be of variable length typically between 2-5 characters in length, could occasionalyl exceed 5 characters and be upwards of 10. Never more than 10. Will be queried on like such: SELECT ... WHERE ... = 'abcd'; SELECT ... WHERE ... LIKE 'ab...

How to export SQL Server 2005 rows to excel? Everytime I do it I get errors

I have SQL Server 2005 and I am trying to export a table into an Excel file. I right click on my database and click export. I go through the wizard and choose to export to excel then I choose my one table that I want to export and hit finished. I get this Messages Error 0xc0202009: Data Flow Task: SSIS Error Code DTS_E...

DMV in SQL 2008 to replace dm_os_exec_requests

I've been going through an old SQL 2005 performance tuning document and it talks about the dynamic management view sys.dm_os_exec_requests. It looks like that view is no longer available in SQL 2008. Is there a direct replacement? Is there a standard way of selecting the same data from another DMV or group of DMVs? Thanks! ...

How to implement reverse geocoding on SQL Server 2008 (with spatial capabilities)?

Let's suppose I have a street shapefile loaded on SQL Server 2008. How can I implement a reverse geocode function (get an address from a lat/long pair)? What SQL Spatial functions can I use for that? Does it have a function that get the closest "feature" from a lat/long pair? ...

Fastest way to map a list of names in an excel doc to their IDs in a lookup table?

For one of my projects I display a list of counties in a drop down list (this list comes from a lookup table containing all counties). The client just requested that I limit it to a subset of their choice. The subset was given to me in an excel spreadsheet containing only names (seen below): I'm trying to figure out the quickest way...

What should I have in mind when building OLAP solution from scratch?

I'm working for a company running a software product based on a MS SQL database server, and through the years I have developed 20-30 quite advanced reports in PHP, taking data directly from the database. This has been very successful, and people are happy with it. But it has some drawbacks: For new changes, it can be quite development...

Select rows from SQL where column doesn't match something in a string array?

Let's say I have a table, Product, with a column called ProductName, with values like: Lawnmower Weedwacker Backhoe Gas Can Batmobile Now, I have a list, in Notepad, of products that should be excluded from the result set, i.e.: Lawnmower Weedwacker Batmobile In my real-life problem, there are tens of thousands of records, and thou...