sql-server

SQL SERVER Query result in CSV format is possible?

Hi, Is it possible to get the query result in .CSV file format from SQL SERVER 2000 and above versions? If so can we use this feature from an asp.net application to get the result in CSV format? If so how can we do this? ...

CASE statement within WHERE statement

Greetings, I would like to include CASE Statement inside my where statement as follows: SELECT a1.ROWGUID FROM Table1 a1 INNER JOIN Table2 a2 on a1.ROWGUID=a2.Table1ROWGUID WHERE a1.Title='title' AND (CASE WHEN @variable is not null THEN a1.ROWGUID in (SELECT * FROM #TempTable)) However, this 'CASE' statement does not work inside 'W...

Other language string in SQL Server 2005

I am trying you insert some string which is not in English (other language). when i fetch back they are not correct. They comes like "?????". But at the same time when I enter the string through the SQL Server UI (SSMS) to enter the string, it works OK. What could be the solution please? ...

joining stored proc result with a query linq to entities

Hi Experts, I am working with linq to entities where I have a stored proc which returns an enetity based on some parameters. I can get this result in program. Now I want to join this resultset with similar entity on a common field. my entity Books { BookId, Title } Stored Proc GetFilterBooks(someparam) ( Select * from books wher...

Will performance of a SQL server degrade if the DB can't fit in the memory?

Will the performance of a SQL server drastically degrade if the database is bigger than the RAM? Or does only the index have to fit in the memory? I know this is complex, but as a rule of thumb? ...

How do I create queries to SQL Server tables via Visual Studio when no knowledge about SQL nor Linq?

Let´s be frank, my knowledge regarding SQL language is very low. Nevertheless, my boss gave me the task to build a database application using the following tools: SQL Server and Visual Studio 2008; C#. I use the VS DataSet as a local mirror of the SQL Server. And let´s be frank again, my understanding of the VS Query builder is also ve...

Strange error occurring when using wcf to run query against sql server

Hi all, I am building an asp.net application, using II6 on windows server 2003 (vps hosting). I am confronted with an error I didn't receive on my development machine (windows 7, iis 7.5, 64 bit). When my wcf service tries launching my query running against a local sql server this is the error I receive: Memory gates checking faile...

SmoApplication.EnumAvailableSqlServers returns server names but not instance names (but only on one machine)

Hi, There are a number of questions about this and a number of possible causes and thus far ive tried them all with no success. situation: i have an app that needs a db to work, onstartup it does a SmoApplication.EnumAvailableSqlServers(false) to get all the instances on the network, shows the user a dropdown, they pick one and i go con...

default schema synonym

I have a database FooDb with a schema BarSchema that contains a table Tbl (i.e. FooDb.BarSchema.Tbl) I am also logged in as a user with BarSchema as default. This query works fine SELECT * FROM FooDb..Tbl I also have a synonym for this table in another db CREATE SYNONYM TblSynonym FOR FooDb..Tbl But now I get an error "Invalid ob...

SQL Server varchar to datetime

I have a field varchar(14) = 20090226115644 I need convert it to -> 2009-02-26 11:56:44 (datetime format) My idea. use cast and convert.. but I always have errors. Conversion failed when converting datetime from character string. I made this, but don`t like it.. SELECT SUBSTRING(move,1,4) + '-' + SUBSTRING(move,5,2) + ...

T-SQL Query Results Not as Expected Deduplication

Hi Guys, I am attempting to get all records where and Id field exists more than once, trouble is my query is returning nothing and I have no idea as to why!? And this is the only method I know. Some more information: There are up to 8 of the same Order Numbers Each set is grouped by ProcessOrder, I require the lowest value of these b...

How do I INSERT binary data from a local file with SQLCMD?

I need to insert binary data from a file into a varbinary(max) column in SQL Server as a part of my deployment script. The file is on the local machine, SQL Server is on the remote. Here is the data table definition CREATE TABLE [dbo].[Config] ( [ID] INT IDENTITY (1, 1) NOT NULL, [Name] NVARCHAR (50) NOT NULL, ...

Update Multiple Tables at a Time - SQL Server/T-SQL

I have two tables, Customer and CustomerPhone. Single record in Customer can have multiple CustomerPhone records. As you see in the image below, Phone and Fax resides in CustomerPhone table whereas the rest of the fields resides in Customer table. If user want to edits a customer record, obviously i will have to update the record in Cus...

PHP --> SQL Server + Excel file upload from a specific row

I have a requirement in which, i need to upload an excel file into SQL Server database. It is working well till this point. But sometimes i am getting excel file in such a way, that the first 2 rows and columns are empty rows. That is not even fixed every time. so the format of the table after upload is not as expected. It is assigning...

How do I filter one of the columns in a SQL Server SQL Query

I have a table (that relates to a number of other tables) where I would like to filter ONE of the columns (RequesterID) - that column will be a combobox where only people that are not sales people should be selectable. Here is the "unfiltered" query, lets call it QUERY 1: SELECT RequestsID, RequesterID, ProductsID FROM dbo.Requests I...

Deploying WPF applications with SQL Server

Ok so I'm developing a WPF application that makes heavy use of SQL Server. I've been asked to create an installer package that checks whether the client already has SQL Server Express 2005 already installed, his operating system (64bit Vs x86) and install the required SQL Server instance if needed. I'm then required to automatically map...

Need help with a SQL CTE Query

I have a table that I need to get some specific data from for a view. Here's the base table structure with some sample data: | UserID | ReportsToUserID | Org ID | ------------------------------------- | 1 | NULL | 1 | ------------------------------------- | 2 | 1 | 1 | -----------------------...

Should we have separate database instance for each developer?

What is the best way for developing a database based application? We can have two approaches. One common database for all the developers. List item Separate database for all the developers. What are the pros and cons of each? And which one is better way? Edit: More then one developer is supposed to update the database and we alrea...

Embedding SQL Server into a .NET application

Hey, I've just finished writing a VB.NET application. Now I want to package the executable and the database ofcourse into a single installer file. I tried using QSetup, InstallShield to make SQL Server embedded into the setup file, and finally after hours of try&fail I have no idea. Anyone? ...

Power error handling inside of sql function

I have a power function call inside of a sql function. What is the correct way to handle overflow and underflow conditions since I cannot use a Try Catch inside of a function. I am also trying to avoid modifying the ARITHABORT, ANSI_WARNINGS, and ARITHIGNORE settings in the calling code. GO CREATE FUNCTION TestPow() RETURNS DECIMAL(30,...