Article Row Filter - 2 Parameters
Nov 10, 2006
hello,
i need to filter an article based on a user-supplied datetime filter (the datetime parameter is specified by the subscriber just before replication). at the same time i need to filter again by user (different subscribers get different rows).
i already did the user-based filter using HOST_NAME( ). but the difficulty here (al least i think so) lies in passing 2 parameters to the filter. i cannot rely on using SUSER_SNAME to pass the user filter, because no one will want to create 500 user accounts. so i guess the only solution here is to pass both parameters using only HOST_NAME( ) and then write 2 splitting functions which uses HOST_NAME( ) as its parameter. am i right ?
publisher/distributor is sql server 2005, all subscribers use sql mobile.
TIA, kamil nowicki
View 10 Replies
ADVERTISEMENT
Feb 20, 2007
Hello!
I've begin to do a tutorial of this site: Working with Data in ASP.NET 2.0 c#, but in the 3. step I can't make something:
In this step I can't add parameterized methods to the TableAdapter. The problem come up when I want to add Sql query.
SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, DiscontinuedFROM ProductsWHERE CategoryID = @CategoryID
The error message:
Error in WHERE clause near '@'.Unable to parse query text.
So, how can i use parameter in this method?
tnx for the help
Simpson
View 6 Replies
View Related
Jan 12, 2008
Hi,
I've tried using the same method mentioned in the dozens of posts dedicated to this topic but it's not working.
My SQL statement is:
SELECT [University Origins].Origin, COUNT([University Origins].Origin) AS TotalCount, Hospitals.Name
FROM Posts INNER JOIN
Hospitals ON Posts.HospitalID = Hospitals.[Hospital ID] CROSS JOIN
[University Origins] INNER JOIN
Incumbents ON [University Origins].[Uni Origin ID] = Incumbents.[University Origin]
WHERE (NOT ([University Origins].Origin = 'No answer')) AND (Hospitals.Name IN (@HospitalFilter))
GROUP BY [University Origins].Origin, Hospitals.Name
The HospitalFilter parameter is set to Multivalue and it's populated with it's own SQL statement giving the Distinct Hospitals.
I have setup a filter on my table with the following expressions:
Expression: =Trim(Fields!Name.Value)
Operator: = IN
Value: =Trim(Parameters!HospitalFilter.Value.ToString )
I have used Trim to remove leading and trailing spaces.
Running the report always returns zero results and I'm puzzled by this. Would appreciate any advice and suggestions
Thanks,
John
View 8 Replies
View Related
Jul 24, 2007
how do i add parameters like this dynamically? do i need to change the select command? to add the @ID part?
View 4 Replies
View Related
Jul 7, 2015
I have a report I'm working on that provides a census of members. These members have certain properties;
Load date,Report Type,Clinic,Care Manager,PCP Name.
The census is from an outside group and what I do is massage it for our internal databases and reports to our care managers.
The report starts out by returning only those entries that were received in the last report from the outside vendor and I filter each of the parameters by using a WITH statement and an INNER JOIN, as follows;
WITH Date_of_Most_Recent_Census AS
(
SELECT
MAX(Load_Date) AS [CurDate]
FROM
Census_Rpt_Final
)
[Code] ...
The default is for all parameters to start out with all possible values for the current load date. But, I need to be able to filter the available - and default - values for each parameter based upon the selection of the other parameters.
So, the Load Date is built in by use of the CTE that is a part of all the parameters. But, I need the report to allow the end user to select from each of the others, but limiting what is avaliable for selection based upon the settings of the other parameters.
For example, the second parameter is the Report Type. It can be either "Hospital," or "SNF." But, not all Clinics, Care Managers or PCPs may have an entry in both types. So, if the user selects, say, "Hospital," all the parameters would alter their available and default values such that they only include options where the census shows they are a "Hospital" entry.But, not all Clinics in the most recent census may have both report types. So, if the end user selects a particular clinic, it would also recalculate the available and default values for Report Type, as well as those beneath it on the list. And, likewise for the remainder of the parameters.
My initial thought was to add WHERE statements to the datasets controlling each parameter, but SSRS keeps asking me to define the parameters when I click out of the dataset's properties. Now, I know that SSRS is a single pass process - and, I'll cross the bridge on adjusting parameters defined earlier in the list when I come to it - but I thought that parameters lower in the list would update, since they'd have their values defined.For instance, the Clinic parameter is after Report Type, so the code I used to set up Clinic was;
WITH Date_of_Most_Recent_Census AS
(
SELECT
MAX(Load_Date) AS [CurDate]
FROM
Census_Rpt_Final
)
SELECT DISTINCT
[code]....
But, this asks me to define @ReportType, even though it precedes Clinic on the parameter list.
View 2 Replies
View Related
Mar 2, 2006
SQL 2005 Dev
How can I do this with Parameters? I can get a single parameter to filter for a single date (or even a combo list of the dates in DB). But I want my parameters to interact so that they specify a range. Is this possible?
View 3 Replies
View Related
Apr 15, 2008
Hello,
Here is my problem:
I use SQL Server 2005. I have approx. 50 tables in my database and 30 of them have a filed named "CompanyID". Example:
create table A (ID int identity, NAME varchar(100), COMPANYID int)create table A (ID int identity, REF_ID int, FIELD1 varchar(100), FIELD2 varchar(100), COMPANYID int)
Also there are nearly 200 stored procedures that read data from these tables. Example:
create procedure ABCasbegin /* some checks and expressions here ... */ select ... from A inner join B on (A.ID = B.REF_ID) where ... /* ... */end;
All my queries in the Stored procedure does not filter the tables by CompanyID, so they process the entire data.
However, now we have a requirement to separate the data for each company. That means that we have to put a filter by CompanyID to each of those 20 tables in each query where the tables appear.
Firstly, I put the CompanyID in the context so now its value is accessible through the context_info() function. Thus I do not need now to pass it as a parameter to the stored procedures.
However, I don't know what is the easiest and fastest way to filter the tables. Example:
I modified the above mentioned procedure in the following way:
create procedure ABCasbegin /* some checks and expressions here ... */
-- gets the CompanyID from the context: DECLARE @CompanyID int; SELECT @CompanyID = CONVERT(float, CONVERT(varchar(128), context_info()))
select ... from A inner join B on (A.ID = B.REF_ID) where ...
and A.COMPANYID = @CompanyID and B.COMPANYID = @CompanyID /* ... */end;
Now I have the desired filter by CompanyID. However, modifying over 200 stored procedures is rather tedious work and I don't think that this is the best approach. Is there any functionality in SQL Server that can provide the possibility to put an automatic filter to the tables.
For example: when I wrote "SELECT * FROM A", the actual statements to be executed would be "SELECT * FROM A WHERE CompanyID = CONVERT(float, CONVERT(varchar(128), context_info()))".
I was looking for something like "INSTEAD OF SELECT" triggers but I didn't manage to find any answer.
I would very grateful is someone suggests a solution for something like "global table filter" (that will help me make an easy refactoring)?
Thanks in advance.
Best regards,
Beroetz
View 5 Replies
View Related
Jan 26, 2006
Howdy,
I have a table that has a group. In this group, I want to filter by 2 different expressions, concatenated with an OR. BUT I can't change the "And/Or" column value for the first entry because it is grayed out. The column will automatically change to an OR value if both my expression column fields are the same (which I don€™t want) but if I put any other value in to the expression field of the second row, the "And/Or" field of the first row automatically changes to an AND.
PLEASE! How do I get the And/Or field "ungrayed" so I can change it to what I want?
The 2 filters I and using check the UserID = to the user, and the other is checking a count to get the Top N 1. (So just showing the current user and the top producer)
View 14 Replies
View Related
Jan 9, 2004
Tech firms defend moving U.S. jobs overseas (http://www.msnbc.msn.com/default.aspx?id=3899043&p1=0)
Any thoughts or comments?
View 14 Replies
View Related
Aug 8, 2006
I am experiencing the behaviour described in this kb article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;825019
but I am reliably informed that both the sql 2000 boxes which are linked have been patched to sp4.
Has anyone had any experience of this issue recurring post patching?
View 1 Replies
View Related
Dec 23, 2004
Hi,
I'm use MSSQL2000 SP3 with replication.
I want to know that Can i add new article to existing publication by
Enterprice Manager ?
someone told me that we can do that in older version but not now,right? :confused:
View 1 Replies
View Related
Feb 2, 2006
MS has post a KB article on how to post a question on a online forum...
http://support.microsoft.com/kb/q555375
At first I though this was hilarious, but there is actually some good information in here that is applicable on this forum as well as anywhere else. Perhaps Brett could add this as a sticky?
Regards,
hmscott
View 2 Replies
View Related
Jun 19, 2008
Dear All,
i'm in the transactional replication environment. we need to add one new table to the publisher. it is sql server 2005 environment. please explain me the steps
and in another table, i need to change the data type of a table.
please guide me
Arnav
Even you learn 1%, Learn it with 100% confidence.
View 15 Replies
View Related
Oct 31, 2007
hi
i'm new to replication. i'm looking for a full article that explains Replication good, can u take a link to that article ?
thanks
View 5 Replies
View Related
Mar 8, 2006
Hi:
If I want to unpublish an article thru Enterprise Manager, it does not allow me to uncheck it at publication properties. It only allows me to uncheck articles if I delete the subscription first. Does anybody know how tp do this in Enterprise Manager without deleting the subscription?
Thanks
View 3 Replies
View Related
Oct 14, 2014
Here's what my script boils down to when adding a new view (admin.replication_test):
Code:
EXEC sp_addarticle
@publication = N'<publication name>'
, @article = N'replication_test'
, @source_owner = N'admin'
, @source_object = N'replication_test'
, @type = N'view schema only'
;
If I check the GUI, the article appears to be ticked in the publication.
Generate a new snapshot.
View not found in replicated database!
View 9 Replies
View Related
Oct 9, 2007
hi guys,
im new to sql server...
i am currently studying sql server 2000
i know this subject has been asked before...
i would just like to ask if you know some related articles regarding advantages of using sqlserver over vfp dbf/dbc?
i am going to discuss it to my class.
thanks very much!
any help is very much appreciated!
Joel
View 4 Replies
View Related
Mar 27, 2008
how to add new article within the existing replication
View 1 Replies
View Related
Jun 2, 2006
Hi There
I hope someone can help me asap.
I need to alter a column on a replicated table.
So i execute sp_dropsubscription and sp_droparticle for the table for all publication to that article in the database.
Usually i just alter the table and then execute sp_adddarticle and sp_addsubscription afterwards and everything is cool.
However in this case after i drop the subscriptions for the article, when i try alter the table it says it is being replicated.
I query sysobjects and see that the table has replinfo = 1 , this is snapshot replication, but i only have transactional replication ? I used to have snapshot but that was dropped long ago.
I then query sysarticles and i find the table, however the pubid (publication id) for the table is equal to the publication id of another databases publication ??? I also have found in sysarticles articles with a publication id's equal to publications that do not exist, for example articles will have pubid of 2 , but if i run sp_helppublication on all user databases there is no publciation with an id of 2 ?
Please help, even after i drop all subscriptions to an article it seems that sql server thinks the article belongs to another databases publciation or publications that no longer exist?
Maybe there is some sort of cleanup sp i can run or something but it seems to me sql server has gotten articles confused with old deleted publications that no longer exist.
Therefore after dropping all subscriptions i still cannot alter tables as sql server think it is still being published but it is not!
Thanx
View 4 Replies
View Related
Oct 24, 2007
Hi,
I'm setting up Transaction Replication b/w SQL Server 2K and SQL Server 2K5.
I have published Tables, Views and SPs as articles.
When I try to modify the published Stored procedure, the changes are not replicated.
When I Reinitialize the Subscription and start the Snapshot agent, it is copying the changes
made. But all articles are reinitialized again, So it takes huge time to do this.
Is there any way to just reinitialize only the changed article?
Or Is there any work around for this problem?
Than
View 1 Replies
View Related
Nov 3, 2006
The chapter from my book that talks about upgrading packages from DTS to SSIS has been posted here : http://www.quepublishing.com/articles/article.asp?p=605035&rl=1
Didn't even know it until I happened to be doing a search on upgrading and the article popped up in the search...
How funny is that! :)
Hope it helps.
View 2 Replies
View Related
Sep 26, 2007
the msdn article explains how to input new data to a databse and return the primary key of the inputted row. It works perfectly. However, it explains how to insert a value, but there is a problem. It seems to set the value to be submitted in the VB code, instead of having the value be the user's input in the textbox. Look for the following line in the code below: newRow("ClientFileNumber") = "ClientFileNumber" It inputs "clientfilenumber" instead of what is actually inputted in the texbox. Does anyone know how to bypass this, to not have the words "clientfilenumber" inputted?Dim sqlconn As SqlConnection = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Client.mdf;Integrated Security=True;User Instance=True")
Dim catDA As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM Orders", sqlconn)
catDA.InsertCommand = New SqlCommand("JobInsert", sqlconn)
catDA.InsertCommand.CommandType = CommandType.StoredProcedure
catDA.InsertCommand.Parameters.Add("@ClientFileNumber", SqlDbType.VarChar, 50, "ClientFileNumber")Dim NewJobNumber As SqlParameter = catDA.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "OrdersID")
NewJobNumber.Direction = ParameterDirection.Output
sqlconn.Open()
Dim catDS As DataSet = New DataSetcatDA.Fill(catDS, "Orders")
Dim newRow As DataRow = catDS.Tables("Orders").NewRow()
newRow("ClientFileNumber") = ""catDS.Tables("Orders").Rows.Add(newRow)
catDA.Update(catDS, "Orders")
sqlconn.Close()
Response.Redirect("control_page_copy.aspx?NewJobNumber=" + NewJobNumber.Value.ToString())
View 1 Replies
View Related
Jun 2, 2006
Hi,
I'm building a straightforward-ish news site. Currently, the story details (e.g. headline, description, author, date) are stored in a SQL DB. The news is categorised and the category details are also stored in an SQL table.
However - what is the best way to store the actual news article?
At the moment, when the user enters a story, they input the details and article text. The details are saved in the DB and the text is saved as an XML file with filename corresponding to the article DB primary key. When the story is "read" the app pulls the details from the DB and loads up the appropriate XML file from disk.
For various reasons, I need to keep the article stored as XML, either in a file or in the DB. The DB provides for faster sorting and retrieval, and I don't want to store large amounts of data (i.e. the article itself) in the DB if avoidable.
I guess there are a few ways to do it -
1. Store details in DB and article as XML file.2. Store details and article in same DB table3. Store details in one DB table and articles in another
I would imagine that 3 would be the best, but would there be a performance hit? What is the maximum size of field (i.e. article size) I can have in a table?
Cheers
Graham Wilson.
View 3 Replies
View Related
Feb 3, 2001
Hi,
It would be very nice if some people out there, using merge replication can tell me their strategy to add Article through Enterprise Manager.
I have Merge Replication, I have new table which has to be replicated. I counld not find options in Wizard to add New article for replication.
Any Help will be appreciated.
Thanking you in anticipation
Cheers
Hemant
View 1 Replies
View Related
Dec 9, 2002
We're replicating columns in a table from 7.0 server to SQL2k server. Once we've got the data on SQL2k, we were able to take advantage of DTS that was not available in version 7.0.
I recenlty added a column to the article and changed the DTS accordingly (transformation columns). However, I'm getting this error ever though I added the new column in the DTS.
-------
The number of columns in the bcp file does not match what is defined in the DTS package. Regenerate the package.
-----
I've recreated the package with no luck. This is becoming urgent as it's supposed to go into production soon.
Please help!!
Thanks,
Colleen
View 2 Replies
View Related
Feb 11, 2005
Hi All,
I am having a server where replication is set up between 2 differnt databases. It is currently running. I want to add a couple of tables to the replication. I tried using sp_addArticle, but after executing it, in the properties of the publication it shows the new tables, but at the database level the tables are missing.
I tried with sp_addsubscription but I am getting strange error:
Server: Msg 14100, Level 16, State 1, Procedure sp_addsubscription, Line 240
Specify all articles when subscribing to a publication using concurrent snapshot processing.
What can I do to publish the tables into the target database?
Thanks in advance.
View 5 Replies
View Related
Apr 22, 2004
I am running merge replication (SQL 2000 with SP2) with an anonymous pull subscription. The application vendor has come out with update that requires adding a table to a database. The vendor has created scripts that will add the table, as well as some stored procedures. If I apply the scripts to both servers and add the table as a new article to the publication, am I going to have to apply a snapshot of the entire database (which is very large)?
Your help is greatly appreciated.
Gary
View 3 Replies
View Related
Apr 29, 2004
Hello folks!
I'm looking for a good article about Indexed Views.
Cheers!
Rafael
View 1 Replies
View Related
Dec 13, 2005
RD writes "Do you have a comparative article on SQL Express and MS Access?"
View 2 Replies
View Related
Jul 23, 2005
I posted a link to a prior article in here, that one about highperformance hierarchies, and have the first two parts of a new series.Hopefully this is of value to someone.http://www.yafla.com/papers/SQL_Ser..._sql_server.htmThanks.
View 1 Replies
View Related
Jun 5, 2006
I've uploaded a new version of my article on Dynamic Search Conditionson http://www.sommarskog.se/dyn-search.html. I've revised the article tocover SQL 2005, and made a general overhaul of the content. There was a*very* embarrassing error that I've corrected.I've also added a new interesting method for static SQL. I've found that ifyou say:SELECT ...FROM tblWHERE (key1 = @key1 AND @key1 IS NOT NULL)OR (key2 = @key2 AND @key2 IS NOT NULL)OR (key3 = @key3 AND @key3 IS NOT NULL)This will use indexes if all columns are indexed, and furthermore SQLServer will decide at run-time which index(es) to access. The articleincludes a trick where you can combine this with the normal conditions fordynamic searches for very good performance under some circumstances.I also cover the new OPTION (RECOMPILE) to force statement recompile.I was hoping that it could lead to just as good query plans as dynamicSQL, but it's far cry from that.--Erland Sommarskog, SQL Server MVP, Join Bytes!Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/pr...oads/books.mspxBooks Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodin...ions/books.mspx
View 3 Replies
View Related