sql-server

Design principles for designing database architecture of financial transaction system?

Hi, I want to design a database which will keep record for financial transaction.I want to design it as a product so that it can be used for any type of financial transaction.Are there some design principles specific to financial transaction database design that can help me out to make database more durable for long term with minimal arc...

How to join multiple tabels in the query scripts

I have 3 tabels in my SQL Server database with the following info: tabel: TeacherInfo columns: tID, tName, tAge, tLocationId values 1 Abel 53 1 2 Bob 23 2 3 Apaul 24 2 tabel: LocationInfo columns: lId, lD...

SQL [CASE Query View]

SELECT DT, FlowParam, Abs_P, T, Volume, Energy, FlowTime_T, (SELECT ' > 1 ' AS Expr1 WHERE ( (SELECT COUNT(*) AS Expr2 FROM dbo.BACS_Alarm_1 WHERE (DT_T >= dbo.BACS_HourFlow_1.DT_T) AND (DT_T <= dbo.BACS_HourFlow_1.DT_T + dbo.BACS_HourFlow_1.FlowTime_T) ) > 1 )) AS...

Problem in stored procedure result

I have a store procedure like this : ALTER PROCEDURE [dbo].[CheckUser&Pass] ( @Username nchar(15), @Password nchar(15) ) AS SET NOCOUNT ON; SELECT Username, Pass, Code_Person FROM Login WHERE (Username = @Username) AND (Pass = @Password) And Execution : DECLARE @return_value int EXEC @return_...

Make SQL Select Query Read Only

Is there a way to set an "Select Only" Mode? I work with SQL Server Management Studio and im afraid of editing some lines while selecting stuff from the database! ...

The result of stored procedure to a table, without creating the table manually in SQL Server

What I need to do is, put the results of stored procedure (with lots of parameters) in to a table. Something like that: SELECT * INTO Table_1 FROM ( EXEC [MY_DataBase].[dbo].[GET_Report] '%%', '%%', '%%', 'x', 'x', 'x', 'x', 'x', 'x' .... ) X However this seems to be an incorrect syntax, I searched for it and people are first creatin...

Is there a way to filter sql execution plans by specific operator?

I have a great bunch of sql server statements that run on sql server 2008 I try to inspect its execution plans. Actually it generates a great deal of execution plans. I want to show only the execution plans that have a specific operator(s). e.g I want to get the execution plans that have Table Scan operator. Any way to do something like...

Delete large amount of data in sql server

suppose that I have a table with 10000000 record. What is difference between this two solution? 1- delete data like : DELETE FROM MyTable 2- delete all of data with a application row by row : DELETE FROM MyTable WHERE ID = @SelectedID Is the first solution has best performance? what is the impact on log and performance? ...

How are server side applications created, how is client - server communication done?

I would like to have a client-server application written in .NET which would do following: server is running Linux on the server there is SQL database (mySQL) containing document URLs What we want: - server side would regularly crawl all URLs and create a full text index for them - client side would be able to perform a query into th...

SQL Server String parsing for special characters

I need a solution (t-sql function / procedure) to parse an SQL Server varchar(max) and eliminating all special characters and accents The output of this string will be transformed to a CSV file using an AWK script that breaks on special characters like '&', '%', '\' and all accent characters that on convert turn into unknown characters...

Grouping date periods (by number of days) but exclude the weekends?

I have a table with start and end dates in. My goal is to have a table that has grouped these dates into how many days the period spans. I thought I had the solution with a simple SQL statement (MS SQL Server 2005) but I want to exclude weekends. SELECT DATEDIFF(D, StartDate, EndDate)+1 AS Days, COUNT(ID) as Count FROM myDateTable GRO...

When does a db transaction written in ADO.NET actually begin?

One of the key things in database-intensive applications is to keep the transactions as short as possible. Today I was wondering when this transaction would actually begin: using (SqlConnection sqlConnection = new SqlConnection(connectionString)) { sqlConnection.Open(); /*(1)*/ SqlTransaction sqlTransaction = sqlConnection...

Cannot create a row of size 8074 which is greater than the allowable maximum row size of 8060.

I have already asked a question about this, but the problems keeps on hitting me ;-) I have two tables that are identical. I want to add a xml column. In the first table this is no problem, but in the second table I get the sqlException (title). However, apart from the data in it, they are the same. So, can I get the sqlException becaus...

What disadvantages are there for leaving an SQL Connection open?

This seems to be a simple question, but I wonder the disadvantages of not calling the "close()" function. Thanks. ...

SQL Server DB & App design level suggestion needed. Constraint in DB or App?

I need some suggestions to implement a business rule - whether to keep it in DB (using TRIGGERs) or in App code. --- Table structure:--- # ORG - Master table for Organizations # USER - Master table for Users (each user belongs to an Org so there's a field OrgId which is FK ro ORG) # SITE - Master table for Sites # ORGSITE - {OrgId, ...

Changing Identity Seed in SQL Server (Permanently!)

Is there any way of changing the identity seed for an identity column permanently? Using DBCC CHECKIDENT just seems to set the last_value. If the table is truncated all values are reset. dbcc checkident ('__Test_SeedIdent', reseed, 1000) select name, seed_value, increment_value, last_value from sys.identity_columns where [object_id] = ...

Bad performance of SQL query due to ORDER BY clause

Hi, I have a query joining 4 tables with a lot of conditions in the WHERE clause. The query also includes ORDER BY clause on a numeric column. It takes 6 seconds to return which is too long and I need to speed it up. Surprisingly I found that if I remove the ORDER BY clause it takes 2 seconds. Why the order by makes so massive difference...

How and where to handle exceptions in a 3-tier web application? Specifically Sql Database Exceptions

I'm building the standard 3-tier ASP.NET web application but I'm struggling as to where to do certain things - specifically handling exceptions. I've tried to have a look around on the web for some examples but can't find any which go as far as a whole project showing how everything links together. In my data-tier I'm connecting to SQL...

How to archive the SQL data record in File system and restore it back when required?

Hi everyone, I need a C# program to read the a record (stored in various tables) from the database and store it in the File System (in some format) and remove the record from the database. In other words, archiving database record on File System. It is also required to restore this record back when needed. So how can i achieve this? In...

Basic questions on setting up an access controlled intranet site - ASP .NET

Please note: I understand this is a somewhat vague question. Therefore your patience is very much appreciated. Requesting: An abstract high level idea of where to begin as I am totally clueless at this point. Background: I am setting up an intranet site (ASP .NET) where users from our local user group (who are also added in ou...