sql-server

Update a single row with t-sql

I want to update a row in my date base. The problem is, through a mistake on my part, I have two identical rows of data. How do I run the update on just one row? ...

Implications of Fulltext Search over many columns

Hello, I have a really wide table which includes separate columns for billing address, shipping address, primary address, names, aliases etc. (I can't normalize this table further, and that's not the question here anyways). I'm implementing SQL Server fulltext search, and I'm wondering whether I should limit the search ability to just t...

Start position for a reused t- sql cursor?

I'm working on a stored procedure that uses a cursor on a temporary table (I have read a bit about why cursors are undesirable, but in this situation I believe I still need to use one). In my procedure I need to step through the rows of the table twice. Having declared the cursor, already stepped through the temporary table once and c...

Best pattern for storing (product) attributes in SQL Server

We are starting a new project where we need to store product and many product attributes in a database. The technology stack is MS SQL 2008 and Entity Framework 4.0 / LINQ for data access. The products (and Products Table) are pretty straightforward (a SKU, manufacturer, price, etc..). However there are also many attributes to store w...

What is syncobj in SQL Server

Hi. I run this script to search particular text in sys.columns and I get a lot of "dbo.syncobj_0x3934443438443332" this kind of result. SELECT c.name, s.name + '.' + o.name FROM sys.columns c INNER JOIN sys.objects o ON c.object_id=o.object_id INNER JOIN sys.schemas s ON o.schema_id=s.schema_id WHERE c.name LIKE '%text%' If I get i...

Importing CSV filte to SQL server...

HI guys, I am trying to import CSV file to SQL server database, no success, I am still newbie to sql server, thanks Operation stopped... Initializing Data Flow Task (Success) Initializing Connections (Success) Setting SQL Command (Success) Setting Source Connection (Success) Setting Destination Connection (Success) Validating (Success...

Keyword search on all columns of multiple tables in SQL Server

Dear all, We are maintaining the profile information’s (like profile first name, last name, address, city, state, age, religion, occupation, education, etc….) from tbl_profie table in SQL Server. The users can search profiles using any keywords like Example 1: MBBS, Delhi, India Example 2: MBA, Delhi, cricket Example 3 : London, Hindu...

SQL different joins not making any difference to result

I'm trying to write a quick (ha!) program to organise some of my financial information. What I ideally want is a query that will return all records with financial information in them from TableA. There should be one row for each month, but in instances where there were no transactions for a month there will be no record. I get results li...

Storing SQL queries in Table in sql server

We have multiple jobs in our system. These jobs are listed in a grid. We have 3 different user types (usertypeid 1,2,3). For each user listing is different and he can filter listing by selecting view from a dropdown. ViewName in the below table is the view which needs to be displayed. To achieve this functionality, a fellow developer...

I want just the insert query for a temp table.

Hi..I am using C#.Net and Sql Server ( Windows Application ). I had created a temporary table. When a button is clicked, temporary table (#tmp_emp_details) is created. I am having another button called "insert Values" and also 5 textboxes. The values that are entered in the textbox are used and whenever com.ExecuteNonQuery(); line com...

inserting only date in a column in sql server

hi! Is there a way to insert only date in a datetime column in sql server without the time? for example date (datetime) =============== 12-01-2000 16-02-2000 or i should store this as a varchar and cast it when retriving so that i can convert to whatever form i need. ...

In the context of an asp.net website, what's the most efficient way to check whether a User has access to a particular record?

I have a webpage that you pass in an id parameter (via a querystring), which it then uses to fetch data from a database. Typically, a user would navigate to this page from another page that lists only those records that the user has access to. However, if they go directly to the page by typing in the URL in the Address Bar, they can effe...

How do I do pivoting in this query in SQL?

Hi there I have this table like this: Name; Amount1, Amount, Rate1, Rate2 Test; 1000; 2000; 1.0; 2.0 I want to display into: Parameter; Amount1; Rate1; Total 'Parameter 1'; 1000; 1.0; 1000 'Parameter 2'; 2000; 2.0; 4000 BTW ... I am using SQL2K5. All I can think of is CURSOR. Any other solution in elegant way? Thanks ...

IF statement error

I have the following columns in TableA TableA Column1 varchar Column2 int Column3 bit I am using this statement IF Column3 = 0 SELECT Column1, Column2 FROM TableA WHERE Column2 > 200 ELSE SELECT Column1, Column2 FROM TableA WHERE Column2 < 200 But the statment does not compile. It says Invalid Column Name 'Co...

Users Hierarchy Logic

Hi guys, I am writing a user security module using SQLServer 2008 so threfore need to design a database accordingly. Formally I had Userinfo table with UserID, Username and ParentID to build a recursion and populated tree to represent hierarchy but now I have following criteria which I need to develop. I have now USERS, ADMINISTRATORS...

Difficulty restoring a differential backup in SQL Server, 2 media families are expected or no files are ready for rollforward

I have sql backups copied from server A to server B on a nightly basis. We want to move the sql server from server A to server B without much downtime, but the files are very large. I assumed that performing a differential backup and restore would solve the problem with the databases. Copy full backup from server A to copy to server ...

Exit and rollback everything in script on error

Hey guys ! I'm in a bit of a pickle here. I have a TSQL script that does a lot of database structure adjustments but it's not really safe to just let it go through when something fails. to make things clear: using MS SQL 2005 it's NOT a stored procedure, just a script file (.sql) what I have is something in the following order BEG...

How to interact sql database in vb.net desktop application

Hi guys, I am writing a desktop database application. I want my application to use SQL database. What is the best way to start. ...

Are there performance problems in querying non varbinary(max) fields in a table containing varbinary(max) data?

I created a table to insert all the documents of my application. It is a simple table (let's call it DOC_DATA) that has 3 fields: DOC_ID, FileSize, Data. Data is varbinary(max). I then have many tables (CUSTOMERS_DOCUMENTS, EMPLOYEES_DOCUMENTS, ...) that contain other data (like "document description", "Created by", "Customer ID" ...). ...

Code Access Security in Reporting Services 2008

Hi I have a Delivery Extension running inside Reporting Service 2008. It has been running fine for a long time. But now I want to make an insert into a database from within the extension. First error I got, was this: Exception: System.Security.SecurityException Exception Message: Request for the permission of type 'System.Data.SqlCli...