sql-server

SQL: break up one row into many (normalization)

I am in middle of upgrading from a poorly designed legacy database to a new database. In the old database there is tableA with fields Id and Commodities. Id is the primary key and contains an int and Commodities contains a comma delimited list. TableA: id | commodities 1135 | fish,eggs,meat 1127 | flour,oil In the new datab...

Howto: C# string to SQL full-text catalog search?

I have some search queries like so: George AND NOT Washington OR Abraham Dog OR cat AND NOT Wolf for these searches I would want to get back results for George or Abraham but not Washington, etc. basically I want to take the string and be able to submit a contextual search to my full-text catalog stored procedure search. I ...

LINQ And Concurrency Question

I am developing three applications that all share a common database. I'm running into many different concurrency issues and was wondering if it is possible to prevent any other queries to execute when certain queries are running (in other words, locking the database so there won't be any concurrency issues). Edit: I'm using LINQ to SQ...

Google like search query using Full Text Search in SQL Server

I am running a small website wherein I would like to make a functionality like Related Links section. For that I created fulltext catalog and index. So far I tried many ways to create search query which behaves like google, but I would say i was not even 10% close to what google is doing. During my research what i found was only follo...

Create View SQL

I am a student this is homework. I use SQL server to check my work but have to write script by hand. Create and display a VIEW that displays the account balance subtotals for each account group. Account group is defined as the first two digits of the account number. Display a grand total of the balance column at the end ...

Can I order the results of a concatenation in tsql?

SQL Server 2008 - I want to concatenate four columns into delimited values, but I want them to be ordered alphabetically. Is this possible? *UPDATE:*More info... This will be used on approx 700k-1M rows per day in an ETL job via SSIS. If there is an easier way to do it within SSIS, please let me know (script task, etc). It could also be...

distinct on a single column, yet returning a row from the same table based on an unselected condition

I am new to Sql server, and my MySql background is only decent, nothing exceptional. I have a table with 5 columns: Neighbrhood City State zip_code zip_percent The goal of the query: To provide a list of neighborhoods (unique) within a city and the zip_code that corresponds with the highest zip_percent. Thus returning 2 columns: Nei...

what should my initial size be

I'm moving a database from MySQL to SQLServer. When creating the database, what should I set the initial size to? I know the size of the imported database will be about 130MB but will grow. Should 130MB be the initial size or should I just take the default of 2MB? ...

Get list of tables but not include system tables (SQL Server 2K)?

Hey all, I know I can get a list of tables from a given database with the following query: select * from information_schema.tables How do I go about excluding system tables though? Thanks, Sonny ...

What is passing parameters to SQL and why do I need it?

Beginner here: In this answer to my question of how to insert data into SQL Server he mentioned passing parameters instead of string concatenation like I currently have. Is this really necessary for security? If so, what exactly is passing parameters? When i google it I get a lot about stored procedures. Is that what I want, I do n...

Cast as decimal not giving me correct results

Hello I get a result of 0.00000 from the following cast Secs_in_month = 2592000 total_fault_time_sum = 99 cast(((Secs_in_Month - total_fault_time_sum) / Secs_in_Month) as decimal(18,5)) AS availability the result should be 0.99996 any ideas on what I am doing wrong here ? Many thanks ...

Is there a SQL Server function for displaying pseudo-random database records?

is there a way to show a certain amount of random records from a database table, but heavily influenced by the date and time of creation. for example: showing 10 records at random, but showing latest with more frequency than the earliest say there are 100 entries in the news table latest (by date time) record would have an almost 100%...

Compute median of column in SQL common table expression

In MSSQL2008, I am trying to compute the median of a column of numbers from a common table expression using the classic median query as follows: WITH cte AS ( SELECT number FROM table ) SELECT cte.*, (SELECT (SELECT ( (SELECT TOP 1 cte.number FROM (SELECT TOP 50 PERCENT cte.number FROM cte ...

Registering Users to a Login Database - Web Frontend?

I have a database which manages login information for an application, and find myself (for rather tragic reasons involving combo boxes - don't ask) needing to manage the registration of new users through a web frontend. Quite literally all it needs to do is have a single form composed of a few edit boxes and a handful of combo boxes. Kee...

Convert SQL Server database to MySQL

I have an application database on SQL Server 2008 Express on my dedicated server. It's not enough for my web app. Are there any good free conversion tools that will enable me to convert my current SQL Server database to MySQL on my server. Will my web app be able to work the same? ...

how will webserver running IIS 5.0 handle multiple dbserver connections?

one websevers one website one page, three users clients two dbservers different databases on each using sql server 2005 server express when any of the client accessing the page from his computer clicks on button A ---- connect to 'table1' of db 'first' on dbserver1 button B ---- connect to 'table1' of db 'second' on dbsever2 questi...

Query taking long time to insert data in sql server express

Hi, I have strange scenario in which if I create database using SQL Server 2008 Express (database compatibility level SQL Server 2008) and perform insert using xml datatype, it executes indefinitely, but when same query is executed on database with compatibility level SQL Server 2005 it runs fine and executes in less than one minute. ...

Optimizing queries for a database using SQL/XML. Suggested resources?

This question is theoretical as well as practical. Any results indicating useful resources on optimizing queries will be appreciated. There is a large SQL database which stores a large amount of data stored in SQLXML fields. Querying the XML directly is not fast enough. I have looked at some MSDN articles on optimizing SQLXML (i.e....

Correctness of the query

Am interested to know how correct is my query the question is posted here., I doubt If I have written a perfect one, and I wish to ask you all where can I improve my code. Note: I did not want to fill this place up with lot of code, was very brief. Thank you. SELECT a.BookingId AS BookingId, CAST(b.Transa...

SQL Server Select query optimization

Hi, I am looking at some feature which will enable me to partition tables horizontally, i.e. the context of me referring to a table is only a sub-set of the entire set of records in a table. This could be a typical scenario in a SaaS model since data of one account is not of significance to another. Let us say, there is a...