sql-server-2008

Does Indexing a View in Sql Server 2008 actually duplicate the original data?

Hi folks, If i create an Indexed View (in Sql Server 2008), does this mean i copy all required the data from the source tables into a separate new table? Or are only some tiny pointers/indexes saved, to represent this view? ...

How to delete rows in tables that contain foreign keys to other tables

Suppose there is a main table containing a primary key and there is another table which contains a foreign key to this main table. So if we delete the row of main table it will delete the child table also. How do I write this query? ...

SQL Server: how to use the same procedure in different instances?

I have a stored procedure in a test instance of a sql server (named sql2008test\sql2008_test) and it is located in one database. I would like to use this procedure also in production instance (named sql2008prod\sql2008_prod). Should I copy this procedure into this prod instance or can I modify my procedure somehow to query data from prod...

help with sql-server query

hi i have this table: num | class | Prob ---------------------- 1 | 2 | 1 99 | 4 | 2 2 | 5 | 3 99 | 6 | 4 where Prob = 99 i need * else i need to leave empty num | class | Prob ---------------------- | 2 | 1 * | 4 | 2 | 5 ...

Which are the problems in creating and dropping a linked server just for executing a remote query?

I need to retrieve some data from a remote database, it is a kind of "updates manager", so my application will connect to that remote server to check if there are new updates. I use a webserver for doing the "handshake and validation" work, but then I connect directly to a remote sql server to retrieve the data. The webserver will ret...

Replication with pull subscribers fails under Active Directory policy when using a dedicated replication account

I have a replication set up with pull subscribers and it's deployed in our corporate domain. I have requested to create a dedicated account to run this replication off of. On a pull subscription client in Sql Agent job I get this error: Message Unable to start execution of step 1 (reason: Error authenticating proxy DOMAIN\username, sys...

NHibernate and SQL Server 2008 encryption

How to perform SQL Server built-in encryption/decryption with NHibernate? I mean encryption of separate columns. ...

Import from csv (into different columns) via Openrowset and Microsoft.ACE.OLEDB.12.0

I want to clarify how I could import data from .csv into table with 3 columns (see CR Ranking.csv below). My query: select * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=C:\Work\;HDR=Yes;', 'SELECT * FROM [CR Ranking.csv]'); Outputs results into one coulmn: header: Category;INfo;Rank row 1: Category 1;Info;1 row 2: Ca...

Connection string not found when trying to query database under SubSonic

I get this error no matter what version of SubSonic I use. When I query the database for data, it errors out, saying it can not connect to the database. However, it is able to generate the .cs classes(ActiveRecord, Context, etc) when told to do so. Any help is appreciated. Thanks folks... ...

t-sql query : retrieve latest row approaches

Based on the following table Table_A ID Rev Description ----------------------------------- 1 1 Some text. 1 2 Some text. Adding more. 1 3 Some text. Ading more & more. The above will keep adding a new row when user updates the description. I want to take the row with MAX(Rev) [i.e. the latest description]. To...

Find N element in sequence using SQL

Given the following table: Sequence Tag ----- ---- 1 a 2 a 3 a 88 a 100 a 1 b 7 b 88 b 101 b I would like a query that returns the 4th in each sequence of tags (ordered by Tag, Sequence asc): Tag 4thInSequence ----- -------- ...

SSRS - report is rendering inconsistently

I have a report that was developed in SSRS 2008. It renders inconsistently. The report has a pivot on two separate columns. One time I run it, and the output is fine and the report renders with data and all of the data checks out. Inconsistently, when I run the report using the EXACT same parameters, the report renders,but no data is di...

SQL Server: Hidden risks of using DBCC SHRINKFILE

We're getting a huge LDF file by using a full recovery mode in a SQL Server DB. so we're planning to shrink the log file. Is there any performance penalty for using DBCC SHRINKFILE to reduce the database log file size (LDF)? and what about applying it to the data file (MDF)? ...

Does LINQ skip & take have decent performance?

We have a query for about 40 data fields related to customers. The query will often return a large amount of records, say up to 20,000. We only want to use say around the first 500 results. Then, we just want to be able to page through them 10 at a time. Is LINQ skip and take a reasonable approach for this? Are there any potentnialy...

Deadlock issue with SQL Server 2008 and ADO.NET

In our applications we don't use either ADO.NET transaction or SQL Server transactions in procedures and now we are getting the below error in our website when multiple people are using. Transaction (Process ID 73) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim...

How to copy and paste script text from SSMS to Outlook or Word without garbling it?

Say, I have a script nicely formatted in SSMS and it's annotated with all kinds of comments in different languages. But when I copy and paste this nice thingy into Word with syntax highlighted I will get a syntax-highlighted message with those comments garbled, as if reading the source text with one code page and pasting it using another...

Can't Connect To SQL Server with the Newly Create Login Name

CREATE LOGIN RepAcc WITH PASSWORD = '123456'; USE master; CREATE USER TestReport FOR LOGIN RepAcc WITH DEFAULT_SCHEMA = master; GO When i click connect object explorer and choose SQL Server Authentication then Type RepAcc as username and password 123456, i get error says can not connect, login is invalid or so. What should i do...

How to COUNT column values differently in a VIEW?

I have a column in Datablase Table, Suppose its Observation which contains three types of values Positive Negative NULL Now I want to count the Total no of rows , Total Positive and Total Negative and some other columns. I can not use Where clause here. And its a view So result should be like Total Positive Negative SomeOthe...

Database Missing ! Finding the root cause

Assume one fine day an admin comes to the office like he always does to do his admin tasks on Sql Server Databases and to his surprise finds a database missing. He has no clue of who dropped it or was it from an external batch or SQL injection etc ... where do one start an investigation and what are the important parameters/ findings tha...

How to figure out which column raises an arithmetic overflow error upon insert?

Imagine a table with like a hundred of different columns in it. Imagine, then, that I have a user-data table from where I want to copy data to the base table. So I wrote this simple insert-select statement and this error pops up. So, what's the most elegant way to figure out which column raises the error? My initial thoughts on the solu...