sql-server

Explain this SQL query in plain English.

Please explain, in plain English, what question this SQL query answers: SELECT SUM(price) FROM Room r, Hotel h WHERE r.hotelNo = h.hotelNo and hotelName = 'Paris Hilton' and roomNo NOT IN (SELECT roomNo FROM Booking b, Hotel h WHERE (dateFrom <= CURRENT_DATE AND dateTo >= CURRENT_DATE) AND b.hotelNo = h.hotelNo AND hotelName = 'Paris ...

DATE lookup table (1990/01/01:2041/12/31)

I use a DATE's master table for looking up dates and other values in order to control several events, intervals and calculations within my app. It has rows for every single day begining from 01/01/1990 to 12/31/2041. One example of how I use this lookup table is: A customer pawned an item on: JAN-31-2010 Customer returns on MAY-03-...

how can I prevent dbo login from access my database?

I Made login (x) with sql authentication for mydatabase(Sharp) in sql2000.And I want to prevent dbo login from access my database what can i do? ...

How can I update many rows with SQL in a single table?

Hi folks. I have a table and one of the columns holds web addresses like: 'http://...' or 'https://...'. The problem is that there are some invalid entries, like 'shttp://...' or '#http//...' (the first character is invalid) and I want to correct all of them. I use the following SQL statement: 'SELECT [...] FROM MyTable WHERE WebAdd...

Convert SQL Server 2000 to 2005

I have a SQL Server 2000 database and I want to convert it to SQL Server 2005 ...

SQL Server - sum comma separated value from a column

There is a column in database which contains comma separated values like: 0.00,12.45,14.33 and so on. I need to sum this inside a stored procedure. One way which I can think of is to split and convert it into a table using a function and then sum it. Any other ideas? ...

Override Locale Date with custom setings.

Aside from the GL Support, is there a way to override locale settings with custom values for month and day when using mmm-dd-yyyy, modified spanish examples: Jan = ENE, Aug = AGO, or long dates (mmmm) January = ENERO, August = AGOSTO, or (dddd) Monday = LUNES, Thursday = JUEVES, etc.? ...

SQL: Recursively get parent records using Common Table Expressions

Hi there, Suposse you have to following tables where a sale consists of products and a product can be placed in multiple categories. Whereby categories have a hierachly structure like: Man Shoes Sport Casual Watches Women Shoes Sport Casual Watches Tables: Sale: id name 1 Sale1 Product: id saleidfk name ...

Database table relationships: Always also relate to specified value (Linq to SQL in .NET Framework)

I really can not describe my question better in the title. If anyone has suggestions: Please tell! I use the Linq to SQL framework in .NET. I ran into something which could be easily solved if the framework supported this, it would be a lot of extra coding otherwise: I have a n to n relation with a helper table in between. Those tables...

SqlCommandBuilder.DeriveParameters(command) and IsNullable

I have written an O/R database wrapper that generates some wrapper methods for stored procs it reads from the database. Now I need to produce some custom wrapper code if an input parameter of a stored proc is defaulted to NULL. The problem is - I get stored proc parameters using: SqlCommandBuilder.DeriveParameters(command) and it do...

Facing problem in configuring Reporting Server

Hi all, I am using Sql server 2005 express edition and i want to Install and configure Reporting server on my local machine.Now i have installed the reporting server but the issue is that i am unable to configure it properly.when ever i go to start the reporting services it gives me the following message: THE SQL SERVER REPORTING SERV...

MS SQL datetime precision problem

I have a situation where two persons might work on the same order (stored in an MS SQL database) from two different computers. To prevent data loss in the case where one would save his copy of the order first, and then a little later the second would save his copy and overwrite the first, I've added a check against the lastSaved field (d...

view to select specific period or latest when null

Hi I have a product table which simplifies to this: create table product(id int primary key identity, productid int, year int, quarter int, price money) and some sample data: insert into product select 11, 2010, 1, 1.11 insert into product select 11, 2010, 2, 2.11 insert into product select 11, 2010, 3, 3.11 insert into product sele...

updating all other records

Hi, I've got a query below. I want to add a condition that if the parameter of @IsPrestigeFeatured = 0 then update all of the other rows <> PropertyId in the IsprestigeFeatured column to 0 and if @IsPrestigeFeatured = 1 then IsprestigeFeatured = 1 where propertyId = PropertyId. I've looked into case statements / if statements but I can'...

when a sql server agent job is created and sheduled should we start running the job manaully for the first time or will it start automaitcally

hi i have created a sql server agent job and scheduled it for every 10 mins. for the first time, when it runs should we need to run the job manually once before it starts with scheduled time. Basically how does the job run for the first time. Also when the job is created the owner of the job is in disabled state. will this effect the sc...

SUM minutes SQL server

HI guys, My litle problem goes like this : I have this columns : PHONE_NR , TIME ( time field ), Meaning the calling telephone number and call duration. I need to group phone nr and sum the minutes. Filds looks like this : nr time 726028xxx 00:07:07 735560css 00:07:37 726028xxx 00:07:55 ...

Reporting on data when data is missing (ie. how to report zero activities for a customer on a given week)

I want to create a report which aggregates the number of activities per customer per week. If there has been no activites on that customer for a given week, 0 should be displayed (i.e week 3 and 4 in the sample below) CUSTOMER | #ACTIVITIES | WEEKNUMBER A | 4 | 1 A | 2 | 2 A | 0 | 3 A | 0 | 4 A | 1 | 5 B ... C ... ...

Constant Function in SQL Server (slow view that uses a function)

Hi, I have coded a view that relies on a scalar function value for one if its join conditions. The query plan is conservatively expecting that the function result could change between executions when the function is constant (at least for each complete query). The result changes once a day or so. Because of the huge number of rows the ...

Import MySQL database into a MS SQL Server

I have a .sql file from a MySQL dump containing tables definitions and the data to be inserted in this tables. How can I convert this database represented in the dump file into a MS SQL server database? ...

SQL Server identity issue

I have a query like below declare @str_CustomerID int Insert into IMDECONP38.[Customer].dbo.CustomerMaster ( CustomerName , CustomerAddress , CustomerEmail , CustomerPhone ) values ( ‘werw12e’ , ‘jkj12kj’ , ‘3212423sdf’ , ‘1212121′ ) select @str_CustomerID= scope_identity() After execution it returns null in my parameter. I want to ...