sql-server

Who should be an owner of the new schema?

I am creating a new schema in SQLServer 2008. Should I create a new user with the same name as schema owner? Should I use 'dbo' user as schema owner? ...

Finding matches in multiple columns in different orders

Hello, I am trying to merge 2 databases with the same schema together, and this is one part of it. I have changed the subject to keep it more understandable - I cannot change this schema, it's just what I'm working with. I have a table in both my source and target databases with the following columns: Car CarType1 CarType2 CarType3 C...

SQL Server database max row RowVersion

Does anyone know if there is a way I can get a database's max RowVersion value? The database I am using is SQL Server 2008. Thanks. ...

SQL case in select query.

I have following query Select a,b,c, case totalcount when 0 then 0 else abcd/totalcount end AS 'd', case totalcount when 0 then 0 else defg/totalcount end AS 'e' From Table1 In this query, I have same case statement in select query...C...

How to create sequential number column index on table with data

Hi I have the following table with 10 unique rows, BookingID is a FK containing a random number. The number doesn't need to be in sequence. BookingID, Description 1000 Foo 3000 Bar 1500 Zoo I need to insert an sequential index called ID which goes from 1..x how do I do that in SQL Server 2005? I was thinking to wri...

Where is the Query Analyzer in SQL Server Management Studio 2008 R2?

I have some SQL thats getting run and it is taking to long to return the results / parse / display, etc. in a asp.net c# application. I have SQL Server Management Studio 2008 R2 installed to connect to a remote SQL Server 2000 machine. Is there a Query Analyzer or profiler I can use to see whats going on? I'm not sure if I'm sending too...

List/Menu Searching

Firstly I'm really newbie in programming and now I want to develop system using asp but I got problem to create searching. What I want is searching by date. When user select Feb (start) - Nov(end) then report will display below. engine -use dreamweaver database - SQL Server SQL for column select from column month and column year Real...

'Where in' T-SQL implementation

Hi guys, I have a stored procedure that take many input parameters including an @userID. Now, in the core of the SP I select from a view using the following Where close : Where userID = @userID This works fine. Now I want to pass multiple users to be able wo query it like this : where userID in (1,2,...) How can I pass the value ...

sql server remove trailing zeros in decimal

Is there an easy way to strip trailing zeros from decimals so that select amount from table gives you 2.5 instead of 2.50 or 3 instead of 3.00? Thanks, Tom ...

PL/SQL Vs T-SQL and Database Jobs

So Im really wanting to do Database working as a job when I graduate. I've Gotten Books/CD's. Video Tutorials/Learning (Nuggets) and everything. I've had prior experience with MySQL for a Databases class and I absolutely LOVED it. Anyways I know there are 2 types, Database Admins and Database Devs. I assume the Admins manage them where...

What is the best way to make autocomplete field using jquery (With mySql or XML ?)

My autocomplete field: http://www.faressoft.org/autocomplete/ What is the best way to make autocomplete field using jquery (With mySql or XML ?) and what is the reason ? How to minimize consumption of server resources ? What is the best way if i have a big database or a small batadase ? mySql or XML ...

Using t-sql to select a dataset with duplicate values removed

I have a set of tables in SQL Server 2005 which contain timeseries data. There is hence a datetime field and a set of values. CREATE TABLE [dbo].[raw_data]( [Time] [datetime] NULL, [field1] [float] NULL, [field2] [float] NULL, [field3] [float] NULL ) The datetime field is unfortunately not a unique key, and there appea...

ms sql call stored procedure with date time parameter

how do one call a stored procedure that has date input . spName getDate() does not work. the question is about calling within ms sql managment studio. ...

SQL Server stored procedure and Linq-to-SQL

I'm working on a project right now where we have to implement all communications to the database via stored procedures. We are using Linq-to-SQL, so all the database entities are in place. My question is how you could write a stored procedure that returns an entity, if this is possible. Example, we validate a user when he's logging in w...

Multi-part identifier could not be bound

I know that there are several questions around this exception on SO, but nothing seen that helps me. I have following query giving me a "Multi-part identifier 'claim.fiData' could not be bound"-Exception: SELECT claim.idData FROM tabData as claim INNER JOIN dbo._previousClaimsByFiData(claim.fiData) AS prevClaim ON prevClaim.idData...

How to create materialized views in SQL Server ?

I am going to design a DW and I heard about materialized views. Actually I want to create a view and it should update automatically when base tables are changed. Can anyone explain with an query example.. ...

SQL server filtered indexes

Hi, I have a table that is quite modest in size at the moment but will grow to a few million rows so I’m looking to build things right from the start. The table contains 15 or so column containing information for agent telephony performance but that is not really relevant. One of the queries that is run on this table looks at data from...

What generated this database accessor code?

I'm trying to make alterations to an existing project, and I've found a project in the solution which is full of generated classes. Problem is, nobody here can tell me what generated them, so I'm pretty much left with pasting one of the classes in here and hoping someone will be able to tell me where they came from. The solution I'm w...

SQL - ordering a common table expression

Using this sample table: drop table Population CREATE TABLE [dbo].[Population]( [PersonId] [int] NOT NULL, [Name] [varchar](50) NOT NULL, [MotherId] [int] NULL, [FatherId] [int] NULL ) ON [PRIMARY] insert Population (PersonId, [Name], MotherId, FatherId) values (1, 'Baby', 2, 3) insert Population (PersonId, [Name], Mothe...

How to do a fast DELETE of lots of data from a large table (sql server)

I want to delete about 90% of rows from a million+ row table. Anything I can do to make this faster? e.g. if I turn on Simple Recovery Mode will this help? ...