sql-server

SQL Server 2008 user instance database creation failure within an asp.net project

I'm trying to create a database within the app_data folder of an asp.net mvc project using the IDE, but i am getting a "Required Components Missing" message indicating "Connections to SQL Server files (*.mdf) requireSQL Express 2005 ....." I am using - Windows 7 Enterprise - VS2008 Team System SP1 - SQL Server 2008 Developer Edition SP...

writing a transaction in t-sql and error handling

Hi Do u think there is a better way to write a transaction in t-sql? Is there a better approach that improves maintainability and performance of the application that uses this transaction? -- Description: Insert email Receiver under specified subject -- ============================================= ALTER PROCEDURE [Contact].[Receiver_...

Checkbox on Sql Server Reporting Services Report

I'm working on a report in SSRS 2005 that is a questionnaire with yes/no answers. Trying to get a checkbox on the report. Have tried using windings for the font and an iif statement to set the character, but that doesn't come out correctly when exporting to PDF. I'm using local reports, not from a report server. ...

How to get "raw" facts data from Analysis Services

We are developed a custom MOLAP engine for live processing a large amount of data in process. And now we got a requirement to integrate SSAS with our system. Dimension's meta info and attributes data are very easy to get. But how can I get facts data without making SSAS to calculate aggregates i.e. data that stored only on leafs? Aggre...

How can I get SQL Sever Tables to appear in Reverse Engineering Wizard?

Hello.. I don't do much Java coding so I am not too familiar with the NetBeans IDE. I am trying to create a reverse engineering file based on a SQL Server connection that is set up in my hibernate.cfg.xml. The reverse engineering wizard does not show any tables given the configuration file. I do not receive any error however. I believ...

Sql Server Mgmt Studio: is there a way to get it to reuse windows?

This is more an annoyance than a real problem, but it would be great if someone had a trick to get it to work. Let's say I have a .Sql file, MyScript.Sql. If I go to the file location in Windows Explorer and double click it, it opens SSMS. Good, that's what I want. However if I double click on that file again (or a different .sql file)...

How do I count occurrences by day in SQL?

Newbie SQL question here --> I've got an Occurrences table that contains a row for each time a user did something. A user can do the thing multiple times per day. It looks like this: Date Username ------ -------- 1/1/9 User1 1/1/9 User1 1/1/9 User2 1/2/9 User1 1/2/9 User3 1/3/9 User1 1/3/9 User1 1/...

Find the user with the most contact

Users send messages to each others message boxes, how to find the user who knows the most other users (receive AND send??). I have SQL Server. Table: USER_ID USER_NAME USER_GROUP MESSAGE_ID MESSAGE_MESSAGE MESSAGE_FROM_USER M_ESSAGE_TO_USER A user can send and receive, so who knows the most other users (by send AND receive??) ...

how do you detect what (site/service/stored procedure) is making call to SQL Server 2005 using the sa login?

Hi there, i was just wondering if anybody knows how to detect what is calling the sa login on my sql server 2005. I have a stack of websites and i swear i configured these with a different user id and password but my event viewer logs tell me that something is constantly trying to login using the sa credentials. Any help would be appreci...

How to use SQL conditional statements

I need to delete a row based upon the value in a column while executing an update query. Here is the code: UPDATE tag SET tag_count = tag_count - 1 WHERE tag_id = 1 IF tag_count < 1 delete from tag where tag_id = 1 This query here gives me an error. EDIT I am using inline sql with C# and sql server ...

Exporting Data To Excel, with Jagged Columns due to dynamic data?

I have a bit of an interesting problem where I need to create an Excel data dump from some data in the database, but rather than it being something simple I have some complex data to merge, below is an example of the data that I have to deal with. TblGeneralInfo RecordId|Record Name |Date |Cost 1 |Test Entry | 1/1/2010 |2....

Re-writing this sql query

Hi, I have written an SQL query that gets unread messages but I think I can improve the code (speed and readability). The first select is for COUNT function, the second is for grouping messages according to conversation_id, and the final nested select is for selecting last messages. Please give me suggestions. Thanks in advance. SELEC...

SQL - select distinct records in one field with highest records from another field

In a scenario where I have a table like so: int id (PK) int staff_id int skill_id bit mainskill I want to select only ONE record for each staff member (represented by staff_id) listing their main skill as represented by a (1) in mainskill. If no main skill is present, I want to return any of the skill records for that staff member. Fo...

Query joining in sql server 2005

I have two queries like: SELECT PC_COMP_CODE, PC_SL_LDGR_CODE, PC_SL_ACNO ACCOUNT, COUNT(PC_CHEQUE_NO) CHQS, SUM(CONVERT(FLOAT, PC_AMOUNT)) CHQ_AMT FROM GLAS_PDC_CHEQUES WHERE PC_COMP_CODE = '1' AND PC_DISCD IS NULL GROUP BY PC_SL_LDG...

dynamically create table statement in sql

how to dynamically create a table with same columns as that of previous table. in sql ...

How to combine IN operator with LIKE condition (or best way to get comparable results)

I need to select rows where a field begins with one of several different prefixes: select * from table where field like 'ab%' or field like 'cd%' or field like "ef%" or... What is the best way to do this using SQL in Oracle or SQL Server? I'm looking for something like the following statements (which are incorrect): select ...

How to automatically refresh sql server olap cube

I have built a cube in visual studio and deployed to SSAS. How can I get the data refreshed using a nightly sql batch job or some other means? TIA ...

Datetime display using month name in T-SQL

Hi all There is a field which is date type in a table. The format of this field is mm/dd/yy. Is there any way to convert it to dd-Month name-yy? Best Regards, ...

Performace and Sizes of Non-Clustered Indexes drops as size of clustering key increases?

Excerpt from: http://www.sqlservercentral.com/articles/Indexing/68563/ The width of the clustering key does not, however, only affect the clustered index. The clustering key, being the rows’ address, is located in every single nonclustered index. Hence a wide clustering key increases the size of all nonclustered indexes, ...

Increment field in Select statement

I have some data which i dont have a group statement in, and would not like to have a group statement in. But i would like to have an increment field so i can can do a reporting services zebra table. So, how do i turn this data: region country office somedata someotherdata EUROPE Austria Vienna 12 2 AS...