sql-server-2008

SQL Server 2008: How to Copy Data from Table in DB1 to Table in DB2?

I have two identical databases on the same server. During a deployment process, I have data in tables in database A that need copied over to the tables in database B. What is the easiest way to programmatically accomplish this task? EDIT: Tables do have identity columns. There are tables with foreign key constraints, so insert order i...

ms-access: how to do a proper requery?

i am distributing ms-access-2007 front ends. the back end is sql server. a user will click on a button and it will return a query from the sql server 2008 database. is it possible to requery this query if the user clicks the button again? usually the behavior of access is that if you query it again, it displays old results. how do i m...

Entity Framework: Alternate solution to using non primary unique keys in an association

I know the entity frame work does not allow you to generate a model from a database using non primary unique keys as a Foreign Key association. Can I modify the EDMX manually? If so, can someone provide me an example or reference? If not, are there any other possibilities? Easiest Example: Here is the DDL for the tables. You will no...

How to replace common words in sql column

I have a table of common words that are used in sentences (i.e. A, the, and, where, etc...) What I want to do is loop through all those words and strip them out of the descriptions that people have entered to attempt to generate common keywords or tags. But I can't use replace because replace will remove any instance of the common word ...

Using DateTimeOffset as WHERE criteria in a SQL Server 2008 query

Hi Everyone, I was wondering if anyone could help me understand why these two criteria do not return the same result sets. To me, it seems weird that SQL Server 2008 R2 wouldn't know to use the offset while constraining the data. Is there a better way to do this? As far as I can tell, Criteria Two is the only way to get the correct data...

Skip rows in query based on data

I have data as follow DECLARE @tmp TABLE(cid int, colspan int, rowspan int, corder int) INSERT INTO @tmp SELECT 1,2,null,1 UNION SELECT 2,null,null,2 UNION SELECT 3,null,null,3 UNION SELECT 4,3,null,4 UNION SELECT 5,null,null,5 UNION SELECT 6,null,null,6 UNION SELECT 7,null,null,7 I want to query to return cid colspan rowspan cor...

SQLServer 2008: Showing the Information with Money DataType in Classic ASP

Hi All, I am using MS SQL 2008 to develop one system with Classic ASP. I want to show 3 Decimal Places the field Datatype is money. I got answer from this http://www.sqlusa.com/bestpractices2005/moneyformat/ . I use like this in my SQL Statement : CONVERT(VARCHAR, CAST(Sell_Price AS Decimal(19, 3))) AS Unit_Price What I w...

CTE and Hierarchical XML Result

Hei, I've a simple CTE that result with hierarchical list of items (Parent/Child relation). How can I convert it to XML with the "FOR XML" sql syntax while preserving the hierarchical structure? Thanks, Espen ...

Fastest way to fetch a subset (200M) from a very large table (600M) in SQL Server

Hi, we are facing the following problem and we are trying to come up with the best possible solution. We are using SQL Server 2008. We have a table that has more than 600 millions records, and has about 25 columns. One of the columns is an ID and is indexed. We need to get a subset of records from this table. There are mainly 2 cases: ...

Store and read HTML in database with ASP.NET MVC?

I want to allow HTML in a comment box (eventually use tinymce or something like that), store it in an MSSQL database, and then read it back to a page where the field is rendered in a tabl cell. It all works fine with the storing of the HTML after I fixed the validation problem on the action method. But when read back from the database, ...

Adding an INDEX to a CTE

Should be a pretty straight forward question. Can I add an INDEX to a Common Table Expression (CTE)? ...

SQL: How to convert values to lower case and append an s?

I'd like to do this but I know this isn't the right syntax: INSERT INTO TBL1 SELECT Col1.ToLower + 's' FROM TBL2 ...

SQL Query to delete records occuring within 3000 milliseconds of each other

I have a table of data recording certain user events. The results looks something like: ID Username EventDate 1 UserA 2010-10-21 16:59:59.367 2 UserA 2010-10-21 17:00:00.114 3 UserA 2010-10-21 17:00:00.003 4 UserA 2010-10-21 17:00:02.867 5 UserB 2010-10-21 18:43:26.538 6 UserB 2010-10-21...

SQL Server 2008: why do I see only system tables when I login ODBC from ACCESS

I am using Access to try to get some links to tables in SQL Server 2008. I've created a user name under security in SSMS for SQL Server and I've mapped it to a user that is under the database that I need. I've also given that user a default database that I need. When I try to connect through ODBC I am not seeing the correct tables. Wha...

SQL Server combining data question

Hey all I am trying to combine my data into one sum. This is my output right now: Amount --------- $258.0 $400.0 $1011.0 $628.0 $628.0 $340.0 $340.0 $1764.0 of course the total would be $5369. This is the type of output I need Description | Quantity | Price | Amount -------------------------------------------- Fees 8 ...

SQL Server 2008: how do I grant privileges to a username?

I need to be able to establish an ODBC connection through SQL Server authentication. In SSMS how do I grant permission for a user to be able to have ALL RIGHTS on a specific database? is there a way to do this graphically with SSMS? ...

SQL Server 2008: ODBC connection problems

I am able to successfully connect from access 2007 into SQL Server 2008 using ODBC; however it prompts me with the password each time. When I try to open the linked table from access it says connection filed: SQLSTATE '28000' SQL SERVER ERROR 18452 [microsoft][odbc.........[][]] login failed. the loin is frmo an untrusted domain and can...

SQL Server 2008: should I be using Windows auth or SQL Server auth?

I have an MS-Access 2007 front end. I will have multiple users on it. They are all going to be on the network company domain. Should I be using Windows authentication or SQL Server authentication to be connecting to SQL Server 2008 via ODBC? ...

i started this replication wizard it adds GUID FIELD, how should i add data to this manually in future?

using replication in sql srv causes the addition of this guid field, it also adds a value to it but when i insert new records to the db, i have to give somthing or the guid field it should be like aaaaa-aaa-something and unique!! this is a problem for me , how am i supposed to do this keeping it unique every time? should sql srv aut...

what method is the most used and efficient to copy "database schema" to other servers not the db!

servers all sql server 2008, and win xp i have the following task create a huge database, DONE distribute it to the 20 waiting servers!! if there were two or three i would have taken the trouble of creating the db's on all of using sql server managemnt stdio but i am guessing that there is an efficient way please note, only the co...