sql-server

Is it better to log to file or database?

We're still using old Classic ASP and are wanting to log whenever a user does something in our application. We'll write a generic subroutine to take in the details we want to log. Should we log this to say a txt file using FileSystemObject or log it to a MSSQL database? If the database, should we add a new table to the one existing dat...

Finding Similar Records with SQL

Hello, I have a SQL Server 2008 database with 2 tables. These tables are Address and Store. These tables are defined as Address -------- ID (int) Line1 (nvarchar(255)) PostalCode (nvarchar(5)) City (nvarchar(255)) State (nvarchar(255)) Store ----- ID (int) LocationID (int) Name I am trying to find a list of stores that are located a...

SQLServer2008 : Obfuscation or scrambling

Hi all, is it possible to obfuscate or scramble a column in SQLServer 2008 R2 without having to use encryption or some highly ineffecient custom made function that does substrings ? :) greetings, Tim ...

Updating a table with multiple values from a select statement where the date matches

I'm having a problem updating a table and im sure its pretty straight forward but im going round and round in circles here. Table 'table1' data I want to update is formatted as follows: [Month] Figure ---------------------------------- 2010-05-01 00:00:00.000 1.0000 2010-06-01 00:00:00.000 1.0000 2010-07-01 00:00:00....

Sql Server, Composite Primary keys and clustered indexes

How does Sql Server handle fill factor on tables with clustered indexes on composite primary keys? I would assume a key node value would be generated based on the fields that make up the clustered index. Would this mean that each new row inserted would effectively get inserted to at the end of the index? ...

How to query for rows that have highest column value among rows that have same value for one of the columns

I have UserScores Table with data like this: Id userId Score 1 1 10 2 2 5 3 1 5 I would like to have a query or SQL block that can give me the following output Id userId Score 3 1 5 2 2 5 That is, I would like to pick rows that are unique by 'user id' that belong...

SQL Server: how to determine what will break when downgrading a database?

We're building an application for a client with the assumption that they'd be upgrading to a minimum of SQL Server 2005 from SQL Server 2000. We're finished our application, built on 2005, and are ready to integrate. Turns out that they're not going to upgrade their DB server. So, now we're stuck with trying to sort out what will break...

SQL-Query: EXISTS in Subtable

I have two tables tabData and tabDataDetail. I want all idData(PK) from Parent-Table(tabData) that have only rows in Child-Table(tabDataDetail, FK is fiData) with: fiActionCode=11 alone or fiactionCode=11 and fiActionCode=34 Any other combination is invalid. How to get them? What i've tried without success(slow and gives me also r...

Column creation and use

Hi, I am fairly new to SQL, so not sure if this is just a SQL compiler thing or not. When I have used SQL before it's been through JAVA or PHP, never just straight SQL. I am using SQL Server 2005 and attempting to add a column to my table, and then populate it. Here is what I have now: ALTER TABLE House DROP COLUMN CustomerType ALTE...

In Multi-Tenant Data Architecture, what is the best way to implement tenant filter view?

I am implementing a SaaS application using ASP.Net MVC 2 and SQL Server database. I am using Shared Tenancy approach. To filter data, so far I have found 2 approaches. Option 1: http://msdn.microsoft.com/en-us/library/aa479086.aspx#mlttntda_tvf Using sql login per tenant. Thus, using SUSER_SID() as a filter in the views Option 2: ht...

problems while executing a sql command in vb

I have a problem with a sql query. Through the query I am trying to search database for any occurrences of string (can be anything) in a column using the SQL LIKE command. The problem is that it works fine for most of the strings say john, jim, ji"m , but does not work when i include the following characters which are ( ' , { , } , and a...

Error when issuing BACKUP CERTIFICATE

I am creating a certificate in one of my databases, which works without a problem. However, when I try to back up that certificate so that I can port it over to another database I receive the following error message: An error occurred during decryption. Here's my backup statement: BACKUP CERTIFICATE test_certs TO FILE = 'C:\test_cert...

Visual Studio Redraw Fail

I am using Visual Studio 2008 to develop SQL Server 2008 R2 SSIS packages. Whenever I switch between applications, the components in the package lose their outlines, break point visual markers - it just looks ugly. Here is where everything except the name and the background color is lost I have uninstalled an reinstalled Visual Stu...

sql server invalid precision on exists check query

Using sql server 2008 I am getting and invalid precision value error in the following perl script: use DBI; $idx = '12345'; $query = 'if exists (select * from tbl where idx = ?) select top 10 * from tbl'; my $h = $dbh->prepare($query) or die "Couldn't prepare query: " . $dbh->errstr; $h->execute($idx) or die "Couldn't execute statement:...

SQL Connection with public IP, named instance and port number

I have had difficulty creating a connection string in c# that will connect to a remote SQL server using a public IP, named instance and a port number (other than 1433). Anyone know how to do that? ...

Extracting Data Client Side

I need to be able to extract and transform data from a data source on a client machine and ship it off via a web service call to be loaded into our data store. I would love to be able leverage SSIS but the Sql Server licensing agreement is preventing me from installing Integration Services on a client machine. Can I just provide the clie...

Help for using (exernal images) from the website with SSRS

I have a small web site where i maintain users data. I maintain the users data in table and store there images like /images/users/user_id.jpeg on the server. I am using the ReportViewer control in the asp.net page to show the reports from SSRS in the web application. Now user want reports where they can see the users image in the repor...

Setting up a user to my database in my SQL Server

Hi All, I just finished creating a new user for my database in SQL Server. I had 4 tables I wanted to grant Insert, Update, Select and delete permissions. I did this manually in the Securables area of the new user. Is there a better way to do this that to have to touch each object? if so, how? Thanks, rod. ...

Casting Eval("bitValue") as Bool

I have a list view with a HyperLink control within the ItemTemplate. I want to display the link if a returned value is 0 (false), and not display the link if it is 1 (true). So far I have this: <asp:HyperLink runat="server" ID="lnkReview" NavigateUrl='<%# Eval("EnquiryID", @"selectcompany.aspx?enq={0}")%>' Text="Review Enquiry" V...

How do I execute a stored procedure every time a report is run?

I have a stored proc that basically is used for logging reports that were executed with their parameters. I'd like to run this stored proc on every execution of the report? Do I do this through the report code window? ...