sql-server

Common exceptions while executing sql queries

I have read that catching the particular exception separately enhanced the performance so I just wanted to know what are the most common exception that might generate while executing any sql query ...

AdvantureWorks Hirarchy

Hi everybody. I have a question about AdvantureWorks. What is the query to determine the full hirarchy of an employee's managers? example: Alex is the input Sara (Manager - Level 1) James(Manager - Level 2) David(Manager - Level 3) Alex(Simple Employee) ...

how to allow android to access/modify a remote database

I'm running a .net aspx application. I'll need my android app to access and modify/insert information into the ms sql database. is there any api ? thank you ...

DisplayName - 'User' + UserId - Best Way to Do This

I want to do something like SO does with DisplayName. When someone does not enter a DisplayName, I want to default this to 'User' + UserId. So the first user who signs up would get User1 - since UserId will be 1, the second User2 - since UserId will be 2, and so on. The easiest way I can think of doing this is using a trigger, but I...

How Database stores data internally in B-Tree/B+Tree

My question is that How database stores data and how it performs query internally. Suppose we have following fields in our table: ID Name Age Weight Manager and we query select * from Table1 where age>50 and weight<100 I am just curious that how it perform query internally. What will the Node of B-Tre/B+Tree contains in this exam...

SQL CASE statement

Hi Friends, I have the following queries and I want to put them in an sql CASE statement so I would have only one query but I don't know how to do that. Can somebody help me? IF (SELECT EtlLoadId FROM ssislogs.audit.processcontrol WHERE SubjectArea = 'UaqaFacetsImp') > 0 SELECT pc.SrcFileName + ' - '+ CONVERT(VARCHAR(10), pc.[Reco...

Help creating the necessary TSQL for this basic requirement.

I've gotten really rusty with TSQL I'm ashamed to say. Using Entity Framework has made me forget what little TSQL I even knew. And I haven't exactly made very complex queries with Entity Framework either, just never had the need to sad to say. This is one exercise our professor gave us this Friday: "Monica buys a gallon of milk from th...

What is the most popular website written in asp.net?

I am trying to justify writing a website in asp.net that has the potential to be as large as wikipedia. Are there any large websites content driven websites that have been written asp.net? ...

detecting if database there or not CONFUSIONS, please help and improve this code

my aim is to create a db, and check if the db is there or not, at pageload the confusions are stated beneath "BOLD TEXT" i do not see why its not clear but still as requested i adding more explanations working fine code using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using Syst...

i would like to get the following information of a database please suggests ways

My need is to write a code, which creates a db creates four tables creates primary keys creates foreign keys and constraints like type int or boolean or string etc Yes I know w3c shools has the sql codes, but the problem is I first need to detect if these things exists or not one by one. And this is for me a great problem. I tried ...

Generate different timing for workers for printing

Hi, I am working on a project where there are 110 workers, each work for 4 hours in a batch of 8 worker, I want to Generate timing for this workers. e.g - Batch 1 - Worker 1-8 Timing 08:00am - 12:00pm Date 1/1/2010 - Batch 2 - Worker 9-16 Timing 12:00am - 04:00pm Date 1/1/2010 - Batch 3 - Worker 17-24 Timing 0...

Adding a unique row count to a SQL 2008 "for xml path" statement?

Ok, not sure if this is possible to do.. I have a query that returns just simple records from the database, but formatted out as XML as follows: select name, address, dateCreated, flag from table where name = 'test' for xml path('row'), root('rows') ok, no problems, and I get the XML as desired: <rows> <row> <name>jddjdjd</nam...

SQL Server Express - Commercial use

I'm developing a web site and i would like to use the SQL Server Express as my DB. The Express edition is limited for 4GB per DB. Is it legal to create & use several DB's for the use of a single web site? ...

Auto increment values with alpha numeric

Hi experts, I am trying automatically increment the alpha numeric field (say for productid in product table). But I am getting an error (see below). Could somebody please look into this error or any other approach to achieve this task? My table details: create table tblProduct ( id varchar(15) ) create procedure spInsertInProduct AS...

Cannot modify table ( using microsoft sql server management studio 2008 )

I create 2 tables and another 1 with foreign keys to the other two. I realized I want to make some changes to table no 3. I try to update a field but I get an error "Saving changes is not permitted. The changes you have made require the following table to be dropped and re-created." I delete those 2 relationships but when I look at d...

Multiple queries in stored procedure

Possible Duplicate: SQL CASE statement Hi Frdz, i have created a stored proc and i put three queries in stored proc with inputvariable @EtlLoadId = 0 and i get three different windows for each query under result tab. is there any chance i can get results from the stored proc (results of three queries) as only one window and r...

SQL Server Case when syntax

Ive a big select case in SQL query. (select case tb_usuario.int_id_cargo when 13 then '20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53' when 20 then '' when 21 the...

Performing String parsing with TEXT DataType

Using TEXT datatype in SQL Working on SQL 2000, I would like to perform the following Select @String = SUBSTRING(@String, @idx + DATALENGTH(@firstDelimiter)/ 2,LEN(@String)) NOTE: @String is a type TEXT , @FirstDelimiter is of type Varchar(4). Why am I unable to run the above code? How do I perform the above instead? Is the a...

Adding a reference data to the table column from different table line

I have an event table with following columns: sequence (int) DeviceID (varchar(8)) time_start (datetime) DeviceState (smallint) time_end (datetime) All columns except time_end are populated with the data (my current time_end column is NULL through out the table). What I'd need to do is to populate the time_end column with the event c...

T-SQL for deletions based on tiered datetime

I have a table that essentially stores revisions of certain datasets (i.e. edits back through time if you like). The date of the revision is unimaginatively stored as a datetime field named revision. Each new revision is taken daily, at midnight. If this table were left to populate, there would be a set of rows for every single day, wh...