sql-server

SQL Server Error: maximum number of prefixes. The maximum is 3.

Trying to run a cross-server update: UPDATE cmslive.CMSFintrac.dbo.lsipos SET PostHistorySequencenNmber = ( SELECT TransactionNumber FROM Transactions WHERE Transactions.TransactionDate = cmslive.CMSFintrac.dbo.lsipos.TransactionDate) Gives the error: Server: Msg 117, Level 15, State 2, Line 5 The number name ...

Tool to visualize SQL Cascade tree

Is there a tool that will let you visualize a SQL Server 2008 cascade tree? I'm having troubles with items not being able to be deleted and I would like to see the path that SQL takes. ...

SQL Server: Difference between PARTITION BY and GROUP BY

I've been using GROUP BY for all types of aggregate queries over the years. Recently, I've been reverse-engineering some code that uses PARTITION BY to perform aggregations. In reading through all the documentation I can find about PARTITION BY, it sounds a lot like GROUP BY, maybe with a little extra functionality added in? Are they ...

Fact table with multiple facts

I have a dimension (SiteItem) has two important facts: perUserClicks perBrowserClicks however, within this dimension, I have groups of values based on an attribute column (let's call the groups AboveFoldItems, LeftNavItems, OnTheFlyItems, etc.) each have more facts that are specific to that group: AboveFoldItems: eyeTime, loadTime...

How do I use BCP or Sql Server Management Studio to get BLOB data out of Sql Server?

I'm sorry if this question has been asked already, but I couldn't find it anywhere. I have a table that stores files as BLOBS. The column that holds the file is an image datatype. I would like to be able to extract the binary data out of the column and turn it in to an actual file. I would ideally like to be able to do this with BCP o...

how can i have a unique column in many tables

hi. I have ten or more(i don't know) tables that have a column named foo with same datatype. how can i tell sql that values in all the tables should be unique. I mean If(i have value "1" in table1) I should NOT be able to have value "1" in table2 ...

Simple regex question (C#, SQL Server)

Hello, I have some Regex, it looks like this: string regexForDrop = @"^((%27)|'|(\-\-))\s*(d|%64|%44)(r|%72|%52)(o|%6F|%4F)(p|%70|%50)$"; It works fine, when i write to the input "--drop", but it does not works, when i write "drop table users" or something like that. I need that it would be working, no matter what comes after "--drop"...

How to grant permissions to single SELECT/UPDATE statment (sql server) ?

I have a problem when trying to execute this update statement (below) using C# SqlCommand when I execute it locally it works fine, but when deployed to another machine I got a permission error The SELECT permission was denied on the object Order ... The UPDATE permission was denied on the object Order ... Update Statement UPDATE Orde...

Multiple Table Joins to Improve Performance?

If I have a table structure like this: Transaction [TransID, ...] Document [DocID, TransID, ...] Signer [SignerID, ...] Signature [SigID, DocID, SignerID, ...] And the business logic is like this: Transactions can have multiple documents Documents can have multiple signatures And the same signer can have multiple signatures in mu...

Scheduled export of database structure (table, view, sp) to file

I'm using SQL 2005. I can right click on a database and create scripts for the database that will recreate the structure (tables, views, stored procedures) elsewhere. Or just as a backup, version, etc. But, is there a way I can schedule it to do this? And output to a folder I choose? I really appreciate the help. Don ...

Export products and variants from SQL Server

I have a SQL Server DB that has a table of products, and another table which contains a list of the sku variants of each product if it has one. I want to export all the products and their SKU's into excel. At the moment, I have a helper SQL function which performs the subquery against a product_id and concatenates all the SKU's into a c...

Store Image data type using PHP

I have SQL Server with following table : table PROMO, column: code , varchar(10) name , varchar(10) image_data, image desc , text How to insert image file as binary into sql server using PHP PDO? the image will be stored in column image_data EDIT: What type of variable should I pass to the PDO parameter $stmt = $conn->prepare($qu...

How to configure replication? - This database is not enabled for publication.

Hi, I'm trying to configure repication on SQL Server 2005. I can done it using wizard. But when I'm trying to run generated scripts by this wizard the error message appears: Msg 14013, Level 16, State 1, Procedure sp_MSrepl_addpublication, Line 159 This database is not enabled for publication. Msg 18757, Level 16, State 1, Procedure sp...

SQL Server Conditional Foreign Key Constraints

I'm having trouble figuring out how to create a foreign key constraint. My data model is fixed and out of my control, it looks like this: CREATE TABLE Enquiry (Enquiry_Ref INTEGER PRIMARY KEY CLUSTERED, Join_Ref INTEGER, EnquiryDate, EnquiryType...) CREATE TABLE Contact (Contact_Ref INTEGER PRIMARY KEY CLUSTERED, Surname, Forenam...

condense logic down to one Sql query

first is the disclaimer, I did not design the database I am now supporting and I would not have designed it this way, but here I am. Problem: My client has a table in his database that contains listings for rentals. In this table is a text field to store the city of the listing. What my client is hoping to see is a dropdown list of all ...

ODBC query on MS SQL Server returning first 255 characters only in PHP PDO (FreeTDS)

I'm currently trying to pull some data from a SQL Server database view that we have restricted access to from our Linux web server. We don't need to edit the data just display it in a webpage. It all looks fine until we try to output and only get the first 255 characters of a text field. Does anyone know if this is a problem with usin...

Send bulk email from SQL Server 2008

Hi, I am relatively new to databases,so please forgive me if my query sounds trivial. I need to send bulk email to all the contacts listed in a particular table. The body of the email is stored in a .doc file which begins as Dear Mr. _. The SQL server will read this file, append the last name of the contact in the blank space and send it...

Problem with simple select query to find dates in SQL Server

I use simple query to get dates of contract for a person: SELECT [KlienciUmowyDataPoczatkowa], IsNULL([KlienciUmowyDataKoncowa], GETDATE()) AS 'KlienciUmowyDataKoncowa' FROM [BazaZarzadzanie].[dbo].[KlienciPortfeleUmowy] WHERE [PortfelID] = 3 This is what I get: KlienciUmowyDataPoczatkowa KlienciUmowyDataKoncowa 2005-11-...

Sort order of aspnet_Users table

I am wondering if the aspnet_Users table is always sorted (by UserName) even if I add new users which are alphabetically between two already existing users. I've noticed that the method Membership.GetAllUsers() always seems to return a sorted collection of MembershipUsers. Also when I look into SQL Server Management Studio and run a si...

How to delete rows from tables which is referenced each other?

I want to do this: delete from table1 a,table2 b, table3 c where a.col1 = b.col1 and b.col2 = c.col2 and a.co3 <> 8001; But its giving me an error. ...