sql-server

How do I rollback a transaction that has already been committed?

I am implementing an undo button for a lengthy operation on a web app. Since the undo will come in another request, I have to commit the operation. Is there a way to issue a hint on the transaction like "maybe rollback"? So after the transaction is committed, I could still rollback in another processes if needed. Otherwise the Undo fu...

Excel VBA to SQL Server without SSIS

Excel problem: User clicks a button and VBA parses an input file, putting data into cells in the spreadsheet. Then she mails copies of the spreadsheet to people who do work with the data. I am to replace this with SSRS or ASP or Sharepoint displaying the data from SQL Server. In order to work on this without interrupting the current ...

What impact does the Z Index number have in an RDLC file?

I have been creating rdlc reports from scratch using C# to write xml files. To make sure I do this properly I look at the XML behind other reports I created using the VS 2008 report designer feature. When I look at the XML for the reports created using VS, I see the field called ZIndex which as a integer value associated with it. What...

Keeping track of web application usage in an SQL Database (Need Suggestions)

I have a system that will allow users to send messages to thier clients. I want to limit the user to x amount of messages per day/week/month (depending on subscription). What is a good way to tally for the time period and reset the tally once the time period restarts? I would like to incorporate some sort of SQL job to reset the tally. ...

in sqlserver, need to select one of two columns, can a case statment do this?

My table: Users (userID, col1, col2) I want to make a generic stored procedure, but I need to return EITHER col1 or col2 in a query. Can I case statement handle this situation? SELECT userID, col1 FROM Users OR SELECT userID, col2 FROM Users ...

one sql parameter to give me 3 potential values

In my stored procedure I need a single parameter that will give me a potential of 3 values. So I can do something like: @p1 <-- my parameter IF (@p1 ???) -- include users SELECT * FROM USERS IF (@p1 ???) -- include employees SELECT * FROM employees IF (@p1 ???) -- iclude customers SELECT * FROM CUSTOMERS I am gues...

Subquery will sometimes need to union with another table, can I put an IF?

My query looks like: SELECT * FROM ( SELECT * FROM Server1 UNION SELECT * FROM Server2 ) Now, I have the options for the subquery: only server 1 only server 2 both server 1 and 2 I was thinking of having a parameter in my stored procedure that would perform a bitwise operation on the para...

what the difrent between primary..unique..foreign key, index

hi What is the difference between primary, unique and foreign key constraints, and indexes? I work on Oracle 10g and Sql Server 2008 thanks in advance ...

Is there an easy way to remove all default values for a SQL database?

I'd like to remove all default values that have been setup in a particular database, is there a script that I can run to do this for all tables in database? Could be a bit time consuming without ... any help would be appreciated! ...

installing VWD 2005 after VWD 2008 ?

Hello, I originally installed the Visual Studio 2008 SP1 Express editions. I also installed SQL Server 2005 Express as I had some 2005 databases. Later I needed to install both VWD 2005 Express and VB 2005 Express as well. Now when I am using VWD 2005 and try a to add a SQL Datatabase as a new item, I get the error: "this server is no...

Get data from table, Using Rows as Columns.

I have following data in my table. I want to extract ProductId which has this criteria, FieldValue = 1.0 and FieldValue = 'Y' and FieldValue = 'N' This is not possible using following query select * from MyTable WHERE (FieldId = 50 AND (FieldValue BETWEEN '1.0' AND '1.0')) AND (FieldId = 55 AND FieldValue = 'Y') AND (FieldId = ...

Attempt at database localization using table-valued functions

Hi ! I'm looking for opinions on the following localization technique: We start with 2 tables: tblProducts : ProductID, Name,Description,SomeAttribute tblProductsLocalization : ProductID,Language,Name,Description and a table-valued function: CREATE FUNCTION [dbo].[LocalizedProducts](@locale nvarchar(50)) RETURNS TABLE AS (SELECT a.P...

Odd Full Text Search Result

Hi I have 2 following 2 queries: SELECT FT_TBL.JobId, FT_TBL.Title, FT_TBL.[Description], FT_TBL.Location, KEY_TBL.RANK FROM Jobs AS FT_TBL INNER JOIN FREETEXTTABLE (Jobs, (Title, [Description], Location), 'asp.net software') AS KEY_TBL on FT_TBL.JobId = KEY_TBL.[KEY] WHERE CONTAINS (Location, '"luton*"') order by KEY_TB...

DbDataReader closing by itself?

I have the following code: var entityConnection = (System.Data.EntityClient.EntityConnection)c.Connection; DbConnection conn = entityConnection.StoreConnection; ConnectionState initialState = conn.State; List<Jobs> list = new List<Jobs>(); int id = 0; try { if (initialState ...

Updating row of table Using data from multiple columns of another table.

I have following table which I want to update using another table, given below. I want to update Null values of above given table using following table on the basis of ProductId. The updated table should be like this. I have mentioned ProductId in these table just for example. I don't know exact ProductId. It could be any ProductId....

TSQL: Any benefits for explicitly specifying NVARCHAR in a string?

When you add pass a new job_type to sys.sp_cdc_add_job @job_type, (which is of type nvarchar(20)) You can pass the argument as either N'cleanup' cleanup Are there any reasons or benefits to use the former syntax using N' to pass the argument to stored procedures? ...

SQL Server 2008 localization of tables

I need to localize a SQL Server 2008 database. After investigating recommendations, I have found that it is best to have separate tables or each of the languages for the strings. That way different sorting settings can be set for each table. For example, a typical Product table has ProdID, Product Description, and Price fields. The r...

SQL Server wide indexes with many include columns

Should I be careful adding too many include columns to a non-cluster index? I understand that this will prevent bookmark look-ups on fully covered queries, but the counter I assume is there's the additional cost of maintaining the index if the columns aren't static and the additional overall size of the index causing additional physic...

How to supress Solution1 save prompt in SQL Server Management Studio

Almost every time I close SQL Server Management Studio I get a prompt that asks if I want to save "Solution1". My understanding is that solution files are deprecated; in fact I've recently tried to use SQL solution files but decided against it because they are almost impossible to manage in the current UI. Does anyone know how to force...

Can calculated column be used in another calculated column?

SELECT ExchangeRatePrice = CASE pp.Price WHEN NULL THEN 0 ELSE (CASE WHEN c.CurrencyId = 1 THEN pp.Price ELSE CONVERT(DECIMAL(9, 2), (pp.Price * c.ExchangeRate)) END) END , price as OriginalPriceInDB, 10 * Price as CalculatedPrice, c.currencyid as Currency FROM ProductPrice pp, currency c I w...