sql-server-2005

SQLServer 2005 Generate all INDEX as CREATE statement?

Hi there, I have two database with same structures, but one of them is missing INDEXES (i think i've missed out), i mean the table didn't have any INDEXES yet. I was plan to generate CREATE INDEX for the database which have indexes but can't found any method available in Management Studio, yes we can generate script for tables, view, e...

Dynamic View name in Table valued function

I'm passing View name as parameter in a Table Valued Function, and I want to fetch some data from that view by building a dynamic SQL and executing it by sp_executesql(). when try to execute the function, I get the error: Only functions and extended stored procedures can be executed from within a function. DBMS: SQL Server 2005 any wor...

How to tell last update/insert activity on a table sql 2005

Hello, I am trying to find out when the last insert/update was done to a specific table in our sql 2005 db. The data does not have a timestamp, so I can not tell that way. Are there any dmv out there that would assist me in this? Thanks, hp Duplicate: http://stackoverflow.com/questions/301060/how-to-find-recent-sql-update-operations-a...

conditionally create user in SQL Server

Hi, I would like to create a user 'foo' in database 'mydb' if the user doesn't already exist. Currently my script looks like this: USE [mydb] CREATE USER [foo] FOR LOGIN [foo] GO However if the user already exists, this fails with an error message: Msg 15023, Level 16, State 1, Line 2 User, group, or role 'jsrvpp' already exists in ...

Why can't I shrink a transaction log file, even after backup?

I have a database that has a 28gig transaction log file. Recovery mode is simple. I just took a full backup of the database, and then ran both: backup log dbmcms with truncate_only DBCC SHRINKFILE ('Wxlog0', TRUNCATEONLY) The name of the db is db_mcms and the name of the transaction log file is Wxlog0. Neither has helped. I'm ...

Import Data Wizard Does Not Like Data Type I Choose For A Column

Does anybody else have this same problem, when you import data from Excel file to MSSQL Server 2005, if some column contains mostly numeric data, but even if you set the column type to varchar, the wizard fails to import those fields that fail to parse as numbers? ...

Upgrading SQL Server 2000 to 2005 or 2008 - DTS to SSIS

Our office uses SQL Server 2000, and by and large it has served our needs well. I'm looking into the possibility of upgrading to SQL 2005 or 2008 because of the new features not found in 2000 (when I saw Index usage statistics which told me which Indexes were the most used and which were never used, that blew me away). I'm not too conc...

SQL Server 2005 Express other users can't see stored procedures

I added a couple of stored procedures to a SQL Server 2005 database at our company. The database uses Windows Authentication. Other users cannot see the procedures, although they can view the database/tables/stored procedures using SQL Server Management Express. What am I missing? ...

I need yyyy-mm-dd hh:mm:ss in SQL Server to become yyyy-mm-dd in C#

HI, This might be a frequent question. I have a date column (InvDate) in SQL Server 2005 database, which has a value like 2009-04-23 00:00:00.000. I am fetching this into a Dataset. Now i need to store only 2009-04-23 into some output Excel sheet (i am using OleDB). I dont want the time , even if it is just 00:00:00.000. I have tri...

How to grant permissions to developers to grant permissions to users?

Is there a way I can give developers permission to grant a user permissions over objects without giving them the option to create users or functions? I'm trying to limit developers permissions, I recently found out that developers had db_owner permissions in dev and prod environments! So I'm doing my best to stop this madness. Any good...

Checking for time range overlap, the watchman problem [SQL]

I am running into a road block on a larger problem. As part of a large query I need to solve a "night watchman" problem. I have a table with schedule shifts as such: ID | Start | End 1 | 2009-1-1 06:00 | 2009-1-1 14:00 2 | 2009-1-1 10:00 | 2009-1-1 18:00 3 | 2009-2-1 20:00 | 2009-2-2 04:00 4 | 2009-2-2 06:00 | 2009-2-2 14:...

SQL putting two single quotes around datetime fields and fails to insert record

I am trying to INSERT into an SQL database table, but it doesn't work. So I used the SQL server profiler to see how it was building the query; what it shows is the following: declare @p1 int set @p1=0 declare @p2 int set @p2=0 declare @p3 int set @p3=1 exec InsertProcedureName @ConsumerMovingDetailID=@p1 output, @UniqueID=@p2 output, ...

javascript - accessing a field of datatype varchar(max) in resultset

Within a javascript app, we're calling a sproc on SQL Server 2005 that's returning a resultset with 3 columns of type: bigint, varchar(20), and varchar(MAX). When calling the sproc and reading the results, there's no exception being thrown. When enumerating the resultset: var dbConn = DatabaseConnectionFactory.createDatabaseConnection(...

TSD3025: The following cross database dependencies could not be verified

I have created a VSTS database project by importing an existing database schema. Upon importing I get a slew of (thousands) of TSD3025 warnings on the project that aren't clear as to how I might resolve them. I don't get what it means by cross-database since the objects in question are all contained within the same database. Exam...

how to find out who and when permissions/grants in stored procedure was changed

There is a stored procedure in SQL Server 2005 in which users claim execute permission was removed as they can no longer execute the stored procedure. I tried to find it in trace files, but i can't find an entry for this stored procedure My question is is there other way to find out who and when permission/grants of this stored procedu...

How do you export the content of stored procedures?

How can I export the content of a stored procedure using a SQL Statement? ...

MSSQL Server 2005 tempdb problem

So I have a database that is acting weird. I am watching all activity on the server, and the tempdb is constantly growing. It has grown by 30gb in about 45 minutes. I keep checking the allocated space in the tempdb, and it is always about 8mb. I know that it is not needing all the space it is allocating, I have watched 1 transaction happ...

HRESULT: 0x8004D00E using TransactionScope - C#

I received the following error when I tried to run a C# WinForms application on a Windows Server 2003 Standard Edition SP1 machine that was connecting to a SQL server 2000, converting the data in the WinForms app and inserting the converted into a SQL server 2005 application. I am connecting to each database using SSPI. The code was co...

Reporting services 2005: Is there a way to dymanically change a report header?

I have a report that needs different header text on pages depending on the content of the page. Is there a way change the text in the header based on a piece of information on a page? Page 1 header: ITINERARY Page 2 header: ITINERARY Page 3 header: FARE RULES Page 4 header: RECEIPT The other issue is that eac...

Connecting to SQL server from Virtual PC

I have VS 2008 and SQL Server 2005 Developer edition installed on my desktop. I have a instance of XP running in Virtual PC and want to connect to the dev instance. I am logged on as a domain user on both the desktop and the Virtual instance of XP. When I try to connect I get a message saying "Server does not exist or access denied". ...