sql

Sql date field is not getting saved exactly

Hi, I am trying to insert a date value '2010-03-14 02:00:00 AM'(Day light saving start time for 2010 year) in a datetime field of a table in sql server 2005. The date is saved as '2010-03-14 03:00:00 AM' The server is installed in US(EST time zone). Can anyone tell me the reason why the date is saving differently? Thanks Rupa ...

Creating reports in Access after the DB is completed

Hi, I have a fully functional DB developed in Access. It was done using a very "interactive" developer-client increment-iterative process as no one really knows what the final DB is to show. All tables were developed (and normalized) as well as forms (and sub-forms), however, now reports must be designed and implemented. The forms of c...

LinQ to SQL : InvalidOperationException in a Windows Service

Hi all, I have implemented a small Windows Service which runs every 9 minutes and writes the data which comes througth a webservice to the db. Do do the db work I use Linq To SQL using (var db = new DataClasses1DataContext()) { var currentWeather = this.GetWeatherData(); //////TODO Add the ...

Limit rows returned using TableAdapter (typed DataSets)

Does anyone know the best way to limit the number of rows returned when using typed TableAdapters? Options appear to be: Pass "top X" as a parameter (can't do this until we're on SQLS2008 Issue a dynamic SQL statement: set rowcount X before calling my tableadapter method, then set rowcount 0 aftwards. Something else I haven't thought ...

sql / linq to entities: group on group of hours

Hi, i have a table with snow data which i get delivered per hour. so for instance at between 0am and 1 am 1 cm snow will fall, between 1 am and 2 am 3 cm snow will fall, between 2 am and 3 am 0 cm snow will fall, between 3 am and 4 am 2 cm snow will fall etc. so the table has a Snowdate column (datetime), a Snowdate hour column (int) an...

Multiple max values in a query

I know the title does not sound very descriptive, but it is the best I could think of: I have this table ID BDATE VALUE 28911 14/4/2009 44820 28911 17/4/2009 32240 28911 20/4/2009 30550 28911 22/4/2009 4422587,5 28911 23/4/2009 4441659 28911 24/4/2009 7749594,67 38537 17/4/2009 58280 38537 20/4/2009 137240 385...

How to save an image from SQL Server to a file using SQL

Question In SQL Server 2005, I have a table with images (data type: image). Using only SQL, how do I save an image as a file (on the same server that SQL Server is running). If I have to, I'll use SQL CLR, but I want to avoid that if possible. Background I want a SQL Server job to run no a schedule that calls a proc that will send ema...

SQL query for retrieving connecting trains

Hi. I have a database containing a lot of train times, for a lot of different trains. It looks something like this: Table1 Station_id Station_name etc Table2 StationName Arrival Departure TrainNumber etc I know how to retrieve the time of departure for a given train, but how would i proceed if I wanted to retrieve a travel plan con...

[Java] Find a Database table's unique constraint

Hi, I'm trying to find the unique constraints of a table using Java (on an Oracle Database, but that should make no difference). I found a way to discover the Primary Keys of a table, thanks to DatabaseMetaData's getPrimaryKeys(....); However I was unable to find the unique constaints of the tables, and the Internet was not able to he...

SQLServer 2008 generic column type

Hi, I've a table on SqlServer where a column type should be undefined, I mean, it should be able to contain any kind of type (string, int, boolean and datetime). This because my users should be able to define which type the column is for each record. In the past when I encountered this problem I decided to create it as nvachar(MAX). Wh...

MySQL Query is far too complicated

Hi there, I've got a query that I've made but I've got a problem with - Is this the 'neatest' way of writing this? I'm this could be written a lot better, I've heard you can 'loop through recordset' using more queries - would this be a good thing to do? And if so can someone point me in the right direction? This query must use up a lot ...

How to join 2 tables based on a like in mysql

I have 2 tables Employee and Company_Employee. Employee: ID, FirstName Company_Employee: ID, Company_ID, Employee_ID I want to do a search by First Name. I was thinking my query would look like: select FirstName, ID from Employee where FirstName LIKE '%John%' and ID in (select id from Company_Employee) This query returns no ro...

t-sql table join

Is there any way I can do a join between two tables where the resulting table has only the columns of the left table without the need to discriminate all the columns names in the select? ...

How can i see what IP address made the request to SQL Server?

Hello, i need to clearly see what IP address made what sql query to SQL server. I am trying to use SQL Profiler, but it seems there is no way i can somehow to differentiate the machine (browser) where the query came from. It only has the communication details between the web server and the sql server. Is there ANY way for me (any unknow...

Tool for Merging Database Scripts

Hey all, I'm wondering if anyone has ever used a tool which will take a series of .sql scripts and a manifest file of some sort and merge them into one big .sql file according to the order defined in the manifest? I'm trying to integrate database change packaging into our automated build and I could write a tool for this but I figured ...

Lots of queries to pull up user photos and their comments. (CakePHP)

What I'm trying to do is pull up profile info w/ the profile's comments. I get everything as expected. No error returned, array is formatted perfectly. My concern is the queries that are run. It runs one query for each ID to get its photo (the start of the query is noted in comments in the code below). I guess this is the only way to get...

Convert SQLite DB files to "LINQ to SQL" like SQLMetal.exe

How do I convert SQLite DB files to LINQ ORM files? Is there any utility like SQLMetal.exe? ...

How to run a stored procedure every day in SQL Server Express Edition?

How is it possible to run a stored procedure at a particular time every day in SQL Server Express Edition? Notes: This is needed to truncate an audit table An alternative would be to modify the insert query but this is probably less efficient SQL Server Express Edition does not have the SQL Server Agent Related Questions: How can ...

What is going on inside when I run left join?

I have a question regarding left join on SQL: I would like to know how SQL servers perform left join? Let's say I have two tables. PEOPLE id name PHONE id person_id phone When I execute: select name, phone from people left join phone on people.id = phone.person_id ...I would like to know how SQL servers process the...

How to run a stored procedure when SQL Server Express Edition starts?

How is it possible to run a stored procedure when SQL Server Express Edition starts? ...