I have a table of users profiles. Every user can have many profiles and the user has the ability to arange the order of how they will be displayed in a grid.
There are 2 tables Users and Profiles (1:M)
I've added a orderby column to the Users table where will be values like 1,2,3..
So far it seems to be okay. But when a user will chan...
I'm writing a fairly long running script, which prints progress messages as it goes.
However, SQL Server Management Studio by default shows the resultset tab, not the messages tab, so the user will have to click the messages tab after starting the script to see the progress as it happens.
Is there a way for my script to tell SSMS to s...
It what should be a simple task, or a simple google search, I have come up empty. I am trying to simply calculate a grade percentage. I am trying to use:
Select round((133 / 150), 2) * 100
That results in 0. I am trying to calcualte to get a score of 89%. I have tried multiple combinations and I am beginning to think it is either too ...
Is it possible to pass parameters to a SQL Server script? I have a script that creates a database. It is called from a batch file using sqlcmd. Part of that SQL script is as follows:
CREATE DATABASE [SAMPLE] ON PRIMARY
( NAME = N'SAMPLE', FILENAME = N'c:\dev\SAMPLE.mdf' , SIZE = 23552KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LO...
if you are running a query that inserts a new set of records in a table from other one, there is a way to force the update of the coincident pk record in the destination table, without deleting records or split the process in two others (insert new and update existing)?
...
FastDB is an open-source, in-memory database that's tightly integrated with C++ (it supports a SQL-like query language where tables are classes and rows are objects). Like most IMDBs, it's meant for applications dominated by read access patterns. The algorithms and data structures are optimized for systems that read and write data entire...
I have a table that looks like this:
Slug | Parent | MetaTitle | MetaDescription | MetaKeywords
The Url's on the site are built by appending the slug to the parent as long as the parent is not null. So if I have data like so:
Slug | Parent
-----------------------------------------
Home null
About n...
Hi All,
I am in a situation where I need to find the Changes happened to the database since last migration.
Eg: Changes happened to the Stored Procedure,and Views and functions.
How Can I find these Changes.
We are not using any third Party Tools.
Please can any one help me out on this.
Thanks in Advance.
Venkat
...
I have two databases, with the following tables:
DatabaseA
TableA
ColumnA (varChar(10)
DatabaseB
TableB
ColumnB (varChar(10)
I need a query that:
Ignores NULLs or empty strings
Finds rows where the value of ColumnA does not exist in columnB
In this case, replaces the value of the non matching row in ColumnA with '' (empty string)...
Which of the following two statements would you consider to be the most effective for deleting large number of rows?
Statement #1:
DELETE TOP (@count) FROM ProductInfo WHERE productId = @productid
Statement #2: Derived table
DELETE t1 FROM (SELECT TOP (@count) * from ProductInfo
WHERE productId = @productId v) t1
...
What is wrong with the syntax in this function? I am getting the following errors:
ALTER FUNCTION [dbo].[udf_ReportingLevelStructure2]
(
@CompanyID INT
)
RETURNS @result TABLE
(
CompanyName VARCHAR(300),
[rl_Index] INT,
[rl_Addr1] VARCHAR(MAX),
[rl_Addr2] VARCHAR(MAX),
[rl_DisplayName] VARCHAR(MAX)
)
AS
BEGIN
...
I've got a stack of Models something like this (I'm typing it out in relative shorthand):
class User:
pass
class ItemList:
pass
# A User can have more than one ItemList
# An ItemList can have more than one User
# Classic M2M
class ItemListOwnership:
user = fk(User)
itemlist = fk(ItemList)
# An ItemList has multipl...
When would you use an output parameter vs a return variable, or vice versa? In the following simple example, I can achieve the same thing using either one.
Using output parameter
create proc dbo.TestOutput (@InValue int, @OutValue int output)
as
set @OutValue = @InValue
declare @x int
exec TestOutput @InValue = 3, @OutValue = @x outpu...
I have a dataset that gets populated from a stored proc in sql server. I have a column that has lets say has a set of values. I do not know what those values are. All I know is that they of the type "string". I want to extract all the distinct values from that column.
...
I'm selecting columns from one table and would like to select all values of a column from a related table when the two tables have a matching value, separate them by commas, and display them in a single column with my results from table one.
I'm fairly new to this and apologize ahead of time if I'm not wording it correctly.
...
HI,
I have query like this
final Query contractQuery = cgnDao.getEntityManager().
createNativeQuery("SELECT k.phrase, ak.type FROM key k INNER JOIN adkey ak USING (key_id) WHERE pck.pub_id =" + pid +" AND pck.c_id =" + campId );
How can i get each and every element from the query?
Where phrase is an String and type is...
I'm using the following code to generate a list of all wordpress blogs in my wordpress mu network:
$blogs = $wpdb->get_results("SELECT * FROM " . $wpdb->blogs . " WHERE last_updated!='0000-00-00 00:00:00' AND public='1' AND spam = '0' AND deleted ='0' ORDER BY registered " . $order . " LIMIT " . $limit);
How do i do to order them ...
I know Oracle RDMS can't merge a view that has a set operator in it. I want to know why is that.
For example, this:
SELECT u.*
FROM
(
SELECT a.a1 A,
a.a2 B
FROM tab_a a
UNION ALL
SELECT b.b1 A,
b.b2 B
FROM tab_b b
) u,
tab_p p
WHERE p.a = u.a
could be transformed into this:
SELECT *
FROM
...
I want to remove all special characters (",/{}etc.) from an input field being saved as a string to the DB.
What is the best approach?
Should this check be tackled with JS, ColdFusion or Microsoft SQL - Maybe all three?
How would I go about coding this using ColdFusion or Microsoft SQL?
...
I need to add a autonumber column to an existing table which has about 15 million records in SQL 2005.
Do you think how much time it'll take? What's the better way to do it?
...