Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Friday, March 30, 2012

Regarding Creating Stored Procedures If One Does Not Exist

Hello,
Very quick question (I hope) regarding SQL Server:
I want to create a query that basically says that if a stored procedure (say
sproc_foo) does not exist, then create the stored procedure. I know that
there are easy ways to do this with creating tables/databases if they don't
exist, but how is this possible with stored procedures?
Regards,
James Simpson
Straightway Technologies Inc.Hi James,
You can try something like this
IF NOT EXISTS (SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
AND type in (N'P', N'PC'))
BEGIN
CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
...
Hope this helps,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"James Simpson" wrote:
> Hello,
> Very quick question (I hope) regarding SQL Server:
> I want to create a query that basically says that if a stored procedure (say
> sproc_foo) does not exist, then create the stored procedure. I know that
> there are easy ways to do this with creating tables/databases if they don't
> exist, but how is this possible with stored procedures?
> Regards,
> James Simpson
> Straightway Technologies Inc.
>|||Ben,
Alas, that will not work as is, since CREATE PROCEDURE must be the first
statement in a batch. Scripting from SQL Server 2005 with the If Not Exists
check turned on produces:
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id =OBJECT_ID(N'[dbo].[MyProc]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @.statement = N'
CREATE PROC [dbo].[MyProc]
@.Parm1 char(6)
AS
-- Do Something'
So, as you can see it is a 'dynamic SQL' implementation. (I believe that
there is a CONNECT request for something better than this.)
RLF
"Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
news:36E61DF6-EBAB-45E8-B0E5-A91610CA5D46@.microsoft.com...
> Hi James,
> You can try something like this
> IF NOT EXISTS (SELECT * FROM sys.objects
> WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
> AND type in (N'P', N'PC'))
> BEGIN
> CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
> ...
> Hope this helps,
> Ben Nevarez
> Senior Database Administrator
> AIG SunAmerica
>
> "James Simpson" wrote:
>> Hello,
>> Very quick question (I hope) regarding SQL Server:
>> I want to create a query that basically says that if a stored procedure
>> (say
>> sproc_foo) does not exist, then create the stored procedure. I know that
>> there are easy ways to do this with creating tables/databases if they
>> don't
>> exist, but how is this possible with stored procedures?
>> Regards,
>> James Simpson
>> Straightway Technologies Inc.|||Dear Ben/Russel,
Ben - I tried the solution you gave and for whatever reason it does not
appear to work. I have also seen this type of example online and this query
fails miserably on SQL Server 2005 Express. Russel, the solution you gave
works perfectly, and hopefully Microsoft resolves this issue.
Regards,
James Simpson
Straightway Technologies Inc.|||Hi Russell,
I agree with your note but that was not intended to be a final and complete
solution and my primary purpose was to show the IF NOT EXISTS part.
Perhaps it is like saying that your code does not work as is either, because
you have BEGIN but END is missing :-)
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"Russell Fields" wrote:
> Ben,
> Alas, that will not work as is, since CREATE PROCEDURE must be the first
> statement in a batch. Scripting from SQL Server 2005 with the If Not Exists
> check turned on produces:
> IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id => OBJECT_ID(N'[dbo].[MyProc]') AND type in (N'P', N'PC'))
> BEGIN
> EXEC dbo.sp_executesql @.statement = N'
> CREATE PROC [dbo].[MyProc]
> @.Parm1 char(6)
> AS
> -- Do Something'
> So, as you can see it is a 'dynamic SQL' implementation. (I believe that
> there is a CONNECT request for something better than this.)
> RLF
>
> "Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
> news:36E61DF6-EBAB-45E8-B0E5-A91610CA5D46@.microsoft.com...
> >
> > Hi James,
> >
> > You can try something like this
> >
> > IF NOT EXISTS (SELECT * FROM sys.objects
> > WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
> > AND type in (N'P', N'PC'))
> > BEGIN
> > CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
> > ...
> >
> > Hope this helps,
> >
> > Ben Nevarez
> > Senior Database Administrator
> > AIG SunAmerica
> >
> >
> >
> > "James Simpson" wrote:
> >
> >> Hello,
> >> Very quick question (I hope) regarding SQL Server:
> >> I want to create a query that basically says that if a stored procedure
> >> (say
> >> sproc_foo) does not exist, then create the stored procedure. I know that
> >> there are easy ways to do this with creating tables/databases if they
> >> don't
> >> exist, but how is this possible with stored procedures?
> >>
> >> Regards,
> >>
> >> James Simpson
> >> Straightway Technologies Inc.
> >>
>
>|||Ben, OK. Sorry. I was just trying to emphasize that the 'natural' way will
not work as expected. - RLF
"Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
news:3C07E41D-E259-4887-ABCE-2C403FD6929A@.microsoft.com...
> Hi Russell,
> I agree with your note but that was not intended to be a final and
> complete
> solution and my primary purpose was to show the IF NOT EXISTS part.
> Perhaps it is like saying that your code does not work as is either,
> because
> you have BEGIN but END is missing :-)
> Ben Nevarez
> Senior Database Administrator
> AIG SunAmerica
>
> "Russell Fields" wrote:
>> Ben,
>> Alas, that will not work as is, since CREATE PROCEDURE must be the first
>> statement in a batch. Scripting from SQL Server 2005 with the If Not
>> Exists
>> check turned on produces:
>> IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id =>> OBJECT_ID(N'[dbo].[MyProc]') AND type in (N'P', N'PC'))
>> BEGIN
>> EXEC dbo.sp_executesql @.statement = N'
>> CREATE PROC [dbo].[MyProc]
>> @.Parm1 char(6)
>> AS
>> -- Do Something'
>> So, as you can see it is a 'dynamic SQL' implementation. (I believe that
>> there is a CONNECT request for something better than this.)
>> RLF
>>
>> "Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
>> news:36E61DF6-EBAB-45E8-B0E5-A91610CA5D46@.microsoft.com...
>> >
>> > Hi James,
>> >
>> > You can try something like this
>> >
>> > IF NOT EXISTS (SELECT * FROM sys.objects
>> > WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
>> > AND type in (N'P', N'PC'))
>> > BEGIN
>> > CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
>> > ...
>> >
>> > Hope this helps,
>> >
>> > Ben Nevarez
>> > Senior Database Administrator
>> > AIG SunAmerica
>> >
>> >
>> >
>> > "James Simpson" wrote:
>> >
>> >> Hello,
>> >> Very quick question (I hope) regarding SQL Server:
>> >> I want to create a query that basically says that if a stored
>> >> procedure
>> >> (say
>> >> sproc_foo) does not exist, then create the stored procedure. I know
>> >> that
>> >> there are easy ways to do this with creating tables/databases if they
>> >> don't
>> >> exist, but how is this possible with stored procedures?
>> >>
>> >> Regards,
>> >>
>> >> James Simpson
>> >> Straightway Technologies Inc.
>> >>
>>|||Russell, I think you were right. Thanks for the additional explanation.
I also got the code using the SQL Server Scripts Wizard and the 'Include if
NOT EXISTS' option turned on. The problem was that I replaced EXEC
dbo.sp_executesql with CREATE PROCEDURE to make the code easier to read and
understand.
Thanks,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"Russell Fields" wrote:
> Ben, OK. Sorry. I was just trying to emphasize that the 'natural' way will
> not work as expected. - RLF
> "Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
> news:3C07E41D-E259-4887-ABCE-2C403FD6929A@.microsoft.com...
> >
> > Hi Russell,
> >
> > I agree with your note but that was not intended to be a final and
> > complete
> > solution and my primary purpose was to show the IF NOT EXISTS part.
> >
> > Perhaps it is like saying that your code does not work as is either,
> > because
> > you have BEGIN but END is missing :-)
> >
> > Ben Nevarez
> > Senior Database Administrator
> > AIG SunAmerica
> >
> >
> >
> > "Russell Fields" wrote:
> >
> >> Ben,
> >>
> >> Alas, that will not work as is, since CREATE PROCEDURE must be the first
> >> statement in a batch. Scripting from SQL Server 2005 with the If Not
> >> Exists
> >> check turned on produces:
> >>
> >> IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id => >> OBJECT_ID(N'[dbo].[MyProc]') AND type in (N'P', N'PC'))
> >> BEGIN
> >> EXEC dbo.sp_executesql @.statement = N'
> >> CREATE PROC [dbo].[MyProc]
> >> @.Parm1 char(6)
> >> AS
> >> -- Do Something'
> >>
> >> So, as you can see it is a 'dynamic SQL' implementation. (I believe that
> >> there is a CONNECT request for something better than this.)
> >>
> >> RLF
> >>
> >>
> >> "Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
> >> news:36E61DF6-EBAB-45E8-B0E5-A91610CA5D46@.microsoft.com...
> >> >
> >> > Hi James,
> >> >
> >> > You can try something like this
> >> >
> >> > IF NOT EXISTS (SELECT * FROM sys.objects
> >> > WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
> >> > AND type in (N'P', N'PC'))
> >> > BEGIN
> >> > CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
> >> > ...
> >> >
> >> > Hope this helps,
> >> >
> >> > Ben Nevarez
> >> > Senior Database Administrator
> >> > AIG SunAmerica
> >> >
> >> >
> >> >
> >> > "James Simpson" wrote:
> >> >
> >> >> Hello,
> >> >> Very quick question (I hope) regarding SQL Server:
> >> >> I want to create a query that basically says that if a stored
> >> >> procedure
> >> >> (say
> >> >> sproc_foo) does not exist, then create the stored procedure. I know
> >> >> that
> >> >> there are easy ways to do this with creating tables/databases if they
> >> >> don't
> >> >> exist, but how is this possible with stored procedures?
> >> >>
> >> >> Regards,
> >> >>
> >> >> James Simpson
> >> >> Straightway Technologies Inc.
> >> >>
> >>
> >>
> >>
>
>

Regarding Creating Stored Procedures If One Does Not Exist

Hello,
Very quick question (I hope) regarding SQL Server:
I want to create a query that basically says that if a stored procedure (say
sproc_foo) does not exist, then create the stored procedure. I know that
there are easy ways to do this with creating tables/databases if they don't
exist, but how is this possible with stored procedures?
Regards,
James Simpson
Straightway Technologies Inc.
Hi James,
You can try something like this
IF NOT EXISTS (SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
AND type in (N'P', N'PC'))
BEGIN
CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
...
Hope this helps,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"James Simpson" wrote:

> Hello,
> Very quick question (I hope) regarding SQL Server:
> I want to create a query that basically says that if a stored procedure (say
> sproc_foo) does not exist, then create the stored procedure. I know that
> there are easy ways to do this with creating tables/databases if they don't
> exist, but how is this possible with stored procedures?
> Regards,
> James Simpson
> Straightway Technologies Inc.
>
|||Ben,
Alas, that will not work as is, since CREATE PROCEDURE must be the first
statement in a batch. Scripting from SQL Server 2005 with the If Not Exists
check turned on produces:
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N'[dbo].[MyProc]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @.statement = N'
CREATE PROC [dbo].[MyProc]
@.Parm1 char(6)
AS
-- Do Something'
So, as you can see it is a 'dynamic SQL' implementation. (I believe that
there is a CONNECT request for something better than this.)
RLF
"Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
news:36E61DF6-EBAB-45E8-B0E5-A91610CA5D46@.microsoft.com...[vbcol=seagreen]
> Hi James,
> You can try something like this
> IF NOT EXISTS (SELECT * FROM sys.objects
> WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
> AND type in (N'P', N'PC'))
> BEGIN
> CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
> ...
> Hope this helps,
> Ben Nevarez
> Senior Database Administrator
> AIG SunAmerica
>
> "James Simpson" wrote:
|||Dear Ben/Russel,
Ben - I tried the solution you gave and for whatever reason it does not
appear to work. I have also seen this type of example online and this query
fails miserably on SQL Server 2005 Express. Russel, the solution you gave
works perfectly, and hopefully Microsoft resolves this issue.
Regards,
James Simpson
Straightway Technologies Inc.
|||Hi Russell,
I agree with your note but that was not intended to be a final and complete
solution and my primary purpose was to show the IF NOT EXISTS part.
Perhaps it is like saying that your code does not work as is either, because
you have BEGIN but END is missing :-)
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"Russell Fields" wrote:

> Ben,
> Alas, that will not work as is, since CREATE PROCEDURE must be the first
> statement in a batch. Scripting from SQL Server 2005 with the If Not Exists
> check turned on produces:
> IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id =
> OBJECT_ID(N'[dbo].[MyProc]') AND type in (N'P', N'PC'))
> BEGIN
> EXEC dbo.sp_executesql @.statement = N'
> CREATE PROC [dbo].[MyProc]
> @.Parm1 char(6)
> AS
> -- Do Something'
> So, as you can see it is a 'dynamic SQL' implementation. (I believe that
> there is a CONNECT request for something better than this.)
> RLF
>
> "Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
> news:36E61DF6-EBAB-45E8-B0E5-A91610CA5D46@.microsoft.com...
>
>
|||Ben, OK. Sorry. I was just trying to emphasize that the 'natural' way will
not work as expected. - RLF
"Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
news:3C07E41D-E259-4887-ABCE-2C403FD6929A@.microsoft.com...[vbcol=seagreen]
> Hi Russell,
> I agree with your note but that was not intended to be a final and
> complete
> solution and my primary purpose was to show the IF NOT EXISTS part.
> Perhaps it is like saying that your code does not work as is either,
> because
> you have BEGIN but END is missing :-)
> Ben Nevarez
> Senior Database Administrator
> AIG SunAmerica
>
> "Russell Fields" wrote:
|||Russell, I think you were right. Thanks for the additional explanation.
I also got the code using the SQL Server Scripts Wizard and the 'Include if
NOT EXISTS' option turned on. The problem was that I replaced EXEC
dbo.sp_executesql with CREATE PROCEDURE to make the code easier to read and
understand.
Thanks,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"Russell Fields" wrote:

> Ben, OK. Sorry. I was just trying to emphasize that the 'natural' way will
> not work as expected. - RLF
> "Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
> news:3C07E41D-E259-4887-ABCE-2C403FD6929A@.microsoft.com...
>
>

Regarding Creating Stored Procedures If One Does Not Exist

Hello,
Very quick question (I hope) regarding SQL Server:
I want to create a query that basically says that if a stored procedure (say
sproc_foo) does not exist, then create the stored procedure. I know that
there are easy ways to do this with creating tables/databases if they don't
exist, but how is this possible with stored procedures?
Regards,
James Simpson
Straightway Technologies Inc.Hi James,
You can try something like this
IF NOT EXISTS (SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
AND type in (N'P', N'PC'))
BEGIN
CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
...
Hope this helps,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"James Simpson" wrote:

> Hello,
> Very quick question (I hope) regarding SQL Server:
> I want to create a query that basically says that if a stored procedure (s
ay
> sproc_foo) does not exist, then create the stored procedure. I know that
> there are easy ways to do this with creating tables/databases if they don'
t
> exist, but how is this possible with stored procedures?
> Regards,
> James Simpson
> Straightway Technologies Inc.
>|||Ben,
Alas, that will not work as is, since CREATE PROCEDURE must be the first
statement in a batch. Scripting from SQL Server 2005 with the If Not Exists
check turned on produces:
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N'[dbo].[MyProc]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @.statement = N'
CREATE PROC [dbo].[MyProc]
@.Parm1 char(6)
AS
-- Do Something'
So, as you can see it is a 'dynamic SQL' implementation. (I believe that
there is a CONNECT request for something better than this.)
RLF
"Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
news:36E61DF6-EBAB-45E8-B0E5-A91610CA5D46@.microsoft.com...[vbcol=seagreen]
> Hi James,
> You can try something like this
> IF NOT EXISTS (SELECT * FROM sys.objects
> WHERE object_id = OBJECT_ID(N'[dbo].[uspGetBillOfMaterials]')
> AND type in (N'P', N'PC'))
> BEGIN
> CREATE PROCEDURE [dbo].[uspGetBillOfMaterials]
> ...
> Hope this helps,
> Ben Nevarez
> Senior Database Administrator
> AIG SunAmerica
>
> "James Simpson" wrote:
>|||Dear Ben/Russel,
Ben - I tried the solution you gave and for whatever reason it does not
appear to work. I have also seen this type of example online and this query
fails miserably on SQL Server 2005 Express. Russel, the solution you gave
works perfectly, and hopefully Microsoft resolves this issue.
Regards,
James Simpson
Straightway Technologies Inc.|||Hi Russell,
I agree with your note but that was not intended to be a final and complete
solution and my primary purpose was to show the IF NOT EXISTS part.
Perhaps it is like saying that your code does not work as is either, because
you have BEGIN but END is missing :-)
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"Russell Fields" wrote:

> Ben,
> Alas, that will not work as is, since CREATE PROCEDURE must be the first
> statement in a batch. Scripting from SQL Server 2005 with the If Not Exis
ts
> check turned on produces:
> IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id =
> OBJECT_ID(N'[dbo].[MyProc]') AND type in (N'P', N'PC'))
> BEGIN
> EXEC dbo.sp_executesql @.statement = N'
> CREATE PROC [dbo].[MyProc]
> @.Parm1 char(6)
> AS
> -- Do Something'
> So, as you can see it is a 'dynamic SQL' implementation. (I believe that
> there is a CONNECT request for something better than this.)
> RLF
>
> "Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
> news:36E61DF6-EBAB-45E8-B0E5-A91610CA5D46@.microsoft.com...
>
>|||Ben, OK. Sorry. I was just trying to emphasize that the 'natural' way will
not work as expected. - RLF
"Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
news:3C07E41D-E259-4887-ABCE-2C403FD6929A@.microsoft.com...[vbcol=seagreen]
> Hi Russell,
> I agree with your note but that was not intended to be a final and
> complete
> solution and my primary purpose was to show the IF NOT EXISTS part.
> Perhaps it is like saying that your code does not work as is either,
> because
> you have BEGIN but END is missing :-)
> Ben Nevarez
> Senior Database Administrator
> AIG SunAmerica
>
> "Russell Fields" wrote:
>|||Russell, I think you were right. Thanks for the additional explanation.
I also got the code using the SQL Server Scripts Wizard and the 'Include if
NOT EXISTS' option turned on. The problem was that I replaced EXEC
dbo.sp_executesql with CREATE PROCEDURE to make the code easier to read and
understand.
Thanks,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"Russell Fields" wrote:

> Ben, OK. Sorry. I was just trying to emphasize that the 'natural' way wil
l
> not work as expected. - RLF
> "Ben Nevarez" <BenNevarez@.discussions.microsoft.com> wrote in message
> news:3C07E41D-E259-4887-ABCE-2C403FD6929A@.microsoft.com...
>
>sql

Regarding BulkInsert

Hello,
I am trying to do this and i am getting this error..
create table #temptbl (rec varchar(284))
BULK INSERT #temptbl FROM 'z:\Testline.txt'
WITH ( DATAFILETYPE = 'char',
FIELDTERMINATOR = '\r\n',
CODEPAGE = 'RAW',
MAXERRORS = 10000,
FIRSTROW = 2)
Server: Msg 8104, Level 16, State 2, Line 3
The current user is not the database or object owner of table '#timberline'.
Cannot perform SET operation.
User has BulkAdmin rights and he is a dbo in the database.
Pls advise.
Thanks,
Message posted via http://www.droptable.com
> User has BulkAdmin rights and he is a dbo in the database.
This should work according to:
http://support.microsoft.com/default...b;en-us;302621
http://support.microsoft.com/default...b;en-us;243023
Are you certain the user is dbo or a db_owner role member? Please confirm
with SELECT USER, IS_MEMBER('db_owner') in the tempdb database. Tempdb is
recreated at startup so any permissions in that database are lost.
Hope this helps.
Dan Guzman
SQL Server MVP
"msqldba m via droptable.com" <u11604@.uwe> wrote in message
news:582f80513d042@.uwe...
> Hello,
> I am trying to do this and i am getting this error..
> create table #temptbl (rec varchar(284))
> BULK INSERT #temptbl FROM 'z:\Testline.txt'
> WITH ( DATAFILETYPE = 'char',
> FIELDTERMINATOR = '\r\n',
> CODEPAGE = 'RAW',
> MAXERRORS = 10000,
> FIRSTROW = 2)
> Server: Msg 8104, Level 16, State 2, Line 3
> The current user is not the database or object owner of table
> '#timberline'.
> Cannot perform SET operation.
>
> User has BulkAdmin rights and he is a dbo in the database.
> Pls advise.
> Thanks,
> --
> Message posted via http://www.droptable.com

Regarding BulkInsert

Hello,
I am trying to do this and i am getting this error..
create table #temptbl (rec varchar(284))
BULK INSERT #temptbl FROM 'z:\Testline.txt'
WITH ( DATAFILETYPE = 'char',
FIELDTERMINATOR = '\r\n',
CODEPAGE = 'RAW',
MAXERRORS = 10000,
FIRSTROW = 2)
Server: Msg 8104, Level 16, State 2, Line 3
The current user is not the database or object owner of table '#timberline'.
Cannot perform SET operation.
User has BulkAdmin rights and he is a dbo in the database.
Pls advise.
Thanks,
--
Message posted via http://www.sqlmonster.com> User has BulkAdmin rights and he is a dbo in the database.
This should work according to:
http://support.microsoft.com/default.aspx?scid=kb;en-us;302621
http://support.microsoft.com/default.aspx?scid=kb;en-us;243023
Are you certain the user is dbo or a db_owner role member? Please confirm
with SELECT USER, IS_MEMBER('db_owner') in the tempdb database. Tempdb is
recreated at startup so any permissions in that database are lost.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"msqldba m via SQLMonster.com" <u11604@.uwe> wrote in message
news:582f80513d042@.uwe...
> Hello,
> I am trying to do this and i am getting this error..
> create table #temptbl (rec varchar(284))
> BULK INSERT #temptbl FROM 'z:\Testline.txt'
> WITH ( DATAFILETYPE = 'char',
> FIELDTERMINATOR = '\r\n',
> CODEPAGE = 'RAW',
> MAXERRORS = 10000,
> FIRSTROW = 2)
> Server: Msg 8104, Level 16, State 2, Line 3
> The current user is not the database or object owner of table
> '#timberline'.
> Cannot perform SET operation.
>
> User has BulkAdmin rights and he is a dbo in the database.
> Pls advise.
> Thanks,
> --
> Message posted via http://www.sqlmonster.com

Regarding BulkInsert

Hello,
I am trying to do this and i am getting this error..
create table #temptbl (rec varchar(284))
BULK INSERT #temptbl FROM 'z:\Testline.txt'
WITH ( DATAFILETYPE = 'char',
FIELDTERMINATOR = '\r\n',
CODEPAGE = 'RAW',
MAXERRORS = 10000,
FIRSTROW = 2)
Server: Msg 8104, Level 16, State 2, Line 3
The current user is not the database or object owner of table '#timberline'.
Cannot perform SET operation.
User has BulkAdmin rights and he is a dbo in the database.
Pls advise.
Thanks,
Message posted via http://www.droptable.com> User has BulkAdmin rights and he is a dbo in the database.
This should work according to:
http://support.microsoft.com/defaul...kb;en-us;302621
http://support.microsoft.com/defaul...kb;en-us;243023
Are you certain the user is dbo or a db_owner role member? Please confirm
with SELECT USER, IS_MEMBER('db_owner') in the tempdb database. Tempdb is
recreated at startup so any permissions in that database are lost.
Hope this helps.
Dan Guzman
SQL Server MVP
"msqldba m via droptable.com" <u11604@.uwe> wrote in message
news:582f80513d042@.uwe...
> Hello,
> I am trying to do this and i am getting this error..
> create table #temptbl (rec varchar(284))
> BULK INSERT #temptbl FROM 'z:\Testline.txt'
> WITH ( DATAFILETYPE = 'char',
> FIELDTERMINATOR = '\r\n',
> CODEPAGE = 'RAW',
> MAXERRORS = 10000,
> FIRSTROW = 2)
> Server: Msg 8104, Level 16, State 2, Line 3
> The current user is not the database or object owner of table
> '#timberline'.
> Cannot perform SET operation.
>
> User has BulkAdmin rights and he is a dbo in the database.
> Pls advise.
> Thanks,
> --
> Message posted via http://www.droptable.com

Monday, March 26, 2012

reg error in sql


CREATE TABLE [dbo].[ContactInfo] (
[ContactID] [int] IDENTITY (1, 1) NOT NULL ,
[Title] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FirstName] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[MiddleName] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[LastName] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[JobTitle] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Company] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Website] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[OfficePhone] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[HomePhone] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Mobile] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Fax] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[OfficialEmail] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PersonalEmail] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

) ON [PRIMARY]

In the above code i get the error"Line 3: Incorrect syntax near 'COLLATE'. " while compiling in sql

What is the error?


GO

i just ran the whole thing in my SQL Server (Sql Server 2000) and it worked fine.

hth,

mcm

|||

I ran this script in SQL server 2005 & it run without any problems :-) which version of SQL server are you using ?

refreshview removes user defined functions from sysdepends

When I create a procedure that references a user defined procedure it
appears in sysdepends, but disapears after being refreshed. Is this
expected and is there an alternative to sp_refreshview that correctly
refreshes sysdepends
--0--0--
print 'drop depenencies'
go
drop view depends_test
go
print 'create view'
go
create view depends_test as
select
dbo.ufJsmTranslate('test') As test_column
from
(select 1 one) test
go
print 'check depenencies'
go
sp_depends depends_test
go
print 'refresh'
go
sp_refreshview depends_test
go
print 'check depenencies'
go
sp_depends depends_test
--0--0--
drop depenencies
create view
check depenencies
In the current database, the specified object references the following:
name type updated selected column
-- -- -- -- --
dbo.ufJsmTranslate scalar function no no
refresh
check depenencies
Object does not reference any object, and no objects reference it.
--0--0--May be this is a bug, It seems that sp_refreshview does not update reference
s
to udfs. Here I have a script with the same problem. I also tried to create
the udf and view with the SCHEMABINDING property, everything was ok, except
that sp_refresh is giving me an error when I try to refresh the view.
-- same problem
use northwind
go
create table t(colA int)
go
create function dbo.ufn_funct1 (
@.i int
)
returns int
as
begin
return (@.i)
end
go
create view myview
as
select dbo.ufn_funct1(colA) as colA from t
go
exec sp_depends myview
go
exec sp_refreshview myview
go
exec sp_depends myview
go
drop view myview
go
drop function dbo.ufn_funct1
go
drop table t
go
-- Tried to fix it using schemabinfing
-- sp_refreshview is giving me an error
use northwind
go
create table t(colA int)
go
create function dbo.ufn_funct1 (
@.i int
)
returns int
with schemabinding
as
begin
return (@.i)
end
go
create view dbo.myview
with schemabinding
as
select dbo.ufn_funct1(colA) as colA from dbo.t
go
exec sp_depends 'dbo.myview'
go
exec sp_refreshview 'dbo.myview'
go
-- Server: Msg 208, Level 16, State 8, Procedure sp_refreshview, Line 1
-- Invalid object name 'dbo.myview'.
exec sp_depends 'dbo.myview'
go
drop view dbo.myview
go
drop function dbo.ufn_funct1
go
drop table t
go
AMB
"bilbo.baggins@.freesurf.ch" wrote:

> When I create a procedure that references a user defined procedure it
> appears in sysdepends, but disapears after being refreshed. Is this
> expected and is there an alternative to sp_refreshview that correctly
> refreshes sysdepends
> --0--0--
> print 'drop depenencies'
> go
> drop view depends_test
> go
> print 'create view'
> go
> create view depends_test as
> select
> dbo.ufJsmTranslate('test') As test_column
> from
> (select 1 one) test
> go
> print 'check depenencies'
> go
> sp_depends depends_test
> go
> print 'refresh'
> go
> sp_refreshview depends_test
> go
> print 'check depenencies'
> go
> sp_depends depends_test
> --0--0--
> drop depenencies
> create view
> check depenencies
> In the current database, the specified object references the following:
> name type updated selected column
> -- -- -- -- --
> dbo.ufJsmTranslate scalar function no no
> refresh
> check depenencies
> Object does not reference any object, and no objects reference it.
> --0--0--
>|||Correction,

> May be this is a bug, It seems that sp_refreshview does not update referen
ces
> to udfs. Here I have a script with the same problem. I also tried to creat
e
> the udf and view with the SCHEMABINDING property, everything was ok, excep
t
> that sp_refresh is giving me an error when I try to refresh the view.
..., except that sp_refreshview ...

> -- Server: Msg 208, Level 16, State 8, Procedure sp_refreshview, Line 1
> -- Invalid object name 'dbo.myview'.
> exec sp_depends 'dbo.myview'
> go
-- Server: Msg 208, Level 16, State 8, Procedure sp_refreshview, Line 1
-- Invalid object name 'dbo.myview'.
exec sp_refreshview 'dbo.myview'
go
AMB
"Alejandro Mesa" wrote:
> May be this is a bug, It seems that sp_refreshview does not update referen
ces
> to udfs. Here I have a script with the same problem. I also tried to creat
e
> the udf and view with the SCHEMABINDING property, everything was ok, excep
t
> that sp_refresh is giving me an error when I try to refresh the view.
> -- same problem
> use northwind
> go
> create table t(colA int)
> go
> create function dbo.ufn_funct1 (
> @.i int
> )
> returns int
> as
> begin
> return (@.i)
> end
> go
> create view myview
> as
> select dbo.ufn_funct1(colA) as colA from t
> go
> exec sp_depends myview
> go
> exec sp_refreshview myview
> go
> exec sp_depends myview
> go
> drop view myview
> go
> drop function dbo.ufn_funct1
> go
> drop table t
> go
> -- Tried to fix it using schemabinfing
> -- sp_refreshview is giving me an error
> use northwind
> go
> create table t(colA int)
> go
> create function dbo.ufn_funct1 (
> @.i int
> )
> returns int
> with schemabinding
> as
> begin
> return (@.i)
> end
> go
> create view dbo.myview
> with schemabinding
> as
> select dbo.ufn_funct1(colA) as colA from dbo.t
> go
> exec sp_depends 'dbo.myview'
> go
> exec sp_refreshview 'dbo.myview'
> go
> -- Server: Msg 208, Level 16, State 8, Procedure sp_refreshview, Line 1
> -- Invalid object name 'dbo.myview'.
> exec sp_depends 'dbo.myview'
> go
> drop view dbo.myview
> go
> drop function dbo.ufn_funct1
> go
> drop table t
> go
>
> AMB
>
> "bilbo.baggins@.freesurf.ch" wrote:
>

Refreshing links in frontend

Hi everyone,
Could someone explain to me how to refresh the links to my sql server?
Each time i modify or create a field in a table, the modifications are
not implented in the front-end. How can i resolve this.
Greetings,
StefanieAre you selecting from views with SELECT *? In this case, check out
sp_refreshview in the Books Online.
--
Hope this helps.
Dan Guzman
SQL Server MVP
--
SQL FAQ links (courtesy Neil Pike):
http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
--
"Stefanie Pindew" <spindew@.yahoo.com> wrote in message
news:ehJkMpZXDHA.1004@.TK2MSFTNGP12.phx.gbl...
> Hi everyone,
> Could someone explain to me how to refresh the links to my sql server?
> Each time i modify or create a field in a table, the modifications are
> not implented in the front-end. How can i resolve this.
> Greetings,
> Stefanie
>|||Or are you referring to an Access front end? In that case,
you can use the Linked Table Manager or do it
programmatically with the refresh method of the tabledefs
collection.
--Sue
On Fri, 08 Aug 2003 12:46:17 +0200, Stefanie Pindew
<spindew@.yahoo.com> wrote:
>Hi everyone,
>Could someone explain to me how to refresh the links to my sql server?
>Each time i modify or create a field in a table, the modifications are
>not implented in the front-end. How can i resolve this.
>Greetings,
>Stefanie|||>--Original Message--
>Or are you referring to an Access front end? In that case,
>you can use the Linked Table Manager or do it
>programmatically with the refresh method of the tabledefs
>collection.
>--Sue
>On Fri, 08 Aug 2003 12:46:17 +0200, Stefanie Pindew
><spindew@.yahoo.com> wrote:
>>Hi everyone,
>>Could someone explain to me how to refresh the links to
my sql server?
>>Each time i modify or create a field in a table, the
modifications are
>>not implented in the front-end. How can i resolve this.
>>Greetings,
>>Stefanie
>.
>Hi,
I want it do it programmatically in the access front-end
and in the access adp front-end|||Stefanie,
I've just checked the following code and it works:
Dim tdLoop As TableDef
For Each tdLoop In CurrentDb.TableDefs
tdLoop.RefreshLink
Next
However, I can remember having problems when using the
.RefreshLink method... Give it a try though.
Regards,
Danny
"Stefanie Pindew" <spindew@.lollo.com> wrote in message news:02f201c35fee$71d670c0$a001280a@.phx.gbl...
> >--Original Message--
> >Or are you referring to an Access front end? In that case,
> >you can use the Linked Table Manager or do it
> >programmatically with the refresh method of the tabledefs
> >collection.
> >
> >--Sue
> >
> >On Fri, 08 Aug 2003 12:46:17 +0200, Stefanie Pindew
> ><spindew@.yahoo.com> wrote:
> >
> >>Hi everyone,
> >>
> >>Could someone explain to me how to refresh the links to
> my sql server?
> >>Each time i modify or create a field in a table, the
> modifications are
> >>not implented in the front-end. How can i resolve this.
> >>
> >>Greetings,
> >>
> >>Stefanie
> >
> >.
> >Hi,
> I want it do it programmatically in the access front-end
> and in the access adp front-end|||>--Original Message--
>Stefanie,
>I've just checked the following code and it works:
>Dim tdLoop As TableDef
>For Each tdLoop In CurrentDb.TableDefs
> tdLoop.RefreshLink
>Next
>However, I can remember having problems when using the
>..RefreshLink method... Give it a try though.
>Regards,
>Danny
>
>"Stefanie Pindew" <spindew@.lollo.com> wrote in message
news:02f201c35fee$71d670c0$a001280a@.phx.gbl...
>> >--Original Message--
>> >Or are you referring to an Access front end? In that
case,
>> >you can use the Linked Table Manager or do it
>> >programmatically with the refresh method of the
tabledefs
>> >collection.
>> >
>> >--Sue
>> >
>> >On Fri, 08 Aug 2003 12:46:17 +0200, Stefanie Pindew
>> ><spindew@.yahoo.com> wrote:
>> >
>> >>Hi everyone,
>> >>
>> >>Could someone explain to me how to refresh the links
to
>> my sql server?
>> >>Each time i modify or create a field in a table, the
>> modifications are
>> >>not implented in the front-end. How can i resolve
this.
>> >>
>> >>Greetings,
>> >>
>> >>Stefanie
>> >
>> >.
>> >Hi,
>> I want it do it programmatically in the access front-end
>> and in the access adp front-end
>
>.
>He thanks man, it works for me too|||Stefanie,
There are some issues with using .RefreshLink with Access97,
but I can't remember what they are. In case you have any
problems, I ended up implementing a solution that deleted the
linked tables from within Access and then re-linked them.
Both tasks can be accomplished using the DoCmd object:
DoCmd.DeleteObject
DoCmd.TransferDatabase
Email me if you want some sample code.
Regards,
Danny
"Stefanie Pindew" <spindew@.lollo.com> wrote in message news:066501c35ffe$995740b0$a301280a@.phx.gbl...
> >--Original Message--
> >Stefanie,
> >
> >I've just checked the following code and it works:
> >
> >Dim tdLoop As TableDef
> >For Each tdLoop In CurrentDb.TableDefs
> > tdLoop.RefreshLink
> >Next
> >
> >However, I can remember having problems when using the
> >..RefreshLink method... Give it a try though.
> >
> >Regards,
> >Danny
> >
> >
> >"Stefanie Pindew" <spindew@.lollo.com> wrote in message
> news:02f201c35fee$71d670c0$a001280a@.phx.gbl...
> >>
> >> >--Original Message--
> >> >Or are you referring to an Access front end? In that
> case,
> >> >you can use the Linked Table Manager or do it
> >> >programmatically with the refresh method of the
> tabledefs
> >> >collection.
> >> >
> >> >--Sue
> >> >
> >> >On Fri, 08 Aug 2003 12:46:17 +0200, Stefanie Pindew
> >> ><spindew@.yahoo.com> wrote:
> >> >
> >> >>Hi everyone,
> >> >>
> >> >>Could someone explain to me how to refresh the links
> to
> >> my sql server?
> >> >>Each time i modify or create a field in a table, the
> >> modifications are
> >> >>not implented in the front-end. How can i resolve
> this.
> >> >>
> >> >>Greetings,
> >> >>
> >> >>Stefanie
> >> >
> >> >.
> >> >Hi,
> >>
> >> I want it do it programmatically in the access front-end
> >> and in the access adp front-end
> >
> >
> >.
> >He thanks man, it works for me too

Refreshing Links in Access doesn't allow me to Add Records!

Hi
I have an application in Access2003 with linked tables. When I create the
links manually (picking DNS etc) I have no problems. When I then try to
recreate the links programatically (different users) I am not able to add an
y
records to any of the tables! If I erase all the linked tables and reconnect
manually with the other user I have no problems!
I am using the relink code from
http://support.microsoft.com/defaul...kb;en-us;159691
Any and all suggestions Welcome!!!
Regards
Meir
Suggestions?There is a seperate newgroup for acceess/adp/sql server integration.
Post there
--
Regards
R.D
--Knowledge gets doubled when shared
"mrrcomp" wrote:

> Hi
> I have an application in Access2003 with linked tables. When I create the
> links manually (picking DNS etc) I have no problems. When I then try to
> recreate the links programatically (different users) I am not able to add
any
> records to any of the tables! If I erase all the linked tables and reconne
ct
> manually with the other user I have no problems!
> I am using the relink code from
> http://support.microsoft.com/defaul...kb;en-us;159691
>
> Any and all suggestions Welcome!!!
> Regards
> Meir
>
> Suggestions?
>|||As long as the user has permissions in the database and you have a
primary key defined on the table, inserts an dupdates shouldn't be a
problem. However, instead of using a DSN, you can supply connection
information in your code. This should get you started:
Public Sub LinkODBConnectionString()
Dim strConnection As String
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
' Specify the driver, the server, and the connection
strConnection = "ODBC;Driver={SQL Server};" & _
" Server=(local);Database=SqlDbName;Truste
d_Connection=Yes"
' Specifying a SQLS user/password instead of integrated security
' strConnection = "ODBC;Driver={SQL Server};" & _
' " Server=(Local);Database=SqlDbName;UID=Us
erName;PWD=password"
' Create Linked Table. The LinkedTableName and the
' ServerTableName can be the same.
Set tdf = db.CreateTableDef("LinkedTableName")
tdf.Connect = strConnection
tdf.SourceTableName = "ServerTableName"
db.TableDefs.Append tdf
Set tdf = Nothing
End Sub
On Fri, 7 Oct 2005 05:17:03 -0700, "mrrcomp"
<mrrcomp@.discussions.microsoft.com> wrote:

>Hi
>I have an application in Access2003 with linked tables. When I create the
>links manually (picking DNS etc) I have no problems. When I then try to
>recreate the links programatically (different users) I am not able to add a
ny
>records to any of the tables! If I erase all the linked tables and reconnec
t
>manually with the other user I have no problems!
>I am using the relink code from
>http://support.microsoft.com/defaul...kb;en-us;159691
>
>Any and all suggestions Welcome!!!
>Regards
>Meir
>
>Suggestions?sql

Friday, March 23, 2012

Reformatting ResultSet

I'm using ADO.Net to return a set of records from a SQL Server, which I
then process to create a text stream ultimately used as the InnerHTML
property of a browser control in a C# project. Please don't ask why I'm
doing it that way. I know it's stupid, but customer requirements dictate
that it be done that way. Here's my question. Assume I get the following
return from the SQL query:
KeyType ILS KeyVal 1 <ILS F1>Somevalue</ILS F2><ILS F2>Somevalue</ILS
F2>...
KeyType PARTS KeyVal 2 <PARTS F1>Somevalue</PARTS F1><PARTS
F2>Somevalue</PARTS F2>...
KeyType ILS KeyVal 3 <ILS F1>Somevalue</ILS F2><ILS
F2>SomeSpecificvalue</ILS F2>...
After processing, this yields:
<ILS Records>
<ILS>KeyVal 1
<ILS F1>Somevalue</ILS F1>
<ILS F2>Somevalue</ILS F2>
</ILS>
<ILS match='true'>KeyVal 3
<ILS F1>Somevalue</ILS F1>
<ILS F2><b>SomeSpecificvalue</b></ILS F2>
</ILS>
</ILS Records>
<PARTS Records>
<PARTS>KeyVal 2
<PARTS F1>Somevalue</PARTS F1>
<PARTS F2>Somevalue</PARTS F2>
</PARTS>
</PARTS Records>
The result above is funneled through an XML stylesheet, which renders
exactly the way the customer wants it to. There are a whole lot of ifs,
ands, and buts associated with how each record is formatted, its weight, its
type, its priority, query parameters, etc.. The SQL Server returns the
result set into the datareader object very quickly. Does it make sense to
put the application specific formatting logic into stored procedures, or
would it make more sense to leave the record level formatting in the C#
code?> Does it make sense to
> put the application specific formatting logic into stored procedures, or
> would it make more sense to leave the record level formatting in the C#
> code?
I'd leave it in c# code. TSQL isn't the best language in the world for these
types of things. I
think that your code will be more readable, manageable and efficient as c# c
ode.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"bigbob" <big@.bob.com> wrote in message news:eAn$3a9AFHA.1400@.TK2MSFTNGP11.phx.gbl...[color
=darkred]
> I'm using ADO.Net to return a set of records from a SQL Server, which I
> then process to create a text stream ultimately used as the InnerHTML
> property of a browser control in a C# project. Please don't ask why I'm
> doing it that way. I know it's stupid, but customer requirements dictate
> that it be done that way. Here's my question. Assume I get the following
> return from the SQL query:
> KeyType ILS KeyVal 1 <ILS F1>Somevalue</ILS F2><ILS F2>Somevalue</ILS
> F2>...
> KeyType PARTS KeyVal 2 <PARTS F1>Somevalue</PARTS F1><PARTS
> F2>Somevalue</PARTS F2>...
> KeyType ILS KeyVal 3 <ILS F1>Somevalue</ILS F2><ILS
> F2>SomeSpecificvalue</ILS F2>...
> After processing, this yields:
> <ILS Records>
> <ILS>KeyVal 1
> <ILS F1>Somevalue</ILS F1>
> <ILS F2>Somevalue</ILS F2>
> </ILS>
> <ILS match='true'>KeyVal 3
> <ILS F1>Somevalue</ILS F1>
> <ILS F2><b>SomeSpecificvalue</b></ILS F2>
> </ILS>
> </ILS Records>
> <PARTS Records>
> <PARTS>KeyVal 2
> <PARTS F1>Somevalue</PARTS F1>
> <PARTS F2>Somevalue</PARTS F2>
> </PARTS>
> </PARTS Records>
> The result above is funneled through an XML stylesheet, which renders
> exactly the way the customer wants it to. There are a whole lot of ifs,
> ands, and buts associated with how each record is formatted, its weight, i
ts
> type, its priority, query parameters, etc.. The SQL Server returns the
> result set into the datareader object very quickly. Does it make sense to
> put the application specific formatting logic into stored procedures, or
> would it make more sense to leave the record level formatting in the C#
> code?
>[/color]|||Thanks, Tibor.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%232FLMK%23AFHA.1188@.tk2msftngp13.phx.gbl...
> I'd leave it in c# code. TSQL isn't the best language in the world for
these types of things. I
> think that your code will be more readable, manageable and efficient as c#
code.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "bigbob" <big@.bob.com> wrote in message
news:eAn$3a9AFHA.1400@.TK2MSFTNGP11.phx.gbl...
its
to
>

Reflective linking

Greetings.
I want to create a tree control which will list all the employees in an
employee table in the correct hierarchy like
<company>
managers
sub managers
employees
For that, how can I setup reflective linking (linking ot the same table) in
SQL server and how can I populate the tree control from it ?
Thanks!
You may have a look here:
(Quelle:
http://msdn.microsoft.com/library/de...qd_14_5yk3.asp)
But the main part to populate the tree should be implemented in your
frontend apllication. The best thing would be to set up some recursive
function which alway try to first retrieve the "manager" and the search for
the next level, and so on.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
"news.microsoft.com" <v-hshah@.microsoft.com> schrieb im Newsbeitrag
news:%23uukSelZFHA.3364@.TK2MSFTNGP09.phx.gbl...
> Greetings.
> I want to create a tree control which will list all the employees in an
> employee table in the correct hierarchy like
> <company>
> managers
> sub managers
> employees
>
> For that, how can I setup reflective linking (linking ot the same table)
> in SQL server and how can I populate the tree control from it ?
> Thanks!
>
|||Get a copy of TREES & HIERARCHIES IN SQL for details, but look up the
"nested set model" on Google. There is no need for self-referencing
tables, recursion or procedural code.
sql

Reflective linking

Greetings.
I want to create a tree control which will list all the employees in an
employee table in the correct hierarchy like
<company>
managers
sub managers
employees
For that, how can I setup reflective linking (linking ot the same table) in
SQL server and how can I populate the tree control from it ?
Thanks!You may have a look here:
(Quelle:
http://msdn.microsoft.com/library/d...r />
_5yk3.asp)
But the main part to populate the tree should be implemented in your
frontend apllication. The best thing would be to set up some recursive
function which alway try to first retrieve the "manager" and the search for
the next level, and so on.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"news.microsoft.com" <v-hshah@.microsoft.com> schrieb im Newsbeitrag
news:%23uukSelZFHA.3364@.TK2MSFTNGP09.phx.gbl...
> Greetings.
> I want to create a tree control which will list all the employees in an
> employee table in the correct hierarchy like
> <company>
> managers
> sub managers
> employees
>
> For that, how can I setup reflective linking (linking ot the same table)
> in SQL server and how can I populate the tree control from it ?
> Thanks!
>|||Get a copy of TREES & HIERARCHIES IN SQL for details, but look up the
"nested set model" on Google. There is no need for self-referencing
tables, recursion or procedural code.

Reflective linking

Greetings.
I want to create a tree control which will list all the employees in an
employee table in the correct hierarchy like
<company>
managers
sub managers
employees
For that, how can I setup reflective linking (linking ot the same table) in
SQL server and how can I populate the tree control from it ?
Thanks!You may have a look here:
(Quelle:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_qd_14_5yk3.asp)
But the main part to populate the tree should be implemented in your
frontend apllication. The best thing would be to set up some recursive
function which alway try to first retrieve the "manager" and the search for
the next level, and so on.
HTH, Jens Suessmeyer.
--
http://www.sqlserver2005.de
--
"news.microsoft.com" <v-hshah@.microsoft.com> schrieb im Newsbeitrag
news:%23uukSelZFHA.3364@.TK2MSFTNGP09.phx.gbl...
> Greetings.
> I want to create a tree control which will list all the employees in an
> employee table in the correct hierarchy like
> <company>
> managers
> sub managers
> employees
>
> For that, how can I setup reflective linking (linking ot the same table)
> in SQL server and how can I populate the tree control from it ?
> Thanks!
>|||Get a copy of TREES & HIERARCHIES IN SQL for details, but look up the
"nested set model" on Google. There is no need for self-referencing
tables, recursion or procedural code.

Reflective linking

Greetings.
I want to create a tree control which will list all the employees in an
employee table in the correct hierarchy like
<company>
managers
sub managers
employees
For that, how can I setup reflective linking (linking ot the same table) in
SQL server and how can I populate the tree control from it ?
Thanks!You may have a look here:
(Quelle:
_5yk3.asp" target="_blank">http://msdn.microsoft.com/library/d...r />
_5yk3.asp)
But the main part to populate the tree should be implemented in your
frontend apllication. The best thing would be to set up some recursive
function which alway try to first retrieve the "manager" and the search for
the next level, and so on.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"news.microsoft.com" <v-hshah@.microsoft.com> schrieb im Newsbeitrag
news:%23uukSelZFHA.3364@.TK2MSFTNGP09.phx.gbl...
> Greetings.
> I want to create a tree control which will list all the employees in an
> employee table in the correct hierarchy like
> <company>
> managers
> sub managers
> employees
>
> For that, how can I setup reflective linking (linking ot the same table)
> in SQL server and how can I populate the tree control from it ?
> Thanks!
>|||Get a copy of TREES & HIERARCHIES IN SQL for details, but look up the
"nested set model" on Google. There is no need for self-referencing
tables, recursion or procedural code.

Wednesday, March 21, 2012

Referring to report items

Hi,
Is there any way to directly access a value contained in, for example, a
textbox?
If I were to create a textbox ('textbox1') with a default 'value' attribute
of "Hello World!", how would I make 'textbox2' get the value of 'textbox1'
and set its own 'value' to equal it?
I thought maybe it would be something like an expression in textbox2 along
the lines of: "=Controls!textbox1.Value"
Of course, I can see problems if controls aren't rendered etc, but I thought
I'd ask.
Thanks,
CraigTry =ReportItems!textbox1.Value
Regards,
Davy Ramirez
Winsight - Paris
http://www.winsight.fr
"CraigyBoop" <CraigyBoop@.discussions.microsoft.com> wrote in message
news:34FA58AE-092E-42F7-B371-CAC59F9E0568@.microsoft.com...
> Hi,
> Is there any way to directly access a value contained in, for example, a
> textbox?
> If I were to create a textbox ('textbox1') with a default 'value'
attribute
> of "Hello World!", how would I make 'textbox2' get the value of 'textbox1'
> and set its own 'value' to equal it?
> I thought maybe it would be something like an expression in textbox2 along
> the lines of: "=Controls!textbox1.Value"
> Of course, I can see problems if controls aren't rendered etc, but I
thought
> I'd ask.
> Thanks,
> Craig|||Please see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rscreate/htm/rcr_creating_expressions_v1_7ilv.asp
for more information about ReportItems and Globals in general.
--
Bruce Johnson [MSFT]
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Davy Ramirez" <davy.ramirez.removethis@.winsight.fr> wrote in message
news:%23gr%23UsssEHA.820@.TK2MSFTNGP12.phx.gbl...
> Try =ReportItems!textbox1.Value
> Regards,
> Davy Ramirez
> Winsight - Paris
> http://www.winsight.fr
> "CraigyBoop" <CraigyBoop@.discussions.microsoft.com> wrote in message
> news:34FA58AE-092E-42F7-B371-CAC59F9E0568@.microsoft.com...
>> Hi,
>> Is there any way to directly access a value contained in, for example, a
>> textbox?
>> If I were to create a textbox ('textbox1') with a default 'value'
> attribute
>> of "Hello World!", how would I make 'textbox2' get the value of
>> 'textbox1'
>> and set its own 'value' to equal it?
>> I thought maybe it would be something like an expression in textbox2
>> along
>> the lines of: "=Controls!textbox1.Value"
>> Of course, I can see problems if controls aren't rendered etc, but I
> thought
>> I'd ask.
>> Thanks,
>> Craig
>

Refering Local DB Tables from Master Procedures

Hi,
I am facing a problem while reading user database tables from a procedure in
the master database.
Example.
create procedure sp_Test
as
select count(*) from syscolumns
select count(*) from UserTable
go
I granted public access to this procedure in the master database.
When I execute the procedure in Query Analyzer with master DB, it is pulling
the record counts from the master tables.
When I execute it for some other user database, it returns the count of
records from syscolumn tables of that local database, but still takes the
count from UserTable of master database. It does not take the count from the
local database.
Could anyone help me know, if there is any setting, to point to the local
database instead of master while refering user tables (for system tables it
takes from local databases). Version : SQL Server 2000
Thanks and Regards,
Prasanth
HI
USE master
GO
ALTER procedure sp_Test @.dbname as sysname, @.UserTable as sysname
as
DECLARE @.strSQL as nvarchar(100)
set @.strSQL = 'select count(*) from ' + @.UserTable
select count(*) from syscolumns
EXECUTE sp_executesql @.strSQL
GO
USE pubs
GO
sp_test 'pubs', 'employee'
GO
Andras Jakus MCDBA
"Prasanth" wrote:

> Hi,
> I am facing a problem while reading user database tables from a procedure in
> the master database.
> Example.
> create procedure sp_Test
> as
> select count(*) from syscolumns
> select count(*) from UserTable
> go
> I granted public access to this procedure in the master database.
> When I execute the procedure in Query Analyzer with master DB, it is pulling
> the record counts from the master tables.
> When I execute it for some other user database, it returns the count of
> records from syscolumn tables of that local database, but still takes the
> count from UserTable of master database. It does not take the count from the
> local database.
> Could anyone help me know, if there is any setting, to point to the local
> database instead of master while refering user tables (for system tables it
> takes from local databases). Version : SQL Server 2000
> --
> Thanks and Regards,
> Prasanth
|||Thanks for the reply Andras,
Currently I am using the procedure as you have given.
Is there any way I can directly query user tables just like system tables,
without passing the DB name and table names as parameters?
"Andras Jakus" wrote:
[vbcol=seagreen]
> HI
> USE master
> GO
> ALTER procedure sp_Test @.dbname as sysname, @.UserTable as sysname
> as
> DECLARE @.strSQL as nvarchar(100)
> set @.strSQL = 'select count(*) from ' + @.UserTable
> select count(*) from syscolumns
> EXECUTE sp_executesql @.strSQL
> GO
> USE pubs
> GO
> sp_test 'pubs', 'employee'
> GO
> Andras Jakus MCDBA
> "Prasanth" wrote:
|||HI
Try this, but without parameter you can use with onli one table name.
(The db name parameter in first procedure unnecessary)
ALTER procedure sp_Test
as
DECLARE @.strSQL as nvarchar(100)
set @.strSQL = 'select count(*) from dbo.employee'
select count(*) from syscolumns
EXECUTE sp_executesql @.strSQL
GO
Andras Jakus MCDBA
"Prasanth" wrote:
[vbcol=seagreen]
> Thanks for the reply Andras,
> Currently I am using the procedure as you have given.
> Is there any way I can directly query user tables just like system tables,
> without passing the DB name and table names as parameters?
> "Andras Jakus" wrote:

Refering Local DB Tables from Master Procedures

Hi,
I am facing a problem while reading user database tables from a procedure in
the master database.
Example.
create procedure sp_Test
as
select count(*) from syscolumns
select count(*) from UserTable
go
I granted public access to this procedure in the master database.
When I execute the procedure in Query Analyzer with master DB, it is pulling
the record counts from the master tables.
When I execute it for some other user database, it returns the count of
records from syscolumn tables of that local database, but still takes the
count from UserTable of master database. It does not take the count from the
local database.
Could anyone help me know, if there is any setting, to point to the local
database instead of master while refering user tables (for system tables it
takes from local databases). Version : SQL Server 2000
--
Thanks and Regards,
PrasanthHI
USE master
GO
ALTER procedure sp_Test @.dbname as sysname, @.UserTable as sysname
as
DECLARE @.strSQL as nvarchar(100)
set @.strSQL = 'select count(*) from ' + @.UserTable
select count(*) from syscolumns
EXECUTE sp_executesql @.strSQL
GO
USE pubs
GO
sp_test 'pubs', 'employee'
GO
Andras Jakus MCDBA
"Prasanth" wrote:
> Hi,
> I am facing a problem while reading user database tables from a procedure in
> the master database.
> Example.
> create procedure sp_Test
> as
> select count(*) from syscolumns
> select count(*) from UserTable
> go
> I granted public access to this procedure in the master database.
> When I execute the procedure in Query Analyzer with master DB, it is pulling
> the record counts from the master tables.
> When I execute it for some other user database, it returns the count of
> records from syscolumn tables of that local database, but still takes the
> count from UserTable of master database. It does not take the count from the
> local database.
> Could anyone help me know, if there is any setting, to point to the local
> database instead of master while refering user tables (for system tables it
> takes from local databases). Version : SQL Server 2000
> --
> Thanks and Regards,
> Prasanth|||Thanks for the reply Andras,
Currently I am using the procedure as you have given.
Is there any way I can directly query user tables just like system tables,
without passing the DB name and table names as parameters?
"Andras Jakus" wrote:
> HI
> USE master
> GO
> ALTER procedure sp_Test @.dbname as sysname, @.UserTable as sysname
> as
> DECLARE @.strSQL as nvarchar(100)
> set @.strSQL = 'select count(*) from ' + @.UserTable
> select count(*) from syscolumns
> EXECUTE sp_executesql @.strSQL
> GO
> USE pubs
> GO
> sp_test 'pubs', 'employee'
> GO
> Andras Jakus MCDBA
> "Prasanth" wrote:
> > Hi,
> > I am facing a problem while reading user database tables from a procedure in
> > the master database.
> > Example.
> > create procedure sp_Test
> > as
> > select count(*) from syscolumns
> > select count(*) from UserTable
> > go
> >
> > I granted public access to this procedure in the master database.
> > When I execute the procedure in Query Analyzer with master DB, it is pulling
> > the record counts from the master tables.
> > When I execute it for some other user database, it returns the count of
> > records from syscolumn tables of that local database, but still takes the
> > count from UserTable of master database. It does not take the count from the
> > local database.
> >
> > Could anyone help me know, if there is any setting, to point to the local
> > database instead of master while refering user tables (for system tables it
> > takes from local databases). Version : SQL Server 2000
> > --
> > Thanks and Regards,
> > Prasanth|||HI
Try this, but without parameter you can use with onli one table name.
(The db name parameter in first procedure unnecessary)
ALTER procedure sp_Test
as
DECLARE @.strSQL as nvarchar(100)
set @.strSQL = 'select count(*) from dbo.employee'
select count(*) from syscolumns
EXECUTE sp_executesql @.strSQL
GO
Andras Jakus MCDBA
"Prasanth" wrote:
> Thanks for the reply Andras,
> Currently I am using the procedure as you have given.
> Is there any way I can directly query user tables just like system tables,
> without passing the DB name and table names as parameters?
> "Andras Jakus" wrote:
> > HI
> > USE master
> > GO
> > ALTER procedure sp_Test @.dbname as sysname, @.UserTable as sysname
> > as
> >
> > DECLARE @.strSQL as nvarchar(100)
> >
> > set @.strSQL = 'select count(*) from ' + @.UserTable
> >
> > select count(*) from syscolumns
> > EXECUTE sp_executesql @.strSQL
> >
> > GO
> >
> > USE pubs
> > GO
> > sp_test 'pubs', 'employee'
> > GO
> >
> > Andras Jakus MCDBA
> >
> > "Prasanth" wrote:
> >
> > > Hi,
> > > I am facing a problem while reading user database tables from a procedure in
> > > the master database.
> > > Example.
> > > create procedure sp_Test
> > > as
> > > select count(*) from syscolumns
> > > select count(*) from UserTable
> > > go
> > >
> > > I granted public access to this procedure in the master database.
> > > When I execute the procedure in Query Analyzer with master DB, it is pulling
> > > the record counts from the master tables.
> > > When I execute it for some other user database, it returns the count of
> > > records from syscolumn tables of that local database, but still takes the
> > > count from UserTable of master database. It does not take the count from the
> > > local database.
> > >
> > > Could anyone help me know, if there is any setting, to point to the local
> > > database instead of master while refering user tables (for system tables it
> > > takes from local databases). Version : SQL Server 2000
> > > --
> > > Thanks and Regards,
> > > Prasanthsql

Referential integrity constraints on indexed views

Hi
I was wondering whether we can create referential integrity constraints on
indexed views in SQL Server 2000. We are trying to create a data model and
would like to know whether we can enforce constraints on indexed views,
otherwise we may have to go for tables.
Please inform.
Thanks
BobBob,
Not that I'm aware of - never seen anyone add a constraint to a
view(indexed). Would probably have to handle this at the table level with
constraints or triggers.
HTH
Jerry
"Bob" <Bob@.discussions.microsoft.com> wrote in message
news:B911616E-39CC-4879-B485-58ED9E951E23@.microsoft.com...
> Hi
> I was wondering whether we can create referential integrity constraints on
> indexed views in SQL Server 2000. We are trying to create a data model and
> would like to know whether we can enforce constraints on indexed views,
> otherwise we may have to go for tables.
> Please inform.
> Thanks
> Bob|||The indexed view ultimately gets it data from the underlying tables. So if
they have the proper constraints the view will never see incorrect data.
Andrew J. Kelly SQL MVP
"Bob" <Bob@.discussions.microsoft.com> wrote in message
news:B911616E-39CC-4879-B485-58ED9E951E23@.microsoft.com...
> Hi
> I was wondering whether we can create referential integrity constraints on
> indexed views in SQL Server 2000. We are trying to create a data model and
> would like to know whether we can enforce constraints on indexed views,
> otherwise we may have to go for tables.
> Please inform.
> Thanks
> Bob

Referential integrity constraints on indexed views

Hi
I was wondering whether we can create referential integrity constraints on
indexed views in SQL Server 2000. We are trying to create a data model and
would like to know whether we can enforce constraints on indexed views,
otherwise we may have to go for tables.
Please inform.
Thanks
BobBob,
Not that I'm aware of - never seen anyone add a constraint to a
view(indexed). Would probably have to handle this at the table level with
constraints or triggers.
HTH
Jerry
"Bob" <Bob@.discussions.microsoft.com> wrote in message
news:B911616E-39CC-4879-B485-58ED9E951E23@.microsoft.com...
> Hi
> I was wondering whether we can create referential integrity constraints on
> indexed views in SQL Server 2000. We are trying to create a data model and
> would like to know whether we can enforce constraints on indexed views,
> otherwise we may have to go for tables.
> Please inform.
> Thanks
> Bob|||The indexed view ultimately gets it data from the underlying tables. So if
they have the proper constraints the view will never see incorrect data.
--
Andrew J. Kelly SQL MVP
"Bob" <Bob@.discussions.microsoft.com> wrote in message
news:B911616E-39CC-4879-B485-58ED9E951E23@.microsoft.com...
> Hi
> I was wondering whether we can create referential integrity constraints on
> indexed views in SQL Server 2000. We are trying to create a data model and
> would like to know whether we can enforce constraints on indexed views,
> otherwise we may have to go for tables.
> Please inform.
> Thanks
> Bob