sql-server

SQL Stored Procedure execution time mystery

I'm trying to figure out why a SQL Server stored procedure is executing slowly, so I've put in some crude timers, like this: Create Procedure DoStuff As Begin Declare @Stopwatch datetime Set @Stopwatch=GetDate() Print char(13) + 'Task A' /* Perform Task A */ Print DateDiff(ms, @Stopwatch, GetDate()); Set @Stopwatc...

The case of the Missing-Index-Not!

I ran the code found here: SQLServerPedia Find Missing Indexes (sic) and it reported an index missing (one column in the equality column, none in the inequality column, and none in the included column). However, this index already exists! I've updated stats on the index, on the table, dropped and recreated the index in question, run sp_...

problem creating a simple relationship in SQL Server 2005

I am using the database diagram to simply drag one column in a table to another to associate them and then trying to save it. i have done this a million times in the past with no problems. Both of the data types are the same, uniqueidentifier. Here is the error I get: 'Customer ' table saved successfully 'CustomerOrder ' table ...

How to update a database remotely?

Hi, all. I'm looking for a strategy to allow automatic updates for a number of databases at customer sites through a publish-subscribe kind of mechanism. Right now there is a datacenter which has all the master data that get fed through extractions from hundreds of databases out there. The problem is that, whenever I need to do create a...

SQL 2008 Full Text Search Catalog on multiple tables

I am attempting to setup a full text search catalog in SQL Server 2008 is there a way to make this catalog contain data from multiple tables? ...

SQL Server 2008 Schema Naming Conventions

I'm creating a brand new database with no legacy constraints, so I'm curious as to what the schema best practices are. The database will be called "SecurityData". It stores information about bonds. The schema I have already identified are: import - Views and procs that are really linked server calls to other databases export - Views ...

SQL Server-- join tables and SUM columns for each distinct row

Hi all, Could someone double check my SQL statement for proper operation and general commonsense approach? Here's what's going on: I have a parent and child table with a one-to-many relationship, joined on a column named AccountNumberKey. The child table has numeric columns in it I need to sum up. The data is such that all child r...

VS for Database Developers: Lookup Tables

How to you handle the contents of lookup tables that should be treated as "code" rather than data? ...

How to delete a "tree" of data from sql?

I have a table structure similar to: Portfolios Properties Units Leases All tables are setup with foreign key relationships and cascade deletes. I want to be able to delete a portfolio, which would in turn delete all properties assigned to that portfolio, all units assigned to those properties, and all leases assigned to tho...

Loading Multiple Tables using SSIS keeping foreign key relationships

I am trying to load data from a single file (with million+ records) into multiple tables on SQL Server using SSIS while maintaining the relationships defined in the file. To better elaborate with an example, lets assume I am trying to load a file containing employee name, the offices they have occupied in the past and their Job title h...

group / sum data based on period of time in SQL Server

I have a customers table and I want to get the growth broken down by different periods say day, week, or year. To simplify let's assume there are only 2 columns: CustomerID, CreatedOn Trying to grasp this concept so I can apply it to several reports I want to make. ...

SQL Group Select Query

Hi, I have the following table: ----------- ---------- ----------- | AccountID | Password | IpAddress | ----------- ---------- -----------| | 1 1234 127.0.0.1 | | 2 123 127.0.0.1 | | 3 1234 127.0.0.1 | | 4 12 127.0.0.2 | | 5 123 127.0.0.2 | | 6 ...

SQL Server JDBC Exception

When using ANT to build my Java application I keep getting this error. I have tried multiple times to use SQLJDBC.JAR and SQLJDBC4.JAR but continually receive this error message. I am completely stumpped why this error is received even after upgrading to sqljdbc4.jar. [javadoc] java.lang.UnsupportedOperationException: Java Runtime...

Wrong locale in SQL Query results

I have a SQL Server 2005 database set to locale Turkish_CI_AS. The locale setting of the pc of the SQL Server is set to Turkish. Turkish decimal separator is "," and thousands separator is ".". There is a field with datatype decimal(14, 3) and it has a record with value "400,123" (that's four hundred). When I use Open Table in SQL Manage...

How do you port a SqlServer database to MySQL?

I have a SqlServer db that I would like to port to MySQL. What's the best way to to this. Things that need to be ported are: - Tables (and data) - FileStream --> MySQL equivalent? - Stored Procedures - Functions ...

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_UserCars_aspnet_Users"

I am trying to insert data to UserCars table using ObjectDataSource Insert Method. the userId(FOREIGN KEY) I am trying to insert is GUID type. corresponding PRIMARY key is UserId(uniqeidentifier) in aspnet_users table which is part of Membrship shema the userId(guid) = JustCreateduser so it means it shoukd be the same vaues. however...

ASP.NET simple web site 'framework'

Hi, I'm a LOB .NET applications developer that would like to do some www consumer facing web site development for small business, along with internet marketing. Typically I need just a simple 5 page layout 'home', 'about us', 'contact', 'faq', etc... But with flexibility to expand onto it if needed. I guess my question is - are there a...

T-sql: how to perform optimised Paging?

Hi I wrote the following code, it works fine, but it takes like 3 sec to complete if the table is containing a million record. Is there a way to optimize the following code. DBCC DROPCLEANBUFFERS; DBCC FREEPROCCACHE; DECLARE @Page_Size int; DECLARE @Page_Number int; DECLARE @Lower_Bound int; DECLARE @Upper_Bound int; SET @Page_Size...

What is the PostgreSQL equivalent to ISNULL()

In MSSQL, I can do SELECT ISNULL(Field,'Empty') from Table But in PGSQL i get a syntax error. how do I emulate the ISNULL functionality ? ...

mysql equivalent data types

I'm coming from a sql server background, what would the equivalent data types be for in mysql: nvarchar (allows for any type text, so it supports funny characters for all languages etc) nvarchar(max) (allows for very long text documents) ...