sql-server-2005

Decryption problem

Hi, I have inserted some data in table using encryption (encrypted by creating my own certificate.). INSERT INTO Person2(ContactID, eFirstName, eMiddleName, eLastName) Values (1, EncryptByCert(Cert_ID('TestCertificate'), 'FirstName'), EncryptByCert(Cert_ID('TestCertificate'), 'Middle Name'), EncryptByCert(Cert_ID('TestCertificat...

Random Records & SQL2005 Stored Procedure Insert

Hi, I need to submit data from a form to an SQL2005 database via a stored procedure. The difficult part is that i also need to get 5 random records from a secondary table and insert these as part of the inserted record in table 1. My structure is akin to this: Tbl_Organisations (table to get the 5 random records from) Key | organis...

What is the best way to lay out nested data in SQL Server Reporting Services 2005?

I am attempting to create a report that contains a list nested within another list to produce the following layout: User name: Bob User info: Interesting stuff about Bob Permissions: Administrator SuperUser User User name: Next user etc... The data looks like this: ...

How do I create parametrized XPath queries in SQL server?

I am trying to write a parametrized query in SQL server that uses a parameter value as part of the XPath, however it does not seem to work the way I would expect it to. Here is my sample: create table ##example (xmltest xml) declare @LanguagePath varchar(75) set @LanguagePath = '(/languages/language[@id="en-US"])[1]' insert into ##ex...

Importing ODBC database to MS SQL 2005

How do I get a database from ODBC data source to SQL Server 2005? Can I use SQL Managment Studio Express for this? ...

best way to convert and validate a date string

I have a single char(8) variable formatted as ddmmyyyy in a stored procedure (quality and validity of this value is unknown and beyond my control). What is the best most efficient way to move the value into a datetime variable, and throw an error if it is not valid datetime. DECLARE @Source char(8) DECLARE @Destination datetime ...

Can I use data in a query in the Page Header of a Reporting Services report?

I am pretty sure I cannot, but I would just like to double check - can I use data in a query in the Page Header of a Reporting Services report? Thanks! ...

SQL Server 2005 - Pass In Name of Table to be Queried via Parameter

Here's the situation. Due to the design of the database I have to work with, I need to write a stored procedure in such a way that I can pass in the name of the table to be queried against if at all possible. The program in question does its processing by jobs, and each job gets its own table created in the database, IE table-jobid1, t...

Triggering a stored procedure in SQL Server 2005 by email

How can I trigger a stored procedure in SQL Server 2005 based on emails arriving in an Exchange inbox (with POP3/IMAP enabled)? I'd rather not use Windows Services if possible, and use the SQL Server functionality instead. ...

What Access Rights am I Missing on my Stored Procedure

I'm trying to run a stored procedure from my website that disables a trigger. Here is the code for the trigger: CREATE PROCEDURE [dbo].[DisableMyTrigger] AS BEGIN alter table dbo.TableName DISABLE TRIGGER TriggerName END I've also set the permissions on the stored procedure with: Grant Exec on dbo.DisableMyTrigger To DBAccountNam...

How can I determine which of my SQL 2005 statistics are unused?

After a few years, one of my largest databases has accumulated 73 statistics on one of it's largest tables. With indexes, I can run many types of reports and queries to decide how often / heavily specific indexes are used. Is there an equivalent for statistics? How can I tell which ones are useless after all these years? We're running ...

Can't bulk insert file

I have a 5GB file that I need to bulk insert into a SQL Server database (2005 SP2). When I attempt to do so (using a format file that worked in the past for the same import file), I get the error: The transaction log for database 'tempdb' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in ...

How to create 20 databases at a time in sqlserver?

Hi, I have written the following procedure to create a series of 20 databases. But it is not creating them. The database is not created even when I go to my H: drive and didnot find the ldf and mdf named bharath1 bharath2 like... What did I do wrong with this? USE master GO DECLARE @command varchar(1000), @i int while @i < 5 SET @...

Add a non null column to a sql table script - getting an error.

SQL Server 2005. The following 3 lines of sql work without error if the Is_Active column had previously existed in the Dim_Form table. ie if Is_Active has not existed previously, running the following 3 lines gives an error as displayed below; ALTER TABLE dbo.Dim_form add Is_Active bit NULL UPDATE dbo.Dim_form set Is_Active = 1 ALTER...

[SOLVED] MS SQL Server 2005 : Error log is too big and getting bigger

I guess someone tries to logon to our sql server and error log is getting bigger. I am running out of space on hdd. What should be the solution? Cleaning up error log regularly? Howto? Disabling access to SQL server? For attacker IPs? For local use only? Howto? Any other? Regards, Burak ...

Query to get only the duplicate data

Hi I have a table with data ID Name 1 John 2 Robert 3 John 4 Sam 5 Jack 6 Sam Now i want ony the the duplicate names ony through query ie....

SQL, returning logic of value being in another query to field

This is my query as it is now. I want to add another column to the result checking if the ItemID is equal to any value in another table column (BuildComponents.ComponentID). Eg. writing 'Y' if its there and 'N' if its not. I do not want this to affect what rows are returned. I am using MS SQL 2005. The logic would be something like this:...

What is the internal representation of datetime in sql server?

What is the underlying datastructure of datetime values stored in SQL Server (2000 and 2005 if different)? Ie down to the byte representation? Presumably the default representation you get when you select a datetime column is a culture specific value / subject to change. That is, some underlying structure that we don't see is getting ...

SQL Server 2005 joining results of two different sp like ...

Hi, I want to join results of two different store procedures that returns same structure in following fashion: EXEC StoreProcedure1 p1 UNION EXEC StoreProcedure2 p2 I realize that is not possible, can sombody suggest elegant alternative? I beleive I should use temp table ? Thanks ...

What would be a better way to handle this sql logic?

Inside of a stored procedure, I populate a table of items (#Items). Just basic information about them. However for each item, I need to make sure I can sell them, and in order to do that I need to perform a whole lot of validation. In order to keep the stored procedure somewhat maintainable, I moved the logic into another stored procedur...