Showing posts with label userid. Show all posts
Showing posts with label userid. Show all posts

Tuesday, March 27, 2012

ConCat data

I need to create a csv file where it's just one giant file.
There is only one field I pull from a table called USerID(Char8). Then for
every record in the table create a file like this.
Receipents-c/n=XXXXX%Receipents-c/n=XXXXXReceipents-c/n=XXXXXReceipents-c/n=
XXXXX This will then Import into Exchange for a Distrubution List. Any IdeasSee if this link gives you some ideas
http://www.rac4sql.net/xp_execresultset.asp
Anith|||Would that not put each order on a separate line.
I need it all strung together ..as one big file...
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:%23QJSioLBFHA.936@.TK2MSFTNGP12.phx.gbl...
> See if this link gives you some ideas
> http://www.rac4sql.net/xp_execresultset.asp
> --
> Anith
>|||Anith has pointed you to a trick to create a file for each record/row for
your table.
Look like you want to concatenate the rows into a single string? If so, it's
probably best to do it from the client side (i.e. vb/script/etc).
Though, I am bit about your comment regarding CSV in your first
post. Perhaps, you want to clarify so we can help.
-oj
"HoosBruin" <Hoosbruin@.Kconline.com> wrote in message
news:L92dnbdsqJ2N6WTcRVn-gg@.kconline.com...
> Would that not put each order on a separate line.
> I need it all strung together ..as one big file...
>
> "Anith Sen" <anith@.bizdatasolutions.com> wrote in message
> news:%23QJSioLBFHA.936@.TK2MSFTNGP12.phx.gbl...
>|||sorry .. I just meant to have a csv extension to the filename.
do you have an example vbscript to concat these records from the sql table
?
thanks again.
"oj" <nospam_ojngo@.home.com> wrote in message
news:%23C0Ko0MBFHA.3492@.TK2MSFTNGP12.phx.gbl...
> Anith has pointed you to a trick to create a file for each record/row for
> your table.
> Look like you want to concatenate the rows into a single string? If so,
> it's probably best to do it from the client side (i.e. vb/script/etc).
> Though, I am bit about your comment regarding CSV in your first
> post. Perhaps, you want to clarify so we can help.
> --
> -oj
>
> "HoosBruin" <Hoosbruin@.Kconline.com> wrote in message
> news:L92dnbdsqJ2N6WTcRVn-gg@.kconline.com...
>|||Here is a vbscript.
Main()
Sub Main()
Dim sqlcnt,rs,s
s="Begin"
Set cntsql = CreateObject("ADODB.Connection")
With cntsql
.provider = "SQLOLEDB"
.connectionstring = "Data Source=.\dev;integrated security=SSPI"
.Open
Set rs = .Execute("select OrderID from Northwind..Orders")
Do Until rs.EOF
s = s & rs.Fields("OrderID") & ","
rs.MoveNext
Loop
.Close
End With
Set rs = Nothing
Set cntsql = Nothing
s = s & "End"
Call WriteToFile(s)
End Sub
Function WriteToFile(s)
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("c:\test.csv", True)
tf.Write(s)
tf.Close()
Set fso= Nothing
Set tf= Nothing
End Function
-oj
"HoosBruin" <Hoosbruin@.Kconline.com> wrote in message
news:ZLydnddhH-JSVWTcRVn-tw@.kconline.com...
> sorry .. I just meant to have a csv extension to the filename.
> do you have an example vbscript to concat these records from the sql table
> ?
> thanks again.
>
> "oj" <nospam_ojngo@.home.com> wrote in message
> news:%23C0Ko0MBFHA.3492@.TK2MSFTNGP12.phx.gbl...
>|||Thanks again.
"oj" <nospam_ojngo@.home.com> wrote in message
news:uyuNXkQBFHA.3368@.TK2MSFTNGP10.phx.gbl...
> Here is a vbscript.
> Main()
> Sub Main()
> Dim sqlcnt,rs,s
> s="Begin"
> Set cntsql = CreateObject("ADODB.Connection")
> With cntsql
> .provider = "SQLOLEDB"
> .connectionstring = "Data Source=.\dev;integrated security=SSPI"
> .Open
> Set rs = .Execute("select OrderID from Northwind..Orders")
> Do Until rs.EOF
> s = s & rs.Fields("OrderID") & ","
> rs.MoveNext
> Loop
> .Close
> End With
> Set rs = Nothing
> Set cntsql = Nothing
> s = s & "End"
> Call WriteToFile(s)
> End Sub
> Function WriteToFile(s)
> Dim fso, tf
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set tf = fso.CreateTextFile("c:\test.csv", True)
> tf.Write(s)
> tf.Close()
> Set fso= Nothing
> Set tf= Nothing
> End Function
>
> --
> -oj
>
> "HoosBruin" <Hoosbruin@.Kconline.com> wrote in message
> news:ZLydnddhH-JSVWTcRVn-tw@.kconline.com...
>|||oj The script worked great but...
The problem I'm having it puts an extra %Recipients/cn= at the end of the
file. The Import process that is using this output fails on this bogus
record since it doesn't have an ID attached. How can I remove this last
record from the file if it doesn't have a valid record.
"HoosBruin" <Hoosbruin@.Kconline.com> wrote in message
news:msKdnbiYuoaxv2fcRVn-vw@.kconline.com...
> Thanks again.
>
>
> "oj" <nospam_ojngo@.home.com> wrote in message
> news:uyuNXkQBFHA.3368@.TK2MSFTNGP10.phx.gbl...
>|||You would need to check the returned value before concatenating it in your
vbscript.
e.g.
if rs("your_keycol")="abc" then
'it is good and concatenate
else
'it is bad and ignore
endif
Take a look at this site for help on vbscripting
http://msdn.microsoft.com/library/e...me=true

-oj
"HoosBruin" <Hoosbruin@.Kconline.com> wrote in message
news:g5WdnagRsbodGpzfRVn-2A@.kconline.com...
> oj The script worked great but...
> The problem I'm having it puts an extra %Recipients/cn= at the end of the
> file. The Import process that is using this output fails on this bogus
> record since it doesn't have an ID attached. How can I remove this last
> record from the file if it doesn't have a valid record.
>
>
> "HoosBruin" <Hoosbruin@.Kconline.com> wrote in message
> news:msKdnbiYuoaxv2fcRVn-vw@.kconline.com...
>

Sunday, March 25, 2012

computer name access sql server

Is there a way to determine which workstation is accessing the SQL server? I
know in SQL Profile you can see the userid but can you see what actualy
workstation is accessing the server?I found it
sp_who, tells me everything I need to know,
thanks,
"Mike" <Mike@.community.nospam.com> wrote in message
news:u$gQtjPtHHA.4952@.TK2MSFTNGP04.phx.gbl...
> Is there a way to determine which workstation is accessing the SQL server?
> I know in SQL Profile you can see the userid but can you see what actualy
> workstation is accessing the server?
>|||On Jun 22, 11:12 am, "Mike" <M...@.community.nospam.com> wrote:
> Is there a way to determine which workstation is accessing the SQL server? I
> know in SQL Profile you can see the userid but can you see what actualy
> workstation is accessing the server?
select login_time as 'Login',
last_batch as 'Batch',
cast(status as varchar(12)) as 'Status',
cast(hostname as varchar(18)) as 'Host',
cast(program_name as varchar(32)) as 'Program',
cast(cmd as varchar(24)) as 'Command',
cast(nt_username as varchar(18)) as 'User',
cast(loginame as varchar(24)) as 'Login'
from sysprocesses
WHERE hostname<>''
order by nt_username;
go
http://www.sqlhacks.com/index.php/Administration/ListConnectedUsers
for examples and explanations
New this week:
How to drop the time portion of a DateTime column in MS SQL Server
How to get both the details and the subtotals with Microsoft SQL
Server
How to summarize data with Microsoft SQL Server
How to optimize Microsoft SQL Server
How to retrieve data with Microsoft SQL Server
How to get how many records are in all the tables of a Microsoft SQL
Server database
How to calculate grand totals with SQL Server with the GROUP BY WITH
ROLLUP
How to get the 3rd highest salary with MS SQL Server
How to number rows without using cursors with MS SQL Server 2005
How to rank rows by grouping without using cursors with SQL Server
with dense_rank
How to know who is connected to your server with SQL Server?
How to manually delete duplicate rows with MS SQL Server
How to delete duplicate rows in bulk with MS SQL Server
How to move TEMPDB to another drive in Microsoft SQL Server
Improvements to SQL Server indexes
How to increase the size of TEMPDB

computer name access sql server

Is there a way to determine which workstation is accessing the SQL server? I
know in SQL Profile you can see the userid but can you see what actualy
workstation is accessing the server?
I found it
sp_who, tells me everything I need to know,
thanks,
"Mike" <Mike@.community.nospam.com> wrote in message
news:u$gQtjPtHHA.4952@.TK2MSFTNGP04.phx.gbl...
> Is there a way to determine which workstation is accessing the SQL server?
> I know in SQL Profile you can see the userid but can you see what actualy
> workstation is accessing the server?
>
|||On Jun 22, 11:12 am, "Mike" <M...@.community.nospam.com> wrote:
> Is there a way to determine which workstation is accessing the SQL server? I
> know in SQL Profile you can see the userid but can you see what actualy
> workstation is accessing the server?
select login_time as 'Login',
last_batch as 'Batch',
cast(status as varchar(12)) as 'Status',
cast(hostname as varchar(18)) as 'Host',
cast(program_name as varchar(32)) as 'Program',
cast(cmd as varchar(24)) as 'Command',
cast(nt_username as varchar(18)) as 'User',
cast(loginame as varchar(24)) as 'Login'
from sysprocesses
WHERE hostname<>''
order by nt_username;
go
http://www.sqlhacks.com/index.php/Administration/ListConnectedUsers
for examples and explanations
New this week:
How to drop the time portion of a DateTime column in MS SQL Server
How to get both the details and the subtotals with Microsoft SQL
Server
How to summarize data with Microsoft SQL Server
How to optimize Microsoft SQL Server
How to retrieve data with Microsoft SQL Server
How to get how many records are in all the tables of a Microsoft SQL
Server database
How to calculate grand totals with SQL Server with the GROUP BY WITH
ROLLUP
How to get the 3rd highest salary with MS SQL Server
How to number rows without using cursors with MS SQL Server 2005
How to rank rows by grouping without using cursors with SQL Server
with dense_rank
How to know who is connected to your server with SQL Server?
How to manually delete duplicate rows with MS SQL Server
How to delete duplicate rows in bulk with MS SQL Server
How to move TEMPDB to another drive in Microsoft SQL Server
Improvements to SQL Server indexes
How to increase the size of TEMPDB
sqlsql

computer name access sql server

Is there a way to determine which workstation is accessing the SQL server? I
know in SQL Profile you can see the userid but can you see what actualy
workstation is accessing the server?I found it
sp_who, tells me everything I need to know,
thanks,
"Mike" <Mike@.community.nospam.com> wrote in message
news:u$gQtjPtHHA.4952@.TK2MSFTNGP04.phx.gbl...
> Is there a way to determine which workstation is accessing the SQL server?
> I know in SQL Profile you can see the userid but can you see what actualy
> workstation is accessing the server?
>|||On Jun 22, 11:12 am, "Mike" <M...@.community.nospam.com> wrote:
> Is there a way to determine which workstation is accessing the SQL server?
I
> know in SQL Profile you can see the userid but can you see what actualy
> workstation is accessing the server?
select login_time as 'Login',
last_batch as 'Batch',
cast(status as varchar(12)) as 'Status',
cast(hostname as varchar(18)) as 'Host',
cast(program_name as varchar(32)) as 'Program',
cast(cmd as varchar(24)) as 'Command',
cast(nt_username as varchar(18)) as 'User',
cast(loginame as varchar(24)) as 'Login'
from sysprocesses
WHERE hostname<>''
order by nt_username;
go
http://www.sqlhacks.com/index.php/A...tConnectedUsers
for examples and explanations
New this week:
How to drop the time portion of a DateTime column in MS SQL Server
How to get both the details and the subtotals with Microsoft SQL
Server
How to summarize data with Microsoft SQL Server
How to optimize Microsoft SQL Server
How to retrieve data with Microsoft SQL Server
How to get how many records are in all the tables of a Microsoft SQL
Server database
How to calculate grand totals with SQL Server with the GROUP BY WITH
ROLLUP
How to get the 3rd highest salary with MS SQL Server
How to number rows without using cursors with MS SQL Server 2005
How to rank rows by grouping without using cursors with SQL Server
with dense_rank
How to know who is connected to your server with SQL Server?
How to manually delete duplicate rows with MS SQL Server
How to delete duplicate rows in bulk with MS SQL Server
How to move TEMPDB to another drive in Microsoft SQL Server
Improvements to SQL Server indexes
How to increase the size of TEMPDB

Sunday, February 19, 2012

complete newbie

would someone me so good as to help me out with the script for a basic
customer table ? , usualy fields, userid (primary key) name, address,
creditcard number, card type, phone number, email address?

TIAHi

Look at

http://www.databaseanswers.org/data_models/index.htm

Regards
----------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@.epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"strawberry" <1@.2.com> wrote in message
news:6iA9e.13718$DU6.5013@.newsfe1-gui.ntli.net...
> would someone me so good as to help me out with the script for a basic
> customer table ? , usualy fields, userid (primary key) name, address,
> creditcard number, card type, phone number, email address?
>
> TIA