I would like to write a 'generic' script to operate on a number of databases. The 'use databasename' commands will be distributed in the body of the script. I would rather show the database name information at the top of the script. So ideally:
declare @db varchar(100)
set @db = 'data_in'
use @db
This fails. So perhaps
declare @db ...
The code previously implemented takes in the xls file saves it on to a column in a table using the stream i use the same method but the only change is the the file saved is a xlsm or an xlsx type file it saves to the column in the database
When I try and get the contents from the database and throw the saved xlsm file or xlsx file I get...
We're having a problem where indexes on our tables are being ignored and SQL Server 2000 is performing table scans instead. We can force the use of indexes by using the WITH (INDEX=<index_name>) clause but would prefer not to have to do this.
As a developer I'm very familiar with SQL Server when writing T-SQL, but profiling and perform...
Hi,
Hopefully someone can help me. I have a Visual Studio 2008 WinForms
application to which I have added a Local Data Cache. The local data cache is
using a SDF file via SqlServerCE and is caching a SQL Server 2008 dbase with
change tracking enabled.
This is working and I can do bidirectional syncs and the like.
The problem I am ...
We have a requirement from a client to protect the database our application uses, even from their local administrators (Auditors just gave them that requirement).
In their requirement, protecting the data means that the Sql Server admin cannot read, nor modify sensitive data stored in tables.
We could do that with Encryption in Sql Ser...
This query returns me first below table. forexample; 2009-06-01 00:00:00 people enter my system '41' times. i need second table
declare @date1 smalldatetime, @date2 smalldatetime , @countgap int, @page nvarchar(100)
select @date1='2009-01-01', @date2='2009-12-30 23:59:59' ,@countgap=1, @page='Tüm Sayfalar'
declare @@date1 smalldate...
Hi,
im trying to realize something like this:
DECLARE @id int
declare @cont varchar(max)
declare @temp varchar(max)
DECLARE curs CURSOR FOR SELECT id, [content] FROM [dbo].[Contents]
OPEN curs
FETCH NEXT FROM curs into @id, @cont
WHILE @@FETCH_STATUS = 0
BEGIN
SET @temp = replace(@cont, @param_ReplaceThis, @param_WithReplace...
i came across the need to cleanse some data, and i need to find some particular guids (i.e. uniqueidentifiers) in SQL Server°.
i've come up with a stored procedure that does a SELECT from every uniqueidentifier column in every table in the current database, and returns a result set if the guid is found.
It uses the INFORMATION_SCHEMA v...
How can the Report Manager interface be changed to view only from the gray bar right below the four tabs, view, properties, history and subscription?
...
Is there a quick and easy way to list when every index in the database last had their statistics updated? The preferred answer would be a query. Also, is it possible to determine the "quality" of the statistics: FULLSCAN, SAMPLE n, etc.
EDIT
this worked for what I needed, a slight mod to @OrbMan great answer...
SELECT
STATS_DATE(...
I have added a bounty to this as I have, as yet been able to figure this out and time is out.
The below stored procedure will not allow me to add it to Modify it. When attempting to modify it I get the following error -->
Msg 213, Level 16, State 1, Procedure spPersonRelationshipAddOpposing, Line 51
Insert Error: Column name or n...
I am trying to copy a database from one server to another in id different location, including all the schema, data, DTS Package and Scheduled Jobs.
I used Redgates SQL Packager to pack the schema and data.But I am having trouble in packing the DTS Package (which is a very complex one) in simpler way.Please advice!
...
I'm building a web app that attempts to install/upgrade the database on App_Start.
Part of the installation procedure is to ensure that the database has the asp.net features installed. For this I am using the System.Web.Management.SqlServices object.
My intention is to do all the database work within an SQL transaction and if any of it ...
I am creating a SQL CLR assembly that needs to use a Third Party assembly inside it. The trouble is I cannot reference this assembly as only ones already deployed to SQL or other SQL project references are allowed.
Is it possible to use 3rd party assemblies in a SQL CLR assembly and if so how?
Thanks in advance.
...
I have a Master File table on a server(A). Data is first replicated to a central server(B) and then to all of our locations(C). Then from C->B->A
A = Sql 2005
B = SQL 2005
C = Sql 2000
My issue is that data gets all the way to C but replication is set for updates yet I get a Primary Constraint error from C -> B. I set loopback detect...
I have a large DB table which I am using for testing. It contains 7.3m phone call records. I would like to delete many of those, but still maintain a good spread over phone numbers and dates. Is there any way of achieving this? Maybe something to do with table sample?
...
In SQL Server Management Studio (SSMS) running against SQL Server 2005, I have a solution which contains a number of views.
These views are not sorted alphabetically.
Can anyone provide either an explanation of why, or a solution to order them alphabetically ?
...
I got the following error trying to convert from a varchar to varbinary..
Implicit conversion from data type
varchar to varbinary(max) is not
allowed. Use the CONVERT function to
run this query.
and this is the alter command that I tried.
alter table foo Alter column bar varBINARY(max)
So how do I use the convert function...
I'm trying to do something like :
SELECT * FROM table LIMIT 10,20
or
SELECT * FROM table LIMIT 10 OFFSET 10
but using SQLServer
The only solution I found looks like overkill:
SELECT * FROM (
SELECT *, ROW_NUMBER() OVER (ORDER BY name) as row FROM sys.databases
) a WHERE row > 5 and row <= 10
I also found:
SELECT TOP 10 * ...
Is it possible to use SQL Server Management Studio Express 2005 to connect to an MSDE database?
...