sql-server

SQL Query Time Coverage

I don´t now if this is the right place for such a question, but I´ll try it :) I have got several sql db entries which represents time periods E.G. Datefrom datetill 2010-10-01 2011-01-01 2011-02-01 2011-05-16 2011-08-08 2011-09-01 I need to test if a given time period ist fully covered from the entries. Is th...

database question

Hi, I have written a cursor like bellow : declare myCursor cursor for select productID, productName from products declare @productID int declare @productName nvarchar(50) open myCursor fetch next from myCursor into @productID,@productName print @productID print @productName set @productID=0 set @productName='' while @@FETCH_STATUS=0...

User management in MSSQL

Hello, I'm trying to set up security for my application for users. I am not sure about my logic. Is the following possible: I want to create 1 login for 'all users' in Active Directory. Then I want an admin (in the program self) to choose which user is in which server role (e.g. marketing, sales, ...). Then I want to give those roles p...

Using Mysql and sql server from python

I need to write a python application with use both of the mysql and sql server is there a general python module or library that can access both mysql and sql server as DBI with perl or should i use 2 libraries and if yes which libraries do you recommend . ...

Using LIKE in sp_executesql

Hi, SET @whereCond = @whereCond + ' AND name LIKE ''%'' + @name + ''%''' Is there something wrong here? After I generate where condition, I execute it with sp_executesql, but I did get anything. When I SELECT the same thing without sp, it's ok. How to use LIKE in sp_executesql? Can you bring some examples, please? Thank you. UPDA...

Return parent records with child records equaling specific values AND where total set of child records for a given parent equal a specific value

Currently I have a query that returns parent data for parent records that have a subset of child table records equaling certain values. However, I want to narrow it to only return those parent records with children having certain values, but where those are the only child records belonging to given parent or where the number of child re...

SQLServer Transaction Isolation Analogy

Does anyone have a good analogy of SQLServer transaction isolation levels? (SQL2005 upward) ...

SQL Server get unique rows or row with largest field value

Hi, I have a table in SQL Server 2005, as follows, say, fields A, B, C, D If I have the following data: A B C D 1 B1 C1 D1 - 2 B1 C1 D1 - 3 B2 C2 D2 - 4 B2 C2 D2 - 5 B2 C2 D2 - 6 B3 C3 D3 - I want to be able to pick out the rows which are either unique (on B, C...

SQL Server data modification while importing

In mySql, I have a Float field equals to 4.85 When importing into SQL Server 2008 in a Float field i get, 4,84999990463257 Someone has an idea why ? Thanks Jon ...

How do I tune a query

I have a query that is running slowly. I know generally to make performance faster, limit joins, and try to use procs instead of straight queries. Due to business rules, I cannot use procs. I've already cut the number of joins as much as I can think of. What's the next step in query tuning? ...

Stored procedure: pass XML as an argument and INSERT (key/value pairs)

How would you construct and pass XML as an argument to a stored procedure on an MS SQL 2005 server? And how would you INSERT the XML into a table? The data is in the form of key/value pairs: [ 0: [key, value], 1: [key, value], 2: [key, value] ] ...

NHibernate/SQL Server multiple foreign keys to same table... Possible?

Hi, I have a SalesOrder table and a separate Address table. The SalesOrder has two addresses - thus avoiding use of a list, there are the Delivery and Invoice address. This is how they have been mapped in the SalesOrder mapping file: <many-to-one name="DeliveryAddress" class="Address" column="`DeliveryAddressGUID`" /> <many-to-one na...

Fee Reminder Database

Hi, I am designing a small website where user register and pay there monthly fee, I want to send them a AUTO-reminder email 5 days before there membership expire. How should I design the database, right now I have 2 table MemberDetails PaymentDetails in PaymentDetails Table I am keep a record of all the payment he/she have made, i...

Where does SSMS save user created templates?

Does SSMS save these to a file location or are they managed internally thru SSMS? If there is a location where is it? ...

bulk-select into a varbinary

I have an application which needs to create a snapshot of record identifiers which can be persisted in the database server. I currently have a table that looks like this: CREATE TABLE Workset ( Workset_id int, Sequence int, Record_id int ) which I insert into using something like: INSERT INTO WorkSet (Workset_id, Sequence, Rec...

Should programmers use SSIS, and if so, why?

As a .NET developer, for what reasons should I prefer SSIS packages over writing code? We have a ton of packages in production where I currently work, and they're a nightmare to both "write" (perhaps draw?) and maintain. Each package looks like a bowl of multicolored spaghetti with C# and VB.NET scripts mixed in at the points where the a...

Unable to load driver 'ODBC'

Trying to load ODBC in my Rails app (I'm on Linux, FreeBSD 7.3-STABLE using rb-odbc, unixODBC, and FreeTDS to connect to MSSql) but I'm getting this error: Trace can be found here: http://gist.github.com/547759 Anyone have any glaring ideas? Thanks! ...

Does it matter where I check part of a composite key when joining two tables in SQL Server?

I'm joining two tables on a composite key, and I'm wondering if it matters where I compare the corresponding columns when I do the join. Say I have a table, TableA, with columns ColAFoo, ColAFoo2, and ColABar. TableA has a composite primary key comprising ColAFoo and ColAFoo2 (PK_TableA). I also have TableB, with ColBFoo, ColBFoo2, an...

Counting groups of data in SQL

I have a table of about 1.6M rows where the records have a unique (identity) ID and then also have a 8-character "code" field. The code field it used to group data into sets...all rows with the same code are in the same set. Each set should consist of 12 records, but it seems our data load was off and some sets are incomplete. I need ...

MS SQL Server 2005: What Happens If LDF-file are lost ?

If I put my MS SQL Log file on another drive and the drive crashes. What happens to my MS SQL Database, will it create a new log file or how do I correct it? ...