Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Sunday, March 25, 2012

Adding a constraint question

Can you add a constraint using the below syntax but to check whether a field
has only numeric digits?
So that if Threshold was updated to say 'marc1' it would fail.
ALTER TABLE misre_threshold WITH NOCHECK
ADD CONSTRAINT Threshold CHECK (Threshold in ('Y','N'))Something like this?
ALTER TABLE misre_threshold WITH NOCHECK
ADD CONSTRAINT Threshold_Const CHECK (isnumeric(Threshold) = 1)
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/
"marcmc" wrote:

> Can you add a constraint using the below syntax but to check whether a fie
ld
> has only numeric digits?
> So that if Threshold was updated to say 'marc1' it would fail.
> ALTER TABLE misre_threshold WITH NOCHECK
> ADD CONSTRAINT Threshold CHECK (Threshold in ('Y','N'))|||Try this:
...check (<column name> not like '%[^0-9]%')
ML
http://milambda.blogspot.com/|||thanks guys BUT
I tried the following:
but the Threshold Column is dataType money
ALTER TABLE misre_threshold WITH NOCHECK
ADD CONSTRAINT Threshold_Const CHECK (isnumeric(convert(money,Threshold)) =
1)
ALTER TABLE misre_threshold WITH NOCHECK
ADD CONSTRAINT Threshold_Const CHECK (Threshold not like '%[^0-9]%')
Server: Msg 257, Level 16, State 3, Line 1
Implicit conversion from data type money to varchar is not allowed. Use the
CONVERT function to run this query.|||Aha, I assumed it was a character column (you haven't mentioned the actual
data type).
Use CAST in the constraint:
ALTER TABLE misre_threshold WITH NOCHECK
ADD CONSTRAINT Threshold_Const CHECK (cast(Threshold as varchar(64)) not
like '%[^0-9]%')
ML
http://milambda.blogspot.com/|||By the way - have you checked out this nice article regarding the ISNUMERIC
function?
http://www.aspfaq.com/show.asp?id=2390
ML
http://milambda.blogspot.com/|||thanks that does build it but my .net application runs as follows and so
encounters an error, should i change my .net app? I would rather not.|||Thanks for that..
Kewl article.. But I am using 2000 SP4 and the results are different. But
some misses nevertheless.
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/
"ML" wrote:

> By the way - have you checked out this nice article regarding the ISNUMERI
C
> function?
> http://www.aspfaq.com/show.asp?id=2390
>
> ML
> --
> http://milambda.blogspot.com/|||Whenever a constraint is violated the SQL Server returns an error saying so,
and the error should be handled by the calling application. Isn't the
constraint already implemented on the application tier? Why not?
What exactly do you need?
An alternative is to use a trigger and simply rollback any transactions that
would otherwise violate the constraint, but this is IMHO a kludge, since the
data would not be inserted and the user would not be notified of this - in m
y
view - vital consequence.
ML
http://milambda.blogspot.com/|||I see your point.
I don't know what your exposure is to validating data on a datagrid within
.net but it aint pretty.
sample ddl,
What I want is the first update to break the constraint, the second should
not.
create table marc(
ThresholdType varchar(6),
Threshold money)
insert into marc values('RecEst', 20000.00)
ALTER TABLE marc WITH NOCHECK
ADD CONSTRAINT Threshold CHECK (cast(Threshold as varchar(64)) not
like '%[^0-9]%')
select * from marc
update marc set Threshold = 'marc1' where ThresholdType = 'RecEst'
update marc set Threshold = 20001.00 where ThresholdType = 'RecEst'

Thursday, March 22, 2012

Adding a Column in the middle

Can someone give me the syntax for adding a column into
the middle of the table? I know how to do this in E.M,
but I need to script this.Hi,
You cannot add a new column in the middle of the table structure.
The only solution to add the column in the middle:-
1. Down load the data
2. Script the table structure and dependant objects like indexes, Triggers..
3. Recreate the table with new structure (Add the new column in the position
u require)
4. Execute the dependant objects scripts
Note:
If you add the new column using enterprise manager it does the above steps
in back end.
Thanks
Hari
MCDBA
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx
.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.|||Here is how to do it. This is exactly what EM does just to let you know. I
got this via using profiler. Basically I create a table first with three
column, a, b, and c. Then I wanted to add column d prior to c.
CREATE TABLE dbo.Tmp_Table3
(
a char(10) NULL,
b char(10) NULL,
d char(10) NULL,
c char(10) NULL
) ON [PRIMARY]
IF EXISTS(SELECT * FROM dbo.Table3)
EXEC('INSERT INTO dbo.Tmp_Table3 (a, b, c)
SELECT a, b, c FROM dbo.Table3 TABLOCKX')
DROP TABLE dbo.Table3
declare @.P1 int
set @.P1=0
declare @.P2 int
set @.P2=16388
declare @.P3 int
set @.P3=8193
declare @.P4 int
set @.P4=0
exec sp_cursoropen @.P1 output, N'EXECUTE sp_rename N''dbo.Tmp_Table3'',
N''Table3'', ''OBJECT''
', @.P2 output, @.P3 output, @.P4 output
select @.P1, @.P2, @.P3, @.P4
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx
.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.|||Watch what EM does behind the scenes. You can't just add a column to the
middle of the table (and not sure why you care where the column is anyway).
You have to drop the table and re-create it. An alternative is to create a
view with the columns defined in the correct order, but I still don't
understand why column order matters.
http://www.aspfaq.com/
(Reverse address to reply.)
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx
.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.

Adding a Column in the middle

Can someone give me the syntax for adding a column into
the middle of the table? I know how to do this in E.M,
but I need to script this.
Hi,
You cannot add a new column in the middle of the table structure.
The only solution to add the column in the middle:-
1. Down load the data
2. Script the table structure and dependant objects like indexes, Triggers..
3. Recreate the table with new structure (Add the new column in the position
u require)
4. Execute the dependant objects scripts
Note:
If you add the new column using enterprise manager it does the above steps
in back end.
Thanks
Hari
MCDBA
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.
|||Here is how to do it. This is exactly what EM does just to let you know. I
got this via using profiler. Basically I create a table first with three
column, a, b, and c. Then I wanted to add column d prior to c.
CREATE TABLE dbo.Tmp_Table3
(
a char(10) NULL,
b char(10) NULL,
d char(10) NULL,
c char(10) NULL
) ON [PRIMARY]
IF EXISTS(SELECT * FROM dbo.Table3)
EXEC('INSERT INTO dbo.Tmp_Table3 (a, b, c)
SELECT a, b, c FROM dbo.Table3 TABLOCKX')
DROP TABLE dbo.Table3
declare @.P1 int
set @.P1=0
declare @.P2 int
set @.P2=16388
declare @.P3 int
set @.P3=8193
declare @.P4 int
set @.P4=0
exec sp_cursoropen @.P1 output, N'EXECUTE sp_rename N''dbo.Tmp_Table3'',
N''Table3'', ''OBJECT''
', @.P2 output, @.P3 output, @.P4 output
select @.P1, @.P2, @.P3, @.P4
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.
|||Watch what EM does behind the scenes. You can't just add a column to the
middle of the table (and not sure why you care where the column is anyway).
You have to drop the table and re-create it. An alternative is to create a
view with the columns defined in the correct order, but I still don't
understand why column order matters.
http://www.aspfaq.com/
(Reverse address to reply.)
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.

Adding a Column in the middle

Can someone give me the syntax for adding a column into
the middle of the table? I know how to do this in E.M,
but I need to script this.Hi,
You cannot add a new column in the middle of the table structure.
The only solution to add the column in the middle:-
1. Down load the data
2. Script the table structure and dependant objects like indexes, Triggers..
3. Recreate the table with new structure (Add the new column in the position
u require)
4. Execute the dependant objects scripts
Note:
If you add the new column using enterprise manager it does the above steps
in back end.
Thanks
Hari
MCDBA
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.|||Here is how to do it. This is exactly what EM does just to let you know. I
got this via using profiler. Basically I create a table first with three
column, a, b, and c. Then I wanted to add column d prior to c.
CREATE TABLE dbo.Tmp_Table3
(
a char(10) NULL,
b char(10) NULL,
d char(10) NULL,
c char(10) NULL
) ON [PRIMARY]
IF EXISTS(SELECT * FROM dbo.Table3)
EXEC('INSERT INTO dbo.Tmp_Table3 (a, b, c)
SELECT a, b, c FROM dbo.Table3 TABLOCKX')
DROP TABLE dbo.Table3
declare @.P1 int
set @.P1=0
declare @.P2 int
set @.P2=16388
declare @.P3 int
set @.P3=8193
declare @.P4 int
set @.P4=0
exec sp_cursoropen @.P1 output, N'EXECUTE sp_rename N''dbo.Tmp_Table3'',
N''Table3'', ''OBJECT''
', @.P2 output, @.P3 output, @.P4 output
select @.P1, @.P2, @.P3, @.P4
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.|||Watch what EM does behind the scenes. You can't just add a column to the
middle of the table (and not sure why you care where the column is anyway).
You have to drop the table and re-create it. An alternative is to create a
view with the columns defined in the correct order, but I still don't
understand why column order matters.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"CurtM" <anonymous@.discussions.microsoft.com> wrote in message
news:17b0801c44985$bd9fa1d0$a301280a@.phx.gbl...
> Can someone give me the syntax for adding a column into
> the middle of the table? I know how to do this in E.M,
> but I need to script this.

Tuesday, March 6, 2012

Add Keywords to Query Analyzers Syntax

Does anyone know of a way to add *key words* to Query Analyzer's syntax
highlighting feature? I would think that there would be a text/xml file
that could be modified. This certainly can't be hard coded.

Thanks,
BryanI think you are going to be disappointed then. I know of no way to add
keywords in the way you want.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"Bryan Bullard" <reply@.to.group.com> wrote in message
news:zBylc.6707$l_1.5292@.newssvr23.news.prodigy.co m...
> Does anyone know of a way to add *key words* to Query Analyzer's syntax
> highlighting feature? I would think that there would be a text/xml file
> that could be modified. This certainly can't be hard coded.
> Thanks,
> Bryan|||"Allan Mitchell" <allan@.no-spam.sqldts.com> wrote in message
news:4096bd6a$0$31706$fa0fcedb@.lovejoy.zen.co.uk.. .
> I know of no way to add keywords in the way you want.

Then do you know of another way?|||Bryan Bullard (reply@.to.group.com) writes:
> Does anyone know of a way to add *key words* to Query Analyzer's syntax
> highlighting feature? I would think that there would be a text/xml file
> that could be modified. This certainly can't be hard coded.

There is no way to change the list of highlighted words. I would actually
guess that the list is hardcoded. After all, QA is to designed against a
certain version of SQL Server, so new keywords are not likely to appear
out of the blue. :-)

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Bryan,

It seems that the keywords are contained in the file
"../tools/binn/sqllex.dll" -- part of which appears in plain-text. For fun,
I tried the following command from a Linux prompt (after backing up the
file):

sed 's/CHECKALLOC/RICHDILLON/' sqllex.dll > new.dll

... and then renamed the new file. Sure enough, QA stopped highlighing
"CHECKALLOC" in blue. Sadly, it wouldn't highlight my name, though. :-(
There must be something important about the rest of the gobbledygook in that
file ;-)

Rich

"Bryan Bullard" <reply@.to.group.com> wrote in message
news:zBylc.6707$l_1.5292@.newssvr23.news.prodigy.co m...
> Does anyone know of a way to add *key words* to Query Analyzer's syntax
> highlighting feature? I would think that there would be a text/xml file
> that could be modified. This certainly can't be hard coded.
> Thanks,
> Bryan|||

Quote:

Originally Posted by Erland Sommarskog

Bryan Bullard (reply@.to.group.com) writes:
> Does anyone know of a way to add *key words* to Query Analyzer's syntax
> highlighting feature? I would think that there would be a text/xml file
> that could be modified. This certainly can't be hard coded.

There is no way to change the list of highlighted words. I would actually
guess that the list is hardcoded. After all, QA is to designed against a
certain version of SQL Server, so new keywords are not likely to appear
out of the blue. :-)

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

It's actually hardcoded, and found this out the hardway when a dll was no longer registered.
the syntax highlighting functionality is done by a dll named sqllex.dll that is typically found in the C:\Program Files\Microsoft SQL Server\80\Tools\Binn directory;
if you unregister the dll, you'll lose the syntax highlighting completely; re-registering it restores the functionality, which i discovered when uninstalling/reinstalling after a beta of SQL 2005.
because the list of keywords is in the DLL, and not in a file the DLL uses, there's no way to ADD keywords unless you could replace that dll with your own enhanced verison.
HTH.

Add Keywords to Query Analyzers Syntax

Does anyone know of a way to add *key words* to Query Analyzer's syntax
highlighting feature? I would think that there would be a text/xml file
that could be modified. This certainly can't be hard coded.

Thanks,
BryanI think you are going to be disappointed then. I know of no way to add
keywords in the way you want.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"Bryan Bullard" <reply@.to.group.com> wrote in message
news:zBylc.6707$l_1.5292@.newssvr23.news.prodigy.co m...
> Does anyone know of a way to add *key words* to Query Analyzer's syntax
> highlighting feature? I would think that there would be a text/xml file
> that could be modified. This certainly can't be hard coded.
> Thanks,
> Bryan|||"Allan Mitchell" <allan@.no-spam.sqldts.com> wrote in message
news:4096bd6a$0$31706$fa0fcedb@.lovejoy.zen.co.uk.. .
> I know of no way to add keywords in the way you want.

Then do you know of another way?|||Bryan Bullard (reply@.to.group.com) writes:
> Does anyone know of a way to add *key words* to Query Analyzer's syntax
> highlighting feature? I would think that there would be a text/xml file
> that could be modified. This certainly can't be hard coded.

There is no way to change the list of highlighted words. I would actually
guess that the list is hardcoded. After all, QA is to designed against a
certain version of SQL Server, so new keywords are not likely to appear
out of the blue. :-)

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Bryan,

It seems that the keywords are contained in the file
"../tools/binn/sqllex.dll" -- part of which appears in plain-text. For fun,
I tried the following command from a Linux prompt (after backing up the
file):

sed 's/CHECKALLOC/RICHDILLON/' sqllex.dll > new.dll

... and then renamed the new file. Sure enough, QA stopped highlighing
"CHECKALLOC" in blue. Sadly, it wouldn't highlight my name, though. :-(
There must be something important about the rest of the gobbledygook in that
file ;-)

Rich

"Bryan Bullard" <reply@.to.group.com> wrote in message
news:zBylc.6707$l_1.5292@.newssvr23.news.prodigy.co m...
> Does anyone know of a way to add *key words* to Query Analyzer's syntax
> highlighting feature? I would think that there would be a text/xml file
> that could be modified. This certainly can't be hard coded.
> Thanks,
> Bryan

Saturday, February 25, 2012

Add Informix linked server

I used the following syntax and was able to add a linked server to an
Informix database.
EXEC sp_addlinkedserver
@.server = 'Server1', -- defined in
-- SetNet32 on tab 'Server information',
-- field 'Informix Server'
@.provider = 'MSDASQL', -- DO NOT CHANGE !
@.datasrc = 'jaco', -- name of the
-- ODBC connection defined in step 3
@.srvproduct = 'Informix-CLI 3.12 (32 bit)';
Server1 is the Informix host defined in Setnet32. When I run the script, the
linked server is named after the host, that is "server1" However, this link
points to a single database defined in the datasource "jaco"
now I need to rename the Linked server "Server1" to something else so that I
can add another linked server using another datasource (wfi, for example).
1. How can I rename a linked server?
2. I ran "SELECT * FROM Server1.jaco.owner.station and got this error
message:
Server: Msg 7312, Level 16, State 1, Line 1
Invalid use of schema and/or catalog for OLE DB provider 'MSDASQL'. A
four-part name was supplied, but the provider does not expose the necessary
interfaces to use a catalog and/or schema.
OLE DB error trace [Non-interface error].
Any help is greatly appreciated.
Thanks
BillBill,
1. I think you can change the linked server name with sp_setnetname. Try it.
2. Try using OPENQUERY() instead.
Jon Jahren
"Bill Nguyen" <billn_nospam_please@.jaco.com> wrote in message
news:#aRY0YFyEHA.1984@.TK2MSFTNGP14.phx.gbl...
> I used the following syntax and was able to add a linked server to an
> Informix database.
> EXEC sp_addlinkedserver
> @.server = 'Server1', -- defined in
> -- SetNet32 on tab 'Server information',
> -- field 'Informix Server'
> @.provider = 'MSDASQL', -- DO NOT CHANGE !
> @.datasrc = 'jaco', -- name of the
> -- ODBC connection defined in step 3
> @.srvproduct = 'Informix-CLI 3.12 (32 bit)';
> Server1 is the Informix host defined in Setnet32. When I run the script,
the
> linked server is named after the host, that is "server1" However, this
link
> points to a single database defined in the datasource "jaco"
> now I need to rename the Linked server "Server1" to something else so that
I
> can add another linked server using another datasource (wfi, for example).
> 1. How can I rename a linked server?
> 2. I ran "SELECT * FROM Server1.jaco.owner.station and got this error
> message:
> Server: Msg 7312, Level 16, State 1, Line 1
> Invalid use of schema and/or catalog for OLE DB provider 'MSDASQL'. A
> four-part name was supplied, but the provider does not expose the
necessary
> interfaces to use a catalog and/or schema.
> OLE DB error trace [Non-interface error].
>
> Any help is greatly appreciated.
> Thanks
> Bill
>
>
>|||Jon;
I think I dis something wrong now that I can't even establish the linked
server.
I followed the instructions fromt his page:
[url]http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=243&lngWId=5[/
url]
This worked the first time in establishing the linked server. I was able to
click on Tables & Views tabs of the linked server and see all the tables in
the linked (Informix) server.
However, I wasn't able to extract data from it.
I went on the to next step following the example below:
5. Now, you have to map logins from SQL server to logins on Informix server.
Execute statement:
EXEC sp_addlinkedsrvlogin 'PNDON7', 'false', 'sa', 'login_name', 'password'
You have to put your machine login name and password of course.
I was confused as to which login_name and password to use, so I used the
login name & password I always used to access Informix database (on linked
server).
After executing this sp_addlinkedsrvlogin, I wasn't able to do anything.
Clicking on the linked server Tables or Views tab generated an error message
regarding 'sa" passowrd error.
How do I go to cleanup all this mess and start a new?
Thanks
Bill
"Jon Jahren" <jon.jahren.fightspam@.sqlkompetanse.no> wrote in message
news:%23dU888JyEHA.1396@.tk2msftngp13.phx.gbl...
> Bill,
> 1. I think you can change the linked server name with sp_setnetname. Try
it.
> 2. Try using OPENQUERY() instead.
> Jon Jahren
> "Bill Nguyen" <billn_nospam_please@.jaco.com> wrote in message
> news:#aRY0YFyEHA.1984@.TK2MSFTNGP14.phx.gbl...
> the
> link
that[vbcol=seagreen]
> I
example).[vbcol=seagreen]
> necessary
>

Add Informix linked server

I used the following syntax and was able to add a linked server to an
Informix database.
EXEC sp_addlinkedserver
@.server = 'Server1', -- defined in
-- SetNet32 on tab 'Server information',
-- field 'Informix Server'
@.provider = 'MSDASQL', -- DO NOT CHANGE !
@.datasrc = 'jaco', -- name of the
-- ODBC connection defined in step 3
@.srvproduct = 'Informix-CLI 3.12 (32 bit)';
Server1 is the Informix host defined in Setnet32. When I run the script, the
linked server is named after the host, that is "server1" However, this link
points to a single database defined in the datasource "jaco"
now I need to rename the Linked server "Server1" to something else so that I
can add another linked server using another datasource (wfi, for example).
1. How can I rename a linked server?
2. I ran "SELECT * FROM Server1.jaco.owner.station and got this error
message:
Server: Msg 7312, Level 16, State 1, Line 1
Invalid use of schema and/or catalog for OLE DB provider 'MSDASQL'. A
four-part name was supplied, but the provider does not expose the necessary
interfaces to use a catalog and/or schema.
OLE DB error trace [Non-interface error].
Any help is greatly appreciated.
Thanks
Bill
Bill,
1. I think you can change the linked server name with sp_setnetname. Try it.
2. Try using OPENQUERY() instead.
Jon Jahren
"Bill Nguyen" <billn_nospam_please@.jaco.com> wrote in message
news:#aRY0YFyEHA.1984@.TK2MSFTNGP14.phx.gbl...
> I used the following syntax and was able to add a linked server to an
> Informix database.
> EXEC sp_addlinkedserver
> @.server = 'Server1', -- defined in
> -- SetNet32 on tab 'Server information',
> -- field 'Informix Server'
> @.provider = 'MSDASQL', -- DO NOT CHANGE !
> @.datasrc = 'jaco', -- name of the
> -- ODBC connection defined in step 3
> @.srvproduct = 'Informix-CLI 3.12 (32 bit)';
> Server1 is the Informix host defined in Setnet32. When I run the script,
the
> linked server is named after the host, that is "server1" However, this
link
> points to a single database defined in the datasource "jaco"
> now I need to rename the Linked server "Server1" to something else so that
I
> can add another linked server using another datasource (wfi, for example).
> 1. How can I rename a linked server?
> 2. I ran "SELECT * FROM Server1.jaco.owner.station and got this error
> message:
> Server: Msg 7312, Level 16, State 1, Line 1
> Invalid use of schema and/or catalog for OLE DB provider 'MSDASQL'. A
> four-part name was supplied, but the provider does not expose the
necessary
> interfaces to use a catalog and/or schema.
> OLE DB error trace [Non-interface error].
>
> Any help is greatly appreciated.
> Thanks
> Bill
>
>
>
|||Jon;
I think I dis something wrong now that I can't even establish the linked
server.
I followed the instructions fromt his page:
http://www.planet-source-code.com/vb...d=243&lngWId=5
This worked the first time in establishing the linked server. I was able to
click on Tables & Views tabs of the linked server and see all the tables in
the linked (Informix) server.
However, I wasn't able to extract data from it.
I went on the to next step following the example below:
5. Now, you have to map logins from SQL server to logins on Informix server.
Execute statement:
EXEC sp_addlinkedsrvlogin 'PNDON7', 'false', 'sa', 'login_name', 'password'
You have to put your machine login name and password of course.
I was confused as to which login_name and password to use, so I used the
login name & password I always used to access Informix database (on linked
server).
After executing this sp_addlinkedsrvlogin, I wasn't able to do anything.
Clicking on the linked server Tables or Views tab generated an error message
regarding 'sa" passowrd error.
How do I go to cleanup all this mess and start a new?
Thanks
Bill
"Jon Jahren" <jon.jahren.fightspam@.sqlkompetanse.no> wrote in message
news:%23dU888JyEHA.1396@.tk2msftngp13.phx.gbl...
> Bill,
> 1. I think you can change the linked server name with sp_setnetname. Try
it.[vbcol=seagreen]
> 2. Try using OPENQUERY() instead.
> Jon Jahren
> "Bill Nguyen" <billn_nospam_please@.jaco.com> wrote in message
> news:#aRY0YFyEHA.1984@.TK2MSFTNGP14.phx.gbl...
> the
> link
that[vbcol=seagreen]
> I
example).
> necessary
>

Friday, February 24, 2012

Add composite primary key

I'm a bit unclear on the syntax to add a composite (multiple columns)
primary key to a table. The columns already exist. Thanks.ALTER TABLE dbo.TableName ADD CONSTRAINT
PK_ConstraintName PRIMARY KEY NONCLUSTERED
(
Col1,
Col2
) ON [PRIMARY]
When in doubt, you can always perform the action in Enterprise Manager
and then look at the change script to help clear up basic syntax
things.
HTH,
Stu|||Do:
ALTER TABLE tbl ADD CONSTRAINT pk PRIMARY KEY ( col1, col2 )
Anith|||Roughly this at table creation:
CONSTRAINT PK_NameIt PRIMARY KEY CLUSTERED (Column1, Column2, Column3)
Obviously if you need a NONCLUSTERED PK, use that syntax instead.
Mark
"Rick Charnes" <rickxyz--nospam.zyxcharnes@.thehartford.com> wrote in message
news:MPG.1dc2cab9b0d541d8989902@.msnews.microsoft.com...
> I'm a bit unclear on the syntax to add a composite (multiple columns)
> primary key to a table. The columns already exist. Thanks.

Add column with variable name

HI!

Im trying to use an stored procedure to add a new column.
The problem is that the column name is stored in a variable, and I get syntax error.

Here is my code:

CREATE PROCEDURE test AS
declare @.colname as varchar(10)

set @.colname = 'new_col'

alter table prueba add @.colname int

And here is the error I get:
Error 170: Line 6 Incorrect syntax near '@.colname'

Any idea?Originally posted by soy_lore_lore
HI!

Im trying to use an stored procedure to add a new column.
The problem is that the column name is stored in a variable, and I get syntax error.

Here is my code:

CREATE PROCEDURE test AS
declare @.colname as varchar(10)

set @.colname = 'new_col'

alter table prueba add @.colname int

And here is the error I get:
Error 170: Line 6 Incorrect syntax near '@.colname'

Any idea?

Try this:

exec('alter table prueba add '+@.colname+' int')|||Originally posted by snail
Try this:

exec('alter table prueba add '+@.colname+' int')

THANKS!

Sunday, February 19, 2012

Add Column to a View

I am trying to add a NEW Column to a view
Here is the syntax I am using
ALTER VIEW AFS_INDEX
ADD Value varchar(30)
Can some one tell me what I am doing wrong and what is the correct way of
doing this
ThanksPlease refer to BOL for syntax questions. ALTER VIEW cannot be used in the
same manner as ALTER TABLE.|||You should be adding to one of the base table that define the view, not
altering the view itself.
"Chrismkr" wrote:

> I am trying to add a NEW Column to a view
> Here is the syntax I am using
> ALTER VIEW AFS_INDEX
> ADD Value varchar(30)
> Can some one tell me what I am doing wrong and what is the correct way of
> doing this
> Thanks
>|||Alter view works exactly the same as create view, but completely different
from alter table.
When you alter a view or stored procedure you actually recreate it, but
leave the permissions in place. So use alter view just as you would create
view.
"Chrismkr" <Chrismkr@.discussions.microsoft.com> wrote in message
news:7B76CA24-E9C3-423D-9C22-0F6A6B58D8A8@.microsoft.com...
> I am trying to add a NEW Column to a view
> Here is the syntax I am using
> ALTER VIEW AFS_INDEX
> ADD Value varchar(30)
> Can some one tell me what I am doing wrong and what is the correct way of
> doing this
> Thanks
>

Thursday, February 9, 2012

actual syntax by tracing

Hello

I am running 6.5 sql and work with a traffic and billing software ( called NOvar) from another company(encoda system) which does a lot of scheduling, reporting etc

I dont know the contents of table (100 table ) and their column
or which table its querying to take out reports

Can i create a trace to know the syntax each time some thing is executed.

I also need to create customized reports, can this be done by sql reporting or does i need to go from crystal reports or someone else
For i dont know any language except sql and HTML

sejDO you have SQL Server Client side tools installed?|||Yes i do have that installed