sql-server

How can I execute a single query in SQL Server Management Studio?

Background: I'm using SQL Server Management Studio 2008 and I have a query window open that contains multiple queries. Is there a keyboard shortcut that will allow me to execute a single query without highlighting the query I would like to run first? Some other SQL tools have shorcuts that run the query that is under the cursor, which ...

TSQL Pivot without aggregate function

I have a table like this... CustomerID DBColumnName Data -------------------------------------- 1 FirstName Joe 1 MiddleName S 1 LastName Smith 1 Date 12/12/2009 2 FirstName Sam 2 MiddleName S 2 LastName Freddrick 2 ...

Login fails under IIS localhost but works under Visual Studio Server

I get this using this URL (my website setup through IIS): http://localhost/dreamrishta/Default.aspx Cannot open database "myDB" requested by the login. The login failed. Login failed for user 'R-2C02CDE60B8C4\ASPNET'. But when I use Visual Studios built in server: localhost:3554/Default.aspx It works fine and does not throw any err...

Indexed View vs Indexes on Table

I have the following table EVENT_LOG: EVENT_ID: pk, int, not null TYPEID: fk, int, not null CATEGORYID: fk, int, null SOURCE: varchar(255), null DESCRIPTION: varchar(4000), null CREATED: datetime, null We've been creating a report, and found that performance sucks. There aren't any indexes aside from the clustered one. We could cr...

SSIS timestamps

Can anyone provide details on what the three of these mean? System::ContainerStartTime System::CreationDate System::StartTime The documentation for these three is virtually non-existent. ...

Best way to get data from Ms Access Mdb file to sql server 2005

We use a software which uses Sql server 2005 as back-end. The problem is we have data coming in access file and we need to store it in sql server tables. I have the sql server tables ready. I don't need all the data i get in MDB access file but need specific columns from access and then store it in SQL server. I get fresh access tab...

DBUnit and SQL Server getting a socket closed

I keep getting this exception with DBUnit in the same place: org.dbunit.dataset.DataSetException: com.microsoft.sqlserver.jdbc.SQLServerException: Socket closed at org.dbunit.database.DatabaseTableMetaData.getColumns(DatabaseTableMetaData.java:359) etc. Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Socket closed at co...

Inserting a BLOB with OLE DB

I'm working on an app which is using OLE DB and SQL Server Native Client to access a SQL Server DB. To date, I've only been dealing with fairly simple SQL. For this, I've been obtaining an ICommandText and using SetCommandText. I now want to insert a large object into the database. I see that ICommandStream exists, but it seems like ...

VB.NET - SQLCommand.ExecScalar() throws unreferenced exception on Return?

I'm calling Sqlcommand.ExecScalar() - stepping through the stored proc works fine, right under RETURN @RecordNum @RecordNum correctly contains a bigint, as scoped. When I step into the RETURN.. I get an exception thrown, that visual studio does not seem to be able to capture. The stored procedure works fine when executed directly, a...

Does SQL Server 2k5 preserve locking hints over linked servers?

I've been nosing around--and I'm no DBA myself,--but became curious when trying to troubleshoot a particularly expensive (and infrequent) query that performs an outer join on a linked server (2k5 to 2k5, different dbs on different physical machines). The issue doesn't generally seem to be execution time, but rather locking, as the outer ...

Database Designing and Normalization issue

Hi friends, I have a huge access mdb file which contains a single table with 20-30 columns and over 50000 rows and i have some thing like this columns: id desc name phone email fax ab bc zxy sd country state zip ..... 1 a ab 12 fff 12 w 2 3 2 d sd 233 2 d ab 12 fff 12 s 2 3 1 d sd ...

How can I drop all indexes in a SQL database with one command?

So, how can I drop all indexes in a SQL database with one command? I have this command that will get me all the 20 or so drop statements, but how can I run all of those drop statements from this "result set"? select * from vw_drop_idnex; Another variation that gives me the same list is: SELECT 'DROP INDEX ' + ix.Name + ' ON ' + OB...

How can I make a stored procedure return a "dataset" using a parameter I pass?

I'm very new to Stored Procedures. Say I have a IDCategory (int) and I pass that to a stored procedure. In normal-talk, it'd go: Find me all the listings with an IDCategory equal to the IDCategory I'm telling you to find. So it would find say 3 listing, and create a table with columns: IDListing, IDCategory, Price, Seller, Im...

SQL Server select and insert issue

Hello everyone, I have two databases called DB1 and DB2 on the same database server. I have Table1 in DB2 and Table2 in DB2. Currently, I am using insert into select * to transfer all data from Table2 into Table1 (Table1 is empty, my purpose is to make a copy of data from Table2 to Table1). The table structure is clustered ID column (of...

TSQL, how to avoid if conditions?

Hello SQL Gurus, I am from procedure programming background, end up writing TSQL recently with my new job. My mindset still thinking about writing queries with if conditions. How to avoid following query without if condition. DECLARE @NumAddress INT SELECT @NumAddress = COUNT(*) FROM Address WHERE UserID = 1001 IF @NumAddress ...

Creating a table in SQL Server Express

I'm trying to setup a SQL database for a local program management and install system. I think i've created a basic serviceable schema that should work, but i'm unsure how to translate it to a CREATE TABLE command. Can someone help me with the translation and/or point me to resources that will? Schema: Programs( progID[key] (integer...

How do i connect to a SQL database from C#?

I am trying to write a local program management and install system for my home network, and i think i've got the technologies nailed down: C#/.NET/WPF for the client Lua for installation scripting support (through LuaInterface) SQL Server Express for maintaining a database of programs However i'm unsure what specifically i'll use to ...

Returning Explicit Open XML results sets from a Table Value Function

I'm trying to return rows in Open XML form from a table value function in SQL Server (2008). I'm occasionally getting errors when I select the results with "for xml explicit" which suggest that the order of the results is not guaranteed to be the same as the order I insert into the output of the TVF. So my first question is: is that th...

Data Caching Stores In ASP.NET MVC

Greetings fellow earthlings. I'm researching methods of caching data retrieved from various database tables using ASP.NET MVC. We have a huge amount of data which is only updated once a day and from then on is static. This can vary but generally it's things like a list of users (employees), to departments, offices, locations we're in ...

Streaming byte[] to Image in ASP.NET C#

I have an Image stored in my SQL Server database stored with my User data which I retrieve all at once. Now I have the byte[] directly on the page I want to show it on. How do I put it in my WebControls.Image? I don't want to have to call an HttpHandler and call the database again. This obviously just outputs it to the whole page. ...