Showing posts with label column. Show all posts
Showing posts with label column. Show all posts

Sunday, March 25, 2012

Analysis server cube Performance through Excel 2007

Hello Everybody

I am accessing Analysis server cube -2005 through Excel 2007 for building reports. When ever i select a row or column right click and select Filter > Hide Selected Items, it will show "running query on the OLAP server" at bottom and will not respond after that.

Ran the MDX generated by Excel 2007 directly on analysis server, even then also it takes lot of time and finally it doesnt respond. I read in the forum that the sql generated by Excel 2007 is different. how can i tweak in so that cube performance improves ?

Thanks
Kiran

Hi Kiran,

Do you have old AS 2000 to compare performance? The reason I am asking this because you can check if you have same aggregation setup in AS 2005 cube. If you don't have old cube to compare try creating aggregation on AS 2005 cube. Also you can check profiler, performance counter etc.

-Ashok

sql

Monday, March 19, 2012

An issue with Full Text Search against PDF blobs...

My client is trying to use SQL Server Full Text Search to search PDFs stored
in a varbinary(max) column. Full text search works fine for other Microsoft
Office documents stored in the same table but it does NOT give back any
results from the PDF documents.
Following is a high-level view of what the client did:
1. Installed Adobe PDF IFilter 6.0
2. Ran the stored procedure sp_fulltext_service (as documented)
3. Restarted the server
4. Verified that the filter got properly installed by querying the system
view
sys.fulltext_document_types
5. Created a full text index on the table with the documents
6. Started a full population of the index
7. Ran a sample query with a string he knows is in the PDF file like the
following:
select * from documents where freetext(document, ‘Review’) and got no
results
back
8. Ran the same sample query with a string he knows is in some Word files
like the
following: select * from documents where freetext(document, ‘SQL’) the
query
returned several rows back as expected.
Does anybody know what might be happening here?
Thank you!
Camilo Leon
Camilo,
Are you using 64-bit Windows and SQL Server? If so, last time I looked the
Adobe PDF IFilter was only 32-bit.
RLF
"Camilo" <Camilo@.discussions.microsoft.com> wrote in message
news:92BEFB18-89BF-4C7E-8B11-769B0C329B7B@.microsoft.com...
> My client is trying to use SQL Server Full Text Search to search PDFs
> stored
> in a varbinary(max) column. Full text search works fine for other
> Microsoft
> Office documents stored in the same table but it does NOT give back any
> results from the PDF documents.
> Following is a high-level view of what the client did:
> 1. Installed Adobe PDF IFilter 6.0
> 2. Ran the stored procedure sp_fulltext_service (as documented)
> 3. Restarted the server
> 4. Verified that the filter got properly installed by querying the system
> view
> sys.fulltext_document_types
> 5. Created a full text index on the table with the documents
> 6. Started a full population of the index
> 7. Ran a sample query with a string he knows is in the PDF file like the
> following:
> select * from documents where freetext(document, 'Review') and got no
> results
> back
> 8. Ran the same sample query with a string he knows is in some Word files
> like the
> following: select * from documents where freetext(document, 'SQL') the
> query
> returned several rows back as expected.
> Does anybody know what might be happening here?
> Thank you!
> Camilo Leon
>
|||Russell,
No, we are using a 32-bit machine in this case.
I did make FTS work with PDF files by creating a new table, importing the
data, creating a new catalog and populating it again.
Thanks!
Camilo
"Russell Fields" wrote:

> Camilo,
> Are you using 64-bit Windows and SQL Server? If so, last time I looked the
> Adobe PDF IFilter was only 32-bit.
> RLF
> "Camilo" <Camilo@.discussions.microsoft.com> wrote in message
> news:92BEFB18-89BF-4C7E-8B11-769B0C329B7B@.microsoft.com...
>
>
|||Check the gatherer logs to see what the status of your population was.
relevantNoise - dedicated to mining blogs for business intelligence.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Camilo" <Camilo@.discussions.microsoft.com> wrote in message
news:92BEFB18-89BF-4C7E-8B11-769B0C329B7B@.microsoft.com...
> My client is trying to use SQL Server Full Text Search to search PDFs
> stored
> in a varbinary(max) column. Full text search works fine for other
> Microsoft
> Office documents stored in the same table but it does NOT give back any
> results from the PDF documents.
> Following is a high-level view of what the client did:
> 1. Installed Adobe PDF IFilter 6.0
> 2. Ran the stored procedure sp_fulltext_service (as documented)
> 3. Restarted the server
> 4. Verified that the filter got properly installed by querying the system
> view
> sys.fulltext_document_types
> 5. Created a full text index on the table with the documents
> 6. Started a full population of the index
> 7. Ran a sample query with a string he knows is in the PDF file like the
> following:
> select * from documents where freetext(document, 'Review') and got no
> results
> back
> 8. Ran the same sample query with a string he knows is in some Word files
> like the
> following: select * from documents where freetext(document, 'SQL') the
> query
> returned several rows back as expected.
> Does anybody know what might be happening here?
> Thank you!
> Camilo Leon
>

an interesting problem

I manage a news database oriented website where there is a column named
'news' in a table 'news' storing huge HTML formatted artciles. I had to
replace a particular word 'india' by 'world' in all the records under this
column. Strange thing is the occurances of the word 'india' towards the end
of the articles are getting recognized by
select count(*) from news where charindex('india',news)>0
i.e. the above query results 0. Though there are thousands of records in
the column 'news' containing the word 'india'.
I think the issue is of max limit of charindex.
Please help at the earliest convenience of yours.
Regards,
John-I think the issue is of max limit of charindex.
No I don=B4t think so, because Charindex returns an INT, so there should
be a problem if the character would be found at the
2,147,483,648 +1. So are you searching on the right table and database
? That should return a hit, if the word india is present in there.
HTH, jens Suessmeyer.|||John
Did you try LIKE operator?
"John" <netconsul@.gmail.com> wrote in message
news:ePx4t626FHA.1140@.tk2msftngp13.phx.gbl...
>I manage a news database oriented website where there is a column named
>'news' in a table 'news' storing huge HTML formatted artciles. I had to
>replace a particular word 'india' by 'world' in all the records under this
>column. Strange thing is the occurances of the word 'india' towards the end
>of the articles are getting recognized by
> select count(*) from news where charindex('india',news)>0
>
> i.e. the above query results 0. Though there are thousands of records in
> the column 'news' containing the word 'india'.
> I think the issue is of max limit of charindex.
> Please help at the earliest convenience of yours.
> Regards,
> John
>
>
>|||Thats what my problem is.
select news from news where news like '%india%'
results in 74000+ records while
select count(*) from news where charindex('india',news)>0
returns none.
I am using charindex to find the position of India in the record and use
'updatetext' to replace it by world.
because charindex('india',news) returns 0, updatetext cant replace india in
each record by world.
Any quick help will be appreciated.
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1132230042.794270.99970@.g43g2000cwa.googlegroups.com...
-I think the issue is of max limit of charindex.
No I don´t think so, because Charindex returns an INT, so there should
be a problem if the character would be found at the
2,147,483,648 +1. So are you searching on the right table and database
? That should return a hit, if the word india is present in there.
HTH, jens Suessmeyer.|||Hi Everyone,
Solution to my problem lies here.
http://www.aspfaq.com/show.asp?id=2445
Please note that my fear about charindex is correct.
Initially I used CHARINDEX, but that failed if the pattern was deeper than
8,000 characters into the value. PATINDEX never dies. :-)
Thanks
John
"John" <netconsul@.gmail.com> wrote in message
news:eT7LVE66FHA.4076@.TK2MSFTNGP10.phx.gbl...
> Thats what my problem is.
> select news from news where news like '%india%'
> results in 74000+ records while
> select count(*) from news where charindex('india',news)>0
>
> returns none.
> I am using charindex to find the position of India in the record and use
> 'updatetext' to replace it by world.
> because charindex('india',news) returns 0, updatetext cant replace india
> in each record by world.
>
> Any quick help will be appreciated.
>
>
> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1132230042.794270.99970@.g43g2000cwa.googlegroups.com...
> -I think the issue is of max limit of charindex.
> No I don´t think so, because Charindex returns an INT, so there should
> be a problem if the character would be found at the
> 2,147,483,648 +1. So are you searching on the right table and database
> ? That should return a hit, if the word india is present in there.
> HTH, jens Suessmeyer.
>

an interesting problem

I manage a news database oriented website where there is a column named
'news' in a table 'news' storing huge HTML formatted artciles. I had to
replace a particular word 'india' by 'world' in all the records under this
column. Strange thing is the occurances of the word 'india' towards the end
of the articles are getting recognized by
select count(*) from news where charindex('india',news)>0
i.e. the above query results 0. Though there are thousands of records in
the column 'news' containing the word 'india'.
I think the issue is of max limit of charindex.
Please help at the earliest convenience of yours.
Regards,
John
-I think the issue is of max limit of charindex.
No I don=B4t think so, because Charindex returns an INT, so there should
be a problem if the character would be found at the
2,147,483,648 +1. So are you searching on the right table and database
? That should return a hit, if the word india is present in there.
HTH, jens Suessmeyer.
|||John
Did you try LIKE operator?
"John" <netconsul@.gmail.com> wrote in message
news:ePx4t626FHA.1140@.tk2msftngp13.phx.gbl...
>I manage a news database oriented website where there is a column named
>'news' in a table 'news' storing huge HTML formatted artciles. I had to
>replace a particular word 'india' by 'world' in all the records under this
>column. Strange thing is the occurances of the word 'india' towards the end
>of the articles are getting recognized by
> select count(*) from news where charindex('india',news)>0
>
> i.e. the above query results 0. Though there are thousands of records in
> the column 'news' containing the word 'india'.
> I think the issue is of max limit of charindex.
> Please help at the earliest convenience of yours.
> Regards,
> John
>
>
>
|||Thats what my problem is.
select news from news where news like '%india%'
results in 74000+ records while
select count(*) from news where charindex('india',news)>0
returns none.
I am using charindex to find the position of India in the record and use
'updatetext' to replace it by world.
because charindex('india',news) returns 0, updatetext cant replace india in
each record by world.
Any quick help will be appreciated.
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1132230042.794270.99970@.g43g2000cwa.googlegro ups.com...
-I think the issue is of max limit of charindex.
No I dont think so, because Charindex returns an INT, so there should
be a problem if the character would be found at the
2,147,483,648 +1. So are you searching on the right table and database
? That should return a hit, if the word india is present in there.
HTH, jens Suessmeyer.
|||Hi Everyone,
Solution to my problem lies here.
http://www.aspfaq.com/show.asp?id=2445
Please note that my fear about charindex is correct.
Initially I used CHARINDEX, but that failed if the pattern was deeper than
8,000 characters into the value. PATINDEX never dies. :-)
Thanks
John
"John" <netconsul@.gmail.com> wrote in message
news:eT7LVE66FHA.4076@.TK2MSFTNGP10.phx.gbl...
> Thats what my problem is.
> select news from news where news like '%india%'
> results in 74000+ records while
> select count(*) from news where charindex('india',news)>0
>
> returns none.
> I am using charindex to find the position of India in the record and use
> 'updatetext' to replace it by world.
> because charindex('india',news) returns 0, updatetext cant replace india
> in each record by world.
>
> Any quick help will be appreciated.
>
>
> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1132230042.794270.99970@.g43g2000cwa.googlegro ups.com...
> -I think the issue is of max limit of charindex.
> No I dont think so, because Charindex returns an INT, so there should
> be a problem if the character would be found at the
> 2,147,483,648 +1. So are you searching on the right table and database
> ? That should return a hit, if the word india is present in there.
> HTH, jens Suessmeyer.
>

an interesting problem

I manage a news database oriented website where there is a column named
'news' in a table 'news' storing huge HTML formatted artciles. I had to
replace a particular word 'india' by 'world' in all the records under this
column. Strange thing is the occurances of the word 'india' towards the end
of the articles are getting recognized by
select count(*) from news where charindex('india',news)>0
i.e. the above query results 0. Though there are thousands of records in
the column 'news' containing the word 'india'.
I think the issue is of max limit of charindex.
Please help at the earliest convenience of yours.
Regards,
John-I think the issue is of max limit of charindex.
No I don=B4t think so, because Charindex returns an INT, so there should
be a problem if the character would be found at the
2,147,483,648 +1. So are you searching on the right table and database
? That should return a hit, if the word india is present in there.
HTH, jens Suessmeyer.|||John
Did you try LIKE operator?
"John" <netconsul@.gmail.com> wrote in message
news:ePx4t626FHA.1140@.tk2msftngp13.phx.gbl...
>I manage a news database oriented website where there is a column named
>'news' in a table 'news' storing huge HTML formatted artciles. I had to
>replace a particular word 'india' by 'world' in all the records under this
>column. Strange thing is the occurances of the word 'india' towards the end
>of the articles are getting recognized by
> select count(*) from news where charindex('india',news)>0
>
> i.e. the above query results 0. Though there are thousands of records in
> the column 'news' containing the word 'india'.
> I think the issue is of max limit of charindex.
> Please help at the earliest convenience of yours.
> Regards,
> John
>
>
>|||Thats what my problem is.
select news from news where news like '%india%'
results in 74000+ records while
select count(*) from news where charindex('india',news)>0
returns none.
I am using charindex to find the position of India in the record and use
'updatetext' to replace it by world.
because charindex('india',news) returns 0, updatetext cant replace india in
each record by world.
Any quick help will be appreciated.
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1132230042.794270.99970@.g43g2000cwa.googlegroups.com...
-I think the issue is of max limit of charindex.
No I dont think so, because Charindex returns an INT, so there should
be a problem if the character would be found at the
2,147,483,648 +1. So are you searching on the right table and database
? That should return a hit, if the word india is present in there.
HTH, jens Suessmeyer.|||Hi Everyone,
Solution to my problem lies here.
http://www.aspfaq.com/show.asp?id=2445
Please note that my fear about charindex is correct.
Initially I used CHARINDEX, but that failed if the pattern was deeper than
8,000 characters into the value. PATINDEX never dies. :-)
Thanks
John
"John" <netconsul@.gmail.com> wrote in message
news:eT7LVE66FHA.4076@.TK2MSFTNGP10.phx.gbl...
> Thats what my problem is.
> select news from news where news like '%india%'
> results in 74000+ records while
> select count(*) from news where charindex('india',news)>0
>
> returns none.
> I am using charindex to find the position of India in the record and use
> 'updatetext' to replace it by world.
> because charindex('india',news) returns 0, updatetext cant replace india
> in each record by world.
>
> Any quick help will be appreciated.
>
>
> "Jens" <Jens@.sqlserver2005.de> wrote in message
> news:1132230042.794270.99970@.g43g2000cwa.googlegroups.com...
> -I think the issue is of max limit of charindex.
> No I dont think so, because Charindex returns an INT, so there should
> be a problem if the character would be found at the
> 2,147,483,648 +1. So are you searching on the right table and database
> ? That should return a hit, if the word india is present in there.
> HTH, jens Suessmeyer.
>

An Full-Text Catalog Item Count of 0?

Hi,
I've enabled a full-text index on a table having 77 thousand records on a
varchar(50) column. And yet when I when I populate the catalog:
exec sp_fulltext_catalog 'OrdersCatalog', 'start_full'
I get an item count,
SELECT fulltextcatalogproperty('OrdersCatalog', 'ItemCount'),
of 0.
This column has data 95% of the time. What am I missing?
Thank you.
--
Mark Holahan
Check the event log and the gatherer logs for messages:
It is likely you are running into one of the errors in these kb articles
http://support.microsoft.com/default...b;en-us;295034
http://support.microsoft.com/default...b;en-us;317746
http://support.microsoft.com/default...b;en-us;295772
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message
news:Ogx2wObHFHA.2860@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I've enabled a full-text index on a table having 77 thousand records on a
> varchar(50) column. And yet when I when I populate the catalog:
> exec sp_fulltext_catalog 'OrdersCatalog', 'start_full'
> I get an item count,
> SELECT fulltextcatalogproperty('OrdersCatalog', 'ItemCount'),
> of 0.
> This column has data 95% of the time. What am I missing?
> Thank you.
> --
> --
> Mark Holahan
>
|||Bull's eye! Thanks.
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:ek2TowbHFHA.3880@.TK2MSFTNGP10.phx.gbl...
> Check the event log and the gatherer logs for messages:
> It is likely you are running into one of the errors in these kb articles
> http://support.microsoft.com/default...b;en-us;295034
> http://support.microsoft.com/default...b;en-us;317746
> http://support.microsoft.com/default...b;en-us;295772
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message
> news:Ogx2wObHFHA.2860@.TK2MSFTNGP12.phx.gbl...
>
|||Hi Hilary,
I have had a similar problem with the Full-text Catalog Item Count of 0,
after I enable some Full-text Indexing from 4 tables. I can view the
table names on the Full-text Catalog, but when double-clicked the
Catalog, the propereties page showed an Item Count of 0.
Because we are developing a back-end database for a SharePoint Services
server, based on the information from the SharePoint Administration
guide, we needed to use Domain Account, instead of the local System
account, after we saw the Item Count of 0 for our first try.
The big question is after we set up the domain account, the Item Count
was still zero.
Is something wrong with the Full-text Search configuration, or on the
SharePoint Service server?
Thanks,
Jeffrey
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!
|||Is MSSearch running under the local system account? It must be for this to
work.
Are there any error or warning messages in the application log from MSSearch
or MSSCi?
You might want to consult these kb article for more information on resolving
the typical problems you get this MSSearch and SQL Server.
http://support.microsoft.com/default...b;en-us;295034
http://support.microsoft.com/default...b;en-us;317746
http://support.microsoft.com/default...b;en-us;295772
"Jeffrey Wang" <cjeffwang@.gmail.com> wrote in message
news:ug43i2TIFHA.2924@.TK2MSFTNGP15.phx.gbl...
> Hi Hilary,
> I have had a similar problem with the Full-text Catalog Item Count of 0,
> after I enable some Full-text Indexing from 4 tables. I can view the
> table names on the Full-text Catalog, but when double-clicked the
> Catalog, the propereties page showed an Item Count of 0.
> Because we are developing a back-end database for a SharePoint Services
> server, based on the information from the SharePoint Administration
> guide, we needed to use Domain Account, instead of the local System
> account, after we saw the Item Count of 0 for our first try.
> The big question is after we set up the domain account, the Item Count
> was still zero.
> Is something wrong with the Full-text Search configuration, or on the
> SharePoint Service server?
> Thanks,
> Jeffrey
>
>
> *** Sent via Developersdex http://www.codecomments.com ***
> Don't just participate in USENET...get rewarded for it!

Sunday, March 11, 2012

An explicit value for the identity column in table

for some unknow reasons.. my store proc stop working.. and i got an error..
i have installaed the latest SP4 for SQL server 2000 and still have the problem !
any ideas why ??
Message "An explicit value for the identity column in table 'LCMS_Modules' can only be specified when a column list is used and IDENTITY_INSERT is ON."
CREATE procedure LCMS_Modules_Add

@.PageID int,
@.ModuleDefID int,
@.Panename nvarchar(32),
@.Title nvarchar(128),
@.Admins nvarchar(256)

as

insert into LCMS_Modules
values(@.PageID, @.ModuleDefID, 99, @.Panename, @.Title, '0;', @.Admins, 0, '', 'Center', '', '', '', 1, 0)
GO

Have you reordered the columns in your LCMS_Modules table? I amguessing that you did, and that the identity column had previously beenat the end and is now in the beginning or somewhere in the middle.
Specify your column names in your INSERT statement. This is a best practice anyway and should take care of your problem.
insert into LCMS_Modules (column1, column2, column3, ...etc..., column15),
values(@.PageID, @.ModuleDefID, 99, @.Panename, @.Title, '0;', @.Admins, 0, '', 'Center', '', '', '', 1, 0)

An error occurred while receiving data: '10054(An existing connection was forcibly closed by th

What does this error mean? I get this in the transmission_status column of sys.transmission_queue

An error occurred while receiving data: '10053(An established connection was aborted by the software in your host machine.)'.

Also, does the number in this message correspond to error 10053 in sys.messages?

Thanks

It means that the peer is closing the connection during login, most likely due to lack of CONNECT permission on the endpoint. You need to attch the profiler to the peer and monitor the 'Security Audit/Audit Broker Login' and 'Broker/Broker connection' events.

10054 and 10053 are system errors (OS), they are WSAECONNRESET and WSAECONNABORTED. they are described here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp

HTH,
~ Remus

|||

Thanks

What happened was that my certificates expired (set start date as 01/01/05 and neglected an expiry date)

An error occurred while receiving data: '10054(An existing connection was forcibly closed b

What does this error mean? I get this in the transmission_status column of sys.transmission_queue

An error occurred while receiving data: '10053(An established connection was aborted by the software in your host machine.)'.

Also, does the number in this message correspond to error 10053 in sys.messages?

Thanks

It means that the peer is closing the connection during login, most likely due to lack of CONNECT permission on the endpoint. You need to attch the profiler to the peer and monitor the 'Security Audit/Audit Broker Login' and 'Broker/Broker connection' events.

10054 and 10053 are system errors (OS), they are WSAECONNRESET and WSAECONNABORTED. they are described here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp

HTH,
~ Remus

|||

Thanks

What happened was that my certificates expired (set start date as 01/01/05 and neglected an expiry date)

Friday, February 24, 2012

AMO: Can''t update dsv when delete a column

Hi, friends, please have a look at this:

I am using AMO, and I do this:

1 step: I drop a column from the source table by SQL:

ALTER TABLE TargetTable Drop COLUMN ColumnName

2 step: I try to update the dsv by AMO:

Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter( _
"SELECT * FROM [dbo].[" + tableName + "] WHERE 1=0", connection)
Dim i As Integer

For i = 0 To dsv.Schema.Tables.Count - 1
If dsv.Schema.Tables(i).TableName = "dbo_" & tableName Then
MessageBox.Show("Before dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)
MessageBox.Show("After dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
End If

Next

But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column.

3 step: I save the dsv to the server.

If Mainform.tDatabase.DataSourceViews.Count > 0 Then
Mainform.tDatabase.DataSourceViews(0).Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull)
End If

Then I check the server, the dsv still include the columnname I have deleted.

Why and how to update the dsv after I delete a column?

Thanks!

ivanchain wrote:

Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)

ivanchain wrote:

But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column

Let's also check if the returned 'dataTable' still contains the column you deleted. If it does contain the column, then we need to double check the table name and its columns in SQL Server.If the returned 'dataTable' doesn't contain the column, it looks like you need to replace the table in the DSV with this returned 'dataTable', but according to documentation at http://msdn2.microsoft.com/en-us/library/152bda9x.aspx, this should not be the case.

The rest of the code looks good, the problem is not in AMO, but in the FillSchema area.

Adrian Dumitrascu

|||

I tried what you said:

Let's also check if the returned 'dataTable' still contains the column you deleted. If it does contain the column, then we need to double check the table name and its columns in SQL Server.

Yes, the returned 'dataTable' still contains the column I deleted. But I don't know what you exactly mean of DOUBLE CHECK the table name and its columns in SQL Server? I need to check what?

Thank you!

|||

The problem is still there.... help!

thanks.

|||

The only ideas that I have are:

- double check that the database name (that you use in the code) is the same with the database on which you removed the column from the table. There might be a concidence that you have 2 databases containing the same table name and column name, you deleted from one, but the code works on the other database by chance (since I don't see in the code where you explicitly chose the database on which to run the SELECT statement)

- double check that the name and the schema, 'dbo', of the table you use in the code are the same as the schema and the name of the table from which you deleted the column

|||

Thanks, Adrian. But, I don't think it's about the NAME of the table. Because my code could update dsv when I add a column into the SQL table in the SQL Server. If the name of the table is wrong, it will also not update when adding, right?

Thanks!

AMO: Can't update dsv when delete a column

Hi, friends, please have a look at this:

I am using AMO, and I do this:

1 step: I drop a column from the source table by SQL:

ALTER TABLE TargetTable Drop COLUMN ColumnName

2 step: I try to update the dsv by AMO:

Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter( _
"SELECT * FROM [dbo].[" + tableName + "] WHERE 1=0", connection)
Dim i As Integer

For i = 0 To dsv.Schema.Tables.Count - 1
If dsv.Schema.Tables(i).TableName = "dbo_" & tableName Then
MessageBox.Show("Before dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)
MessageBox.Show("After dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
End If

Next

But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column.

3 step: I save the dsv to the server.

If Mainform.tDatabase.DataSourceViews.Count > 0 Then
Mainform.tDatabase.DataSourceViews(0).Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull)
End If

Then I check the server, the dsv still include the columnname I have deleted.

Why and how to update the dsv after I delete a column?

Thanks!

ivanchain wrote:

Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)

ivanchain wrote:

But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column

Let's also check if the returned 'dataTable' still contains the column you deleted. If it does contain the column, then we need to double check the table name and its columns in SQL Server.If the returned 'dataTable' doesn't contain the column, it looks like you need to replace the table in the DSV with this returned 'dataTable', but according to documentation at http://msdn2.microsoft.com/en-us/library/152bda9x.aspx, this should not be the case.

The rest of the code looks good, the problem is not in AMO, but in the FillSchema area.

Adrian Dumitrascu

|||

I tried what you said:

Let's also check if the returned 'dataTable' still contains the column you deleted. If it does contain the column, then we need to double check the table name and its columns in SQL Server.

Yes, the returned 'dataTable' still contains the column I deleted. But I don't know what you exactly mean of DOUBLE CHECK the table name and its columns in SQL Server? I need to check what?

Thank you!

|||

The problem is still there.... help!

thanks.

|||

The only ideas that I have are:

- double check that the database name (that you use in the code) is the same with the database on which you removed the column from the table. There might be a concidence that you have 2 databases containing the same table name and column name, you deleted from one, but the code works on the other database by chance (since I don't see in the code where you explicitly chose the database on which to run the SELECT statement)

- double check that the name and the schema, 'dbo', of the table you use in the code are the same as the schema and the name of the table from which you deleted the column

|||

Thanks, Adrian. But, I don't think it's about the NAME of the table. Because my code could update dsv when I add a column into the SQL table in the SQL Server. If the name of the table is wrong, it will also not update when adding, right?

Thanks!

AMO Question - Distinct members in Cube

Hi,

How to filter members in a dimension.

To meet a requirement, I made a table as a Fact and a Dimension. In the said table, I have a column which is varchar and contains unique values always. They can be said as 'A' or 'B' or 'C'. For all records in the said table, any of these three values can be present. But they are not from any lookup table but come from a third party system.

Using the AMO object, I am listing all the values are members. But the problem I am facing is, I am getting all values as members. As per my requirement, I must list only distinct of them

I am setting the DimensionAttribute object's Usage property to Key, OrderBy to OrderBy.Name and Type to Regular. What other property need to be set to list only the unique values as members?

I request a quick response to this query. I am desperately looking for the reply to solve the problem.

Thanks

Sekhar PC

Sorry Sekhar.

But the description of your problem is not very clear. Can you try to describe what you are trying to acheve.

Edward Melomed.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Hi,

Thank you for your reply.

In my cube, I have a fact table which has a column of varchar type. Assume that, the possible values are A,B,C,D.

While building the cube using the AMO and VB.Net, I am required to list them as members in the cube. Essentially, I am required to fetch the distinct values from that column and list as members.

How to that using AMO and VB.Net?

Thanks in advance

Sekhar

|||

You dont use AMO for retreiving data from Analysis Services. For that you use ADOMD.NET object model ( not the only option, but it might be easiest for you).

Here is some information on how to use ADOMD.NET

http://msdn2.microsoft.com/en-us/library/ms123483.aspx
http://msdn2.microsoft.com/en-us/library/ms123477.aspx

You can try and get a book on Analysis Services: Teo Lachev's "Applied Microsoft Analysis Services 2005.. " is good one you can use.

Edward Melomed.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

AMO Question - Distinct members in Cube

Hi,

How to filter members in a dimension.

To meet a requirement, I made a table as a Fact and a Dimension. In the said table, I have a column which is varchar and contains unique values always. They can be said as 'A' or 'B' or 'C'. For all records in the said table, any of these three values can be present. But they are not from any lookup table but come from a third party system.

Using the AMO object, I am listing all the values are members. But the problem I am facing is, I am getting all values as members. As per my requirement, I must list only distinct of them

I am setting the DimensionAttribute object's Usage property to Key, OrderBy to OrderBy.Name and Type to Regular. What other property need to be set to list only the unique values as members?

I request a quick response to this query. I am desperately looking for the reply to solve the problem.

Thanks

Sekhar PC

Sorry Sekhar.

But the description of your problem is not very clear. Can you try to describe what you are trying to acheve.

Edward Melomed.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Hi,

Thank you for your reply.

In my cube, I have a fact table which has a column of varchar type. Assume that, the possible values are A,B,C,D.

While building the cube using the AMO and VB.Net, I am required to list them as members in the cube. Essentially, I am required to fetch the distinct values from that column and list as members.

How to that using AMO and VB.Net?

Thanks in advance

Sekhar

|||

You dont use AMO for retreiving data from Analysis Services. For that you use ADOMD.NET object model ( not the only option, but it might be easiest for you).

Here is some information on how to use ADOMD.NET

http://msdn2.microsoft.com/en-us/library/ms123483.aspx
http://msdn2.microsoft.com/en-us/library/ms123477.aspx

You can try and get a book on Analysis Services: Teo Lachev's "Applied Microsoft Analysis Services 2005.. " is good one you can use.

Edward Melomed.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

Sunday, February 19, 2012

Ambiguous Column Names in Multi-Table Join

Hi all,

A (possibly dumb) question, but I've had no luck finding a definitive
answer to it. Suppose I have two tables, Employees and Employers, which
both have a column named "Id":

Employees
-Id
-FirstName
-LastName
-SSN
etc.

Employers
-Id
-Name
-Address
etc.

and now I perform the following join:

SELECT Employees.*, Employers.*
FROM Employees LEFT JOIN Employers ON (Employees.Id=Employers.Id)

The result-set will contain two "Id" columns, so SQL Server will
disambiguate them; one column will still be called "Id", while the
other will be called "Id1." My question is, how are you supposed to
know which "Id" column belongs to which table? My intuition tells me,
and limited testing seems to indicate, that it depends on the order in
which the table names show up in the query, so that in the above
example, "Id" would refer to Employees.Id, while "Id1" would refer to
Employers.Id. Is this order guaranteed?

Also, why does SQL Server use such a IMO brain-damaged technique to
handle column name conflicts? In MS Access, it's much more
straightforward; after executing the above query, you can use
"Employees.Id" and "Employers.Id" (and more generally,
"TableNameOrTableAlias.ColumnName") to refer to the specific "Id"
column you want, instead of "Id" and "Id1" -- the
"just-tack-on-a-number" strategy is slightly annoying when dealing with
complex queries.

--
Mike SYou could :
SELECT E1.id as "Employees_ID", E2.id as "Employers_ID"
FROM Employees as E1 LEFT JOIN Employers AS E2 ON (E1.Id=E2.Id)

--
--
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
___________________________________

"Mike S" <mgspross@.netscape.net> wrote in message
news:1150907102.154838.278240@.m73g2000cwd.googlegr oups.com...
> Hi all,
> A (possibly dumb) question, but I've had no luck finding a definitive
> answer to it. Suppose I have two tables, Employees and Employers, which
> both have a column named "Id":
> Employees
> -Id
> -FirstName
> -LastName
> -SSN
> etc.
> Employers
> -Id
> -Name
> -Address
> etc.
> and now I perform the following join:
> SELECT Employees.*, Employers.*
> FROM Employees LEFT JOIN Employers ON (Employees.Id=Employers.Id)
> The result-set will contain two "Id" columns, so SQL Server will
> disambiguate them; one column will still be called "Id", while the
> other will be called "Id1." My question is, how are you supposed to
> know which "Id" column belongs to which table? My intuition tells me,
> and limited testing seems to indicate, that it depends on the order in
> which the table names show up in the query, so that in the above
> example, "Id" would refer to Employees.Id, while "Id1" would refer to
> Employers.Id. Is this order guaranteed?
> Also, why does SQL Server use such a IMO brain-damaged technique to
> handle column name conflicts? In MS Access, it's much more
> straightforward; after executing the above query, you can use
> "Employees.Id" and "Employers.Id" (and more generally,
> "TableNameOrTableAlias.ColumnName") to refer to the specific "Id"
> column you want, instead of "Id" and "Id1" -- the
> "just-tack-on-a-number" strategy is slightly annoying when dealing with
> complex queries.
> --
> Mike S|||Jack Vamvas wrote:
> You could :
> SELECT E1.id as "Employees_ID", E2.id as "Employers_ID"
> FROM Employees as E1 LEFT JOIN Employers AS E2 ON (E1.Id=E2.Id)

I was actually thinking about doing it that way, just aliasing all the
columns. I was hoping to avoid that because it would involve changing a
number of existing queries/program code - plus most of the queries are
'SELECT * FROM Table" type queries, so to produce the same results, I'd
have to alias every single column in each table. For this particular
project, I think it might be easier to deal with names like Id, Id1,
Id2, etc., even though it's not very readable...oh well, just a matter
of adding extra comments to the source code ;-)

--
Mike S|||Run this in query analyzer

select * from
(select 1 as id)a
cross join (select 2 as id) b

as you can see the result set is this
id id
---- ----
1 2

id is displayed twice, where do you get id1 is it client site?
I ran the same query in enterprise manager and I see id twice

Denis the SQL Menace
http://sqlservercode.blogspot.com/

Mike S wrote:
> Hi all,
> A (possibly dumb) question, but I've had no luck finding a definitive
> answer to it. Suppose I have two tables, Employees and Employers, which
> both have a column named "Id":
> Employees
> -Id
> -FirstName
> -LastName
> -SSN
> etc.
> Employers
> -Id
> -Name
> -Address
> etc.
> and now I perform the following join:
> SELECT Employees.*, Employers.*
> FROM Employees LEFT JOIN Employers ON (Employees.Id=Employers.Id)
> The result-set will contain two "Id" columns, so SQL Server will
> disambiguate them; one column will still be called "Id", while the
> other will be called "Id1." My question is, how are you supposed to
> know which "Id" column belongs to which table? My intuition tells me,
> and limited testing seems to indicate, that it depends on the order in
> which the table names show up in the query, so that in the above
> example, "Id" would refer to Employees.Id, while "Id1" would refer to
> Employers.Id. Is this order guaranteed?
> Also, why does SQL Server use such a IMO brain-damaged technique to
> handle column name conflicts? In MS Access, it's much more
> straightforward; after executing the above query, you can use
> "Employees.Id" and "Employers.Id" (and more generally,
> "TableNameOrTableAlias.ColumnName") to refer to the specific "Id"
> column you want, instead of "Id" and "Id1" -- the
> "just-tack-on-a-number" strategy is slightly annoying when dealing with
> complex queries.
> --
> Mike S|||No trying to rub salt in your wounds, but this wouldn't be an issue if
you followed a couple of standard programming practices:

1. Avoid SELECT * in production code. Always specify column names
(and aliases if you'd like); it'll make maintenance much easier, and
keep you from having to recompile dependent views if you add or remove
a column at a later date.

2. Use stored procedures as a data access method rather than SQL in
the application; much easier to adjust a stored procedure in one place
rather than several SQL statements throughout your application (not to
mention the security benefits).

There are exceptions to every rule, of course, and I'm not in your
shoes, but it sounds like you need to tighten up your code a bit.

Stu

Mike S wrote:
> Jack Vamvas wrote:
> > You could :
> > SELECT E1.id as "Employees_ID", E2.id as "Employers_ID"
> > FROM Employees as E1 LEFT JOIN Employers AS E2 ON (E1.Id=E2.Id)
> I was actually thinking about doing it that way, just aliasing all the
> columns. I was hoping to avoid that because it would involve changing a
> number of existing queries/program code - plus most of the queries are
> 'SELECT * FROM Table" type queries, so to produce the same results, I'd
> have to alias every single column in each table. For this particular
> project, I think it might be easier to deal with names like Id, Id1,
> Id2, etc., even though it's not very readable...oh well, just a matter
> of adding extra comments to the source code ;-)
> --
> Mike S|||Mike S (mgspross@.netscape.net) writes:
> I was actually thinking about doing it that way, just aliasing all the
> columns. I was hoping to avoid that because it would involve changing a
> number of existing queries/program code - plus most of the queries are
> 'SELECT * FROM Table" type queries, so to produce the same results, I'd
> have to alias every single column in each table. For this particular
> project, I think it might be easier to deal with names like Id, Id1,
> Id2, etc., even though it's not very readable...oh well, just a matter
> of adding extra comments to the source code ;-)

If you have a lot of SELECT * then you have a lot of code to modify.
SELECT * does not belong in production code.

I don't know where you got the idea of Id1 from; SQL Server returns a
result set with two columns that have the same name.

Besides, if the id is a join column, there is little reason to return
it twice...

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||>> A (possibly dumb) question, but I've had no luck finding a definitive answer to it. Suppose I have two tables, Employees and Employers, which both have a column named "Id" <<

Well, first of all, kill the stupid bastard that used "id" as a column
name, since he never read ISO-11179 or any book on BASIC data modeling.
This is not a data element name; it is too vague (identifier of
what??) and it appears EVERYWHERE, so it is a meaningless exposed
physical locator.

Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Sample data is also a good idea, along with clear
specifications. It is very hard to debug code when you do not let us
see it. If you were polite and had a valid schema, would it look like
this?

CREATE TABLE Personnel -- note the use of a collective name for a set
(ssn CHAR(9) NOT NULL PRIMARY KEY, -- legal requirement!
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
.. );

CREATE TABLE Employers
(duns_nbr CHAR(9) NOT NULL PRIMARY KEY, -- industry standards!!
employer_name VARCHAR(20) NOT NULL,
..);

>> and now I perform the following join: <<

I hope not! it makes no sense. What is the relationship between two
values in totally different domains?? Gee, we need a table for that
...

>> The result-set will contain two "Id" columns, so SQL Server will disambiguate them; one column will still be called "Id", while the other will be called "Id1." My question is, how are you supposed to know which "Id" column belongs to which table? <<

By having a proper data model in which different data elements have
different names. What you have here is a "Vague, Magical, Universal
one-size-fits-all Kabalah Number" on tables, when you need a third
table called "Employment" with the employees and employers identifiers
in its columns. Basically the engine is tryitn to do the best it can
with your crappy design.

>> My intuition tells me, and limited testing seems to indicate, that it depends on the order in which the table names show up in the query, so that in the above example, "Id" would refer to Employees.Id, while "Id1" would refer to Employers.Id. Is this order guaranteed? <<

This is one of MANY reasons good programmers do not do this kind of
crappy design. The vendor is free to do anything they wish with the
display of such data. Nobody agrees. Nobody does it the same in
different releases. The best you can do is alias one of the columns.

Ambiguous column name?

Hi there,
I'm using push transactional replication to our new reporting server, when
copying over the initial snapshot I get the following error:
Ambiguous column name 'ShipViaCd'
Anyone have a similar problem when implementing replication?
never, please post your schema for the objects you are replicating as well
as the publication and subscription creation scripts.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"Justin" <Justin@.discussions.microsoft.com> wrote in message
news:EE4D64BE-03C9-4CD0-8F36-B0C52E0AC6DC@.microsoft.com...
> Hi there,
> I'm using push transactional replication to our new reporting server, when
> copying over the initial snapshot I get the following error:
> Ambiguous column name 'ShipViaCd'
> Anyone have a similar problem when implementing replication?

Ambiguous Column Name Problem

I have a table which needs to have a column called rank. When I run the
following query I get an error about the table names being ambiguous. Is
there a way round this. Regards, Chris.
SELECT [Key], productdescriptionid, productdesc_name FROM FREETEXTTABLE
(tblProductDescriptions, *,'biopsy') F JOIN tblProductDescriptions P ON
P.productdescriptionid = F.[KEY]ORDER BY RANK DESC
Sorry I really wasn't thinking. just put F.RANK !!!!!
SELECT [Key], productdescriptionid, productdesc_name FROM FREETEXTTABLE
(tblProductDescriptions, *,'biopsy') F JOIN tblProductDescriptions P ON
P.productdescriptionid = F.[KEY]ORDER BY RANK DESC
"Chris Kennedy" <chrisknospam@.cybase.co.uk> wrote in message
news:OnxD4UKeEHA.3132@.TK2MSFTNGP11.phx.gbl...
> I have a table which needs to have a column called rank. When I run the
> following query I get an error about the table names being ambiguous. Is
> there a way round this. Regards, Chris.
> SELECT [Key], productdescriptionid, productdesc_name FROM FREETEXTTABLE
> (tblProductDescriptions, *,'biopsy') F JOIN tblProductDescriptions P ON
> P.productdescriptionid = F.[KEY]ORDER BY RANK DESC
>
|||does this work?
SELECT [Key], productdescriptionid, productdesc_name FROM FREETEXTTABLE
(tblProductDescriptions, *,'biopsy') F JOIN tblProductDescriptions P ON
P.productdescriptionid = F.[KEY] ORDER BY F.[RANK] DESC
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"Chris Kennedy" <chrisknospam@.cybase.co.uk> wrote in message
news:OnxD4UKeEHA.3132@.TK2MSFTNGP11.phx.gbl...
> I have a table which needs to have a column called rank. When I run the
> following query I get an error about the table names being ambiguous. Is
> there a way round this. Regards, Chris.
> SELECT [Key], productdescriptionid, productdesc_name FROM FREETEXTTABLE
> (tblProductDescriptions, *,'biopsy') F JOIN tblProductDescriptions P ON
> P.productdescriptionid = F.[KEY]ORDER BY RANK DESC
>

Ambiguous column name on Insert

I am getting an Ambiguous column name on this insert for all fields.
Insert Into Agentlocatordata ([Agent],
[AgentLoc],
[AppointmentDate],
[BusinessName],
[BusinessPhone1],
[BusinessPhone2],
[BusinessType],
[CommercialProp],
[Contact],
[ContactEmail],
[CPRepGotit],
[Crossstreet],
[DateCreated],
[DateLastChanged],
[DirectConnect],
[Direction1],
[Direction2],
[Direction3],
[DisplayName],
[E_Mail],
[FaxByEmail],
[FaxPhone],
[License],
[MailAddress1],
[MailAddress2],
[MailCity],
[MailName],
[MailState],
[MailZip],
[MKTGRep],
[NoOfAgents],
[OfficeAddress1],
[OfficeAddress2],
[OfficeCity],
[OfficeState],
[OfficeZip],
[OfficeZipp4],
[Owner],
[Profile],
[RepGotit],
[ShortName],
[ShowPage],
[Specialty],
[StarfishGroup],
[State],
[TaxPayerShortName],
[TaxType],
[Unit],
[Website],
[Zone])
Select Distinct
[Agents]
,[AgentLoc]
,[AppointmentDate]
,[BusinessName]
,[BusinessPhone1]
,[BusinessPhone2]
,[BusinessType]
,[CommercialProp]
,[Contact]
,[ContactEmail]
,[CPRepGotit]
,[Crossstreet]
,[DateCreated]
,[DateLastChanged]
,[DirectConnect]
,[Direction1]
,[Direction2]
,[Direction3]
,[DisplayName]
,[EMail]
,[FaxByEmail]
,[FaxPhone]
,[License]
,[MailAddress1]
,[MailAddress2]
,[MailCity]
,[MailName]
,[MailState]
,[MailZip]
,[MKTGRep]
,[NoOfAgents]
,[OfficeAddress1]
,[OfficeAddress2]
,[OfficeCity]
,[OfficeState]
,[OfficeZip]
,[OfficeZipp4]
,[Owner]
,[Profile]
,[RepGotit]
,[ShortName]
,[ShowPage]
,[Specialty]
,[StarfishGroup]
,[State]
,[TaxPayerShortName]
,[TaxType]
,[Unit]
,[Website]
,[Zone]
from Agent full outer
join Agent0315 on Agent.Agent = Agent0315.agents
where Agent.agent = Agent0315.agents
ANy Help would be great!Lontae Jones wrote:
> I am getting an Ambiguous column name on this insert for all fields.
> Insert Into Agentlocatordata ([Agent],
> [AgentLoc],
> [AppointmentDate],
> [BusinessName],
> [BusinessPhone1],
> [BusinessPhone2],
> [BusinessType],
> [CommercialProp],
> [Contact],
> [ContactEmail],
> [CPRepGotit],
> [Crossstreet],
> [DateCreated],
> [DateLastChanged],
> [DirectConnect],
> [Direction1],
> [Direction2],
> [Direction3],
> [DisplayName],
> [E_Mail],
> [FaxByEmail],
> [FaxPhone],
> [License],
> [MailAddress1],
> [MailAddress2],
> [MailCity],
> [MailName],
> [MailState],
> [MailZip],
> [MKTGRep],
> [NoOfAgents],
> [OfficeAddress1],
> [OfficeAddress2],
> [OfficeCity],
> [OfficeState],
> [OfficeZip],
> [OfficeZipp4],
> [Owner],
> [Profile],
> [RepGotit],
> [ShortName],
> [ShowPage],
> [Specialty],
> [StarfishGroup],
> [State],
> [TaxPayerShortName],
> [TaxType],
> [Unit],
> [Website],
> [Zone])
> Select Distinct
> [Agents]
> ,[AgentLoc]
> ,[AppointmentDate]
> ,[BusinessName]
> ,[BusinessPhone1]
> ,[BusinessPhone2]
> ,[BusinessType]
> ,[CommercialProp]
> ,[Contact]
> ,[ContactEmail]
> ,[CPRepGotit]
> ,[Crossstreet]
> ,[DateCreated]
> ,[DateLastChanged]
> ,[DirectConnect]
> ,[Direction1]
> ,[Direction2]
> ,[Direction3]
> ,[DisplayName]
> ,[EMail]
> ,[FaxByEmail]
> ,[FaxPhone]
> ,[License]
> ,[MailAddress1]
> ,[MailAddress2]
> ,[MailCity]
> ,[MailName]
> ,[MailState]
> ,[MailZip]
> ,[MKTGRep]
> ,[NoOfAgents]
> ,[OfficeAddress1]
> ,[OfficeAddress2]
> ,[OfficeCity]
> ,[OfficeState]
> ,[OfficeZip]
> ,[OfficeZipp4]
> ,[Owner]
> ,[Profile]
> ,[RepGotit]
> ,[ShortName]
> ,[ShowPage]
> ,[Specialty]
> ,[StarfishGroup]
> ,[State]
> ,[TaxPayerShortName]
> ,[TaxType]
> ,[Unit]
> ,[Website]
> ,[Zone]
> from Agent full outer
> join Agent0315 on Agent.Agent = Agent0315.agents
> where Agent.agent = Agent0315.agents
> ANy Help would be great!
You didn't qualify any of your columns in the SELECT portion. If you use
a join, you need to qualify your columns as a matter of good practice.
You probably have the same column name in the Agent and Agent0315
tables.
David Gugick
Imceda Software
www.imceda.com|||My select follows my insert but I am still getting ambiguos errors on all
columns.
Insert Into Agentlocatordata ([Agent],
[AgentLoc],
[AppointmentDate],
[BusinessName],
[BusinessPhone1],
[BusinessPhone2],
[BusinessType],
[CommercialProp],
[Contact],
[ContactEmail],
[CPRepGotit],
[Crossstreet],
[DateCreated],
[DateLastChanged],
[DirectConnect],
[Direction1],
[Direction2],
[Direction3],
[DisplayName],
[E_Mail],
[FaxByEmail],
[FaxPhone],
[License],
[MailAddress1],
[MailAddress2],
[MailCity],
[MailName],
[MailState],
[MailZip],
[MKTGRep],
[NoOfAgents],
[OfficeAddress1],
[OfficeAddress2],
[OfficeCity],
[OfficeState],
[OfficeZip],
[OfficeZipp4],
[Owner],
[Profile],
[RepGotit],
[ShortName],
[ShowPage],
[Specialty],
[StarfishGroup],
[State],
[TaxPayerShortName],
[TaxType],
[Unit],
[Website],
[Zone])
Select Distinct [Agents] ,[AgentLoc],[AppointmentDate]
,[BusinessName]
,[BusinessPhone1]
,[BusinessPhone2]
,[BusinessType]
,[CommercialProp]
,[Contact]
,[ContactEmail]
,[CPRepGotit]
,[Crossstreet]
,[DateCreated]
,[DateLastChanged]
,[DirectConnect]
,[Direction1]
,[Direction2]
,[Direction3]
,[DisplayName]
,[EMail]
,[FaxByEmail]
,[FaxPhone]
,[License]
,[MailAddress1]
,[MailAddress2]
,[MailCity]
,[MailName]
,[MailState]
,[MailZip]
,[MKTGRep]
,[NoOfAgents]
,[OfficeAddress1]
,[OfficeAddress2]
,[OfficeCity]
,[OfficeState]
,[OfficeZip]
,[OfficeZipp4]
,[Owner]
,[Profile]
,[RepGotit]
,[ShortName]
,[ShowPage]
,[Specialty]
,[StarfishGroup]
,[State]
,[TaxPayerShortName]
,[TaxType]
,[Unit]
,[Website]
,[Zone]
from Agent full outer
join Agent0315 on Agent.Agent = Agent0315.agents
where Agent.agent = Agent0315.agents
"David Gugick" wrote:

> Lontae Jones wrote:
> You didn't qualify any of your columns in the SELECT portion. If you use
> a join, you need to qualify your columns as a matter of good practice.
> You probably have the same column name in the Agent and Agent0315
> tables.
> --
> David Gugick
> Imceda Software
> www.imceda.com
>|||For each column that is in both the Agent and Agent0315 tables,
you must specify whether you want Agent.theColumn or Agent0315.theColumn.
Your column names are ambiguous because they appear in two different tables
in the FROM clause, but you don't say which you want in your result.
SK
Lontae Jones wrote:
>My select follows my insert but I am still getting ambiguos errors on all
>columns.
>Insert Into Agentlocatordata ([Agent],
> [AgentLoc],
> [AppointmentDate],
> [BusinessName],
> [BusinessPhone1],
> [BusinessPhone2],
> [BusinessType],
> [CommercialProp],
> [Contact],
> [ContactEmail],
> [CPRepGotit],
> [Crossstreet],
> [DateCreated],
> [DateLastChanged],
> [DirectConnect],
> [Direction1],
> [Direction2],
> [Direction3],
> [DisplayName],
> [E_Mail],
> [FaxByEmail],
> [FaxPhone],
> [License],
> [MailAddress1],
> [MailAddress2],
> [MailCity],
> [MailName],
> [MailState],
> [MailZip],
> [MKTGRep],
> [NoOfAgents],
> [OfficeAddress1],
> [OfficeAddress2],
> [OfficeCity],
> [OfficeState],
> [OfficeZip],
> [OfficeZipp4],
> [Owner],
> [Profile],
> [RepGotit],
> [ShortName],
> [ShowPage],
> [Specialty],
> [StarfishGroup],
> [State],
> [TaxPayerShortName],
> [TaxType],
> [Unit],
> [Website],
> [Zone])
>Select Distinct [Agents] ,[AgentLoc],[AppointmentDate]
> ,[BusinessName]
> ,[BusinessPhone1]
> ,[BusinessPhone2]
> ,[BusinessType]
> ,[CommercialProp]
> ,[Contact]
> ,[ContactEmail]
> ,[CPRepGotit]
> ,[Crossstreet]
> ,[DateCreated]
> ,[DateLastChanged]
> ,[DirectConnect]
> ,[Direction1]
> ,[Direction2]
> ,[Direction3]
> ,[DisplayName]
> ,[EMail]
> ,[FaxByEmail]
> ,[FaxPhone]
> ,[License]
> ,[MailAddress1]
> ,[MailAddress2]
> ,[MailCity]
> ,[MailName]
> ,[MailState]
> ,[MailZip]
> ,[MKTGRep]
> ,[NoOfAgents]
> ,[OfficeAddress1]
> ,[OfficeAddress2]
> ,[OfficeCity]
> ,[OfficeState]
> ,[OfficeZip]
> ,[OfficeZipp4]
> ,[Owner]
> ,[Profile]
> ,[RepGotit]
> ,[ShortName]
> ,[ShowPage]
> ,[Specialty]
> ,[StarfishGroup]
> ,[State]
> ,[TaxPayerShortName]
> ,[TaxType]
> ,[Unit]
> ,[Website]
> ,[Zone]
>from Agent full outer
>join Agent0315 on Agent.Agent = Agent0315.agents
>where Agent.agent = Agent0315.agents
>"David Gugick" wrote:
>
>

Thursday, February 16, 2012

Ambiguous column name error

Hi all,
I am a newbee at SQl and replication. But I have setup a Transactional
replication model, the Source server is both publisher and Distributor, and
SQL 2000 SP4 is used.
The snapshot is created, but the distribution fails. And the following error
is generated, 'ambiguous column name' with a column specified. Is there
anything that we can do about this or did the developer used the wrong naming
conventions in his desgin?
Help would be greatly appreciated!!!
Remco
Anyone?

ambigous column name message

I am modifying an existing stored procedure in SQL server 2005. I have added a new field to the sp and am now receiving an ambiguous column name message. The column being referred to was in the sp before I modified. The column is on the line above where I added my new field ( EMPLOYEE NUMBER) to the sp. I am at a loss to why I'm getting this error message when executing the sp because this column existed before I modified. Can anyone help me understand why I'm getting this message all of a sudden and/ or where to look for help? Thanks in advance for any light you can help shed on this matter. Code snippet is below:

[BILL DUE DATE], [PAYMENT DATE AND TIME],

[EMPLOYEE NUMBER] )

Msg 209, Level 16, State 1, Procedure spBuildNoReasonLetter, Line 34

Ambiguous column name 'PAYMENT DATE AND TIME'.

There is no way we can 'guess' what is happening without seeing the code.

Please post the entire stored procedure code.

|||

Sorry, here is the sp:

setANSI_NULLSON

setQUOTED_IDENTIFIERON

go

ALTERPROCEDURE [dbo].[spBuildNoReasonLetter]

AS

setnocounton

TRUNCATETABLE [NO REASON LETTER];

INSERTINTO [NO REASON LETTER] ( [EMPLOYER NUMBER], [EMPLOYER NAME],

[CONTACT PERSON], [ADDRESS LINE 1],

[ADDRESS LINE 2], [ADDRESS LINE 3],

[EMPLOYEE SSN], [SERVICE CODE],

[EMPLOYEE NAME], [BILLING PERIOD],

[BILL DUE DATE], [PAYMENT DATE AND TIME],

[EMPLOYEE NUMBER] )

SELECTDISTINCT [NIGHT BATCH TABLE].[EMPLOYER NUMBER],

[COMPANY ADDRESS].[FULL NAME] AS [EMPLOYER NAME],

[COMPANY ADDRESS].[CONTACT PERSON],

[COMPANY ADDRESS].[ADDRESS LINE 1],

[COMPANY ADDRESS].[ADDRESS LINE 2],

[COMPANY ADDRESS].[CITY]+', '+[COMPANY ADDRESS].[STATE]+' '+[COMPANY ADDRESS].[ZIP CODE] AS [ADDRESS LINE 3],

[NIGHT BATCH TABLE].[EMPLOYEE SSN],

[NIGHT BATCH TABLE].[SERVICE CODE],

[MAIN EMPLOYEE].[FULL NAME] AS [EMPLOYEE NAME],Convert(varchar(10),

[COMPANY PAY TABLE].[BILLING PERIOD START],101)+' Thru '+Convert(varchar(10),[COMPANY PAY TABLE].[BILLING PERIOD END],101)AS [BILLING PERIOD],

[NIGHT BATCH TABLE].[BILL DUE DATE], [PAYMENT DATE AND TIME],

[MAIN EMPLOYEE].[EMPLOYEE NUMBER]

FROM(([NIGHT BATCH TABLE] INNERJOIN [COMPANY ADDRESS] ON([NIGHT BATCH TABLE].[EMPLOYER NUMBER] = [COMPANY ADDRESS].[ADDRESS KEY])AND

([NIGHT BATCH TABLE].[ADDRESS TYPE] = [COMPANY ADDRESS].[ADDRESS TYPE]))

INNERJOIN [MAIN EMPLOYEE] ON [NIGHT BATCH TABLE].[EMPLOYEE SSN] = [MAIN EMPLOYEE].[EMPLOYEE SSN])

INNERJOIN [NO REASON LETTER] ON [MAIN EMPLOYEE].[EMPLOYEE NUMBER] = [NO REASON LETTER].[EMPLOYEE NUMBER]

INNERJOIN [COMPANY PAY TABLE] ON([NIGHT BATCH TABLE].[BILL DUE DATE] = [COMPANY PAY TABLE].[BILL DUE DATE])AND

([NIGHT BATCH TABLE].[EMPLOYER NUMBER] = [COMPANY PAY TABLE].[EMPLOYER NUMBER])

WHERE([NIGHT BATCH TABLE].[REASON CODE]='X'AND

[MAIN EMPLOYEE].[STATUS CODE] In('00','01','09'));

UPDATE NRL

SET NRL.[CARRIER NAME] = CA.[FULL NAME],

NRL.[LOGO PATH] = CA.[CONTACT PERSON],

NRL.[TOLL FREE SERVICE NO] = CA.[TOLL FREE SERVICE NO]

FROM [NO REASON LETTER] AS NRL INNERJOIN [COMPANY ADDRESS] AS CA ON(CA.[ADDRESS KEY] = NRL.[EMPLOYER NUMBER] AND

CA.[ADDRESS TYPE] ='R')

UPDATE NRL

SET NRL.[SORT FIELD1] = dbo.fnReturnNRLSortField(CO.[SORT BILL BY],

ME.[FULL NAME],

ME.[EMPLOYEE SSN],

ME.[EMPLOYEE NUMBER],

ME.[DEPARTMENT CODE],

ME.[LOCATION CODE], 1),

NRL.[SORT FIELD2] = dbo.fnReturnNRLSortField(CO.[SORT BILL BY],

ME.[FULL NAME],

ME.[EMPLOYEE SSN],

ME.[EMPLOYEE NUMBER],

ME.[DEPARTMENT CODE],

ME.[LOCATION CODE], 2),

NRL.[EMPLOYEE SSN] = dbo.fnReturnFieldOrBlank(ME.[EMPLOYEE SSN], CO.[DO NOT DISPLAY SSN])

FROM [NO REASON LETTER] AS NRL INNERJOIN [COMPANY] AS CO ON(CO.[EMPLOYER NUMBER] = NRL.[EMPLOYER NUMBER])

INNERJOIN [MAIN EMPLOYEE] AS ME ON(ME.[EMPLOYEE SSN] = NRL.[EMPLOYEE SSN])

INNERJOIN [MAIN EMPLOYEE] AS ME ON(ME.[EMPLOYEE NUMBER] = NRL.[EMPLOYEE NUMBER])

|||I have changed my code slightly and am now getting a differenet message (new code is below error message:

Msg 4104, Level 16, State 1, Procedure spBuildNoReasonLetter, Line 17

The multi-part identifier "NO REASON LETTER.EMPLOYEE NUMBER" could not be bound.

setANSI_NULLSON

setQUOTED_IDENTIFIERON

go

ALTERPROCEDURE [dbo].[spBuildNoReasonLetter]

AS

setnocounton

TRUNCATETABLE [NO REASON LETTER];

INSERTINTO [NO REASON LETTER] ( [EMPLOYER NUMBER], [EMPLOYER NAME],

[CONTACT PERSON], [ADDRESS LINE 1],

[ADDRESS LINE 2], [ADDRESS LINE 3],

[EMPLOYEE SSN], [SERVICE CODE],

[EMPLOYEE NAME], [BILLING PERIOD],

[BILL DUE DATE], [PAYMENT DATE AND TIME],

[EMPLOYEE NUMBER])

SELECTDISTINCT [NIGHT BATCH TABLE].[EMPLOYER NUMBER],

[COMPANY ADDRESS].[FULL NAME] AS [EMPLOYER NAME],

[COMPANY ADDRESS].[CONTACT PERSON],

[COMPANY ADDRESS].[ADDRESS LINE 1],

[COMPANY ADDRESS].[ADDRESS LINE 2],

[COMPANY ADDRESS].[CITY]+', '+[COMPANY ADDRESS].[STATE]+' '+[COMPANY ADDRESS].[ZIP CODE] AS [ADDRESS LINE 3],

[NIGHT BATCH TABLE].[EMPLOYEE SSN],

[NIGHT BATCH TABLE].[SERVICE CODE],

[MAIN EMPLOYEE].[FULL NAME] AS [EMPLOYEE NAME],Convert(varchar(10),

[COMPANY PAY TABLE].[BILLING PERIOD START],101)+' Thru '+Convert(varchar(10),[COMPANY PAY TABLE].[BILLING PERIOD END],101)AS [BILLING PERIOD],

[NIGHT BATCH TABLE].[BILL DUE DATE], [PAYMENT DATE AND TIME],

[MAIN EMPLOYEE].[EMPLOYEE NUMBER]

FROM(([NIGHT BATCH TABLE] INNERJOIN [COMPANY ADDRESS] ON([NIGHT BATCH TABLE].[EMPLOYER NUMBER] = [COMPANY ADDRESS].[ADDRESS KEY])AND

([NIGHT BATCH TABLE].[ADDRESS TYPE] = [COMPANY ADDRESS].[ADDRESS TYPE]))

INNERJOIN [MAIN EMPLOYEE] ON [NIGHT BATCH TABLE].[EMPLOYEE SSN] = [MAIN EMPLOYEE].[EMPLOYEE SSN])

INNERJOIN [MAIN EMPLOYEE] AS MET ON [NO REASON LETTER].[EMPLOYEE NUMBER] = [MAIN EMPLOYEE].[EMPLOYEE NUMBER]

INNERJOIN [COMPANY PAY TABLE] ON([NIGHT BATCH TABLE].[BILL DUE DATE] = [COMPANY PAY TABLE].[BILL DUE DATE])AND

([NIGHT BATCH TABLE].[EMPLOYER NUMBER] = [COMPANY PAY TABLE].[EMPLOYER NUMBER])

WHERE([NIGHT BATCH TABLE].[REASON CODE]='X'AND

[MAIN EMPLOYEE].[STATUS CODE] In('00','01','09'));

UPDATE NRL

SET NRL.[CARRIER NAME] = CA.[FULL NAME],

NRL.[LOGO PATH] = CA.[CONTACT PERSON],

NRL.[TOLL FREE SERVICE NO] = CA.[TOLL FREE SERVICE NO]

FROM [NO REASON LETTER] AS NRL INNERJOIN [COMPANY ADDRESS] AS CA ON(CA.[ADDRESS KEY] = NRL.[EMPLOYER NUMBER] AND

CA.[ADDRESS TYPE] ='R')

UPDATE NRL

SET NRL.[SORT FIELD1] = dbo.fnReturnNRLSortField(CO.[SORT BILL BY],

ME.[FULL NAME],

ME.[EMPLOYEE SSN],

MET.[EMPLOYEE NUMBER],

ME.[DEPARTMENT CODE],

ME.[LOCATION CODE], 1),

NRL.[SORT FIELD2] = dbo.fnReturnNRLSortField(CO.[SORT BILL BY],

ME.[FULL NAME],

ME.[EMPLOYEE SSN],

MET.[EMPLOYEE NUMBER],

ME.[DEPARTMENT CODE],

ME.[LOCATION CODE], 2),

NRL.[EMPLOYEE SSN] = dbo.fnReturnFieldOrBlank(ME.[EMPLOYEE SSN], CO.[DO NOT DISPLAY SSN])

FROM [NO REASON LETTER] AS NRL INNERJOIN [COMPANY] AS CO ON(CO.[EMPLOYER NUMBER] = NRL.[EMPLOYER NUMBER])

INNERJOIN [MAIN EMPLOYEE] AS ME ON(ME.[EMPLOYEE SSN] = NRL.[EMPLOYEE SSN])

INNERJOIN [MAIN EMPLOYEE] AS MET ON(ME.[EMPLOYEE NUMBER] = NRL.[EMPLOYEE NUMBER])

|||

Hi,

you are not referencing the Table in the Select clause, therefore you cannot use it in the join part.

BTW. Did I mention that it is horrorible to use space and special characters in defintions ?

Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||

Now I'm confused.

First you TRUNCATE the [NO REASON LETTER] table.

Then you attempt to use JOIN conditions to that EMPTY table (but there is no previous mention of a JOIN to that table.. What are you trying to accomplish?

INNERJOIN [MAIN EMPLOYEE] AS MET ON [NO REASON LETTER].[EMPLOYEE NUMBER] = [MAIN EMPLOYEE].[EMPLOYEE NUMBER]

Even if it 'could' happen (and it just can't), since the table is empty, this would serve to filter out ALL possible rows and nothing would be inserted.

So what's the point?

|||

One other thing to keep in mind is that if you are going to Alias a table in a join clause, you probably should use it in the join.

INNERJOIN [MAIN EMPLOYEE] AS MET ON(ME.[EMPLOYEE NUMBER] = NRL.[EMPLOYEE NUMBER])

I would think that you would want to use MET.[EMPLOYEE NUMBER] instead of ME.

Ben Miller

Am I missing something - DBCC SHRINKFILE('NewFile', EMPTYFILE)

I create a filegroup, added a file to it and created a table with 1
varchar(256) column to it. I then added several rows of data. I wanted to
test removing the filegroup and can't. First I ran:
DBCC SHRINKFILE('NewFile', EMPTYFILE)
and received:
DbId = 34, FileId = 8, CurrentSize = 13056, MinimumSize = 1280,
UsedPages = 8, EstimatedPages = 8
I then run:
ALTER DATABASE TestDB REMOVE FILE NewFile
and get:
Server: Msg 5042, Level 16, State 1, Line 1
The file 'Newfile' cannot be removed because it is not empty.
The table is not miving to another filegroup.
You have to create another file in the same filegroup to hold the table or
you have to move the table to another filegroup. DBCC SHRINKFILE will not
reassign objects to a different filegroup.
To answer the next question, create a clustered index on the table in the
target file group to move a table.
Geoff N. Hiten
Senior Database Administrator
Microsoft SQL Server MVP
"Charlie" <SQL@.newsgroups.nospam> wrote in message
news:DE1296AC-082F-48D9-97E8-8FC5AF1D5452@.microsoft.com...
>I create a filegroup, added a file to it and created a table with 1
> varchar(256) column to it. I then added several rows of data. I wanted to
> test removing the filegroup and can't. First I ran:
> DBCC SHRINKFILE('NewFile', EMPTYFILE)
> and received:
> DbId = 34, FileId = 8, CurrentSize = 13056, MinimumSize = 1280,
> UsedPages = 8, EstimatedPages = 8
> I then run:
> ALTER DATABASE TestDB REMOVE FILE NewFile
> and get:
> Server: Msg 5042, Level 16, State 1, Line 1
> The file 'Newfile' cannot be removed because it is not empty.
> The table is not miving to another filegroup.
>
|||I have no idea why I thought it would magicaly reassign it to another
filegroup.
"Charlie" wrote:

> I create a filegroup, added a file to it and created a table with 1
> varchar(256) column to it. I then added several rows of data. I wanted to
> test removing the filegroup and can't. First I ran:
> DBCC SHRINKFILE('NewFile', EMPTYFILE)
> and received:
> DbId = 34, FileId = 8, CurrentSize = 13056, MinimumSize = 1280,
> UsedPages = 8, EstimatedPages = 8
> I then run:
> ALTER DATABASE TestDB REMOVE FILE NewFile
> and get:
> Server: Msg 5042, Level 16, State 1, Line 1
> The file 'Newfile' cannot be removed because it is not empty.
> The table is not miving to another filegroup.
>