sql-server

tSQL CASE to control execution

I understand how to use a case statement to return different values: SELECT CASE Color WHEN 'Blue' THEN 'Water' WHEN 'Black' THEN 'Oil' WHEN 'Red' THEN 'Blood' END FROM dbo.Liquid Is there a way to use it to control flow instead of IF-ELSE, i.e. DECLARE @Color varchar() SELECT @Color = Color FROM d...

what is the compatibility level of sql server 2008 r2

what is the compatibility level of sql server 2008 r2? does anyone know when it will be released? ...

Sample Spatial Data for Sql Server 2008

Hi, I'm looking for sample database including spatial data. That can be also oracle-equivalent,convertable to sql server 2008 Related : http://stackoverflow.com/questions/57068/good-databases-with-sample-data ...

Creating audit triggers in SQL Server

I need to implement change tracking on two tables in my SQL Server 2005 database. I need to audit additions, deletions, updates (with detail on what was updated). I was planning on using a trigger to do this, but after poking around on Google I found that it was incredibly easy to do this incorrectly, and I wanted to avoid that on the ...

SSAS Deploy Wizard Shows Errr

SSAS Deploy Wizard Shows Errr when Started : SSAS Deployment Utility has encountered a problem and need to close. please help me. this appears evry time i started to install SSAS 2005 on my sytem. Regrdas, Manish ...

Conversion failed when converting datetime from character string

when i compile the following code , "Conversion failed when converting datetime from character string" exception raises , what is wrong with that ? code : DateTime after3Dyas = DateTime.Now.AddDays(3); try { Con.Open(); SqlCommand Command = Con.CreateCommand(); Command.CommandText = ...

Encrypt SQL Server connection string

If one has a connectionstring in one's application, is there a way to encrypt the information it contains? The connection string is created using the SqlConnectionStringBuilder object. Or is it 'acceptable' that sensitive information is sent in plaintext to the server? ...

I need help in speeding up the execution's time of my stored proc

Hello guys.I wanna ask some little question.How can i speed up the perfomance of the next stored proc.First,a need to say that there are 30 000 000 rows in the next table: CREATE TABLE tblT ( [RowID] [int] IDENTITY(1, 1) NOT NULL ,[CheckDateID] int NOT NULL ,[SSN] varchar(10) ,[CheckDate] datetime ,[val] m...

C# SQLServer retrieving results and place in a .csv format

Hi, I had a look on the site and on Google, but I couldn't seem to find a good solution to what I'm trying to do. Basically, I have a client server application (C#) where I send the server an SQL select statement (Connecting to SQL Server 2008) and would like to return results in a CSV manner back to the client. So far I have the follo...

hibernate related problem..

i want to access a databaseof SQL through hibernate in NetBeans IDE..can anybody help me out.. ...

create entities for a dynamically created database in SQL Server

I have an application where I create database's dynamically in a SQL Server using Server Management Objects through my application. I want to use the Entity Framework to access this database when it has been created, is this possible? As I can not generate Entity classes from a database in VS. I do have the structure of the database ...

regular expression inside SQL Server

Hi! I need something like this... stored value in DB is: 5XXXXXX [where x can be any digit] and i need to match incoming SQL query string like... 5349878. Does anyone has an idea how to do it? i have also different cases like XXXX7XX for example, so it has to be generic. i don't care to represent the pattern in a differnet way ins...

organize sql server enterprise manager DB Diagram view

As i get more and more tables, using the diagram view becomes harder and harder. is there anyway to have it auto order or sort to align joined tables, etc and avoid having to do it manually ...

Extract year from datetime format

I'm doing my final year project using asp.net as front end and SQL Server 2005 as back end My question is: I want extract only the year from datetime format. And use the year to filter data ...

What problems will I cause by installing SQL Express as MSSQLSERVER?

As with the people in this feedback doc, Selecting the "Default Instance" option in SQL Server 2008 Express RTM has no effect, I had to install SQL Server Express 2008 twice before I realised what was I was doing. The installation defaults to "SQLExpress" even if you select Default Instance. What problems might I cause myself in the fu...

SQL Server 2008 multi columns statistics not being used by row count estimation

i have a table with columns A and B which are correlated in the following meaning: A == 1 => B == 3 A == 2 => B == 0 A == 3 => B == 7 with => meaning implies with high probability. I want to query like this: where A = 2 and B = 3 --very few rows should match so i have created statistics on (A, B). however the query optimizer comple...

multiple constraint keys

if i have tabled: Resource (id (PK), name) Manager (id(PK), resource_id (FK), manager_resource_ID(FK)) Should resource_id and manager_id both be foreign keys into the Resource table. i obviously dont want to enter any values in each of those columns that are not proper resources when i add the first relationship (resource_id <-> id...

Need help in optimizing update statement

Hello guys. I have two tables : create table CurrentDay ( ID int identity primary key, ssn varchar(10), val money, CheckDate datetime, CurrentStatus tinyint) create table PreviousDay ( ID int identity primary key, ssn varchar(10), val money, CheckDate datetime, CurrentStatus tinyint) I need update field CurrentDay.CurrentStatus...

SQL Server: store more integers in a single value

I'm not sure how to explain this probably, so I'll use an example. I have to store (etc.) some users ID in a single value/column in my SQL Server table, so one value could look like this "4231 3271 3722 7432 4831 3192 ". of course this can be stored as a text, char, nchar, nvarchar and som on. But which is the best? if I have to only st...

how can i rewrite a select query in this situation

Hello guys! Here are two table in parent/child relationship. What i need to do is to select students with there average mark: CREATE TABLE dbo.Students( Id int NOT NULL, Name varchar(15) NOT NULL, CONSTRAINT PK_Students PRIMARY KEY CLUSTERED ( CREATE TABLE [dbo].[Results]( Id int NOT NULL, Subject varchar(15) NOT NULL, Mark in...