sql-server

TSQL - do query on result set from a stored procedure

Say if using sp_helplognis, want to view result set with filter UserName=db_owner. Is there any way besides output the original result set to a temp table and then query on that temp table? Thanks. ...

SQL Server select-where statement issue

Hello everyone, I am using SQL Server 2008 Enterprise on Windows Server 2008 Enterprise. I have a question about tsql in SQL Server 2008. For select-where statement, there are two differnet forms, (1) select where foo between [some value] and [some other value], (2) select where foo >= [some value] and foo <= [some other value]? I am ...

SQL Server: retrieving data type length

Hello, I am writing a basic DBMS package and I am trying to retrieve the column length. This is the query I am using to retrieve the infomation: SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'testVariables' This works fine, no issues except for CHARACTER_MAXIMUM_LENGTH...

ANALYSIS SERVICES in SQL Server 2005

Dear Friend, I want to retrive the Current running value of the Following Analysis Service using SQL Query. Ad Hoc data mining Anonymous connection Linked Objects User Defined Functions Please help me Thank You. ...

Attach: Cannot add an entity with a key that is already in use

I found a bunch of possible duplicates around this but none really seemed to be having the same problem I'm having. I'm getting a DuplicateKeyException: Cannot add an entity with a key that is already in use. Here's my SqlProductsRepository: public class SqlProductsRepository : IProductsRepository { private Table<Product> productsT...

SQL migration tool

I want to write a SQL migration tool. This tool must: merge new scripts in a folder, validate the merging of those scripts, run those scripts against a database. if a validation error occurred, then highlight the invalid rows. if the script was successful deployed, I want to save this information in a database with the version and ot...

Entity Framework v4: Preventing Storage Model Overwrites by Update Model Wizard

In my Entity Framework v4 project, I have a table with two columns that are computed by the database (via triggers, etc.). In order to get EF to properly insert records into the table, I have to manually mark the columns as "Computed" in the EF Storage Model (the StoreGeneratedPattern attribute), which is not supported by the designer -...

How do I remove duplicate results from my sql query

Thank you so much for helping! Ok, the portion of my query producing duplicate results is: Left Join CMS_ECH.dbo.hsplit hsplit on hsplit.row_date = ANDREWSTABLE.SegStart_Date and hsplit.split = ANDREWSTABLE.dispsplit and hsplit.starttime = ANDREWSTABLE.Interval ...

SQL LIKE with special characters

If I try to create a select with special (nordic) characters like: Select * from users where name like '%æ%' It just selects all users instead of those containing the letter 'æ'. Do I need to install some special drivers to the database, or is there something else I have missed? Update: I am using a SQL Server 2008 database, the col...

How to select top x from with params?

I'm using Sql-Server 2005 I have Users table with userID and gender. I want to select top 1000 males(0) and top 1000 females(1) order by userID desc. If i create union only one result set is ordered by userID desc. What other way to do that? SELECT top 1000 * FROM Users where gender=0 union SELECT top 1000 * FROM Users where gender=1 ...

What data can be stored in varbinary data type of sql server?

I have a table in which the userpassword field have varbinary datatype, So im confused that in which form should i save the data into userpassword field because when i save varchar data it gave me error. ...

Recommended approach how to modify schema of a production SQL database?

Say there is a database with 100+ tables and a major feature is added, which requires 20 of existing tables to be modified and 30 more added. The changes were done over a long time (6 months) by multiple developers on the development database. Let's assume the changes do not make any existing production data invalid (e.g. there are defau...

Code to validate SQL Scripts

How i can validate sql scripts before executing using .net2 and c#. If sql is not valid i want to return error rows. ...

how should I ensure that mytable is efficient

I am desiging a new table that will potentially have 200K rows. I would like to make sure that querys to this table are efficiant. in the past I had always given a row a unique id in the assumption that this would result in an index: CREATE TABLE [dbo].[Equipment]( [EquipID] [nchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, ...

SQL Server 2005: Select statement in ISNULL condition

Environment: SQL Server 2005 I have a stored proc which receives comma separated value in one parameter. I have written a Table Valued UDF function in SQL to break it and and return me it as a table. I am using that value to filter the data in the where clause of the stored proc. Everything works fine until there is NULL in that comma s...

SQL Server - lack of NATURAL JOIN / x JOIN y USING(field)

I've just been reading up on NATURAL JOIN / USING - SQL92 features which are (sadly?) missing from SQL Server's current repertoire. Has anyone come from a DBMS that supported these to SQL Server (or another non-supporting DBMS) - were they as useful as they sound, or a can of worms (which also sounds possible!)? ...

How can I convert a OLE Automation Date value to a date in SQL Server

My application stores dates as OLE Automation doubles with the DateTime.ToOADate() command. Now, I need to create a SQL view wich shows me the Date stored. How can I quickly convert the double to a date? Thanks ...

ASP.NET Website Administration Tool: Unable to connect to SQL Server database

I am trying to get authentication and authorization working with my ASP MVC project. I've run the aspnet_regsql.exe tool without any problem and see the aspnetdb database on my server (using the Management Studio tool). my connection string in my web.config is: <connectionStrings> <add name="ApplicationServices" connectionStri...

Call aspnet_regsql.exe from SQL script

Hello, how to call aspnet_regsql.exe from an SQL script? thanks ...

Title: Multipart identifier s.Company_id could not be bound

I am getting the following error while executing the query . Please help Multipart identifier s.Company_id could not be bound INSERT INTO Company_Item_Company_List ( Company_id, Company_item_id, client_id, last_modified_timestamp, last_modified_user_id ) SELECT dcsl.distribution_center_id, sisl.Compan...