sql

Can I remove the "not for replication" option from an existing check constraint in T-SQL?

Suppose a check constraint (involving multiple columns) with the "not for replication" option was added to a database table (e.g. "alter table table_name add constraint constraint_name check not for replication (constraint_expression)") I found syntax for dropping "not for replication" from a column, but not for an existing check constr...

Connecting to SQL server from Virtual PC

I have VS 2008 and SQL Server 2005 Developer edition installed on my desktop. I have a instance of XP running in Virtual PC and want to connect to the dev instance. I am logged on as a domain user on both the desktop and the Virtual instance of XP. When I try to connect I get a message saying "Server does not exist or access denied". ...

Getting Primary Key Records Which Is Not Associate With Any Foreign Key

I have the following two tables, affiliates and referrers. affiliates Table id loginid 3 CR0007 2 CR5604 4 VRTC0008 referrers Table id affiliates_id loginid 3 2 MLT29710 4 3 MX0001 If I want to know, an affiliate is associated with whom referrer(s), I can simply us...

Select from multiple tables in DBIx::Class

I have the following DBIx::Class code : my $where = 'me.loginid = ? AND me.code = ?'; my @bind = ( $loginID, $code ); my $tip_signals = $bom_schema->resultset('Table1')->search_literal( $where, @bind, { join => 'table2', group_by => [ 'me.id' ], '+select' => [ {'count' => '*'}, 'table2.id' ], '+a...

SQL strict enforce of order by a date column

I have a table(say TableA) with the following schema A(int) B(int) D (varchar) C(date) If I write the query select A, C from TableA where A >=0 order by A asc, B asc, D asc, C asc. The last row of the query will have the C date column which is largest ( I mean here the latest which is greater than all the other dates). I...

SQL function question

Hi, having trouble coming up with search parameters for this issue, so I can't find an answer on my own. Column X | Message (info 1) | Message (info 2) (info 1) | Above is the contents of one column I need to handle. The result of the query should be the part INSIDE the parentheses only. Problem is,...

Sql datasource wizard problem

hi guys i have an error with sqldatasource. When i click sqldatasource's updatequery property visual studio give an error: Microsoft Visual Studio Could not load file or assembly 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\%DXROOT%\ProductionTools\BuildComponents.dll' or one of its dependencies. The system cannot find ...

Why do no databases fully support ANSI or ISO SQL standards?

If I were designing a oil refinery, I wouldn't expect that materials from different vendors would not comply with published standards in subtle yet important ways. Pipework, valves and other components from one supplier would come with flanges and wall thicknesses to ANSI standards, as would the same parts from any other supplier. Inte...

Using table just after creating it: object does not exist

I have a script in T-SQL that goes like this: create table TableName (...) SET IDENTITY INSERT TableName ON And on second line I get error: Cannot find the object "TableName" because it does not exist or you do not have permissions. I execute it from Management Studio 2005. When I put "GO" between these two lines, it's working. But ...

Selecting date intervals, doing it fast, and always returning the latest entry with the result.

I have a database with a table, storing changes in account-balance across a couple of accounts, with three columns; float balance, #The account balance after the change Date date, #Date that balance change occurred int aid #Account that the balance change occurred on It contains a couple of entries for each day of the...

Function for week of the month in mysql

I was looking for a simple function to get the week of the month (rather than the easy week of the year) in a mysql query. The best I could come up with was: WEEK(dateField) - WEEK(DATE_SUB(dateField, INTERVAL DAYOFMONTH(dateField)-1 DAY)) + 1 I'd love to know if I'm reinventing the wheel here, and if there is an easier and cleaner s...

multiple like on same column DB2

I am trying to query something like select emp_id from dept.employee where firstname like '%sam%' or firstname like '%SAM%' or firstname like '%will%' or firstname like '%WILL%' Is it possible to put it in regex something like select emp_id from dept.employee where firstname like '%sam|SAM|will|WILL%' or select emp_id ...

Does the order of tables referenced in the ON clause of the JOIN matter?

Does it matter which way I order the criteria in the ON clause for a JOIN? select a.Name, b.Status from a inner join b on a.StatusID = b.ID versus select a.Name, b.Status from a inner join b on b.ID = a.StatusID Is there any impact on performance? What if I had multiple criteria? Is one order more maintainable than another? ...

When trying to run an SQL query in delphi using a button click nothing happens!!

Hello, I am trying to run SQL queries using a button click in Delphi, the database is successfully connected everything compiles fine when i enter the query i.e. "Select * from StaffDetails" and then click on run expecting it to show me the results in the DBGrid nothing happens at all the code for the button is as follows procedu...

Select N rows from a table with a non-unique foreign key

I have asked a similar question before and while the answers I got were spectacular I might need to clearify. Just like This question I want to return N number of rows depending on a value in a column. My example will be I have a blog where I want to show my posts along with a preview of the comments. The last three comments to be exa...

Select from a DB2 table and insert to a SQL table

I feel like this might be a crazy question, and if anyone has a better idea of how to do it, by all means please let me know. I have a .Net C# project at work that validates certain tables against the company standards they must adhere to. The tables can be on SQL Server or DB2. When a table is initially added to the program, I gathe...

SQL and ADO.net: Too many arguments specified with output param

ALTER PROCEDURE dbo.uspGetOrderTrackingHeaderInfo @ContractID varchar(9) , @SalesRepID int , @StatusID int , @TypeID int , @StartDate datetime , @EndDate datetime , @Identity int = null output AS INSERT INTO [dbo].[tblOrderTracking] ([ContractID] ,[StatusID] ,[TypeID] ,[SalesRepID] ...

Is there an ORM (Object Relational Mapper) framework that supports C++ and C#

I'm looking for an ORM that will allow me to write a C# user interface and a C++ service. Both need to access data from the same database. Ideally I want C# and C++ classes to be generated from the database schema that I can then program against. The database will probably be SQLServer, but that hasn't been decided yet. Note: I'm doing...

How to calculate VAT in SQL query?

How do you write a SQL query to calculate the VAT and then add it to Total? Thank You ...

Is it possible to add languages/locales to SQL Server 2005?

The contents of sys.syslanguages lists several languages/locales, however is it possible to add languages? For example, I'd like to add Australian English and Canadian French. Any help is appreciated! ...