I am currently writing a script that intelligently strips a database down into a series of ordered INSERT statements with seeded identity columns that will allow me to place the records into a new database without destroying any keys or relationships.
I am using the PRINT function to write the finished insert statements to the message w...
Using either a view and/or stored procedure, I can return the results of executing an MDX query against SQL Analysis Services (using OPENROWSET against a linked SSAS Server into SQL).
Unfortunately, the resultset doesn't include a PK field...or for that matter, even a column which COULD act as a PK if I were to hack the model.
Can an...
I have a query which returns a set of numbers:
SELECT Sequence FROM Table1 WHERE Hash=2783342
Returns:
578
642
313
Now, I want to find all rows in the first table where any of that set of numbers is between two other columns. For the purpose of illustration, I am just picking 578, but I also want all of the rest:
SELECT * FROM Tab...
Simplifying what I'm doing somewhat, as an example, say I have the following tables:
declare @elements table (id int, name nvarchar(20))
insert into @elements (id, name) values (1, 'FirstName')
insert into @elements (id, name) values (2, 'Surname')
insert into @elements (id, name) values (3, 'Address')
declare @values table (id int, v...
For example, say I have this SQL Script:
create table Person
(
id int primary key,
name nvarchar(40)
)
create table Country
(
id int primary key,
name nvarchar(40)
)
How can I have those commands in a single file and be able to run it?
...
I'm running a Windows 7 VM via Parallels on OSX. There's an instance of SQL Server running on that VM. I would very much like to be able to connect to that instance from my host (OSX). I want to be able to leverage my local RoR environment with SQLServer as a backend.
I can't get the VM to respond to any requests from my Mac and I ha...
Hi Gurus
I'm using Microsoft .NET Framework 3.5 to create a web service with VB.NET. I'm using a Stored Procedure in SQL Server 2008 so that SQL can insert all the data that I'm passing.
The problem is that in one of the servicse I need to pass around 10,000 records and it's not very efficient to run the stored procedure 10,000 times.
...
Here's what I have so far:
create table rubro (
id_rubro int primary key,
nombre_rubro nvarchar(150)
)
go
create table cliente (
id_cliente int primary key,
direccion nvarchar(400),
telefono int,
nit int
)
...
i would like to be able to access a database from a remote machine
should i be adding a username in this prompt? if so, where do i input the password? i do not see the dialogue where i can assign a password for a username? or maybe i can just use existing usernames?
...
I'm trying to run this SQL script but it's not working. It says there is an error near the GO text.
create table rubro
(
id_rubro int primary key,
nombre_rubro nvarchar(150)
);
GO
create table cliente
(
id_cliente int primary key,
direccion nvarchar(400),
telefono int,
nit int
);
...
I need to export database from one server and import it into another server.
How do I export the entire database to a file, or two files mdf, ldf (either option is fine)
How do I import it into a new server using ssms?
In the instructinos frmo ponies, it says:
In the To a point in time text box,
either retain the default (Most ...
In MSSQL 2008 how can I query for tables with foreign key references to a specific table column?
Let's say I have a table called Audit with an int column called 'ID".
How can I find all the tables in my database that have a foreign key to Audit.ID ?
...
I need to know of a way to combine multiple SELECT statements in one VIEW? I tried the UNION ALL, but it fails since I am using unique columns to aggregate the GRAND TOTAL.
I am a student this is part of a group project.
I have one table with 4 columns: account, description, short_description, and balance. The COA (chart of accounts) i...
I am trying to restore a DB
I am getting this prompt, however I am unable to point to a database to restore from
Has anyone else experienced this horrific problem?
...
I am using the following syntax:
Case
When acdtime != 0 Then sum(CAST(ti_stafftime as DECIMAL)/acdtime)*100
Else '0'
End as MyPercent,
Yet I am still getting this error:
Msg 8134, Level 16, State 1, Line 3
Divide by zero error encountered.
What am I doing wrong here?
My whole query is below:
Select
logid,
row_date,
...
Hi Guys,
Need help with the pivot clause in sql server 2008.
I have a table with this info:
Weekno DayOfWeek FromTime ToTime
1 2 10:00 14:00
1 3 10:00 14:00
2 3 08:00 13:00
2 4 09:00 13:00
2 5 14:00 ...
I want to order SQL Inserts into a table to optimize page use by avoiding fragmentation as much as possible.
I will be running a .net Windows Service, which every 2 hours will take some data from a database and optimize it
for future queries. A varchar(6000) column is involved, though I estimate it will rarely go beyond 4000 bytes.
In f...
I just noticed two months after switching out a backup drive that one table in one of the backed-up databases is losing records past a certain point.
The database is backed up weekly.
Prior to the new drive, the table had records from 3/11/2010 to 6/8/2010.
After the first backup ran, the table was missing all records past 3/11/2010,ex...
Greetings,
How to create duplicate table (structure only) with new name in the same database in SQL Server 2008?
I have table with 45 fields so I want to create new with same structure but new name.
I do not want to copy the data!!
Thank you,
...
I have defined a SQL server bootstrapper in the .wixproj file:
<BootstrapperFileV7 Include="Microsoft.Sql.Server.Express.10.0">
<ProductName>Sql Server Express</ProductName>
</BootstrapperFileV7>
And the pre-requisite check in the .wxs file:
<PropertyRef Id="NETFRAMEWORK35_SP_LEVEL" />
<Condition Message="This setup requires the .N...