sql-server

How to do sorting in SQL SERVER varchar types

Hi, I have a table say tblSwap with a column StroreVals. StroreVals 20 21 29 11 10 5 7 I want to get the result in descending order using SQL SERVER 2005. How to do? If you fire SELECT StroreVals FROM tblSwap ORDER BY StroreVals DESC The output is 7 5 29 21 20 11 10 Also, if it is like "Abc", "Def","Azy","kly"? Pl...

What is the SQL Server equivalent to Oracle's Virtual Private Database?

What is the SQL Server equivalent to Oracle's Virtual Private Database (VPD)? ...

Can't connect to Oracle in dtsx job

When MS-SQL Server 2000 dtsx job tries to run, gets error "Ora-12154 TNS could not resolve service name" Tnsping to the oracle service to connect replies OK The Windows 2003 x64 Server that runs the dtsx jobs has 32 bit Oracle Server, ODAC 32 bit and Oracle Client 32 bit installed. Thank you for your concern , Kayhan YÜKSEL ...

What SQL Server Datatype Should I Use To Store A Byte[]

I want to store arrays of bytes in SQL Server. What datatype, or pre INSERT manipulation would you suggest to store these? I wouldn't expect these byte[] to exceed 1024 in length. ...

.NET SqlConnection class, connection pooling and reconnection logic

We have some client code which is using the SqlConnection class in .NET to talk to a SQLServer database. It is intermittently failing with this error: "ExecuteReader requires an open and available Connection. The connection's current state is Closed" The "temporary" solution is to reboot the process, after which everything works - howe...

Manually inserting varbinary data into SQL Server

Hi, We have a SQL Server table for user settings. Originally the settings were domain objects which had been serialized as XML into the table but we recently begun serializing them as binary. However, as part of our deployment process we statically pre-populate the table with predefined settings for our users. Originally, this was as...

ASP.NET, SQL 2005 "paging"

Hi, This is a followup on the question: http://stackoverflow.com/questions/1014526/asp-net-next-previous-buttons-to-display-single-row-in-a-form As it says on the page above, theres a previous/next button on the page, that retrieves a single row one at a time. Totally there's ~500,000 rows. When I "page" through each subscribtion num...

SQL mem usage

I'm managing a co-located winserver08 box running both IIS and SQL 08 express. I just happened to glance at the task manager's performance tab and find the 'mem usage history graph is close to topped out reading 1.8 gig (i have 2 gig physical ram). Processes shows sqlserver is running at 940,000K - by far the largest consumer. I'm a low...

C# + Sql Server - Execute a stored procedure large number of times. Best way?

Hi all. I have one stored procedure which inserts data into 3 tables, (does UPSERTS), and has some rudamentary logic. (IF-THEN-ELSE) I need to execute this Sproc millions of times (From a C# app) using different parameters and I need it to be FAST. What is the best way to do so? Does anybody know an open-source (or not) off the shelf...

mulit value and stored procedures

I have looked at the other questions concerning Multi Value selection in reporting services and none of them fixed my issue. My issue is this. I have a report that has a query for the parameter - @Type. Select distinct(type) from TypeTable order by Type the report paramenter is set up and the report shows all the returned results (cu...

How do you get the sql server username of the currently executing command in a CLR Trigger?

I know that SqlContext.WindowsIdentity returns the current user that is executing the command (in a CLR trigger), however, this only works for windows authenticated users. How do I get the username if it's a sql server user instead? Any help is appreciated. ...

sql update from select statement

Sorry for the length of this, I'm trying to give a lot of info to avoid non-relevant solutions. My goal is to embed at least 1 UPDATE statement into a SELECT statement so that I have a chance to update some computed values at the instant before the select statement runs (think of it like a TRIGGER on SELECT). VIEW is not in immediate s...

SQL Server 2005 Sleep_Task Wait Type

I have recently encountered a wait type that I am unable to find much info for. I have a stored procedure that takes about 1.0 hour to run but when the connection in the activity monitor displays the Sleep_Task wait type the SP could run for days if I didn't kill it. It just sits there doing nothing. Does anyone have any info on what th...

# in SQL Query

I have somebody elses code (C# ASP.Net) which contains the following query: string query = "SELECT distinct(destinations.name) as Destinations FROM destinations, flights WHERE destinations.d_ID = flights.d_ID AND flights.Date = #" + date.ToShortDateString() + "#"; I could not find w...

using pyodbc on ubuntu to insert a image field on SQL Server

I am using Ubuntu 9.04 I have installed the following package versions: unixodbc and unixodbc-dev: 2.2.11-16build3 tdsodbc: 0.82-4 libsybdb5: 0.82-4 freetds-common and freetds-dev: 0.82-4 python2.6-dev I have configured /etc/unixodbc.ini like this: [FreeTDS] Description = TDS driver (Sybase/MS SQL) Driver = /usr...

Summarizing data by multiple columns

My boss is asking me to code a report that has the following components: A pie chart of employee count by state A pie chart of employee count by age bracket (10 year brackets) A pie chart of employee length of service (5 year brackets) A pie chart of employee Male/Female breakdown A pie chart of employee count by salary band (computer ...

How can I open an Office Document from sql server via my C# windows app and automatically save back to database when editing is done?

Our application is written in C# using .net 2.0. The application tracks our business process and users can attach office documents for reference as attachments. They frequently edit those documents. Currently, they have to save the file to their hard drive, edit and save the file, then re-attach to our application to save into databas...

SQL Server Inserting Decimal, but selecting Int

I have a table with two decimal(18,0) fields. I am inserting into this table, two decimal values. For example, 1.11 When I select from the table (with no casts), I get 1. I'm losing all percision and I have no clue why. insert into TEST values (153, 'test', 'test', 1, 1, 1.11, 1.11) Select * from TEST and they are 1 and 1 instead of...

Recompile stored procs?

Is there a way to re-compile or at least 'check compile' stored procedures en masse? Sometimes we'll make schema changes - add or drop a column, etc. And do our best to identify affected procs only to be bitten by one we missed, which pukes when it runs next. SQLServer 2k5 or 2k8. ...

Mapping class properties to generic columns in table .NET

I have have a SQL Server table which has generic names like Text1, Text2.. etc. The table was designed like this because the same structure is used for different projects. I have a class in .NET which has properties. Say a Customer class has a property called FirstName. How can I do the mapping from FirstName to Text1 just once (centra...