sql-server

What does 0..1 Mean in EF?

Hi I am just starting out with the Entity Framework and in my ms sql database I made a diagram in some relationships of tables have a primary key to primary key relation ship what I conceive as 1 to 1 relationship. Now I generated EF database in VS2008 and these same ones have a relationship of 1 to 0..1 So it seems to say "0" or "1"....

Simulating MySql OLD_PASSWORD in .NET or MS SQL ?

I have started a new project in .NET which uses some old system's datababase in MySql. The data stored in mysql is periodicaly transfered to MS Sql on which our system works. I need to authenticate users with their login and password. User's passwords are stored as hash generated by OLD_PASSWORD function from mysql. Is there any way to ...

SQL Server PIVOT - Multiple Aggregates

Given the following result set: --------------------------------------------------------- CustomerID  Service  TransType  SubTotal   Tax   NetTotal --------------------------------------------------------- 106           A        CREDIT     12.52   -   12.52 106 A        CREDIT     10.07   -   10.07 106           ...

export query results into CSV file issue in SQL Server

Hello everyone, I am using SQL Server 2008 Enterprise. I want to export the query result into csv file from SQL Server Management Studio. The issue is, the default csv file is comma (',') separated for each result column in each exported row, and I want to make it '\t' separated since comma exists in some of the result column values. A...

IF statement in ORDER BY Clause of a SELECT Statement in a SQL Server Stored Procedure

I am trying to create a stored procedure that takes a bit parameter which if true orders by one column and if false orders by another column. How would I implement this? Here is what I have so far CREATE PROCEDURE [dbo].[CLICK10_GetCP] @switch AS BIT AS BEGIN SELECT acct_nbr, acct_name FROM acct ...

Outputting Results from complicated database structure (SQL Server)

This will be a long question so I'll try and explain it as best as I can. I've developed a simple reporting tool in which a number of results are stored and given a report id, these results were generated from a particular quote being used on the main system, with a huge list of these being stored in a quotes table. Here are the current...

way to retrieve the objects QUOTED_IDENTIFIER (and associated ANSI) settings??

Hi, is there a way to identify whether the object is created with SET QUOTED_IDENTIFIER on or off?? (not only this set option, am lookin for a script to identify all the ANSI settings associated to the object) this is a follow up to the questions in staack link - 1 and Link-2 i ve been getting the SET QUOTED_IDENTIFIER error on a si...

Extended Stored Procedure with ODBC DSN

I have an extended stored procedure (written in Delphi if that makes any difference) that makes its own connection via ODBC and performs some processing - stuff that can't be done using T-SQL alone. If I try to connect using the System DSN that is set up (e.g. named MyDataSource), the xp returns the following error: [Microsoft][ODBC SQ...

SQL Server: loading database file

I'm using SQL Server 2008. I should be able to "connect" to a user-specified database file (mdf) (using the AttachDbFilename section of the connection string) and save a copy of the selected file. I also have to work with the contents of the database. If I got it right, a single mdf file represents a complete database with tables, store...

What can cause garbage on prints with reportserver?

I develop a Winforms application written with framework 2.0, which has some Server Reports in Report Server (SQLServer 2005). This reports in the test enviroment are printing just right, but in production weird things happens (as ussual). Sometimes, the windows spooler sends the print job to the printer and the printer acknowledge the ...

SQL Pivot table

Is there a way to pivot an Entity-Attribute table? I want to flip all the rows into columns, regardless of how many different attributes there are. Here's an example of what I want to accomplish. The example uses two attributes: FirstName, LastName. But in the real database, there are thousands of attributes and I want to flip them ...

Why does LIKE not return rows for variables with '%' at end?

I find this quite odd on Microsoft SQL Server: SELECT * FROM deliveries WHERE code LIKE '01999195000%' -- 9 rows returned. Works. DECLARE @a VARCHAR(10) SET @a='01999195000%' SELECT * FROM deliveries WHERE code LIKE @a -- 0 rows returned? Why not? SET @a = '01999195000' SELECT * FROM deliveries WHERE code LIKE @a + '%' -- 9 rows retur...

Importing a MDF file into SQL Server 2008?

I have inherited a VB.net web app that I'm making some changes on. I'm perfectly capable with the programming side (VB and MSSQL) but I'm getting lost with the tools. I was given a zip file of the code and everything. I opened the sln file in Visual Studio 2005 and it worked fairly easily with little modification. Running the app works ...

relationships in Sql

I know how to create one to many, many to many relationships in SQL Server, but is it possible to create one to one relationship? And is it possible to create 1 to 0 or 1 relationship? ...

Can't connect to Sql Server

Im getting this error on the production server: A network-related or instance-specific error occurred while establishing a > connection to SQL Server. It's on IIS, and connecting to sql server with Windows authentication. Any idea? or solutions? ...

SQL Server: sort a column numerically if possible, otherwise alpha

I am working with a table that comes from an external source, and cannot be "cleaned". There is a column which an nvarchar(20) and contains an integer about 95% of the time, but occasionally contains an alpha. I want to use something like select * from sch.tbl order by cast(shouldBeANumber as integer) but this throws an error on the...

Why a simple T-SQL UDF function makes the code execution 3 times slower

Hi folks, I'm rewriting some old stored procedure and I've come across an unexpected performance issue when using a function instead of inline code. The function is very simple as follow: ALTER FUNCTION [dbo].[GetDateDifferenceInDays] ( @first_date SMALLDATETIME, @second_date SMALLDATETIME ) RETURNS INT AS BEGIN RETURN ABS(DA...

SSIS Redeployment

I finally got my SSIS package deployed to our SQL 2005 server, and I can run it from my ASP.NET 2.0 code. I needed to change my package after I first set it up. I double-clicked the .manifest file and deployed the package to the same server, but the job is never updated. It stays in the same state as when I first deployed it. Is ther...

List SQL Server instances in ASP.NET

I'm trying to list all the SLQ Servers that are available on our Network in a gridview on a form. I have this code in a button click event. SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance; System.Data.DataTable myDataTable = instance.GetDataSources(); gvSqlServers.DataSource = myDataTable; gvSqlServers.DataBind(); ...

Check if string contains another string

In T-SQL, how would you check if a string doesn't contain another string? I have an nvarchar which could be "Oranges Apples". I would like to do an update where, for instance, a columm doesn't contain "Apples". How can this be done? ...