sql-server

Atomically mark and return a group of rows in database

I'm writing a background service that needs to process a series of jobs, stored as records in a sqlserver table. The service needs to find the oldest 20 jobs that need to be worked (where status = 'new'), mark them (set status = 'processing'), run them, and update the jobs afterward. It's the first part I need help with. There could be ...

How do you add a primary key to a sql view? - Or alternate way to link views to linq-2-entities

I'm adding a very simple view (or trying to) to my entities object model. The database is in sql server 2008. I'm on .net 3.5 (sp1) using C#. The view has two fields: color and colorcount, a Varchar(50) and a count(*) respectively. When I do Update Model from Database, and select the view to add, it runs (it updated tables, adding ...

How can I select none duplicate rows with inner join?

My MS SQL Server stored procedure is: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_close] @DATE NVARCHAR(8) AS BEGIN SELECT appointment_datas.appointment_date ,appointment_datas.appointment_no ,costumer_datas.costumer_name ,appointment_datas.appointment_type ,personel_datas.personel_ADI FRO...

How to pass a SQL temp table to a C# stored procedure

What's the best way to pass a temp table to a C# stored procedure (SQL 2008)? Am I stuck passing the temp table name as text and running a select from C#? I was hoping to use Table Value Parameters, but they don't appear to be supported in C# sprocs. ...

Attaching mdf file into sql server

Earlier mdf file was in app_Data folder, and application was working fine. When I attached mdf file into sql server. I can execute queries. But when I try to use it from asp.net application it give following exception. Cannot open user default database. Login failed. Login failed for user 'domain\username' ...

SQL server 2008: How to get the start date and end date of my data?

hi! As a newb, I already know that I will be berated for asking this question, but I did not find the answer on the site here and could use some help... I have a table that lists data by the day, and by type. For example Transaction | Date | Type ----------------------------- Updat | 11/7/2008 | Cash-out Update | 11/10/2008 ...

What do all these "Save DTS Package" options mean?

I'm creating a DTS package. After specifying the source, destination, and tables, I get the Save, schedule, and replicate package step, which has a Save DTS Package checkbox. If I check the box to save, I get these options: SQL Server SQL Server Meta Data Services Structured Storage File Visual Basic File Can anyone give a good exp...

Retrieving SQL Server Extended Properties From C#

We document our SQL Server database by creating table and column level Description extended properties. We usually enter these via SSMS. My question is this. I'm creating a C# application where I'd like to read the extended properties for a particular table and its associated columns. Can someone show me how I might go about doing thi...

find the duplicate and write it in log file.

...

Running a query in Page Load a bad idea?

I'm running an ASP.NET app in which I have added an insert/update query to the [global] Page_Load. So, each time the user hits any page on the site, it updates the database with their activity (session ID, time, page they hit). I haven't implemented it yet, but this was the only suggestion given to me as to how to keep track of how man...

Is there a reliable way to convert unzoned datetime into UNIX time_t?

I need to convert a database column in a (MSSQL) database table into UNIX time_t. The problem is that this column does not have a timezone and some dates are from GMT (+0000) and some from BST (+0100). I am working on UK times. Is there a reliable way to convert unzoned datetime into UNIX time_t? I'm currently using SELECT *,DATEDIFF(s...

SQL Server Session State, web farm, and IIS configuration

So I set up SQL Server Session State using SQL Server 2008 and the temp database and today I decided to look into the data in the tables only to find this in the ASPStateTempApplications table: AppId AppName 538231025 /lm/w3svc/1/root 611758131 /lm/w3svc/3/root 802488340 /lm/w3svc/4/root -940085065 /lm/w3svc/4/root/webapp 68...

Help with SQL to get Hits per day for today and 1 month prior...

I have this SQL now: CREATE PROCEDURE dbo.sel_Track_HitsLast30Days( @projectID int ) AS BEGIN DECLARE @FirstDay smalldatetime, @NumberOfMonths int, @priorMonth smalldatetime set @priorMonth = (SELECT CAST( ( STR( YEAR( dateadd(m,-1, getDate()) ) ) + '/' + STR( MONTH( dateadd(m,-1, getDate()) ) ) + '/' + STR( DAY( dateadd(m,-1, getDate(...

Looking for a script which will script out all database level persmissions( including xp_cmdshell and sql proxy account)

I need a stored procedure or script which will script out all database level permissions- including permissions to xp_cmdshell for any objects as well as permissions to a sql proxy account. Thanks! ...

Get details of object from database - keep ID secure

Hi, I have a list of books obtained from the database. When a user selects a book, I'd like it to retrieve the information for that book and display it on screen. However, I'd like to keep the ID of the book hidden from the client-side, so what would be the best way to transfer the ID of the selected book? I think my brain has melted,...

The server could not load DCOM error

I have a local SQL 2000 database. My Winform app suddenly died when trying to all a stored proc that has not changed. Here's teh error message: Server: Msg 7404, Level 16, State 2, Procedure RecordCurrentUser2, Line 45 The server could not load DCOM. Then, I noticed that when I try to alter the SP using Query Analyzer, I would get the ...

Hide SQL in Profiler

How can I make my SQL statements not to appear in Profiler ? They contain sensitive information and I don't want them to show in Profiler. Thanks for the replies ! ...

SQL Server Enterprise Manager Download? (Or Windows 7 equivalent?)

I maintain a couple of older sites running SQL Server 2000 and 2005. On my old XP box I was using SQL Server Enterprise Manager to access them. I'm now on a Windows 7 box. Is that product still available for download/install and will it run on Windows 7? I can't seem to find a download for that specific component. Or is there an alte...

SQL Insert Script Generator with Dependency Trackert

Hello All Is there any free tool to generate SQL insert Script in order of dependency. Thanks ...

SQL Server encryption using self signed SSL certificate. Querying from ASP.NET 3.5.

I've created a self-signed cert for testing encryption between my web application and the SQL Server. When attempting to query the database using "Encrypt=Yes;" in the connection string, I receive the following message: A connection was successfully established with the server, but then an error occurred during the pre-login handsha...